clang  7.0.0
TreeTransform.h
Go to the documentation of this file.
1 //===------- TreeTransform.h - Semantic Tree Transformation -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements a semantic tree transformation that takes a given
10 // AST and rebuilds it, possibly transforming some nodes in the process.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
15 #define LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
16 
17 #include "CoroutineStmtBuilder.h"
18 #include "TypeLocBuilder.h"
19 #include "clang/AST/Decl.h"
20 #include "clang/AST/DeclObjC.h"
21 #include "clang/AST/DeclTemplate.h"
22 #include "clang/AST/Expr.h"
23 #include "clang/AST/ExprCXX.h"
24 #include "clang/AST/ExprObjC.h"
25 #include "clang/AST/ExprOpenMP.h"
26 #include "clang/AST/Stmt.h"
27 #include "clang/AST/StmtCXX.h"
28 #include "clang/AST/StmtObjC.h"
29 #include "clang/AST/StmtOpenMP.h"
30 #include "clang/Sema/Designator.h"
31 #include "clang/Sema/Lookup.h"
32 #include "clang/Sema/Ownership.h"
34 #include "clang/Sema/ScopeInfo.h"
37 #include "llvm/ADT/ArrayRef.h"
38 #include "llvm/Support/ErrorHandling.h"
39 #include <algorithm>
40 
41 namespace clang {
42 using namespace sema;
43 
44 /// A semantic tree transformation that allows one to transform one
45 /// abstract syntax tree into another.
46 ///
47 /// A new tree transformation is defined by creating a new subclass \c X of
48 /// \c TreeTransform<X> and then overriding certain operations to provide
49 /// behavior specific to that transformation. For example, template
50 /// instantiation is implemented as a tree transformation where the
51 /// transformation of TemplateTypeParmType nodes involves substituting the
52 /// template arguments for their corresponding template parameters; a similar
53 /// transformation is performed for non-type template parameters and
54 /// template template parameters.
55 ///
56 /// This tree-transformation template uses static polymorphism to allow
57 /// subclasses to customize any of its operations. Thus, a subclass can
58 /// override any of the transformation or rebuild operators by providing an
59 /// operation with the same signature as the default implementation. The
60 /// overriding function should not be virtual.
61 ///
62 /// Semantic tree transformations are split into two stages, either of which
63 /// can be replaced by a subclass. The "transform" step transforms an AST node
64 /// or the parts of an AST node using the various transformation functions,
65 /// then passes the pieces on to the "rebuild" step, which constructs a new AST
66 /// node of the appropriate kind from the pieces. The default transformation
67 /// routines recursively transform the operands to composite AST nodes (e.g.,
68 /// the pointee type of a PointerType node) and, if any of those operand nodes
69 /// were changed by the transformation, invokes the rebuild operation to create
70 /// a new AST node.
71 ///
72 /// Subclasses can customize the transformation at various levels. The
73 /// most coarse-grained transformations involve replacing TransformType(),
74 /// TransformExpr(), TransformDecl(), TransformNestedNameSpecifierLoc(),
75 /// TransformTemplateName(), or TransformTemplateArgument() with entirely
76 /// new implementations.
77 ///
78 /// For more fine-grained transformations, subclasses can replace any of the
79 /// \c TransformXXX functions (where XXX is the name of an AST node, e.g.,
80 /// PointerType, StmtExpr) to alter the transformation. As mentioned previously,
81 /// replacing TransformTemplateTypeParmType() allows template instantiation
82 /// to substitute template arguments for their corresponding template
83 /// parameters. Additionally, subclasses can override the \c RebuildXXX
84 /// functions to control how AST nodes are rebuilt when their operands change.
85 /// By default, \c TreeTransform will invoke semantic analysis to rebuild
86 /// AST nodes. However, certain other tree transformations (e.g, cloning) may
87 /// be able to use more efficient rebuild steps.
88 ///
89 /// There are a handful of other functions that can be overridden, allowing one
90 /// to avoid traversing nodes that don't need any transformation
91 /// (\c AlreadyTransformed()), force rebuilding AST nodes even when their
92 /// operands have not changed (\c AlwaysRebuild()), and customize the
93 /// default locations and entity names used for type-checking
94 /// (\c getBaseLocation(), \c getBaseEntity()).
95 template<typename Derived>
97  /// Private RAII object that helps us forget and then re-remember
98  /// the template argument corresponding to a partially-substituted parameter
99  /// pack.
100  class ForgetPartiallySubstitutedPackRAII {
101  Derived &Self;
102  TemplateArgument Old;
103 
104  public:
105  ForgetPartiallySubstitutedPackRAII(Derived &Self) : Self(Self) {
106  Old = Self.ForgetPartiallySubstitutedPack();
107  }
108 
109  ~ForgetPartiallySubstitutedPackRAII() {
110  Self.RememberPartiallySubstitutedPack(Old);
111  }
112  };
113 
114 protected:
116 
117  /// The set of local declarations that have been transformed, for
118  /// cases where we are forced to build new declarations within the transformer
119  /// rather than in the subclass (e.g., lambda closure types).
120  llvm::DenseMap<Decl *, Decl *> TransformedLocalDecls;
121 
122 public:
123  /// Initializes a new tree transformer.
124  TreeTransform(Sema &SemaRef) : SemaRef(SemaRef) { }
125 
126  /// Retrieves a reference to the derived class.
127  Derived &getDerived() { return static_cast<Derived&>(*this); }
128 
129  /// Retrieves a reference to the derived class.
130  const Derived &getDerived() const {
131  return static_cast<const Derived&>(*this);
132  }
133 
134  static inline ExprResult Owned(Expr *E) { return E; }
135  static inline StmtResult Owned(Stmt *S) { return S; }
136 
137  /// Retrieves a reference to the semantic analysis object used for
138  /// this tree transform.
139  Sema &getSema() const { return SemaRef; }
140 
141  /// Whether the transformation should always rebuild AST nodes, even
142  /// if none of the children have changed.
143  ///
144  /// Subclasses may override this function to specify when the transformation
145  /// should rebuild all AST nodes.
146  ///
147  /// We must always rebuild all AST nodes when performing variadic template
148  /// pack expansion, in order to avoid violating the AST invariant that each
149  /// statement node appears at most once in its containing declaration.
150  bool AlwaysRebuild() { return SemaRef.ArgumentPackSubstitutionIndex != -1; }
151 
152  /// Returns the location of the entity being transformed, if that
153  /// information was not available elsewhere in the AST.
154  ///
155  /// By default, returns no source-location information. Subclasses can
156  /// provide an alternative implementation that provides better location
157  /// information.
159 
160  /// Returns the name of the entity being transformed, if that
161  /// information was not available elsewhere in the AST.
162  ///
163  /// By default, returns an empty name. Subclasses can provide an alternative
164  /// implementation with a more precise name.
166 
167  /// Sets the "base" location and entity when that
168  /// information is known based on another transformation.
169  ///
170  /// By default, the source location and entity are ignored. Subclasses can
171  /// override this function to provide a customized implementation.
172  void setBase(SourceLocation Loc, DeclarationName Entity) { }
173 
174  /// RAII object that temporarily sets the base location and entity
175  /// used for reporting diagnostics in types.
177  TreeTransform &Self;
178  SourceLocation OldLocation;
179  DeclarationName OldEntity;
180 
181  public:
183  DeclarationName Entity) : Self(Self) {
184  OldLocation = Self.getDerived().getBaseLocation();
185  OldEntity = Self.getDerived().getBaseEntity();
186 
187  if (Location.isValid())
188  Self.getDerived().setBase(Location, Entity);
189  }
190 
192  Self.getDerived().setBase(OldLocation, OldEntity);
193  }
194  };
195 
196  /// Determine whether the given type \p T has already been
197  /// transformed.
198  ///
199  /// Subclasses can provide an alternative implementation of this routine
200  /// to short-circuit evaluation when it is known that a given type will
201  /// not change. For example, template instantiation need not traverse
202  /// non-dependent types.
204  return T.isNull();
205  }
206 
207  /// Determine whether the given call argument should be dropped, e.g.,
208  /// because it is a default argument.
209  ///
210  /// Subclasses can provide an alternative implementation of this routine to
211  /// determine which kinds of call arguments get dropped. By default,
212  /// CXXDefaultArgument nodes are dropped (prior to transformation).
214  return E->isDefaultArgument();
215  }
216 
217  /// Determine whether we should expand a pack expansion with the
218  /// given set of parameter packs into separate arguments by repeatedly
219  /// transforming the pattern.
220  ///
221  /// By default, the transformer never tries to expand pack expansions.
222  /// Subclasses can override this routine to provide different behavior.
223  ///
224  /// \param EllipsisLoc The location of the ellipsis that identifies the
225  /// pack expansion.
226  ///
227  /// \param PatternRange The source range that covers the entire pattern of
228  /// the pack expansion.
229  ///
230  /// \param Unexpanded The set of unexpanded parameter packs within the
231  /// pattern.
232  ///
233  /// \param ShouldExpand Will be set to \c true if the transformer should
234  /// expand the corresponding pack expansions into separate arguments. When
235  /// set, \c NumExpansions must also be set.
236  ///
237  /// \param RetainExpansion Whether the caller should add an unexpanded
238  /// pack expansion after all of the expanded arguments. This is used
239  /// when extending explicitly-specified template argument packs per
240  /// C++0x [temp.arg.explicit]p9.
241  ///
242  /// \param NumExpansions The number of separate arguments that will be in
243  /// the expanded form of the corresponding pack expansion. This is both an
244  /// input and an output parameter, which can be set by the caller if the
245  /// number of expansions is known a priori (e.g., due to a prior substitution)
246  /// and will be set by the callee when the number of expansions is known.
247  /// The callee must set this value when \c ShouldExpand is \c true; it may
248  /// set this value in other cases.
249  ///
250  /// \returns true if an error occurred (e.g., because the parameter packs
251  /// are to be instantiated with arguments of different lengths), false
252  /// otherwise. If false, \c ShouldExpand (and possibly \c NumExpansions)
253  /// must be set.
255  SourceRange PatternRange,
257  bool &ShouldExpand,
258  bool &RetainExpansion,
259  Optional<unsigned> &NumExpansions) {
260  ShouldExpand = false;
261  return false;
262  }
263 
264  /// "Forget" about the partially-substituted pack template argument,
265  /// when performing an instantiation that must preserve the parameter pack
266  /// use.
267  ///
268  /// This routine is meant to be overridden by the template instantiator.
270  return TemplateArgument();
271  }
272 
273  /// "Remember" the partially-substituted pack template argument
274  /// after performing an instantiation that must preserve the parameter pack
275  /// use.
276  ///
277  /// This routine is meant to be overridden by the template instantiator.
279 
280  /// Note to the derived class when a function parameter pack is
281  /// being expanded.
283 
284  /// Transforms the given type into another type.
285  ///
286  /// By default, this routine transforms a type by creating a
287  /// TypeSourceInfo for it and delegating to the appropriate
288  /// function. This is expensive, but we don't mind, because
289  /// this method is deprecated anyway; all users should be
290  /// switched to storing TypeSourceInfos.
291  ///
292  /// \returns the transformed type.
293  QualType TransformType(QualType T);
294 
295  /// Transforms the given type-with-location into a new
296  /// type-with-location.
297  ///
298  /// By default, this routine transforms a type by delegating to the
299  /// appropriate TransformXXXType to build a new type. Subclasses
300  /// may override this function (to take over all type
301  /// transformations) or some set of the TransformXXXType functions
302  /// to alter the transformation.
303  TypeSourceInfo *TransformType(TypeSourceInfo *DI);
304 
305  /// Transform the given type-with-location into a new
306  /// type, collecting location information in the given builder
307  /// as necessary.
308  ///
309  QualType TransformType(TypeLocBuilder &TLB, TypeLoc TL);
310 
311  /// Transform a type that is permitted to produce a
312  /// DeducedTemplateSpecializationType.
313  ///
314  /// This is used in the (relatively rare) contexts where it is acceptable
315  /// for transformation to produce a class template type with deduced
316  /// template arguments.
317  /// @{
318  QualType TransformTypeWithDeducedTST(QualType T);
319  TypeSourceInfo *TransformTypeWithDeducedTST(TypeSourceInfo *DI);
320  /// @}
321 
322  /// Transform the given statement.
323  ///
324  /// By default, this routine transforms a statement by delegating to the
325  /// appropriate TransformXXXStmt function to transform a specific kind of
326  /// statement or the TransformExpr() function to transform an expression.
327  /// Subclasses may override this function to transform statements using some
328  /// other mechanism.
329  ///
330  /// \returns the transformed statement.
331  StmtResult TransformStmt(Stmt *S);
332 
333  /// Transform the given statement.
334  ///
335  /// By default, this routine transforms a statement by delegating to the
336  /// appropriate TransformOMPXXXClause function to transform a specific kind
337  /// of clause. Subclasses may override this function to transform statements
338  /// using some other mechanism.
339  ///
340  /// \returns the transformed OpenMP clause.
341  OMPClause *TransformOMPClause(OMPClause *S);
342 
343  /// Transform the given attribute.
344  ///
345  /// By default, this routine transforms a statement by delegating to the
346  /// appropriate TransformXXXAttr function to transform a specific kind
347  /// of attribute. Subclasses may override this function to transform
348  /// attributed statements using some other mechanism.
349  ///
350  /// \returns the transformed attribute
351  const Attr *TransformAttr(const Attr *S);
352 
353 /// Transform the specified attribute.
354 ///
355 /// Subclasses should override the transformation of attributes with a pragma
356 /// spelling to transform expressions stored within the attribute.
357 ///
358 /// \returns the transformed attribute.
359 #define ATTR(X)
360 #define PRAGMA_SPELLING_ATTR(X) \
361  const X##Attr *Transform##X##Attr(const X##Attr *R) { return R; }
362 #include "clang/Basic/AttrList.inc"
363 
364  /// Transform the given expression.
365  ///
366  /// By default, this routine transforms an expression by delegating to the
367  /// appropriate TransformXXXExpr function to build a new expression.
368  /// Subclasses may override this function to transform expressions using some
369  /// other mechanism.
370  ///
371  /// \returns the transformed expression.
372  ExprResult TransformExpr(Expr *E);
373 
374  /// Transform the given initializer.
375  ///
376  /// By default, this routine transforms an initializer by stripping off the
377  /// semantic nodes added by initialization, then passing the result to
378  /// TransformExpr or TransformExprs.
379  ///
380  /// \returns the transformed initializer.
381  ExprResult TransformInitializer(Expr *Init, bool NotCopyInit);
382 
383  /// Transform the given list of expressions.
384  ///
385  /// This routine transforms a list of expressions by invoking
386  /// \c TransformExpr() for each subexpression. However, it also provides
387  /// support for variadic templates by expanding any pack expansions (if the
388  /// derived class permits such expansion) along the way. When pack expansions
389  /// are present, the number of outputs may not equal the number of inputs.
390  ///
391  /// \param Inputs The set of expressions to be transformed.
392  ///
393  /// \param NumInputs The number of expressions in \c Inputs.
394  ///
395  /// \param IsCall If \c true, then this transform is being performed on
396  /// function-call arguments, and any arguments that should be dropped, will
397  /// be.
398  ///
399  /// \param Outputs The transformed input expressions will be added to this
400  /// vector.
401  ///
402  /// \param ArgChanged If non-NULL, will be set \c true if any argument changed
403  /// due to transformation.
404  ///
405  /// \returns true if an error occurred, false otherwise.
406  bool TransformExprs(Expr *const *Inputs, unsigned NumInputs, bool IsCall,
407  SmallVectorImpl<Expr *> &Outputs,
408  bool *ArgChanged = nullptr);
409 
410  /// Transform the given declaration, which is referenced from a type
411  /// or expression.
412  ///
413  /// By default, acts as the identity function on declarations, unless the
414  /// transformer has had to transform the declaration itself. Subclasses
415  /// may override this function to provide alternate behavior.
417  llvm::DenseMap<Decl *, Decl *>::iterator Known
418  = TransformedLocalDecls.find(D);
419  if (Known != TransformedLocalDecls.end())
420  return Known->second;
421 
422  return D;
423  }
424 
425  /// Transform the specified condition.
426  ///
427  /// By default, this transforms the variable and expression and rebuilds
428  /// the condition.
429  Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var,
430  Expr *Expr,
432 
433  /// Transform the attributes associated with the given declaration and
434  /// place them on the new declaration.
435  ///
436  /// By default, this operation does nothing. Subclasses may override this
437  /// behavior to transform attributes.
438  void transformAttrs(Decl *Old, Decl *New) { }
439 
440  /// Note that a local declaration has been transformed by this
441  /// transformer.
442  ///
443  /// Local declarations are typically transformed via a call to
444  /// TransformDefinition. However, in some cases (e.g., lambda expressions),
445  /// the transformer itself has to transform the declarations. This routine
446  /// can be overridden by a subclass that keeps track of such mappings.
447  void transformedLocalDecl(Decl *Old, Decl *New) {
448  TransformedLocalDecls[Old] = New;
449  }
450 
451  /// Transform the definition of the given declaration.
452  ///
453  /// By default, invokes TransformDecl() to transform the declaration.
454  /// Subclasses may override this function to provide alternate behavior.
456  return getDerived().TransformDecl(Loc, D);
457  }
458 
459  /// Transform the given declaration, which was the first part of a
460  /// nested-name-specifier in a member access expression.
461  ///
462  /// This specific declaration transformation only applies to the first
463  /// identifier in a nested-name-specifier of a member access expression, e.g.,
464  /// the \c T in \c x->T::member
465  ///
466  /// By default, invokes TransformDecl() to transform the declaration.
467  /// Subclasses may override this function to provide alternate behavior.
469  return cast_or_null<NamedDecl>(getDerived().TransformDecl(Loc, D));
470  }
471 
472  /// Transform the set of declarations in an OverloadExpr.
473  bool TransformOverloadExprDecls(OverloadExpr *Old, bool RequiresADL,
474  LookupResult &R);
475 
476  /// Transform the given nested-name-specifier with source-location
477  /// information.
478  ///
479  /// By default, transforms all of the types and declarations within the
480  /// nested-name-specifier. Subclasses may override this function to provide
481  /// alternate behavior.
483  TransformNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
484  QualType ObjectType = QualType(),
485  NamedDecl *FirstQualifierInScope = nullptr);
486 
487  /// Transform the given declaration name.
488  ///
489  /// By default, transforms the types of conversion function, constructor,
490  /// and destructor names and then (if needed) rebuilds the declaration name.
491  /// Identifiers and selectors are returned unmodified. Sublcasses may
492  /// override this function to provide alternate behavior.
494  TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo);
495 
496  /// Transform the given template name.
497  ///
498  /// \param SS The nested-name-specifier that qualifies the template
499  /// name. This nested-name-specifier must already have been transformed.
500  ///
501  /// \param Name The template name to transform.
502  ///
503  /// \param NameLoc The source location of the template name.
504  ///
505  /// \param ObjectType If we're translating a template name within a member
506  /// access expression, this is the type of the object whose member template
507  /// is being referenced.
508  ///
509  /// \param FirstQualifierInScope If the first part of a nested-name-specifier
510  /// also refers to a name within the current (lexical) scope, this is the
511  /// declaration it refers to.
512  ///
513  /// By default, transforms the template name by transforming the declarations
514  /// and nested-name-specifiers that occur within the template name.
515  /// Subclasses may override this function to provide alternate behavior.
517  TransformTemplateName(CXXScopeSpec &SS, TemplateName Name,
518  SourceLocation NameLoc,
519  QualType ObjectType = QualType(),
520  NamedDecl *FirstQualifierInScope = nullptr,
521  bool AllowInjectedClassName = false);
522 
523  /// Transform the given template argument.
524  ///
525  /// By default, this operation transforms the type, expression, or
526  /// declaration stored within the template argument and constructs a
527  /// new template argument from the transformed result. Subclasses may
528  /// override this function to provide alternate behavior.
529  ///
530  /// Returns true if there was an error.
531  bool TransformTemplateArgument(const TemplateArgumentLoc &Input,
532  TemplateArgumentLoc &Output,
533  bool Uneval = false);
534 
535  /// Transform the given set of template arguments.
536  ///
537  /// By default, this operation transforms all of the template arguments
538  /// in the input set using \c TransformTemplateArgument(), and appends
539  /// the transformed arguments to the output list.
540  ///
541  /// Note that this overload of \c TransformTemplateArguments() is merely
542  /// a convenience function. Subclasses that wish to override this behavior
543  /// should override the iterator-based member template version.
544  ///
545  /// \param Inputs The set of template arguments to be transformed.
546  ///
547  /// \param NumInputs The number of template arguments in \p Inputs.
548  ///
549  /// \param Outputs The set of transformed template arguments output by this
550  /// routine.
551  ///
552  /// Returns true if an error occurred.
554  unsigned NumInputs,
555  TemplateArgumentListInfo &Outputs,
556  bool Uneval = false) {
557  return TransformTemplateArguments(Inputs, Inputs + NumInputs, Outputs,
558  Uneval);
559  }
560 
561  /// Transform the given set of template arguments.
562  ///
563  /// By default, this operation transforms all of the template arguments
564  /// in the input set using \c TransformTemplateArgument(), and appends
565  /// the transformed arguments to the output list.
566  ///
567  /// \param First An iterator to the first template argument.
568  ///
569  /// \param Last An iterator one step past the last template argument.
570  ///
571  /// \param Outputs The set of transformed template arguments output by this
572  /// routine.
573  ///
574  /// Returns true if an error occurred.
575  template<typename InputIterator>
576  bool TransformTemplateArguments(InputIterator First,
577  InputIterator Last,
578  TemplateArgumentListInfo &Outputs,
579  bool Uneval = false);
580 
581  /// Fakes up a TemplateArgumentLoc for a given TemplateArgument.
582  void InventTemplateArgumentLoc(const TemplateArgument &Arg,
583  TemplateArgumentLoc &ArgLoc);
584 
585  /// Fakes up a TypeSourceInfo for a type.
587  return SemaRef.Context.getTrivialTypeSourceInfo(T,
588  getDerived().getBaseLocation());
589  }
590 
591 #define ABSTRACT_TYPELOC(CLASS, PARENT)
592 #define TYPELOC(CLASS, PARENT) \
593  QualType Transform##CLASS##Type(TypeLocBuilder &TLB, CLASS##TypeLoc T);
594 #include "clang/AST/TypeLocNodes.def"
595 
596  template<typename Fn>
597  QualType TransformFunctionProtoType(TypeLocBuilder &TLB,
598  FunctionProtoTypeLoc TL,
599  CXXRecordDecl *ThisContext,
600  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  /// Transforms the parameters of a function type into the
626  /// given vectors.
627  ///
628  /// The result vectors should be kept in sync; null entries in the
629  /// variables vector are acceptable.
630  ///
631  /// Return true on error.
632  bool TransformFunctionTypeParams(
633  SourceLocation Loc, ArrayRef<ParmVarDecl *> Params,
634  const QualType *ParamTypes,
635  const FunctionProtoType::ExtParameterInfo *ParamInfos,
636  SmallVectorImpl<QualType> &PTypes, SmallVectorImpl<ParmVarDecl *> *PVars,
637  Sema::ExtParameterInfoBuilder &PInfos);
638 
639  /// Transforms a single function-type parameter. Return null
640  /// on error.
641  ///
642  /// \param indexAdjustment - A number to add to the parameter's
643  /// scope index; can be negative
644  ParmVarDecl *TransformFunctionTypeParam(ParmVarDecl *OldParm,
645  int indexAdjustment,
646  Optional<unsigned> NumExpansions,
647  bool ExpectParameterPack);
648 
649  QualType TransformReferenceType(TypeLocBuilder &TLB, ReferenceTypeLoc TL);
650 
651  StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr);
652  ExprResult TransformCXXNamedCastExpr(CXXNamedCastExpr *E);
653 
655  TemplateParameterList *TPL) {
656  return TPL;
657  }
658 
659  ExprResult TransformAddressOfOperand(Expr *E);
660 
661  ExprResult TransformDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E,
662  bool IsAddressOfOperand,
663  TypeSourceInfo **RecoveryTSI);
664 
665  ExprResult TransformParenDependentScopeDeclRefExpr(
666  ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool IsAddressOfOperand,
667  TypeSourceInfo **RecoveryTSI);
668 
669  StmtResult TransformOMPExecutableDirective(OMPExecutableDirective *S);
670 
671 // FIXME: We use LLVM_ATTRIBUTE_NOINLINE because inlining causes a ridiculous
672 // amount of stack usage with clang.
673 #define STMT(Node, Parent) \
674  LLVM_ATTRIBUTE_NOINLINE \
675  StmtResult Transform##Node(Node *S);
676 #define EXPR(Node, Parent) \
677  LLVM_ATTRIBUTE_NOINLINE \
678  ExprResult Transform##Node(Node *E);
679 #define ABSTRACT_STMT(Stmt)
680 #include "clang/AST/StmtNodes.inc"
681 
682 #define OPENMP_CLAUSE(Name, Class) \
683  LLVM_ATTRIBUTE_NOINLINE \
684  OMPClause *Transform ## Class(Class *S);
685 #include "clang/Basic/OpenMPKinds.def"
686 
687  /// Build a new qualified type given its unqualified type and type
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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// Build a new potentially dependently-sized extended vector type
822  /// given the element type and 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 RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr,
827  SourceLocation AttributeLoc,
829 
830  /// Build a new extended vector type given the element type and
831  /// number of elements.
832  ///
833  /// By default, performs semantic analysis when building the vector type.
834  /// Subclasses may override this routine to provide different behavior.
835  QualType RebuildExtVectorType(QualType ElementType, unsigned NumElements,
836  SourceLocation AttributeLoc);
837 
838  /// Build a new potentially dependently-sized extended vector type
839  /// given the element type and number of elements.
840  ///
841  /// By default, performs semantic analysis when building the vector type.
842  /// Subclasses may override this routine to provide different behavior.
843  QualType RebuildDependentSizedExtVectorType(QualType ElementType,
844  Expr *SizeExpr,
845  SourceLocation AttributeLoc);
846 
847  /// Build a new DependentAddressSpaceType or return the pointee
848  /// type variable with the correct address space (retrieved from
849  /// AddrSpaceExpr) applied to it. The former will be returned in cases
850  /// where the address space remains dependent.
851  ///
852  /// By default, performs semantic analysis when building the type with address
853  /// space applied. Subclasses may override this routine to provide different
854  /// behavior.
855  QualType RebuildDependentAddressSpaceType(QualType PointeeType,
856  Expr *AddrSpaceExpr,
857  SourceLocation AttributeLoc);
858 
859  /// Build a new function type.
860  ///
861  /// By default, performs semantic analysis when building the function type.
862  /// Subclasses may override this routine to provide different behavior.
863  QualType RebuildFunctionProtoType(QualType T,
864  MutableArrayRef<QualType> ParamTypes,
865  const FunctionProtoType::ExtProtoInfo &EPI);
866 
867  /// Build a new unprototyped function type.
868  QualType RebuildFunctionNoProtoType(QualType ResultType);
869 
870  /// Rebuild an unresolved typename type, given the decl that
871  /// the UnresolvedUsingTypenameDecl was transformed to.
872  QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D);
873 
874  /// Build a new typedef type.
876  return SemaRef.Context.getTypeDeclType(Typedef);
877  }
878 
879  /// Build a new class/struct/union type.
881  return SemaRef.Context.getTypeDeclType(Record);
882  }
883 
884  /// Build a new Enum type.
886  return SemaRef.Context.getTypeDeclType(Enum);
887  }
888 
889  /// Build a new typeof(expr) type.
890  ///
891  /// By default, performs semantic analysis when building the typeof type.
892  /// Subclasses may override this routine to provide different behavior.
893  QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc);
894 
895  /// Build a new typeof(type) type.
896  ///
897  /// By default, builds a new TypeOfType with the given underlying type.
898  QualType RebuildTypeOfType(QualType Underlying);
899 
900  /// Build a new unary transform type.
901  QualType RebuildUnaryTransformType(QualType BaseType,
903  SourceLocation Loc);
904 
905  /// Build a new C++11 decltype type.
906  ///
907  /// By default, performs semantic analysis when building the decltype type.
908  /// Subclasses may override this routine to provide different behavior.
909  QualType RebuildDecltypeType(Expr *Underlying, SourceLocation Loc);
910 
911  /// Build a new C++11 auto type.
912  ///
913  /// By default, builds a new AutoType with the given deduced type.
915  // Note, IsDependent is always false here: we implicitly convert an 'auto'
916  // which has been deduced to a dependent type into an undeduced 'auto', so
917  // that we'll retry deduction after the transformation.
918  return SemaRef.Context.getAutoType(Deduced, Keyword,
919  /*IsDependent*/ false);
920  }
921 
922  /// By default, builds a new DeducedTemplateSpecializationType with the given
923  /// deduced type.
925  QualType Deduced) {
927  Template, Deduced, /*IsDependent*/ false);
928  }
929 
930  /// Build a new template specialization type.
931  ///
932  /// By default, performs semantic analysis when building the template
933  /// specialization type. Subclasses may override this routine to provide
934  /// different behavior.
935  QualType RebuildTemplateSpecializationType(TemplateName Template,
936  SourceLocation TemplateLoc,
938 
939  /// Build a new parenthesized type.
940  ///
941  /// By default, builds a new ParenType type from the inner type.
942  /// Subclasses may override this routine to provide different behavior.
944  return SemaRef.BuildParenType(InnerType);
945  }
946 
947  /// Build a new qualified name type.
948  ///
949  /// By default, builds a new ElaboratedType type from the keyword,
950  /// the nested-name-specifier and the named type.
951  /// Subclasses may override this routine to provide different behavior.
953  ElaboratedTypeKeyword Keyword,
954  NestedNameSpecifierLoc QualifierLoc,
955  QualType Named) {
956  return SemaRef.Context.getElaboratedType(Keyword,
957  QualifierLoc.getNestedNameSpecifier(),
958  Named);
959  }
960 
961  /// Build a new typename type that refers to a template-id.
962  ///
963  /// By default, builds a new DependentNameType type from the
964  /// nested-name-specifier and the given type. Subclasses may override
965  /// this routine to provide different behavior.
967  ElaboratedTypeKeyword Keyword,
968  NestedNameSpecifierLoc QualifierLoc,
969  SourceLocation TemplateKWLoc,
970  const IdentifierInfo *Name,
971  SourceLocation NameLoc,
973  bool AllowInjectedClassName) {
974  // Rebuild the template name.
975  // TODO: avoid TemplateName abstraction
976  CXXScopeSpec SS;
977  SS.Adopt(QualifierLoc);
978  TemplateName InstName = getDerived().RebuildTemplateName(
979  SS, TemplateKWLoc, *Name, NameLoc, QualType(), nullptr,
980  AllowInjectedClassName);
981 
982  if (InstName.isNull())
983  return QualType();
984 
985  // If it's still dependent, make a dependent specialization.
986  if (InstName.getAsDependentTemplateName())
987  return SemaRef.Context.getDependentTemplateSpecializationType(Keyword,
988  QualifierLoc.getNestedNameSpecifier(),
989  Name,
990  Args);
991 
992  // Otherwise, make an elaborated type wrapping a non-dependent
993  // specialization.
994  QualType T =
995  getDerived().RebuildTemplateSpecializationType(InstName, NameLoc, Args);
996  if (T.isNull()) return QualType();
997 
998  if (Keyword == ETK_None && QualifierLoc.getNestedNameSpecifier() == nullptr)
999  return T;
1000 
1001  return SemaRef.Context.getElaboratedType(Keyword,
1002  QualifierLoc.getNestedNameSpecifier(),
1003  T);
1004  }
1005 
1006  /// Build a new typename type that refers to an identifier.
1007  ///
1008  /// By default, performs semantic analysis when building the typename type
1009  /// (or elaborated type). Subclasses may override this routine to provide
1010  /// different behavior.
1012  SourceLocation KeywordLoc,
1013  NestedNameSpecifierLoc QualifierLoc,
1014  const IdentifierInfo *Id,
1015  SourceLocation IdLoc,
1016  bool DeducedTSTContext) {
1017  CXXScopeSpec SS;
1018  SS.Adopt(QualifierLoc);
1019 
1020  if (QualifierLoc.getNestedNameSpecifier()->isDependent()) {
1021  // If the name is still dependent, just build a new dependent name type.
1022  if (!SemaRef.computeDeclContext(SS))
1023  return SemaRef.Context.getDependentNameType(Keyword,
1024  QualifierLoc.getNestedNameSpecifier(),
1025  Id);
1026  }
1027 
1028  if (Keyword == ETK_None || Keyword == ETK_Typename) {
1029  QualType T = SemaRef.CheckTypenameType(Keyword, KeywordLoc, QualifierLoc,
1030  *Id, IdLoc);
1031  // If a dependent name resolves to a deduced template specialization type,
1032  // check that we're in one of the syntactic contexts permitting it.
1033  if (!DeducedTSTContext) {
1034  if (auto *Deduced = dyn_cast_or_null<DeducedTemplateSpecializationType>(
1035  T.isNull() ? nullptr : T->getContainedDeducedType())) {
1036  SemaRef.Diag(IdLoc, diag::err_dependent_deduced_tst)
1037  << (int)SemaRef.getTemplateNameKindForDiagnostics(
1038  Deduced->getTemplateName())
1039  << QualType(QualifierLoc.getNestedNameSpecifier()->getAsType(), 0);
1040  if (auto *TD = Deduced->getTemplateName().getAsTemplateDecl())
1041  SemaRef.Diag(TD->getLocation(), diag::note_template_decl_here);
1042  return QualType();
1043  }
1044  }
1045  return T;
1046  }
1047 
1049 
1050  // We had a dependent elaborated-type-specifier that has been transformed
1051  // into a non-dependent elaborated-type-specifier. Find the tag we're
1052  // referring to.
1053  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1054  DeclContext *DC = SemaRef.computeDeclContext(SS, false);
1055  if (!DC)
1056  return QualType();
1057 
1058  if (SemaRef.RequireCompleteDeclContext(SS, DC))
1059  return QualType();
1060 
1061  TagDecl *Tag = nullptr;
1062  SemaRef.LookupQualifiedName(Result, DC);
1063  switch (Result.getResultKind()) {
1066  break;
1067 
1068  case LookupResult::Found:
1069  Tag = Result.getAsSingle<TagDecl>();
1070  break;
1071 
1074  llvm_unreachable("Tag lookup cannot find non-tags");
1075 
1077  // Let the LookupResult structure handle ambiguities.
1078  return QualType();
1079  }
1080 
1081  if (!Tag) {
1082  // Check where the name exists but isn't a tag type and use that to emit
1083  // better diagnostics.
1084  LookupResult Result(SemaRef, Id, IdLoc, Sema::LookupTagName);
1085  SemaRef.LookupQualifiedName(Result, DC);
1086  switch (Result.getResultKind()) {
1087  case LookupResult::Found:
1090  NamedDecl *SomeDecl = Result.getRepresentativeDecl();
1091  Sema::NonTagKind NTK = SemaRef.getNonTagTypeDeclKind(SomeDecl, Kind);
1092  SemaRef.Diag(IdLoc, diag::err_tag_reference_non_tag) << SomeDecl
1093  << NTK << Kind;
1094  SemaRef.Diag(SomeDecl->getLocation(), diag::note_declared_at);
1095  break;
1096  }
1097  default:
1098  SemaRef.Diag(IdLoc, diag::err_not_tag_in_scope)
1099  << Kind << Id << DC << QualifierLoc.getSourceRange();
1100  break;
1101  }
1102  return QualType();
1103  }
1104 
1105  if (!SemaRef.isAcceptableTagRedeclaration(Tag, Kind, /*isDefinition*/false,
1106  IdLoc, Id)) {
1107  SemaRef.Diag(KeywordLoc, diag::err_use_with_wrong_tag) << Id;
1108  SemaRef.Diag(Tag->getLocation(), diag::note_previous_use);
1109  return QualType();
1110  }
1111 
1112  // Build the elaborated-type-specifier type.
1113  QualType T = SemaRef.Context.getTypeDeclType(Tag);
1114  return SemaRef.Context.getElaboratedType(Keyword,
1115  QualifierLoc.getNestedNameSpecifier(),
1116  T);
1117  }
1118 
1119  /// Build a new pack expansion type.
1120  ///
1121  /// By default, builds a new PackExpansionType type from the given pattern.
1122  /// Subclasses may override this routine to provide different behavior.
1124  SourceRange PatternRange,
1125  SourceLocation EllipsisLoc,
1126  Optional<unsigned> NumExpansions) {
1127  return getSema().CheckPackExpansion(Pattern, PatternRange, EllipsisLoc,
1128  NumExpansions);
1129  }
1130 
1131  /// Build a new atomic type given its value type.
1132  ///
1133  /// By default, performs semantic analysis when building the atomic type.
1134  /// Subclasses may override this routine to provide different behavior.
1135  QualType RebuildAtomicType(QualType ValueType, SourceLocation KWLoc);
1136 
1137  /// Build a new pipe type given its value type.
1138  QualType RebuildPipeType(QualType ValueType, SourceLocation KWLoc,
1139  bool isReadPipe);
1140 
1141  /// Build a new template name given a nested name specifier, a flag
1142  /// indicating whether the "template" keyword was provided, and the template
1143  /// that the template name refers to.
1144  ///
1145  /// By default, builds the new template name directly. Subclasses may override
1146  /// this routine to provide different behavior.
1147  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1148  bool TemplateKW,
1149  TemplateDecl *Template);
1150 
1151  /// Build a new template name given a nested name specifier and the
1152  /// name that is referred to as a template.
1153  ///
1154  /// By default, performs semantic analysis to determine whether the name can
1155  /// be resolved to a specific template, then builds the appropriate kind of
1156  /// template name. Subclasses may override this routine to provide different
1157  /// behavior.
1158  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1159  SourceLocation TemplateKWLoc,
1160  const IdentifierInfo &Name,
1161  SourceLocation NameLoc, QualType ObjectType,
1162  NamedDecl *FirstQualifierInScope,
1163  bool AllowInjectedClassName);
1164 
1165  /// Build a new template name given a nested name specifier and the
1166  /// overloaded operator name that is referred to as a template.
1167  ///
1168  /// By default, performs semantic analysis to determine whether the name can
1169  /// be resolved to a specific template, then builds the appropriate kind of
1170  /// template name. Subclasses may override this routine to provide different
1171  /// behavior.
1172  TemplateName RebuildTemplateName(CXXScopeSpec &SS,
1173  SourceLocation TemplateKWLoc,
1174  OverloadedOperatorKind Operator,
1175  SourceLocation NameLoc, QualType ObjectType,
1176  bool AllowInjectedClassName);
1177 
1178  /// Build a new template name given a template template parameter pack
1179  /// and the
1180  ///
1181  /// By default, performs semantic analysis to determine whether the name can
1182  /// be resolved to a specific template, then builds the appropriate kind of
1183  /// template name. Subclasses may override this routine to provide different
1184  /// behavior.
1186  const TemplateArgument &ArgPack) {
1187  return getSema().Context.getSubstTemplateTemplateParmPack(Param, ArgPack);
1188  }
1189 
1190  /// Build a new compound statement.
1191  ///
1192  /// By default, performs semantic analysis to build the new statement.
1193  /// Subclasses may override this routine to provide different behavior.
1195  MultiStmtArg Statements,
1196  SourceLocation RBraceLoc,
1197  bool IsStmtExpr) {
1198  return getSema().ActOnCompoundStmt(LBraceLoc, RBraceLoc, Statements,
1199  IsStmtExpr);
1200  }
1201 
1202  /// Build a new case statement.
1203  ///
1204  /// By default, performs semantic analysis to build the new statement.
1205  /// Subclasses may override this routine to provide different behavior.
1207  Expr *LHS,
1208  SourceLocation EllipsisLoc,
1209  Expr *RHS,
1211  return getSema().ActOnCaseStmt(CaseLoc, LHS, EllipsisLoc, RHS,
1212  ColonLoc);
1213  }
1214 
1215  /// Attach the body to a new case statement.
1216  ///
1217  /// By default, performs semantic analysis to build the new statement.
1218  /// Subclasses may override this routine to provide different behavior.
1220  getSema().ActOnCaseStmtBody(S, Body);
1221  return S;
1222  }
1223 
1224  /// Build a new default statement.
1225  ///
1226  /// By default, performs semantic analysis to build the new statement.
1227  /// Subclasses may override this routine to provide different behavior.
1230  Stmt *SubStmt) {
1231  return getSema().ActOnDefaultStmt(DefaultLoc, ColonLoc, SubStmt,
1232  /*CurScope=*/nullptr);
1233  }
1234 
1235  /// Build a new label statement.
1236  ///
1237  /// By default, performs semantic analysis to build the new statement.
1238  /// Subclasses may override this routine to provide different behavior.
1240  SourceLocation ColonLoc, Stmt *SubStmt) {
1241  return SemaRef.ActOnLabelStmt(IdentLoc, L, ColonLoc, SubStmt);
1242  }
1243 
1244  /// Build a new label statement.
1245  ///
1246  /// By default, performs semantic analysis to build the new statement.
1247  /// Subclasses may override this routine to provide different behavior.
1249  ArrayRef<const Attr*> Attrs,
1250  Stmt *SubStmt) {
1251  return SemaRef.ActOnAttributedStmt(AttrLoc, Attrs, SubStmt);
1252  }
1253 
1254  /// Build a new "if" statement.
1255  ///
1256  /// By default, performs semantic analysis to build the new statement.
1257  /// Subclasses may override this routine to provide different behavior.
1258  StmtResult RebuildIfStmt(SourceLocation IfLoc, bool IsConstexpr,
1259  Sema::ConditionResult Cond, Stmt *Init, Stmt *Then,
1260  SourceLocation ElseLoc, Stmt *Else) {
1261  return getSema().ActOnIfStmt(IfLoc, IsConstexpr, Init, Cond, Then,
1262  ElseLoc, Else);
1263  }
1264 
1265  /// Start building a new switch statement.
1266  ///
1267  /// By default, performs semantic analysis to build the new statement.
1268  /// Subclasses may override this routine to provide different behavior.
1270  Sema::ConditionResult Cond) {
1271  return getSema().ActOnStartOfSwitchStmt(SwitchLoc, Init, Cond);
1272  }
1273 
1274  /// Attach the body to the switch statement.
1275  ///
1276  /// By default, performs semantic analysis to build the new statement.
1277  /// Subclasses may override this routine to provide different behavior.
1279  Stmt *Switch, Stmt *Body) {
1280  return getSema().ActOnFinishSwitchStmt(SwitchLoc, Switch, Body);
1281  }
1282 
1283  /// Build a new while statement.
1284  ///
1285  /// By default, performs semantic analysis to build the new statement.
1286  /// Subclasses may override this routine to provide different behavior.
1288  Sema::ConditionResult Cond, Stmt *Body) {
1289  return getSema().ActOnWhileStmt(WhileLoc, Cond, Body);
1290  }
1291 
1292  /// Build a new do-while statement.
1293  ///
1294  /// By default, performs semantic analysis to build the new statement.
1295  /// Subclasses may override this routine to provide different behavior.
1297  SourceLocation WhileLoc, SourceLocation LParenLoc,
1298  Expr *Cond, SourceLocation RParenLoc) {
1299  return getSema().ActOnDoStmt(DoLoc, Body, WhileLoc, LParenLoc,
1300  Cond, RParenLoc);
1301  }
1302 
1303  /// Build a new for statement.
1304  ///
1305  /// By default, performs semantic analysis to build the new statement.
1306  /// Subclasses may override this routine to provide different behavior.
1308  Stmt *Init, Sema::ConditionResult Cond,
1309  Sema::FullExprArg Inc, SourceLocation RParenLoc,
1310  Stmt *Body) {
1311  return getSema().ActOnForStmt(ForLoc, LParenLoc, Init, Cond,
1312  Inc, RParenLoc, Body);
1313  }
1314 
1315  /// Build a new goto statement.
1316  ///
1317  /// By default, performs semantic analysis to build the new statement.
1318  /// Subclasses may override this routine to provide different behavior.
1320  LabelDecl *Label) {
1321  return getSema().ActOnGotoStmt(GotoLoc, LabelLoc, Label);
1322  }
1323 
1324  /// Build a new indirect goto statement.
1325  ///
1326  /// By default, performs semantic analysis to build the new statement.
1327  /// Subclasses may override this routine to provide different behavior.
1329  SourceLocation StarLoc,
1330  Expr *Target) {
1331  return getSema().ActOnIndirectGotoStmt(GotoLoc, StarLoc, Target);
1332  }
1333 
1334  /// Build a new return statement.
1335  ///
1336  /// By default, performs semantic analysis to build the new statement.
1337  /// Subclasses may override this routine to provide different behavior.
1339  return getSema().BuildReturnStmt(ReturnLoc, Result);
1340  }
1341 
1342  /// Build a new declaration statement.
1343  ///
1344  /// By default, performs semantic analysis to build the new statement.
1345  /// Subclasses may override this routine to provide different behavior.
1347  SourceLocation StartLoc, SourceLocation EndLoc) {
1348  Sema::DeclGroupPtrTy DG = getSema().BuildDeclaratorGroup(Decls);
1349  return getSema().ActOnDeclStmt(DG, StartLoc, EndLoc);
1350  }
1351 
1352  /// Build a new inline asm statement.
1353  ///
1354  /// By default, performs semantic analysis to build the new statement.
1355  /// Subclasses may override this routine to provide different behavior.
1357  bool IsVolatile, unsigned NumOutputs,
1358  unsigned NumInputs, IdentifierInfo **Names,
1359  MultiExprArg Constraints, MultiExprArg Exprs,
1360  Expr *AsmString, MultiExprArg Clobbers,
1361  SourceLocation RParenLoc) {
1362  return getSema().ActOnGCCAsmStmt(AsmLoc, IsSimple, IsVolatile, NumOutputs,
1363  NumInputs, Names, Constraints, Exprs,
1364  AsmString, Clobbers, RParenLoc);
1365  }
1366 
1367  /// Build a new MS style inline asm statement.
1368  ///
1369  /// By default, performs semantic analysis to build the new statement.
1370  /// Subclasses may override this routine to provide different behavior.
1372  ArrayRef<Token> AsmToks,
1373  StringRef AsmString,
1374  unsigned NumOutputs, unsigned NumInputs,
1375  ArrayRef<StringRef> Constraints,
1376  ArrayRef<StringRef> Clobbers,
1377  ArrayRef<Expr*> Exprs,
1378  SourceLocation EndLoc) {
1379  return getSema().ActOnMSAsmStmt(AsmLoc, LBraceLoc, AsmToks, AsmString,
1380  NumOutputs, NumInputs,
1381  Constraints, Clobbers, Exprs, EndLoc);
1382  }
1383 
1384  /// Build a new co_return statement.
1385  ///
1386  /// By default, performs semantic analysis to build the new statement.
1387  /// Subclasses may override this routine to provide different behavior.
1389  bool IsImplicit) {
1390  return getSema().BuildCoreturnStmt(CoreturnLoc, Result, IsImplicit);
1391  }
1392 
1393  /// Build a new co_await expression.
1394  ///
1395  /// By default, performs semantic analysis to build the new expression.
1396  /// Subclasses may override this routine to provide different behavior.
1398  bool IsImplicit) {
1399  return getSema().BuildResolvedCoawaitExpr(CoawaitLoc, Result, IsImplicit);
1400  }
1401 
1402  /// Build a new co_await expression.
1403  ///
1404  /// By default, performs semantic analysis to build the new expression.
1405  /// Subclasses may override this routine to provide different behavior.
1407  Expr *Result,
1408  UnresolvedLookupExpr *Lookup) {
1409  return getSema().BuildUnresolvedCoawaitExpr(CoawaitLoc, Result, Lookup);
1410  }
1411 
1412  /// Build a new co_yield expression.
1413  ///
1414  /// By default, performs semantic analysis to build the new expression.
1415  /// Subclasses may override this routine to provide different behavior.
1417  return getSema().BuildCoyieldExpr(CoyieldLoc, Result);
1418  }
1419 
1421  return getSema().BuildCoroutineBodyStmt(Args);
1422  }
1423 
1424  /// Build a new Objective-C \@try statement.
1425  ///
1426  /// By default, performs semantic analysis to build the new statement.
1427  /// Subclasses may override this routine to provide different behavior.
1429  Stmt *TryBody,
1430  MultiStmtArg CatchStmts,
1431  Stmt *Finally) {
1432  return getSema().ActOnObjCAtTryStmt(AtLoc, TryBody, CatchStmts,
1433  Finally);
1434  }
1435 
1436  /// Rebuild an Objective-C exception declaration.
1437  ///
1438  /// By default, performs semantic analysis to build the new declaration.
1439  /// Subclasses may override this routine to provide different behavior.
1441  TypeSourceInfo *TInfo, QualType T) {
1442  return getSema().BuildObjCExceptionDecl(TInfo, T,
1443  ExceptionDecl->getInnerLocStart(),
1444  ExceptionDecl->getLocation(),
1445  ExceptionDecl->getIdentifier());
1446  }
1447 
1448  /// Build a new Objective-C \@catch statement.
1449  ///
1450  /// By default, performs semantic analysis to build the new statement.
1451  /// Subclasses may override this routine to provide different behavior.
1453  SourceLocation RParenLoc,
1454  VarDecl *Var,
1455  Stmt *Body) {
1456  return getSema().ActOnObjCAtCatchStmt(AtLoc, RParenLoc,
1457  Var, Body);
1458  }
1459 
1460  /// Build a new Objective-C \@finally statement.
1461  ///
1462  /// By default, performs semantic analysis to build the new statement.
1463  /// Subclasses may override this routine to provide different behavior.
1465  Stmt *Body) {
1466  return getSema().ActOnObjCAtFinallyStmt(AtLoc, Body);
1467  }
1468 
1469  /// Build a new Objective-C \@throw statement.
1470  ///
1471  /// By default, performs semantic analysis to build the new statement.
1472  /// Subclasses may override this routine to provide different behavior.
1474  Expr *Operand) {
1475  return getSema().BuildObjCAtThrowStmt(AtLoc, Operand);
1476  }
1477 
1478  /// Build a new OpenMP executable directive.
1479  ///
1480  /// By default, performs semantic analysis to build the new statement.
1481  /// Subclasses may override this routine to provide different behavior.
1483  DeclarationNameInfo DirName,
1484  OpenMPDirectiveKind CancelRegion,
1485  ArrayRef<OMPClause *> Clauses,
1486  Stmt *AStmt, SourceLocation StartLoc,
1487  SourceLocation EndLoc) {
1488  return getSema().ActOnOpenMPExecutableDirective(
1489  Kind, DirName, CancelRegion, Clauses, AStmt, StartLoc, EndLoc);
1490  }
1491 
1492  /// Build a new OpenMP 'if' clause.
1493  ///
1494  /// By default, performs semantic analysis to build the new OpenMP clause.
1495  /// Subclasses may override this routine to provide different behavior.
1497  Expr *Condition, SourceLocation StartLoc,
1498  SourceLocation LParenLoc,
1499  SourceLocation NameModifierLoc,
1501  SourceLocation EndLoc) {
1502  return getSema().ActOnOpenMPIfClause(NameModifier, Condition, StartLoc,
1503  LParenLoc, NameModifierLoc, ColonLoc,
1504  EndLoc);
1505  }
1506 
1507  /// Build a new OpenMP 'final' clause.
1508  ///
1509  /// By default, performs semantic analysis to build the new OpenMP clause.
1510  /// Subclasses may override this routine to provide different behavior.
1512  SourceLocation LParenLoc,
1513  SourceLocation EndLoc) {
1514  return getSema().ActOnOpenMPFinalClause(Condition, StartLoc, LParenLoc,
1515  EndLoc);
1516  }
1517 
1518  /// Build a new OpenMP 'num_threads' clause.
1519  ///
1520  /// By default, performs semantic analysis to build the new OpenMP clause.
1521  /// Subclasses may override this routine to provide different behavior.
1523  SourceLocation StartLoc,
1524  SourceLocation LParenLoc,
1525  SourceLocation EndLoc) {
1526  return getSema().ActOnOpenMPNumThreadsClause(NumThreads, StartLoc,
1527  LParenLoc, EndLoc);
1528  }
1529 
1530  /// Build a new OpenMP 'safelen' 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().ActOnOpenMPSafelenClause(Len, StartLoc, LParenLoc, EndLoc);
1538  }
1539 
1540  /// Build a new OpenMP 'simdlen' 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().ActOnOpenMPSimdlenClause(Len, StartLoc, LParenLoc, EndLoc);
1548  }
1549 
1550  /// Build a new OpenMP 'collapse' clause.
1551  ///
1552  /// By default, performs semantic analysis to build the new OpenMP clause.
1553  /// Subclasses may override this routine to provide different behavior.
1555  SourceLocation LParenLoc,
1556  SourceLocation EndLoc) {
1557  return getSema().ActOnOpenMPCollapseClause(Num, StartLoc, LParenLoc,
1558  EndLoc);
1559  }
1560 
1561  /// Build a new OpenMP 'default' clause.
1562  ///
1563  /// By default, performs semantic analysis to build the new OpenMP clause.
1564  /// Subclasses may override this routine to provide different behavior.
1566  SourceLocation KindKwLoc,
1567  SourceLocation StartLoc,
1568  SourceLocation LParenLoc,
1569  SourceLocation EndLoc) {
1570  return getSema().ActOnOpenMPDefaultClause(Kind, KindKwLoc,
1571  StartLoc, LParenLoc, EndLoc);
1572  }
1573 
1574  /// Build a new OpenMP 'proc_bind' clause.
1575  ///
1576  /// By default, performs semantic analysis to build the new OpenMP clause.
1577  /// Subclasses may override this routine to provide different behavior.
1579  SourceLocation KindKwLoc,
1580  SourceLocation StartLoc,
1581  SourceLocation LParenLoc,
1582  SourceLocation EndLoc) {
1583  return getSema().ActOnOpenMPProcBindClause(Kind, KindKwLoc,
1584  StartLoc, LParenLoc, EndLoc);
1585  }
1586 
1587  /// Build a new OpenMP 'schedule' clause.
1588  ///
1589  /// By default, performs semantic analysis to build the new OpenMP clause.
1590  /// Subclasses may override this routine to provide different behavior.
1593  OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc,
1594  SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc,
1595  SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc) {
1596  return getSema().ActOnOpenMPScheduleClause(
1597  M1, M2, Kind, ChunkSize, StartLoc, LParenLoc, M1Loc, M2Loc, KindLoc,
1598  CommaLoc, EndLoc);
1599  }
1600 
1601  /// Build a new OpenMP 'ordered' 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 EndLoc,
1607  SourceLocation LParenLoc, Expr *Num) {
1608  return getSema().ActOnOpenMPOrderedClause(StartLoc, EndLoc, LParenLoc, Num);
1609  }
1610 
1611  /// Build a new OpenMP 'private' clause.
1612  ///
1613  /// By default, performs semantic analysis to build the new OpenMP clause.
1614  /// Subclasses may override this routine to provide different behavior.
1616  SourceLocation StartLoc,
1617  SourceLocation LParenLoc,
1618  SourceLocation EndLoc) {
1619  return getSema().ActOnOpenMPPrivateClause(VarList, StartLoc, LParenLoc,
1620  EndLoc);
1621  }
1622 
1623  /// Build a new OpenMP 'firstprivate' clause.
1624  ///
1625  /// By default, performs semantic analysis to build the new OpenMP clause.
1626  /// Subclasses may override this routine to provide different behavior.
1628  SourceLocation StartLoc,
1629  SourceLocation LParenLoc,
1630  SourceLocation EndLoc) {
1631  return getSema().ActOnOpenMPFirstprivateClause(VarList, StartLoc, LParenLoc,
1632  EndLoc);
1633  }
1634 
1635  /// Build a new OpenMP 'lastprivate' clause.
1636  ///
1637  /// By default, performs semantic analysis to build the new OpenMP clause.
1638  /// Subclasses may override this routine to provide different behavior.
1640  SourceLocation StartLoc,
1641  SourceLocation LParenLoc,
1642  SourceLocation EndLoc) {
1643  return getSema().ActOnOpenMPLastprivateClause(VarList, StartLoc, LParenLoc,
1644  EndLoc);
1645  }
1646 
1647  /// Build a new OpenMP 'shared' clause.
1648  ///
1649  /// By default, performs semantic analysis to build the new OpenMP clause.
1650  /// Subclasses may override this routine to provide different behavior.
1652  SourceLocation StartLoc,
1653  SourceLocation LParenLoc,
1654  SourceLocation EndLoc) {
1655  return getSema().ActOnOpenMPSharedClause(VarList, StartLoc, LParenLoc,
1656  EndLoc);
1657  }
1658 
1659  /// Build a new OpenMP 'reduction' clause.
1660  ///
1661  /// By default, performs semantic analysis to build the new statement.
1662  /// Subclasses may override this routine to provide different behavior.
1664  SourceLocation StartLoc,
1665  SourceLocation LParenLoc,
1667  SourceLocation EndLoc,
1668  CXXScopeSpec &ReductionIdScopeSpec,
1669  const DeclarationNameInfo &ReductionId,
1670  ArrayRef<Expr *> UnresolvedReductions) {
1671  return getSema().ActOnOpenMPReductionClause(
1672  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1673  ReductionId, UnresolvedReductions);
1674  }
1675 
1676  /// Build a new OpenMP 'task_reduction' clause.
1677  ///
1678  /// By default, performs semantic analysis to build the new statement.
1679  /// Subclasses may override this routine to provide different behavior.
1681  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1683  CXXScopeSpec &ReductionIdScopeSpec,
1684  const DeclarationNameInfo &ReductionId,
1685  ArrayRef<Expr *> UnresolvedReductions) {
1686  return getSema().ActOnOpenMPTaskReductionClause(
1687  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1688  ReductionId, UnresolvedReductions);
1689  }
1690 
1691  /// Build a new OpenMP 'in_reduction' clause.
1692  ///
1693  /// By default, performs semantic analysis to build the new statement.
1694  /// Subclasses may override this routine to provide different behavior.
1695  OMPClause *
1698  SourceLocation EndLoc,
1699  CXXScopeSpec &ReductionIdScopeSpec,
1700  const DeclarationNameInfo &ReductionId,
1701  ArrayRef<Expr *> UnresolvedReductions) {
1702  return getSema().ActOnOpenMPInReductionClause(
1703  VarList, StartLoc, LParenLoc, ColonLoc, EndLoc, ReductionIdScopeSpec,
1704  ReductionId, UnresolvedReductions);
1705  }
1706 
1707  /// Build a new OpenMP 'linear' clause.
1708  ///
1709  /// By default, performs semantic analysis to build the new OpenMP clause.
1710  /// Subclasses may override this routine to provide different behavior.
1712  SourceLocation StartLoc,
1713  SourceLocation LParenLoc,
1717  SourceLocation EndLoc) {
1718  return getSema().ActOnOpenMPLinearClause(VarList, Step, StartLoc, LParenLoc,
1719  Modifier, ModifierLoc, ColonLoc,
1720  EndLoc);
1721  }
1722 
1723  /// Build a new OpenMP 'aligned' clause.
1724  ///
1725  /// By default, performs semantic analysis to build the new OpenMP clause.
1726  /// Subclasses may override this routine to provide different behavior.
1728  SourceLocation StartLoc,
1729  SourceLocation LParenLoc,
1731  SourceLocation EndLoc) {
1732  return getSema().ActOnOpenMPAlignedClause(VarList, Alignment, StartLoc,
1733  LParenLoc, ColonLoc, EndLoc);
1734  }
1735 
1736  /// Build a new OpenMP 'copyin' clause.
1737  ///
1738  /// By default, performs semantic analysis to build the new OpenMP clause.
1739  /// Subclasses may override this routine to provide different behavior.
1741  SourceLocation StartLoc,
1742  SourceLocation LParenLoc,
1743  SourceLocation EndLoc) {
1744  return getSema().ActOnOpenMPCopyinClause(VarList, StartLoc, LParenLoc,
1745  EndLoc);
1746  }
1747 
1748  /// Build a new OpenMP 'copyprivate' clause.
1749  ///
1750  /// By default, performs semantic analysis to build the new OpenMP clause.
1751  /// Subclasses may override this routine to provide different behavior.
1753  SourceLocation StartLoc,
1754  SourceLocation LParenLoc,
1755  SourceLocation EndLoc) {
1756  return getSema().ActOnOpenMPCopyprivateClause(VarList, StartLoc, LParenLoc,
1757  EndLoc);
1758  }
1759 
1760  /// Build a new OpenMP 'flush' pseudo clause.
1761  ///
1762  /// By default, performs semantic analysis to build the new OpenMP clause.
1763  /// Subclasses may override this routine to provide different behavior.
1765  SourceLocation StartLoc,
1766  SourceLocation LParenLoc,
1767  SourceLocation EndLoc) {
1768  return getSema().ActOnOpenMPFlushClause(VarList, StartLoc, LParenLoc,
1769  EndLoc);
1770  }
1771 
1772  /// Build a new OpenMP 'depend' pseudo clause.
1773  ///
1774  /// By default, performs semantic analysis to build the new OpenMP clause.
1775  /// Subclasses may override this routine to provide different behavior.
1776  OMPClause *
1779  SourceLocation StartLoc, SourceLocation LParenLoc,
1780  SourceLocation EndLoc) {
1781  return getSema().ActOnOpenMPDependClause(DepKind, DepLoc, ColonLoc, VarList,
1782  StartLoc, LParenLoc, EndLoc);
1783  }
1784 
1785  /// Build a new OpenMP 'device' clause.
1786  ///
1787  /// By default, performs semantic analysis to build the new statement.
1788  /// Subclasses may override this routine to provide different behavior.
1790  SourceLocation LParenLoc,
1791  SourceLocation EndLoc) {
1792  return getSema().ActOnOpenMPDeviceClause(Device, StartLoc, LParenLoc,
1793  EndLoc);
1794  }
1795 
1796  /// Build a new OpenMP 'map' clause.
1797  ///
1798  /// By default, performs semantic analysis to build the new OpenMP clause.
1799  /// Subclasses may override this routine to provide different behavior.
1800  OMPClause *
1802  OpenMPMapClauseKind MapType, bool IsMapTypeImplicit,
1804  ArrayRef<Expr *> VarList, SourceLocation StartLoc,
1805  SourceLocation LParenLoc, SourceLocation EndLoc) {
1806  return getSema().ActOnOpenMPMapClause(MapTypeModifier, MapType,
1807  IsMapTypeImplicit, MapLoc, ColonLoc,
1808  VarList, StartLoc, LParenLoc, EndLoc);
1809  }
1810 
1811  /// Build a new OpenMP 'num_teams' clause.
1812  ///
1813  /// By default, performs semantic analysis to build the new statement.
1814  /// Subclasses may override this routine to provide different behavior.
1816  SourceLocation LParenLoc,
1817  SourceLocation EndLoc) {
1818  return getSema().ActOnOpenMPNumTeamsClause(NumTeams, StartLoc, LParenLoc,
1819  EndLoc);
1820  }
1821 
1822  /// Build a new OpenMP 'thread_limit' clause.
1823  ///
1824  /// By default, performs semantic analysis to build the new statement.
1825  /// Subclasses may override this routine to provide different behavior.
1827  SourceLocation StartLoc,
1828  SourceLocation LParenLoc,
1829  SourceLocation EndLoc) {
1830  return getSema().ActOnOpenMPThreadLimitClause(ThreadLimit, StartLoc,
1831  LParenLoc, EndLoc);
1832  }
1833 
1834  /// Build a new OpenMP 'priority' clause.
1835  ///
1836  /// By default, performs semantic analysis to build the new statement.
1837  /// Subclasses may override this routine to provide different behavior.
1839  SourceLocation LParenLoc,
1840  SourceLocation EndLoc) {
1841  return getSema().ActOnOpenMPPriorityClause(Priority, StartLoc, LParenLoc,
1842  EndLoc);
1843  }
1844 
1845  /// Build a new OpenMP 'grainsize' clause.
1846  ///
1847  /// By default, performs semantic analysis to build the new statement.
1848  /// Subclasses may override this routine to provide different behavior.
1850  SourceLocation LParenLoc,
1851  SourceLocation EndLoc) {
1852  return getSema().ActOnOpenMPGrainsizeClause(Grainsize, StartLoc, LParenLoc,
1853  EndLoc);
1854  }
1855 
1856  /// Build a new OpenMP 'num_tasks' clause.
1857  ///
1858  /// By default, performs semantic analysis to build the new statement.
1859  /// Subclasses may override this routine to provide different behavior.
1861  SourceLocation LParenLoc,
1862  SourceLocation EndLoc) {
1863  return getSema().ActOnOpenMPNumTasksClause(NumTasks, StartLoc, LParenLoc,
1864  EndLoc);
1865  }
1866 
1867  /// Build a new OpenMP 'hint' clause.
1868  ///
1869  /// By default, performs semantic analysis to build the new statement.
1870  /// Subclasses may override this routine to provide different behavior.
1872  SourceLocation LParenLoc,
1873  SourceLocation EndLoc) {
1874  return getSema().ActOnOpenMPHintClause(Hint, StartLoc, LParenLoc, EndLoc);
1875  }
1876 
1877  /// Build a new OpenMP 'dist_schedule' clause.
1878  ///
1879  /// By default, performs semantic analysis to build the new OpenMP clause.
1880  /// Subclasses may override this routine to provide different behavior.
1881  OMPClause *
1883  Expr *ChunkSize, SourceLocation StartLoc,
1884  SourceLocation LParenLoc, SourceLocation KindLoc,
1885  SourceLocation CommaLoc, SourceLocation EndLoc) {
1886  return getSema().ActOnOpenMPDistScheduleClause(
1887  Kind, ChunkSize, StartLoc, LParenLoc, KindLoc, CommaLoc, EndLoc);
1888  }
1889 
1890  /// Build a new OpenMP 'to' clause.
1891  ///
1892  /// By default, performs semantic analysis to build the new statement.
1893  /// Subclasses may override this routine to provide different behavior.
1895  SourceLocation StartLoc,
1896  SourceLocation LParenLoc,
1897  SourceLocation EndLoc) {
1898  return getSema().ActOnOpenMPToClause(VarList, StartLoc, LParenLoc, EndLoc);
1899  }
1900 
1901  /// Build a new OpenMP 'from' clause.
1902  ///
1903  /// By default, performs semantic analysis to build the new statement.
1904  /// Subclasses may override this routine to provide different behavior.
1906  SourceLocation StartLoc,
1907  SourceLocation LParenLoc,
1908  SourceLocation EndLoc) {
1909  return getSema().ActOnOpenMPFromClause(VarList, StartLoc, LParenLoc,
1910  EndLoc);
1911  }
1912 
1913  /// Build a new OpenMP 'use_device_ptr' clause.
1914  ///
1915  /// By default, performs semantic analysis to build the new OpenMP clause.
1916  /// Subclasses may override this routine to provide different behavior.
1918  SourceLocation StartLoc,
1919  SourceLocation LParenLoc,
1920  SourceLocation EndLoc) {
1921  return getSema().ActOnOpenMPUseDevicePtrClause(VarList, StartLoc, LParenLoc,
1922  EndLoc);
1923  }
1924 
1925  /// Build a new OpenMP 'is_device_ptr' clause.
1926  ///
1927  /// By default, performs semantic analysis to build the new OpenMP clause.
1928  /// Subclasses may override this routine to provide different behavior.
1930  SourceLocation StartLoc,
1931  SourceLocation LParenLoc,
1932  SourceLocation EndLoc) {
1933  return getSema().ActOnOpenMPIsDevicePtrClause(VarList, StartLoc, LParenLoc,
1934  EndLoc);
1935  }
1936 
1937  /// Rebuild the operand to an Objective-C \@synchronized statement.
1938  ///
1939  /// By default, performs semantic analysis to build the new statement.
1940  /// Subclasses may override this routine to provide different behavior.
1942  Expr *object) {
1943  return getSema().ActOnObjCAtSynchronizedOperand(atLoc, object);
1944  }
1945 
1946  /// Build a new Objective-C \@synchronized statement.
1947  ///
1948  /// By default, performs semantic analysis to build the new statement.
1949  /// Subclasses may override this routine to provide different behavior.
1951  Expr *Object, Stmt *Body) {
1952  return getSema().ActOnObjCAtSynchronizedStmt(AtLoc, Object, Body);
1953  }
1954 
1955  /// Build a new Objective-C \@autoreleasepool statement.
1956  ///
1957  /// By default, performs semantic analysis to build the new statement.
1958  /// Subclasses may override this routine to provide different behavior.
1960  Stmt *Body) {
1961  return getSema().ActOnObjCAutoreleasePoolStmt(AtLoc, Body);
1962  }
1963 
1964  /// Build a new Objective-C fast enumeration statement.
1965  ///
1966  /// By default, performs semantic analysis to build the new statement.
1967  /// Subclasses may override this routine to provide different behavior.
1969  Stmt *Element,
1970  Expr *Collection,
1971  SourceLocation RParenLoc,
1972  Stmt *Body) {
1973  StmtResult ForEachStmt = getSema().ActOnObjCForCollectionStmt(ForLoc,
1974  Element,
1975  Collection,
1976  RParenLoc);
1977  if (ForEachStmt.isInvalid())
1978  return StmtError();
1979 
1980  return getSema().FinishObjCForCollectionStmt(ForEachStmt.get(), Body);
1981  }
1982 
1983  /// Build a new C++ exception declaration.
1984  ///
1985  /// By default, performs semantic analysis to build the new decaration.
1986  /// Subclasses may override this routine to provide different behavior.
1989  SourceLocation StartLoc,
1990  SourceLocation IdLoc,
1991  IdentifierInfo *Id) {
1992  VarDecl *Var = getSema().BuildExceptionDeclaration(nullptr, Declarator,
1993  StartLoc, IdLoc, Id);
1994  if (Var)
1995  getSema().CurContext->addDecl(Var);
1996  return Var;
1997  }
1998 
1999  /// Build a new C++ catch statement.
2000  ///
2001  /// By default, performs semantic analysis to build the new statement.
2002  /// Subclasses may override this routine to provide different behavior.
2004  VarDecl *ExceptionDecl,
2005  Stmt *Handler) {
2006  return Owned(new (getSema().Context) CXXCatchStmt(CatchLoc, ExceptionDecl,
2007  Handler));
2008  }
2009 
2010  /// Build a new C++ try statement.
2011  ///
2012  /// By default, performs semantic analysis to build the new statement.
2013  /// Subclasses may override this routine to provide different behavior.
2015  ArrayRef<Stmt *> Handlers) {
2016  return getSema().ActOnCXXTryBlock(TryLoc, TryBlock, Handlers);
2017  }
2018 
2019  /// Build a new C++0x range-based for statement.
2020  ///
2021  /// By default, performs semantic analysis to build the new statement.
2022  /// Subclasses may override this routine to provide different behavior.
2024  SourceLocation CoawaitLoc,
2026  Stmt *Range, Stmt *Begin, Stmt *End,
2027  Expr *Cond, Expr *Inc,
2028  Stmt *LoopVar,
2029  SourceLocation RParenLoc) {
2030  // If we've just learned that the range is actually an Objective-C
2031  // collection, treat this as an Objective-C fast enumeration loop.
2032  if (DeclStmt *RangeStmt = dyn_cast<DeclStmt>(Range)) {
2033  if (RangeStmt->isSingleDecl()) {
2034  if (VarDecl *RangeVar = dyn_cast<VarDecl>(RangeStmt->getSingleDecl())) {
2035  if (RangeVar->isInvalidDecl())
2036  return StmtError();
2037 
2038  Expr *RangeExpr = RangeVar->getInit();
2039  if (!RangeExpr->isTypeDependent() &&
2040  RangeExpr->getType()->isObjCObjectPointerType())
2041  return getSema().ActOnObjCForCollectionStmt(ForLoc, LoopVar, RangeExpr,
2042  RParenLoc);
2043  }
2044  }
2045  }
2046 
2047  return getSema().BuildCXXForRangeStmt(ForLoc, CoawaitLoc, ColonLoc,
2048  Range, Begin, End,
2049  Cond, Inc, LoopVar, RParenLoc,
2051  }
2052 
2053  /// Build a new C++0x range-based for statement.
2054  ///
2055  /// By default, performs semantic analysis to build the new statement.
2056  /// Subclasses may override this routine to provide different behavior.
2058  bool IsIfExists,
2059  NestedNameSpecifierLoc QualifierLoc,
2060  DeclarationNameInfo NameInfo,
2061  Stmt *Nested) {
2062  return getSema().BuildMSDependentExistsStmt(KeywordLoc, IsIfExists,
2063  QualifierLoc, NameInfo, Nested);
2064  }
2065 
2066  /// Attach body to a C++0x range-based for statement.
2067  ///
2068  /// By default, performs semantic analysis to finish the new statement.
2069  /// Subclasses may override this routine to provide different behavior.
2071  return getSema().FinishCXXForRangeStmt(ForRange, Body);
2072  }
2073 
2075  Stmt *TryBlock, Stmt *Handler) {
2076  return getSema().ActOnSEHTryBlock(IsCXXTry, TryLoc, TryBlock, Handler);
2077  }
2078 
2080  Stmt *Block) {
2081  return getSema().ActOnSEHExceptBlock(Loc, FilterExpr, Block);
2082  }
2083 
2085  return SEHFinallyStmt::Create(getSema().getASTContext(), Loc, Block);
2086  }
2087 
2088  /// Build a new predefined expression.
2089  ///
2090  /// By default, performs semantic analysis to build the new expression.
2091  /// Subclasses may override this routine to provide different behavior.
2094  return getSema().BuildPredefinedExpr(Loc, IT);
2095  }
2096 
2097  /// Build a new expression that references a declaration.
2098  ///
2099  /// By default, performs semantic analysis to build the new expression.
2100  /// Subclasses may override this routine to provide different behavior.
2102  LookupResult &R,
2103  bool RequiresADL) {
2104  return getSema().BuildDeclarationNameExpr(SS, R, RequiresADL);
2105  }
2106 
2107 
2108  /// Build a new expression that references a declaration.
2109  ///
2110  /// By default, performs semantic analysis to build the new expression.
2111  /// Subclasses may override this routine to provide different behavior.
2113  ValueDecl *VD,
2114  const DeclarationNameInfo &NameInfo,
2115  TemplateArgumentListInfo *TemplateArgs) {
2116  CXXScopeSpec SS;
2117  SS.Adopt(QualifierLoc);
2118 
2119  // FIXME: loses template args.
2120 
2121  return getSema().BuildDeclarationNameExpr(SS, NameInfo, VD);
2122  }
2123 
2124  /// Build a new expression in parentheses.
2125  ///
2126  /// By default, performs semantic analysis to build the new expression.
2127  /// Subclasses may override this routine to provide different behavior.
2129  SourceLocation RParen) {
2130  return getSema().ActOnParenExpr(LParen, RParen, SubExpr);
2131  }
2132 
2133  /// Build a new pseudo-destructor expression.
2134  ///
2135  /// By default, performs semantic analysis to build the new expression.
2136  /// Subclasses may override this routine to provide different behavior.
2137  ExprResult RebuildCXXPseudoDestructorExpr(Expr *Base,
2138  SourceLocation OperatorLoc,
2139  bool isArrow,
2140  CXXScopeSpec &SS,
2141  TypeSourceInfo *ScopeType,
2142  SourceLocation CCLoc,
2143  SourceLocation TildeLoc,
2144  PseudoDestructorTypeStorage Destroyed);
2145 
2146  /// Build a new unary operator expression.
2147  ///
2148  /// By default, performs semantic analysis to build the new expression.
2149  /// Subclasses may override this routine to provide different behavior.
2151  UnaryOperatorKind Opc,
2152  Expr *SubExpr) {
2153  return getSema().BuildUnaryOp(/*Scope=*/nullptr, OpLoc, Opc, SubExpr);
2154  }
2155 
2156  /// Build a new builtin offsetof expression.
2157  ///
2158  /// By default, performs semantic analysis to build the new expression.
2159  /// Subclasses may override this routine to provide different behavior.
2163  SourceLocation RParenLoc) {
2164  return getSema().BuildBuiltinOffsetOf(OperatorLoc, Type, Components,
2165  RParenLoc);
2166  }
2167 
2168  /// Build a new sizeof, alignof or vec_step expression with a
2169  /// type argument.
2170  ///
2171  /// By default, performs semantic analysis to build the new expression.
2172  /// Subclasses may override this routine to provide different behavior.
2174  SourceLocation OpLoc,
2175  UnaryExprOrTypeTrait ExprKind,
2176  SourceRange R) {
2177  return getSema().CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, R);
2178  }
2179 
2180  /// Build a new sizeof, alignof or vec step expression with an
2181  /// expression argument.
2182  ///
2183  /// By default, performs semantic analysis to build the new expression.
2184  /// Subclasses may override this routine to provide different behavior.
2186  UnaryExprOrTypeTrait ExprKind,
2187  SourceRange R) {
2188  ExprResult Result
2189  = getSema().CreateUnaryExprOrTypeTraitExpr(SubExpr, OpLoc, ExprKind);
2190  if (Result.isInvalid())
2191  return ExprError();
2192 
2193  return Result;
2194  }
2195 
2196  /// Build a new array subscript expression.
2197  ///
2198  /// By default, performs semantic analysis to build the new expression.
2199  /// Subclasses may override this routine to provide different behavior.
2201  SourceLocation LBracketLoc,
2202  Expr *RHS,
2203  SourceLocation RBracketLoc) {
2204  return getSema().ActOnArraySubscriptExpr(/*Scope=*/nullptr, LHS,
2205  LBracketLoc, RHS,
2206  RBracketLoc);
2207  }
2208 
2209  /// Build a new array section expression.
2210  ///
2211  /// By default, performs semantic analysis to build the new expression.
2212  /// Subclasses may override this routine to provide different behavior.
2214  Expr *LowerBound,
2215  SourceLocation ColonLoc, Expr *Length,
2216  SourceLocation RBracketLoc) {
2217  return getSema().ActOnOMPArraySectionExpr(Base, LBracketLoc, LowerBound,
2218  ColonLoc, Length, RBracketLoc);
2219  }
2220 
2221  /// Build a new call expression.
2222  ///
2223  /// By default, performs semantic analysis to build the new expression.
2224  /// Subclasses may override this routine to provide different behavior.
2226  MultiExprArg Args,
2227  SourceLocation RParenLoc,
2228  Expr *ExecConfig = nullptr) {
2229  return getSema().ActOnCallExpr(/*Scope=*/nullptr, Callee, LParenLoc,
2230  Args, RParenLoc, ExecConfig);
2231  }
2232 
2233  /// Build a new member access expression.
2234  ///
2235  /// By default, performs semantic analysis to build the new expression.
2236  /// Subclasses may override this routine to provide different behavior.
2238  bool isArrow,
2239  NestedNameSpecifierLoc QualifierLoc,
2240  SourceLocation TemplateKWLoc,
2241  const DeclarationNameInfo &MemberNameInfo,
2242  ValueDecl *Member,
2243  NamedDecl *FoundDecl,
2244  const TemplateArgumentListInfo *ExplicitTemplateArgs,
2245  NamedDecl *FirstQualifierInScope) {
2246  ExprResult BaseResult = getSema().PerformMemberExprBaseConversion(Base,
2247  isArrow);
2248  if (!Member->getDeclName()) {
2249  // We have a reference to an unnamed field. This is always the
2250  // base of an anonymous struct/union member access, i.e. the
2251  // field is always of record type.
2252  assert(Member->getType()->isRecordType() &&
2253  "unnamed member not of record type?");
2254 
2255  BaseResult =
2256  getSema().PerformObjectMemberConversion(BaseResult.get(),
2257  QualifierLoc.getNestedNameSpecifier(),
2258  FoundDecl, Member);
2259  if (BaseResult.isInvalid())
2260  return ExprError();
2261  Base = BaseResult.get();
2262 
2263  CXXScopeSpec EmptySS;
2264  return getSema().BuildFieldReferenceExpr(
2265  Base, isArrow, OpLoc, EmptySS, cast<FieldDecl>(Member),
2266  DeclAccessPair::make(FoundDecl, FoundDecl->getAccess()), MemberNameInfo);
2267  }
2268 
2269  CXXScopeSpec SS;
2270  SS.Adopt(QualifierLoc);
2271 
2272  Base = BaseResult.get();
2273  QualType BaseType = Base->getType();
2274 
2275  if (isArrow && !BaseType->isPointerType())
2276  return ExprError();
2277 
2278  // FIXME: this involves duplicating earlier analysis in a lot of
2279  // cases; we should avoid this when possible.
2280  LookupResult R(getSema(), MemberNameInfo, Sema::LookupMemberName);
2281  R.addDecl(FoundDecl);
2282  R.resolveKind();
2283 
2284  return getSema().BuildMemberReferenceExpr(Base, BaseType, OpLoc, isArrow,
2285  SS, TemplateKWLoc,
2286  FirstQualifierInScope,
2287  R, ExplicitTemplateArgs,
2288  /*S*/nullptr);
2289  }
2290 
2291  /// Build a new binary operator expression.
2292  ///
2293  /// By default, performs semantic analysis to build the new expression.
2294  /// Subclasses may override this routine to provide different behavior.
2296  BinaryOperatorKind Opc,
2297  Expr *LHS, Expr *RHS) {
2298  return getSema().BuildBinOp(/*Scope=*/nullptr, OpLoc, Opc, LHS, RHS);
2299  }
2300 
2301  /// Build a new conditional operator expression.
2302  ///
2303  /// By default, performs semantic analysis to build the new expression.
2304  /// Subclasses may override this routine to provide different behavior.
2306  SourceLocation QuestionLoc,
2307  Expr *LHS,
2309  Expr *RHS) {
2310  return getSema().ActOnConditionalOp(QuestionLoc, ColonLoc, Cond,
2311  LHS, RHS);
2312  }
2313 
2314  /// Build a new C-style cast expression.
2315  ///
2316  /// By default, performs semantic analysis to build the new expression.
2317  /// Subclasses may override this routine to provide different behavior.
2319  TypeSourceInfo *TInfo,
2320  SourceLocation RParenLoc,
2321  Expr *SubExpr) {
2322  return getSema().BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc,
2323  SubExpr);
2324  }
2325 
2326  /// Build a new compound literal expression.
2327  ///
2328  /// By default, performs semantic analysis to build the new expression.
2329  /// Subclasses may override this routine to provide different behavior.
2331  TypeSourceInfo *TInfo,
2332  SourceLocation RParenLoc,
2333  Expr *Init) {
2334  return getSema().BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc,
2335  Init);
2336  }
2337 
2338  /// Build a new extended vector element access expression.
2339  ///
2340  /// By default, performs semantic analysis to build the new expression.
2341  /// Subclasses may override this routine to provide different behavior.
2343  SourceLocation OpLoc,
2344  SourceLocation AccessorLoc,
2345  IdentifierInfo &Accessor) {
2346 
2347  CXXScopeSpec SS;
2348  DeclarationNameInfo NameInfo(&Accessor, AccessorLoc);
2349  return getSema().BuildMemberReferenceExpr(Base, Base->getType(),
2350  OpLoc, /*IsArrow*/ false,
2351  SS, SourceLocation(),
2352  /*FirstQualifierInScope*/ nullptr,
2353  NameInfo,
2354  /* TemplateArgs */ nullptr,
2355  /*S*/ nullptr);
2356  }
2357 
2358  /// Build a new initializer list expression.
2359  ///
2360  /// By default, performs semantic analysis to build the new expression.
2361  /// Subclasses may override this routine to provide different behavior.
2364  SourceLocation RBraceLoc) {
2365  return SemaRef.ActOnInitList(LBraceLoc, Inits, RBraceLoc);
2366  }
2367 
2368  /// Build a new designated initializer expression.
2369  ///
2370  /// By default, performs semantic analysis to build the new expression.
2371  /// Subclasses may override this routine to provide different behavior.
2373  MultiExprArg ArrayExprs,
2374  SourceLocation EqualOrColonLoc,
2375  bool GNUSyntax,
2376  Expr *Init) {
2377  ExprResult Result
2378  = SemaRef.ActOnDesignatedInitializer(Desig, EqualOrColonLoc, GNUSyntax,
2379  Init);
2380  if (Result.isInvalid())
2381  return ExprError();
2382 
2383  return Result;
2384  }
2385 
2386  /// Build a new value-initialized expression.
2387  ///
2388  /// By default, builds the implicit value initialization without performing
2389  /// any semantic analysis. Subclasses may override this routine to provide
2390  /// different behavior.
2392  return new (SemaRef.Context) ImplicitValueInitExpr(T);
2393  }
2394 
2395  /// Build a new \c va_arg expression.
2396  ///
2397  /// By default, performs semantic analysis to build the new expression.
2398  /// Subclasses may override this routine to provide different behavior.
2400  Expr *SubExpr, TypeSourceInfo *TInfo,
2401  SourceLocation RParenLoc) {
2402  return getSema().BuildVAArgExpr(BuiltinLoc,
2403  SubExpr, TInfo,
2404  RParenLoc);
2405  }
2406 
2407  /// Build a new expression list in parentheses.
2408  ///
2409  /// By default, performs semantic analysis to build the new expression.
2410  /// Subclasses may override this routine to provide different behavior.
2412  MultiExprArg SubExprs,
2413  SourceLocation RParenLoc) {
2414  return getSema().ActOnParenListExpr(LParenLoc, RParenLoc, SubExprs);
2415  }
2416 
2417  /// Build a new address-of-label expression.
2418  ///
2419  /// By default, performs semantic analysis, using the name of the label
2420  /// rather than attempting to map the label statement itself.
2421  /// Subclasses may override this routine to provide different behavior.
2423  SourceLocation LabelLoc, LabelDecl *Label) {
2424  return getSema().ActOnAddrLabel(AmpAmpLoc, LabelLoc, Label);
2425  }
2426 
2427  /// Build a new GNU statement expression.
2428  ///
2429  /// By default, performs semantic analysis to build the new expression.
2430  /// Subclasses may override this routine to provide different behavior.
2432  Stmt *SubStmt,
2433  SourceLocation RParenLoc) {
2434  return getSema().ActOnStmtExpr(LParenLoc, SubStmt, RParenLoc);
2435  }
2436 
2437  /// Build a new __builtin_choose_expr expression.
2438  ///
2439  /// By default, performs semantic analysis to build the new expression.
2440  /// Subclasses may override this routine to provide different behavior.
2442  Expr *Cond, Expr *LHS, Expr *RHS,
2443  SourceLocation RParenLoc) {
2444  return SemaRef.ActOnChooseExpr(BuiltinLoc,
2445  Cond, LHS, RHS,
2446  RParenLoc);
2447  }
2448 
2449  /// Build a new generic selection expression.
2450  ///
2451  /// By default, performs semantic analysis to build the new expression.
2452  /// Subclasses may override this routine to provide different behavior.
2454  SourceLocation DefaultLoc,
2455  SourceLocation RParenLoc,
2456  Expr *ControllingExpr,
2458  ArrayRef<Expr *> Exprs) {
2459  return getSema().CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
2460  ControllingExpr, Types, Exprs);
2461  }
2462 
2463  /// Build a new overloaded operator call expression.
2464  ///
2465  /// By default, performs semantic analysis to build the new expression.
2466  /// The semantic analysis provides the behavior of template instantiation,
2467  /// copying with transformations that turn what looks like an overloaded
2468  /// operator call into a use of a builtin operator, performing
2469  /// argument-dependent lookup, etc. Subclasses may override this routine to
2470  /// provide different behavior.
2471  ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
2472  SourceLocation OpLoc,
2473  Expr *Callee,
2474  Expr *First,
2475  Expr *Second);
2476 
2477  /// Build a new C++ "named" cast expression, such as static_cast or
2478  /// reinterpret_cast.
2479  ///
2480  /// By default, this routine dispatches to one of the more-specific routines
2481  /// for a particular named case, e.g., RebuildCXXStaticCastExpr().
2482  /// Subclasses may override this routine to provide different behavior.
2484  Stmt::StmtClass Class,
2485  SourceLocation LAngleLoc,
2486  TypeSourceInfo *TInfo,
2487  SourceLocation RAngleLoc,
2488  SourceLocation LParenLoc,
2489  Expr *SubExpr,
2490  SourceLocation RParenLoc) {
2491  switch (Class) {
2492  case Stmt::CXXStaticCastExprClass:
2493  return getDerived().RebuildCXXStaticCastExpr(OpLoc, LAngleLoc, TInfo,
2494  RAngleLoc, LParenLoc,
2495  SubExpr, RParenLoc);
2496 
2497  case Stmt::CXXDynamicCastExprClass:
2498  return getDerived().RebuildCXXDynamicCastExpr(OpLoc, LAngleLoc, TInfo,
2499  RAngleLoc, LParenLoc,
2500  SubExpr, RParenLoc);
2501 
2502  case Stmt::CXXReinterpretCastExprClass:
2503  return getDerived().RebuildCXXReinterpretCastExpr(OpLoc, LAngleLoc, TInfo,
2504  RAngleLoc, LParenLoc,
2505  SubExpr,
2506  RParenLoc);
2507 
2508  case Stmt::CXXConstCastExprClass:
2509  return getDerived().RebuildCXXConstCastExpr(OpLoc, LAngleLoc, TInfo,
2510  RAngleLoc, LParenLoc,
2511  SubExpr, RParenLoc);
2512 
2513  default:
2514  llvm_unreachable("Invalid C++ named cast");
2515  }
2516  }
2517 
2518  /// Build a new C++ static_cast expression.
2519  ///
2520  /// By default, performs semantic analysis to build the new expression.
2521  /// Subclasses may override this routine to provide different behavior.
2523  SourceLocation LAngleLoc,
2524  TypeSourceInfo *TInfo,
2525  SourceLocation RAngleLoc,
2526  SourceLocation LParenLoc,
2527  Expr *SubExpr,
2528  SourceLocation RParenLoc) {
2529  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_static_cast,
2530  TInfo, SubExpr,
2531  SourceRange(LAngleLoc, RAngleLoc),
2532  SourceRange(LParenLoc, RParenLoc));
2533  }
2534 
2535  /// Build a new C++ dynamic_cast expression.
2536  ///
2537  /// By default, performs semantic analysis to build the new expression.
2538  /// Subclasses may override this routine to provide different behavior.
2540  SourceLocation LAngleLoc,
2541  TypeSourceInfo *TInfo,
2542  SourceLocation RAngleLoc,
2543  SourceLocation LParenLoc,
2544  Expr *SubExpr,
2545  SourceLocation RParenLoc) {
2546  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_dynamic_cast,
2547  TInfo, SubExpr,
2548  SourceRange(LAngleLoc, RAngleLoc),
2549  SourceRange(LParenLoc, RParenLoc));
2550  }
2551 
2552  /// Build a new C++ reinterpret_cast expression.
2553  ///
2554  /// By default, performs semantic analysis to build the new expression.
2555  /// Subclasses may override this routine to provide different behavior.
2557  SourceLocation LAngleLoc,
2558  TypeSourceInfo *TInfo,
2559  SourceLocation RAngleLoc,
2560  SourceLocation LParenLoc,
2561  Expr *SubExpr,
2562  SourceLocation RParenLoc) {
2563  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_reinterpret_cast,
2564  TInfo, SubExpr,
2565  SourceRange(LAngleLoc, RAngleLoc),
2566  SourceRange(LParenLoc, RParenLoc));
2567  }
2568 
2569  /// Build a new C++ const_cast expression.
2570  ///
2571  /// By default, performs semantic analysis to build the new expression.
2572  /// Subclasses may override this routine to provide different behavior.
2574  SourceLocation LAngleLoc,
2575  TypeSourceInfo *TInfo,
2576  SourceLocation RAngleLoc,
2577  SourceLocation LParenLoc,
2578  Expr *SubExpr,
2579  SourceLocation RParenLoc) {
2580  return getSema().BuildCXXNamedCast(OpLoc, tok::kw_const_cast,
2581  TInfo, SubExpr,
2582  SourceRange(LAngleLoc, RAngleLoc),
2583  SourceRange(LParenLoc, RParenLoc));
2584  }
2585 
2586  /// Build a new C++ functional-style cast expression.
2587  ///
2588  /// By default, performs semantic analysis to build the new expression.
2589  /// Subclasses may override this routine to provide different behavior.
2591  SourceLocation LParenLoc,
2592  Expr *Sub,
2593  SourceLocation RParenLoc,
2594  bool ListInitialization) {
2595  return getSema().BuildCXXTypeConstructExpr(TInfo, LParenLoc,
2596  MultiExprArg(&Sub, 1), RParenLoc,
2597  ListInitialization);
2598  }
2599 
2600  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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(
2698  TSInfo, LParenLoc, None, RParenLoc, /*ListInitialization=*/false);
2699  }
2700 
2701  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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  /// 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 LParenOrBraceLoc,
2856  MultiExprArg Args,
2857  SourceLocation RParenOrBraceLoc,
2858  bool ListInitialization) {
2859  return getSema().BuildCXXTypeConstructExpr(
2860  TSInfo, LParenOrBraceLoc, Args, RParenOrBraceLoc, ListInitialization);
2861  }
2862 
2863  /// Build a new object-construction expression.
2864  ///
2865  /// By default, performs semantic analysis to build the new expression.
2866  /// Subclasses may override this routine to provide different behavior.
2868  SourceLocation LParenLoc,
2869  MultiExprArg Args,
2870  SourceLocation RParenLoc,
2871  bool ListInitialization) {
2872  return getSema().BuildCXXTypeConstructExpr(TSInfo, LParenLoc, Args,
2873  RParenLoc, ListInitialization);
2874  }
2875 
2876  /// Build a new member reference expression.
2877  ///
2878  /// By default, performs semantic analysis to build the new expression.
2879  /// Subclasses may override this routine to provide different behavior.
2881  QualType BaseType,
2882  bool IsArrow,
2883  SourceLocation OperatorLoc,
2884  NestedNameSpecifierLoc QualifierLoc,
2885  SourceLocation TemplateKWLoc,
2886  NamedDecl *FirstQualifierInScope,
2887  const DeclarationNameInfo &MemberNameInfo,
2888  const TemplateArgumentListInfo *TemplateArgs) {
2889  CXXScopeSpec SS;
2890  SS.Adopt(QualifierLoc);
2891 
2892  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
2893  OperatorLoc, IsArrow,
2894  SS, TemplateKWLoc,
2895  FirstQualifierInScope,
2896  MemberNameInfo,
2897  TemplateArgs, /*S*/nullptr);
2898  }
2899 
2900  /// Build a new member reference expression.
2901  ///
2902  /// By default, performs semantic analysis to build the new expression.
2903  /// Subclasses may override this routine to provide different behavior.
2905  SourceLocation OperatorLoc,
2906  bool IsArrow,
2907  NestedNameSpecifierLoc QualifierLoc,
2908  SourceLocation TemplateKWLoc,
2909  NamedDecl *FirstQualifierInScope,
2910  LookupResult &R,
2911  const TemplateArgumentListInfo *TemplateArgs) {
2912  CXXScopeSpec SS;
2913  SS.Adopt(QualifierLoc);
2914 
2915  return SemaRef.BuildMemberReferenceExpr(BaseE, BaseType,
2916  OperatorLoc, IsArrow,
2917  SS, TemplateKWLoc,
2918  FirstQualifierInScope,
2919  R, TemplateArgs, /*S*/nullptr);
2920  }
2921 
2922  /// Build a new noexcept expression.
2923  ///
2924  /// By default, performs semantic analysis to build the new expression.
2925  /// Subclasses may override this routine to provide different behavior.
2927  return SemaRef.BuildCXXNoexceptExpr(Range.getBegin(), Arg, Range.getEnd());
2928  }
2929 
2930  /// Build a new expression to compute the length of a parameter pack.
2932  NamedDecl *Pack,
2933  SourceLocation PackLoc,
2934  SourceLocation RParenLoc,
2935  Optional<unsigned> Length,
2936  ArrayRef<TemplateArgument> PartialArgs) {
2937  return SizeOfPackExpr::Create(SemaRef.Context, OperatorLoc, Pack, PackLoc,
2938  RParenLoc, Length, PartialArgs);
2939  }
2940 
2941  /// Build a new Objective-C boxed expression.
2942  ///
2943  /// By default, performs semantic analysis to build the new expression.
2944  /// Subclasses may override this routine to provide different behavior.
2946  return getSema().BuildObjCBoxedExpr(SR, ValueExpr);
2947  }
2948 
2949  /// Build a new Objective-C array literal.
2950  ///
2951  /// By default, performs semantic analysis to build the new expression.
2952  /// Subclasses may override this routine to provide different behavior.
2954  Expr **Elements, unsigned NumElements) {
2955  return getSema().BuildObjCArrayLiteral(Range,
2956  MultiExprArg(Elements, NumElements));
2957  }
2958 
2960  Expr *Base, Expr *Key,
2961  ObjCMethodDecl *getterMethod,
2962  ObjCMethodDecl *setterMethod) {
2963  return getSema().BuildObjCSubscriptExpression(RB, Base, Key,
2964  getterMethod, setterMethod);
2965  }
2966 
2967  /// Build a new Objective-C dictionary literal.
2968  ///
2969  /// By default, performs semantic analysis to build the new expression.
2970  /// Subclasses may override this routine to provide different behavior.
2973  return getSema().BuildObjCDictionaryLiteral(Range, Elements);
2974  }
2975 
2976  /// Build a new Objective-C \@encode expression.
2977  ///
2978  /// By default, performs semantic analysis to build the new expression.
2979  /// Subclasses may override this routine to provide different behavior.
2981  TypeSourceInfo *EncodeTypeInfo,
2982  SourceLocation RParenLoc) {
2983  return SemaRef.BuildObjCEncodeExpression(AtLoc, EncodeTypeInfo, RParenLoc);
2984  }
2985 
2986  /// Build a new Objective-C class message.
2988  Selector Sel,
2989  ArrayRef<SourceLocation> SelectorLocs,
2990  ObjCMethodDecl *Method,
2991  SourceLocation LBracLoc,
2992  MultiExprArg Args,
2993  SourceLocation RBracLoc) {
2994  return SemaRef.BuildClassMessage(ReceiverTypeInfo,
2995  ReceiverTypeInfo->getType(),
2996  /*SuperLoc=*/SourceLocation(),
2997  Sel, Method, LBracLoc, SelectorLocs,
2998  RBracLoc, Args);
2999  }
3000 
3001  /// Build a new Objective-C instance message.
3003  Selector Sel,
3004  ArrayRef<SourceLocation> SelectorLocs,
3005  ObjCMethodDecl *Method,
3006  SourceLocation LBracLoc,
3007  MultiExprArg Args,
3008  SourceLocation RBracLoc) {
3009  return SemaRef.BuildInstanceMessage(Receiver,
3010  Receiver->getType(),
3011  /*SuperLoc=*/SourceLocation(),
3012  Sel, Method, LBracLoc, SelectorLocs,
3013  RBracLoc, Args);
3014  }
3015 
3016  /// Build a new Objective-C instance/class message to 'super'.
3018  Selector Sel,
3019  ArrayRef<SourceLocation> SelectorLocs,
3020  QualType SuperType,
3021  ObjCMethodDecl *Method,
3022  SourceLocation LBracLoc,
3023  MultiExprArg Args,
3024  SourceLocation RBracLoc) {
3025  return Method->isInstanceMethod() ? SemaRef.BuildInstanceMessage(nullptr,
3026  SuperType,
3027  SuperLoc,
3028  Sel, Method, LBracLoc, SelectorLocs,
3029  RBracLoc, Args)
3030  : SemaRef.BuildClassMessage(nullptr,
3031  SuperType,
3032  SuperLoc,
3033  Sel, Method, LBracLoc, SelectorLocs,
3034  RBracLoc, Args);
3035 
3036 
3037  }
3038 
3039  /// Build a new Objective-C ivar reference expression.
3040  ///
3041  /// By default, performs semantic analysis to build the new expression.
3042  /// Subclasses may override this routine to provide different behavior.
3044  SourceLocation IvarLoc,
3045  bool IsArrow, bool IsFreeIvar) {
3046  CXXScopeSpec SS;
3047  DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
3048  ExprResult Result = getSema().BuildMemberReferenceExpr(
3049  BaseArg, BaseArg->getType(),
3050  /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
3051  /*FirstQualifierInScope=*/nullptr, NameInfo,
3052  /*TemplateArgs=*/nullptr,
3053  /*S=*/nullptr);
3054  if (IsFreeIvar && Result.isUsable())
3055  cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
3056  return Result;
3057  }
3058 
3059  /// Build a new Objective-C property reference expression.
3060  ///
3061  /// By default, performs semantic analysis to build the new expression.
3062  /// Subclasses may override this routine to provide different behavior.
3064  ObjCPropertyDecl *Property,
3065  SourceLocation PropertyLoc) {
3066  CXXScopeSpec SS;
3067  DeclarationNameInfo NameInfo(Property->getDeclName(), PropertyLoc);
3068  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3069  /*FIXME:*/PropertyLoc,
3070  /*IsArrow=*/false,
3071  SS, SourceLocation(),
3072  /*FirstQualifierInScope=*/nullptr,
3073  NameInfo,
3074  /*TemplateArgs=*/nullptr,
3075  /*S=*/nullptr);
3076  }
3077 
3078  /// Build a new Objective-C property reference expression.
3079  ///
3080  /// By default, performs semantic analysis to build the new expression.
3081  /// Subclasses may override this routine to provide different behavior.
3083  ObjCMethodDecl *Getter,
3084  ObjCMethodDecl *Setter,
3085  SourceLocation PropertyLoc) {
3086  // Since these expressions can only be value-dependent, we do not
3087  // need to perform semantic analysis again.
3088  return Owned(
3089  new (getSema().Context) ObjCPropertyRefExpr(Getter, Setter, T,
3091  PropertyLoc, Base));
3092  }
3093 
3094  /// Build a new Objective-C "isa" expression.
3095  ///
3096  /// By default, performs semantic analysis to build the new expression.
3097  /// Subclasses may override this routine to provide different behavior.
3099  SourceLocation OpLoc, bool IsArrow) {
3100  CXXScopeSpec SS;
3101  DeclarationNameInfo NameInfo(&getSema().Context.Idents.get("isa"), IsaLoc);
3102  return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
3103  OpLoc, IsArrow,
3104  SS, SourceLocation(),
3105  /*FirstQualifierInScope=*/nullptr,
3106  NameInfo,
3107  /*TemplateArgs=*/nullptr,
3108  /*S=*/nullptr);
3109  }
3110 
3111  /// Build a new shuffle vector expression.
3112  ///
3113  /// By default, performs semantic analysis to build the new expression.
3114  /// Subclasses may override this routine to provide different behavior.
3116  MultiExprArg SubExprs,
3117  SourceLocation RParenLoc) {
3118  // Find the declaration for __builtin_shufflevector
3119  const IdentifierInfo &Name
3120  = SemaRef.Context.Idents.get("__builtin_shufflevector");
3122  DeclContext::lookup_result Lookup = TUDecl->lookup(DeclarationName(&Name));
3123  assert(!Lookup.empty() && "No __builtin_shufflevector?");
3124 
3125  // Build a reference to the __builtin_shufflevector builtin
3126  FunctionDecl *Builtin = cast<FunctionDecl>(Lookup.front());
3127  Expr *Callee = new (SemaRef.Context) DeclRefExpr(Builtin, false,
3128  SemaRef.Context.BuiltinFnTy,
3129  VK_RValue, BuiltinLoc);
3130  QualType CalleePtrTy = SemaRef.Context.getPointerType(Builtin->getType());
3131  Callee = SemaRef.ImpCastExprToType(Callee, CalleePtrTy,
3132  CK_BuiltinFnToFnPtr).get();
3133 
3134  // Build the CallExpr
3135  ExprResult TheCall = new (SemaRef.Context) CallExpr(
3136  SemaRef.Context, Callee, SubExprs, Builtin->getCallResultType(),
3137  Expr::getValueKindForType(Builtin->getReturnType()), RParenLoc);
3138 
3139  // Type-check the __builtin_shufflevector expression.
3140  return SemaRef.SemaBuiltinShuffleVector(cast<CallExpr>(TheCall.get()));
3141  }
3142 
3143  /// Build a new convert vector expression.
3145  Expr *SrcExpr, TypeSourceInfo *DstTInfo,
3146  SourceLocation RParenLoc) {
3147  return SemaRef.SemaConvertVectorExpr(SrcExpr, DstTInfo,
3148  BuiltinLoc, RParenLoc);
3149  }
3150 
3151  /// Build a new template argument pack expansion.
3152  ///
3153  /// By default, performs semantic analysis to build a new pack expansion
3154  /// for a template argument. Subclasses may override this routine to provide
3155  /// different behavior.
3157  SourceLocation EllipsisLoc,
3158  Optional<unsigned> NumExpansions) {
3159  switch (Pattern.getArgument().getKind()) {
3161  ExprResult Result
3162  = getSema().CheckPackExpansion(Pattern.getSourceExpression(),
3163  EllipsisLoc, NumExpansions);
3164  if (Result.isInvalid())
3165  return TemplateArgumentLoc();
3166 
3167  return TemplateArgumentLoc(Result.get(), Result.get());
3168  }
3169 
3172  Pattern.getArgument().getAsTemplate(),
3173  NumExpansions),
3174  Pattern.getTemplateQualifierLoc(),
3175  Pattern.getTemplateNameLoc(),
3176  EllipsisLoc);
3177 
3184  llvm_unreachable("Pack expansion pattern has no parameter packs");
3185 
3187  if (TypeSourceInfo *Expansion
3188  = getSema().CheckPackExpansion(Pattern.getTypeSourceInfo(),
3189  EllipsisLoc,
3190  NumExpansions))
3191  return TemplateArgumentLoc(TemplateArgument(Expansion->getType()),
3192  Expansion);
3193  break;
3194  }
3195 
3196  return TemplateArgumentLoc();
3197  }
3198 
3199  /// Build a new expression pack expansion.
3200  ///
3201  /// By default, performs semantic analysis to build a new pack expansion
3202  /// for an expression. Subclasses may override this routine to provide
3203  /// different behavior.
3205  Optional<unsigned> NumExpansions) {
3206  return getSema().CheckPackExpansion(Pattern, EllipsisLoc, NumExpansions);
3207  }
3208 
3209  /// Build a new C++1z fold-expression.
3210  ///
3211  /// By default, performs semantic analysis in order to build a new fold
3212  /// expression.
3214  BinaryOperatorKind Operator,
3215  SourceLocation EllipsisLoc, Expr *RHS,
3216  SourceLocation RParenLoc) {
3217  return getSema().BuildCXXFoldExpr(LParenLoc, LHS, Operator, EllipsisLoc,
3218  RHS, RParenLoc);
3219  }
3220 
3221  /// Build an empty C++1z fold-expression with the given operator.
3222  ///
3223  /// By default, produces the fallback value for the fold-expression, or
3224  /// produce an error if there is no fallback value.
3226  BinaryOperatorKind Operator) {
3227  return getSema().BuildEmptyCXXFoldExpr(EllipsisLoc, Operator);
3228  }
3229 
3230  /// Build a new atomic operation expression.
3231  ///
3232  /// By default, performs semantic analysis to build the new expression.
3233  /// Subclasses may override this routine to provide different behavior.
3235  MultiExprArg SubExprs,
3236  QualType RetTy,
3238  SourceLocation RParenLoc) {
3239  // Just create the expression; there is not any interesting semantic
3240  // analysis here because we can't actually build an AtomicExpr until
3241  // we are sure it is semantically sound.
3242  return new (SemaRef.Context) AtomicExpr(BuiltinLoc, SubExprs, RetTy, Op,
3243  RParenLoc);
3244  }
3245 
3246 private:
3247  TypeLoc TransformTypeInObjectScope(TypeLoc TL,
3248  QualType ObjectType,
3249  NamedDecl *FirstQualifierInScope,
3250  CXXScopeSpec &SS);
3251 
3252  TypeSourceInfo *TransformTypeInObjectScope(TypeSourceInfo *TSInfo,
3253  QualType ObjectType,
3254  NamedDecl *FirstQualifierInScope,
3255  CXXScopeSpec &SS);
3256 
3257  TypeSourceInfo *TransformTSIInObjectScope(TypeLoc TL, QualType ObjectType,
3258  NamedDecl *FirstQualifierInScope,
3259  CXXScopeSpec &SS);
3260 
3261  QualType TransformDependentNameType(TypeLocBuilder &TLB,
3263  bool DeducibleTSTContext);
3264 };
3265 
3266 template<typename Derived>
3268  if (!S)
3269  return S;
3270 
3271  switch (S->getStmtClass()) {
3272  case Stmt::NoStmtClass: break;
3273 
3274  // Transform individual statement nodes
3275 #define STMT(Node, Parent) \
3276  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(S));
3277 #define ABSTRACT_STMT(Node)
3278 #define EXPR(Node, Parent)
3279 #include "clang/AST/StmtNodes.inc"
3280 
3281  // Transform expressions by calling TransformExpr.
3282 #define STMT(Node, Parent)
3283 #define ABSTRACT_STMT(Stmt)
3284 #define EXPR(Node, Parent) case Stmt::Node##Class:
3285 #include "clang/AST/StmtNodes.inc"
3286  {
3287  ExprResult E = getDerived().TransformExpr(cast<Expr>(S));
3288  if (E.isInvalid())
3289  return StmtError();
3290 
3291  return getSema().ActOnExprStmt(E);
3292  }
3293  }
3294 
3295  return S;
3296 }
3297 
3298 template<typename Derived>
3300  if (!S)
3301  return S;
3302 
3303  switch (S->getClauseKind()) {
3304  default: break;
3305  // Transform individual clause nodes
3306 #define OPENMP_CLAUSE(Name, Class) \
3307  case OMPC_ ## Name : \
3308  return getDerived().Transform ## Class(cast<Class>(S));
3309 #include "clang/Basic/OpenMPKinds.def"
3310  }
3311 
3312  return S;
3313 }
3314 
3315 
3316 template<typename Derived>
3318  if (!E)
3319  return E;
3320 
3321  switch (E->getStmtClass()) {
3322  case Stmt::NoStmtClass: break;
3323 #define STMT(Node, Parent) case Stmt::Node##Class: break;
3324 #define ABSTRACT_STMT(Stmt)
3325 #define EXPR(Node, Parent) \
3326  case Stmt::Node##Class: return getDerived().Transform##Node(cast<Node>(E));
3327 #include "clang/AST/StmtNodes.inc"
3328  }
3329 
3330  return E;
3331 }
3332 
3333 template<typename Derived>
3335  bool NotCopyInit) {
3336  // Initializers are instantiated like expressions, except that various outer
3337  // layers are stripped.
3338  if (!Init)
3339  return Init;
3340 
3341  if (ExprWithCleanups *ExprTemp = dyn_cast<ExprWithCleanups>(Init))
3342  Init = ExprTemp->getSubExpr();
3343 
3344  if (auto *AIL = dyn_cast<ArrayInitLoopExpr>(Init))
3345  Init = AIL->getCommonExpr();
3346 
3347  if (MaterializeTemporaryExpr *MTE = dyn_cast<MaterializeTemporaryExpr>(Init))
3348  Init = MTE->GetTemporaryExpr();
3349 
3350  while (CXXBindTemporaryExpr *Binder = dyn_cast<CXXBindTemporaryExpr>(Init))
3351  Init = Binder->getSubExpr();
3352 
3353  if (ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Init))
3354  Init = ICE->getSubExprAsWritten();
3355 
3356  if (CXXStdInitializerListExpr *ILE =
3357  dyn_cast<CXXStdInitializerListExpr>(Init))
3358  return TransformInitializer(ILE->getSubExpr(), NotCopyInit);
3359 
3360  // If this is copy-initialization, we only need to reconstruct
3361  // InitListExprs. Other forms of copy-initialization will be a no-op if
3362  // the initializer is already the right type.
3363  CXXConstructExpr *Construct = dyn_cast<CXXConstructExpr>(Init);
3364  if (!NotCopyInit && !(Construct && Construct->isListInitialization()))
3365  return getDerived().TransformExpr(Init);
3366 
3367  // Revert value-initialization back to empty parens.
3368  if (CXXScalarValueInitExpr *VIE = dyn_cast<CXXScalarValueInitExpr>(Init)) {
3369  SourceRange Parens = VIE->getSourceRange();
3370  return getDerived().RebuildParenListExpr(Parens.getBegin(), None,
3371  Parens.getEnd());
3372  }
3373 
3374  // FIXME: We shouldn't build ImplicitValueInitExprs for direct-initialization.
3375  if (isa<ImplicitValueInitExpr>(Init))
3376  return getDerived().RebuildParenListExpr(SourceLocation(), None,
3377  SourceLocation());
3378 
3379  // Revert initialization by constructor back to a parenthesized or braced list
3380  // of expressions. Any other form of initializer can just be reused directly.
3381  if (!Construct || isa<CXXTemporaryObjectExpr>(Construct))
3382  return getDerived().TransformExpr(Init);
3383 
3384  // If the initialization implicitly converted an initializer list to a
3385  // std::initializer_list object, unwrap the std::initializer_list too.
3386  if (Construct && Construct->isStdInitListInitialization())
3387  return TransformInitializer(Construct->getArg(0), NotCopyInit);
3388 
3389  SmallVector<Expr*, 8> NewArgs;
3390  bool ArgChanged = false;
3391  if (getDerived().TransformExprs(Construct->getArgs(), Construct->getNumArgs(),
3392  /*IsCall*/true, NewArgs, &ArgChanged))
3393  return ExprError();
3394 
3395  // If this was list initialization, revert to syntactic list form.
3396  if (Construct->isListInitialization())
3397  return getDerived().RebuildInitList(Construct->getLocStart(), NewArgs,
3398  Construct->getLocEnd());
3399 
3400  // Build a ParenListExpr to represent anything else.
3401  SourceRange Parens = Construct->getParenOrBraceRange();
3402  if (Parens.isInvalid()) {
3403  // This was a variable declaration's initialization for which no initializer
3404  // was specified.
3405  assert(NewArgs.empty() &&
3406  "no parens or braces but have direct init with arguments?");
3407  return ExprEmpty();
3408  }
3409  return getDerived().RebuildParenListExpr(Parens.getBegin(), NewArgs,
3410  Parens.getEnd());
3411 }
3412 
3413 template<typename Derived>
3415  unsigned NumInputs,
3416  bool IsCall,
3417  SmallVectorImpl<Expr *> &Outputs,
3418  bool *ArgChanged) {
3419  for (unsigned I = 0; I != NumInputs; ++I) {
3420  // If requested, drop call arguments that need to be dropped.
3421  if (IsCall && getDerived().DropCallArgument(Inputs[I])) {
3422  if (ArgChanged)
3423  *ArgChanged = true;
3424 
3425  break;
3426  }
3427 
3428  if (PackExpansionExpr *Expansion = dyn_cast<PackExpansionExpr>(Inputs[I])) {
3429  Expr *Pattern = Expansion->getPattern();
3430 
3432  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
3433  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
3434 
3435  // Determine whether the set of unexpanded parameter packs can and should
3436  // be expanded.
3437  bool Expand = true;
3438  bool RetainExpansion = false;
3439  Optional<unsigned> OrigNumExpansions = Expansion->getNumExpansions();
3440  Optional<unsigned> NumExpansions = OrigNumExpansions;
3441  if (getDerived().TryExpandParameterPacks(Expansion->getEllipsisLoc(),
3442  Pattern->getSourceRange(),
3443  Unexpanded,
3444  Expand, RetainExpansion,
3445  NumExpansions))
3446  return true;
3447 
3448  if (!Expand) {
3449  // The transform has determined that we should perform a simple
3450  // transformation on the pack expansion, producing another pack
3451  // expansion.
3452  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
3453  ExprResult OutPattern = getDerived().TransformExpr(Pattern);
3454  if (OutPattern.isInvalid())
3455  return true;
3456 
3457  ExprResult Out = getDerived().RebuildPackExpansion(OutPattern.get(),
3458  Expansion->getEllipsisLoc(),
3459  NumExpansions);
3460  if (Out.isInvalid())
3461  return true;
3462 
3463  if (ArgChanged)
3464  *ArgChanged = true;
3465  Outputs.push_back(Out.get());
3466  continue;
3467  }
3468 
3469  // Record right away that the argument was changed. This needs
3470  // to happen even if the array expands to nothing.
3471  if (ArgChanged) *ArgChanged = true;
3472 
3473  // The transform has determined that we should perform an elementwise
3474  // expansion of the pattern. Do so.
3475  for (unsigned I = 0; I != *NumExpansions; ++I) {
3476  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
3477  ExprResult Out = getDerived().TransformExpr(Pattern);
3478  if (Out.isInvalid())
3479  return true;
3480 
3481  if (Out.get()->containsUnexpandedParameterPack()) {
3482  Out = getDerived().RebuildPackExpansion(
3483  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3484  if (Out.isInvalid())
3485  return true;
3486  }
3487 
3488  Outputs.push_back(Out.get());
3489  }
3490 
3491  // If we're supposed to retain a pack expansion, do so by temporarily
3492  // forgetting the partially-substituted parameter pack.
3493  if (RetainExpansion) {
3494  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
3495 
3496  ExprResult Out = getDerived().TransformExpr(Pattern);
3497  if (Out.isInvalid())
3498  return true;
3499 
3500  Out = getDerived().RebuildPackExpansion(
3501  Out.get(), Expansion->getEllipsisLoc(), OrigNumExpansions);
3502  if (Out.isInvalid())
3503  return true;
3504 
3505  Outputs.push_back(Out.get());
3506  }
3507 
3508  continue;
3509  }
3510 
3511  ExprResult Result =
3512  IsCall ? getDerived().TransformInitializer(Inputs[I], /*DirectInit*/false)
3513  : getDerived().TransformExpr(Inputs[I]);
3514  if (Result.isInvalid())
3515  return true;
3516 
3517  if (Result.get() != Inputs[I] && ArgChanged)
3518  *ArgChanged = true;
3519 
3520  Outputs.push_back(Result.get());
3521  }
3522 
3523  return false;
3524 }
3525 
3526 template <typename Derived>
3529  if (Var) {
3530  VarDecl *ConditionVar = cast_or_null<VarDecl>(
3531  getDerived().TransformDefinition(Var->getLocation(), Var));
3532 
3533  if (!ConditionVar)
3534  return Sema::ConditionError();
3535 
3536  return getSema().ActOnConditionVariable(ConditionVar, Loc, Kind);
3537  }
3538 
3539  if (Expr) {
3540  ExprResult CondExpr = getDerived().TransformExpr(Expr);
3541 
3542  if (CondExpr.isInvalid())
3543  return Sema::ConditionError();
3544 
3545  return getSema().ActOnCondition(nullptr, Loc, CondExpr.get(), Kind);
3546  }
3547 
3548  return Sema::ConditionResult();
3549 }
3550 
3551 template<typename Derived>
3555  QualType ObjectType,
3556  NamedDecl *FirstQualifierInScope) {
3558  for (NestedNameSpecifierLoc Qualifier = NNS; Qualifier;
3559  Qualifier = Qualifier.getPrefix())
3560  Qualifiers.push_back(Qualifier);
3561 
3562  CXXScopeSpec SS;
3563  while (!Qualifiers.empty()) {
3564  NestedNameSpecifierLoc Q = Qualifiers.pop_back_val();
3566 
3567  switch (QNNS->getKind()) {
3570  Q.getLocalBeginLoc(), Q.getLocalEndLoc(), ObjectType);
3571  if (SemaRef.BuildCXXNestedNameSpecifier(/*Scope=*/nullptr, IdInfo, false,
3572  SS, FirstQualifierInScope, false))
3573  return NestedNameSpecifierLoc();
3574  }
3575  break;
3576 
3578  NamespaceDecl *NS
3579  = cast_or_null<NamespaceDecl>(
3580  getDerived().TransformDecl(
3581  Q.getLocalBeginLoc(),
3582  QNNS->getAsNamespace()));
3583  SS.Extend(SemaRef.Context, NS, Q.getLocalBeginLoc(), Q.getLocalEndLoc());
3584  break;
3585  }
3586 
3588  NamespaceAliasDecl *Alias
3589  = cast_or_null<NamespaceAliasDecl>(
3590  getDerived().TransformDecl(Q.getLocalBeginLoc(),
3591  QNNS->getAsNamespaceAlias()));
3592  SS.Extend(SemaRef.Context, Alias, Q.getLocalBeginLoc(),
3593  Q.getLocalEndLoc());
3594  break;
3595  }
3596 
3598  // There is no meaningful transformation that one could perform on the
3599  // global scope.
3600  SS.MakeGlobal(SemaRef.Context, Q.getBeginLoc());
3601  break;
3602 
3604  CXXRecordDecl *RD =
3605  cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
3606  SourceLocation(), QNNS->getAsRecordDecl()));
3607  SS.MakeSuper(SemaRef.Context, RD, Q.getBeginLoc(), Q.getEndLoc());
3608  break;
3609  }
3610 
3613  TypeLoc TL = TransformTypeInObjectScope(Q.getTypeLoc(), ObjectType,
3614  FirstQualifierInScope, SS);
3615 
3616  if (!TL)
3617  return NestedNameSpecifierLoc();
3618 
3619  if (TL.getType()->isDependentType() || TL.getType()->isRecordType() ||
3620  (SemaRef.getLangOpts().CPlusPlus11 &&
3621  TL.getType()->isEnumeralType())) {
3622  assert(!TL.getType().hasLocalQualifiers() &&
3623  "Can't get cv-qualifiers here");
3624  if (TL.getType()->isEnumeralType())
3625  SemaRef.Diag(TL.getBeginLoc(),
3626  diag::warn_cxx98_compat_enum_nested_name_spec);
3627  SS.Extend(SemaRef.Context, /*FIXME:*/SourceLocation(), TL,
3628  Q.getLocalEndLoc());
3629  break;
3630  }
3631  // If the nested-name-specifier is an invalid type def, don't emit an
3632  // error because a previous error should have already been emitted.
3633  TypedefTypeLoc TTL = TL.getAs<TypedefTypeLoc>();
3634  if (!TTL || !TTL.getTypedefNameDecl()->isInvalidDecl()) {
3635  SemaRef.Diag(TL.getBeginLoc(), diag::err_nested_name_spec_non_tag)
3636  << TL.getType() << SS.getRange();
3637  }
3638  return NestedNameSpecifierLoc();
3639  }
3640  }
3641 
3642  // The qualifier-in-scope and object type only apply to the leftmost entity.
3643  FirstQualifierInScope = nullptr;
3644  ObjectType = QualType();
3645  }
3646 
3647  // Don't rebuild the nested-name-specifier if we don't have to.
3648  if (SS.getScopeRep() == NNS.getNestedNameSpecifier() &&
3649  !getDerived().AlwaysRebuild())
3650  return NNS;
3651 
3652  // If we can re-use the source-location data from the original
3653  // nested-name-specifier, do so.
3654  if (SS.location_size() == NNS.getDataLength() &&
3655  memcmp(SS.location_data(), NNS.getOpaqueData(), SS.location_size()) == 0)
3656  return NestedNameSpecifierLoc(SS.getScopeRep(), NNS.getOpaqueData());
3657 
3658  // Allocate new nested-name-specifier location information.
3659  return SS.getWithLocInContext(SemaRef.Context);
3660 }
3661 
3662 template<typename Derived>
3666  DeclarationName Name = NameInfo.getName();
3667  if (!Name)
3668  return DeclarationNameInfo();
3669 
3670  switch (Name.getNameKind()) {
3678  return NameInfo;
3679 
3681  TemplateDecl *OldTemplate = Name.getCXXDeductionGuideTemplate();
3682  TemplateDecl *NewTemplate = cast_or_null<TemplateDecl>(
3683  getDerived().TransformDecl(NameInfo.getLoc(), OldTemplate));
3684  if (!NewTemplate)
3685  return DeclarationNameInfo();
3686 
3687  DeclarationNameInfo NewNameInfo(NameInfo);
3688  NewNameInfo.setName(
3689  SemaRef.Context.DeclarationNames.getCXXDeductionGuideName(NewTemplate));
3690  return NewNameInfo;
3691  }
3692 
3696  TypeSourceInfo *NewTInfo;
3697  CanQualType NewCanTy;
3698  if (TypeSourceInfo *OldTInfo = NameInfo.getNamedTypeInfo()) {
3699  NewTInfo = getDerived().TransformType(OldTInfo);
3700  if (!NewTInfo)
3701  return DeclarationNameInfo();
3702  NewCanTy = SemaRef.Context.getCanonicalType(NewTInfo->getType());
3703  }
3704  else {
3705  NewTInfo = nullptr;
3706  TemporaryBase Rebase(*this, NameInfo.getLoc(), Name);
3707  QualType NewT = getDerived().TransformType(Name.getCXXNameType());
3708  if (NewT.isNull())
3709  return DeclarationNameInfo();
3710  NewCanTy = SemaRef.Context.getCanonicalType(NewT);
3711  }
3712 
3713  DeclarationName NewName
3714  = SemaRef.Context.DeclarationNames.getCXXSpecialName(Name.getNameKind(),
3715  NewCanTy);
3716  DeclarationNameInfo NewNameInfo(NameInfo);
3717  NewNameInfo.setName(NewName);
3718  NewNameInfo.setNamedTypeInfo(NewTInfo);
3719  return NewNameInfo;
3720  }
3721  }
3722 
3723  llvm_unreachable("Unknown name kind.");
3724 }
3725 
3726 template<typename Derived>
3729  TemplateName Name,
3730  SourceLocation NameLoc,
3731  QualType ObjectType,
3732  NamedDecl *FirstQualifierInScope,
3733  bool AllowInjectedClassName) {
3735  TemplateDecl *Template = QTN->getTemplateDecl();
3736  assert(Template && "qualified template name must refer to a template");
3737 
3738  TemplateDecl *TransTemplate
3739  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3740  Template));
3741  if (!TransTemplate)
3742  return TemplateName();
3743 
3744  if (!getDerived().AlwaysRebuild() &&
3745  SS.getScopeRep() == QTN->getQualifier() &&
3746  TransTemplate == Template)
3747  return Name;
3748 
3749  return getDerived().RebuildTemplateName(SS, QTN->hasTemplateKeyword(),
3750  TransTemplate);
3751  }
3752 
3754  if (SS.getScopeRep()) {
3755  // These apply to the scope specifier, not the template.
3756  ObjectType = QualType();
3757  FirstQualifierInScope = nullptr;
3758  }
3759 
3760  if (!getDerived().AlwaysRebuild() &&
3761  SS.getScopeRep() == DTN->getQualifier() &&
3762  ObjectType.isNull())
3763  return Name;
3764 
3765  // FIXME: Preserve the location of the "template" keyword.
3766  SourceLocation TemplateKWLoc = NameLoc;
3767 
3768  if (DTN->isIdentifier()) {
3769  return getDerived().RebuildTemplateName(SS,
3770  TemplateKWLoc,
3771  *DTN->getIdentifier(),
3772  NameLoc,
3773  ObjectType,
3774  FirstQualifierInScope,
3775  AllowInjectedClassName);
3776  }
3777 
3778  return getDerived().RebuildTemplateName(SS, TemplateKWLoc,
3779  DTN->getOperator(), NameLoc,
3780  ObjectType, AllowInjectedClassName);
3781  }
3782 
3783  if (TemplateDecl *Template = Name.getAsTemplateDecl()) {
3784  TemplateDecl *TransTemplate
3785  = cast_or_null<TemplateDecl>(getDerived().TransformDecl(NameLoc,
3786  Template));
3787  if (!TransTemplate)
3788  return TemplateName();
3789 
3790  if (!getDerived().AlwaysRebuild() &&
3791  TransTemplate == Template)
3792  return Name;
3793 
3794  return TemplateName(TransTemplate);
3795  }
3796 
3799  TemplateTemplateParmDecl *TransParam
3800  = cast_or_null<TemplateTemplateParmDecl>(
3801  getDerived().TransformDecl(NameLoc, SubstPack->getParameterPack()));
3802  if (!TransParam)
3803  return TemplateName();
3804 
3805  if (!getDerived().AlwaysRebuild() &&
3806  TransParam == SubstPack->getParameterPack())
3807  return Name;
3808 
3809  return getDerived().RebuildTemplateName(TransParam,
3810  SubstPack->getArgumentPack());
3811  }
3812 
3813  // These should be getting filtered out before they reach the AST.
3814  llvm_unreachable("overloaded function decl survived to here");
3815 }
3816 
3817 template<typename Derived>
3819  const TemplateArgument &Arg,
3820  TemplateArgumentLoc &Output) {
3821  SourceLocation Loc = getDerived().getBaseLocation();
3822  switch (Arg.getKind()) {
3824  llvm_unreachable("null template argument in TreeTransform");
3825  break;
3826 
3828  Output = TemplateArgumentLoc(Arg,
3829  SemaRef.Context.getTrivialTypeSourceInfo(Arg.getAsType(), Loc));
3830 
3831  break;
3832 
3837  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName())
3838  Builder.MakeTrivial(SemaRef.Context, DTN->getQualifier(), Loc);
3839  else if (QualifiedTemplateName *QTN = Template.getAsQualifiedTemplateName())
3840  Builder.MakeTrivial(SemaRef.Context, QTN->getQualifier(), Loc);
3841 
3842  if (Arg.getKind() == TemplateArgument::Template)
3843  Output = TemplateArgumentLoc(Arg,
3844  Builder.getWithLocInContext(SemaRef.Context),
3845  Loc);
3846  else
3847  Output = TemplateArgumentLoc(Arg,
3848  Builder.getWithLocInContext(SemaRef.Context),
3849  Loc, Loc);
3850 
3851  break;
3852  }
3853 
3855  Output = TemplateArgumentLoc(Arg, Arg.getAsExpr());
3856  break;
3857 
3863  break;
3864  }
3865 }
3866 
3867 template<typename Derived>
3869  const TemplateArgumentLoc &Input,
3870  TemplateArgumentLoc &Output, bool Uneval) {
3873  /*LambdaContextDecl=*/nullptr, /*ExprContext=*/
3875  const TemplateArgument &Arg = Input.getArgument();
3876  switch (Arg.getKind()) {
3882  llvm_unreachable("Unexpected TemplateArgument");
3883 
3884  case TemplateArgument::Type: {
3885  TypeSourceInfo *DI = Input.getTypeSourceInfo();
3886  if (!DI)
3887  DI = InventTypeSourceInfo(Input.getArgument().getAsType());
3888 
3889  DI = getDerived().TransformType(DI);
3890  if (!DI) return true;
3891 
3892  Output = TemplateArgumentLoc(TemplateArgument(DI->getType()), DI);
3893  return false;
3894  }
3895 
3897  NestedNameSpecifierLoc QualifierLoc = Input.getTemplateQualifierLoc();
3898  if (QualifierLoc) {
3899  QualifierLoc = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc);
3900  if (!QualifierLoc)
3901  return true;
3902  }
3903 
3904  CXXScopeSpec SS;
3905  SS.Adopt(QualifierLoc);
3906  TemplateName Template
3907  = getDerived().TransformTemplateName(SS, Arg.getAsTemplate(),
3908  Input.getTemplateNameLoc());
3909  if (Template.isNull())
3910  return true;
3911 
3912  Output = TemplateArgumentLoc(TemplateArgument(Template), QualifierLoc,
3913  Input.getTemplateNameLoc());
3914  return false;
3915  }
3916 
3918  llvm_unreachable("Caller should expand pack expansions");
3919 
3921  // Template argument expressions are constant expressions.
3923  getSema(), Uneval
3926 
3927  Expr *InputExpr = Input.getSourceExpression();
3928  if (!InputExpr) InputExpr = Input.getArgument().getAsExpr();
3929 
3930  ExprResult E = getDerived().TransformExpr(InputExpr);
3931  E = SemaRef.ActOnConstantExpression(E);
3932  if (E.isInvalid()) return true;
3933  Output = TemplateArgumentLoc(TemplateArgument(E.get()), E.get());
3934  return false;
3935  }
3936  }
3937 
3938  // Work around bogus GCC warning
3939  return true;
3940 }
3941 
3942 /// Iterator adaptor that invents template argument location information
3943 /// for each of the template arguments in its underlying iterator.
3944 template<typename Derived, typename InputIterator>
3946  TreeTransform<Derived> &Self;
3947  InputIterator Iter;
3948 
3949 public:
3952  typedef typename std::iterator_traits<InputIterator>::difference_type
3954  typedef std::input_iterator_tag iterator_category;
3955 
3956  class pointer {
3957  TemplateArgumentLoc Arg;
3958 
3959  public:
3960  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
3961 
3962  const TemplateArgumentLoc *operator->() const { return &Arg; }
3963  };
3964 
3966 
3968  InputIterator Iter)
3969  : Self(Self), Iter(Iter) { }
3970 
3972  ++Iter;
3973  return *this;
3974  }
3975 
3978  ++(*this);
3979  return Old;
3980  }
3981 
3982  reference operator*() const {
3983  TemplateArgumentLoc Result;
3984  Self.InventTemplateArgumentLoc(*Iter, Result);
3985  return Result;
3986  }
3987 
3988  pointer operator->() const { return pointer(**this); }
3989 
3992  return X.Iter == Y.Iter;
3993  }
3994 
3997  return X.Iter != Y.Iter;
3998  }
3999 };
4000 
4001 template<typename Derived>
4002 template<typename InputIterator>
4004  InputIterator First, InputIterator Last, TemplateArgumentListInfo &Outputs,
4005  bool Uneval) {
4006  for (; First != Last; ++First) {
4007  TemplateArgumentLoc Out;
4008  TemplateArgumentLoc In = *First;
4009 
4010  if (In.getArgument().getKind() == TemplateArgument::Pack) {
4011  // Unpack argument packs, which we translate them into separate
4012  // arguments.
4013  // FIXME: We could do much better if we could guarantee that the
4014  // TemplateArgumentLocInfo for the pack expansion would be usable for
4015  // all of the template arguments in the argument pack.
4016  typedef TemplateArgumentLocInventIterator<Derived,
4018  PackLocIterator;
4019  if (TransformTemplateArguments(PackLocIterator(*this,
4020  In.getArgument().pack_begin()),
4021  PackLocIterator(*this,
4022  In.getArgument().pack_end()),
4023  Outputs, Uneval))
4024  return true;
4025 
4026  continue;
4027  }
4028 
4029  if (In.getArgument().isPackExpansion()) {
4030  // We have a pack expansion, for which we will be substituting into
4031  // the pattern.
4032  SourceLocation Ellipsis;
4033  Optional<unsigned> OrigNumExpansions;
4034  TemplateArgumentLoc Pattern
4035  = getSema().getTemplateArgumentPackExpansionPattern(
4036  In, Ellipsis, OrigNumExpansions);
4037 
4039  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
4040  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
4041 
4042  // Determine whether the set of unexpanded parameter packs can and should
4043  // be expanded.
4044  bool Expand = true;
4045  bool RetainExpansion = false;
4046  Optional<unsigned> NumExpansions = OrigNumExpansions;
4047  if (getDerived().TryExpandParameterPacks(Ellipsis,
4048  Pattern.getSourceRange(),
4049  Unexpanded,
4050  Expand,
4051  RetainExpansion,
4052  NumExpansions))
4053  return true;
4054 
4055  if (!Expand) {
4056  // The transform has determined that we should perform a simple
4057  // transformation on the pack expansion, producing another pack
4058  // expansion.
4059  TemplateArgumentLoc OutPattern;
4060  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
4061  if (getDerived().TransformTemplateArgument(Pattern, OutPattern, Uneval))
4062  return true;
4063 
4064  Out = getDerived().RebuildPackExpansion(OutPattern, Ellipsis,
4065  NumExpansions);
4066  if (Out.getArgument().isNull())
4067  return true;
4068 
4069  Outputs.addArgument(Out);
4070  continue;
4071  }
4072 
4073  // The transform has determined that we should perform an elementwise
4074  // expansion of the pattern. Do so.
4075  for (unsigned I = 0; I != *NumExpansions; ++I) {
4076  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
4077 
4078  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4079  return true;
4080 
4082  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4083  OrigNumExpansions);
4084  if (Out.getArgument().isNull())
4085  return true;
4086  }
4087 
4088  Outputs.addArgument(Out);
4089  }
4090 
4091  // If we're supposed to retain a pack expansion, do so by temporarily
4092  // forgetting the partially-substituted parameter pack.
4093  if (RetainExpansion) {
4094  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
4095 
4096  if (getDerived().TransformTemplateArgument(Pattern, Out, Uneval))
4097  return true;
4098 
4099  Out = getDerived().RebuildPackExpansion(Out, Ellipsis,
4100  OrigNumExpansions);
4101  if (Out.getArgument().isNull())
4102  return true;
4103 
4104  Outputs.addArgument(Out);
4105  }
4106 
4107  continue;
4108  }
4109 
4110  // The simple case:
4111  if (getDerived().TransformTemplateArgument(In, Out, Uneval))
4112  return true;
4113 
4114  Outputs.addArgument(Out);
4115  }
4116 
4117  return false;
4118 
4119 }
4120 
4121 //===----------------------------------------------------------------------===//
4122 // Type transformation
4123 //===----------------------------------------------------------------------===//
4124 
4125 template<typename Derived>
4127  if (getDerived().AlreadyTransformed(T))
4128  return T;
4129 
4130  // Temporary workaround. All of these transformations should
4131  // eventually turn into transformations on TypeLocs.
4132  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4133  getDerived().getBaseLocation());
4134 
4135  TypeSourceInfo *NewDI = getDerived().TransformType(DI);
4136 
4137  if (!NewDI)
4138  return QualType();
4139 
4140  return NewDI->getType();
4141 }
4142 
4143 template<typename Derived>
4145  // Refine the base location to the type's location.
4146  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4147  getDerived().getBaseEntity());
4148  if (getDerived().AlreadyTransformed(DI->getType()))
4149  return DI;
4150 
4151  TypeLocBuilder TLB;
4152 
4153  TypeLoc TL = DI->getTypeLoc();
4154  TLB.reserve(TL.getFullDataSize());
4155 
4156  QualType Result = getDerived().TransformType(TLB, TL);
4157  if (Result.isNull())
4158  return nullptr;
4159 
4160  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4161 }
4162 
4163 template<typename Derived>
4164 QualType
4166  switch (T.getTypeLocClass()) {
4167 #define ABSTRACT_TYPELOC(CLASS, PARENT)
4168 #define TYPELOC(CLASS, PARENT) \
4169  case TypeLoc::CLASS: \
4170  return getDerived().Transform##CLASS##Type(TLB, \
4171  T.castAs<CLASS##TypeLoc>());
4172 #include "clang/AST/TypeLocNodes.def"
4173  }
4174 
4175  llvm_unreachable("unhandled type loc!");
4176 }
4177 
4178 template<typename Derived>
4180  if (!isa<DependentNameType>(T))
4181  return TransformType(T);
4182 
4183  if (getDerived().AlreadyTransformed(T))
4184  return T;
4185  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(T,
4186  getDerived().getBaseLocation());
4187  TypeSourceInfo *NewDI = getDerived().TransformTypeWithDeducedTST(DI);
4188  return NewDI ? NewDI->getType() : QualType();
4189 }
4190 
4191 template<typename Derived>
4194  if (!isa<DependentNameType>(DI->getType()))
4195  return TransformType(DI);
4196 
4197  // Refine the base location to the type's location.
4198  TemporaryBase Rebase(*this, DI->getTypeLoc().getBeginLoc(),
4199  getDerived().getBaseEntity());
4200  if (getDerived().AlreadyTransformed(DI->getType()))
4201  return DI;
4202 
4203  TypeLocBuilder TLB;
4204 
4205  TypeLoc TL = DI->getTypeLoc();
4206  TLB.reserve(TL.getFullDataSize());
4207 
4208  auto QTL = TL.getAs<QualifiedTypeLoc>();
4209  if (QTL)
4210  TL = QTL.getUnqualifiedLoc();
4211 
4212  auto DNTL = TL.castAs<DependentNameTypeLoc>();
4213 
4214  QualType Result = getDerived().TransformDependentNameType(
4215  TLB, DNTL, /*DeducedTSTContext*/true);
4216  if (Result.isNull())
4217  return nullptr;
4218 
4219  if (QTL) {
4220  Result = getDerived().RebuildQualifiedType(
4221  Result, QTL.getBeginLoc(), QTL.getType().getLocalQualifiers());
4222  TLB.TypeWasModifiedSafely(Result);
4223  }
4224 
4225  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4226 }
4227 
4228 template<typename Derived>
4229 QualType
4231  QualifiedTypeLoc T) {
4232  Qualifiers Quals = T.getType().getLocalQualifiers();
4233 
4234  QualType Result = getDerived().TransformType(TLB, T.getUnqualifiedLoc());
4235  if (Result.isNull())
4236  return QualType();
4237 
4238  Result = getDerived().RebuildQualifiedType(Result, T.getBeginLoc(), Quals);
4239 
4240  // RebuildQualifiedType might have updated the type, but not in a way
4241  // that invalidates the TypeLoc. (There's no location information for
4242  // qualifiers.)
4243  TLB.TypeWasModifiedSafely(Result);
4244 
4245  return Result;
4246 }
4247 
4248 template<typename Derived>
4250  SourceLocation Loc,
4251  Qualifiers Quals) {
4252  // C++ [dcl.fct]p7:
4253  // [When] adding cv-qualifications on top of the function type [...] the
4254  // cv-qualifiers are ignored.
4255  // C++ [dcl.ref]p1:
4256  // when the cv-qualifiers are introduced through the use of a typedef-name
4257  // or decltype-specifier [...] the cv-qualifiers are ignored.
4258  // Note that [dcl.ref]p1 lists all cases in which cv-qualifiers can be
4259  // applied to a reference type.
4260  // FIXME: This removes all qualifiers, not just cv-qualifiers!
4261  if (T->isFunctionType() || T->isReferenceType())
4262  return T;
4263 
4264  // Suppress Objective-C lifetime qualifiers if they don't make sense for the
4265  // resulting type.
4266  if (Quals.hasObjCLifetime()) {
4267  if (!T->isObjCLifetimeType() && !T->isDependentType())
4268  Quals.removeObjCLifetime();
4269  else if (T.getObjCLifetime()) {
4270  // Objective-C ARC:
4271  // A lifetime qualifier applied to a substituted template parameter
4272  // overrides the lifetime qualifier from the template argument.
4273  const AutoType *AutoTy;
4274  if (const SubstTemplateTypeParmType *SubstTypeParam
4275  = dyn_cast<SubstTemplateTypeParmType>(T)) {
4276  QualType Replacement = SubstTypeParam->getReplacementType();
4277  Qualifiers Qs = Replacement.getQualifiers();
4278  Qs.removeObjCLifetime();
4279  Replacement = SemaRef.Context.getQualifiedType(
4280  Replacement.getUnqualifiedType(), Qs);
4281  T = SemaRef.Context.getSubstTemplateTypeParmType(
4282  SubstTypeParam->getReplacedParameter(), Replacement);
4283  } else if ((AutoTy = dyn_cast<AutoType>(T)) && AutoTy->isDeduced()) {
4284  // 'auto' types behave the same way as template parameters.
4285  QualType Deduced = AutoTy->getDeducedType();
4286  Qualifiers Qs = Deduced.getQualifiers();
4287  Qs.removeObjCLifetime();
4288  Deduced =
4289  SemaRef.Context.getQualifiedType(Deduced.getUnqualifiedType(), Qs);
4290  T = SemaRef.Context.getAutoType(Deduced, AutoTy->getKeyword(),
4291  AutoTy->isDependentType());
4292  } else {
4293  // Otherwise, complain about the addition of a qualifier to an
4294  // already-qualified type.
4295  // FIXME: Why is this check not in Sema::BuildQualifiedType?
4296  SemaRef.Diag(Loc, diag::err_attr_objc_ownership_redundant) << T;
4297  Quals.removeObjCLifetime();
4298  }
4299  }
4300  }
4301 
4302  return SemaRef.BuildQualifiedType(T, Loc, Quals);
4303 }
4304 
4305 template<typename Derived>
4306 TypeLoc
4308  QualType ObjectType,
4309  NamedDecl *UnqualLookup,
4310  CXXScopeSpec &SS) {
4311  if (getDerived().AlreadyTransformed(TL.getType()))
4312  return TL;
4313 
4314  TypeSourceInfo *TSI =
4315  TransformTSIInObjectScope(TL, ObjectType, UnqualLookup, SS);
4316  if (TSI)
4317  return TSI->getTypeLoc();
4318  return TypeLoc();
4319 }
4320 
4321 template<typename Derived>
4324  QualType ObjectType,
4325  NamedDecl *UnqualLookup,
4326  CXXScopeSpec &SS) {
4327  if (getDerived().AlreadyTransformed(TSInfo->getType()))
4328  return TSInfo;
4329 
4330  return TransformTSIInObjectScope(TSInfo->getTypeLoc(), ObjectType,
4331  UnqualLookup, SS);
4332 }
4333 
4334 template <typename Derived>
4336  TypeLoc TL, QualType ObjectType, NamedDecl *UnqualLookup,
4337  CXXScopeSpec &SS) {
4338  QualType T = TL.getType();
4339  assert(!getDerived().AlreadyTransformed(T));
4340 
4341  TypeLocBuilder TLB;
4342  QualType Result;
4343 
4344  if (isa<TemplateSpecializationType>(T)) {
4347 
4348  TemplateName Template = getDerived().TransformTemplateName(
4349  SS, SpecTL.getTypePtr()->getTemplateName(), SpecTL.getTemplateNameLoc(),
4350  ObjectType, UnqualLookup, /*AllowInjectedClassName*/true);
4351  if (Template.isNull())
4352  return nullptr;
4353 
4354  Result = getDerived().TransformTemplateSpecializationType(TLB, SpecTL,
4355  Template);
4356  } else if (isa<DependentTemplateSpecializationType>(T)) {
4359 
4360  TemplateName Template
4361  = getDerived().RebuildTemplateName(SS,
4362  SpecTL.getTemplateKeywordLoc(),
4363  *SpecTL.getTypePtr()->getIdentifier(),
4364  SpecTL.getTemplateNameLoc(),
4365  ObjectType, UnqualLookup,
4366  /*AllowInjectedClassName*/true);
4367  if (Template.isNull())
4368  return nullptr;
4369 
4370  Result = getDerived().TransformDependentTemplateSpecializationType(TLB,
4371  SpecTL,
4372  Template,
4373  SS);
4374  } else {
4375  // Nothing special needs to be done for these.
4376  Result = getDerived().TransformType(TLB, TL);
4377  }
4378 
4379  if (Result.isNull())
4380  return nullptr;
4381 
4382  return TLB.getTypeSourceInfo(SemaRef.Context, Result);
4383 }
4384 
4385 template <class TyLoc> static inline
4387  TyLoc NewT = TLB.push<TyLoc>(T.getType());
4388  NewT.setNameLoc(T.getNameLoc());
4389  return T.getType();
4390 }
4391 
4392 template<typename Derived>
4394  BuiltinTypeLoc T) {
4395  BuiltinTypeLoc NewT = TLB.push<BuiltinTypeLoc>(T.getType());
4396  NewT.setBuiltinLoc(T.getBuiltinLoc());
4397  if (T.needsExtraLocalData())
4399  return T.getType();
4400 }
4401 
4402 template<typename Derived>
4404  ComplexTypeLoc T) {
4405  // FIXME: recurse?
4406  return TransformTypeSpecType(TLB, T);
4407 }
4408 
4409 template <typename Derived>
4411  AdjustedTypeLoc TL) {
4412  // Adjustments applied during transformation are handled elsewhere.
4413  return getDerived().TransformType(TLB, TL.getOriginalLoc());
4414 }
4415 
4416 template<typename Derived>
4418  DecayedTypeLoc TL) {
4419  QualType OriginalType = getDerived().TransformType(TLB, TL.getOriginalLoc());
4420  if (OriginalType.isNull())
4421  return QualType();
4422 
4423  QualType Result = TL.getType();
4424  if (getDerived().AlwaysRebuild() ||
4425  OriginalType != TL.getOriginalLoc().getType())
4426  Result = SemaRef.Context.getDecayedType(OriginalType);
4427  TLB.push<DecayedTypeLoc>(Result);
4428  // Nothing to set for DecayedTypeLoc.
4429  return Result;
4430 }
4431 
4432 template<typename Derived>
4434  PointerTypeLoc TL) {
4435  QualType PointeeType
4436  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4437  if (PointeeType.isNull())
4438  return QualType();
4439 
4440  QualType Result = TL.getType();
4441  if (PointeeType->getAs<ObjCObjectType>()) {
4442  // A dependent pointer type 'T *' has is being transformed such
4443  // that an Objective-C class type is being replaced for 'T'. The
4444  // resulting pointer type is an ObjCObjectPointerType, not a
4445  // PointerType.
4446  Result = SemaRef.Context.getObjCObjectPointerType(PointeeType);
4447 
4449  NewT.setStarLoc(TL.getStarLoc());
4450  return Result;
4451  }
4452 
4453  if (getDerived().AlwaysRebuild() ||
4454  PointeeType != TL.getPointeeLoc().getType()) {
4455  Result = getDerived().RebuildPointerType(PointeeType, TL.getSigilLoc());
4456  if (Result.isNull())
4457  return QualType();
4458  }
4459 
4460  // Objective-C ARC can add lifetime qualifiers to the type that we're
4461  // pointing to.
4462  TLB.TypeWasModifiedSafely(Result->getPointeeType());
4463 
4464  PointerTypeLoc NewT = TLB.push<PointerTypeLoc>(Result);
4465  NewT.setSigilLoc(TL.getSigilLoc());
4466  return Result;
4467 }
4468 
4469 template<typename Derived>
4470 QualType
4472  BlockPointerTypeLoc TL) {
4473  QualType PointeeType
4474  = getDerived().TransformType(TLB, TL.getPointeeLoc());
4475  if (PointeeType.isNull())
4476  return QualType();
4477 
4478  QualType Result = TL.getType();
4479  if (getDerived().AlwaysRebuild() ||
4480  PointeeType != TL.getPointeeLoc().getType()) {
4481  Result = getDerived().RebuildBlockPointerType(PointeeType,
4482  TL.getSigilLoc());
4483  if (Result.isNull())
4484  return QualType();
4485  }
4486 
4487  BlockPointerTypeLoc NewT = TLB.push<BlockPointerTypeLoc>(Result);
4488  NewT.setSigilLoc(TL.getSigilLoc());
4489  return Result;
4490 }
4491 
4492 /// Transforms a reference type. Note that somewhat paradoxically we
4493 /// don't care whether the type itself is an l-value type or an r-value
4494 /// type; we only care if the type was *written* as an l-value type
4495 /// or an r-value type.
4496 template<typename Derived>
4497 QualType
4499  ReferenceTypeLoc TL) {
4500  const ReferenceType *T = TL.getTypePtr();
4501 
4502  // Note that this works with the pointee-as-written.
4503  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4504  if (PointeeType.isNull())
4505  return QualType();
4506 
4507  QualType Result = TL.getType();
4508  if (getDerived().AlwaysRebuild() ||
4509  PointeeType != T->getPointeeTypeAsWritten()) {
4510  Result = getDerived().RebuildReferenceType(PointeeType,
4511  T->isSpelledAsLValue(),
4512  TL.getSigilLoc());
4513  if (Result.isNull())
4514  return QualType();
4515  }
4516 
4517  // Objective-C ARC can add lifetime qualifiers to the type that we're
4518  // referring to.
4521 
4522  // r-value references can be rebuilt as l-value references.
4523  ReferenceTypeLoc NewTL;
4524  if (isa<LValueReferenceType>(Result))
4525  NewTL = TLB.push<LValueReferenceTypeLoc>(Result);
4526  else
4527  NewTL = TLB.push<RValueReferenceTypeLoc>(Result);
4528  NewTL.setSigilLoc(TL.getSigilLoc());
4529 
4530  return Result;
4531 }
4532 
4533 template<typename Derived>
4534 QualType
4537  return TransformReferenceType(TLB, TL);
4538 }
4539 
4540 template<typename Derived>
4541 QualType
4544  return TransformReferenceType(TLB, TL);
4545 }
4546 
4547 template<typename Derived>
4548 QualType
4550  MemberPointerTypeLoc TL) {
4551  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
4552  if (PointeeType.isNull())
4553  return QualType();
4554 
4555  TypeSourceInfo* OldClsTInfo = TL.getClassTInfo();
4556  TypeSourceInfo *NewClsTInfo = nullptr;
4557  if (OldClsTInfo) {
4558  NewClsTInfo = getDerived().TransformType(OldClsTInfo);
4559  if (!NewClsTInfo)
4560  return QualType();
4561  }
4562 
4563  const MemberPointerType *T = TL.getTypePtr();
4564  QualType OldClsType = QualType(T->getClass(), 0);
4565  QualType NewClsType;
4566  if (NewClsTInfo)
4567  NewClsType = NewClsTInfo->getType();
4568  else {
4569  NewClsType = getDerived().TransformType(OldClsType);
4570  if (NewClsType.isNull())
4571  return QualType();
4572  }
4573 
4574  QualType Result = TL.getType();
4575  if (getDerived().AlwaysRebuild() ||
4576  PointeeType != T->getPointeeType() ||
4577  NewClsType != OldClsType) {
4578  Result = getDerived().RebuildMemberPointerType(PointeeType, NewClsType,
4579  TL.getStarLoc());
4580  if (Result.isNull())
4581  return QualType();
4582  }
4583 
4584  // If we had to adjust the pointee type when building a member pointer, make
4585  // sure to push TypeLoc info for it.
4586  const MemberPointerType *MPT = Result->getAs<MemberPointerType>();
4587  if (MPT && PointeeType != MPT->getPointeeType()) {
4588  assert(isa<AdjustedType>(MPT->getPointeeType()));
4589  TLB.push<AdjustedTypeLoc>(MPT->getPointeeType());
4590  }
4591 
4592  MemberPointerTypeLoc NewTL = TLB.push<MemberPointerTypeLoc>(Result);
4593  NewTL.setSigilLoc(TL.getSigilLoc());
4594  NewTL.setClassTInfo(NewClsTInfo);
4595 
4596  return Result;
4597 }
4598 
4599 template<typename Derived>
4600 QualType
4602  ConstantArrayTypeLoc TL) {
4603  const ConstantArrayType *T = TL.getTypePtr();
4604  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4605  if (ElementType.isNull())
4606  return QualType();
4607 
4608  QualType Result = TL.getType();
4609  if (getDerived().AlwaysRebuild() ||
4610  ElementType != T->getElementType()) {
4611  Result = getDerived().RebuildConstantArrayType(ElementType,
4612  T->getSizeModifier(),
4613  T->getSize(),
4615  TL.getBracketsRange());
4616  if (Result.isNull())
4617  return QualType();
4618  }
4619 
4620  // We might have either a ConstantArrayType or a VariableArrayType now:
4621  // a ConstantArrayType is allowed to have an element type which is a
4622  // VariableArrayType if the type is dependent. Fortunately, all array
4623  // types have the same location layout.
4624  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4625  NewTL.setLBracketLoc(TL.getLBracketLoc());
4626  NewTL.setRBracketLoc(TL.getRBracketLoc());
4627 
4628  Expr *Size = TL.getSizeExpr();
4629  if (Size) {
4632  Size = getDerived().TransformExpr(Size).template getAs<Expr>();
4633  Size = SemaRef.ActOnConstantExpression(Size).get();
4634  }
4635  NewTL.setSizeExpr(Size);
4636 
4637  return Result;
4638 }
4639 
4640 template<typename Derived>
4642  TypeLocBuilder &TLB,
4644  const IncompleteArrayType *T = TL.getTypePtr();
4645  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4646  if (ElementType.isNull())
4647  return QualType();
4648 
4649  QualType Result = TL.getType();
4650  if (getDerived().AlwaysRebuild() ||
4651  ElementType != T->getElementType()) {
4652  Result = getDerived().RebuildIncompleteArrayType(ElementType,
4653  T->getSizeModifier(),
4655  TL.getBracketsRange());
4656  if (Result.isNull())
4657  return QualType();
4658  }
4659 
4660  IncompleteArrayTypeLoc NewTL = TLB.push<IncompleteArrayTypeLoc>(Result);
4661  NewTL.setLBracketLoc(TL.getLBracketLoc());
4662  NewTL.setRBracketLoc(TL.getRBracketLoc());
4663  NewTL.setSizeExpr(nullptr);
4664 
4665  return Result;
4666 }
4667 
4668 template<typename Derived>
4669 QualType
4671  VariableArrayTypeLoc TL) {
4672  const VariableArrayType *T = TL.getTypePtr();
4673  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4674  if (ElementType.isNull())
4675  return QualType();
4676 
4677  ExprResult SizeResult;
4678  {
4681  SizeResult = getDerived().TransformExpr(T->getSizeExpr());
4682  }
4683  if (SizeResult.isInvalid())
4684  return QualType();
4685  SizeResult = SemaRef.ActOnFinishFullExpr(SizeResult.get());
4686  if (SizeResult.isInvalid())
4687  return QualType();
4688 
4689  Expr *Size = SizeResult.get();
4690 
4691  QualType Result = TL.getType();
4692  if (getDerived().AlwaysRebuild() ||
4693  ElementType != T->getElementType() ||
4694  Size != T->getSizeExpr()) {
4695  Result = getDerived().RebuildVariableArrayType(ElementType,
4696  T->getSizeModifier(),
4697  Size,
4699  TL.getBracketsRange());
4700  if (Result.isNull())
4701  return QualType();
4702  }
4703 
4704  // We might have constant size array now, but fortunately it has the same
4705  // location layout.
4706  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4707  NewTL.setLBracketLoc(TL.getLBracketLoc());
4708  NewTL.setRBracketLoc(TL.getRBracketLoc());
4709  NewTL.setSizeExpr(Size);
4710 
4711  return Result;
4712 }
4713 
4714 template<typename Derived>
4715 QualType
4718  const DependentSizedArrayType *T = TL.getTypePtr();
4719  QualType ElementType = getDerived().TransformType(TLB, TL.getElementLoc());
4720  if (ElementType.isNull())
4721  return QualType();
4722 
4723  // Array bounds are constant expressions.
4726 
4727  // Prefer the expression from the TypeLoc; the other may have been uniqued.
4728  Expr *origSize = TL.getSizeExpr();
4729  if (!origSize) origSize = T->getSizeExpr();
4730 
4731  ExprResult sizeResult
4732  = getDerived().TransformExpr(origSize);
4733  sizeResult = SemaRef.ActOnConstantExpression(sizeResult);
4734  if (sizeResult.isInvalid())
4735  return QualType();
4736 
4737  Expr *size = sizeResult.get();
4738 
4739  QualType Result = TL.getType();
4740  if (getDerived().AlwaysRebuild() ||
4741  ElementType != T->getElementType() ||
4742  size != origSize) {
4743  Result = getDerived().RebuildDependentSizedArrayType(ElementType,
4744  T->getSizeModifier(),
4745  size,
4747  TL.getBracketsRange());
4748  if (Result.isNull())
4749  return QualType();
4750  }
4751 
4752  // We might have any sort of array type now, but fortunately they
4753  // all have the same location layout.
4754  ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result);
4755  NewTL.setLBracketLoc(TL.getLBracketLoc());
4756  NewTL.setRBracketLoc(TL.getRBracketLoc());
4757  NewTL.setSizeExpr(size);
4758 
4759  return Result;
4760 }
4761 
4762 template <typename Derived>
4765  const DependentVectorType *T = TL.getTypePtr();
4766  QualType ElementType = getDerived().TransformType(T->getElementType());
4767  if (ElementType.isNull())
4768  return QualType();
4769 
4772 
4773  ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
4774  Size = SemaRef.ActOnConstantExpression(Size);
4775  if (Size.isInvalid())
4776  return QualType();
4777 
4778  QualType Result = TL.getType();
4779  if (getDerived().AlwaysRebuild() || ElementType != T->getElementType() ||
4780  Size.get() != T->getSizeExpr()) {
4781  Result = getDerived().RebuildDependentVectorType(
4782  ElementType, Size.get(), T->getAttributeLoc(), T->getVectorKind());
4783  if (Result.isNull())
4784  return QualType();
4785  }
4786 
4787  // Result might be dependent or not.
4788  if (isa<DependentVectorType>(Result)) {
4789  DependentVectorTypeLoc NewTL =
4790  TLB.push<DependentVectorTypeLoc>(Result);
4791  NewTL.setNameLoc(TL.getNameLoc());
4792  } else {
4793  VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
4794  NewTL.setNameLoc(TL.getNameLoc());
4795  }
4796 
4797  return Result;
4798 }
4799 
4800 template<typename Derived>
4802  TypeLocBuilder &TLB,
4804  const DependentSizedExtVectorType *T = TL.getTypePtr();
4805 
4806  // FIXME: ext vector locs should be nested
4807  QualType ElementType = getDerived().TransformType(T->getElementType());
4808  if (ElementType.isNull())
4809  return QualType();
4810 
4811  // Vector sizes are constant expressions.
4814 
4815  ExprResult Size = getDerived().TransformExpr(T->getSizeExpr());
4816  Size = SemaRef.ActOnConstantExpression(Size);
4817  if (Size.isInvalid())
4818  return QualType();
4819 
4820  QualType Result = TL.getType();
4821  if (getDerived().AlwaysRebuild() ||
4822  ElementType != T->getElementType() ||
4823  Size.get() != T->getSizeExpr()) {
4824  Result = getDerived().RebuildDependentSizedExtVectorType(ElementType,
4825  Size.get(),
4826  T->getAttributeLoc());
4827  if (Result.isNull())
4828  return QualType();
4829  }
4830 
4831  // Result might be dependent or not.
4832  if (isa<DependentSizedExtVectorType>(Result)) {
4834  = TLB.push<DependentSizedExtVectorTypeLoc>(Result);
4835  NewTL.setNameLoc(TL.getNameLoc());
4836  } else {
4837  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
4838  NewTL.setNameLoc(TL.getNameLoc());
4839  }
4840 
4841  return Result;
4842 }
4843 
4844 template <typename Derived>
4847  const DependentAddressSpaceType *T = TL.getTypePtr();
4848 
4849  QualType pointeeType = getDerived().TransformType(T->getPointeeType());
4850 
4851  if (pointeeType.isNull())
4852  return QualType();
4853 
4854  // Address spaces are constant expressions.
4857 
4858  ExprResult AddrSpace = getDerived().TransformExpr(T->getAddrSpaceExpr());
4859  AddrSpace = SemaRef.ActOnConstantExpression(AddrSpace);
4860  if (AddrSpace.isInvalid())
4861  return QualType();
4862 
4863  QualType Result = TL.getType();
4864  if (getDerived().AlwaysRebuild() || pointeeType != T->getPointeeType() ||
4865  AddrSpace.get() != T->getAddrSpaceExpr()) {
4866  Result = getDerived().RebuildDependentAddressSpaceType(
4867  pointeeType, AddrSpace.get(), T->getAttributeLoc());
4868  if (Result.isNull())
4869  return QualType();
4870  }
4871 
4872  // Result might be dependent or not.
4873  if (isa<DependentAddressSpaceType>(Result)) {
4875  TLB.push<DependentAddressSpaceTypeLoc>(Result);
4876 
4879  NewTL.setAttrNameLoc(TL.getAttrNameLoc());
4880 
4881  } else {
4882  TypeSourceInfo *DI = getSema().Context.getTrivialTypeSourceInfo(
4883  Result, getDerived().getBaseLocation());
4884  TransformType(TLB, DI->getTypeLoc());
4885  }
4886 
4887  return Result;
4888 }
4889 
4890 template <typename Derived>
4892  VectorTypeLoc TL) {
4893  const VectorType *T = TL.getTypePtr();
4894  QualType ElementType = getDerived().TransformType(T->getElementType());
4895  if (ElementType.isNull())
4896  return QualType();
4897 
4898  QualType Result = TL.getType();
4899  if (getDerived().AlwaysRebuild() ||
4900  ElementType != T->getElementType()) {
4901  Result = getDerived().RebuildVectorType(ElementType, T->getNumElements(),
4902  T->getVectorKind());
4903  if (Result.isNull())
4904  return QualType();
4905  }
4906 
4907  VectorTypeLoc NewTL = TLB.push<VectorTypeLoc>(Result);
4908  NewTL.setNameLoc(TL.getNameLoc());
4909 
4910  return Result;
4911 }
4912 
4913 template<typename Derived>
4915  ExtVectorTypeLoc TL) {
4916  const VectorType *T = TL.getTypePtr();
4917  QualType ElementType = getDerived().TransformType(T->getElementType());
4918  if (ElementType.isNull())
4919  return QualType();
4920 
4921  QualType Result = TL.getType();
4922  if (getDerived().AlwaysRebuild() ||
4923  ElementType != T->getElementType()) {
4924  Result = getDerived().RebuildExtVectorType(ElementType,
4925  T->getNumElements(),
4926  /*FIXME*/ SourceLocation());
4927  if (Result.isNull())
4928  return QualType();
4929  }
4930 
4931  ExtVectorTypeLoc NewTL = TLB.push<ExtVectorTypeLoc>(Result);
4932  NewTL.setNameLoc(TL.getNameLoc());
4933 
4934  return Result;
4935 }
4936 
4937 template <typename Derived>
4939  ParmVarDecl *OldParm, int indexAdjustment, Optional<unsigned> NumExpansions,
4940  bool ExpectParameterPack) {
4941  TypeSourceInfo *OldDI = OldParm->getTypeSourceInfo();
4942  TypeSourceInfo *NewDI = nullptr;
4943 
4944  if (NumExpansions && isa<PackExpansionType>(OldDI->getType())) {
4945  // If we're substituting into a pack expansion type and we know the
4946  // length we want to expand to, just substitute for the pattern.
4947  TypeLoc OldTL = OldDI->getTypeLoc();
4948  PackExpansionTypeLoc OldExpansionTL = OldTL.castAs<PackExpansionTypeLoc>();
4949 
4950  TypeLocBuilder TLB;
4951  TypeLoc NewTL = OldDI->getTypeLoc();
4952  TLB.reserve(NewTL.getFullDataSize());
4953 
4954  QualType Result = getDerived().TransformType(TLB,
4955  OldExpansionTL.getPatternLoc());
4956  if (Result.isNull())
4957  return nullptr;
4958 
4959  Result = RebuildPackExpansionType(Result,
4960  OldExpansionTL.getPatternLoc().getSourceRange(),
4961  OldExpansionTL.getEllipsisLoc(),
4962  NumExpansions);
4963  if (Result.isNull())
4964  return nullptr;
4965 
4966  PackExpansionTypeLoc NewExpansionTL
4967  = TLB.push<PackExpansionTypeLoc>(Result);
4968  NewExpansionTL.setEllipsisLoc(OldExpansionTL.getEllipsisLoc());
4969  NewDI = TLB.getTypeSourceInfo(SemaRef.Context, Result);
4970  } else
4971  NewDI = getDerived().TransformType(OldDI);
4972  if (!NewDI)
4973  return nullptr;
4974 
4975  if (NewDI == OldDI && indexAdjustment == 0)
4976  return OldParm;
4977 
4978  ParmVarDecl *newParm = ParmVarDecl::Create(SemaRef.Context,
4979  OldParm->getDeclContext(),
4980  OldParm->getInnerLocStart(),
4981  OldParm->getLocation(),
4982  OldParm->getIdentifier(),
4983  NewDI->getType(),
4984  NewDI,
4985  OldParm->getStorageClass(),
4986  /* DefArg */ nullptr);
4987  newParm->setScopeInfo(OldParm->getFunctionScopeDepth(),
4988  OldParm->getFunctionScopeIndex() + indexAdjustment);
4989  return newParm;
4990 }
4991 
4992 template <typename Derived>
4995  const QualType *ParamTypes,
4996  const FunctionProtoType::ExtParameterInfo *ParamInfos,
4997  SmallVectorImpl<QualType> &OutParamTypes,
5000  int indexAdjustment = 0;
5001 
5002  unsigned NumParams = Params.size();
5003  for (unsigned i = 0; i != NumParams; ++i) {
5004  if (ParmVarDecl *OldParm = Params[i]) {
5005  assert(OldParm->getFunctionScopeIndex() == i);
5006 
5007  Optional<unsigned> NumExpansions;
5008  ParmVarDecl *NewParm = nullptr;
5009  if (OldParm->isParameterPack()) {
5010  // We have a function parameter pack that may need to be expanded.
5012 
5013  // Find the parameter packs that could be expanded.
5014  TypeLoc TL = OldParm->getTypeSourceInfo()->getTypeLoc();
5015  PackExpansionTypeLoc ExpansionTL = TL.castAs<PackExpansionTypeLoc>();
5016  TypeLoc Pattern = ExpansionTL.getPatternLoc();
5017  SemaRef.collectUnexpandedParameterPacks(Pattern, Unexpanded);
5018  assert(Unexpanded.size() > 0 && "Could not find parameter packs!");
5019 
5020  // Determine whether we should expand the parameter packs.
5021  bool ShouldExpand = false;
5022  bool RetainExpansion = false;
5023  Optional<unsigned> OrigNumExpansions =
5024  ExpansionTL.getTypePtr()->getNumExpansions();
5025  NumExpansions = OrigNumExpansions;
5026  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
5027  Pattern.getSourceRange(),
5028  Unexpanded,
5029  ShouldExpand,
5030  RetainExpansion,
5031  NumExpansions)) {
5032  return true;
5033  }
5034 
5035  if (ShouldExpand) {
5036  // Expand the function parameter pack into multiple, separate
5037  // parameters.
5038  getDerived().ExpandingFunctionParameterPack(OldParm);
5039  for (unsigned I = 0; I != *NumExpansions; ++I) {
5040  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5041  ParmVarDecl *NewParm
5042  = getDerived().TransformFunctionTypeParam(OldParm,
5043  indexAdjustment++,
5044  OrigNumExpansions,
5045  /*ExpectParameterPack=*/false);
5046  if (!NewParm)
5047  return true;
5048 
5049  if (ParamInfos)
5050  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5051  OutParamTypes.push_back(NewParm->getType());
5052  if (PVars)
5053  PVars->push_back(NewParm);
5054  }
5055 
5056  // If we're supposed to retain a pack expansion, do so by temporarily
5057  // forgetting the partially-substituted parameter pack.
5058  if (RetainExpansion) {
5059  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5060  ParmVarDecl *NewParm
5061  = getDerived().TransformFunctionTypeParam(OldParm,
5062  indexAdjustment++,
5063  OrigNumExpansions,
5064  /*ExpectParameterPack=*/false);
5065  if (!NewParm)
5066  return true;
5067 
5068  if (ParamInfos)
5069  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5070  OutParamTypes.push_back(NewParm->getType());
5071  if (PVars)
5072  PVars->push_back(NewParm);
5073  }
5074 
5075  // The next parameter should have the same adjustment as the
5076  // last thing we pushed, but we post-incremented indexAdjustment
5077  // on every push. Also, if we push nothing, the adjustment should
5078  // go down by one.
5079  indexAdjustment--;
5080 
5081  // We're done with the pack expansion.
5082  continue;
5083  }
5084 
5085  // We'll substitute the parameter now without expanding the pack
5086  // expansion.
5087  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5088  NewParm = getDerived().TransformFunctionTypeParam(OldParm,
5089  indexAdjustment,
5090  NumExpansions,
5091  /*ExpectParameterPack=*/true);
5092  } else {
5093  NewParm = getDerived().TransformFunctionTypeParam(
5094  OldParm, indexAdjustment, None, /*ExpectParameterPack=*/ false);
5095  }
5096 
5097  if (!NewParm)
5098  return true;
5099 
5100  if (ParamInfos)
5101  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5102  OutParamTypes.push_back(NewParm->getType());
5103  if (PVars)
5104  PVars->push_back(NewParm);
5105  continue;
5106  }
5107 
5108  // Deal with the possibility that we don't have a parameter
5109  // declaration for this parameter.
5110  QualType OldType = ParamTypes[i];
5111  bool IsPackExpansion = false;
5112  Optional<unsigned> NumExpansions;
5113  QualType NewType;
5114  if (const PackExpansionType *Expansion
5115  = dyn_cast<PackExpansionType>(OldType)) {
5116  // We have a function parameter pack that may need to be expanded.
5117  QualType Pattern = Expansion->getPattern();
5119  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
5120 
5121  // Determine whether we should expand the parameter packs.
5122  bool ShouldExpand = false;
5123  bool RetainExpansion = false;
5124  if (getDerived().TryExpandParameterPacks(Loc, SourceRange(),
5125  Unexpanded,
5126  ShouldExpand,
5127  RetainExpansion,
5128  NumExpansions)) {
5129  return true;
5130  }
5131 
5132  if (ShouldExpand) {
5133  // Expand the function parameter pack into multiple, separate
5134  // parameters.
5135  for (unsigned I = 0; I != *NumExpansions; ++I) {
5136  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
5137  QualType NewType = getDerived().TransformType(Pattern);
5138  if (NewType.isNull())
5139  return true;
5140 
5141  if (NewType->containsUnexpandedParameterPack()) {
5142  NewType =
5143  getSema().getASTContext().getPackExpansionType(NewType, None);
5144 
5145  if (NewType.isNull())
5146  return true;
5147  }
5148 
5149  if (ParamInfos)
5150  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5151  OutParamTypes.push_back(NewType);
5152  if (PVars)
5153  PVars->push_back(nullptr);
5154  }
5155 
5156  // We're done with the pack expansion.
5157  continue;
5158  }
5159 
5160  // If we're supposed to retain a pack expansion, do so by temporarily
5161  // forgetting the partially-substituted parameter pack.
5162  if (RetainExpansion) {
5163  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
5164  QualType NewType = getDerived().TransformType(Pattern);
5165  if (NewType.isNull())
5166  return true;
5167 
5168  if (ParamInfos)
5169  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5170  OutParamTypes.push_back(NewType);
5171  if (PVars)
5172  PVars->push_back(nullptr);
5173  }
5174 
5175  // We'll substitute the parameter now without expanding the pack
5176  // expansion.
5177  OldType = Expansion->getPattern();
5178  IsPackExpansion = true;
5179  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5180  NewType = getDerived().TransformType(OldType);
5181  } else {
5182  NewType = getDerived().TransformType(OldType);
5183  }
5184 
5185  if (NewType.isNull())
5186  return true;
5187 
5188  if (IsPackExpansion)
5189  NewType = getSema().Context.getPackExpansionType(NewType,
5190  NumExpansions);
5191 
5192  if (ParamInfos)
5193  PInfos.set(OutParamTypes.size(), ParamInfos[i]);
5194  OutParamTypes.push_back(NewType);
5195  if (PVars)
5196  PVars->push_back(nullptr);
5197  }
5198 
5199 #ifndef NDEBUG
5200  if (PVars) {
5201  for (unsigned i = 0, e = PVars->size(); i != e; ++i)
5202  if (ParmVarDecl *parm = (*PVars)[i])
5203  assert(parm->getFunctionScopeIndex() == i);
5204  }
5205 #endif
5206 
5207  return false;
5208 }
5209 
5210 template<typename Derived>
5211 QualType
5213  FunctionProtoTypeLoc TL) {
5214  SmallVector<QualType, 4> ExceptionStorage;
5215  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
5216  return getDerived().TransformFunctionProtoType(
5217  TLB, TL, nullptr, 0,
5218  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
5219  return This->TransformExceptionSpec(TL.getBeginLoc(), ESI,
5220  ExceptionStorage, Changed);
5221  });
5222 }
5223 
5224 template<typename Derived> template<typename Fn>
5226  TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext,
5227  unsigned ThisTypeQuals, Fn TransformExceptionSpec) {
5228 
5229  // Transform the parameters and return type.
5230  //
5231  // We are required to instantiate the params and return type in source order.
5232  // When the function has a trailing return type, we instantiate the
5233  // parameters before the return type, since the return type can then refer
5234  // to the parameters themselves (via decltype, sizeof, etc.).
5235  //
5236  SmallVector<QualType, 4> ParamTypes;
5237  SmallVector<ParmVarDecl*, 4> ParamDecls;
5238  Sema::ExtParameterInfoBuilder ExtParamInfos;
5239  const FunctionProtoType *T = TL.getTypePtr();
5240 
5241  QualType ResultType;
5242 
5243  if (T->hasTrailingReturn()) {
5244  if (getDerived().TransformFunctionTypeParams(
5245  TL.getBeginLoc(), TL.getParams(),
5246  TL.getTypePtr()->param_type_begin(),
5248  ParamTypes, &ParamDecls, ExtParamInfos))
5249  return QualType();
5250 
5251  {
5252  // C++11 [expr.prim.general]p3:
5253  // If a declaration declares a member function or member function
5254  // template of a class X, the expression this is a prvalue of type
5255  // "pointer to cv-qualifier-seq X" between the optional cv-qualifer-seq
5256  // and the end of the function-definition, member-declarator, or
5257  // declarator.
5258  Sema::CXXThisScopeRAII ThisScope(SemaRef, ThisContext, ThisTypeQuals);
5259 
5260  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5261  if (ResultType.isNull())
5262  return QualType();
5263  }
5264  }
5265  else {
5266  ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5267  if (ResultType.isNull())
5268  return QualType();
5269 
5270  if (getDerived().TransformFunctionTypeParams(
5271  TL.getBeginLoc(), TL.getParams(),
5272  TL.getTypePtr()->param_type_begin(),
5274  ParamTypes, &ParamDecls, ExtParamInfos))
5275  return QualType();
5276  }
5277 
5279 
5280  bool EPIChanged = false;
5281  if (TransformExceptionSpec(EPI.ExceptionSpec, EPIChanged))
5282  return QualType();
5283 
5284  // Handle extended parameter information.
5285  if (auto NewExtParamInfos =
5286  ExtParamInfos.getPointerOrNull(ParamTypes.size())) {
5287  if (!EPI.ExtParameterInfos ||
5288  llvm::makeArrayRef(EPI.ExtParameterInfos, TL.getNumParams())
5289  != llvm::makeArrayRef(NewExtParamInfos, ParamTypes.size())) {
5290  EPIChanged = true;
5291  }
5292  EPI.ExtParameterInfos = NewExtParamInfos;
5293  } else if (EPI.ExtParameterInfos) {
5294  EPIChanged = true;
5295  EPI.ExtParameterInfos = nullptr;
5296  }
5297 
5298  QualType Result = TL.getType();
5299  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType() ||
5300  T->getParamTypes() != llvm::makeArrayRef(ParamTypes) || EPIChanged) {
5301  Result = getDerived().RebuildFunctionProtoType(ResultType, ParamTypes, EPI);
5302  if (Result.isNull())
5303  return QualType();
5304  }
5305 
5306  FunctionProtoTypeLoc NewTL = TLB.push<FunctionProtoTypeLoc>(Result);
5308  NewTL.setLParenLoc(TL.getLParenLoc());
5309  NewTL.setRParenLoc(TL.getRParenLoc());
5311  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5312  for (unsigned i = 0, e = NewTL.getNumParams(); i != e; ++i)
5313  NewTL.setParam(i, ParamDecls[i]);
5314 
5315  return Result;
5316 }
5317 
5318 template<typename Derived>
5321  SmallVectorImpl<QualType> &Exceptions, bool &Changed) {
5322  assert(ESI.Type != EST_Uninstantiated && ESI.Type != EST_Unevaluated);
5323 
5324  // Instantiate a dynamic noexcept expression, if any.
5325  if (isComputedNoexcept(ESI.Type)) {
5328  ExprResult NoexceptExpr = getDerived().TransformExpr(ESI.NoexceptExpr);
5329  if (NoexceptExpr.isInvalid())
5330  return true;
5331 
5332  ExceptionSpecificationType EST = ESI.Type;
5333  NoexceptExpr =
5334  getSema().ActOnNoexceptSpec(Loc, NoexceptExpr.get(), EST);
5335  if (NoexceptExpr.isInvalid())
5336  return true;
5337 
5338  if (ESI.NoexceptExpr != NoexceptExpr.get() || EST != ESI.Type)
5339  Changed = true;
5340  ESI.NoexceptExpr = NoexceptExpr.get();
5341  ESI.Type = EST;
5342  }
5343 
5344  if (ESI.Type != EST_Dynamic)
5345  return false;
5346 
5347  // Instantiate a dynamic exception specification's type.
5348  for (QualType T : ESI.Exceptions) {
5349  if (const PackExpansionType *PackExpansion =
5350  T->getAs<PackExpansionType>()) {
5351  Changed = true;
5352 
5353  // We have a pack expansion. Instantiate it.
5355  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
5356  Unexpanded);
5357  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
5358 
5359  // Determine whether the set of unexpanded parameter packs can and
5360  // should
5361  // be expanded.
5362  bool Expand = false;
5363  bool RetainExpansion = false;
5364  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
5365  // FIXME: Track the location of the ellipsis (and track source location
5366  // information for the types in the exception specification in general).
5367  if (getDerived().TryExpandParameterPacks(
5368  Loc, SourceRange(), Unexpanded, Expand,
5369  RetainExpansion, NumExpansions))
5370  return true;
5371 
5372  if (!Expand) {
5373  // We can't expand this pack expansion into separate arguments yet;
5374  // just substitute into the pattern and create a new pack expansion
5375  // type.
5376  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
5377  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5378  if (U.isNull())
5379  return true;
5380 
5381  U = SemaRef.Context.getPackExpansionType(U, NumExpansions);
5382  Exceptions.push_back(U);
5383  continue;
5384  }
5385 
5386  // Substitute into the pack expansion pattern for each slice of the
5387  // pack.
5388  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
5389  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
5390 
5391  QualType U = getDerived().TransformType(PackExpansion->getPattern());
5392  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5393  return true;
5394 
5395  Exceptions.push_back(U);
5396  }
5397  } else {
5398  QualType U = getDerived().TransformType(T);
5399  if (U.isNull() || SemaRef.CheckSpecifiedExceptionType(U, Loc))
5400  return true;
5401  if (T != U)
5402  Changed = true;
5403 
5404  Exceptions.push_back(U);
5405  }
5406  }
5407 
5408  ESI.Exceptions = Exceptions;
5409  if (ESI.Exceptions.empty())
5410  ESI.Type = EST_DynamicNone;
5411  return false;
5412 }
5413 
5414 template<typename Derived>
5416  TypeLocBuilder &TLB,
5418  const FunctionNoProtoType *T = TL.getTypePtr();
5419  QualType ResultType = getDerived().TransformType(TLB, TL.getReturnLoc());
5420  if (ResultType.isNull())
5421  return QualType();
5422 
5423  QualType Result = TL.getType();
5424  if (getDerived().AlwaysRebuild() || ResultType != T->getReturnType())
5425  Result = getDerived().RebuildFunctionNoProtoType(ResultType);
5426 
5427  FunctionNoProtoTypeLoc NewTL = TLB.push<FunctionNoProtoTypeLoc>(Result);
5429  NewTL.setLParenLoc(TL.getLParenLoc());
5430  NewTL.setRParenLoc(TL.getRParenLoc());
5431  NewTL.setLocalRangeEnd(TL.getLocalRangeEnd());
5432 
5433  return Result;
5434 }
5435 
5436 template<typename Derived> QualType
5439  const UnresolvedUsingType *T = TL.getTypePtr();
5440  Decl *D = getDerived().TransformDecl(TL.getNameLoc(), T->getDecl());
5441  if (!D)
5442  return QualType();
5443 
5444  QualType Result = TL.getType();
5445  if (getDerived().AlwaysRebuild() || D != T->getDecl()) {
5446  Result = getDerived().RebuildUnresolvedUsingType(TL.getNameLoc(), D);
5447  if (Result.isNull())
5448  return QualType();
5449  }
5450 
5451  // We might get an arbitrary type spec type back. We should at
5452  // least always get a type spec type, though.
5453  TypeSpecTypeLoc NewTL = TLB.pushTypeSpec(Result);
5454  NewTL.setNameLoc(TL.getNameLoc());
5455 
5456  return Result;
5457 }
5458 
5459 template<typename Derived>
5461  TypedefTypeLoc TL) {
5462  const TypedefType *T = TL.getTypePtr();
5463  TypedefNameDecl *Typedef
5464  = cast_or_null<TypedefNameDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5465  T->getDecl()));
5466  if (!Typedef)
5467  return QualType();
5468 
5469  QualType Result = TL.getType();
5470  if (getDerived().AlwaysRebuild() ||
5471  Typedef != T->getDecl()) {
5472  Result = getDerived().RebuildTypedefType(Typedef);
5473  if (Result.isNull())
5474  return QualType();
5475  }
5476 
5477  TypedefTypeLoc NewTL = TLB.push<TypedefTypeLoc>(Result);
5478  NewTL.setNameLoc(TL.getNameLoc());
5479 
5480  return Result;
5481 }
5482 
5483 template<typename Derived>
5485  TypeOfExprTypeLoc TL) {
5486  // typeof expressions are not potentially evaluated contexts
5490 
5491  ExprResult E = getDerived().TransformExpr(TL.getUnderlyingExpr());
5492  if (E.isInvalid())
5493  return QualType();
5494 
5495  E = SemaRef.HandleExprEvaluationContextForTypeof(E.get());
5496  if (E.isInvalid())
5497  return QualType();
5498 
5499  QualType Result = TL.getType();
5500  if (getDerived().AlwaysRebuild() ||
5501  E.get() != TL.getUnderlyingExpr()) {
5502  Result = getDerived().RebuildTypeOfExprType(E.get(), TL.getTypeofLoc());
5503  if (Result.isNull())
5504  return QualType();
5505  }
5506  else E.get();
5507 
5508  TypeOfExprTypeLoc NewTL = TLB.push<TypeOfExprTypeLoc>(Result);
5509  NewTL.setTypeofLoc(TL.getTypeofLoc());
5510  NewTL.setLParenLoc(TL.getLParenLoc());
5511  NewTL.setRParenLoc(TL.getRParenLoc());
5512 
5513  return Result;
5514 }
5515 
5516 template<typename Derived>
5518  TypeOfTypeLoc TL) {
5519  TypeSourceInfo* Old_Under_TI = TL.getUnderlyingTInfo();
5520  TypeSourceInfo* New_Under_TI = getDerived().TransformType(Old_Under_TI);
5521  if (!New_Under_TI)
5522  return QualType();
5523 
5524  QualType Result = TL.getType();
5525  if (getDerived().AlwaysRebuild() || New_Under_TI != Old_Under_TI) {
5526  Result = getDerived().RebuildTypeOfType(New_Under_TI->getType());
5527  if (Result.isNull())
5528  return QualType();
5529  }
5530 
5531  TypeOfTypeLoc NewTL = TLB.push<TypeOfTypeLoc>(Result);
5532  NewTL.setTypeofLoc(TL.getTypeofLoc());
5533  NewTL.setLParenLoc(TL.getLParenLoc());
5534  NewTL.setRParenLoc(TL.getRParenLoc());
5535  NewTL.setUnderlyingTInfo(New_Under_TI);
5536 
5537  return Result;
5538 }
5539 
5540 template<typename Derived>
5542  DecltypeTypeLoc TL) {
5543  const DecltypeType *T = TL.getTypePtr();
5544 
5545  // decltype expressions are not potentially evaluated contexts
5549 
5550  ExprResult E = getDerived().TransformExpr(T->getUnderlyingExpr());
5551  if (E.isInvalid())
5552  return QualType();
5553 
5554  E = getSema().ActOnDecltypeExpression(E.get());
5555  if (E.isInvalid())
5556  return QualType();
5557 
5558  QualType Result = TL.getType();
5559  if (getDerived().AlwaysRebuild() ||
5560  E.get() != T->getUnderlyingExpr()) {
5561  Result = getDerived().RebuildDecltypeType(E.get(), TL.getNameLoc());
5562  if (Result.isNull())
5563  return QualType();
5564  }
5565  else E.get();
5566 
5567  DecltypeTypeLoc NewTL = TLB.push<DecltypeTypeLoc>(Result);
5568  NewTL.setNameLoc(TL.getNameLoc());
5569 
5570  return Result;
5571 }
5572 
5573 template<typename Derived>
5575  TypeLocBuilder &TLB,
5576  UnaryTransformTypeLoc TL) {
5577  QualType Result = TL.getType();
5578  if (Result->isDependentType()) {
5579  const UnaryTransformType *T = TL.getTypePtr();
5580  QualType NewBase =
5581  getDerived().TransformType(TL.getUnderlyingTInfo())->getType();
5582  Result = getDerived().RebuildUnaryTransformType(NewBase,
5583  T->getUTTKind(),
5584  TL.getKWLoc());
5585  if (Result.isNull())
5586  return QualType();
5587  }
5588 
5589  UnaryTransformTypeLoc NewTL = TLB.push<UnaryTransformTypeLoc>(Result);
5590  NewTL.setKWLoc(TL.getKWLoc());
5591  NewTL.setParensRange(TL.getParensRange());
5593  return Result;
5594 }
5595 
5596 template<typename Derived>
5598  AutoTypeLoc TL) {
5599  const AutoType *T = TL.getTypePtr();
5600  QualType OldDeduced = T->getDeducedType();
5601  QualType NewDeduced;
5602  if (!OldDeduced.isNull()) {
5603  NewDeduced = getDerived().TransformType(OldDeduced);
5604  if (NewDeduced.isNull())
5605  return QualType();
5606  }
5607 
5608  QualType Result = TL.getType();
5609  if (getDerived().AlwaysRebuild() || NewDeduced != OldDeduced ||
5610  T->isDependentType()) {
5611  Result = getDerived().RebuildAutoType(NewDeduced, T->getKeyword());
5612  if (Result.isNull())
5613  return QualType();
5614  }
5615 
5616  AutoTypeLoc NewTL = TLB.push<AutoTypeLoc>(Result);
5617  NewTL.setNameLoc(TL.getNameLoc());
5618 
5619  return Result;
5620 }
5621 
5622 template<typename Derived>
5626 
5627  CXXScopeSpec SS;
5628  TemplateName TemplateName = getDerived().TransformTemplateName(
5629  SS, T->getTemplateName(), TL.getTemplateNameLoc());
5630  if (TemplateName.isNull())
5631  return QualType();
5632 
5633  QualType OldDeduced = T->getDeducedType();
5634  QualType NewDeduced;
5635  if (!OldDeduced.isNull()) {
5636  NewDeduced = getDerived().TransformType(OldDeduced);
5637  if (NewDeduced.isNull())
5638  return QualType();
5639  }
5640 
5641  QualType Result = getDerived().RebuildDeducedTemplateSpecializationType(
5642  TemplateName, NewDeduced);
5643  if (Result.isNull())
5644  return QualType();
5645 
5649 
5650  return Result;
5651 }
5652 
5653 template<typename Derived>
5655  RecordTypeLoc TL) {
5656  const RecordType *T = TL.getTypePtr();
5657  RecordDecl *Record
5658  = cast_or_null<RecordDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5659  T->getDecl()));
5660  if (!Record)
5661  return QualType();
5662 
5663  QualType Result = TL.getType();
5664  if (getDerived().AlwaysRebuild() ||
5665  Record != T->getDecl()) {
5666  Result = getDerived().RebuildRecordType(Record);
5667  if (Result.isNull())
5668  return QualType();
5669  }
5670 
5671  RecordTypeLoc NewTL = TLB.push<RecordTypeLoc>(Result);
5672  NewTL.setNameLoc(TL.getNameLoc());
5673 
5674  return Result;
5675 }
5676 
5677 template<typename Derived>
5679  EnumTypeLoc TL) {
5680  const EnumType *T = TL.getTypePtr();
5681  EnumDecl *Enum
5682  = cast_or_null<EnumDecl>(getDerived().TransformDecl(TL.getNameLoc(),
5683  T->getDecl()));
5684  if (!Enum)
5685  return QualType();
5686 
5687  QualType Result = TL.getType();
5688  if (getDerived().AlwaysRebuild() ||
5689  Enum != T->getDecl()) {
5690  Result = getDerived().RebuildEnumType(Enum);
5691  if (Result.isNull())
5692  return QualType();
5693  }
5694 
5695  EnumTypeLoc NewTL = TLB.push<EnumTypeLoc>(Result);
5696  NewTL.setNameLoc(TL.getNameLoc());
5697 
5698  return Result;
5699 }
5700 
5701 template<typename Derived>
5703  TypeLocBuilder &TLB,
5705  Decl *D = getDerived().TransformDecl(TL.getNameLoc(),
5706  TL.getTypePtr()->getDecl());
5707  if (!D) return QualType();
5708 
5709  QualType T = SemaRef.Context.getTypeDeclType(cast<TypeDecl>(D));
5710  TLB.pushTypeSpec(T).setNameLoc(TL.getNameLoc());
5711  return T;
5712 }
5713 
5714 template<typename Derived>
5716  TypeLocBuilder &TLB,
5718  return TransformTypeSpecType(TLB, TL);
5719 }
5720 
5721 template<typename Derived>
5723  TypeLocBuilder &TLB,
5725  const SubstTemplateTypeParmType *T = TL.getTypePtr();
5726 
5727  // Substitute into the replacement type, which itself might involve something
5728  // that needs to be transformed. This only tends to occur with default
5729  // template arguments of template template parameters.
5730  TemporaryBase Rebase(*this, TL.getNameLoc(), DeclarationName());
5731  QualType Replacement = getDerived().TransformType(T->getReplacementType());
5732  if (Replacement.isNull())
5733  return QualType();
5734 
5735  // Always canonicalize the replacement type.
5736  Replacement = SemaRef.Context.getCanonicalType(Replacement);
5737  QualType Result
5738  = SemaRef.Context.getSubstTemplateTypeParmType(T->getReplacedParameter(),
5739  Replacement);
5740 
5741  // Propagate type-source information.
5743  = TLB.push<SubstTemplateTypeParmTypeLoc>(Result);
5744  NewTL.setNameLoc(TL.getNameLoc());
5745  return Result;
5746 
5747 }
5748 
5749 template<typename Derived>
5751  TypeLocBuilder &TLB,
5753  return TransformTypeSpecType(TLB, TL);
5754 }
5755 
5756 template<typename Derived>
5758  TypeLocBuilder &TLB,
5760  const TemplateSpecializationType *T = TL.getTypePtr();
5761 
5762  // The nested-name-specifier never matters in a TemplateSpecializationType,
5763  // because we can't have a dependent nested-name-specifier anyway.
5764  CXXScopeSpec SS;
5765  TemplateName Template
5766  = getDerived().TransformTemplateName(SS, T->getTemplateName(),
5767  TL.getTemplateNameLoc());
5768  if (Template.isNull())
5769  return QualType();
5770 
5771  return getDerived().TransformTemplateSpecializationType(TLB, TL, Template);
5772 }
5773 
5774 template<typename Derived>
5776  AtomicTypeLoc TL) {
5777  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
5778  if (ValueType.isNull())
5779  return QualType();
5780 
5781  QualType Result = TL.getType();
5782  if (getDerived().AlwaysRebuild() ||
5783  ValueType != TL.getValueLoc().getType()) {
5784  Result = getDerived().RebuildAtomicType(ValueType, TL.getKWLoc());
5785  if (Result.isNull())
5786  return QualType();
5787  }
5788 
5789  AtomicTypeLoc NewTL = TLB.push<AtomicTypeLoc>(Result);
5790  NewTL.setKWLoc(TL.getKWLoc());
5791  NewTL.setLParenLoc(TL.getLParenLoc());
5792  NewTL.setRParenLoc(TL.getRParenLoc());
5793 
5794  return Result;
5795 }
5796 
5797 template <typename Derived>
5799  PipeTypeLoc TL) {
5800  QualType ValueType = getDerived().TransformType(TLB, TL.getValueLoc());
5801  if (ValueType.isNull())
5802  return QualType();
5803 
5804  QualType Result = TL.getType();
5805  if (getDerived().AlwaysRebuild() || ValueType != TL.getValueLoc().getType()) {
5806  const PipeType *PT = Result->getAs<PipeType>();
5807  bool isReadPipe = PT->isReadOnly();
5808  Result = getDerived().RebuildPipeType(ValueType, TL.getKWLoc(), isReadPipe);
5809  if (Result.isNull())
5810  return QualType();
5811  }
5812 
5813  PipeTypeLoc NewTL = TLB.push<PipeTypeLoc>(Result);
5814  NewTL.setKWLoc(TL.getKWLoc());
5815 
5816  return Result;
5817 }
5818 
5819  /// Simple iterator that traverses the template arguments in a
5820  /// container that provides a \c getArgLoc() member function.
5821  ///
5822  /// This iterator is intended to be used with the iterator form of
5823  /// \c TreeTransform<Derived>::TransformTemplateArguments().
5824  template<typename ArgLocContainer>
5826  ArgLocContainer *Container;
5827  unsigned Index;
5828 
5829  public:
5832  typedef int difference_type;
5833  typedef std::input_iterator_tag iterator_category;
5834 
5835  class pointer {
5836  TemplateArgumentLoc Arg;
5837 
5838  public:
5839  explicit pointer(TemplateArgumentLoc Arg) : Arg(Arg) { }
5840 
5842  return &Arg;
5843  }
5844  };
5845 
5846 
5848 
5849  TemplateArgumentLocContainerIterator(ArgLocContainer &Container,
5850  unsigned Index)
5851  : Container(&Container), Index(Index) { }
5852 
5854  ++Index;
5855  return *this;
5856  }
5857 
5860  ++(*this);
5861  return Old;
5862  }
5863 
5865  return Container->getArgLoc(Index);
5866  }
5867 
5869  return pointer(Container->getArgLoc(Index));
5870  }
5871 
5874  return X.Container == Y.Container && X.Index == Y.Index;
5875  }
5876 
5879  return !(X == Y);
5880  }
5881  };
5882 
5883 
5884 template <typename Derived>
5886  TypeLocBuilder &TLB,
5888  TemplateName Template) {
5889  TemplateArgumentListInfo NewTemplateArgs;
5890  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
5891  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
5893  ArgIterator;
5894  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
5895  ArgIterator(TL, TL.getNumArgs()),
5896  NewTemplateArgs))
5897  return QualType();
5898 
5899  // FIXME: maybe don't rebuild if all the template arguments are the same.
5900 
5901  QualType Result =
5902  getDerived().RebuildTemplateSpecializationType(Template,
5903  TL.getTemplateNameLoc(),
5904  NewTemplateArgs);
5905 
5906  if (!Result.isNull()) {
5907  // Specializations of template template parameters are represented as
5908  // TemplateSpecializationTypes, and substitution of type alias templates
5909  // within a dependent context can transform them into
5910  // DependentTemplateSpecializationTypes.
5911  if (isa<DependentTemplateSpecializationType>(Result)) {
5918  NewTL.setLAngleLoc(TL.getLAngleLoc());
5919  NewTL.setRAngleLoc(TL.getRAngleLoc());
5920  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5921  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5922  return Result;
5923  }
5924 
5926  = TLB.push<TemplateSpecializationTypeLoc>(Result);
5929  NewTL.setLAngleLoc(TL.getLAngleLoc());
5930  NewTL.setRAngleLoc(TL.getRAngleLoc());
5931  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5932  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5933  }
5934 
5935  return Result;
5936 }
5937 
5938 template <typename Derived>
5940  TypeLocBuilder &TLB,
5942  TemplateName Template,
5943  CXXScopeSpec &SS) {
5944  TemplateArgumentListInfo NewTemplateArgs;
5945  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
5946  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
5949  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
5950  ArgIterator(TL, TL.getNumArgs()),
5951  NewTemplateArgs))
5952  return QualType();
5953 
5954  // FIXME: maybe don't rebuild if all the template arguments are the same.
5955 
5956  if (DependentTemplateName *DTN = Template.getAsDependentTemplateName()) {
5957  QualType Result
5958  = getSema().Context.getDependentTemplateSpecializationType(
5959  TL.getTypePtr()->getKeyword(),
5960  DTN->getQualifier(),
5961  DTN->getIdentifier(),
5962  NewTemplateArgs);
5963 
5967  NewTL.setQualifierLoc(SS.getWithLocInContext(SemaRef.Context));
5970  NewTL.setLAngleLoc(TL.getLAngleLoc());
5971  NewTL.setRAngleLoc(TL.getRAngleLoc());
5972  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5973  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5974  return Result;
5975  }
5976 
5977  QualType Result
5978  = getDerived().RebuildTemplateSpecializationType(Template,
5979  TL.getTemplateNameLoc(),
5980  NewTemplateArgs);
5981 
5982  if (!Result.isNull()) {
5983  /// FIXME: Wrap this in an elaborated-type-specifier?
5985  = TLB.push<TemplateSpecializationTypeLoc>(Result);
5988  NewTL.setLAngleLoc(TL.getLAngleLoc());
5989  NewTL.setRAngleLoc(TL.getRAngleLoc());
5990  for (unsigned i = 0, e = NewTemplateArgs.size(); i != e; ++i)
5991  NewTL.setArgLocInfo(i, NewTemplateArgs[i].getLocInfo());
5992  }
5993 
5994  return Result;
5995 }
5996 
5997 template<typename Derived>
5998 QualType
6000  ElaboratedTypeLoc TL) {
6001  const ElaboratedType *T = TL.getTypePtr();
6002 
6003  NestedNameSpecifierLoc QualifierLoc;
6004  // NOTE: the qualifier in an ElaboratedType is optional.
6005  if (TL.getQualifierLoc()) {
6006  QualifierLoc
6007  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6008  if (!QualifierLoc)
6009  return QualType();
6010  }
6011 
6012  QualType NamedT = getDerived().TransformType(TLB, TL.getNamedTypeLoc());
6013  if (NamedT.isNull())
6014  return QualType();
6015 
6016  // C++0x [dcl.type.elab]p2:
6017  // If the identifier resolves to a typedef-name or the simple-template-id
6018  // resolves to an alias template specialization, the
6019  // elaborated-type-specifier is ill-formed.
6020  if (T->getKeyword() != ETK_None && T->getKeyword() != ETK_Typename) {
6021  if (const TemplateSpecializationType *TST =
6022  NamedT->getAs<TemplateSpecializationType>()) {
6023  TemplateName Template = TST->getTemplateName();
6024  if (TypeAliasTemplateDecl *TAT = dyn_cast_or_null<TypeAliasTemplateDecl>(
6025  Template.getAsTemplateDecl())) {
6026  SemaRef.Diag(TL.getNamedTypeLoc().getBeginLoc(),
6027  diag::err_tag_reference_non_tag)
6028  << TAT << Sema::NTK_TypeAliasTemplate
6030  SemaRef.Diag(TAT->getLocation(), diag::note_declared_at);
6031  }
6032  }
6033  }
6034 
6035  QualType Result = TL.getType();
6036  if (getDerived().AlwaysRebuild() ||
6037  QualifierLoc != TL.getQualifierLoc() ||
6038  NamedT != T->getNamedType()) {
6039  Result = getDerived().RebuildElaboratedType(TL.getElaboratedKeywordLoc(),
6040  T->getKeyword(),
6041  QualifierLoc, NamedT);
6042  if (Result.isNull())
6043  return QualType();
6044  }
6045 
6046  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6048  NewTL.setQualifierLoc(QualifierLoc);
6049  return Result;
6050 }
6051 
6052 template<typename Derived>
6054  TypeLocBuilder &TLB,
6055  AttributedTypeLoc TL) {
6056  const AttributedType *oldType = TL.getTypePtr();
6057  QualType modifiedType = getDerived().TransformType(TLB, TL.getModifiedLoc());
6058  if (modifiedType.isNull())
6059  return QualType();
6060 
6061  QualType result = TL.getType();
6062 
6063  // FIXME: dependent operand expressions?
6064  if (getDerived().AlwaysRebuild() ||
6065  modifiedType != oldType->getModifiedType()) {
6066  // TODO: this is really lame; we should really be rebuilding the
6067  // equivalent type from first principles.
6068  QualType equivalentType
6069  = getDerived().TransformType(oldType->getEquivalentType());
6070  if (equivalentType.isNull())
6071  return QualType();
6072 
6073  // Check whether we can add nullability; it is only represented as
6074  // type sugar, and therefore cannot be diagnosed in any other way.
6075  if (auto nullability = oldType->getImmediateNullability()) {
6076  if (!modifiedType->canHaveNullability()) {
6077  SemaRef.Diag(TL.getAttrNameLoc(), diag::err_nullability_nonpointer)
6078  << DiagNullabilityKind(*nullability, false) << modifiedType;
6079  return QualType();
6080  }
6081  }
6082 
6083  result = SemaRef.Context.getAttributedType(oldType->getAttrKind(),
6084  modifiedType,
6085  equivalentType);
6086  }
6087 
6088  AttributedTypeLoc newTL = TLB.push<AttributedTypeLoc>(result);
6089  newTL.setAttrNameLoc(TL.getAttrNameLoc());
6090  if (TL.hasAttrOperand())
6092  if (TL.hasAttrExprOperand())
6094  else if (TL.hasAttrEnumOperand())
6096 
6097  return result;
6098 }
6099 
6100 template<typename Derived>
6101 QualType
6103  ParenTypeLoc TL) {
6104  QualType Inner = getDerived().TransformType(TLB, TL.getInnerLoc());
6105  if (Inner.isNull())
6106  return QualType();
6107 
6108  QualType Result = TL.getType();
6109  if (getDerived().AlwaysRebuild() ||
6110  Inner != TL.getInnerLoc().getType()) {
6111  Result = getDerived().RebuildParenType(Inner);
6112  if (Result.isNull())
6113  return QualType();
6114  }
6115 
6116  ParenTypeLoc NewTL = TLB.push<ParenTypeLoc>(Result);
6117  NewTL.setLParenLoc(TL.getLParenLoc());
6118  NewTL.setRParenLoc(TL.getRParenLoc());
6119  return Result;
6120 }
6121 
6122 template<typename Derived>
6125  return TransformDependentNameType(TLB, TL, false);
6126 }
6127 
6128 template<typename Derived>
6130  TypeLocBuilder &TLB, DependentNameTypeLoc TL, bool DeducedTSTContext) {
6131  const DependentNameType *T = TL.getTypePtr();
6132 
6133  NestedNameSpecifierLoc QualifierLoc
6134  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6135  if (!QualifierLoc)
6136  return QualType();
6137 
6138  QualType Result
6139  = getDerived().RebuildDependentNameType(T->getKeyword(),
6141  QualifierLoc,
6142  T->getIdentifier(),
6143  TL.getNameLoc(),
6144  DeducedTSTContext);
6145  if (Result.isNull())
6146  return QualType();
6147 
6148  if (const ElaboratedType* ElabT = Result->getAs<ElaboratedType>()) {
6149  QualType NamedT = ElabT->getNamedType();
6150  TLB.pushTypeSpec(NamedT).setNameLoc(TL.getNameLoc());
6151 
6152  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6154  NewTL.setQualifierLoc(QualifierLoc);
6155  } else {
6156  DependentNameTypeLoc NewTL = TLB.push<DependentNameTypeLoc>(Result);
6158  NewTL.setQualifierLoc(QualifierLoc);
6159  NewTL.setNameLoc(TL.getNameLoc());
6160  }
6161  return Result;
6162 }
6163 
6164 template<typename Derived>
6168  NestedNameSpecifierLoc QualifierLoc;
6169  if (TL.getQualifierLoc()) {
6170  QualifierLoc
6171  = getDerived().TransformNestedNameSpecifierLoc(TL.getQualifierLoc());
6172  if (!QualifierLoc)
6173  return QualType();
6174  }
6175 
6176  return getDerived()
6177  .TransformDependentTemplateSpecializationType(TLB, TL, QualifierLoc);
6178 }
6179 
6180 template<typename Derived>
6184  NestedNameSpecifierLoc QualifierLoc) {
6186 
6187  TemplateArgumentListInfo NewTemplateArgs;
6188  NewTemplateArgs.setLAngleLoc(TL.getLAngleLoc());
6189  NewTemplateArgs.setRAngleLoc(TL.getRAngleLoc());
6190 
6193  if (getDerived().TransformTemplateArguments(ArgIterator(TL, 0),
6194  ArgIterator(TL, TL.getNumArgs()),
6195  NewTemplateArgs))
6196  return QualType();
6197 
6198  QualType Result = getDerived().RebuildDependentTemplateSpecializationType(
6199  T->getKeyword(), QualifierLoc, TL.getTemplateKeywordLoc(),
6200  T->getIdentifier(), TL.getTemplateNameLoc(), NewTemplateArgs,
6201  /*AllowInjectedClassName*/ false);
6202  if (Result.isNull())
6203  return QualType();
6204 
6205  if (const ElaboratedType *ElabT = dyn_cast<ElaboratedType>(Result)) {
6206  QualType NamedT = ElabT->getNamedType();
6207 
6208  // Copy information relevant to the template specialization.
6210  = TLB.push<TemplateSpecializationTypeLoc>(NamedT);
6212  NamedTL.setTemplateNameLoc(TL.getTemplateNameLoc());
6213  NamedTL.setLAngleLoc(TL.getLAngleLoc());
6214  NamedTL.setRAngleLoc(TL.getRAngleLoc());
6215  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6216  NamedTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6217 
6218  // Copy information relevant to the elaborated type.
6219  ElaboratedTypeLoc NewTL = TLB.push<ElaboratedTypeLoc>(Result);
6221  NewTL.setQualifierLoc(QualifierLoc);
6222  } else if (isa<DependentTemplateSpecializationType>(Result)) {
6226  SpecTL.setQualifierLoc(QualifierLoc);
6229  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6230  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6231  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6232  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6233  } else {
6235  = TLB.push<TemplateSpecializationTypeLoc>(Result);
6238  SpecTL.setLAngleLoc(TL.getLAngleLoc());
6239  SpecTL.setRAngleLoc(TL.getRAngleLoc());
6240  for (unsigned I = 0, E = NewTemplateArgs.size(); I != E; ++I)
6241  SpecTL.setArgLocInfo(I, NewTemplateArgs[I].getLocInfo());
6242  }
6243  return Result;
6244 }
6245 
6246 template<typename Derived>
6248  PackExpansionTypeLoc TL) {
6249  QualType Pattern
6250  = getDerived().TransformType(TLB, TL.getPatternLoc());
6251  if (Pattern.isNull())
6252  return QualType();
6253 
6254  QualType Result = TL.getType();
6255  if (getDerived().AlwaysRebuild() ||
6256  Pattern != TL.getPatternLoc().getType()) {
6257  Result = getDerived().RebuildPackExpansionType(Pattern,
6259  TL.getEllipsisLoc(),
6260  TL.getTypePtr()->getNumExpansions());
6261  if (Result.isNull())
6262  return QualType();
6263  }
6264 
6265  PackExpansionTypeLoc NewT = TLB.push<PackExpansionTypeLoc>(Result);
6266  NewT.setEllipsisLoc(TL.getEllipsisLoc());
6267  return Result;
6268 }
6269 
6270 template<typename Derived>
6271 QualType
6273  ObjCInterfaceTypeLoc TL) {
6274  // ObjCInterfaceType is never dependent.
6275  TLB.pushFullCopy(TL);
6276  return TL.getType();
6277 }
6278 
6279 template<typename Derived>
6280 QualType
6282  ObjCTypeParamTypeLoc TL) {
6283  const ObjCTypeParamType *T = TL.getTypePtr();
6284  ObjCTypeParamDecl *OTP = cast_or_null<ObjCTypeParamDecl>(
6285  getDerived().TransformDecl(T->getDecl()->getLocation(), T->getDecl()));
6286  if (!OTP)
6287  return QualType();
6288 
6289  QualType Result = TL.getType();
6290  if (getDerived().AlwaysRebuild() ||
6291  OTP != T->getDecl()) {
6292  Result = getDerived().RebuildObjCTypeParamType(OTP,
6293  TL.getProtocolLAngleLoc(),
6294  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(),
6295  TL.getNumProtocols()),
6296  TL.getProtocolLocs(),
6297  TL.getProtocolRAngleLoc());
6298  if (Result.isNull())
6299  return QualType();
6300  }
6301 
6302  ObjCTypeParamTypeLoc NewTL = TLB.push<ObjCTypeParamTypeLoc>(Result);
6303  if (TL.getNumProtocols()) {
6305  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6306  NewTL.setProtocolLoc(i, TL.getProtocolLoc(i));
6308  }
6309  return Result;
6310 }
6311 
6312 template<typename Derived>
6313 QualType
6315  ObjCObjectTypeLoc TL) {
6316  // Transform base type.
6317  QualType BaseType = getDerived().TransformType(TLB, TL.getBaseLoc());
6318  if (BaseType.isNull())
6319  return QualType();
6320 
6321  bool AnyChanged = BaseType != TL.getBaseLoc().getType();
6322 
6323  // Transform type arguments.
6324  SmallVector<TypeSourceInfo *, 4> NewTypeArgInfos;
6325  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i) {
6326  TypeSourceInfo *TypeArgInfo = TL.getTypeArgTInfo(i);
6327  TypeLoc TypeArgLoc = TypeArgInfo->getTypeLoc();
6328  QualType TypeArg = TypeArgInfo->getType();
6329  if (auto PackExpansionLoc = TypeArgLoc.getAs<PackExpansionTypeLoc>()) {
6330  AnyChanged = true;
6331 
6332  // We have a pack expansion. Instantiate it.
6333  const auto *PackExpansion = PackExpansionLoc.getType()
6336  SemaRef.collectUnexpandedParameterPacks(PackExpansion->getPattern(),
6337  Unexpanded);
6338  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
6339 
6340  // Determine whether the set of unexpanded parameter packs can
6341  // and should be expanded.
6342  TypeLoc PatternLoc = PackExpansionLoc.getPatternLoc();
6343  bool Expand = false;
6344  bool RetainExpansion = false;
6345  Optional<unsigned> NumExpansions = PackExpansion->getNumExpansions();
6346  if (getDerived().TryExpandParameterPacks(
6347  PackExpansionLoc.getEllipsisLoc(), PatternLoc.getSourceRange(),
6348  Unexpanded, Expand, RetainExpansion, NumExpansions))
6349  return QualType();
6350 
6351  if (!Expand) {
6352  // We can't expand this pack expansion into separate arguments yet;
6353  // just substitute into the pattern and create a new pack expansion
6354  // type.
6355  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
6356 
6357  TypeLocBuilder TypeArgBuilder;
6358  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6359  QualType NewPatternType = getDerived().TransformType(TypeArgBuilder,
6360  PatternLoc);
6361  if (NewPatternType.isNull())
6362  return QualType();
6363 
6364  QualType NewExpansionType = SemaRef.Context.getPackExpansionType(
6365  NewPatternType, NumExpansions);
6366  auto NewExpansionLoc = TLB.push<PackExpansionTypeLoc>(NewExpansionType);
6367  NewExpansionLoc.setEllipsisLoc(PackExpansionLoc.getEllipsisLoc());
6368  NewTypeArgInfos.push_back(
6369  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewExpansionType));
6370  continue;
6371  }
6372 
6373  // Substitute into the pack expansion pattern for each slice of the
6374  // pack.
6375  for (unsigned ArgIdx = 0; ArgIdx != *NumExpansions; ++ArgIdx) {
6376  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), ArgIdx);
6377 
6378  TypeLocBuilder TypeArgBuilder;
6379  TypeArgBuilder.reserve(PatternLoc.getFullDataSize());
6380 
6381  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder,
6382  PatternLoc);
6383  if (NewTypeArg.isNull())
6384  return QualType();
6385 
6386  NewTypeArgInfos.push_back(
6387  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6388  }
6389 
6390  continue;
6391  }
6392 
6393  TypeLocBuilder TypeArgBuilder;
6394  TypeArgBuilder.reserve(TypeArgLoc.getFullDataSize());
6395  QualType NewTypeArg = getDerived().TransformType(TypeArgBuilder, TypeArgLoc);
6396  if (NewTypeArg.isNull())
6397  return QualType();
6398 
6399  // If nothing changed, just keep the old TypeSourceInfo.
6400  if (NewTypeArg == TypeArg) {
6401  NewTypeArgInfos.push_back(TypeArgInfo);
6402  continue;
6403  }
6404 
6405  NewTypeArgInfos.push_back(
6406  TypeArgBuilder.getTypeSourceInfo(SemaRef.Context, NewTypeArg));
6407  AnyChanged = true;
6408  }
6409 
6410  QualType Result = TL.getType();
6411  if (getDerived().AlwaysRebuild() || AnyChanged) {
6412  // Rebuild the type.
6413  Result = getDerived().RebuildObjCObjectType(
6414  BaseType,
6415  TL.getLocStart(),
6416  TL.getTypeArgsLAngleLoc(),
6417  NewTypeArgInfos,
6418  TL.getTypeArgsRAngleLoc(),
6419  TL.getProtocolLAngleLoc(),
6420  llvm::makeArrayRef(TL.getTypePtr()->qual_begin(),
6421  TL.getNumProtocols()),
6422  TL.getProtocolLocs(),
6423  TL.getProtocolRAngleLoc());
6424 
6425  if (Result.isNull())
6426  return QualType();
6427  }
6428 
6429  ObjCObjectTypeLoc NewT = TLB.push<ObjCObjectTypeLoc>(Result);
6430  NewT.setHasBaseTypeAsWritten(true);
6432  for (unsigned i = 0, n = TL.getNumTypeArgs(); i != n; ++i)
6433  NewT.setTypeArgTInfo(i, NewTypeArgInfos[i]);
6436  for (unsigned i = 0, n = TL.getNumProtocols(); i != n; ++i)
6437  NewT.setProtocolLoc(i, TL.getProtocolLoc(i));
6439  return Result;
6440 }
6441 
6442 template<typename Derived>
6443 QualType
6446  QualType PointeeType = getDerived().TransformType(TLB, TL.getPointeeLoc());
6447  if (PointeeType.isNull())
6448  return QualType();
6449 
6450  QualType Result = TL.getType();
6451  if (getDerived().AlwaysRebuild() ||
6452  PointeeType != TL.getPointeeLoc().getType()) {
6453  Result = getDerived().RebuildObjCObjectPointerType(PointeeType,
6454  TL.getStarLoc());
6455  if (Result.isNull())
6456  return QualType();
6457  }
6458 
6460  NewT.setStarLoc(TL.getStarLoc());
6461  return Result;
6462 }
6463 
6464 //===----------------------------------------------------------------------===//
6465 // Statement transformation
6466 //===----------------------------------------------------------------------===//
6467 template<typename Derived>
6468 StmtResult
6470  return S;
6471 }
6472 
6473 template<typename Derived>
6474 StmtResult
6476  return getDerived().TransformCompoundStmt(S, false);
6477 }
6478 
6479 template<typename Derived>
6480 StmtResult
6482  bool IsStmtExpr) {
6483  Sema::CompoundScopeRAII CompoundScope(getSema());
6484 
6485  bool SubStmtInvalid = false;
6486  bool SubStmtChanged = false;
6487  SmallVector<Stmt*, 8> Statements;
6488  for (auto *B : S->body()) {
6489  StmtResult Result = getDerived().TransformStmt(B);
6490  if (Result.isInvalid()) {
6491  // Immediately fail if this was a DeclStmt, since it's very
6492  // likely that this will cause problems for future statements.
6493  if (isa<DeclStmt>(B))
6494  return StmtError();
6495 
6496  // Otherwise, just keep processing substatements and fail later.
6497  SubStmtInvalid = true;
6498  continue;
6499  }
6500 
6501  SubStmtChanged = SubStmtChanged || Result.get() != B;
6502  Statements.push_back(Result.getAs<Stmt>());
6503  }
6504 
6505  if (SubStmtInvalid)
6506  return StmtError();
6507 
6508  if (!getDerived().AlwaysRebuild() &&
6509  !SubStmtChanged)
6510  return S;
6511 
6512  return getDerived().RebuildCompoundStmt(S->getLBracLoc(),
6513  Statements,
6514  S->getRBracLoc(),
6515  IsStmtExpr);
6516 }
6517 
6518 template<typename Derived>
6519 StmtResult
6521  ExprResult LHS, RHS;
6522  {
6525 
6526  // Transform the left-hand case value.
6527  LHS = getDerived().TransformExpr(S->getLHS());
6528  LHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), LHS);
6529  if (LHS.isInvalid())
6530  return StmtError();
6531 
6532  // Transform the right-hand case value (for the GNU case-range extension).
6533  RHS = getDerived().TransformExpr(S->getRHS());
6534  RHS = SemaRef.ActOnCaseExpr(S->getCaseLoc(), RHS);
6535  if (RHS.isInvalid())
6536  return StmtError();
6537  }
6538 
6539  // Build the case statement.
6540  // Case statements are always rebuilt so that they will attached to their
6541  // transformed switch statement.
6542  StmtResult Case = getDerived().RebuildCaseStmt(S->getCaseLoc(),
6543  LHS.get(),
6544  S->getEllipsisLoc(),
6545  RHS.get(),
6546  S->getColonLoc());
6547  if (Case.isInvalid())
6548  return StmtError();
6549 
6550  // Transform the statement following the case
6551  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6552  if (SubStmt.isInvalid())
6553  return StmtError();
6554 
6555  // Attach the body to the case statement
6556  return getDerived().RebuildCaseStmtBody(Case.get(), SubStmt.get());
6557 }
6558 
6559 template<typename Derived>
6560 StmtResult
6562  // Transform the statement following the default case
6563  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6564  if (SubStmt.isInvalid())
6565  return StmtError();
6566 
6567  // Default statements are always rebuilt
6568  return getDerived().RebuildDefaultStmt(S->getDefaultLoc(), S->getColonLoc(),
6569  SubStmt.get());
6570 }
6571 
6572 template<typename Derived>
6573 StmtResult
6575  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6576  if (SubStmt.isInvalid())
6577  return StmtError();
6578 
6579  Decl *LD = getDerived().TransformDecl(S->getDecl()->getLocation(),
6580  S->getDecl());
6581  if (!LD)
6582  return StmtError();
6583 
6584 
6585  // FIXME: Pass the real colon location in.
6586  return getDerived().RebuildLabelStmt(S->getIdentLoc(),
6587  cast<LabelDecl>(LD), SourceLocation(),
6588  SubStmt.get());
6589 }
6590 
6591 template <typename Derived>
6593  if (!R)
6594  return R;
6595 
6596  switch (R->getKind()) {
6597 // Transform attributes with a pragma spelling by calling TransformXXXAttr.
6598 #define ATTR(X)
6599 #define PRAGMA_SPELLING_ATTR(X) \
6600  case attr::X: \
6601  return getDerived().Transform##X##Attr(cast<X##Attr>(R));
6602 #include "clang/Basic/AttrList.inc"
6603  default:
6604  return R;
6605  }
6606 }
6607 
6608 template <typename Derived>
6610  bool AttrsChanged = false;
6612 
6613  // Visit attributes and keep track if any are transformed.
6614  for (const auto *I : S->getAttrs()) {
6615  const Attr *R = getDerived().TransformAttr(I);
6616  AttrsChanged |= (I != R);
6617  Attrs.push_back(R);
6618  }
6619 
6620  StmtResult SubStmt = getDerived().TransformStmt(S->getSubStmt());
6621  if (SubStmt.isInvalid())
6622  return StmtError();
6623 
6624  if (SubStmt.get() == S->getSubStmt() && !AttrsChanged)
6625  return S;
6626 
6627  return getDerived().RebuildAttributedStmt(S->getAttrLoc(), Attrs,
6628  SubStmt.get());
6629 }
6630 
6631 template<typename Derived>
6632 StmtResult
6634  // Transform the initialization statement
6635  StmtResult Init = getDerived().TransformStmt(S->getInit());
6636  if (Init.isInvalid())
6637  return StmtError();
6638 
6639  // Transform the condition
6640  Sema::ConditionResult Cond = getDerived().TransformCondition(
6641  S->getIfLoc(), S->getConditionVariable(), S->getCond(),
6644  if (Cond.isInvalid())
6645  return StmtError();
6646 
6647  // If this is a constexpr if, determine which arm we should instantiate.
6648  llvm::Optional<bool> ConstexprConditionValue;
6649  if (S->isConstexpr())
6650  ConstexprConditionValue = Cond.getKnownValue();
6651 
6652  // Transform the "then" branch.
6653  StmtResult Then;
6654  if (!ConstexprConditionValue || *ConstexprConditionValue) {
6655  Then = getDerived().TransformStmt(S->getThen());
6656  if (Then.isInvalid())
6657  return StmtError();
6658  } else {
6659  Then = new (getSema().Context) NullStmt(S->getThen()->getLocStart());
6660  }
6661 
6662  // Transform the "else" branch.
6663  StmtResult Else;
6664  if (!ConstexprConditionValue || !*ConstexprConditionValue) {
6665  Else = getDerived().TransformStmt(S->getElse());
6666  if (Else.isInvalid())
6667  return StmtError();
6668  }
6669 
6670  if (!getDerived().AlwaysRebuild() &&
6671  Init.get() == S->getInit() &&
6672  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6673  Then.get() == S->getThen() &&
6674  Else.get() == S->getElse())
6675  return S;
6676 
6677  return getDerived().RebuildIfStmt(S->getIfLoc(), S->isConstexpr(), Cond,
6678  Init.get(), Then.get(), S->getElseLoc(),
6679  Else.get());
6680 }
6681 
6682 template<typename Derived>
6683 StmtResult
6685  // Transform the initialization statement
6686  StmtResult Init = getDerived().TransformStmt(S->getInit());
6687  if (Init.isInvalid())
6688  return StmtError();
6689 
6690  // Transform the condition.
6691  Sema::ConditionResult Cond = getDerived().TransformCondition(
6692  S->getSwitchLoc(), S->getConditionVariable(), S->getCond(),
6694  if (Cond.isInvalid())
6695  return StmtError();
6696 
6697  // Rebuild the switch statement.
6698  StmtResult Switch
6699  = getDerived().RebuildSwitchStmtStart(S->getSwitchLoc(), Init.get(), Cond);
6700  if (Switch.isInvalid())
6701  return StmtError();
6702 
6703  // Transform the body of the switch statement.
6704  StmtResult Body = getDerived().TransformStmt(S->getBody());
6705  if (Body.isInvalid())
6706  return StmtError();
6707 
6708  // Complete the switch statement.
6709  return getDerived().RebuildSwitchStmtBody(S->getSwitchLoc(), Switch.get(),
6710  Body.get());
6711 }
6712 
6713 template<typename Derived>
6714 StmtResult
6716  // Transform the condition
6717  Sema::ConditionResult Cond = getDerived().TransformCondition(
6718  S->getWhileLoc(), S->getConditionVariable(), S->getCond(),
6720  if (Cond.isInvalid())
6721  return StmtError();
6722 
6723  // Transform the body
6724  StmtResult Body = getDerived().TransformStmt(S->getBody());
6725  if (Body.isInvalid())
6726  return StmtError();
6727 
6728  if (!getDerived().AlwaysRebuild() &&
6729  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6730  Body.get() == S->getBody())
6731  return Owned(S);
6732 
6733  return getDerived().RebuildWhileStmt(S->getWhileLoc(), Cond, Body.get());
6734 }
6735 
6736 template<typename Derived>
6737 StmtResult
6739  // Transform the body
6740  StmtResult Body = getDerived().TransformStmt(S->getBody());
6741  if (Body.isInvalid())
6742  return StmtError();
6743 
6744  // Transform the condition
6745  ExprResult Cond = getDerived().TransformExpr(S->getCond());
6746  if (Cond.isInvalid())
6747  return StmtError();
6748 
6749  if (!getDerived().AlwaysRebuild() &&
6750  Cond.get() == S->getCond() &&
6751  Body.get() == S->getBody())
6752  return S;
6753 
6754  return getDerived().RebuildDoStmt(S->getDoLoc(), Body.get(), S->getWhileLoc(),
6755  /*FIXME:*/S->getWhileLoc(), Cond.get(),
6756  S->getRParenLoc());
6757 }
6758 
6759 template<typename Derived>
6760 StmtResult
6762  // Transform the initialization statement
6763  StmtResult Init = getDerived().TransformStmt(S->getInit());
6764  if (Init.isInvalid())
6765  return StmtError();
6766 
6767  // In OpenMP loop region loop control variable must be captured and be
6768  // private. Perform analysis of first part (if any).
6769  if (getSema().getLangOpts().OpenMP && Init.isUsable())
6770  getSema().ActOnOpenMPLoopInitialization(S->getForLoc(), Init.get());
6771 
6772  // Transform the condition
6773  Sema::ConditionResult Cond = getDerived().TransformCondition(
6774  S->getForLoc(), S->getConditionVariable(), S->getCond(),
6776  if (Cond.isInvalid())
6777  return StmtError();
6778 
6779  // Transform the increment
6780  ExprResult Inc = getDerived().TransformExpr(S->getInc());
6781  if (Inc.isInvalid())
6782  return StmtError();
6783 
6784  Sema::FullExprArg FullInc(getSema().MakeFullDiscardedValueExpr(Inc.get()));
6785  if (S->getInc() && !FullInc.get())
6786  return StmtError();
6787 
6788  // Transform the body
6789  StmtResult Body = getDerived().TransformStmt(S->getBody());
6790  if (Body.isInvalid())
6791  return StmtError();
6792 
6793  if (!getDerived().AlwaysRebuild() &&
6794  Init.get() == S->getInit() &&
6795  Cond.get() == std::make_pair(S->getConditionVariable(), S->getCond()) &&
6796  Inc.get() == S->getInc() &&
6797  Body.get() == S->getBody())
6798  return S;
6799 
6800  return getDerived().RebuildForStmt(S->getForLoc(), S->getLParenLoc(),
6801  Init.get(), Cond, FullInc,
6802  S->getRParenLoc(), Body.get());
6803 }
6804 
6805 template<typename Derived>
6806 StmtResult
6808  Decl *LD = getDerived().TransformDecl(S->getLabel()->getLocation(),
6809  S->getLabel());
6810  if (!LD)
6811  return StmtError();
6812 
6813  // Goto statements must always be rebuilt, to resolve the label.
6814  return getDerived().RebuildGotoStmt(S->getGotoLoc(), S->getLabelLoc(),
6815  cast<LabelDecl>(LD));
6816 }
6817 
6818 template<typename Derived>
6819 StmtResult
6821  ExprResult Target = getDerived().TransformExpr(S->getTarget());
6822  if (Target.isInvalid())
6823  return StmtError();
6824  Target = SemaRef.MaybeCreateExprWithCleanups(Target.get());
6825 
6826  if (!getDerived().AlwaysRebuild() &&
6827  Target.get() == S->getTarget())
6828  return S;
6829 
6830  return getDerived().RebuildIndirectGotoStmt(S->getGotoLoc(), S->getStarLoc(),
6831  Target.get());
6832 }
6833 
6834 template<typename Derived>
6835 StmtResult
6837  return S;
6838 }
6839 
6840 template<typename Derived>
6841 StmtResult
6843  return S;
6844 }
6845 
6846 template<typename Derived>
6847 StmtResult
6849  ExprResult Result = getDerived().TransformInitializer(S->getRetValue(),
6850  /*NotCopyInit*/false);
6851  if (Result.isInvalid())
6852  return StmtError();
6853 
6854  // FIXME: We always rebuild the return statement because there is no way
6855  // to tell whether the return type of the function has changed.
6856  return getDerived().RebuildReturnStmt(S->getReturnLoc(), Result.get());
6857 }
6858 
6859 template<typename Derived>
6860 StmtResult
6862  bool DeclChanged = false;
6863  SmallVector<Decl *, 4> Decls;
6864  for (auto *D : S->decls()) {
6865  Decl *Transformed = getDerived().TransformDefinition(D->getLocation(), D);
6866  if (!Transformed)
6867  return StmtError();
6868 
6869  if (Transformed != D)
6870  DeclChanged = true;
6871 
6872  Decls.push_back(Transformed);
6873  }
6874 
6875  if (!getDerived().AlwaysRebuild() && !DeclChanged)
6876  return S;
6877 
6878  return getDerived().RebuildDeclStmt(Decls, S->getStartLoc(), S->getEndLoc());
6879 }
6880 
6881 template<typename Derived>
6882 StmtResult
6884 
6885  SmallVector<Expr*, 8> Constraints;
6886  SmallVector<Expr*, 8> Exprs;
6888 
6889  ExprResult AsmString;
6890  SmallVector<Expr*, 8> Clobbers;
6891 
6892  bool ExprsChanged = false;
6893 
6894  // Go through the outputs.
6895  for (unsigned I = 0, E = S->getNumOutputs(); I != E; ++I) {
6896  Names.push_back(S->getOutputIdentifier(I));
6897 
6898  // No need to transform the constraint literal.
6899  Constraints.push_back(S->getOutputConstraintLiteral(I));
6900 
6901  // Transform the output expr.
6902  Expr *OutputExpr = S->getOutputExpr(I);
6903  ExprResult Result = getDerived().TransformExpr(OutputExpr);
6904  if (Result.isInvalid())
6905  return StmtError();
6906 
6907  ExprsChanged |= Result.get() != OutputExpr;
6908 
6909  Exprs.push_back(Result.get());
6910  }
6911 
6912  // Go through the inputs.
6913  for (unsigned I = 0, E = S->getNumInputs(); I != E; ++I) {
6914  Names.push_back(S->getInputIdentifier(I));
6915 
6916  // No need to transform the constraint literal.
6917  Constraints.push_back(S->getInputConstraintLiteral(I));
6918 
6919  // Transform the input expr.
6920  Expr *InputExpr = S->getInputExpr(I);
6921  ExprResult Result = getDerived().TransformExpr(InputExpr);
6922  if (Result.isInvalid())
6923  return StmtError();
6924 
6925  ExprsChanged |= Result.get() != InputExpr;
6926 
6927  Exprs.push_back(Result.get());
6928  }
6929 
6930  if (!getDerived().AlwaysRebuild() && !ExprsChanged)
6931  return S;
6932 
6933  // Go through the clobbers.
6934  for (unsigned I = 0, E = S->getNumClobbers(); I != E; ++I)
6935  Clobbers.push_back(S->getClobberStringLiteral(I));
6936 
6937  // No need to transform the asm string literal.
6938  AsmString = S->getAsmString();
6939  return getDerived().RebuildGCCAsmStmt(S->getAsmLoc(), S->isSimple(),
6940  S->isVolatile(), S->getNumOutputs(),
6941  S->getNumInputs(), Names.data(),
6942  Constraints, Exprs, AsmString.get(),
6943  Clobbers, S->getRParenLoc());
6944 }
6945 
6946 template<typename Derived>
6947 StmtResult
6949  ArrayRef<Token> AsmToks =
6950  llvm::makeArrayRef(S->getAsmToks(), S->getNumAsmToks());
6951 
6952  bool HadError = false, HadChange = false;
6953 
6954  ArrayRef<Expr*> SrcExprs = S->getAllExprs();
6955  SmallVector<Expr*, 8> TransformedExprs;
6956  TransformedExprs.reserve(SrcExprs.size());
6957  for (unsigned i = 0, e = SrcExprs.size(); i != e; ++i) {
6958  ExprResult Result = getDerived().TransformExpr(SrcExprs[i]);
6959  if (!Result.isUsable()) {
6960  HadError = true;
6961  } else {
6962  HadChange |= (Result.get() != SrcExprs[i]);
6963  TransformedExprs.push_back(Result.get());
6964  }
6965  }
6966 
6967  if (HadError) return StmtError();
6968  if (!HadChange && !getDerived().AlwaysRebuild())
6969  return Owned(S);
6970 
6971  return getDerived().RebuildMSAsmStmt(S->getAsmLoc(), S->getLBraceLoc(),
6972  AsmToks, S->getAsmString(),
6973  S->getNumOutputs(), S->getNumInputs(),
6974  S->getAllConstraints(), S->getClobbers(),
6975  TransformedExprs, S->getEndLoc());
6976 }
6977 
6978 // C++ Coroutines TS
6979 
6980 template<typename Derived>
6981 StmtResult
6983  auto *ScopeInfo = SemaRef.getCurFunction();
6984  auto *FD = cast<FunctionDecl>(SemaRef.CurContext);
6985  assert(FD && ScopeInfo && !ScopeInfo->CoroutinePromise &&
6986  ScopeInfo->NeedsCoroutineSuspends &&
6987  ScopeInfo->CoroutineSuspends.first == nullptr &&
6988  ScopeInfo->CoroutineSuspends.second == nullptr &&
6989  "expected clean scope info");
6990 
6991  // Set that we have (possibly-invalid) suspend points before we do anything
6992  // that may fail.
6993  ScopeInfo->setNeedsCoroutineSuspends(false);
6994 
6995  // The new CoroutinePromise object needs to be built and put into the current
6996  // FunctionScopeInfo before any transformations or rebuilding occurs.
6997  if (!SemaRef.buildCoroutineParameterMoves(FD->getLocation()))
6998  return StmtError();
6999  auto *Promise = SemaRef.buildCoroutinePromise(FD->getLocation());
7000  if (!Promise)
7001  return StmtError();
7002  getDerived().transformedLocalDecl(S->getPromiseDecl(), Promise);
7003  ScopeInfo->CoroutinePromise = Promise;
7004 
7005  // Transform the implicit coroutine statements we built during the initial
7006  // parse.
7007  StmtResult InitSuspend = getDerived().TransformStmt(S->getInitSuspendStmt());
7008  if (InitSuspend.isInvalid())
7009  return StmtError();
7010  StmtResult FinalSuspend =
7011  getDerived().TransformStmt(S->getFinalSuspendStmt());
7012  if (FinalSuspend.isInvalid())
7013  return StmtError();
7014  ScopeInfo->setCoroutineSuspends(InitSuspend.get(), FinalSuspend.get());
7015  assert(isa<Expr>(InitSuspend.get()) && isa<Expr>(FinalSuspend.get()));
7016 
7017  StmtResult BodyRes = getDerived().TransformStmt(S->getBody());
7018  if (BodyRes.isInvalid())
7019  return StmtError();
7020 
7021  CoroutineStmtBuilder Builder(SemaRef, *FD, *ScopeInfo, BodyRes.get());
7022  if (Builder.isInvalid())
7023  return StmtError();
7024 
7025  Expr *ReturnObject = S->getReturnValueInit();
7026  assert(ReturnObject && "the return object is expected to be valid");
7027  ExprResult Res = getDerived().TransformInitializer(ReturnObject,
7028  /*NoCopyInit*/ false);
7029  if (Res.isInvalid())
7030  return StmtError();
7031  Builder.ReturnValue = Res.get();
7032 
7033  if (S->hasDependentPromiseType()) {
7034  assert(!Promise->getType()->isDependentType() &&
7035  "the promise type must no longer be dependent");
7036  assert(!S->getFallthroughHandler() && !S->getExceptionHandler() &&
7037  !S->getReturnStmtOnAllocFailure() && !S->getDeallocate() &&
7038  "these nodes should not have been built yet");
7039  if (!Builder.buildDependentStatements())
7040  return StmtError();
7041  } else {
7042  if (auto *OnFallthrough = S->getFallthroughHandler()) {
7043  StmtResult Res = getDerived().TransformStmt(OnFallthrough);
7044  if (Res.isInvalid())
7045  return StmtError();
7046  Builder.OnFallthrough = Res.get();
7047  }
7048 
7049  if (auto *OnException = S->getExceptionHandler()) {
7050  StmtResult Res = getDerived().TransformStmt(OnException);
7051  if (Res.isInvalid())
7052  return StmtError();
7053  Builder.OnException = Res.get();
7054  }
7055 
7056  if (auto *OnAllocFailure = S->getReturnStmtOnAllocFailure()) {
7057  StmtResult Res = getDerived().TransformStmt(OnAllocFailure);
7058  if (Res.isInvalid())
7059  return StmtError();
7060  Builder.ReturnStmtOnAllocFailure = Res.get();
7061  }
7062 
7063  // Transform any additional statements we may have already built
7064  assert(S->getAllocate() && S->getDeallocate() &&
7065  "allocation and deallocation calls must already be built");
7066  ExprResult AllocRes = getDerived().TransformExpr(S->getAllocate());
7067  if (AllocRes.isInvalid())
7068  return StmtError();
7069  Builder.Allocate = AllocRes.get();
7070 
7071  ExprResult DeallocRes = getDerived().TransformExpr(S->getDeallocate());
7072  if (DeallocRes.isInvalid())
7073  return StmtError();
7074  Builder.Deallocate = DeallocRes.get();
7075 
7076  assert(S->getResultDecl() && "ResultDecl must already be built");
7077  StmtResult ResultDecl = getDerived().TransformStmt(S->getResultDecl());
7078  if (ResultDecl.isInvalid())
7079  return StmtError();
7080  Builder.ResultDecl = ResultDecl.get();
7081 
7082  if (auto *ReturnStmt = S->getReturnStmt()) {
7083  StmtResult Res = getDerived().TransformStmt(ReturnStmt);
7084  if (Res.isInvalid())
7085  return StmtError();
7086  Builder.ReturnStmt = Res.get();
7087  }
7088  }
7089 
7090  return getDerived().RebuildCoroutineBodyStmt(Builder);
7091 }
7092 
7093 template<typename Derived>
7094 StmtResult
7096  ExprResult Result = getDerived().TransformInitializer(S->getOperand(),
7097  /*NotCopyInit*/false);
7098  if (Result.isInvalid())
7099  return StmtError();
7100 
7101  // Always rebuild; we don't know if this needs to be injected into a new
7102  // context or if the promise type has changed.
7103  return getDerived().RebuildCoreturnStmt(S->getKeywordLoc(), Result.get(),
7104  S->isImplicit());
7105 }
7106 
7107 template<typename Derived>
7108 ExprResult
7110  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7111  /*NotCopyInit*/false);
7112  if (Result.isInvalid())
7113  return ExprError();
7114 
7115  // Always rebuild; we don't know if this needs to be injected into a new
7116  // context or if the promise type has changed.
7117  return getDerived().RebuildCoawaitExpr(E->getKeywordLoc(), Result.get(),
7118  E->isImplicit());
7119 }
7120 
7121 template <typename Derived>
7122 ExprResult
7124  ExprResult OperandResult = getDerived().TransformInitializer(E->getOperand(),
7125  /*NotCopyInit*/ false);
7126  if (OperandResult.isInvalid())
7127  return ExprError();
7128 
7129  ExprResult LookupResult = getDerived().TransformUnresolvedLookupExpr(
7131 
7132  if (LookupResult.isInvalid())
7133  return ExprError();
7134 
7135  // Always rebuild; we don't know if this needs to be injected into a new
7136  // context or if the promise type has changed.
7137  return getDerived().RebuildDependentCoawaitExpr(
7138  E->getKeywordLoc(), OperandResult.get(),
7139  cast<UnresolvedLookupExpr>(LookupResult.get()));
7140 }
7141 
7142 template<typename Derived>
7143 ExprResult
7145  ExprResult Result = getDerived().TransformInitializer(E->getOperand(),
7146  /*NotCopyInit*/false);
7147  if (Result.isInvalid())
7148  return ExprError();
7149 
7150  // Always rebuild; we don't know if this needs to be injected into a new
7151  // context or if the promise type has changed.
7152  return getDerived().RebuildCoyieldExpr(E->getKeywordLoc(), Result.get());
7153 }
7154 
7155 // Objective-C Statements.
7156 
7157 template<typename Derived>
7158 StmtResult
7160  // Transform the body of the @try.
7161  StmtResult TryBody = getDerived().TransformStmt(S->getTryBody());
7162  if (TryBody.isInvalid())
7163  return StmtError();
7164 
7165  // Transform the @catch statements (if present).
7166  bool AnyCatchChanged = false;
7167  SmallVector<Stmt*, 8> CatchStmts;
7168  for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I) {
7169  StmtResult Catch = getDerived().TransformStmt(S->getCatchStmt(I));
7170  if (Catch.isInvalid())
7171  return StmtError();
7172  if (Catch.get() != S->getCatchStmt(I))
7173  AnyCatchChanged = true;
7174  CatchStmts.push_back(Catch.get());
7175  }
7176 
7177  // Transform the @finally statement (if present).
7178  StmtResult Finally;
7179  if (S->getFinallyStmt()) {
7180  Finally = getDerived().TransformStmt(S->getFinallyStmt());
7181  if (Finally.isInvalid())
7182  return StmtError();
7183  }
7184 
7185  // If nothing changed, just retain this statement.
7186  if (!getDerived().AlwaysRebuild() &&
7187  TryBody.get() == S->getTryBody() &&
7188  !AnyCatchChanged &&
7189  Finally.get() == S->getFinallyStmt())
7190  return S;
7191 
7192  // Build a new statement.
7193  return getDerived().RebuildObjCAtTryStmt(S->getAtTryLoc(), TryBody.get(),
7194  CatchStmts, Finally.get());
7195 }
7196 
7197 template<typename Derived>
7198 StmtResult
7200  // Transform the @catch parameter, if there is one.
7201  VarDecl *Var = nullptr;
7202  if (VarDecl *FromVar = S->getCatchParamDecl()) {
7203  TypeSourceInfo *TSInfo = nullptr;
7204  if (FromVar->getTypeSourceInfo()) {
7205  TSInfo = getDerived().TransformType(FromVar->getTypeSourceInfo());
7206  if (!TSInfo)
7207  return StmtError();
7208  }
7209 
7210  QualType T;
7211  if (TSInfo)
7212  T = TSInfo->getType();
7213  else {
7214  T = getDerived().TransformType(FromVar->getType());
7215  if (T.isNull())
7216  return StmtError();
7217  }
7218 
7219  Var = getDerived().RebuildObjCExceptionDecl(FromVar, TSInfo, T);
7220  if (!Var)
7221  return StmtError();
7222  }
7223 
7224  StmtResult Body = getDerived().TransformStmt(S->getCatchBody());
7225  if (Body.isInvalid())
7226  return StmtError();
7227 
7228  return getDerived().RebuildObjCAtCatchStmt(S->getAtCatchLoc(),
7229  S->getRParenLoc(),
7230  Var, Body.get());
7231 }
7232 
7233 template<typename Derived>
7234 StmtResult
7236  // Transform the body.
7237  StmtResult Body = getDerived().TransformStmt(S->getFinallyBody());
7238  if (Body.isInvalid())
7239  return StmtError();
7240 
7241  // If nothing changed, just retain this statement.
7242  if (!getDerived().AlwaysRebuild() &&
7243  Body.get() == S->getFinallyBody())
7244  return S;
7245 
7246  // Build a new statement.
7247  return getDerived().RebuildObjCAtFinallyStmt(S->getAtFinallyLoc(),
7248  Body.get());
7249 }
7250 
7251 template<typename Derived>
7252 StmtResult
7254  ExprResult Operand;
7255  if (S->getThrowExpr()) {
7256  Operand = getDerived().TransformExpr(S->getThrowExpr());
7257  if (Operand.isInvalid())
7258  return StmtError();
7259  }
7260 
7261  if (!getDerived().AlwaysRebuild() &&
7262  Operand.get() == S->getThrowExpr())
7263  return S;
7264 
7265  return getDerived().RebuildObjCAtThrowStmt(S->getThrowLoc(), Operand.get());
7266 }
7267 
7268 template<typename Derived>
7269 StmtResult
7272  // Transform the object we are locking.
7273  ExprResult Object = getDerived().TransformExpr(S->getSynchExpr());
7274  if (Object.isInvalid())
7275  return StmtError();
7276  Object =
7277  getDerived().RebuildObjCAtSynchronizedOperand(S->getAtSynchronizedLoc(),
7278  Object.get());
7279  if (Object.isInvalid())
7280  return StmtError();
7281 
7282  // Transform the body.
7283  StmtResult Body = getDerived().TransformStmt(S->getSynchBody());
7284  if (Body.isInvalid())
7285  return StmtError();
7286 
7287  // If nothing change, just retain the current statement.
7288  if (!getDerived().AlwaysRebuild() &&
7289  Object.get() == S->getSynchExpr() &&
7290  Body.get() == S->getSynchBody())
7291  return S;
7292 
7293  // Build a new statement.
7294  return getDerived().RebuildObjCAtSynchronizedStmt(S->getAtSynchronizedLoc(),
7295  Object.get(), Body.get());
7296 }
7297 
7298 template<typename Derived>
7299 StmtResult
7302  // Transform the body.
7303  StmtResult Body = getDerived().TransformStmt(S->getSubStmt());
7304  if (Body.isInvalid())
7305  return StmtError();
7306 
7307  // If nothing changed, just retain this statement.
7308  if (!getDerived().AlwaysRebuild() &&
7309  Body.get() == S->getSubStmt())
7310  return S;
7311 
7312  // Build a new statement.
7313  return getDerived().RebuildObjCAutoreleasePoolStmt(
7314  S->getAtLoc(), Body.get());
7315 }
7316 
7317 template<typename Derived>
7318 StmtResult
7320  ObjCForCollectionStmt *S) {
7321  // Transform the element statement.
7322  StmtResult Element = getDerived().TransformStmt(S->getElement());
7323  if (Element.isInvalid())
7324  return StmtError();
7325 
7326  // Transform the collection expression.
7327  ExprResult Collection = getDerived().TransformExpr(S->getCollection());
7328  if (Collection.isInvalid())
7329  return StmtError();
7330 
7331  // Transform the body.
7332  StmtResult Body = getDerived().TransformStmt(S->getBody());
7333  if (Body.isInvalid())
7334  return StmtError();
7335 
7336  // If nothing changed, just retain this statement.
7337  if (!getDerived().AlwaysRebuild() &&
7338  Element.get() == S->getElement() &&
7339  Collection.get() == S->getCollection() &&
7340  Body.get() == S->getBody())
7341  return S;
7342 
7343  // Build a new statement.
7344  return getDerived().RebuildObjCForCollectionStmt(S->getForLoc(),
7345  Element.get(),
7346  Collection.get(),
7347  S->getRParenLoc(),
7348  Body.get());
7349 }
7350 
7351 template <typename Derived>
7353  // Transform the exception declaration, if any.
7354  VarDecl *Var = nullptr;
7355  if (VarDecl *ExceptionDecl = S->getExceptionDecl()) {
7356  TypeSourceInfo *T =
7357  getDerived().TransformType(ExceptionDecl->getTypeSourceInfo());
7358  if (!T)
7359  return StmtError();
7360 
7361  Var = getDerived().RebuildExceptionDecl(
7362  ExceptionDecl, T, ExceptionDecl->getInnerLocStart(),
7363  ExceptionDecl->getLocation(), ExceptionDecl->getIdentifier());
7364  if (!Var || Var->isInvalidDecl())
7365  return StmtError();
7366  }
7367 
7368  // Transform the actual exception handler.
7369  StmtResult Handler = getDerived().TransformStmt(S->getHandlerBlock());
7370  if (Handler.isInvalid())
7371  return StmtError();
7372 
7373  if (!getDerived().AlwaysRebuild() && !Var &&
7374  Handler.get() == S->getHandlerBlock())
7375  return S;
7376 
7377  return getDerived().RebuildCXXCatchStmt(S->getCatchLoc(), Var, Handler.get());
7378 }
7379 
7380 template <typename Derived>
7382  // Transform the try block itself.
7383  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7384  if (TryBlock.isInvalid())
7385  return StmtError();
7386 
7387  // Transform the handlers.
7388  bool HandlerChanged = false;
7389  SmallVector<Stmt *, 8> Handlers;
7390  for (unsigned I = 0, N = S->getNumHandlers(); I != N; ++I) {
7391  StmtResult Handler = getDerived().TransformCXXCatchStmt(S->getHandler(I));
7392  if (Handler.isInvalid())
7393  return StmtError();
7394 
7395  HandlerChanged = HandlerChanged || Handler.get() != S->getHandler(I);
7396  Handlers.push_back(Handler.getAs<Stmt>());
7397  }
7398 
7399  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7400  !HandlerChanged)
7401  return S;
7402 
7403  return getDerived().RebuildCXXTryStmt(S->getTryLoc(), TryBlock.get(),
7404  Handlers);
7405 }
7406 
7407 template<typename Derived>
7408 StmtResult
7410  StmtResult Range = getDerived().TransformStmt(S->getRangeStmt());
7411  if (Range.isInvalid())
7412  return StmtError();
7413 
7414  StmtResult Begin = getDerived().TransformStmt(S->getBeginStmt());
7415  if (Begin.isInvalid())
7416  return StmtError();
7417  StmtResult End = getDerived().TransformStmt(S->getEndStmt());
7418  if (End.isInvalid())
7419  return StmtError();
7420 
7421  ExprResult Cond = getDerived().TransformExpr(S->getCond());
7422  if (Cond.isInvalid())
7423  return StmtError();
7424  if (Cond.get())
7425  Cond = SemaRef.CheckBooleanCondition(S->getColonLoc(), Cond.get());
7426  if (Cond.isInvalid())
7427  return StmtError();
7428  if (Cond.get())
7429  Cond = SemaRef.MaybeCreateExprWithCleanups(Cond.get());
7430 
7431  ExprResult Inc = getDerived().TransformExpr(S->getInc());
7432  if (Inc.isInvalid())
7433  return StmtError();
7434  if (Inc.get())
7435  Inc = SemaRef.MaybeCreateExprWithCleanups(Inc.get());
7436 
7437  StmtResult LoopVar = getDerived().TransformStmt(S->getLoopVarStmt());
7438  if (LoopVar.isInvalid())
7439  return StmtError();
7440 
7441  StmtResult NewStmt = S;
7442  if (getDerived().AlwaysRebuild() ||
7443  Range.get() != S->getRangeStmt() ||
7444  Begin.get() != S->getBeginStmt() ||
7445  End.get() != S->getEndStmt() ||
7446  Cond.get() != S->getCond() ||
7447  Inc.get() != S->getInc() ||
7448  LoopVar.get() != S->getLoopVarStmt()) {
7449  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7450  S->getCoawaitLoc(),
7451  S->getColonLoc(), Range.get(),
7452  Begin.get(), End.get(),
7453  Cond.get(),
7454  Inc.get(), LoopVar.get(),
7455  S->getRParenLoc());
7456  if (NewStmt.isInvalid())
7457  return StmtError();
7458  }
7459 
7460  StmtResult Body = getDerived().TransformStmt(S->getBody());
7461  if (Body.isInvalid())
7462  return StmtError();
7463 
7464  // Body has changed but we didn't rebuild the for-range statement. Rebuild
7465  // it now so we have a new statement to attach the body to.
7466  if (Body.get() != S->getBody() && NewStmt.get() == S) {
7467  NewStmt = getDerived().RebuildCXXForRangeStmt(S->getForLoc(),
7468  S->getCoawaitLoc(),
7469  S->getColonLoc(), Range.get(),
7470  Begin.get(), End.get(),
7471  Cond.get(),
7472  Inc.get(), LoopVar.get(),
7473  S->getRParenLoc());
7474  if (NewStmt.isInvalid())
7475  return StmtError();
7476  }
7477 
7478  if (NewStmt.get() == S)
7479  return S;
7480 
7481  return FinishCXXForRangeStmt(NewStmt.get(), Body.get());
7482 }
7483 
7484 template<typename Derived>
7485 StmtResult
7487  MSDependentExistsStmt *S) {
7488  // Transform the nested-name-specifier, if any.
7489  NestedNameSpecifierLoc QualifierLoc;
7490  if (S->getQualifierLoc()) {
7491  QualifierLoc
7492  = getDerived().TransformNestedNameSpecifierLoc(S->getQualifierLoc());
7493  if (!QualifierLoc)
7494  return StmtError();
7495  }
7496 
7497  // Transform the declaration name.
7498  DeclarationNameInfo NameInfo = S->getNameInfo();
7499  if (NameInfo.getName()) {
7500  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
7501  if (!NameInfo.getName())
7502  return StmtError();
7503  }
7504 
7505  // Check whether anything changed.
7506  if (!getDerived().AlwaysRebuild() &&
7507  QualifierLoc == S->getQualifierLoc() &&
7508  NameInfo.getName() == S->getNameInfo().getName())
7509  return S;
7510 
7511  // Determine whether this name exists, if we can.
7512  CXXScopeSpec SS;
7513  SS.Adopt(QualifierLoc);
7514  bool Dependent = false;
7515  switch (getSema().CheckMicrosoftIfExistsSymbol(/*S=*/nullptr, SS, NameInfo)) {
7516  case Sema::IER_Exists:
7517  if (S->isIfExists())
7518  break;
7519 
7520  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7521 
7523  if (S->isIfNotExists())
7524  break;
7525 
7526  return new (getSema().Context) NullStmt(S->getKeywordLoc());
7527 
7528  case Sema::IER_Dependent:
7529  Dependent = true;
7530  break;
7531 
7532  case Sema::IER_Error:
7533  return StmtError();
7534  }
7535 
7536  // We need to continue with the instantiation, so do so now.
7537  StmtResult SubStmt = getDerived().TransformCompoundStmt(S->getSubStmt());
7538  if (SubStmt.isInvalid())
7539  return StmtError();
7540 
7541  // If we have resolved the name, just transform to the substatement.
7542  if (!Dependent)
7543  return SubStmt;
7544 
7545  // The name is still dependent, so build a dependent expression again.
7546  return getDerived().RebuildMSDependentExistsStmt(S->getKeywordLoc(),
7547  S->isIfExists(),
7548  QualifierLoc,
7549  NameInfo,
7550  SubStmt.get());
7551 }
7552 
7553 template<typename Derived>
7554 ExprResult
7556  NestedNameSpecifierLoc QualifierLoc;
7557  if (E->getQualifierLoc()) {
7558  QualifierLoc
7559  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
7560  if (!QualifierLoc)
7561  return ExprError();
7562  }
7563 
7564  MSPropertyDecl *PD = cast_or_null<MSPropertyDecl>(
7565  getDerived().TransformDecl(E->getMemberLoc(), E->getPropertyDecl()));
7566  if (!PD)
7567  return ExprError();
7568 
7569  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
7570  if (Base.isInvalid())
7571  return ExprError();
7572 
7573  return new (SemaRef.getASTContext())
7574  MSPropertyRefExpr(Base.get(), PD, E->isArrow(),
7575  SemaRef.getASTContext().PseudoObjectTy, VK_LValue,
7576  QualifierLoc, E->getMemberLoc());
7577 }
7578 
7579 template <typename Derived>
7582  auto BaseRes = getDerived().TransformExpr(E->getBase());
7583  if (BaseRes.isInvalid())
7584  return ExprError();
7585  auto IdxRes = getDerived().TransformExpr(E->getIdx());
7586  if (IdxRes.isInvalid())
7587  return ExprError();
7588 
7589  if (!getDerived().AlwaysRebuild() &&
7590  BaseRes.get() == E->getBase() &&
7591  IdxRes.get() == E->getIdx())
7592  return E;
7593 
7594  return getDerived().RebuildArraySubscriptExpr(
7595  BaseRes.get(), SourceLocation(), IdxRes.get(), E->getRBracketLoc());
7596 }
7597 
7598 template <typename Derived>
7600  StmtResult TryBlock = getDerived().TransformCompoundStmt(S->getTryBlock());
7601  if (TryBlock.isInvalid())
7602  return StmtError();
7603 
7604  StmtResult Handler = getDerived().TransformSEHHandler(S->getHandler());
7605  if (Handler.isInvalid())
7606  return StmtError();
7607 
7608  if (!getDerived().AlwaysRebuild() && TryBlock.get() == S->getTryBlock() &&
7609  Handler.get() == S->getHandler())
7610  return S;
7611 
7612  return getDerived().RebuildSEHTryStmt(S->getIsCXXTry(), S->getTryLoc(),
7613  TryBlock.get(), Handler.get());
7614 }
7615 
7616 template <typename Derived>
7618  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7619  if (Block.isInvalid())
7620  return StmtError();
7621 
7622  return getDerived().RebuildSEHFinallyStmt(S->getFinallyLoc(), Block.get());
7623 }
7624 
7625 template <typename Derived>
7627  ExprResult FilterExpr = getDerived().TransformExpr(S->getFilterExpr());
7628  if (FilterExpr.isInvalid())
7629  return StmtError();
7630 
7631  StmtResult Block = getDerived().TransformCompoundStmt(S->getBlock());
7632  if (Block.isInvalid())
7633  return StmtError();
7634 
7635  return getDerived().RebuildSEHExceptStmt(S->getExceptLoc(), FilterExpr.get(),
7636  Block.get());
7637 }
7638 
7639 template <typename Derived>
7641  if (isa<SEHFinallyStmt>(Handler))
7642  return getDerived().TransformSEHFinallyStmt(cast<SEHFinallyStmt>(Handler));
7643  else
7644  return getDerived().TransformSEHExceptStmt(cast<SEHExceptStmt>(Handler));
7645 }
7646 
7647 template<typename Derived>
7648 StmtResult
7650  return S;
7651 }
7652 
7653 //===----------------------------------------------------------------------===//
7654 // OpenMP directive transformation
7655 //===----------------------------------------------------------------------===//
7656 template <typename Derived>
7659 
7660  // Transform the clauses
7662  ArrayRef<OMPClause *> Clauses = D->clauses();
7663  TClauses.reserve(Clauses.size());
7664  for (ArrayRef<OMPClause *>::iterator I = Clauses.begin(), E = Clauses.end();
7665  I != E; ++I) {
7666  if (*I) {
7667  getDerived().getSema().StartOpenMPClause((*I)->getClauseKind());
7668  OMPClause *Clause = getDerived().TransformOMPClause(*I);
7669  getDerived().getSema().EndOpenMPClause();
7670  if (Clause)
7671  TClauses.push_back(Clause);
7672  } else {
7673  TClauses.push_back(nullptr);
7674  }
7675  }
7676  StmtResult AssociatedStmt;
7677  if (D->hasAssociatedStmt() && D->getAssociatedStmt()) {
7678  getDerived().getSema().ActOnOpenMPRegionStart(D->getDirectiveKind(),
7679  /*CurScope=*/nullptr);
7680  StmtResult Body;
7681  {
7682  Sema::CompoundScopeRAII CompoundScope(getSema());
7684  Body = getDerived().TransformStmt(CS);
7685  }
7686  AssociatedStmt =
7687  getDerived().getSema().ActOnOpenMPRegionEnd(Body, TClauses);
7688  if (AssociatedStmt.isInvalid()) {
7689  return StmtError();
7690  }
7691  }
7692  if (TClauses.size() != Clauses.size()) {
7693  return StmtError();
7694  }
7695 
7696  // Transform directive name for 'omp critical' directive.
7697  DeclarationNameInfo DirName;
7698  if (D->getDirectiveKind() == OMPD_critical) {
7699  DirName = cast<OMPCriticalDirective>(D)->getDirectiveName();
7700  DirName = getDerived().TransformDeclarationNameInfo(DirName);
7701  }
7702  OpenMPDirectiveKind CancelRegion = OMPD_unknown;
7703  if (D->getDirectiveKind() == OMPD_cancellation_point) {
7704  CancelRegion = cast<OMPCancellationPointDirective>(D)->getCancelRegion();
7705  } else if (D->getDirectiveKind() == OMPD_cancel) {
7706  CancelRegion = cast<OMPCancelDirective>(D)->getCancelRegion();
7707  }
7708 
7709  return getDerived().RebuildOMPExecutableDirective(
7710  D->getDirectiveKind(), DirName, CancelRegion, TClauses,
7711  AssociatedStmt.get(), D->getLocStart(), D->getLocEnd());
7712 }
7713 
7714 template <typename Derived>
7715 StmtResult
7717  DeclarationNameInfo DirName;
7718  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel, DirName, nullptr,
7719  D->getLocStart());
7720  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7721  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7722  return Res;
7723 }
7724 
7725 template <typename Derived>
7726 StmtResult
7728  DeclarationNameInfo DirName;
7729  getDerived().getSema().StartOpenMPDSABlock(OMPD_simd, DirName, nullptr,
7730  D->getLocStart());
7731  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7732  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7733  return Res;
7734 }
7735 
7736 template <typename Derived>
7737 StmtResult
7739  DeclarationNameInfo DirName;
7740  getDerived().getSema().StartOpenMPDSABlock(OMPD_for, DirName, nullptr,
7741  D->getLocStart());
7742  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7743  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7744  return Res;
7745 }
7746 
7747 template <typename Derived>
7748 StmtResult
7750  DeclarationNameInfo DirName;
7751  getDerived().getSema().StartOpenMPDSABlock(OMPD_for_simd, DirName, nullptr,
7752  D->getLocStart());
7753  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7754  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7755  return Res;
7756 }
7757 
7758 template <typename Derived>
7759 StmtResult
7761  DeclarationNameInfo DirName;
7762  getDerived().getSema().StartOpenMPDSABlock(OMPD_sections, DirName, nullptr,
7763  D->getLocStart());
7764  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7765  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7766  return Res;
7767 }
7768 
7769 template <typename Derived>
7770 StmtResult
7772  DeclarationNameInfo DirName;
7773  getDerived().getSema().StartOpenMPDSABlock(OMPD_section, DirName, nullptr,
7774  D->getLocStart());
7775  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7776  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7777  return Res;
7778 }
7779 
7780 template <typename Derived>
7781 StmtResult
7783  DeclarationNameInfo DirName;
7784  getDerived().getSema().StartOpenMPDSABlock(OMPD_single, DirName, nullptr,
7785  D->getLocStart());
7786  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7787  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7788  return Res;
7789 }
7790 
7791 template <typename Derived>
7792 StmtResult
7794  DeclarationNameInfo DirName;
7795  getDerived().getSema().StartOpenMPDSABlock(OMPD_master, DirName, nullptr,
7796  D->getLocStart());
7797  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7798  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7799  return Res;
7800 }
7801 
7802 template <typename Derived>
7803 StmtResult
7805  getDerived().getSema().StartOpenMPDSABlock(
7806  OMPD_critical, D->getDirectiveName(), nullptr, D->getLocStart());
7807  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7808  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7809  return Res;
7810 }
7811 
7812 template <typename Derived>
7815  DeclarationNameInfo DirName;
7816  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for, DirName,
7817  nullptr, D->getLocStart());
7818  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7819  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7820  return Res;
7821 }
7822 
7823 template <typename Derived>
7826  DeclarationNameInfo DirName;
7827  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_for_simd, DirName,
7828  nullptr, D->getLocStart());
7829  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7830  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7831  return Res;
7832 }
7833 
7834 template <typename Derived>
7837  DeclarationNameInfo DirName;
7838  getDerived().getSema().StartOpenMPDSABlock(OMPD_parallel_sections, DirName,
7839  nullptr, D->getLocStart());
7840  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7841  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7842  return Res;
7843 }
7844 
7845 template <typename Derived>
7846 StmtResult
7848  DeclarationNameInfo DirName;
7849  getDerived().getSema().StartOpenMPDSABlock(OMPD_task, DirName, nullptr,
7850  D->getLocStart());
7851  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7852  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7853  return Res;
7854 }
7855 
7856 template <typename Derived>
7858  OMPTaskyieldDirective *D) {
7859  DeclarationNameInfo DirName;
7860  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskyield, DirName, nullptr,
7861  D->getLocStart());
7862  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7863  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7864  return Res;
7865 }
7866 
7867 template <typename Derived>
7868 StmtResult
7870  DeclarationNameInfo DirName;
7871  getDerived().getSema().StartOpenMPDSABlock(OMPD_barrier, DirName, nullptr,
7872  D->getLocStart());
7873  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7874  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7875  return Res;
7876 }
7877 
7878 template <typename Derived>
7879 StmtResult
7881  DeclarationNameInfo DirName;
7882  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskwait, DirName, nullptr,
7883  D->getLocStart());
7884  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7885  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7886  return Res;
7887 }
7888 
7889 template <typename Derived>
7891  OMPTaskgroupDirective *D) {
7892  DeclarationNameInfo DirName;
7893  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskgroup, DirName, nullptr,
7894  D->getLocStart());
7895  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7896  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7897  return Res;
7898 }
7899 
7900 template <typename Derived>
7901 StmtResult
7903  DeclarationNameInfo DirName;
7904  getDerived().getSema().StartOpenMPDSABlock(OMPD_flush, DirName, nullptr,
7905  D->getLocStart());
7906  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7907  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7908  return Res;
7909 }
7910 
7911 template <typename Derived>
7912 StmtResult
7914  DeclarationNameInfo DirName;
7915  getDerived().getSema().StartOpenMPDSABlock(OMPD_ordered, DirName, nullptr,
7916  D->getLocStart());
7917  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7918  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7919  return Res;
7920 }
7921 
7922 template <typename Derived>
7923 StmtResult
7925  DeclarationNameInfo DirName;
7926  getDerived().getSema().StartOpenMPDSABlock(OMPD_atomic, DirName, nullptr,
7927  D->getLocStart());
7928  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7929  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7930  return Res;
7931 }
7932 
7933 template <typename Derived>
7934 StmtResult
7936  DeclarationNameInfo DirName;
7937  getDerived().getSema().StartOpenMPDSABlock(OMPD_target, DirName, nullptr,
7938  D->getLocStart());
7939  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7940  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7941  return Res;
7942 }
7943 
7944 template <typename Derived>
7947  DeclarationNameInfo DirName;
7948  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_data, DirName, nullptr,
7949  D->getLocStart());
7950  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7951  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7952  return Res;
7953 }
7954 
7955 template <typename Derived>
7958  DeclarationNameInfo DirName;
7959  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_enter_data, DirName,
7960  nullptr, D->getLocStart());
7961  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7962  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7963  return Res;
7964 }
7965 
7966 template <typename Derived>
7969  DeclarationNameInfo DirName;
7970  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_exit_data, DirName,
7971  nullptr, D->getLocStart());
7972  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7973  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7974  return Res;
7975 }
7976 
7977 template <typename Derived>
7980  DeclarationNameInfo DirName;
7981  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel, DirName,
7982  nullptr, D->getLocStart());
7983  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7984  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7985  return Res;
7986 }
7987 
7988 template <typename Derived>
7991  DeclarationNameInfo DirName;
7992  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_parallel_for, DirName,
7993  nullptr, D->getLocStart());
7994  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
7995  getDerived().getSema().EndOpenMPDSABlock(Res.get());
7996  return Res;
7997 }
7998 
7999 template <typename Derived>
8002  DeclarationNameInfo DirName;
8003  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_update, DirName,
8004  nullptr, D->getLocStart());
8005  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8006  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8007  return Res;
8008 }
8009 
8010 template <typename Derived>
8011 StmtResult
8013  DeclarationNameInfo DirName;
8014  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams, DirName, nullptr,
8015  D->getLocStart());
8016  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8017  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8018  return Res;
8019 }
8020 
8021 template <typename Derived>
8024  DeclarationNameInfo DirName;
8025  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancellation_point, DirName,
8026  nullptr, D->getLocStart());
8027  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8028  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8029  return Res;
8030 }
8031 
8032 template <typename Derived>
8033 StmtResult
8035  DeclarationNameInfo DirName;
8036  getDerived().getSema().StartOpenMPDSABlock(OMPD_cancel, DirName, nullptr,
8037  D->getLocStart());
8038  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8039  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8040  return Res;
8041 }
8042 
8043 template <typename Derived>
8044 StmtResult
8046  DeclarationNameInfo DirName;
8047  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop, DirName, nullptr,
8048  D->getLocStart());
8049  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8050  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8051  return Res;
8052 }
8053 
8054 template <typename Derived>
8057  DeclarationNameInfo DirName;
8058  getDerived().getSema().StartOpenMPDSABlock(OMPD_taskloop_simd, DirName,
8059  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, DirName, nullptr,
8070  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(
8081  OMPD_distribute_parallel_for, DirName, nullptr, D->getLocStart());
8082  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8083  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8084  return Res;
8085 }
8086 
8087 template <typename Derived>
8088 StmtResult
8091  DeclarationNameInfo DirName;
8092  getDerived().getSema().StartOpenMPDSABlock(
8093  OMPD_distribute_parallel_for_simd, DirName, nullptr, 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_distribute_simd, 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(OMPD_target_parallel_for_simd,
8115  DirName, nullptr,
8116  D->getLocStart());
8117  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8118  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8119  return Res;
8120 }
8121 
8122 template <typename Derived>
8125  DeclarationNameInfo DirName;
8126  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_simd, DirName, nullptr,
8127  D->getLocStart());
8128  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8129  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8130  return Res;
8131 }
8132 
8133 template <typename Derived>
8136  DeclarationNameInfo DirName;
8137  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams_distribute, DirName,
8138  nullptr, D->getLocStart());
8139  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8140  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8141  return Res;
8142 }
8143 
8144 template <typename Derived>
8147  DeclarationNameInfo DirName;
8148  getDerived().getSema().StartOpenMPDSABlock(
8149  OMPD_teams_distribute_simd, DirName, nullptr, D->getLocStart());
8150  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8151  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8152  return Res;
8153 }
8154 
8155 template <typename Derived>
8158  DeclarationNameInfo DirName;
8159  getDerived().getSema().StartOpenMPDSABlock(
8160  OMPD_teams_distribute_parallel_for_simd, DirName, nullptr, D->getLocStart());
8161  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8162  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8163  return Res;
8164 }
8165 
8166 template <typename Derived>
8169  DeclarationNameInfo DirName;
8170  getDerived().getSema().StartOpenMPDSABlock(OMPD_teams_distribute_parallel_for,
8171  DirName, nullptr, D->getLocStart());
8172  StmtResult Res = getDerived().TransformOMPExecutableDirective(D);
8173  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8174  return Res;
8175 }
8176 
8177 template <typename Derived>
8180  DeclarationNameInfo DirName;
8181  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams, DirName,
8182  nullptr, D->getLocStart());
8183  auto Res = getDerived().TransformOMPExecutableDirective(D);
8184  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8185  return Res;
8186 }
8187 
8188 template <typename Derived>
8191  DeclarationNameInfo DirName;
8192  getDerived().getSema().StartOpenMPDSABlock(OMPD_target_teams_distribute,
8193  DirName, nullptr, D->getLocStart());
8194  auto Res = getDerived().TransformOMPExecutableDirective(D);
8195  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8196  return Res;
8197 }
8198 
8199 template <typename Derived>
8200 StmtResult
8203  DeclarationNameInfo DirName;
8204  getDerived().getSema().StartOpenMPDSABlock(
8205  OMPD_target_teams_distribute_parallel_for, DirName, nullptr,
8206  D->getLocStart());
8207  auto Res = getDerived().TransformOMPExecutableDirective(D);
8208  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8209  return Res;
8210 }
8211 
8212 template <typename Derived>
8216  DeclarationNameInfo DirName;
8217  getDerived().getSema().StartOpenMPDSABlock(
8218  OMPD_target_teams_distribute_parallel_for_simd, DirName, nullptr,
8219  D->getLocStart());
8220  auto Res = getDerived().TransformOMPExecutableDirective(D);
8221  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8222  return Res;
8223 }
8224 
8225 template <typename Derived>
8226 StmtResult
8229  DeclarationNameInfo DirName;
8230  getDerived().getSema().StartOpenMPDSABlock(
8231  OMPD_target_teams_distribute_simd, DirName, nullptr, D->getLocStart());
8232  auto Res = getDerived().TransformOMPExecutableDirective(D);
8233  getDerived().getSema().EndOpenMPDSABlock(Res.get());
8234  return Res;
8235 }
8236 
8237 
8238 //===----------------------------------------------------------------------===//
8239 // OpenMP clause transformation
8240 //===----------------------------------------------------------------------===//
8241 template <typename Derived>
8243  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8244  if (Cond.isInvalid())
8245  return nullptr;
8246  return getDerived().RebuildOMPIfClause(
8247  C->getNameModifier(), Cond.get(), C->getLocStart(), C->getLParenLoc(),
8248  C->getNameModifierLoc(), C->getColonLoc(), C->getLocEnd());
8249 }
8250 
8251 template <typename Derived>
8253  ExprResult Cond = getDerived().TransformExpr(C->getCondition());
8254  if (Cond.isInvalid())
8255  return nullptr;
8256  return getDerived().RebuildOMPFinalClause(Cond.get(), C->getLocStart(),
8257  C->getLParenLoc(), C->getLocEnd());
8258 }
8259 
8260 template <typename Derived>
8261 OMPClause *
8263  ExprResult NumThreads = getDerived().TransformExpr(C->getNumThreads());
8264  if (NumThreads.isInvalid())
8265  return nullptr;
8266  return getDerived().RebuildOMPNumThreadsClause(
8267  NumThreads.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8268 }
8269 
8270 template <typename Derived>
8271 OMPClause *
8273  ExprResult E = getDerived().TransformExpr(C->getSafelen());
8274  if (E.isInvalid())
8275  return nullptr;
8276  return getDerived().RebuildOMPSafelenClause(
8277  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8278 }
8279 
8280 template <typename Derived>
8281 OMPClause *
8283  ExprResult E = getDerived().TransformExpr(C->getSimdlen());
8284  if (E.isInvalid())
8285  return nullptr;
8286  return getDerived().RebuildOMPSimdlenClause(
8287  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8288 }
8289 
8290 template <typename Derived>
8291 OMPClause *
8293  ExprResult E = getDerived().TransformExpr(C->getNumForLoops());
8294  if (E.isInvalid())
8295  return nullptr;
8296  return getDerived().RebuildOMPCollapseClause(
8297  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8298 }
8299 
8300 template <typename Derived>
8301 OMPClause *
8303  return getDerived().RebuildOMPDefaultClause(
8305  C->getLParenLoc(), C->getLocEnd());
8306 }
8307 
8308 template <typename Derived>
8309 OMPClause *
8311  return getDerived().RebuildOMPProcBindClause(
8313  C->getLParenLoc(), C->getLocEnd());
8314 }
8315 
8316 template <typename Derived>
8317 OMPClause *
8319  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
8320  if (E.isInvalid())
8321  return nullptr;
8322  return getDerived().RebuildOMPScheduleClause(
8324  C->getScheduleKind(), E.get(), C->getLocStart(), C->getLParenLoc(),
8326  C->getScheduleKindLoc(), C->getCommaLoc(), C->getLocEnd());
8327 }
8328 
8329 template <typename Derived>
8330 OMPClause *
8332  ExprResult E;
8333  if (auto *Num = C->getNumForLoops()) {
8334  E = getDerived().TransformExpr(Num);
8335  if (E.isInvalid())
8336  return nullptr;
8337  }
8338  return getDerived().RebuildOMPOrderedClause(C->getLocStart(), C->getLocEnd(),
8339  C->getLParenLoc(), E.get());
8340 }
8341 
8342 template <typename Derived>
8343 OMPClause *
8345  // No need to rebuild this clause, no template-dependent parameters.
8346  return C;
8347 }
8348 
8349 template <typename Derived>
8350 OMPClause *
8352  // No need to rebuild this clause, no template-dependent parameters.
8353  return C;
8354 }
8355 
8356 template <typename Derived>
8357 OMPClause *
8359  // No need to rebuild this clause, no template-dependent parameters.
8360  return C;
8361 }
8362 
8363 template <typename Derived>
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 *
8385  // No need to rebuild this clause, no template-dependent parameters.
8386  return C;
8387 }
8388 
8389 template <typename Derived>
8390 OMPClause *
8392  // No need to rebuild this clause, no template-dependent parameters.
8393  return C;
8394 }
8395 
8396 template <typename Derived>
8397 OMPClause *
8399  // No need to rebuild this clause, no template-dependent parameters.
8400  return C;
8401 }
8402 
8403 template <typename Derived>
8405  // No need to rebuild this clause, no template-dependent parameters.
8406  return C;
8407 }
8408 
8409 template <typename Derived>
8410 OMPClause *
8412  // No need to rebuild this clause, no template-dependent parameters.
8413  return C;
8414 }
8415 
8416 template <typename Derived>
8417 OMPClause *
8420  Vars.reserve(C->varlist_size());
8421  for (auto *VE : C->varlists()) {
8422  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8423  if (EVar.isInvalid())
8424  return nullptr;
8425  Vars.push_back(EVar.get());
8426  }
8427  return getDerived().RebuildOMPPrivateClause(
8428  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8429 }
8430 
8431 template <typename Derived>
8433  OMPFirstprivateClause *C) {
8435  Vars.reserve(C->varlist_size());
8436  for (auto *VE : C->varlists()) {
8437  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8438  if (EVar.isInvalid())
8439  return nullptr;
8440  Vars.push_back(EVar.get());
8441  }
8442  return getDerived().RebuildOMPFirstprivateClause(
8443  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8444 }
8445 
8446 template <typename Derived>
8447 OMPClause *
8450  Vars.reserve(C->varlist_size());
8451  for (auto *VE : C->varlists()) {
8452  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8453  if (EVar.isInvalid())
8454  return nullptr;
8455  Vars.push_back(EVar.get());
8456  }
8457  return getDerived().RebuildOMPLastprivateClause(
8458  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8459 }
8460 
8461 template <typename Derived>
8462 OMPClause *
8465  Vars.reserve(C->varlist_size());
8466  for (auto *VE : C->varlists()) {
8467  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8468  if (EVar.isInvalid())
8469  return nullptr;
8470  Vars.push_back(EVar.get());
8471  }
8472  return getDerived().RebuildOMPSharedClause(Vars, C->getLocStart(),
8473  C->getLParenLoc(), C->getLocEnd());
8474 }
8475 
8476 template <typename Derived>
8477 OMPClause *
8480  Vars.reserve(C->varlist_size());
8481  for (auto *VE : C->varlists()) {
8482  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8483  if (EVar.isInvalid())
8484  return nullptr;
8485  Vars.push_back(EVar.get());
8486  }
8487  CXXScopeSpec ReductionIdScopeSpec;
8488  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8489 
8490  DeclarationNameInfo NameInfo = C->getNameInfo();
8491  if (NameInfo.getName()) {
8492  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8493  if (!NameInfo.getName())
8494  return nullptr;
8495  }
8496  // Build a list of all UDR decls with the same names ranged by the Scopes.
8497  // The Scope boundary is a duplication of the previous decl.
8498  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8499  for (auto *E : C->reduction_ops()) {
8500  // Transform all the decls.
8501  if (E) {
8502  auto *ULE = cast<UnresolvedLookupExpr>(E);
8503  UnresolvedSet<8> Decls;
8504  for (auto *D : ULE->decls()) {
8505  NamedDecl *InstD =
8506  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8507  Decls.addDecl(InstD, InstD->getAccess());
8508  }
8509  UnresolvedReductions.push_back(
8511  SemaRef.Context, /*NamingClass=*/nullptr,
8512  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context),
8513  NameInfo, /*ADL=*/true, ULE->isOverloaded(),
8514  Decls.begin(), Decls.end()));
8515  } else
8516  UnresolvedReductions.push_back(nullptr);
8517  }
8518  return getDerived().RebuildOMPReductionClause(
8519  Vars, C->getLocStart(), C->getLParenLoc(), C->getColonLoc(),
8520  C->getLocEnd(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8521 }
8522 
8523 template <typename Derived>
8527  Vars.reserve(C->varlist_size());
8528  for (auto *VE : C->varlists()) {
8529  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8530  if (EVar.isInvalid())
8531  return nullptr;
8532  Vars.push_back(EVar.get());
8533  }
8534  CXXScopeSpec ReductionIdScopeSpec;
8535  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8536 
8537  DeclarationNameInfo NameInfo = C->getNameInfo();
8538  if (NameInfo.getName()) {
8539  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8540  if (!NameInfo.getName())
8541  return nullptr;
8542  }
8543  // Build a list of all UDR decls with the same names ranged by the Scopes.
8544  // The Scope boundary is a duplication of the previous decl.
8545  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8546  for (auto *E : C->reduction_ops()) {
8547  // Transform all the decls.
8548  if (E) {
8549  auto *ULE = cast<UnresolvedLookupExpr>(E);
8550  UnresolvedSet<8> Decls;
8551  for (auto *D : ULE->decls()) {
8552  NamedDecl *InstD =
8553  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8554  Decls.addDecl(InstD, InstD->getAccess());
8555  }
8556  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
8557  SemaRef.Context, /*NamingClass=*/nullptr,
8558  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
8559  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
8560  } else
8561  UnresolvedReductions.push_back(nullptr);
8562  }
8563  return getDerived().RebuildOMPTaskReductionClause(
8564  Vars, C->getLocStart(), C->getLParenLoc(), C->getColonLoc(),
8565  C->getLocEnd(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8566 }
8567 
8568 template <typename Derived>
8569 OMPClause *
8572  Vars.reserve(C->varlist_size());
8573  for (auto *VE : C->varlists()) {
8574  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8575  if (EVar.isInvalid())
8576  return nullptr;
8577  Vars.push_back(EVar.get());
8578  }
8579  CXXScopeSpec ReductionIdScopeSpec;
8580  ReductionIdScopeSpec.Adopt(C->getQualifierLoc());
8581 
8582  DeclarationNameInfo NameInfo = C->getNameInfo();
8583  if (NameInfo.getName()) {
8584  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8585  if (!NameInfo.getName())
8586  return nullptr;
8587  }
8588  // Build a list of all UDR decls with the same names ranged by the Scopes.
8589  // The Scope boundary is a duplication of the previous decl.
8590  llvm::SmallVector<Expr *, 16> UnresolvedReductions;
8591  for (auto *E : C->reduction_ops()) {
8592  // Transform all the decls.
8593  if (E) {
8594  auto *ULE = cast<UnresolvedLookupExpr>(E);
8595  UnresolvedSet<8> Decls;
8596  for (auto *D : ULE->decls()) {
8597  NamedDecl *InstD =
8598  cast<NamedDecl>(getDerived().TransformDecl(E->getExprLoc(), D));
8599  Decls.addDecl(InstD, InstD->getAccess());
8600  }
8601  UnresolvedReductions.push_back(UnresolvedLookupExpr::Create(
8602  SemaRef.Context, /*NamingClass=*/nullptr,
8603  ReductionIdScopeSpec.getWithLocInContext(SemaRef.Context), NameInfo,
8604  /*ADL=*/true, ULE->isOverloaded(), Decls.begin(), Decls.end()));
8605  } else
8606  UnresolvedReductions.push_back(nullptr);
8607  }
8608  return getDerived().RebuildOMPInReductionClause(
8609  Vars, C->getLocStart(), C->getLParenLoc(), C->getColonLoc(),
8610  C->getLocEnd(), ReductionIdScopeSpec, NameInfo, UnresolvedReductions);
8611 }
8612 
8613 template <typename Derived>
8614 OMPClause *
8617  Vars.reserve(C->varlist_size());
8618  for (auto *VE : C->varlists()) {
8619  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8620  if (EVar.isInvalid())
8621  return nullptr;
8622  Vars.push_back(EVar.get());
8623  }
8624  ExprResult Step = getDerived().TransformExpr(C->getStep());
8625  if (Step.isInvalid())
8626  return nullptr;
8627  return getDerived().RebuildOMPLinearClause(
8628  Vars, Step.get(), C->getLocStart(), C->getLParenLoc(), C->getModifier(),
8629  C->getModifierLoc(), C->getColonLoc(), 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  ExprResult Alignment = getDerived().TransformExpr(C->getAlignment());
8644  if (Alignment.isInvalid())
8645  return nullptr;
8646  return getDerived().RebuildOMPAlignedClause(
8647  Vars, Alignment.get(), C->getLocStart(), C->getLParenLoc(),
8648  C->getColonLoc(), C->getLocEnd());
8649 }
8650 
8651 template <typename Derived>
8652 OMPClause *
8655  Vars.reserve(C->varlist_size());
8656  for (auto *VE : C->varlists()) {
8657  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8658  if (EVar.isInvalid())
8659  return nullptr;
8660  Vars.push_back(EVar.get());
8661  }
8662  return getDerived().RebuildOMPCopyinClause(Vars, C->getLocStart(),
8663  C->getLParenLoc(), C->getLocEnd());
8664 }
8665 
8666 template <typename Derived>
8667 OMPClause *
8670  Vars.reserve(C->varlist_size());
8671  for (auto *VE : C->varlists()) {
8672  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8673  if (EVar.isInvalid())
8674  return nullptr;
8675  Vars.push_back(EVar.get());
8676  }
8677  return getDerived().RebuildOMPCopyprivateClause(
8678  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8679 }
8680 
8681 template <typename Derived>
8684  Vars.reserve(C->varlist_size());
8685  for (auto *VE : C->varlists()) {
8686  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8687  if (EVar.isInvalid())
8688  return nullptr;
8689  Vars.push_back(EVar.get());
8690  }
8691  return getDerived().RebuildOMPFlushClause(Vars, C->getLocStart(),
8692  C->getLParenLoc(), C->getLocEnd());
8693 }
8694 
8695 template <typename Derived>
8696 OMPClause *
8699  Vars.reserve(C->varlist_size());
8700  for (auto *VE : C->varlists()) {
8701  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8702  if (EVar.isInvalid())
8703  return nullptr;
8704  Vars.push_back(EVar.get());
8705  }
8706  return getDerived().RebuildOMPDependClause(
8707  C->getDependencyKind(), C->getDependencyLoc(), C->getColonLoc(), Vars,
8708  C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8709 }
8710 
8711 template <typename Derived>
8712 OMPClause *
8714  ExprResult E = getDerived().TransformExpr(C->getDevice());
8715  if (E.isInvalid())
8716  return nullptr;
8717  return getDerived().RebuildOMPDeviceClause(
8718  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8719 }
8720 
8721 template <typename Derived>
8724  Vars.reserve(C->varlist_size());
8725  for (auto *VE : C->varlists()) {
8726  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8727  if (EVar.isInvalid())
8728  return nullptr;
8729  Vars.push_back(EVar.get());
8730  }
8731  return getDerived().RebuildOMPMapClause(
8733  C->getMapLoc(), C->getColonLoc(), Vars, C->getLocStart(),
8734  C->getLParenLoc(), C->getLocEnd());
8735 }
8736 
8737 template <typename Derived>
8738 OMPClause *
8740  ExprResult E = getDerived().TransformExpr(C->getNumTeams());
8741  if (E.isInvalid())
8742  return nullptr;
8743  return getDerived().RebuildOMPNumTeamsClause(
8744  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8745 }
8746 
8747 template <typename Derived>
8748 OMPClause *
8750  ExprResult E = getDerived().TransformExpr(C->getThreadLimit());
8751  if (E.isInvalid())
8752  return nullptr;
8753  return getDerived().RebuildOMPThreadLimitClause(
8754  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8755 }
8756 
8757 template <typename Derived>
8758 OMPClause *
8760  ExprResult E = getDerived().TransformExpr(C->getPriority());
8761  if (E.isInvalid())
8762  return nullptr;
8763  return getDerived().RebuildOMPPriorityClause(
8764  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8765 }
8766 
8767 template <typename Derived>
8768 OMPClause *
8770  ExprResult E = getDerived().TransformExpr(C->getGrainsize());
8771  if (E.isInvalid())
8772  return nullptr;
8773  return getDerived().RebuildOMPGrainsizeClause(
8774  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8775 }
8776 
8777 template <typename Derived>
8778 OMPClause *
8780  ExprResult E = getDerived().TransformExpr(C->getNumTasks());
8781  if (E.isInvalid())
8782  return nullptr;
8783  return getDerived().RebuildOMPNumTasksClause(
8784  E.get(), C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8785 }
8786 
8787 template <typename Derived>
8789  ExprResult E = getDerived().TransformExpr(C->getHint());
8790  if (E.isInvalid())
8791  return nullptr;
8792  return getDerived().RebuildOMPHintClause(E.get(), C->getLocStart(),
8793  C->getLParenLoc(), C->getLocEnd());
8794 }
8795 
8796 template <typename Derived>
8798  OMPDistScheduleClause *C) {
8799  ExprResult E = getDerived().TransformExpr(C->getChunkSize());
8800  if (E.isInvalid())
8801  return nullptr;
8802  return getDerived().RebuildOMPDistScheduleClause(
8803  C->getDistScheduleKind(), E.get(), C->getLocStart(), C->getLParenLoc(),
8804  C->getDistScheduleKindLoc(), C->getCommaLoc(), C->getLocEnd());
8805 }
8806 
8807 template <typename Derived>
8808 OMPClause *
8810  return C;
8811 }
8812 
8813 template <typename Derived>
8816  Vars.reserve(C->varlist_size());
8817  for (auto *VE : C->varlists()) {
8818  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8819  if (EVar.isInvalid())
8820  return 0;
8821  Vars.push_back(EVar.get());
8822  }
8823  return getDerived().RebuildOMPToClause(Vars, C->getLocStart(),
8824  C->getLParenLoc(), C->getLocEnd());
8825 }
8826 
8827 template <typename Derived>
8830  Vars.reserve(C->varlist_size());
8831  for (auto *VE : C->varlists()) {
8832  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8833  if (EVar.isInvalid())
8834  return 0;
8835  Vars.push_back(EVar.get());
8836  }
8837  return getDerived().RebuildOMPFromClause(Vars, C->getLocStart(),
8838  C->getLParenLoc(), C->getLocEnd());
8839 }
8840 
8841 template <typename Derived>
8843  OMPUseDevicePtrClause *C) {
8845  Vars.reserve(C->varlist_size());
8846  for (auto *VE : C->varlists()) {
8847  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8848  if (EVar.isInvalid())
8849  return nullptr;
8850  Vars.push_back(EVar.get());
8851  }
8852  return getDerived().RebuildOMPUseDevicePtrClause(
8853  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8854 }
8855 
8856 template <typename Derived>
8857 OMPClause *
8860  Vars.reserve(C->varlist_size());
8861  for (auto *VE : C->varlists()) {
8862  ExprResult EVar = getDerived().TransformExpr(cast<Expr>(VE));
8863  if (EVar.isInvalid())
8864  return nullptr;
8865  Vars.push_back(EVar.get());
8866  }
8867  return getDerived().RebuildOMPIsDevicePtrClause(
8868  Vars, C->getLocStart(), C->getLParenLoc(), C->getLocEnd());
8869 }
8870 
8871 //===----------------------------------------------------------------------===//
8872 // Expression transformation
8873 //===----------------------------------------------------------------------===//
8874 template<typename Derived>
8875 ExprResult
8877  if (!E->isTypeDependent())
8878  return E;
8879 
8880  return getDerived().RebuildPredefinedExpr(E->getLocation(),
8881  E->getIdentType());
8882 }
8883 
8884 template<typename Derived>
8885 ExprResult
8887  NestedNameSpecifierLoc QualifierLoc;
8888  if (E->getQualifierLoc()) {
8889  QualifierLoc
8890  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
8891  if (!QualifierLoc)
8892  return ExprError();
8893  }
8894 
8895  ValueDecl *ND
8896  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getLocation(),
8897  E->getDecl()));
8898  if (!ND)
8899  return ExprError();
8900 
8901  DeclarationNameInfo NameInfo = E->getNameInfo();
8902  if (NameInfo.getName()) {
8903  NameInfo = getDerived().TransformDeclarationNameInfo(NameInfo);
8904  if (!NameInfo.getName())
8905  return ExprError();
8906  }
8907 
8908  if (!getDerived().AlwaysRebuild() &&
8909  QualifierLoc == E->getQualifierLoc() &&
8910  ND == E->getDecl() &&
8911  NameInfo.getName() == E->getDecl()->getDeclName() &&
8912  !E->hasExplicitTemplateArgs()) {
8913 
8914  // Mark it referenced in the new context regardless.
8915  // FIXME: this is a bit instantiation-specific.
8916  SemaRef.MarkDeclRefReferenced(E);
8917 
8918  return E;
8919  }
8920 
8921  TemplateArgumentListInfo TransArgs, *TemplateArgs = nullptr;
8922  if (E->hasExplicitTemplateArgs()) {
8923  TemplateArgs = &TransArgs;
8924  TransArgs.setLAngleLoc(E->getLAngleLoc());
8925  TransArgs.setRAngleLoc(E->getRAngleLoc());
8926  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
8927  E->getNumTemplateArgs(),
8928  TransArgs))
8929  return ExprError();
8930  }
8931 
8932  return getDerived().RebuildDeclRefExpr(QualifierLoc, ND, NameInfo,
8933  TemplateArgs);
8934 }
8935 
8936 template<typename Derived>
8937 ExprResult
8939  return E;
8940 }
8941 
8942 template <typename Derived>
8944  FixedPointLiteral *E) {
8945  return E;
8946 }
8947 
8948 template<typename Derived>
8949 ExprResult
8951  return E;
8952 }
8953 
8954 template<typename Derived>
8955 ExprResult
8957  return E;
8958 }
8959 
8960 template<typename Derived>
8961 ExprResult
8963  return E;
8964 }
8965 
8966 template<typename Derived>
8967 ExprResult
8969  return E;
8970 }
8971 
8972 template<typename Derived>
8973 ExprResult
8975  if (FunctionDecl *FD = E->getDirectCallee())
8976  SemaRef.MarkFunctionReferenced(E->getLocStart(), FD);
8977  return SemaRef.MaybeBindToTemporary(E);
8978 }
8979 
8980 template<typename Derived>
8981 ExprResult
8983  ExprResult ControllingExpr =
8984  getDerived().TransformExpr(E->getControllingExpr());
8985  if (ControllingExpr.isInvalid())
8986  return ExprError();
8987 
8988  SmallVector<Expr *, 4> AssocExprs;
8990  for (unsigned i = 0; i != E->getNumAssocs(); ++i) {
8992  if (TS) {
8993  TypeSourceInfo *AssocType = getDerived().TransformType(TS);
8994  if (!AssocType)
8995  return ExprError();
8996  AssocTypes.push_back(AssocType);
8997  } else {
8998  AssocTypes.push_back(nullptr);
8999  }
9000 
9001  ExprResult AssocExpr = getDerived().TransformExpr(E->getAssocExpr(i));
9002  if (AssocExpr.isInvalid())
9003  return ExprError();
9004  AssocExprs.push_back(AssocExpr.get());
9005  }
9006 
9007  return getDerived().RebuildGenericSelectionExpr(E->getGenericLoc(),
9008  E->getDefaultLoc(),
9009  E->getRParenLoc(),
9010  ControllingExpr.get(),
9011  AssocTypes,
9012  AssocExprs);
9013 }
9014 
9015 template<typename Derived>
9016 ExprResult
9018  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
9019  if (SubExpr.isInvalid())
9020  return ExprError();
9021 
9022  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
9023  return E;
9024 
9025  return getDerived().RebuildParenExpr(SubExpr.get(), E->getLParen(),
9026  E->getRParen());
9027 }
9028 
9029 /// The operand of a unary address-of operator has special rules: it's
9030 /// allowed to refer to a non-static member of a class even if there's no 'this'
9031 /// object available.
9032 template<typename Derived>
9033 ExprResult
9035  if (DependentScopeDeclRefExpr *DRE = dyn_cast<DependentScopeDeclRefExpr>(E))
9036  return getDerived().TransformDependentScopeDeclRefExpr(DRE, true, nullptr);
9037  else
9038  return getDerived().TransformExpr(E);
9039 }
9040 
9041 template<typename Derived>
9042 ExprResult
9044  ExprResult SubExpr;
9045  if (E->getOpcode() == UO_AddrOf)
9046  SubExpr = TransformAddressOfOperand(E->getSubExpr());
9047  else
9048  SubExpr = TransformExpr(E->getSubExpr());
9049  if (SubExpr.isInvalid())
9050  return ExprError();
9051 
9052  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getSubExpr())
9053  return E;
9054 
9055  return getDerived().RebuildUnaryOperator(E->getOperatorLoc(),
9056  E->getOpcode(),
9057  SubExpr.get());
9058 }
9059 
9060 template<typename Derived>
9061 ExprResult
9063  // Transform the type.
9064  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
9065  if (!Type)
9066  return ExprError();
9067 
9068  // Transform all of the components into components similar to what the
9069  // parser uses.
9070  // FIXME: It would be slightly more efficient in the non-dependent case to
9071  // just map FieldDecls, rather than requiring the rebuilder to look for
9072  // the fields again. However, __builtin_offsetof is rare enough in
9073  // template code that we don't care.
9074  bool ExprChanged = false;
9075  typedef Sema::OffsetOfComponent Component;
9076  SmallVector<Component, 4> Components;
9077  for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
9078  const OffsetOfNode &ON = E->getComponent(I);
9079  Component Comp;
9080  Comp.isBrackets = true;
9081  Comp.LocStart = ON.getSourceRange().getBegin();
9082  Comp.LocEnd = ON.getSourceRange().getEnd();
9083  switch (ON.getKind()) {
9084  case OffsetOfNode::Array: {
9085  Expr *FromIndex = E->getIndexExpr(ON.getArrayExprIndex());
9086  ExprResult Index = getDerived().TransformExpr(FromIndex);
9087  if (Index.isInvalid())
9088  return ExprError();
9089 
9090  ExprChanged = ExprChanged || Index.get() != FromIndex;
9091  Comp.isBrackets = true;
9092  Comp.U.E = Index.get();
9093  break;
9094  }
9095 
9096  case OffsetOfNode::Field:
9098  Comp.isBrackets = false;
9099  Comp.U.IdentInfo = ON.getFieldName();
9100  if (!Comp.U.IdentInfo)
9101  continue;
9102 
9103  break;
9104 
9105  case OffsetOfNode::Base:
9106  // Will be recomputed during the rebuild.
9107  continue;
9108  }
9109 
9110  Components.push_back(Comp);
9111  }
9112 
9113  // If nothing changed, retain the existing expression.
9114  if (!getDerived().AlwaysRebuild() &&
9115  Type == E->getTypeSourceInfo() &&
9116  !ExprChanged)
9117  return E;
9118 
9119  // Build a new offsetof expression.
9120  return getDerived().RebuildOffsetOfExpr(E->getOperatorLoc(), Type,
9121  Components, E->getRParenLoc());
9122 }
9123 
9124 template<typename Derived>
9125 ExprResult
9127  assert((!E->getSourceExpr() || getDerived().AlreadyTransformed(E->getType())) &&
9128  "opaque value expression requires transformation");
9129  return E;
9130 }
9131 
9132 template<typename Derived>
9133 ExprResult
9135  return E;
9136 }
9137 
9138 template<typename Derived>
9139 ExprResult
9141  // Rebuild the syntactic form. The original syntactic form has
9142  // opaque-value expressions in it, so strip those away and rebuild
9143  // the result. This is a really awful way of doing this, but the
9144  // better solution (rebuilding the semantic expressions and
9145  // rebinding OVEs as necessary) doesn't work; we'd need
9146  // TreeTransform to not strip away implicit conversions.
9147  Expr *newSyntacticForm = SemaRef.recreateSyntacticForm(E);
9148  ExprResult result = getDerived().TransformExpr(newSyntacticForm);
9149  if (result.isInvalid()) return ExprError();
9150 
9151  // If that gives us a pseudo-object result back, the pseudo-object
9152  // expression must have been an lvalue-to-rvalue conversion which we
9153  // should reapply.
9154  if (result.get()->hasPlaceholderType(BuiltinType::PseudoObject))
9155  result = SemaRef.checkPseudoObjectRValue(result.get());
9156 
9157  return result;
9158 }
9159 
9160 template<typename Derived>
9161 ExprResult
9164  if (E->isArgumentType()) {
9165  TypeSourceInfo *OldT = E->getArgumentTypeInfo();
9166 
9167  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
9168  if (!NewT)
9169  return ExprError();
9170 
9171  if (!getDerived().AlwaysRebuild() && OldT == NewT)
9172  return E;
9173 
9174  return getDerived().RebuildUnaryExprOrTypeTrait(NewT, E->getOperatorLoc(),
9175  E->getKind(),
9176  E->getSourceRange());
9177  }
9178 
9179  // C++0x [expr.sizeof]p1:
9180  // The operand is either an expression, which is an unevaluated operand
9181  // [...]
9185 
9186  // Try to recover if we have something like sizeof(T::X) where X is a type.
9187  // Notably, there must be *exactly* one set of parens if X is a type.
9188  TypeSourceInfo *RecoveryTSI = nullptr;
9189  ExprResult SubExpr;
9190  auto *PE = dyn_cast<ParenExpr>(E->getArgumentExpr());
9191  if (auto *DRE =
9192  PE ? dyn_cast<DependentScopeDeclRefExpr>(PE->getSubExpr()) : nullptr)
9193  SubExpr = getDerived().TransformParenDependentScopeDeclRefExpr(
9194  PE, DRE, false, &RecoveryTSI);
9195  else
9196  SubExpr = getDerived().TransformExpr(E->getArgumentExpr());
9197 
9198  if (RecoveryTSI) {
9199  return getDerived().RebuildUnaryExprOrTypeTrait(
9200  RecoveryTSI, E->getOperatorLoc(), E->getKind(), E->getSourceRange());
9201  } else if (SubExpr.isInvalid())
9202  return ExprError();
9203 
9204  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getArgumentExpr())
9205  return E;
9206 
9207  return getDerived().RebuildUnaryExprOrTypeTrait(SubExpr.get(),
9208  E->getOperatorLoc(),
9209  E->getKind(),
9210  E->getSourceRange());
9211 }
9212 
9213 template<typename Derived>
9214 ExprResult
9216  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9217  if (LHS.isInvalid())
9218  return ExprError();
9219 
9220  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9221  if (RHS.isInvalid())
9222  return ExprError();
9223 
9224 
9225  if (!getDerived().AlwaysRebuild() &&
9226  LHS.get() == E->getLHS() &&
9227  RHS.get() == E->getRHS())
9228  return E;
9229 
9230  return getDerived().RebuildArraySubscriptExpr(LHS.get(),
9231  /*FIXME:*/E->getLHS()->getLocStart(),
9232  RHS.get(),
9233  E->getRBracketLoc());
9234 }
9235 
9236 template <typename Derived>
9237 ExprResult
9239  ExprResult Base = getDerived().TransformExpr(E->getBase());
9240  if (Base.isInvalid())
9241  return ExprError();
9242 
9243  ExprResult LowerBound;
9244  if (E->getLowerBound()) {
9245  LowerBound = getDerived().TransformExpr(E->getLowerBound());
9246  if (LowerBound.isInvalid())
9247  return ExprError();
9248  }
9249 
9250  ExprResult Length;
9251  if (E->getLength()) {
9252  Length = getDerived().TransformExpr(E->getLength());
9253  if (Length.isInvalid())
9254  return ExprError();
9255  }
9256 
9257  if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
9258  LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength())
9259  return E;
9260 
9261  return getDerived().RebuildOMPArraySectionExpr(
9262  Base.get(), E->getBase()->getLocEnd(), LowerBound.get(), E->getColonLoc(),
9263  Length.get(), E->getRBracketLoc());
9264 }
9265 
9266 template<typename Derived>
9267 ExprResult
9269  // Transform the callee.
9270  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9271  if (Callee.isInvalid())
9272  return ExprError();
9273 
9274  // Transform arguments.
9275  bool ArgChanged = false;
9276  SmallVector<Expr*, 8> Args;
9277  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
9278  &ArgChanged))
9279  return ExprError();
9280 
9281  if (!getDerived().AlwaysRebuild() &&
9282  Callee.get() == E->getCallee() &&
9283  !ArgChanged)
9284  return SemaRef.MaybeBindToTemporary(E);
9285 
9286  // FIXME: Wrong source location information for the '('.
9287  SourceLocation FakeLParenLoc
9288  = ((Expr *)Callee.get())->getSourceRange().getBegin();
9289  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
9290  Args,
9291  E->getRParenLoc());
9292 }
9293 
9294 template<typename Derived>
9295 ExprResult
9297  ExprResult Base = getDerived().TransformExpr(E->getBase());
9298  if (Base.isInvalid())
9299  return ExprError();
9300 
9301  NestedNameSpecifierLoc QualifierLoc;
9302  if (E->hasQualifier()) {
9303  QualifierLoc
9304  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
9305 
9306  if (!QualifierLoc)
9307  return ExprError();
9308  }
9309  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
9310 
9311  ValueDecl *Member
9312  = cast_or_null<ValueDecl>(getDerived().TransformDecl(E->getMemberLoc(),
9313  E->getMemberDecl()));
9314  if (!Member)
9315  return ExprError();
9316 
9317  NamedDecl *FoundDecl = E->getFoundDecl();
9318  if (FoundDecl == E->getMemberDecl()) {
9319  FoundDecl = Member;
9320  } else {
9321  FoundDecl = cast_or_null<NamedDecl>(
9322  getDerived().TransformDecl(E->getMemberLoc(), FoundDecl));
9323  if (!FoundDecl)
9324  return ExprError();
9325  }
9326 
9327  if (!getDerived().AlwaysRebuild() &&
9328  Base.get() == E->getBase() &&
9329  QualifierLoc == E->getQualifierLoc() &&
9330  Member == E->getMemberDecl() &&
9331  FoundDecl == E->getFoundDecl() &&
9332  !E->hasExplicitTemplateArgs()) {
9333 
9334  // Mark it referenced in the new context regardless.
9335  // FIXME: this is a bit instantiation-specific.
9336  SemaRef.MarkMemberReferenced(E);
9337 
9338  return E;
9339  }
9340 
9341  TemplateArgumentListInfo TransArgs;
9342  if (E->hasExplicitTemplateArgs()) {
9343  TransArgs.setLAngleLoc(E->getLAngleLoc());
9344  TransArgs.setRAngleLoc(E->getRAngleLoc());
9345  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
9346  E->getNumTemplateArgs(),
9347  TransArgs))
9348  return ExprError();
9349  }
9350 
9351  // FIXME: Bogus source location for the operator
9352  SourceLocation FakeOperatorLoc =
9353  SemaRef.getLocForEndOfToken(E->getBase()->getSourceRange().getEnd());
9354 
9355  // FIXME: to do this check properly, we will need to preserve the
9356  // first-qualifier-in-scope here, just in case we had a dependent
9357  // base (and therefore couldn't do the check) and a
9358  // nested-name-qualifier (and therefore could do the lookup).
9359  NamedDecl *FirstQualifierInScope = nullptr;
9360  DeclarationNameInfo MemberNameInfo = E->getMemberNameInfo();
9361  if (MemberNameInfo.getName()) {
9362  MemberNameInfo = getDerived().TransformDeclarationNameInfo(MemberNameInfo);
9363  if (!MemberNameInfo.getName())
9364  return ExprError();
9365  }
9366 
9367  return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
9368  E->isArrow(),
9369  QualifierLoc,
9370  TemplateKWLoc,
9371  MemberNameInfo,
9372  Member,
9373  FoundDecl,
9375  ? &TransArgs : nullptr),
9376  FirstQualifierInScope);
9377 }
9378 
9379 template<typename Derived>
9380 ExprResult
9382  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9383  if (LHS.isInvalid())
9384  return ExprError();
9385 
9386  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9387  if (RHS.isInvalid())
9388  return ExprError();
9389 
9390  if (!getDerived().AlwaysRebuild() &&
9391  LHS.get() == E->getLHS() &&
9392  RHS.get() == E->getRHS())
9393  return E;
9394 
9395  Sema::FPContractStateRAII FPContractState(getSema());
9396  getSema().FPFeatures = E->getFPFeatures();
9397 
9398  return getDerived().RebuildBinaryOperator(E->getOperatorLoc(), E->getOpcode(),
9399  LHS.get(), RHS.get());
9400 }
9401 
9402 template<typename Derived>
9403 ExprResult
9406  return getDerived().TransformBinaryOperator(E);
9407 }
9408 
9409 template<typename Derived>
9412  // Just rebuild the common and RHS expressions and see whether we
9413  // get any changes.
9414 
9415  ExprResult commonExpr = getDerived().TransformExpr(e->getCommon());
9416  if (commonExpr.isInvalid())
9417  return ExprError();
9418 
9419  ExprResult rhs = getDerived().TransformExpr(e->getFalseExpr());
9420  if (rhs.isInvalid())
9421  return ExprError();
9422 
9423  if (!getDerived().AlwaysRebuild() &&
9424  commonExpr.get() == e->getCommon() &&
9425  rhs.get() == e->getFalseExpr())
9426  return e;
9427 
9428  return getDerived().RebuildConditionalOperator(commonExpr.get(),
9429  e->getQuestionLoc(),
9430  nullptr,
9431  e->getColonLoc(),
9432  rhs.get());
9433 }
9434 
9435 template<typename Derived>
9436 ExprResult
9438  ExprResult Cond = getDerived().TransformExpr(E->getCond());
9439  if (Cond.isInvalid())
9440  return ExprError();
9441 
9442  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9443  if (LHS.isInvalid())
9444  return ExprError();
9445 
9446  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9447  if (RHS.isInvalid())
9448  return ExprError();
9449 
9450  if (!getDerived().AlwaysRebuild() &&
9451  Cond.get() == E->getCond() &&
9452  LHS.get() == E->getLHS() &&
9453  RHS.get() == E->getRHS())
9454  return E;
9455 
9456  return getDerived().RebuildConditionalOperator(Cond.get(),
9457  E->getQuestionLoc(),
9458  LHS.get(),
9459  E->getColonLoc(),
9460  RHS.get());
9461 }
9462 
9463 template<typename Derived>
9464 ExprResult
9466  // Implicit casts are eliminated during transformation, since they
9467  // will be recomputed by semantic analysis after transformation.
9468  return getDerived().TransformExpr(E->getSubExprAsWritten());
9469 }
9470 
9471 template<typename Derived>
9472 ExprResult
9474  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
9475  if (!Type)
9476  return ExprError();
9477 
9478  ExprResult SubExpr
9479  = getDerived().TransformExpr(E->getSubExprAsWritten());
9480  if (SubExpr.isInvalid())
9481  return ExprError();
9482 
9483  if (!getDerived().AlwaysRebuild() &&
9484  Type == E->getTypeInfoAsWritten() &&
9485  SubExpr.get() == E->getSubExpr())
9486  return E;
9487 
9488  return getDerived().RebuildCStyleCastExpr(E->getLParenLoc(),
9489  Type,
9490  E->getRParenLoc(),
9491  SubExpr.get());
9492 }
9493 
9494 template<typename Derived>
9495 ExprResult
9497  TypeSourceInfo *OldT = E->getTypeSourceInfo();
9498  TypeSourceInfo *NewT = getDerived().TransformType(OldT);
9499  if (!NewT)
9500  return ExprError();
9501 
9502  ExprResult Init = getDerived().TransformExpr(E->getInitializer());
9503  if (Init.isInvalid())
9504  return ExprError();
9505 
9506  if (!getDerived().AlwaysRebuild() &&
9507  OldT == NewT &&
9508  Init.get() == E->getInitializer())
9509  return SemaRef.MaybeBindToTemporary(E);
9510 
9511  // Note: the expression type doesn't necessarily match the
9512  // type-as-written, but that's okay, because it should always be
9513  // derivable from the initializer.
9514 
9515  return getDerived().RebuildCompoundLiteralExpr(E->getLParenLoc(), NewT,
9516  /*FIXME:*/E->getInitializer()->getLocEnd(),
9517  Init.get());
9518 }
9519 
9520 template<typename Derived>
9521 ExprResult
9523  ExprResult Base = getDerived().TransformExpr(E->getBase());
9524  if (Base.isInvalid())
9525  return ExprError();
9526 
9527  if (!getDerived().AlwaysRebuild() &&
9528  Base.get() == E->getBase())
9529  return E;
9530 
9531  // FIXME: Bad source location
9532  SourceLocation FakeOperatorLoc =
9533  SemaRef.getLocForEndOfToken(E->getBase()->getLocEnd());
9534  return getDerived().RebuildExtVectorElementExpr(Base.get(), FakeOperatorLoc,
9535  E->getAccessorLoc(),
9536  E->getAccessor());
9537 }
9538 
9539 template<typename Derived>
9540 ExprResult
9542  if (InitListExpr *Syntactic = E->getSyntacticForm())
9543  E = Syntactic;
9544 
9545  bool InitChanged = false;
9546 
9548  if (getDerived().TransformExprs(E->getInits(), E->getNumInits(), false,
9549  Inits, &InitChanged))
9550  return ExprError();
9551 
9552  if (!getDerived().AlwaysRebuild() && !InitChanged) {
9553  // FIXME: Attempt to reuse the existing syntactic form of the InitListExpr
9554  // in some cases. We can't reuse it in general, because the syntactic and
9555  // semantic forms are linked, and we can't know that semantic form will
9556  // match even if the syntactic form does.
9557  }
9558 
9559  return getDerived().RebuildInitList(E->getLBraceLoc(), Inits,
9560  E->getRBraceLoc());
9561 }
9562 
9563 template<typename Derived>
9564 ExprResult
9566  Designation Desig;
9567 
9568  // transform the initializer value
9569  ExprResult Init = getDerived().TransformExpr(E->getInit());
9570  if (Init.isInvalid())
9571  return ExprError();
9572 
9573  // transform the designators.
9574  SmallVector<Expr*, 4> ArrayExprs;
9575  bool ExprChanged = false;
9576  for (const DesignatedInitExpr::Designator &D : E->designators()) {
9577  if (D.isFieldDesignator()) {
9578  Desig.AddDesignator(Designator::getField(D.getFieldName(),
9579  D.getDotLoc(),
9580  D.getFieldLoc()));
9581  if (D.getField()) {
9582  FieldDecl *Field = cast_or_null<FieldDecl>(
9583  getDerived().TransformDecl(D.getFieldLoc(), D.getField()));
9584  if (Field != D.getField())
9585  // Rebuild the expression when the transformed FieldDecl is
9586  // different to the already assigned FieldDecl.
9587  ExprChanged = true;
9588  } else {
9589  // Ensure that the designator expression is rebuilt when there isn't
9590  // a resolved FieldDecl in the designator as we don't want to assign
9591  // a FieldDecl to a pattern designator that will be instantiated again.
9592  ExprChanged = true;
9593  }
9594  continue;
9595  }
9596 
9597  if (D.isArrayDesignator()) {
9598  ExprResult Index = getDerived().TransformExpr(E->getArrayIndex(D));
9599  if (Index.isInvalid())
9600  return ExprError();
9601 
9602  Desig.AddDesignator(
9603  Designator::getArray(Index.get(), D.getLBracketLoc()));
9604 
9605  ExprChanged = ExprChanged || Init.get() != E->getArrayIndex(D);
9606  ArrayExprs.push_back(Index.get());
9607  continue;
9608  }
9609 
9610  assert(D.isArrayRangeDesignator() && "New kind of designator?");
9611  ExprResult Start
9612  = getDerived().TransformExpr(E->getArrayRangeStart(D));
9613  if (Start.isInvalid())
9614  return ExprError();
9615 
9616  ExprResult End = getDerived().TransformExpr(E->getArrayRangeEnd(D));
9617  if (End.isInvalid())
9618  return ExprError();
9619 
9620  Desig.AddDesignator(Designator::getArrayRange(Start.get(),
9621  End.get(),
9622  D.getLBracketLoc(),
9623  D.getEllipsisLoc()));
9624 
9625  ExprChanged = ExprChanged || Start.get() != E->getArrayRangeStart(D) ||
9626  End.get() != E->getArrayRangeEnd(D);
9627 
9628  ArrayExprs.push_back(Start.get());
9629  ArrayExprs.push_back(End.get());
9630  }
9631 
9632  if (!getDerived().AlwaysRebuild() &&
9633  Init.get() == E->getInit() &&
9634  !ExprChanged)
9635  return E;
9636 
9637  return getDerived().RebuildDesignatedInitExpr(Desig, ArrayExprs,
9638  E->getEqualOrColonLoc(),
9639  E->usesGNUSyntax(), Init.get());
9640 }
9641 
9642 // Seems that if TransformInitListExpr() only works on the syntactic form of an
9643 // InitListExpr, then a DesignatedInitUpdateExpr is not encountered.
9644 template<typename Derived>
9645 ExprResult
9648  llvm_unreachable("Unexpected DesignatedInitUpdateExpr in syntactic form of "
9649  "initializer");
9650  return ExprError();
9651 }
9652 
9653 template<typename Derived>
9654 ExprResult
9656  NoInitExpr *E) {
9657  llvm_unreachable("Unexpected NoInitExpr in syntactic form of initializer");
9658  return ExprError();
9659 }
9660 
9661 template<typename Derived>
9662 ExprResult
9664  llvm_unreachable("Unexpected ArrayInitLoopExpr outside of initializer");
9665  return ExprError();
9666 }
9667 
9668 template<typename Derived>
9669 ExprResult
9671  llvm_unreachable("Unexpected ArrayInitIndexExpr outside of initializer");
9672  return ExprError();
9673 }
9674 
9675 template<typename Derived>
9676 ExprResult
9678  ImplicitValueInitExpr *E) {
9679  TemporaryBase Rebase(*this, E->getLocStart(), DeclarationName());
9680 
9681  // FIXME: Will we ever have proper type location here? Will we actually
9682  // need to transform the type?
9683  QualType T = getDerived().TransformType(E->getType());
9684  if (T.isNull())
9685  return ExprError();
9686 
9687  if (!getDerived().AlwaysRebuild() &&
9688  T == E->getType())
9689  return E;
9690 
9691  return getDerived().RebuildImplicitValueInitExpr(T);
9692 }
9693 
9694 template<typename Derived>
9695 ExprResult
9697  TypeSourceInfo *TInfo = getDerived().TransformType(E->getWrittenTypeInfo());
9698  if (!TInfo)
9699  return ExprError();
9700 
9701  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
9702  if (SubExpr.isInvalid())
9703  return ExprError();
9704 
9705  if (!getDerived().AlwaysRebuild() &&
9706  TInfo == E->getWrittenTypeInfo() &&
9707  SubExpr.get() == E->getSubExpr())
9708  return E;
9709 
9710  return getDerived().RebuildVAArgExpr(E->getBuiltinLoc(), SubExpr.get(),
9711  TInfo, E->getRParenLoc());
9712 }
9713 
9714 template<typename Derived>
9715 ExprResult
9717  bool ArgumentChanged = false;
9719  if (TransformExprs(E->getExprs(), E->getNumExprs(), true, Inits,
9720  &ArgumentChanged))
9721  return ExprError();
9722 
9723  return getDerived().RebuildParenListExpr(E->getLParenLoc(),
9724  Inits,
9725  E->getRParenLoc());
9726 }
9727 
9728 /// Transform an address-of-label expression.
9729 ///
9730 /// By default, the transformation of an address-of-label expression always
9731 /// rebuilds the expression, so that the label identifier can be resolved to
9732 /// the corresponding label statement by semantic analysis.
9733 template<typename Derived>
9734 ExprResult
9736  Decl *LD = getDerived().TransformDecl(E->getLabel()->getLocation(),
9737  E->getLabel());
9738  if (!LD)
9739  return ExprError();
9740 
9741  return getDerived().RebuildAddrLabelExpr(E->getAmpAmpLoc(), E->getLabelLoc(),
9742  cast<LabelDecl>(LD));
9743 }
9744 
9745 template<typename Derived>
9746 ExprResult
9748  SemaRef.ActOnStartStmtExpr();
9749  StmtResult SubStmt
9750  = getDerived().TransformCompoundStmt(E->getSubStmt(), true);
9751  if (SubStmt.isInvalid()) {
9752  SemaRef.ActOnStmtExprError();
9753  return ExprError();
9754  }
9755 
9756  if (!getDerived().AlwaysRebuild() &&
9757  SubStmt.get() == E->getSubStmt()) {
9758  // Calling this an 'error' is unintuitive, but it does the right thing.
9759  SemaRef.ActOnStmtExprError();
9760  return SemaRef.MaybeBindToTemporary(E);
9761  }
9762 
9763  return getDerived().RebuildStmtExpr(E->getLParenLoc(),
9764  SubStmt.get(),
9765  E->getRParenLoc());
9766 }
9767 
9768 template<typename Derived>
9769 ExprResult
9771  ExprResult Cond = getDerived().TransformExpr(E->getCond());
9772  if (Cond.isInvalid())
9773  return ExprError();
9774 
9775  ExprResult LHS = getDerived().TransformExpr(E->getLHS());
9776  if (LHS.isInvalid())
9777  return ExprError();
9778 
9779  ExprResult RHS = getDerived().TransformExpr(E->getRHS());
9780  if (RHS.isInvalid())
9781  return ExprError();
9782 
9783  if (!getDerived().AlwaysRebuild() &&
9784  Cond.get() == E->getCond() &&
9785  LHS.get() == E->getLHS() &&
9786  RHS.get() == E->getRHS())
9787  return E;
9788 
9789  return getDerived().RebuildChooseExpr(E->getBuiltinLoc(),
9790  Cond.get(), LHS.get(), RHS.get(),
9791  E->getRParenLoc());
9792 }
9793 
9794 template<typename Derived>
9795 ExprResult
9797  return E;
9798 }
9799 
9800 template<typename Derived>
9801 ExprResult
9803  switch (E->getOperator()) {
9804  case OO_New:
9805  case OO_Delete:
9806  case OO_Array_New:
9807  case OO_Array_Delete:
9808  llvm_unreachable("new and delete operators cannot use CXXOperatorCallExpr");
9809 
9810  case OO_Call: {
9811  // This is a call to an object's operator().
9812  assert(E->getNumArgs() >= 1 && "Object call is missing arguments");
9813 
9814  // Transform the object itself.
9815  ExprResult Object = getDerived().TransformExpr(E->getArg(0));
9816  if (Object.isInvalid())
9817  return ExprError();
9818 
9819  // FIXME: Poor location information
9820  SourceLocation FakeLParenLoc = SemaRef.getLocForEndOfToken(
9821  static_cast<Expr *>(Object.get())->getLocEnd());
9822 
9823  // Transform the call arguments.
9824  SmallVector<Expr*, 8> Args;
9825  if (getDerived().TransformExprs(E->getArgs() + 1, E->getNumArgs() - 1, true,
9826  Args))
9827  return ExprError();
9828 
9829  return getDerived().RebuildCallExpr(Object.get(), FakeLParenLoc,
9830  Args,
9831  E->getLocEnd());
9832  }
9833 
9834 #define OVERLOADED_OPERATOR(Name,Spelling,Token,Unary,Binary,MemberOnly) \
9835  case OO_##Name:
9836 #define OVERLOADED_OPERATOR_MULTI(Name,Spelling,Unary,Binary,MemberOnly)
9837 #include "clang/Basic/OperatorKinds.def"
9838  case OO_Subscript:
9839  // Handled below.
9840  break;
9841 
9842  case OO_Conditional:
9843  llvm_unreachable("conditional operator is not actually overloadable");
9844 
9845  case OO_None:
9847  llvm_unreachable("not an overloaded operator?");
9848  }
9849 
9850  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9851  if (Callee.isInvalid())
9852  return ExprError();
9853 
9854  ExprResult First;
9855  if (E->getOperator() == OO_Amp)
9856  First = getDerived().TransformAddressOfOperand(E->getArg(0));
9857  else
9858  First = getDerived().TransformExpr(E->getArg(0));
9859  if (First.isInvalid())
9860  return ExprError();
9861 
9862  ExprResult Second;
9863  if (E->getNumArgs() == 2) {
9864  Second = getDerived().TransformExpr(E->getArg(1));
9865  if (Second.isInvalid())
9866  return ExprError();
9867  }
9868 
9869  if (!getDerived().AlwaysRebuild() &&
9870  Callee.get() == E->getCallee() &&
9871  First.get() == E->getArg(0) &&
9872  (E->getNumArgs() != 2 || Second.get() == E->getArg(1)))
9873  return SemaRef.MaybeBindToTemporary(E);
9874 
9875  Sema::FPContractStateRAII FPContractState(getSema());
9876  getSema().FPFeatures = E->getFPFeatures();
9877 
9878  return getDerived().RebuildCXXOperatorCallExpr(E->getOperator(),
9879  E->getOperatorLoc(),
9880  Callee.get(),
9881  First.get(),
9882  Second.get());
9883 }
9884 
9885 template<typename Derived>
9886 ExprResult
9888  return getDerived().TransformCallExpr(E);
9889 }
9890 
9891 template<typename Derived>
9892 ExprResult
9894  // Transform the callee.
9895  ExprResult Callee = getDerived().TransformExpr(E->getCallee());
9896  if (Callee.isInvalid())
9897  return ExprError();
9898 
9899  // Transform exec config.
9900  ExprResult EC = getDerived().TransformCallExpr(E->getConfig());
9901  if (EC.isInvalid())
9902  return ExprError();
9903 
9904  // Transform arguments.
9905  bool ArgChanged = false;
9906  SmallVector<Expr*, 8> Args;
9907  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
9908  &ArgChanged))
9909  return ExprError();
9910 
9911  if (!getDerived().AlwaysRebuild() &&
9912  Callee.get() == E->getCallee() &&
9913  !ArgChanged)
9914  return SemaRef.MaybeBindToTemporary(E);
9915 
9916  // FIXME: Wrong source location information for the '('.
9917  SourceLocation FakeLParenLoc
9918  = ((Expr *)Callee.get())->getSourceRange().getBegin();
9919  return getDerived().RebuildCallExpr(Callee.get(), FakeLParenLoc,
9920  Args,
9921  E->getRParenLoc(), EC.get());
9922 }
9923 
9924 template<typename Derived>
9925 ExprResult
9927  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeInfoAsWritten());
9928  if (!Type)
9929  return ExprError();
9930 
9931  ExprResult SubExpr
9932  = getDerived().TransformExpr(E->getSubExprAsWritten());
9933  if (SubExpr.isInvalid())
9934  return ExprError();
9935 
9936  if (!getDerived().AlwaysRebuild() &&
9937  Type == E->getTypeInfoAsWritten() &&
9938  SubExpr.get() == E->getSubExpr())
9939  return E;
9940  return getDerived().RebuildCXXNamedCastExpr(
9942  Type, E->getAngleBrackets().getEnd(),
9943  // FIXME. this should be '(' location
9944  E->getAngleBrackets().getEnd(), SubExpr.get(), E->getRParenLoc());
9945 }
9946 
9947 template<typename Derived>
9948 ExprResult
9950  return getDerived().TransformCXXNamedCastExpr(E);
9951 }
9952 
9953 template<typename Derived>
9954 ExprResult
9956  return getDerived().TransformCXXNamedCastExpr(E);
9957 }
9958 
9959 template<typename Derived>
9960 ExprResult
9963  return getDerived().TransformCXXNamedCastExpr(E);
9964 }
9965 
9966 template<typename Derived>
9967 ExprResult
9969  return getDerived().TransformCXXNamedCastExpr(E);
9970 }
9971 
9972 template<typename Derived>
9973 ExprResult
9975  CXXFunctionalCastExpr *E) {
9976  TypeSourceInfo *Type =
9977  getDerived().TransformTypeWithDeducedTST(E->getTypeInfoAsWritten());
9978  if (!Type)
9979  return ExprError();
9980 
9981  ExprResult SubExpr
9982  = getDerived().TransformExpr(E->getSubExprAsWritten());
9983  if (SubExpr.isInvalid())
9984  return ExprError();
9985 
9986  if (!getDerived().AlwaysRebuild() &&
9987  Type == E->getTypeInfoAsWritten() &&
9988  SubExpr.get() == E->getSubExpr())
9989  return E;
9990 
9991  return getDerived().RebuildCXXFunctionalCastExpr(Type,
9992  E->getLParenLoc(),
9993  SubExpr.get(),
9994  E->getRParenLoc(),
9995  E->isListInitialization());
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().RebuildCXXTypeidExpr(E->getType(),
10012  E->getLocStart(),
10013  TInfo,
10014  E->getLocEnd());
10015  }
10016 
10017  // We don't know whether the subexpression is potentially evaluated until
10018  // after we perform semantic analysis. We speculatively assume it is
10019  // unevaluated; it will get fixed later if the subexpression is in fact
10020  // potentially evaluated.
10024 
10025  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
10026  if (SubExpr.isInvalid())
10027  return ExprError();
10028 
10029  if (!getDerived().AlwaysRebuild() &&
10030  SubExpr.get() == E->getExprOperand())
10031  return E;
10032 
10033  return getDerived().RebuildCXXTypeidExpr(E->getType(),
10034  E->getLocStart(),
10035  SubExpr.get(),
10036  E->getLocEnd());
10037 }
10038 
10039 template<typename Derived>
10040 ExprResult
10042  if (E->isTypeOperand()) {
10043  TypeSourceInfo *TInfo
10044  = getDerived().TransformType(E->getTypeOperandSourceInfo());
10045  if (!TInfo)
10046  return ExprError();
10047 
10048  if (!getDerived().AlwaysRebuild() &&
10049  TInfo == E->getTypeOperandSourceInfo())
10050  return E;
10051 
10052  return getDerived().RebuildCXXUuidofExpr(E->getType(),
10053  E->getLocStart(),
10054  TInfo,
10055  E->getLocEnd());
10056  }
10057 
10060 
10061  ExprResult SubExpr = getDerived().TransformExpr(E->getExprOperand());
10062  if (SubExpr.isInvalid())
10063  return ExprError();
10064 
10065  if (!getDerived().AlwaysRebuild() &&
10066  SubExpr.get() == E->getExprOperand())
10067  return E;
10068 
10069  return getDerived().RebuildCXXUuidofExpr(E->getType(),
10070  E->getLocStart(),
10071  SubExpr.get(),
10072  E->getLocEnd());
10073 }
10074 
10075 template<typename Derived>
10076 ExprResult
10078  return E;
10079 }
10080 
10081 template<typename Derived>
10082 ExprResult
10084  CXXNullPtrLiteralExpr *E) {
10085  return E;
10086 }
10087 
10088 template<typename Derived>
10089 ExprResult
10091  QualType T = getSema().getCurrentThisType();
10092 
10093  if (!getDerived().AlwaysRebuild() && T == E->getType()) {
10094  // Make sure that we capture 'this'.
10095  getSema().CheckCXXThisCapture(E->getLocStart());
10096  return E;
10097  }
10098 
10099  return getDerived().RebuildCXXThisExpr(E->getLocStart(), T, E->isImplicit());
10100 }
10101 
10102 template<typename Derived>
10103 ExprResult
10105  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
10106  if (SubExpr.isInvalid())
10107  return ExprError();
10108 
10109  if (!getDerived().AlwaysRebuild() &&
10110  SubExpr.get() == E->getSubExpr())
10111  return E;
10112 
10113  return getDerived().RebuildCXXThrowExpr(E->getThrowLoc(), SubExpr.get(),
10115 }
10116 
10117 template<typename Derived>
10118 ExprResult
10120  ParmVarDecl *Param
10121  = cast_or_null<ParmVarDecl>(getDerived().TransformDecl(E->getLocStart(),
10122  E->getParam()));
10123  if (!Param)
10124  return ExprError();
10125 
10126  if (!getDerived().AlwaysRebuild() &&
10127  Param == E->getParam())
10128  return E;
10129 
10130  return getDerived().RebuildCXXDefaultArgExpr(E->getUsedLocation(), Param);
10131 }
10132 
10133 template<typename Derived>
10134 ExprResult
10136  FieldDecl *Field
10137  = cast_or_null<FieldDecl>(getDerived().TransformDecl(E->getLocStart(),
10138  E->getField()));
10139  if (!Field)
10140  return ExprError();
10141 
10142  if (!getDerived().AlwaysRebuild() && Field == E->getField())
10143  return E;
10144 
10145  return getDerived().RebuildCXXDefaultInitExpr(E->getExprLoc(), Field);
10146 }
10147 
10148 template<typename Derived>
10149 ExprResult
10152  TypeSourceInfo *T = getDerived().TransformType(E->getTypeSourceInfo());
10153  if (!T)
10154  return ExprError();
10155 
10156  if (!getDerived().AlwaysRebuild() &&
10157  T == E->getTypeSourceInfo())
10158  return E;
10159 
10160  return getDerived().RebuildCXXScalarValueInitExpr(T,
10161  /*FIXME:*/T->getTypeLoc().getEndLoc(),
10162  E->getRParenLoc());
10163 }
10164 
10165 template<typename Derived>
10166 ExprResult
10168  // Transform the type that we're allocating
10169  TypeSourceInfo *AllocTypeInfo =
10170  getDerived().TransformTypeWithDeducedTST(E->getAllocatedTypeSourceInfo());
10171  if (!AllocTypeInfo)
10172  return ExprError();
10173 
10174  // Transform the size of the array we're allocating (if any).
10175  ExprResult ArraySize = getDerived().TransformExpr(E->getArraySize());
10176  if (ArraySize.isInvalid())
10177  return ExprError();
10178 
10179  // Transform the placement arguments (if any).
10180  bool ArgumentChanged = false;
10181  SmallVector<Expr*, 8> PlacementArgs;
10182  if (getDerived().TransformExprs(E->getPlacementArgs(),
10183  E->getNumPlacementArgs(), true,
10184  PlacementArgs, &ArgumentChanged))
10185  return ExprError();
10186 
10187  // Transform the initializer (if any).
10188  Expr *OldInit = E->getInitializer();
10189  ExprResult NewInit;
10190  if (OldInit)
10191  NewInit = getDerived().TransformInitializer(OldInit, true);
10192  if (NewInit.isInvalid())
10193  return ExprError();
10194 
10195  // Transform new operator and delete operator.
10196  FunctionDecl *OperatorNew = nullptr;
10197  if (E->getOperatorNew()) {
10198  OperatorNew = cast_or_null<FunctionDecl>(
10199  getDerived().TransformDecl(E->getLocStart(),
10200  E->getOperatorNew()));
10201  if (!OperatorNew)
10202  return ExprError();
10203  }
10204 
10205  FunctionDecl *OperatorDelete = nullptr;
10206  if (E->getOperatorDelete()) {
10207  OperatorDelete = cast_or_null<FunctionDecl>(
10208  getDerived().TransformDecl(E->getLocStart(),
10209  E->getOperatorDelete()));
10210  if (!OperatorDelete)
10211  return ExprError();
10212  }
10213 
10214  if (!getDerived().AlwaysRebuild() &&
10215  AllocTypeInfo == E->getAllocatedTypeSourceInfo() &&
10216  ArraySize.get() == E->getArraySize() &&
10217  NewInit.get() == OldInit &&
10218  OperatorNew == E->getOperatorNew() &&
10219  OperatorDelete == E->getOperatorDelete() &&
10220  !ArgumentChanged) {
10221  // Mark any declarations we need as referenced.
10222  // FIXME: instantiation-specific.
10223  if (OperatorNew)
10224  SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorNew);
10225  if (OperatorDelete)
10226  SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorDelete);
10227 
10228  if (E->isArray() && !E->getAllocatedType()->isDependentType()) {
10229  QualType ElementType
10230  = SemaRef.Context.getBaseElementType(E->getAllocatedType());
10231  if (const RecordType *RecordT = ElementType->getAs<RecordType>()) {
10232  CXXRecordDecl *Record = cast<CXXRecordDecl>(RecordT->getDecl());
10233  if (CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(Record)) {
10234  SemaRef.MarkFunctionReferenced(E->getLocStart(), Destructor);
10235  }
10236  }
10237  }
10238 
10239  return E;
10240  }
10241 
10242  QualType AllocType = AllocTypeInfo->getType();
10243  if (!ArraySize.get()) {
10244  // If no array size was specified, but the new expression was
10245  // instantiated with an array type (e.g., "new T" where T is
10246  // instantiated with "int[4]"), extract the outer bound from the
10247  // array type as our array size. We do this with constant and
10248  // dependently-sized array types.
10249  const ArrayType *ArrayT = SemaRef.Context.getAsArrayType(AllocType);
10250  if (!ArrayT) {
10251  // Do nothing
10252  } else if (const ConstantArrayType *ConsArrayT
10253  = dyn_cast<ConstantArrayType>(ArrayT)) {
10254  ArraySize = IntegerLiteral::Create(SemaRef.Context, ConsArrayT->getSize(),
10255  SemaRef.Context.getSizeType(),
10256  /*FIXME:*/ E->getLocStart());
10257  AllocType = ConsArrayT->getElementType();
10258  } else if (const DependentSizedArrayType *DepArrayT
10259  = dyn_cast<DependentSizedArrayType>(ArrayT)) {
10260  if (DepArrayT->getSizeExpr()) {
10261  ArraySize = DepArrayT->getSizeExpr();
10262  AllocType = DepArrayT->getElementType();
10263  }
10264  }
10265  }
10266 
10267  return getDerived().RebuildCXXNewExpr(E->getLocStart(),
10268  E->isGlobalNew(),
10269  /*FIXME:*/E->getLocStart(),
10270  PlacementArgs,
10271  /*FIXME:*/E->getLocStart(),
10272  E->getTypeIdParens(),
10273  AllocType,
10274  AllocTypeInfo,
10275  ArraySize.get(),
10276  E->getDirectInitRange(),
10277  NewInit.get());
10278 }
10279 
10280 template<typename Derived>
10281 ExprResult
10283  ExprResult Operand = getDerived().TransformExpr(E->getArgument());
10284  if (Operand.isInvalid())
10285  return ExprError();
10286 
10287  // Transform the delete operator, if known.
10288  FunctionDecl *OperatorDelete = nullptr;
10289  if (E->getOperatorDelete()) {
10290  OperatorDelete = cast_or_null<FunctionDecl>(
10291  getDerived().TransformDecl(E->getLocStart(),
10292  E->getOperatorDelete()));
10293  if (!OperatorDelete)
10294  return ExprError();
10295  }
10296 
10297  if (!getDerived().AlwaysRebuild() &&
10298  Operand.get() == E->getArgument() &&
10299  OperatorDelete == E->getOperatorDelete()) {
10300  // Mark any declarations we need as referenced.
10301  // FIXME: instantiation-specific.
10302  if (OperatorDelete)
10303  SemaRef.MarkFunctionReferenced(E->getLocStart(), OperatorDelete);
10304 
10305  if (!E->getArgument()->isTypeDependent()) {
10306  QualType Destroyed = SemaRef.Context.getBaseElementType(
10307  E->getDestroyedType());
10308  if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
10309  CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
10310  SemaRef.MarkFunctionReferenced(E->getLocStart(),
10311  SemaRef.LookupDestructor(Record));
10312  }
10313  }
10314 
10315  return E;
10316  }
10317 
10318  return getDerived().RebuildCXXDeleteExpr(E->getLocStart(),
10319  E->isGlobalDelete(),
10320  E->isArrayForm(),
10321  Operand.get());
10322 }
10323 
10324 template<typename Derived>
10325 ExprResult
10328  ExprResult Base = getDerived().TransformExpr(E->getBase());
10329  if (Base.isInvalid())
10330  return ExprError();
10331 
10332  ParsedType ObjectTypePtr;
10333  bool MayBePseudoDestructor = false;
10334  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
10335  E->getOperatorLoc(),
10336  E->isArrow()? tok::arrow : tok::period,
10337  ObjectTypePtr,
10338  MayBePseudoDestructor);
10339  if (Base.isInvalid())
10340  return ExprError();
10341 
10342  QualType ObjectType = ObjectTypePtr.get();
10343  NestedNameSpecifierLoc QualifierLoc = E->getQualifierLoc();
10344  if (QualifierLoc) {
10345  QualifierLoc
10346  = getDerived().TransformNestedNameSpecifierLoc(QualifierLoc, ObjectType);
10347  if (!QualifierLoc)
10348  return ExprError();
10349  }
10350  CXXScopeSpec SS;
10351  SS.Adopt(QualifierLoc);
10352 
10353  PseudoDestructorTypeStorage Destroyed;
10354  if (E->getDestroyedTypeInfo()) {
10355  TypeSourceInfo *DestroyedTypeInfo
10356  = getDerived().TransformTypeInObjectScope(E->getDestroyedTypeInfo(),
10357  ObjectType, nullptr, SS);
10358  if (!DestroyedTypeInfo)
10359  return ExprError();
10360  Destroyed = DestroyedTypeInfo;
10361  } else if (!ObjectType.isNull() && ObjectType->isDependentType()) {
10362  // We aren't likely to be able to resolve the identifier down to a type
10363  // now anyway, so just retain the identifier.
10365  E->getDestroyedTypeLoc());
10366  } else {
10367  // Look for a destructor known with the given name.
10368  ParsedType T = SemaRef.getDestructorName(E->getTildeLoc(),
10370  E->getDestroyedTypeLoc(),
10371  /*Scope=*/nullptr,
10372  SS, ObjectTypePtr,
10373  false);
10374  if (!T)
10375  return ExprError();
10376 
10377  Destroyed
10378  = SemaRef.Context.getTrivialTypeSourceInfo(SemaRef.GetTypeFromParser(T),
10379  E->getDestroyedTypeLoc());
10380  }
10381 
10382  TypeSourceInfo *ScopeTypeInfo = nullptr;
10383  if (E->getScopeTypeInfo()) {
10384  CXXScopeSpec EmptySS;
10385  ScopeTypeInfo = getDerived().TransformTypeInObjectScope(
10386  E->getScopeTypeInfo(), ObjectType, nullptr, EmptySS);
10387  if (!ScopeTypeInfo)
10388  return ExprError();
10389  }
10390 
10391  return getDerived().RebuildCXXPseudoDestructorExpr(Base.get(),
10392  E->getOperatorLoc(),
10393  E->isArrow(),
10394  SS,
10395  ScopeTypeInfo,
10396  E->getColonColonLoc(),
10397  E->getTildeLoc(),
10398  Destroyed);
10399 }
10400 
10401 template <typename Derived>
10403  bool RequiresADL,
10404  LookupResult &R) {
10405  // Transform all the decls.
10406  bool AllEmptyPacks = true;
10407  for (auto *OldD : Old->decls()) {
10408  Decl *InstD = getDerived().TransformDecl(Old->getNameLoc(), OldD);
10409  if (!InstD) {
10410  // Silently ignore these if a UsingShadowDecl instantiated to nothing.
10411  // This can happen because of dependent hiding.
10412  if (isa<UsingShadowDecl>(OldD))
10413  continue;
10414  else {
10415  R.clear();
10416  return true;
10417  }
10418  }
10419 
10420  // Expand using pack declarations.
10421  NamedDecl *SingleDecl = cast<NamedDecl>(InstD);
10422  ArrayRef<NamedDecl*> Decls = SingleDecl;
10423  if (auto *UPD = dyn_cast<UsingPackDecl>(InstD))
10424  Decls = UPD->expansions();
10425 
10426  // Expand using declarations.
10427  for (auto *D : Decls) {
10428  if (auto *UD = dyn_cast<UsingDecl>(D)) {
10429  for (auto *SD : UD->shadows())
10430  R.addDecl(SD);
10431  } else {
10432  R.addDecl(D);
10433  }
10434  }
10435 
10436  AllEmptyPacks &= Decls.empty();
10437  };
10438 
10439  // C++ [temp.res]/8.4.2:
10440  // The program is ill-formed, no diagnostic required, if [...] lookup for
10441  // a name in the template definition found a using-declaration, but the
10442  // lookup in the corresponding scope in the instantiation odoes not find
10443  // any declarations because the using-declaration was a pack expansion and
10444  // the corresponding pack is empty
10445  if (AllEmptyPacks && !RequiresADL) {
10446  getSema().Diag(Old->getNameLoc(), diag::err_using_pack_expansion_empty)
10447  << isa<UnresolvedMemberExpr>(Old) << Old->getName();
10448  return true;
10449  }
10450 
10451  // Resolve a kind, but don't do any further analysis. If it's
10452  // ambiguous, the callee needs to deal with it.
10453  R.resolveKind();
10454  return false;
10455 }
10456 
10457 template<typename Derived>
10458 ExprResult
10460  UnresolvedLookupExpr *Old) {
10461  LookupResult R(SemaRef, Old->getName(), Old->getNameLoc(),
10463 
10464  // Transform the declaration set.
10465  if (TransformOverloadExprDecls(Old, Old->requiresADL(), R))
10466  return ExprError();
10467 
10468  // Rebuild the nested-name qualifier, if present.
10469  CXXScopeSpec SS;
10470  if (Old->getQualifierLoc()) {
10471  NestedNameSpecifierLoc QualifierLoc
10472  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
10473  if (!QualifierLoc)
10474  return ExprError();
10475 
10476  SS.Adopt(QualifierLoc);
10477  }
10478 
10479  if (Old->getNamingClass()) {
10480  CXXRecordDecl *NamingClass
10481  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
10482  Old->getNameLoc(),
10483  Old->getNamingClass()));
10484  if (!NamingClass) {
10485  R.clear();
10486  return ExprError();
10487  }
10488 
10489  R.setNamingClass(NamingClass);
10490  }
10491 
10492  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
10493 
10494  // If we have neither explicit template arguments, nor the template keyword,
10495  // it's a normal declaration name or member reference.
10496  if (!Old->hasExplicitTemplateArgs() && !TemplateKWLoc.isValid()) {
10497  NamedDecl *D = R.getAsSingle<NamedDecl>();
10498  // In a C++11 unevaluated context, an UnresolvedLookupExpr might refer to an
10499  // instance member. In other contexts, BuildPossibleImplicitMemberExpr will
10500  // give a good diagnostic.
10501  if (D && D->isCXXInstanceMember()) {
10502  return SemaRef.BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc, R,
10503  /*TemplateArgs=*/nullptr,
10504  /*Scope=*/nullptr);
10505  }
10506 
10507  return getDerived().RebuildDeclarationNameExpr(SS, R, Old->requiresADL());
10508  }
10509 
10510  // If we have template arguments, rebuild them, then rebuild the
10511  // templateid expression.
10512  TemplateArgumentListInfo TransArgs(Old->getLAngleLoc(), Old->getRAngleLoc());
10513  if (Old->hasExplicitTemplateArgs() &&
10514  getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
10515  Old->getNumTemplateArgs(),
10516  TransArgs)) {
10517  R.clear();
10518  return ExprError();
10519  }
10520 
10521  return getDerived().RebuildTemplateIdExpr(SS, TemplateKWLoc, R,
10522  Old->requiresADL(), &TransArgs);
10523 }
10524 
10525 template<typename Derived>
10526 ExprResult
10528  bool ArgChanged = false;
10530  for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I) {
10531  TypeSourceInfo *From = E->getArg(I);
10532  TypeLoc FromTL = From->getTypeLoc();
10533  if (!FromTL.getAs<PackExpansionTypeLoc>()) {
10534  TypeLocBuilder TLB;
10535  TLB.reserve(FromTL.getFullDataSize());
10536  QualType To = getDerived().TransformType(TLB, FromTL);
10537  if (To.isNull())
10538  return ExprError();
10539 
10540  if (To == From->getType())
10541  Args.push_back(From);
10542  else {
10543  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10544  ArgChanged = true;
10545  }
10546  continue;
10547  }
10548 
10549  ArgChanged = true;
10550 
10551  // We have a pack expansion. Instantiate it.
10552  PackExpansionTypeLoc ExpansionTL = FromTL.castAs<PackExpansionTypeLoc>();
10553  TypeLoc PatternTL = ExpansionTL.getPatternLoc();
10555  SemaRef.collectUnexpandedParameterPacks(PatternTL, Unexpanded);
10556 
10557  // Determine whether the set of unexpanded parameter packs can and should
10558  // be expanded.
10559  bool Expand = true;
10560  bool RetainExpansion = false;
10561  Optional<unsigned> OrigNumExpansions =
10562  ExpansionTL.getTypePtr()->getNumExpansions();
10563  Optional<unsigned> NumExpansions = OrigNumExpansions;
10564  if (getDerived().TryExpandParameterPacks(ExpansionTL.getEllipsisLoc(),
10565  PatternTL.getSourceRange(),
10566  Unexpanded,
10567  Expand, RetainExpansion,
10568  NumExpansions))
10569  return ExprError();
10570 
10571  if (!Expand) {
10572  // The transform has determined that we should perform a simple
10573  // transformation on the pack expansion, producing another pack
10574  // expansion.
10575  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
10576 
10577  TypeLocBuilder TLB;
10578  TLB.reserve(From->getTypeLoc().getFullDataSize());
10579 
10580  QualType To = getDerived().TransformType(TLB, PatternTL);
10581  if (To.isNull())
10582  return ExprError();
10583 
10584  To = getDerived().RebuildPackExpansionType(To,
10585  PatternTL.getSourceRange(),
10586  ExpansionTL.getEllipsisLoc(),
10587  NumExpansions);
10588  if (To.isNull())
10589  return ExprError();
10590 
10591  PackExpansionTypeLoc ToExpansionTL
10592  = TLB.push<PackExpansionTypeLoc>(To);
10593  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10594  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10595  continue;
10596  }
10597 
10598  // Expand the pack expansion by substituting for each argument in the
10599  // pack(s).
10600  for (unsigned I = 0; I != *NumExpansions; ++I) {
10601  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(SemaRef, I);
10602  TypeLocBuilder TLB;
10603  TLB.reserve(PatternTL.getFullDataSize());
10604  QualType To = getDerived().TransformType(TLB, PatternTL);
10605  if (To.isNull())
10606  return ExprError();
10607 
10608  if (To->containsUnexpandedParameterPack()) {
10609  To = getDerived().RebuildPackExpansionType(To,
10610  PatternTL.getSourceRange(),
10611  ExpansionTL.getEllipsisLoc(),
10612  NumExpansions);
10613  if (To.isNull())
10614  return ExprError();
10615 
10616  PackExpansionTypeLoc ToExpansionTL
10617  = TLB.push<PackExpansionTypeLoc>(To);
10618  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10619  }
10620 
10621  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10622  }
10623 
10624  if (!RetainExpansion)
10625  continue;
10626 
10627  // If we're supposed to retain a pack expansion, do so by temporarily
10628  // forgetting the partially-substituted parameter pack.
10629  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
10630 
10631  TypeLocBuilder TLB;
10632  TLB.reserve(From->getTypeLoc().getFullDataSize());
10633 
10634  QualType To = getDerived().TransformType(TLB, PatternTL);
10635  if (To.isNull())
10636  return ExprError();
10637 
10638  To = getDerived().RebuildPackExpansionType(To,
10639  PatternTL.getSourceRange(),
10640  ExpansionTL.getEllipsisLoc(),
10641  NumExpansions);
10642  if (To.isNull())
10643  return ExprError();
10644 
10645  PackExpansionTypeLoc ToExpansionTL
10646  = TLB.push<PackExpansionTypeLoc>(To);
10647  ToExpansionTL.setEllipsisLoc(ExpansionTL.getEllipsisLoc());
10648  Args.push_back(TLB.getTypeSourceInfo(SemaRef.Context, To));
10649  }
10650 
10651  if (!getDerived().AlwaysRebuild() && !ArgChanged)
10652  return E;
10653 
10654  return getDerived().RebuildTypeTrait(E->getTrait(),
10655  E->getLocStart(),
10656  Args,
10657  E->getLocEnd());
10658 }
10659 
10660 template<typename Derived>
10661 ExprResult
10663  TypeSourceInfo *T = getDerived().TransformType(E->getQueriedTypeSourceInfo());
10664  if (!T)
10665  return ExprError();
10666 
10667  if (!getDerived().AlwaysRebuild() &&
10668  T == E->getQueriedTypeSourceInfo())
10669  return E;
10670 
10671  ExprResult SubExpr;
10672  {
10675  SubExpr = getDerived().TransformExpr(E->getDimensionExpression());
10676  if (SubExpr.isInvalid())
10677  return ExprError();
10678 
10679  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getDimensionExpression())
10680  return E;
10681  }
10682 
10683  return getDerived().RebuildArrayTypeTrait(E->getTrait(),
10684  E->getLocStart(),
10685  T,
10686  SubExpr.get(),
10687  E->getLocEnd());
10688 }
10689 
10690 template<typename Derived>
10691 ExprResult
10693  ExprResult SubExpr;
10694  {
10697  SubExpr = getDerived().TransformExpr(E->getQueriedExpression());
10698  if (SubExpr.isInvalid())
10699  return ExprError();
10700 
10701  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getQueriedExpression())
10702  return E;
10703  }
10704 
10705  return getDerived().RebuildExpressionTrait(
10706  E->getTrait(), E->getLocStart(), SubExpr.get(), E->getLocEnd());
10707 }
10708 
10709 template <typename Derived>
10711  ParenExpr *PE, DependentScopeDeclRefExpr *DRE, bool AddrTaken,
10712  TypeSourceInfo **RecoveryTSI) {
10713  ExprResult NewDRE = getDerived().TransformDependentScopeDeclRefExpr(
10714  DRE, AddrTaken, RecoveryTSI);
10715 
10716  // Propagate both errors and recovered types, which return ExprEmpty.
10717  if (!NewDRE.isUsable())
10718  return NewDRE;
10719 
10720  // We got an expr, wrap it up in parens.
10721  if (!getDerived().AlwaysRebuild() && NewDRE.get() == DRE)
10722  return PE;
10723  return getDerived().RebuildParenExpr(NewDRE.get(), PE->getLParen(),
10724  PE->getRParen());
10725 }
10726 
10727 template <typename Derived>
10730  return TransformDependentScopeDeclRefExpr(E, /*IsAddressOfOperand=*/false,
10731  nullptr);
10732 }
10733 
10734 template<typename Derived>
10735 ExprResult
10738  bool IsAddressOfOperand,
10739  TypeSourceInfo **RecoveryTSI) {
10740  assert(E->getQualifierLoc());
10741  NestedNameSpecifierLoc QualifierLoc
10742  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc());
10743  if (!QualifierLoc)
10744  return ExprError();
10745  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
10746 
10747  // TODO: If this is a conversion-function-id, verify that the
10748  // destination type name (if present) resolves the same way after
10749  // instantiation as it did in the local scope.
10750 
10751  DeclarationNameInfo NameInfo
10752  = getDerived().TransformDeclarationNameInfo(E->getNameInfo());
10753  if (!NameInfo.getName())
10754  return ExprError();
10755 
10756  if (!E->hasExplicitTemplateArgs()) {
10757  if (!getDerived().AlwaysRebuild() &&
10758  QualifierLoc == E->getQualifierLoc() &&
10759  // Note: it is sufficient to compare the Name component of NameInfo:
10760  // if name has not changed, DNLoc has not changed either.
10761  NameInfo.getName() == E->getDeclName())
10762  return E;
10763 
10764  return getDerived().RebuildDependentScopeDeclRefExpr(
10765  QualifierLoc, TemplateKWLoc, NameInfo, /*TemplateArgs=*/nullptr,
10766  IsAddressOfOperand, RecoveryTSI);
10767  }
10768 
10769  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
10770  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
10771  E->getNumTemplateArgs(),
10772  TransArgs))
10773  return ExprError();
10774 
10775  return getDerived().RebuildDependentScopeDeclRefExpr(
10776  QualifierLoc, TemplateKWLoc, NameInfo, &TransArgs, IsAddressOfOperand,
10777  RecoveryTSI);
10778 }
10779 
10780 template<typename Derived>
10781 ExprResult
10783  // CXXConstructExprs other than for list-initialization and
10784  // CXXTemporaryObjectExpr are always implicit, so when we have
10785  // a 1-argument construction we just transform that argument.
10786  if ((E->getNumArgs() == 1 ||
10787  (E->getNumArgs() > 1 && getDerived().DropCallArgument(E->getArg(1)))) &&
10788  (!getDerived().DropCallArgument(E->getArg(0))) &&
10789  !E->isListInitialization())
10790  return getDerived().TransformExpr(E->getArg(0));
10791 
10792  TemporaryBase Rebase(*this, /*FIXME*/E->getLocStart(), DeclarationName());
10793 
10794  QualType T = getDerived().TransformType(E->getType());
10795  if (T.isNull())
10796  return ExprError();
10797 
10798  CXXConstructorDecl *Constructor
10799  = cast_or_null<CXXConstructorDecl>(
10800  getDerived().TransformDecl(E->getLocStart(),
10801  E->getConstructor()));
10802  if (!Constructor)
10803  return ExprError();
10804 
10805  bool ArgumentChanged = false;
10806  SmallVector<Expr*, 8> Args;
10807  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
10808  &ArgumentChanged))
10809  return ExprError();
10810 
10811  if (!getDerived().AlwaysRebuild() &&
10812  T == E->getType() &&
10813  Constructor == E->getConstructor() &&
10814  !ArgumentChanged) {
10815  // Mark the constructor as referenced.
10816  // FIXME: Instantiation-specific
10817  SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
10818  return E;
10819  }
10820 
10821  return getDerived().RebuildCXXConstructExpr(T, /*FIXME:*/E->getLocStart(),
10822  Constructor,
10823  E->isElidable(), Args,
10824  E->hadMultipleCandidates(),
10825  E->isListInitialization(),
10828  E->getConstructionKind(),
10829  E->getParenOrBraceRange());
10830 }
10831 
10832 template<typename Derived>
10835  QualType T = getDerived().TransformType(E->getType());
10836  if (T.isNull())
10837  return ExprError();
10838 
10839  CXXConstructorDecl *Constructor = cast_or_null<CXXConstructorDecl>(
10840  getDerived().TransformDecl(E->getLocStart(), E->getConstructor()));
10841  if (!Constructor)
10842  return ExprError();
10843 
10844  if (!getDerived().AlwaysRebuild() &&
10845  T == E->getType() &&
10846  Constructor == E->getConstructor()) {
10847  // Mark the constructor as referenced.
10848  // FIXME: Instantiation-specific
10849  SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
10850  return E;
10851  }
10852 
10853  return getDerived().RebuildCXXInheritedCtorInitExpr(
10854  T, E->getLocation(), Constructor,
10855  E->constructsVBase(), E->inheritedFromVBase());
10856 }
10857 
10858 /// Transform a C++ temporary-binding expression.
10859 ///
10860 /// Since CXXBindTemporaryExpr nodes are implicitly generated, we just
10861 /// transform the subexpression and return that.
10862 template<typename Derived>
10863 ExprResult
10865  return getDerived().TransformExpr(E->getSubExpr());
10866 }
10867 
10868 /// Transform a C++ expression that contains cleanups that should
10869 /// be run after the expression is evaluated.
10870 ///
10871 /// Since ExprWithCleanups nodes are implicitly generated, we
10872 /// just transform the subexpression and return that.
10873 template<typename Derived>
10874 ExprResult
10876  return getDerived().TransformExpr(E->getSubExpr());
10877 }
10878 
10879 template<typename Derived>
10880 ExprResult
10883  TypeSourceInfo *T =
10884  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
10885  if (!T)
10886  return ExprError();
10887 
10888  CXXConstructorDecl *Constructor
10889  = cast_or_null<CXXConstructorDecl>(
10890  getDerived().TransformDecl(E->getLocStart(),
10891  E->getConstructor()));
10892  if (!Constructor)
10893  return ExprError();
10894 
10895  bool ArgumentChanged = false;
10896  SmallVector<Expr*, 8> Args;
10897  Args.reserve(E->getNumArgs());
10898  if (TransformExprs(E->getArgs(), E->getNumArgs(), true, Args,
10899  &ArgumentChanged))
10900  return ExprError();
10901 
10902  if (!getDerived().AlwaysRebuild() &&
10903  T == E->getTypeSourceInfo() &&
10904  Constructor == E->getConstructor() &&
10905  !ArgumentChanged) {
10906  // FIXME: Instantiation-specific
10907  SemaRef.MarkFunctionReferenced(E->getLocStart(), Constructor);
10908  return SemaRef.MaybeBindToTemporary(E);
10909  }
10910 
10911  // FIXME: We should just pass E->isListInitialization(), but we're not
10912  // prepared to handle list-initialization without a child InitListExpr.
10913  SourceLocation LParenLoc = T->getTypeLoc().getEndLoc();
10914  return getDerived().RebuildCXXTemporaryObjectExpr(
10915  T, LParenLoc, Args, E->getLocEnd(),
10916  /*ListInitialization=*/LParenLoc.isInvalid());
10917 }
10918 
10919 template<typename Derived>
10920 ExprResult
10922  // Transform any init-capture expressions before entering the scope of the
10923  // lambda body, because they are not semantically within that scope.
10924  typedef std::pair<ExprResult, QualType> InitCaptureInfoTy;
10925  SmallVector<InitCaptureInfoTy, 8> InitCaptureExprsAndTypes;
10926  InitCaptureExprsAndTypes.resize(E->explicit_capture_end() -
10927  E->explicit_capture_begin());
10929  CEnd = E->capture_end();
10930  C != CEnd; ++C) {
10931  if (!E->isInitCapture(C))
10932  continue;
10935  ExprResult NewExprInitResult = getDerived().TransformInitializer(
10936  C->getCapturedVar()->getInit(),
10937  C->getCapturedVar()->getInitStyle() == VarDecl::CallInit);
10938 
10939  if (NewExprInitResult.isInvalid())
10940  return ExprError();
10941  Expr *NewExprInit = NewExprInitResult.get();
10942 
10943  VarDecl *OldVD = C->getCapturedVar();
10944  QualType NewInitCaptureType =
10945  getSema().buildLambdaInitCaptureInitialization(
10946  C->getLocation(), OldVD->getType()->isReferenceType(),
10947  OldVD->getIdentifier(),
10948  C->getCapturedVar()->getInitStyle() != VarDecl::CInit, NewExprInit);
10949  NewExprInitResult = NewExprInit;
10950  InitCaptureExprsAndTypes[C - E->capture_begin()] =
10951  std::make_pair(NewExprInitResult, NewInitCaptureType);
10952  }
10953 
10954  // Transform the template parameters, and add them to the current
10955  // instantiation scope. The null case is handled correctly.
10956  auto TPL = getDerived().TransformTemplateParameterList(
10958 
10959  // Transform the type of the original lambda's call operator.
10960  // The transformation MUST be done in the CurrentInstantiationScope since
10961  // it introduces a mapping of the original to the newly created
10962  // transformed parameters.
10963  TypeSourceInfo *NewCallOpTSI = nullptr;
10964  {
10965  TypeSourceInfo *OldCallOpTSI = E->getCallOperator()->getTypeSourceInfo();
10966  FunctionProtoTypeLoc OldCallOpFPTL =
10967  OldCallOpTSI->getTypeLoc().getAs<FunctionProtoTypeLoc>();
10968 
10969  TypeLocBuilder NewCallOpTLBuilder;
10970  SmallVector<QualType, 4> ExceptionStorage;
10971  TreeTransform *This = this; // Work around gcc.gnu.org/PR56135.
10972  QualType NewCallOpType = TransformFunctionProtoType(
10973  NewCallOpTLBuilder, OldCallOpFPTL, nullptr, 0,
10974  [&](FunctionProtoType::ExceptionSpecInfo &ESI, bool &Changed) {
10975  return This->TransformExceptionSpec(OldCallOpFPTL.getBeginLoc(), ESI,
10976  ExceptionStorage, Changed);
10977  });
10978  if (NewCallOpType.isNull())
10979  return ExprError();
10980  NewCallOpTSI = NewCallOpTLBuilder.getTypeSourceInfo(getSema().Context,
10981  NewCallOpType);
10982  }
10983 
10984  LambdaScopeInfo *LSI = getSema().PushLambdaScope();
10985  Sema::FunctionScopeRAII FuncScopeCleanup(getSema());
10986  LSI->GLTemplateParameterList = TPL;
10987 
10988  // Create the local class that will describe the lambda.
10989  CXXRecordDecl *Class
10990  = getSema().createLambdaClosureType(E->getIntroducerRange(),
10991  NewCallOpTSI,
10992  /*KnownDependent=*/false,
10993  E->getCaptureDefault());
10994  getDerived().transformedLocalDecl(E->getLambdaClass(), Class);
10995 
10996  // Build the call operator.
10997  CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
10998  Class, E->getIntroducerRange(), NewCallOpTSI,
10999  E->getCallOperator()->getLocEnd(),
11000  NewCallOpTSI->getTypeLoc().castAs<FunctionProtoTypeLoc>().getParams(),
11001  E->getCallOperator()->isConstexpr());
11002 
11003  LSI->CallOperator = NewCallOperator;
11004 
11005  for (unsigned I = 0, NumParams = NewCallOperator->getNumParams();
11006  I != NumParams; ++I) {
11007  auto *P = NewCallOperator->getParamDecl(I);
11008  if (P->hasUninstantiatedDefaultArg()) {
11010  getSema(),
11012  ExprResult R = getDerived().TransformExpr(
11014  P->setDefaultArg(R.get());
11015  }
11016  }
11017 
11018  getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
11019  getDerived().transformedLocalDecl(E->getCallOperator(), NewCallOperator);
11020 
11021  // Introduce the context of the call operator.
11022  Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
11023  /*NewThisContext*/false);
11024 
11025  // Enter the scope of the lambda.
11026  getSema().buildLambdaScope(LSI, NewCallOperator,
11027  E->getIntroducerRange(),
11028  E->getCaptureDefault(),
11029  E->getCaptureDefaultLoc(),
11030  E->hasExplicitParameters(),
11031  E->hasExplicitResultType(),
11032  E->isMutable());
11033 
11034  bool Invalid = false;
11035 
11036  // Transform captures.
11037  bool FinishedExplicitCaptures = false;
11039  CEnd = E->capture_end();
11040  C != CEnd; ++C) {
11041  // When we hit the first implicit capture, tell Sema that we've finished
11042  // the list of explicit captures.
11043  if (!FinishedExplicitCaptures && C->isImplicit()) {
11044  getSema().finishLambdaExplicitCaptures(LSI);
11045  FinishedExplicitCaptures = true;
11046  }
11047 
11048  // Capturing 'this' is trivial.
11049  if (C->capturesThis()) {
11050  getSema().CheckCXXThisCapture(C->getLocation(), C->isExplicit(),
11051  /*BuildAndDiagnose*/ true, nullptr,
11052  C->getCaptureKind() == LCK_StarThis);
11053  continue;
11054  }
11055  // Captured expression will be recaptured during captured variables
11056  // rebuilding.
11057  if (C->capturesVLAType())
11058  continue;
11059 
11060  // Rebuild init-captures, including the implied field declaration.
11061  if (E->isInitCapture(C)) {
11062  InitCaptureInfoTy InitExprTypePair =
11063  InitCaptureExprsAndTypes[C - E->capture_begin()];
11064  ExprResult Init = InitExprTypePair.first;
11065  QualType InitQualType = InitExprTypePair.second;
11066  if (Init.isInvalid() || InitQualType.isNull()) {
11067  Invalid = true;
11068  continue;
11069  }
11070  VarDecl *OldVD = C->getCapturedVar();
11071  VarDecl *NewVD = getSema().createLambdaInitCaptureVarDecl(
11072  OldVD->getLocation(), InitExprTypePair.second, OldVD->getIdentifier(),
11073  OldVD->getInitStyle(), Init.get());
11074  if (!NewVD)
11075  Invalid = true;
11076  else {
11077  getDerived().transformedLocalDecl(OldVD, NewVD);
11078  }
11079  getSema().buildInitCaptureField(LSI, NewVD);
11080  continue;
11081  }
11082 
11083  assert(C->capturesVariable() && "unexpected kind of lambda capture");
11084 
11085  // Determine the capture kind for Sema.
11087  = C->isImplicit()? Sema::TryCapture_Implicit
11088  : C->getCaptureKind() == LCK_ByCopy
11091  SourceLocation EllipsisLoc;
11092  if (C->isPackExpansion()) {
11093  UnexpandedParameterPack Unexpanded(C->getCapturedVar(), C->getLocation());
11094  bool ShouldExpand = false;
11095  bool RetainExpansion = false;
11096  Optional<unsigned> NumExpansions;
11097  if (getDerived().TryExpandParameterPacks(C->getEllipsisLoc(),
11098  C->getLocation(),
11099  Unexpanded,
11100  ShouldExpand, RetainExpansion,
11101  NumExpansions)) {
11102  Invalid = true;
11103  continue;
11104  }
11105 
11106  if (ShouldExpand) {
11107  // The transform has determined that we should perform an expansion;
11108  // transform and capture each of the arguments.
11109  // expansion of the pattern. Do so.
11110  VarDecl *Pack = C->getCapturedVar();
11111  for (unsigned I = 0; I != *NumExpansions; ++I) {
11112  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11113  VarDecl *CapturedVar
11114  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11115  Pack));
11116  if (!CapturedVar) {
11117  Invalid = true;
11118  continue;
11119  }
11120 
11121  // Capture the transformed variable.
11122  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind);
11123  }
11124 
11125  // FIXME: Retain a pack expansion if RetainExpansion is true.
11126 
11127  continue;
11128  }
11129 
11130  EllipsisLoc = C->getEllipsisLoc();
11131  }
11132 
11133  // Transform the captured variable.
11134  VarDecl *CapturedVar
11135  = cast_or_null<VarDecl>(getDerived().TransformDecl(C->getLocation(),
11136  C->getCapturedVar()));
11137  if (!CapturedVar || CapturedVar->isInvalidDecl()) {
11138  Invalid = true;
11139  continue;
11140  }
11141 
11142  // Capture the transformed variable.
11143  getSema().tryCaptureVariable(CapturedVar, C->getLocation(), Kind,
11144  EllipsisLoc);
11145  }
11146  if (!FinishedExplicitCaptures)
11147  getSema().finishLambdaExplicitCaptures(LSI);
11148 
11149  // Enter a new evaluation context to insulate the lambda from any
11150  // cleanups from the enclosing full-expression.
11151  getSema().PushExpressionEvaluationContext(
11153 
11154  // Instantiate the body of the lambda expression.
11155  StmtResult Body =
11156  Invalid ? StmtError() : getDerived().TransformStmt(E->getBody());
11157 
11158  // ActOnLambda* will pop the function scope for us.
11159  FuncScopeCleanup.disable();
11160 
11161  if (Body.isInvalid()) {
11162  SavedContext.pop();
11163  getSema().ActOnLambdaError(E->getLocStart(), /*CurScope=*/nullptr,
11164  /*IsInstantiation=*/true);
11165  return ExprError();
11166  }
11167 
11168  // Copy the LSI before ActOnFinishFunctionBody removes it.
11169  // FIXME: This is dumb. Store the lambda information somewhere that outlives
11170  // the call operator.
11171  auto LSICopy = *LSI;
11172  getSema().ActOnFinishFunctionBody(NewCallOperator, Body.get(),
11173  /*IsInstantiation*/ true);
11174  SavedContext.pop();
11175 
11176  return getSema().BuildLambdaExpr(E->getLocStart(), Body.get()->getLocEnd(),
11177  &LSICopy);
11178 }
11179 
11180 template<typename Derived>
11181 ExprResult
11184  TypeSourceInfo *T =
11185  getDerived().TransformTypeWithDeducedTST(E->getTypeSourceInfo());
11186  if (!T)
11187  return ExprError();
11188 
11189  bool ArgumentChanged = false;
11190  SmallVector<Expr*, 8> Args;
11191  Args.reserve(E->arg_size());
11192  if (getDerived().TransformExprs(E->arg_begin(), E->arg_size(), true, Args,
11193  &ArgumentChanged))
11194  return ExprError();
11195 
11196  if (!getDerived().AlwaysRebuild() &&
11197  T == E->getTypeSourceInfo() &&
11198  !ArgumentChanged)
11199  return E;
11200 
11201  // FIXME: we're faking the locations of the commas
11202  return getDerived().RebuildCXXUnresolvedConstructExpr(
11203  T, E->getLParenLoc(), Args, E->getRParenLoc(), E->isListInitialization());
11204 }
11205 
11206 template<typename Derived>
11207 ExprResult
11210  // Transform the base of the expression.
11211  ExprResult Base((Expr*) nullptr);
11212  Expr *OldBase;
11213  QualType BaseType;
11214  QualType ObjectType;
11215  if (!E->isImplicitAccess()) {
11216  OldBase = E->getBase();
11217  Base = getDerived().TransformExpr(OldBase);
11218  if (Base.isInvalid())
11219  return ExprError();
11220 
11221  // Start the member reference and compute the object's type.
11222  ParsedType ObjectTy;
11223  bool MayBePseudoDestructor = false;
11224  Base = SemaRef.ActOnStartCXXMemberReference(nullptr, Base.get(),
11225  E->getOperatorLoc(),
11226  E->isArrow()? tok::arrow : tok::period,
11227  ObjectTy,
11228  MayBePseudoDestructor);
11229  if (Base.isInvalid())
11230  return ExprError();
11231 
11232  ObjectType = ObjectTy.get();
11233  BaseType = ((Expr*) Base.get())->getType();
11234  } else {
11235  OldBase = nullptr;
11236  BaseType = getDerived().TransformType(E->getBaseType());
11237  ObjectType = BaseType->getAs<PointerType>()->getPointeeType();
11238  }
11239 
11240  // Transform the first part of the nested-name-specifier that qualifies
11241  // the member name.
11242  NamedDecl *FirstQualifierInScope
11243  = getDerived().TransformFirstQualifierInScope(
11245  E->getQualifierLoc().getBeginLoc());
11246 
11247  NestedNameSpecifierLoc QualifierLoc;
11248  if (E->getQualifier()) {
11249  QualifierLoc
11250  = getDerived().TransformNestedNameSpecifierLoc(E->getQualifierLoc(),
11251  ObjectType,
11252  FirstQualifierInScope);
11253  if (!QualifierLoc)
11254  return ExprError();
11255  }
11256 
11257  SourceLocation TemplateKWLoc = E->getTemplateKeywordLoc();
11258 
11259  // TODO: If this is a conversion-function-id, verify that the
11260  // destination type name (if present) resolves the same way after
11261  // instantiation as it did in the local scope.
11262 
11263  DeclarationNameInfo NameInfo
11264  = getDerived().TransformDeclarationNameInfo(E->getMemberNameInfo());
11265  if (!NameInfo.getName())
11266  return ExprError();
11267 
11268  if (!E->hasExplicitTemplateArgs()) {
11269  // This is a reference to a member without an explicitly-specified
11270  // template argument list. Optimize for this common case.
11271  if (!getDerived().AlwaysRebuild() &&
11272  Base.get() == OldBase &&
11273  BaseType == E->getBaseType() &&
11274  QualifierLoc == E->getQualifierLoc() &&
11275  NameInfo.getName() == E->getMember() &&
11276  FirstQualifierInScope == E->getFirstQualifierFoundInScope())
11277  return E;
11278 
11279  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
11280  BaseType,
11281  E->isArrow(),
11282  E->getOperatorLoc(),
11283  QualifierLoc,
11284  TemplateKWLoc,
11285  FirstQualifierInScope,
11286  NameInfo,
11287  /*TemplateArgs*/nullptr);
11288  }
11289 
11290  TemplateArgumentListInfo TransArgs(E->getLAngleLoc(), E->getRAngleLoc());
11291  if (getDerived().TransformTemplateArguments(E->getTemplateArgs(),
11292  E->getNumTemplateArgs(),
11293  TransArgs))
11294  return ExprError();
11295 
11296  return getDerived().RebuildCXXDependentScopeMemberExpr(Base.get(),
11297  BaseType,
11298  E->isArrow(),
11299  E->getOperatorLoc(),
11300  QualifierLoc,
11301  TemplateKWLoc,
11302  FirstQualifierInScope,
11303  NameInfo,
11304  &TransArgs);
11305 }
11306 
11307 template<typename Derived>
11308 ExprResult
11310  // Transform the base of the expression.
11311  ExprResult Base((Expr*) nullptr);
11312  QualType BaseType;
11313  if (!Old->isImplicitAccess()) {
11314  Base = getDerived().TransformExpr(Old->getBase());
11315  if (Base.isInvalid())
11316  return ExprError();
11317  Base = getSema().PerformMemberExprBaseConversion(Base.get(),
11318  Old->isArrow());
11319  if (Base.isInvalid())
11320  return ExprError();
11321  BaseType = Base.get()->getType();
11322  } else {
11323  BaseType = getDerived().TransformType(Old->getBaseType());
11324  }
11325 
11326  NestedNameSpecifierLoc QualifierLoc;
11327  if (Old->getQualifierLoc()) {
11328  QualifierLoc
11329  = getDerived().TransformNestedNameSpecifierLoc(Old->getQualifierLoc());
11330  if (!QualifierLoc)
11331  return ExprError();
11332  }
11333 
11334  SourceLocation TemplateKWLoc = Old->getTemplateKeywordLoc();
11335 
11336  LookupResult R(SemaRef, Old->getMemberNameInfo(),
11338 
11339  // Transform the declaration set.
11340  if (TransformOverloadExprDecls(Old, /*RequiresADL*/false, R))
11341  return ExprError();
11342 
11343  // Determine the naming class.
11344  if (Old->getNamingClass()) {
11345  CXXRecordDecl *NamingClass
11346  = cast_or_null<CXXRecordDecl>(getDerived().TransformDecl(
11347  Old->getMemberLoc(),
11348  Old->getNamingClass()));
11349  if (!NamingClass)
11350  return ExprError();
11351 
11352  R.setNamingClass(NamingClass);
11353  }
11354 
11355  TemplateArgumentListInfo TransArgs;
11356  if (Old->hasExplicitTemplateArgs()) {
11357  TransArgs.setLAngleLoc(Old->getLAngleLoc());
11358  TransArgs.setRAngleLoc(Old->getRAngleLoc());
11359  if (getDerived().TransformTemplateArguments(Old->getTemplateArgs(),
11360  Old->getNumTemplateArgs(),
11361  TransArgs))
11362  return ExprError();
11363  }
11364 
11365  // FIXME: to do this check properly, we will need to preserve the
11366  // first-qualifier-in-scope here, just in case we had a dependent
11367  // base (and therefore couldn't do the check) and a
11368  // nested-name-qualifier (and therefore could do the lookup).
11369  NamedDecl *FirstQualifierInScope = nullptr;
11370 
11371  return getDerived().RebuildUnresolvedMemberExpr(Base.get(),
11372  BaseType,
11373  Old->getOperatorLoc(),
11374  Old->isArrow(),
11375  QualifierLoc,
11376  TemplateKWLoc,
11377  FirstQualifierInScope,
11378  R,
11379  (Old->hasExplicitTemplateArgs()
11380  ? &TransArgs : nullptr));
11381 }
11382 
11383 template<typename Derived>
11384 ExprResult
11388  ExprResult SubExpr = getDerived().TransformExpr(E->getOperand());
11389  if (SubExpr.isInvalid())
11390  return ExprError();
11391 
11392  if (!getDerived().AlwaysRebuild() && SubExpr.get() == E->getOperand())
11393  return E;
11394 
11395  return getDerived().RebuildCXXNoexceptExpr(E->getSourceRange(),SubExpr.get());
11396 }
11397 
11398 template<typename Derived>
11399 ExprResult
11401  ExprResult Pattern = getDerived().TransformExpr(E->getPattern());
11402  if (Pattern.isInvalid())
11403  return ExprError();
11404 
11405  if (!getDerived().AlwaysRebuild() && Pattern.get() == E->getPattern())
11406  return E;
11407 
11408  return getDerived().RebuildPackExpansion(Pattern.get(), E->getEllipsisLoc(),
11409  E->getNumExpansions());
11410 }
11411 
11412 template<typename Derived>
11413 ExprResult
11415  // If E is not value-dependent, then nothing will change when we transform it.
11416  // Note: This is an instantiation-centric view.
11417  if (!E->isValueDependent())
11418  return E;
11419 
11422 
11423  ArrayRef<TemplateArgument> PackArgs;
11424  TemplateArgument ArgStorage;
11425 
11426  // Find the argument list to transform.
11427  if (E->isPartiallySubstituted()) {
11428  PackArgs = E->getPartialArguments();
11429  } else if (E->isValueDependent()) {
11430  UnexpandedParameterPack Unexpanded(E->getPack(), E->getPackLoc());
11431  bool ShouldExpand = false;
11432  bool RetainExpansion = false;
11433  Optional<unsigned> NumExpansions;
11434  if (getDerived().TryExpandParameterPacks(E->getOperatorLoc(), E->getPackLoc(),
11435  Unexpanded,
11436  ShouldExpand, RetainExpansion,
11437  NumExpansions))
11438  return ExprError();
11439 
11440  // If we need to expand the pack, build a template argument from it and
11441  // expand that.
11442  if (ShouldExpand) {
11443  auto *Pack = E->getPack();
11444  if (auto *TTPD = dyn_cast<TemplateTypeParmDecl>(Pack)) {
11445  ArgStorage = getSema().Context.getPackExpansionType(
11446  getSema().Context.getTypeDeclType(TTPD), None);
11447  } else if (auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(Pack)) {
11448  ArgStorage = TemplateArgument(TemplateName(TTPD), None);
11449  } else {
11450  auto *VD = cast<ValueDecl>(Pack);
11451  ExprResult DRE = getSema().BuildDeclRefExpr(
11452  VD, VD->getType().getNonLValueExprType(getSema().Context),
11453  VD->getType()->isReferenceType() ? VK_LValue : VK_RValue,
11454  E->getPackLoc());
11455  if (DRE.isInvalid())
11456  return ExprError();
11457  ArgStorage = new (getSema().Context) PackExpansionExpr(
11458  getSema().Context.DependentTy, DRE.get(), E->getPackLoc(), None);
11459  }
11460  PackArgs = ArgStorage;
11461  }
11462  }
11463 
11464  // If we're not expanding the pack, just transform the decl.
11465  if (!PackArgs.size()) {
11466  auto *Pack = cast_or_null<NamedDecl>(
11467  getDerived().TransformDecl(E->getPackLoc(), E->getPack()));
11468  if (!Pack)
11469  return ExprError();
11470  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), Pack,
11471  E->getPackLoc(),
11472  E->getRParenLoc(), None, None);
11473  }
11474 
11475  // Try to compute the result without performing a partial substitution.
11476  Optional<unsigned> Result = 0;
11477  for (const TemplateArgument &Arg : PackArgs) {
11478  if (!Arg.isPackExpansion()) {
11479  Result = *Result + 1;
11480  continue;
11481  }
11482 
11483  TemplateArgumentLoc ArgLoc;
11484  InventTemplateArgumentLoc(Arg, ArgLoc);
11485 
11486  // Find the pattern of the pack expansion.
11487  SourceLocation Ellipsis;
11488  Optional<unsigned> OrigNumExpansions;
11489  TemplateArgumentLoc Pattern =
11490  getSema().getTemplateArgumentPackExpansionPattern(ArgLoc, Ellipsis,
11491  OrigNumExpansions);
11492 
11493  // Substitute under the pack expansion. Do not expand the pack (yet).
11494  TemplateArgumentLoc OutPattern;
11495  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11496  if (getDerived().TransformTemplateArgument(Pattern, OutPattern,
11497  /*Uneval*/ true))
11498  return true;
11499 
11500  // See if we can determine the number of arguments from the result.
11501  Optional<unsigned> NumExpansions =
11502  getSema().getFullyPackExpandedSize(OutPattern.getArgument());
11503  if (!NumExpansions) {
11504  // No: we must be in an alias template expansion, and we're going to need
11505  // to actually expand the packs.
11506  Result = None;
11507  break;
11508  }
11509 
11510  Result = *Result + *NumExpansions;
11511  }
11512 
11513  // Common case: we could determine the number of expansions without
11514  // substituting.
11515  if (Result)
11516  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11517  E->getPackLoc(),
11518  E->getRParenLoc(), *Result, None);
11519 
11520  TemplateArgumentListInfo TransformedPackArgs(E->getPackLoc(),
11521  E->getPackLoc());
11522  {
11523  TemporaryBase Rebase(*this, E->getPackLoc(), getBaseEntity());
11525  Derived, const TemplateArgument*> PackLocIterator;
11526  if (TransformTemplateArguments(PackLocIterator(*this, PackArgs.begin()),
11527  PackLocIterator(*this, PackArgs.end()),
11528  TransformedPackArgs, /*Uneval*/true))
11529  return ExprError();
11530  }
11531 
11532  // Check whether we managed to fully-expand the pack.
11533  // FIXME: Is it possible for us to do so and not hit the early exit path?
11535  bool PartialSubstitution = false;
11536  for (auto &Loc : TransformedPackArgs.arguments()) {
11537  Args.push_back(Loc.getArgument());
11538  if (Loc.getArgument().isPackExpansion())
11539  PartialSubstitution = true;
11540  }
11541 
11542  if (PartialSubstitution)
11543  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11544  E->getPackLoc(),
11545  E->getRParenLoc(), None, Args);
11546 
11547  return getDerived().RebuildSizeOfPackExpr(E->getOperatorLoc(), E->getPack(),
11548  E->getPackLoc(), E->getRParenLoc(),
11549  Args.size(), None);
11550 }
11551 
11552 template<typename Derived>
11553 ExprResult
11556  // Default behavior is to do nothing with this transformation.
11557  return E;
11558 }
11559 
11560 template<typename Derived>
11561 ExprResult
11564  // Default behavior is to do nothing with this transformation.
11565  return E;
11566 }
11567 
11568 template<typename Derived>
11569 ExprResult
11571  // Default behavior is to do nothing with this transformation.
11572  return E;
11573 }
11574 
11575 template<typename Derived>
11576 ExprResult
11579  return getDerived().TransformExpr(E->GetTemporaryExpr());
11580 }
11581 
11582 template<typename Derived>
11583 ExprResult
11585  Expr *Pattern = E->getPattern();
11586 
11588  getSema().collectUnexpandedParameterPacks(Pattern, Unexpanded);
11589  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
11590 
11591  // Determine whether the set of unexpanded parameter packs can and should
11592  // be expanded.
11593  bool Expand = true;
11594  bool RetainExpansion = false;
11595  Optional<unsigned> NumExpansions;
11596  if (getDerived().TryExpandParameterPacks(E->getEllipsisLoc(),
11597  Pattern->getSourceRange(),
11598  Unexpanded,
11599  Expand, RetainExpansion,
11600  NumExpansions))
11601  return true;
11602 
11603  if (!Expand) {
11604  // Do not expand any packs here, just transform and rebuild a fold
11605  // expression.
11606  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11607 
11608  ExprResult LHS =
11609  E->getLHS() ? getDerived().TransformExpr(E->getLHS()) : ExprResult();
11610  if (LHS.isInvalid())
11611  return true;
11612 
11613  ExprResult RHS =
11614  E->getRHS() ? getDerived().TransformExpr(E->getRHS()) : ExprResult();
11615  if (RHS.isInvalid())
11616  return true;
11617 
11618  if (!getDerived().AlwaysRebuild() &&
11619  LHS.get() == E->getLHS() && RHS.get() == E->getRHS())
11620  return E;
11621 
11622  return getDerived().RebuildCXXFoldExpr(
11623  E->getLocStart(), LHS.get(), E->getOperator(), E->getEllipsisLoc(),
11624  RHS.get(), E->getLocEnd());
11625  }
11626 
11627  // The transform has determined that we should perform an elementwise
11628  // expansion of the pattern. Do so.
11629  ExprResult Result = getDerived().TransformExpr(E->getInit());
11630  if (Result.isInvalid())
11631  return true;
11632  bool LeftFold = E->isLeftFold();
11633 
11634  // If we're retaining an expansion for a right fold, it is the innermost
11635  // component and takes the init (if any).
11636  if (!LeftFold && RetainExpansion) {
11637  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11638 
11639  ExprResult Out = getDerived().TransformExpr(Pattern);
11640  if (Out.isInvalid())
11641  return true;
11642 
11643  Result = getDerived().RebuildCXXFoldExpr(
11644  E->getLocStart(), Out.get(), E->getOperator(), E->getEllipsisLoc(),
11645  Result.get(), E->getLocEnd());
11646  if (Result.isInvalid())
11647  return true;
11648  }
11649 
11650  for (unsigned I = 0; I != *NumExpansions; ++I) {
11652  getSema(), LeftFold ? I : *NumExpansions - I - 1);
11653  ExprResult Out = getDerived().TransformExpr(Pattern);
11654  if (Out.isInvalid())
11655  return true;
11656 
11657  if (Out.get()->containsUnexpandedParameterPack()) {
11658  // We still have a pack; retain a pack expansion for this slice.
11659  Result = getDerived().RebuildCXXFoldExpr(
11660  E->getLocStart(),
11661  LeftFold ? Result.get() : Out.get(),
11662  E->getOperator(), E->getEllipsisLoc(),
11663  LeftFold ? Out.get() : Result.get(),
11664  E->getLocEnd());
11665  } else if (Result.isUsable()) {
11666  // We've got down to a single element; build a binary operator.
11667  Result = getDerived().RebuildBinaryOperator(
11668  E->getEllipsisLoc(), E->getOperator(),
11669  LeftFold ? Result.get() : Out.get(),
11670  LeftFold ? Out.get() : Result.get());
11671  } else
11672  Result = Out;
11673 
11674  if (Result.isInvalid())
11675  return true;
11676  }
11677 
11678  // If we're retaining an expansion for a left fold, it is the outermost
11679  // component and takes the complete expansion so far as its init (if any).
11680  if (LeftFold && RetainExpansion) {
11681  ForgetPartiallySubstitutedPackRAII Forget(getDerived());
11682 
11683  ExprResult Out = getDerived().TransformExpr(Pattern);
11684  if (Out.isInvalid())
11685  return true;
11686 
11687  Result = getDerived().RebuildCXXFoldExpr(
11688  E->getLocStart(), Result.get(),
11689  E->getOperator(), E->getEllipsisLoc(),
11690  Out.get(), E->getLocEnd());
11691  if (Result.isInvalid())
11692  return true;
11693  }
11694 
11695  // If we had no init and an empty pack, and we're not retaining an expansion,
11696  // then produce a fallback value or error.
11697  if (Result.isUnset())
11698  return getDerived().RebuildEmptyCXXFoldExpr(E->getEllipsisLoc(),
11699  E->getOperator());
11700 
11701  return Result;
11702 }
11703 
11704 template<typename Derived>
11705 ExprResult
11708  return getDerived().TransformExpr(E->getSubExpr());
11709 }
11710 
11711 template<typename Derived>
11712 ExprResult
11714  return SemaRef.MaybeBindToTemporary(E);
11715 }
11716 
11717 template<typename Derived>
11718 ExprResult
11720  return E;
11721 }
11722 
11723 template<typename Derived>
11724 ExprResult
11726  ExprResult SubExpr = getDerived().TransformExpr(E->getSubExpr());
11727  if (SubExpr.isInvalid())
11728  return ExprError();
11729 
11730  if (!getDerived().AlwaysRebuild() &&
11731  SubExpr.get() == E->getSubExpr())
11732  return E;
11733 
11734  return getDerived().RebuildObjCBoxedExpr(E->getSourceRange(), SubExpr.get());
11735 }
11736 
11737 template<typename Derived>
11738 ExprResult
11740  // Transform each of the elements.
11741  SmallVector<Expr *, 8> Elements;
11742  bool ArgChanged = false;
11743  if (getDerived().TransformExprs(E->getElements(), E->getNumElements(),
11744  /*IsCall=*/false, Elements, &ArgChanged))
11745  return ExprError();
11746 
11747  if (!getDerived().AlwaysRebuild() && !ArgChanged)
11748  return SemaRef.MaybeBindToTemporary(E);
11749 
11750  return getDerived().RebuildObjCArrayLiteral(E->getSourceRange(),
11751  Elements.data(),
11752  Elements.size());
11753 }
11754 
11755 template<typename Derived>
11756 ExprResult
11758  ObjCDictionaryLiteral *E) {
11759  // Transform each of the elements.
11761  bool ArgChanged = false;
11762  for (unsigned I = 0, N = E->getNumElements(); I != N; ++I) {
11763  ObjCDictionaryElement OrigElement = E->getKeyValueElement(I);
11764 
11765  if (OrigElement.isPackExpansion()) {
11766  // This key/value element is a pack expansion.
11768  getSema().collectUnexpandedParameterPacks(OrigElement.Key, Unexpanded);
11769  getSema().collectUnexpandedParameterPacks(OrigElement.Value, Unexpanded);
11770  assert(!Unexpanded.empty() && "Pack expansion without parameter packs?");
11771 
11772  // Determine whether the set of unexpanded parameter packs can
11773  // and should be expanded.
11774  bool Expand = true;
11775  bool RetainExpansion = false;
11776  Optional<unsigned> OrigNumExpansions = OrigElement.NumExpansions;
11777  Optional<unsigned> NumExpansions = OrigNumExpansions;
11778  SourceRange PatternRange(OrigElement.Key->getLocStart(),
11779  OrigElement.Value->getLocEnd());
11780  if (getDerived().TryExpandParameterPacks(OrigElement.EllipsisLoc,
11781  PatternRange,
11782  Unexpanded,
11783  Expand, RetainExpansion,
11784  NumExpansions))
11785  return ExprError();
11786 
11787  if (!Expand) {
11788  // The transform has determined that we should perform a simple
11789  // transformation on the pack expansion, producing another pack
11790  // expansion.
11791  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
11792  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11793  if (Key.isInvalid())
11794  return ExprError();
11795 
11796  if (Key.get() != OrigElement.Key)
11797  ArgChanged = true;
11798 
11799  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
11800  if (Value.isInvalid())
11801  return ExprError();
11802 
11803  if (Value.get() != OrigElement.Value)
11804  ArgChanged = true;
11805 
11806  ObjCDictionaryElement Expansion = {
11807  Key.get(), Value.get(), OrigElement.EllipsisLoc, NumExpansions
11808  };
11809  Elements.push_back(Expansion);
11810  continue;
11811  }
11812 
11813  // Record right away that the argument was changed. This needs
11814  // to happen even if the array expands to nothing.
11815  ArgChanged = true;
11816 
11817  // The transform has determined that we should perform an elementwise
11818  // expansion of the pattern. Do so.
11819  for (unsigned I = 0; I != *NumExpansions; ++I) {
11820  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), I);
11821  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11822  if (Key.isInvalid())
11823  return ExprError();
11824 
11825  ExprResult Value = getDerived().TransformExpr(OrigElement.Value);
11826  if (Value.isInvalid())
11827  return ExprError();
11828 
11829  ObjCDictionaryElement Element = {
11830  Key.get(), Value.get(), SourceLocation(), NumExpansions
11831  };
11832 
11833  // If any unexpanded parameter packs remain, we still have a
11834  // pack expansion.
11835  // FIXME: Can this really happen?
11836  if (Key.get()->containsUnexpandedParameterPack() ||
11837  Value.get()->containsUnexpandedParameterPack())
11838  Element.EllipsisLoc = OrigElement.EllipsisLoc;
11839 
11840  Elements.push_back(Element);
11841  }
11842 
11843  // FIXME: Retain a pack expansion if RetainExpansion is true.
11844 
11845  // We've finished with this pack expansion.
11846  continue;
11847  }
11848 
11849  // Transform and check key.
11850  ExprResult Key = getDerived().TransformExpr(OrigElement.Key);
11851  if (Key.isInvalid())
11852  return ExprError();
11853 
11854  if (Key.get() != OrigElement.Key)
11855  ArgChanged = true;
11856 
11857  // Transform and check value.
11859  = getDerived().TransformExpr(OrigElement.Value);
11860  if (Value.isInvalid())
11861  return ExprError();
11862 
11863  if (Value.get() != OrigElement.Value)
11864  ArgChanged = true;
11865 
11866  ObjCDictionaryElement Element = {
11867  Key.get(), Value.get(), SourceLocation(), None
11868  };
11869  Elements.push_back(Element);
11870  }
11871 
11872  if (!getDerived().AlwaysRebuild() && !ArgChanged)
11873  return SemaRef.MaybeBindToTemporary(E);
11874 
11875  return getDerived().RebuildObjCDictionaryLiteral(E->getSourceRange(),
11876  Elements);
11877 }
11878 
11879 template<typename Derived>
11880 ExprResult
11882  TypeSourceInfo *EncodedTypeInfo
11883  = getDerived().TransformType(E->getEncodedTypeSourceInfo());
11884  if (!EncodedTypeInfo)
11885  return ExprError();
11886 
11887  if (!getDerived().AlwaysRebuild() &&
11888  EncodedTypeInfo == E->getEncodedTypeSourceInfo())
11889  return E;
11890 
11891  return getDerived().RebuildObjCEncodeExpr(E->getAtLoc(),
11892  EncodedTypeInfo,
11893  E->getRParenLoc());
11894 }
11895 
11896 template<typename Derived>
11899  // This is a kind of implicit conversion, and it needs to get dropped
11900  // and recomputed for the same general reasons that ImplicitCastExprs
11901  // do, as well a more specific one: this expression is only valid when
11902  // it appears *immediately* as an argument expression.
11903  return getDerived().TransformExpr(E->getSubExpr());
11904 }
11905 
11906 template<typename Derived>
11909  TypeSourceInfo *TSInfo
11910  = getDerived().TransformType(E->getTypeInfoAsWritten());
11911  if (!TSInfo)
11912  return ExprError();
11913 
11914  ExprResult Result = getDerived().TransformExpr(E->getSubExpr());
11915  if (Result.isInvalid())
11916  return ExprError();
11917 
11918  if (!getDerived().AlwaysRebuild() &&
11919  TSInfo == E->getTypeInfoAsWritten() &&
11920  Result.get() == E->getSubExpr())
11921  return E;
11922 
11923  return SemaRef.BuildObjCBridgedCast(E->getLParenLoc(), E->getBridgeKind(),
11924  E->getBridgeKeywordLoc(), TSInfo,
11925  Result.get());
11926 }
11927 
11928 template <typename Derived>
11931  return E;
11932 }
11933 
11934 template<typename Derived>
11935 ExprResult
11937  // Transform arguments.
11938  bool ArgChanged = false;
11939  SmallVector<Expr*, 8> Args;
11940  Args.reserve(E->getNumArgs());
11941  if (getDerived().TransformExprs(E->getArgs(), E->getNumArgs(), false, Args,
11942  &ArgChanged))
11943  return ExprError();
11944 
11946  // Class message: transform the receiver type.
11947  TypeSourceInfo *ReceiverTypeInfo
11948  = getDerived().TransformType(E->getClassReceiverTypeInfo());
11949  if (!ReceiverTypeInfo)
11950  return ExprError();
11951 
11952  // If nothing changed, just retain the existing message send.
11953  if (!getDerived().AlwaysRebuild() &&
11954  ReceiverTypeInfo == E->getClassReceiverTypeInfo() && !ArgChanged)
11955  return SemaRef.MaybeBindToTemporary(E);
11956 
11957  // Build a new class message send.
11959  E->getSelectorLocs(SelLocs);
11960  return getDerived().RebuildObjCMessageExpr(ReceiverTypeInfo,
11961  E->getSelector(),
11962  SelLocs,
11963  E->getMethodDecl(),
11964  E->getLeftLoc(),
11965  Args,
11966  E->getRightLoc());
11967  }
11968  else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
11970  if (!E->getMethodDecl())
11971  return ExprError();
11972 
11973  // Build a new class message send to 'super'.
11975  E->getSelectorLocs(SelLocs);
11976  return getDerived().RebuildObjCMessageExpr(E->getSuperLoc(),
11977  E->getSelector(),
11978  SelLocs,
11979  E->getReceiverType(),
11980  E->getMethodDecl(),
11981  E->getLeftLoc(),
11982  Args,
11983  E->getRightLoc());
11984  }
11985 
11986  // Instance message: transform the receiver
11987  assert(E->getReceiverKind() == ObjCMessageExpr::Instance &&
11988  "Only class and instance messages may be instantiated");
11989  ExprResult Receiver
11990  = getDerived().TransformExpr(E->getInstanceReceiver());
11991  if (Receiver.isInvalid())
11992  return ExprError();
11993 
11994  // If nothing changed, just retain the existing message send.
11995  if (!getDerived().AlwaysRebuild() &&
11996  Receiver.get() == E->getInstanceReceiver() && !ArgChanged)
11997  return SemaRef.MaybeBindToTemporary(E);
11998 
11999  // Build a new instance message send.
12001  E->getSelectorLocs(SelLocs);
12002  return getDerived().RebuildObjCMessageExpr(Receiver.get(),
12003  E->getSelector(),
12004  SelLocs,
12005  E->getMethodDecl(),
12006  E->getLeftLoc(),
12007  Args,
12008  E->getRightLoc());
12009 }
12010 
12011 template<typename Derived>
12012 ExprResult
12014  return E;
12015 }
12016 
12017 template<typename Derived>
12018 ExprResult
12020  return E;
12021 }
12022 
12023 template<typename Derived>
12024 ExprResult
12026  // Transform the base expression.
12027  ExprResult Base = getDerived().TransformExpr(E->getBase());
12028  if (Base.isInvalid())
12029  return ExprError();
12030 
12031  // We don't need to transform the ivar; it will never change.
12032 
12033  // If nothing changed, just retain the existing expression.
12034  if (!getDerived().AlwaysRebuild() &&
12035  Base.get() == E->getBase())
12036  return E;
12037 
12038  return getDerived().RebuildObjCIvarRefExpr(Base.get(), E->getDecl(),
12039  E->getLocation(),
12040  E->isArrow(), E->isFreeIvar());
12041 }
12042 
12043 template<typename Derived>
12044 ExprResult
12046  // 'super' and types never change. Property never changes. Just
12047  // retain the existing expression.
12048  if (!E->isObjectReceiver())
12049  return E;
12050 
12051  // Transform the base expression.
12052  ExprResult Base = getDerived().TransformExpr(E->getBase());
12053  if (Base.isInvalid())
12054  return ExprError();
12055 
12056  // We don't need to transform the property; it will never change.
12057 
12058  // If nothing changed, just retain the existing expression.
12059  if (!getDerived().AlwaysRebuild() &&
12060  Base.get() == E->getBase())
12061  return E;
12062 
12063  if (E->isExplicitProperty())
12064  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12065  E->getExplicitProperty(),
12066  E->getLocation());
12067 
12068  return getDerived().RebuildObjCPropertyRefExpr(Base.get(),
12069  SemaRef.Context.PseudoObjectTy,
12072  E->getLocation());
12073 }
12074 
12075 template<typename Derived>
12076 ExprResult
12078  // Transform the base expression.
12079  ExprResult Base = getDerived().TransformExpr(E->getBaseExpr());
12080  if (Base.isInvalid())
12081  return ExprError();
12082 
12083  // Transform the key expression.
12084  ExprResult Key = getDerived().TransformExpr(E->getKeyExpr());
12085  if (Key.isInvalid())
12086  return ExprError();
12087 
12088  // If nothing changed, just retain the existing expression.
12089  if (!getDerived().AlwaysRebuild() &&
12090  Key.get() == E->getKeyExpr() && Base.get() == E->getBaseExpr())
12091  return E;
12092 
12093  return getDerived().RebuildObjCSubscriptRefExpr(E->getRBracket(),
12094  Base.get(), Key.get(),
12095  E->getAtIndexMethodDecl(),
12096  E->setAtIndexMethodDecl());
12097 }
12098 
12099 template<typename Derived>
12100 ExprResult
12102  // Transform the base expression.
12103  ExprResult Base = getDerived().TransformExpr(E->getBase());
12104  if (Base.isInvalid())
12105  return ExprError();
12106 
12107  // If nothing changed, just retain the existing expression.
12108  if (!getDerived().AlwaysRebuild() &&
12109  Base.get() == E->getBase())
12110  return E;
12111 
12112  return getDerived().RebuildObjCIsaExpr(Base.get(), E->getIsaMemberLoc(),
12113  E->getOpLoc(),
12114  E->isArrow());
12115 }
12116 
12117 template<typename Derived>
12118 ExprResult
12120  bool ArgumentChanged = false;
12121  SmallVector<Expr*, 8> SubExprs;
12122  SubExprs.reserve(E->getNumSubExprs());
12123  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
12124  SubExprs, &ArgumentChanged))
12125  return ExprError();
12126 
12127  if (!getDerived().AlwaysRebuild() &&
12128  !ArgumentChanged)
12129  return E;
12130 
12131  return getDerived().RebuildShuffleVectorExpr(E->getBuiltinLoc(),
12132  SubExprs,
12133  E->getRParenLoc());
12134 }
12135 
12136 template<typename Derived>
12137 ExprResult
12139  ExprResult SrcExpr = getDerived().TransformExpr(E->getSrcExpr());
12140  if (SrcExpr.isInvalid())
12141  return ExprError();
12142 
12143  TypeSourceInfo *Type = getDerived().TransformType(E->getTypeSourceInfo());
12144  if (!Type)
12145  return ExprError();
12146 
12147  if (!getDerived().AlwaysRebuild() &&
12148  Type == E->getTypeSourceInfo() &&
12149  SrcExpr.get() == E->getSrcExpr())
12150  return E;
12151 
12152  return getDerived().RebuildConvertVectorExpr(E->getBuiltinLoc(),
12153  SrcExpr.get(), Type,
12154  E->getRParenLoc());
12155 }
12156 
12157 template<typename Derived>
12158 ExprResult
12160  BlockDecl *oldBlock = E->getBlockDecl();
12161 
12162  SemaRef.ActOnBlockStart(E->getCaretLocation(), /*Scope=*/nullptr);
12163  BlockScopeInfo *blockScope = SemaRef.getCurBlock();
12164 
12165  blockScope->TheDecl->setIsVariadic(oldBlock->isVariadic());
12166  blockScope->TheDecl->setBlockMissingReturnType(
12167  oldBlock->blockMissingReturnType());
12168 
12170  SmallVector<QualType, 4> paramTypes;
12171 
12172  const FunctionProtoType *exprFunctionType = E->getFunctionType();
12173 
12174  // Parameter substitution.
12175  Sema::ExtParameterInfoBuilder extParamInfos;
12176  if (getDerived().TransformFunctionTypeParams(
12177  E->getCaretLocation(), oldBlock->parameters(), nullptr,
12178  exprFunctionType->getExtParameterInfosOrNull(), paramTypes, &params,
12179  extParamInfos)) {
12180  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
12181  return ExprError();
12182  }
12183 
12184  QualType exprResultType =
12185  getDerived().TransformType(exprFunctionType->getReturnType());
12186 
12187  auto epi = exprFunctionType->getExtProtoInfo();
12188  epi.ExtParameterInfos = extParamInfos.getPointerOrNull(paramTypes.size());
12189 
12191  getDerived().RebuildFunctionProtoType(exprResultType, paramTypes, epi);
12192  blockScope->FunctionType = functionType;
12193 
12194  // Set the parameters on the block decl.
12195  if (!params.empty())
12196  blockScope->TheDecl->setParams(params);
12197 
12198  if (!oldBlock->blockMissingReturnType()) {
12199  blockScope->HasImplicitReturnType = false;
12200  blockScope->ReturnType = exprResultType;
12201  }
12202 
12203  // Transform the body
12204  StmtResult body = getDerived().TransformStmt(E->getBody());
12205  if (body.isInvalid()) {
12206  getSema().ActOnBlockError(E->getCaretLocation(), /*Scope=*/nullptr);
12207  return ExprError();
12208  }
12209 
12210 #ifndef NDEBUG
12211  // In builds with assertions, make sure that we captured everything we
12212  // captured before.
12213  if (!SemaRef.getDiagnostics().hasErrorOccurred()) {
12214  for (const auto &I : oldBlock->captures()) {
12215  VarDecl *oldCapture = I.getVariable();
12216 
12217  // Ignore parameter packs.
12218  if (isa<ParmVarDecl>(oldCapture) &&
12219  cast<ParmVarDecl>(oldCapture)->isParameterPack())
12220  continue;
12221 
12222  VarDecl *newCapture =
12223  cast<VarDecl>(getDerived().TransformDecl(E->getCaretLocation(),
12224  oldCapture));
12225  assert(blockScope->CaptureMap.count(newCapture));
12226  }
12227  assert(oldBlock->capturesCXXThis() == blockScope->isCXXThisCaptured());
12228  }
12229 #endif
12230 
12231  return SemaRef.ActOnBlockStmtExpr(E->getCaretLocation(), body.get(),
12232  /*Scope=*/nullptr);
12233 }
12234 
12235 template<typename Derived>
12236 ExprResult
12238  llvm_unreachable("Cannot transform asType expressions yet");
12239 }
12240 
12241 template<typename Derived>
12242 ExprResult
12244  QualType RetTy = getDerived().TransformType(E->getType());
12245  bool ArgumentChanged = false;
12246  SmallVector<Expr*, 8> SubExprs;
12247  SubExprs.reserve(E->getNumSubExprs());
12248  if (getDerived().TransformExprs(E->getSubExprs(), E->getNumSubExprs(), false,
12249  SubExprs, &ArgumentChanged))
12250  return ExprError();
12251 
12252  if (!getDerived().AlwaysRebuild() &&
12253  !ArgumentChanged)
12254  return E;
12255 
12256  return getDerived().RebuildAtomicExpr(E->getBuiltinLoc(), SubExprs,
12257  RetTy, E->getOp(), E->getRParenLoc());
12258 }
12259 
12260 //===----------------------------------------------------------------------===//
12261 // Type reconstruction
12262 //===----------------------------------------------------------------------===//
12263 
12264 template<typename Derived>
12266  SourceLocation Star) {
12267  return SemaRef.BuildPointerType(PointeeType, Star,
12268  getDerived().getBaseEntity());
12269 }
12270 
12271 template<typename Derived>
12273  SourceLocation Star) {
12274  return SemaRef.BuildBlockPointerType(PointeeType, Star,
12275  getDerived().getBaseEntity());
12276 }
12277 
12278 template<typename Derived>
12279 QualType
12281  bool WrittenAsLValue,
12282  SourceLocation Sigil) {
12283  return SemaRef.BuildReferenceType(ReferentType, WrittenAsLValue,
12284  Sigil, getDerived().getBaseEntity());
12285 }
12286 
12287 template<typename Derived>
12288 QualType
12290  QualType ClassType,
12291  SourceLocation Sigil) {
12292  return SemaRef.BuildMemberPointerType(PointeeType, ClassType, Sigil,
12293  getDerived().getBaseEntity());
12294 }
12295 
12296 template<typename Derived>
12298  const ObjCTypeParamDecl *Decl,
12299  SourceLocation ProtocolLAngleLoc,
12300  ArrayRef<ObjCProtocolDecl *> Protocols,
12301  ArrayRef<SourceLocation> ProtocolLocs,
12302  SourceLocation ProtocolRAngleLoc) {
12303  return SemaRef.BuildObjCTypeParamType(Decl,
12304  ProtocolLAngleLoc, Protocols,
12305  ProtocolLocs, ProtocolRAngleLoc,
12306  /*FailOnError=*/true);
12307 }
12308 
12309 template<typename Derived>
12311  QualType BaseType,
12312  SourceLocation Loc,
12313  SourceLocation TypeArgsLAngleLoc,
12314  ArrayRef<TypeSourceInfo *> TypeArgs,
12315  SourceLocation TypeArgsRAngleLoc,
12316  SourceLocation ProtocolLAngleLoc,
12317  ArrayRef<ObjCProtocolDecl *> Protocols,
12318  ArrayRef<SourceLocation> ProtocolLocs,
12319  SourceLocation ProtocolRAngleLoc) {
12320  return SemaRef.BuildObjCObjectType(BaseType, Loc, TypeArgsLAngleLoc,
12321  TypeArgs, TypeArgsRAngleLoc,
12322  ProtocolLAngleLoc, Protocols, ProtocolLocs,
12323  ProtocolRAngleLoc,
12324  /*FailOnError=*/true);
12325 }
12326 
12327 template<typename Derived>
12329  QualType PointeeType,
12330  SourceLocation Star) {
12331  return SemaRef.Context.getObjCObjectPointerType(PointeeType);
12332 }
12333 
12334 template<typename Derived>
12335 QualType
12338  const llvm::APInt *Size,
12339  Expr *SizeExpr,
12340  unsigned IndexTypeQuals,
12341  SourceRange BracketsRange) {
12342  if (SizeExpr || !Size)
12343  return SemaRef.BuildArrayType(ElementType, SizeMod, SizeExpr,
12344  IndexTypeQuals, BracketsRange,
12345  getDerived().getBaseEntity());
12346 
12347  QualType Types[] = {
12348  SemaRef.Context.UnsignedCharTy, SemaRef.Context.UnsignedShortTy,
12349  SemaRef.Context.UnsignedIntTy, SemaRef.Context.UnsignedLongTy,
12350  SemaRef.Context.UnsignedLongLongTy, SemaRef.Context.UnsignedInt128Ty
12351  };
12352  const unsigned NumTypes = llvm::array_lengthof(Types);
12353  QualType SizeType;
12354  for (unsigned I = 0; I != NumTypes; ++I)
12355  if (Size->getBitWidth() == SemaRef.Context.getIntWidth(Types[I])) {
12356  SizeType = Types[I];
12357  break;
12358  }
12359 
12360  // Note that we can return a VariableArrayType here in the case where
12361  // the element type was a dependent VariableArrayType.
12362  IntegerLiteral *ArraySize
12363  = IntegerLiteral::Create(SemaRef.Context, *Size, SizeType,
12364  /*FIXME*/BracketsRange.getBegin());
12365  return SemaRef.BuildArrayType(ElementType, SizeMod, ArraySize,
12366  IndexTypeQuals, BracketsRange,
12367  getDerived().getBaseEntity());
12368 }
12369 
12370 template<typename Derived>
12371 QualType
12374  const llvm::APInt &Size,
12375  unsigned IndexTypeQuals,
12376  SourceRange BracketsRange) {
12377  return getDerived().RebuildArrayType(ElementType, SizeMod, &Size, nullptr,
12378  IndexTypeQuals, BracketsRange);
12379 }
12380 
12381 template<typename Derived>
12382 QualType
12385  unsigned IndexTypeQuals,
12386  SourceRange BracketsRange) {
12387  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr, nullptr,
12388  IndexTypeQuals, BracketsRange);
12389 }
12390 
12391 template<typename Derived>
12392 QualType
12395  Expr *SizeExpr,
12396  unsigned IndexTypeQuals,
12397  SourceRange BracketsRange) {
12398  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
12399  SizeExpr,
12400  IndexTypeQuals, BracketsRange);
12401 }
12402 
12403 template<typename Derived>
12404 QualType
12407  Expr *SizeExpr,
12408  unsigned IndexTypeQuals,
12409  SourceRange BracketsRange) {
12410  return getDerived().RebuildArrayType(ElementType, SizeMod, nullptr,
12411  SizeExpr,
12412  IndexTypeQuals, BracketsRange);
12413 }
12414 
12415 template <typename Derived>
12417  QualType PointeeType, Expr *AddrSpaceExpr, SourceLocation AttributeLoc) {
12418  return SemaRef.BuildAddressSpaceAttr(PointeeType, AddrSpaceExpr,
12419  AttributeLoc);
12420 }
12421 
12422 template <typename Derived>
12423 QualType
12425  unsigned NumElements,
12426  VectorType::VectorKind VecKind) {
12427  // FIXME: semantic checking!
12428  return SemaRef.Context.getVectorType(ElementType, NumElements, VecKind);
12429 }
12430 
12431 template <typename Derived>
12433  QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc,
12434  VectorType::VectorKind VecKind) {
12435  return SemaRef.BuildVectorType(ElementType, SizeExpr, AttributeLoc);
12436 }
12437 
12438 template<typename Derived>
12440  unsigned NumElements,
12441  SourceLocation AttributeLoc) {
12442  llvm::APInt numElements(SemaRef.Context.getIntWidth(SemaRef.Context.IntTy),
12443  NumElements, true);
12444  IntegerLiteral *VectorSize
12445  = IntegerLiteral::Create(SemaRef.Context, numElements, SemaRef.Context.IntTy,
12446  AttributeLoc);
12447  return SemaRef.BuildExtVectorType(ElementType, VectorSize, AttributeLoc);
12448 }
12449 
12450 template<typename Derived>
12451 QualType
12453  Expr *SizeExpr,
12454  SourceLocation AttributeLoc) {
12455  return SemaRef.BuildExtVectorType(ElementType, SizeExpr, AttributeLoc);
12456 }
12457 
12458 template<typename Derived>
12460  QualType T,
12461  MutableArrayRef<QualType> ParamTypes,
12462  const FunctionProtoType::ExtProtoInfo &EPI) {
12463  return SemaRef.BuildFunctionType(T, ParamTypes,
12464  getDerived().getBaseLocation(),
12465  getDerived().getBaseEntity(),
12466  EPI);
12467 }
12468 
12469 template<typename Derived>
12471  return SemaRef.Context.getFunctionNoProtoType(T);
12472 }
12473 
12474 template<typename Derived>
12476  Decl *D) {
12477  assert(D && "no decl found");
12478  if (D->isInvalidDecl()) return QualType();
12479 
12480  // FIXME: Doesn't account for ObjCInterfaceDecl!
12481  TypeDecl *Ty;
12482  if (auto *UPD = dyn_cast<UsingPackDecl>(D)) {
12483  // A valid resolved using typename pack expansion decl can have multiple
12484  // UsingDecls, but they must each have exactly one type, and it must be
12485  // the same type in every case. But we must have at least one expansion!
12486  if (UPD->expansions().empty()) {
12487  getSema().Diag(Loc, diag::err_using_pack_expansion_empty)
12488  << UPD->isCXXClassMember() << UPD;
12489  return QualType();
12490  }
12491 
12492  // We might still have some unresolved types. Try to pick a resolved type
12493  // if we can. The final instantiation will check that the remaining
12494  // unresolved types instantiate to the type we pick.
12495  QualType FallbackT;
12496  QualType T;
12497  for (auto *E : UPD->expansions()) {
12498  QualType ThisT = RebuildUnresolvedUsingType(Loc, E);
12499  if (ThisT.isNull())
12500  continue;
12501  else if (ThisT->getAs<UnresolvedUsingType>())
12502  FallbackT = ThisT;
12503  else if (T.isNull())
12504  T = ThisT;
12505  else
12506  assert(getSema().Context.hasSameType(ThisT, T) &&
12507  "mismatched resolved types in using pack expansion");
12508  }
12509  return T.isNull() ? FallbackT : T;
12510  } else if (auto *Using = dyn_cast<UsingDecl>(D)) {
12511  assert(Using->hasTypename() &&
12512  "UnresolvedUsingTypenameDecl transformed to non-typename using");
12513 
12514  // A valid resolved using typename decl points to exactly one type decl.
12515  assert(++Using->shadow_begin() == Using->shadow_end());
12516  Ty = cast<TypeDecl>((*Using->shadow_begin())->getTargetDecl());
12517  } else {
12518  assert(isa<UnresolvedUsingTypenameDecl>(D) &&
12519  "UnresolvedUsingTypenameDecl transformed to non-using decl");
12520  Ty = cast<UnresolvedUsingTypenameDecl>(D);
12521  }
12522 
12523  return SemaRef.Context.getTypeDeclType(Ty);
12524 }
12525 
12526 template<typename Derived>
12528  SourceLocation Loc) {
12529  return SemaRef.BuildTypeofExprType(E, Loc);
12530 }
12531 
12532 template<typename Derived>
12534  return SemaRef.Context.getTypeOfType(Underlying);
12535 }
12536 
12537 template<typename Derived>
12539  SourceLocation Loc) {
12540  return SemaRef.BuildDecltypeType(E, Loc);
12541 }
12542 
12543 template<typename Derived>
12546  SourceLocation Loc) {
12547  return SemaRef.BuildUnaryTransformType(BaseType, UKind, Loc);
12548 }
12549 
12550 template<typename Derived>
12552  TemplateName Template,
12553  SourceLocation TemplateNameLoc,
12554  TemplateArgumentListInfo &TemplateArgs) {
12555  return SemaRef.CheckTemplateIdType(Template, TemplateNameLoc, TemplateArgs);
12556 }
12557 
12558 template<typename Derived>
12560  SourceLocation KWLoc) {
12561  return SemaRef.BuildAtomicType(ValueType, KWLoc);
12562 }
12563 
12564 template<typename Derived>
12566  SourceLocation KWLoc,
12567  bool isReadPipe) {
12568  return isReadPipe ? SemaRef.BuildReadPipeType(ValueType, KWLoc)
12569  : SemaRef.BuildWritePipeType(ValueType, KWLoc);
12570 }
12571 
12572 template<typename Derived>
12575  bool TemplateKW,
12576  TemplateDecl *Template) {
12577  return SemaRef.Context.getQualifiedTemplateName(SS.getScopeRep(), TemplateKW,
12578  Template);
12579 }
12580 
12581 template<typename Derived>
12584  SourceLocation TemplateKWLoc,
12585  const IdentifierInfo &Name,
12586  SourceLocation NameLoc,
12587  QualType ObjectType,
12588  NamedDecl *FirstQualifierInScope,
12589  bool AllowInjectedClassName) {
12591  TemplateName.setIdentifier(&Name, NameLoc);
12592  Sema::TemplateTy Template;
12593  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
12594  SS, TemplateKWLoc, TemplateName,
12595  ParsedType::make(ObjectType),
12596  /*EnteringContext=*/false,
12597  Template, AllowInjectedClassName);
12598  return Template.get();
12599 }
12600 
12601 template<typename Derived>
12604  SourceLocation TemplateKWLoc,
12605  OverloadedOperatorKind Operator,
12606  SourceLocation NameLoc,
12607  QualType ObjectType,
12608  bool AllowInjectedClassName) {
12609  UnqualifiedId Name;
12610  // FIXME: Bogus location information.
12611  SourceLocation SymbolLocations[3] = { NameLoc, NameLoc, NameLoc };
12612  Name.setOperatorFunctionId(NameLoc, Operator, SymbolLocations);
12613  Sema::TemplateTy Template;
12614  getSema().ActOnDependentTemplateName(/*Scope=*/nullptr,
12615  SS, TemplateKWLoc, Name,
12616  ParsedType::make(ObjectType),
12617  /*EnteringContext=*/false,
12618  Template, AllowInjectedClassName);
12619  return Template.get();
12620 }
12621 
12622 template<typename Derived>
12623 ExprResult
12625  SourceLocation OpLoc,
12626  Expr *OrigCallee,
12627  Expr *First,
12628  Expr *Second) {
12629  Expr *Callee = OrigCallee->IgnoreParenCasts();
12630  bool isPostIncDec = Second && (Op == OO_PlusPlus || Op == OO_MinusMinus);
12631 
12632  if (First->getObjectKind() == OK_ObjCProperty) {
12635  return SemaRef.checkPseudoObjectAssignment(/*Scope=*/nullptr, OpLoc, Opc,
12636  First, Second);
12637  ExprResult Result = SemaRef.CheckPlaceholderExpr(First);
12638  if (Result.isInvalid())
12639  return ExprError();
12640  First = Result.get();
12641  }
12642 
12643  if (Second && Second->getObjectKind() == OK_ObjCProperty) {
12644  ExprResult Result = SemaRef.CheckPlaceholderExpr(Second);
12645  if (Result.isInvalid())
12646  return ExprError();
12647  Second = Result.get();
12648  }
12649 
12650  // Determine whether this should be a builtin operation.
12651  if (Op == OO_Subscript) {
12652  if (!First->getType()->isOverloadableType() &&
12653  !Second->getType()->isOverloadableType())
12654  return getSema().CreateBuiltinArraySubscriptExpr(First,
12655  Callee->getLocStart(),
12656  Second, OpLoc);
12657  } else if (Op == OO_Arrow) {
12658  // -> is never a builtin operation.
12659  return SemaRef.BuildOverloadedArrowExpr(nullptr, First, OpLoc);
12660  } else if (Second == nullptr || isPostIncDec) {
12661  if (!First->getType()->isOverloadableType() ||
12662  (Op == OO_Amp && getSema().isQualifiedMemberAccess(First))) {
12663  // The argument is not of overloadable type, or this is an expression
12664  // of the form &Class::member, so try to create a built-in unary
12665  // operation.
12666  UnaryOperatorKind Opc
12667  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
12668 
12669  return getSema().CreateBuiltinUnaryOp(OpLoc, Opc, First);
12670  }
12671  } else {
12672  if (!First->getType()->isOverloadableType() &&
12673  !Second->getType()->isOverloadableType()) {
12674  // Neither of the arguments is an overloadable type, so try to
12675  // create a built-in binary operation.
12677  ExprResult Result
12678  = SemaRef.CreateBuiltinBinOp(OpLoc, Opc, First, Second);
12679  if (Result.isInvalid())
12680  return ExprError();
12681 
12682  return Result;
12683  }
12684  }
12685 
12686  // Compute the transformed set of functions (and function templates) to be
12687  // used during overload resolution.
12688  UnresolvedSet<16> Functions;
12689  bool RequiresADL;
12690 
12691  if (UnresolvedLookupExpr *ULE = dyn_cast<UnresolvedLookupExpr>(Callee)) {
12692  Functions.append(ULE->decls_begin(), ULE->decls_end());
12693  // If the overload could not be resolved in the template definition
12694  // (because we had a dependent argument), ADL is performed as part of
12695  // template instantiation.
12696  RequiresADL = ULE->requiresADL();
12697  } else {
12698  // If we've resolved this to a particular non-member function, just call
12699  // that function. If we resolved it to a member function,
12700  // CreateOverloaded* will find that function for us.
12701  NamedDecl *ND = cast<DeclRefExpr>(Callee)->getDecl();
12702  if (!isa<CXXMethodDecl>(ND))
12703  Functions.addDecl(ND);
12704  RequiresADL = false;
12705  }
12706 
12707  // Add any functions found via argument-dependent lookup.
12708  Expr *Args[2] = { First, Second };
12709  unsigned NumArgs = 1 + (Second != nullptr);
12710 
12711  // Create the overloaded operator invocation for unary operators.
12712  if (NumArgs == 1 || isPostIncDec) {
12713  UnaryOperatorKind Opc
12714  = UnaryOperator::getOverloadedOpcode(Op, isPostIncDec);
12715  return SemaRef.CreateOverloadedUnaryOp(OpLoc, Opc, Functions, First,
12716  RequiresADL);
12717  }
12718 
12719  if (Op == OO_Subscript) {
12720  SourceLocation LBrace;
12721  SourceLocation RBrace;
12722 
12723  if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Callee)) {
12724  DeclarationNameLoc NameLoc = DRE->getNameInfo().getInfo();
12728  NameLoc.CXXOperatorName.EndOpNameLoc);
12729  } else {
12730  LBrace = Callee->getLocStart();
12731  RBrace = OpLoc;
12732  }
12733 
12734  return SemaRef.CreateOverloadedArraySubscriptExpr(LBrace, RBrace,
12735  First, Second);
12736  }
12737 
12738  // Create the overloaded operator invocation for binary operators.
12740  ExprResult Result = SemaRef.CreateOverloadedBinOp(
12741  OpLoc, Opc, Functions, Args[0], Args[1], RequiresADL);
12742  if (Result.isInvalid())
12743  return ExprError();
12744 
12745  return Result;
12746 }
12747 
12748 template<typename Derived>
12749 ExprResult
12751  SourceLocation OperatorLoc,
12752  bool isArrow,
12753  CXXScopeSpec &SS,
12754  TypeSourceInfo *ScopeType,
12755  SourceLocation CCLoc,
12756  SourceLocation TildeLoc,
12757  PseudoDestructorTypeStorage Destroyed) {
12758  QualType BaseType = Base->getType();
12759  if (Base->isTypeDependent() || Destroyed.getIdentifier() ||
12760  (!isArrow && !BaseType->getAs<RecordType>()) ||
12761  (isArrow && BaseType->getAs<PointerType>() &&
12762  !BaseType->getAs<PointerType>()->getPointeeType()
12763  ->template getAs<RecordType>())){
12764  // This pseudo-destructor expression is still a pseudo-destructor.
12765  return SemaRef.BuildPseudoDestructorExpr(
12766  Base, OperatorLoc, isArrow ? tok::arrow : tok::period, SS, ScopeType,
12767  CCLoc, TildeLoc, Destroyed);
12768  }
12769 
12770  TypeSourceInfo *DestroyedType = Destroyed.getTypeSourceInfo();
12771  DeclarationName Name(SemaRef.Context.DeclarationNames.getCXXDestructorName(
12772  SemaRef.Context.getCanonicalType(DestroyedType->getType())));
12773  DeclarationNameInfo NameInfo(Name, Destroyed.getLocation());
12774  NameInfo.setNamedTypeInfo(DestroyedType);
12775 
12776  // The scope type is now known to be a valid nested name specifier
12777  // component. Tack it on to the end of the nested name specifier.
12778  if (ScopeType) {
12779  if (!ScopeType->getType()->getAs<TagType>()) {
12780  getSema().Diag(ScopeType->getTypeLoc().getBeginLoc(),
12781  diag::err_expected_class_or_namespace)
12782  << ScopeType->getType() << getSema().getLangOpts().CPlusPlus;
12783  return ExprError();
12784  }
12785  SS.Extend(SemaRef.Context, SourceLocation(), ScopeType->getTypeLoc(),
12786  CCLoc);
12787  }
12788 
12789  SourceLocation TemplateKWLoc; // FIXME: retrieve it from caller.
12790  return getSema().BuildMemberReferenceExpr(Base, BaseType,
12791  OperatorLoc, isArrow,
12792  SS, TemplateKWLoc,
12793  /*FIXME: FirstQualifier*/ nullptr,
12794  NameInfo,
12795  /*TemplateArgs*/ nullptr,
12796  /*S*/nullptr);
12797 }
12798 
12799 template<typename Derived>
12800 StmtResult
12802  SourceLocation Loc = S->getLocStart();
12803  CapturedDecl *CD = S->getCapturedDecl();
12804  unsigned NumParams = CD->getNumParams();
12805  unsigned ContextParamPos = CD->getContextParamPosition();
12807  for (unsigned I = 0; I < NumParams; ++I) {
12808  if (I != ContextParamPos) {
12809  Params.push_back(
12810  std::make_pair(
12811  CD->getParam(I)->getName(),
12812  getDerived().TransformType(CD->getParam(I)->getType())));
12813  } else {
12814  Params.push_back(std::make_pair(StringRef(), QualType()));
12815  }
12816  }
12817  getSema().ActOnCapturedRegionStart(Loc, /*CurScope*/nullptr,
12818  S->getCapturedRegionKind(), Params);
12819  StmtResult Body;
12820  {
12821  Sema::CompoundScopeRAII CompoundScope(getSema());
12822  Body = getDerived().TransformStmt(S->getCapturedStmt());
12823  }
12824 
12825  if (Body.isInvalid()) {
12826  getSema().ActOnCapturedRegionError();
12827  return StmtError();
12828  }
12829 
12830  return getSema().ActOnCapturedRegionEnd(Body.get());
12831 }
12832 
12833 } // end namespace clang
12834 
12835 #endif // LLVM_CLANG_LIB_SEMA_TREETRANSFORM_H
SourceLocation getRParenLoc() const
Definition: Stmt.h:1235
Expr * getInc()
Definition: Stmt.h:1290
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Definition: ExprObjC.h:595
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
Definition: ExprObjC.h:1543
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:1082
Represents a single C99 designator.
Definition: Expr.h:4361
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:1160
CXXRecordDecl * getNamingClass() const
Retrieve the naming class of this lookup.
Definition: ExprCXX.cpp:1297
SourceLocation getRBracLoc() const
Definition: Stmt.h:709
const BlockDecl * getBlockDecl() const
Definition: Expr.h:5065
This represents &#39;#pragma omp distribute simd&#39; composite directive.
Definition: StmtOpenMP.h:3216
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:4548
IdentifierInfo * getInputIdentifier(unsigned i) const
Definition: Stmt.h:1797
This represents &#39;#pragma omp master&#39; directive.
Definition: StmtOpenMP.h:1399
Represents a type that was referred to using an elaborated type keyword, e.g., struct S...
Definition: Type.h:4945
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition: Decl.h:1568
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2277
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Definition: ExprCXX.h:931
SourceLocation getRParenLoc() const
Definition: Stmt.h:1704
The null pointer literal (C++11 [lex.nullptr])
Definition: ExprCXX.h:593
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:2766
capture_iterator explicit_capture_end() const
Retrieve an iterator pointing past the end of the sequence of explicit lambda captures.
Definition: ExprCXX.cpp:992
This represents &#39;#pragma omp task&#39; directive.
Definition: StmtOpenMP.h:1739
This represents a GCC inline-assembly statement extension.
Definition: Stmt.h:1683
Represents a function declaration or definition.
Definition: Decl.h:1716
Represents a &#39;co_await&#39; expression while the type of the promise is dependent.
Definition: ExprCXX.h:4455
Expr * getArrayIndex(const Designator &D) const
Definition: Expr.cpp:3892
SourceLocation getForLoc() const
Definition: StmtCXX.h:195
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:64
This represents &#39;thread_limit&#39; clause in the &#39;#pragma omp ...&#39; directive.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Definition: Sema.h:226
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:2376
The receiver is an object instance.
Definition: ExprObjC.h:1076
Expr * getLHS() const
Definition: Expr.h:3474
bool hasExplicitTemplateArgs() const
Determines whether this expression had explicit template arguments.
Definition: ExprCXX.h:2782
const Stmt * getElse() const
Definition: Stmt.h:1014
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprCXX.h:3727
unsigned getNumInputs() const
Definition: Stmt.h:1599
Sema::ConditionResult TransformCondition(SourceLocation Loc, VarDecl *Var, Expr *Expr, Sema::ConditionKind Kind)
Transform the specified condition.
SourceLocation getOpLoc() const
Definition: ExprObjC.h:1496
SourceLocation getRParenLoc() const
Definition: Expr.h:2452
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Definition: ExprObjC.h:352
SourceLocation getLocEnd() const LLVM_READONLY
Returns the ending location of the clause.
Definition: OpenMPClause.h:71
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Definition: Expr.h:1151
const FunctionProtoType * getFunctionType() const
getFunctionType - Return the underlying function type for this block.
Definition: Expr.cpp:2080
CompoundStmt * getBlock() const
Definition: Stmt.h:2026
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:1303
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:497
PtrTy get() const
Definition: Ownership.h:81
PointerType - C99 6.7.5.1 - Pointer Declarators.
Definition: Type.h:2393
StmtResult RebuildCaseStmt(SourceLocation CaseLoc, Expr *LHS, SourceLocation EllipsisLoc, Expr *RHS, SourceLocation ColonLoc)
Build a new case statement.
QualType getPointeeType() const
Definition: Type.h:2406
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:1131
Represents the dependent type named by a dependently-scoped typename using declaration, e.g.
Definition: Type.h:3886
Stores the type being destroyed by a pseudo-destructor expression.
Definition: ExprCXX.h:2224
A (possibly-)qualified type.
Definition: Type.h:655
Keeps information about an identifier in a nested-name-spec.
Definition: Sema.h:5365
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:2596
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1347
Derived & getDerived()
Retrieves a reference to the derived class.
ArrayRef< OMPClause * > clauses()
Definition: StmtOpenMP.h:262
Expr * getCond() const
Definition: Expr.h:3881
QualType TransformType(QualType T)
Transforms the given type into another type.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
Definition: Expr.h:2385
ObjCMethodDecl * getAtIndexMethodDecl() const
Definition: ExprObjC.h:875
Instantiation or recovery rebuild of a for-range statement.
Definition: Sema.h:3785
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:786
SourceLocation getLParen() const
Get the location of the left parentheses &#39;(&#39;.
Definition: Expr.h:1777
const Expr * getSubExpr() const
Definition: ExprCXX.h:1050
capture_iterator capture_end() const
Retrieve an iterator pointing past the end of the sequence of lambda captures.
Definition: ExprCXX.cpp:980
SourceLocation getCommaLoc()
Get location of &#39;,&#39;.
Definition: OpenMPClause.h:902
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:404
Expr * getCond()
Definition: Stmt.h:1176
TemplateParameterList * GLTemplateParameterList
If this is a generic lambda, and the template parameter list has been created (from the AutoTemplateP...
Definition: ScopeInfo.h:813
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:3737
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:2421
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
Definition: Sema.h:3016
CompoundStmt * getSubStmt()
Definition: Expr.h:3670
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:3240
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2340
NestedNameSpecifierLoc getTemplateQualifierLoc() const
Definition: TemplateBase.h:532
StmtResult RebuildCXXTryStmt(SourceLocation TryLoc, Stmt *TryBlock, ArrayRef< Stmt *> Handlers)
Build a new C++ try statement.
StmtResult RebuildSwitchStmtBody(SourceLocation SwitchLoc, Stmt *Switch, Stmt *Body)
Attach the body to the switch statement.
unsigned getNumAsmToks()
Definition: Stmt.h:1890
Expr * getUnderlyingExpr() const
Definition: Type.h:4021
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:2341
static ConditionResult ConditionError()
Definition: Sema.h:9822
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
Definition: ExprCXX.h:2869
const TemplateArgumentLoc * operator->() const
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1443
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:106
bool hasExplicitResultType() const
Whether this lambda had its result type explicitly specified.
Definition: ExprCXX.h:1851
StmtResult FinishCXXForRangeStmt(Stmt *ForRange, Stmt *Body)
Attach body to a C++0x range-based for statement.
bool isThrownVariableInScope() const
Determines whether the variable thrown by this expression (if any!) is within the innermost try block...
Definition: ExprCXX.h:1060
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:1391
bool isLeftFold() const
Does this produce a left-associated sequence of operators?
Definition: ExprCXX.h:4296
Represents a &#39;co_return&#39; statement in the C++ Coroutines TS.
Definition: StmtCXX.h:442
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:2373
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
Expr * getDimensionExpression() const
Definition: ExprCXX.h:2560
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
Definition: StmtObjC.h:230
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2484
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:108
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:974
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:3015
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
Definition: Expr.h:2062
SourceLocation getRParenLoc() const
Definition: Expr.h:3722
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Definition: Type.cpp:497
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:3041
TypeLoc getValueLoc() const
Definition: TypeLoc.h:2336
ObjCMethodDecl * setAtIndexMethodDecl() const
Definition: ExprObjC.h:879
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:633
QualType RebuildEnumType(EnumDecl *Enum)
Build a new Enum type.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:1019
unsigned getNumOutputs() const
Definition: Stmt.h:1577
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:2090
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:5020
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:954
This represents &#39;#pragma omp for simd&#39; directive.
Definition: StmtOpenMP.h:1149
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:534
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:6186
Expr * getBase() const
Definition: Expr.h:2590
const StringLiteral * getAsmString() const
Definition: Stmt.h:1709
TypeSourceInfo * getTypeSourceInfo() const
Definition: Expr.h:2788
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Definition: Sema.h:1281
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:1197
TemplateParameterList * TransformTemplateParameterList(TemplateParameterList *TPL)
This represents &#39;#pragma omp teams distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3627
Stmt * getHandlerBlock() const
Definition: StmtCXX.h:54
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2130
ObjCMethodDecl * getImplicitPropertySetter() const
Definition: ExprObjC.h:698
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:4735
FunctionDecl * getOperatorNew() const
Definition: ExprCXX.h:2015
WrittenBuiltinSpecs & getWrittenBuiltinSpecs()
Definition: TypeLoc.h:570
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Definition: ExprCXX.h:2824
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:242
QualType getDeducedTemplateSpecializationType(TemplateName Template, QualType DeducedType, bool IsDependent) const
C++17 deduced class template specialization type.
const Expr * getSubExpr() const
Definition: Expr.h:3972
DeclarationNameInfo getNameInfo() const
Retrieve the name of the entity we&#39;re testing for, along with location information.
Definition: StmtCXX.h:280
Defines the C++ template declaration subclasses.
Opcode getOpcode() const
Definition: Expr.h:3184
StringRef P
CapturedStmt * getInnermostCapturedStmt()
Get innermost captured statement for the construct.
Definition: StmtOpenMP.h:228
Represents a C++11 auto or C++14 decltype(auto) type.
Definition: Type.h:4562
SourceLocation getIdentLoc() const
Definition: Stmt.h:891
Represents an attribute applied to a statement.
Definition: Stmt.h:918
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:1751
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:2610
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies this name, if any.
Definition: StmtCXX.h:276
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:1428
This represents &#39;#pragma omp target teams distribute&#39; combined directive.
Definition: StmtOpenMP.h:3764
Represents Objective-C&#39;s @throw statement.
Definition: StmtObjC.h:323
bool requiresZeroInitialization() const
Whether this construction first requires zero-initialization before the initializer is called...
Definition: ExprCXX.h:1382
void setParams(ArrayRef< ParmVarDecl *> NewParamInfo)
Definition: Decl.cpp:4151
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:1139
QualType RebuildTypeOfExprType(Expr *Underlying, SourceLocation Loc)
Build a new typeof(expr) type.
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2160
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:2668
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:64
Represent a C++ namespace.
Definition: Decl.h:514
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4486
Represents a call to a C++ constructor.
Definition: ExprCXX.h:1292
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
Definition: ExprObjC.h:822
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:3057
FPOptions getFPFeatures() const
Definition: Expr.h:3317
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Definition: ExprCXX.h:2507
TypeLoc getOriginalLoc() const
Definition: TypeLoc.h:1207
bool getIsCXXTry() const
Definition: Stmt.h:2066
SourceLocation getLParenLoc() const
Definition: Expr.h:3104
SourceLocation getLocStart() const LLVM_READONLY
Definition: Expr.h:4786
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:367
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:51
QualType TransformTemplateSpecializationType(TypeLocBuilder &TLB, TemplateSpecializationTypeLoc TL, TemplateName Template)
ExprResult RebuildCXXConstCastExpr(SourceLocation OpLoc, SourceLocation LAngleLoc, TypeSourceInfo *TInfo, SourceLocation RAngleLoc, SourceLocation LParenLoc, Expr *SubExpr, SourceLocation RParenLoc)
Build a new C++ const_cast expression.
Expr * getCondition() const
Returns condition.
Definition: OpenMPClause.h:310
SourceLocation getAttributeLoc() const
Definition: Type.h:3116
This represents &#39;#pragma omp parallel for&#39; directive.
Definition: StmtOpenMP.h:1520
MS property subscript expression.
Definition: ExprCXX.h:834
OMPClause * RebuildOMPPriorityClause(Expr *Priority, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;priority&#39; clause.
SourceLocation getGotoLoc() const
Definition: Stmt.h:1381
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:3892
SourceLocation getLocEnd() const LLVM_READONLY
Definition: DeclBase.h:414
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1896
This represents &#39;#pragma omp target teams distribute parallel for&#39; combined directive.
Definition: StmtOpenMP.h:3832
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:2477
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
Definition: ExprCXX.h:4150
SourceLocation getAccessorLoc() const
Definition: Expr.h:5013
ExprResult RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op, SourceLocation OpLoc, Expr *Callee, Expr *First, Expr *Second)
Build a new overloaded operator call expression.
Expr * getAlignment()
Returns alignment.
SourceLocation getLocalBeginLoc() const
Retrieve the location of the beginning of this component of the nested-name-specifier.
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:985
SourceLocation getRParenLoc() const
getRParenLoc - Return the location of final right parenthesis.
Definition: Expr.h:3809
SourceLocation getEndLoc() const
Get the end source location.
Definition: TypeLoc.cpp:227
SourceLocation getSecondScheduleModifierLoc() const
Get the second modifier location.
Definition: OpenMPClause.h:897
QualType getElementType() const
Definition: Type.h:2703
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "while" statement, if any.
Definition: Stmt.cpp:901
TemplateName getTemplateName() const
Retrieve the name of the template that we are deducing.
Definition: Type.h:4616
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:196
Expr * getIndexExpr(unsigned Idx)
Definition: Expr.h:2090
Stmt * getExceptionHandler() const
Definition: StmtCXX.h:386
DeclarationNameInfo TransformDeclarationNameInfo(const DeclarationNameInfo &NameInfo)
Transform the given declaration name.
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1861
Expr * getDeallocate() const
Definition: StmtCXX.h:396
An identifier, stored as an IdentifierInfo*.
This represents &#39;#pragma omp target exit data&#39; directive.
Definition: StmtOpenMP.h:2431
Stmt * getSubStmt()
Definition: Stmt.h:843
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:572
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:10734
OMPClause * RebuildOMPDeviceClause(Expr *Device, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;device&#39; clause.
Represents a variable declaration or definition.
Definition: Decl.h:814
ActionResult< Stmt * > StmtResult
Definition: Ownership.h:268
const Derived & getDerived() const
Retrieves a reference to the derived class.
This represents clause &#39;private&#39; in the &#39;#pragma omp ...&#39; directives.
SourceLocation getLParenLoc() const
Definition: Stmt.h:1305
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:1460
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1752
void removeObjCLifetime()
Definition: Type.h:349
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:2752
This represents &#39;num_threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:384
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:6190
SourceLocation getOperatorLoc() const
Retrieve the location of the &#39;.&#39; or &#39;->&#39; operator.
Definition: ExprCXX.h:2341
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:2244
UnresolvedLookupExpr * getOperatorCoawaitLookup() const
Definition: ExprCXX.h:4482
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:6526
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Definition: Type.h:6466
varlist_range varlists()
Definition: OpenMPClause.h:209
Records and restores the FP_CONTRACT state on entry/exit of compound statements.
Definition: Sema.h:1182
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:2470
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:3551
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
Stmt * getResultDecl() const
Definition: StmtCXX.h:402
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:4598
TypeSourceInfo * InventTypeSourceInfo(QualType T)
Fakes up a TypeSourceInfo for a type.
SourceLocation getColonLoc() const
Definition: Expr.h:3419
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:1488
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
SourceLocation getLeftLoc() const
Definition: ExprObjC.h:1384
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:5093
A namespace, stored as a NamespaceDecl*.
SourceLocation getColonLoc() const
Return the location of &#39;:&#39;.
Definition: OpenMPClause.h:307
DeclarationName getName() const
Gets the name looked up.
Definition: ExprCXX.h:2743
reference front() const
Definition: DeclBase.h:1238
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Definition: ExprCXX.h:624
TypeLoc getNamedTypeLoc() const
Definition: TypeLoc.h:2041
bool isInvalidDecl() const
Definition: DeclBase.h:549
SourceLocation getIfLoc() const
Definition: Stmt.h:1021
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:4111
unsigned getNumPlacementArgs() const
Definition: ExprCXX.h:2029
TypeSourceInfo * getArgumentTypeInfo() const
Definition: Expr.h:2174
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:2897
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:2006
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:1490
A C++ throw-expression (C++ [except.throw]).
Definition: ExprCXX.h:1028
Expr * getExprOperand() const
Definition: ExprCXX.h:728
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Definition: ExprCXX.h:3092
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:2473
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
Represents a parameter to a function.
Definition: Decl.h:1535
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:153
Represents the result of substituting a type for a template type parameter.
Definition: Type.h:4417
TemplateArgumentLocContainerIterator operator++(int)
SourceLocation getRParenLoc() const
Definition: Expr.h:4911
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:867
bool isUnset() const
Definition: Ownership.h:172
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2021
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:154
CXXRecordDecl * getLambdaClass() const
Retrieve the class that corresponds to the lambda.
Definition: ExprCXX.cpp:1014
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1027
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3888
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:449
ObjCPropertyDecl * getExplicitProperty() const
Definition: ExprObjC.h:688
PipeType - OpenCL20.
Definition: Type.h:5819
bool needsExtraLocalData() const
Definition: TypeLoc.h:577
A C++ static_cast expression (C++ [expr.static.cast]).
Definition: ExprCXX.h:306
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:722
ExprResult RebuildCXXNoexceptExpr(SourceRange Range, Expr *Arg)
Build a new noexcept expression.
Expr * getExprOperand() const
Definition: ExprCXX.h:941
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:3730
const Stmt * getSubStmt() const
Definition: StmtObjC.h:368
SourceLocation getAttributeLoc() const
Definition: Type.h:3001
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:269
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:281
LabelStmt - Represents a label, which has a substatement.
Definition: Stmt.h:875
Represents a struct/union/class.
Definition: Decl.h:3570
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:4286
unsigned varlist_size() const
Definition: OpenMPClause.h:206
QualType RebuildDependentNameType(ElaboratedTypeKeyword Keyword, SourceLocation KeywordLoc, NestedNameSpecifierLoc QualifierLoc, const IdentifierInfo *Id, SourceLocation IdLoc, bool DeducedTSTContext)
Build a new typename type that refers to an identifier.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:297
TypeSourceInfo * getEncodedTypeSourceInfo() const
Definition: ExprObjC.h:419
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:2352
SourceLocation getKeywordLoc() const
Definition: StmtCXX.h:462
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
SourceLocation getColonLoc() const
Definition: Stmt.h:849
One of these records is kept for each identifier that is lexed.
Stmt * getBody()
Definition: Stmt.h:1226
Expr * GetTemporaryExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue...
Definition: ExprCXX.h:4191
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:74
SourceLocation getTildeLoc() const
Retrieve the location of the &#39;~&#39;.
Definition: ExprCXX.h:2359
SourceLocation getRParenLoc() const
Definition: Expr.h:5404
Step
Definition: OpenMPClause.h:146
An element in an Objective-C dictionary literal.
Definition: ExprObjC.h:247
This represents &#39;#pragma omp parallel&#39; directive.
Definition: StmtOpenMP.h:278
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Definition: Expr.h:3701
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:5355
SourceLocation getRParen() const
Get the location of the right parentheses &#39;)&#39;.
Definition: Expr.h:1781
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:4522
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:289
ArrayRef< QualType > getParamTypes() const
Definition: Type.h:3675
The results of name lookup within a DeclContext.
Definition: DeclBase.h:1190
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:3958
TypeSourceInfo * getTypeSourceInfo() const
Definition: TemplateBase.h:507
TypeLoc getInnerLoc() const
Definition: TypeLoc.h:1187
QualType BuildParenType(QualType T)
Build a paren type including T.
Definition: SemaType.cpp:1764
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
ExprResult RebuildInitList(SourceLocation LBraceLoc, MultiExprArg Inits, SourceLocation RBraceLoc)
Build a new initializer list expression.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1910
bool isExplicitProperty() const
Definition: ExprObjC.h:686
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2547
bool isSpelledAsLValue() const
Definition: Type.h:2545
SourceLocation getAmpAmpLoc() const
Definition: Expr.h:3622
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:529
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:13724
Represents a member of a struct/union/class.
Definition: Decl.h:2534
TemplateName getTemplateName() const
Retrieve the name of the template that we are specializing.
Definition: Type.h:4724
void setBlockMissingReturnType(bool val)
Definition: Decl.h:3997
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:3607
Represents a place-holder for an object not to be initialized by anything.
Definition: Expr.h:4584
SourceLocation getAttrNameLoc() const
The location of the attribute name, i.e.
Definition: TypeLoc.h:897
VarDecl * getPromiseDecl() const
Definition: StmtCXX.h:375
ArrayRef< Expr * > getAllExprs() const
Definition: Stmt.h:1936
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
Definition: Decl.h:1588
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:589
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
Definition: TypeTraits.h:97
CompoundStmt * getBody() const
Retrieve the body of the lambda.
Definition: ExprCXX.cpp:1029
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:1979
const Expr * getRetValue() const
Definition: Stmt.cpp:928
SourceLocation getLabelLoc() const
Definition: Expr.h:3624
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2075
bool hasExplicitTemplateArgs() const
Determines whether the member name was followed by an explicit template argument list.
Definition: Expr.h:2655
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:4197
SourceLocation getOperatorLoc() const
Definition: Expr.h:2201
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:3918
bool isReferenceType() const
Definition: Type.h:6125
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:3107
SourceLocation getDefaultKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:658
Interesting information about a specific parameter that can&#39;t simply be reflected in parameter&#39;s type...
Definition: Type.h:3453
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2071
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:3352
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Definition: Expr.h:936
bool isInvalid() const
Definition: Sema.h:9811
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
Definition: ExprCXX.h:3539
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:687
qual_iterator qual_begin() const
Definition: Type.h:5256
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:1439
QualType RebuildDependentVectorType(QualType ElementType, Expr *SizeExpr, SourceLocation AttributeLoc, VectorType::VectorKind)
Build a new potentially dependently-sized extended vector type given the element type and number of e...
ExprResult RebuildCXXThrowExpr(SourceLocation ThrowLoc, Expr *Sub, bool IsThrownVariableInScope)
Build a new C++ throw expression.
std::pair< VarDecl *, Expr * > get() const
Definition: Sema.h:9812
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Definition: Expr.h:4988
ArrayRef< SourceLocation > getProtocolLocs() const
Definition: TypeLoc.h:806
LookupResultKind getResultKind() const
Definition: Lookup.h:310
OpenMPDirectiveKind getDirectiveKind() const
Definition: StmtOpenMP.h:246
Expr * getSafelen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:483
OMPClause * RebuildOMPCollapseClause(Expr *Num, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;collapse&#39; clause.
Expr * getSubExpr()
Definition: Expr.h:2892
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:4307
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1954
This represents &#39;#pragma omp barrier&#39; directive.
Definition: StmtOpenMP.h:1851
SourceLocation getQuestionLoc() const
Definition: Expr.h:3418
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
Definition: ExprObjC.h:177
void ExpandingFunctionParameterPack(ParmVarDecl *Pack)
Note to the derived class when a function parameter pack is being expanded.
SourceRange getSourceRange() const LLVM_READONLY
Expr * getNumTeams()
Return NumTeams number.
Represents a reference to a non-type template parameter pack that has been substituted with a non-tem...
Definition: ExprCXX.h:4004
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:1446
bool isAssignmentOp() const
Definition: Expr.h:3271
LambdaCaptureDefault getCaptureDefault() const
Determine the default capture kind for this lambda.
Definition: ExprCXX.h:1720
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Definition: Lookup.h:56
StmtResult RebuildObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *Object, Stmt *Body)
Build a new Objective-C @synchronized statement.
bool hasExplicitTemplateArgs() const
Determines whether this lookup had explicit template arguments.
Definition: ExprCXX.h:3031
StmtResult RebuildObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Build a new Objective-C @autoreleasepool statement.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1853
IdentifierTable & Idents
Definition: ASTContext.h:545
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:5908
SourceLocation getCatchLoc() const
Definition: StmtCXX.h:51
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Definition: Specifiers.h:110
OMPClause * RebuildOMPFlushClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;flush&#39; pseudo clause.
bool TryExpandParameterPacks(SourceLocation EllipsisLoc, SourceRange PatternRange, ArrayRef< UnexpandedParameterPack > Unexpanded, bool &ShouldExpand, bool &RetainExpansion, Optional< unsigned > &NumExpansions)
Determine whether we should expand a pack expansion with the given set of parameter packs into separa...
StmtResult ActOnAttributedStmt(SourceLocation AttrLoc, ArrayRef< const Attr *> Attrs, Stmt *SubStmt)
Definition: SemaStmt.cpp:518
Represents Objective-C&#39;s @catch statement.
Definition: StmtObjC.h:76
Expr * getLHS() const
Definition: ExprCXX.h:4287
DeclClass * getAsSingle() const
Definition: Lookup.h:496
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
OpenMPDistScheduleClauseKind
OpenMP attributes for &#39;dist_schedule&#39; clause.
Definition: OpenMPKinds.h:100
IndirectGotoStmt - This represents an indirect goto.
Definition: Stmt.h:1365
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:4050
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:671
This represents &#39;#pragma omp distribute parallel for&#39; composite directive.
Definition: StmtOpenMP.h:3067
VarDecl * RebuildExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *Declarator, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id)
Build a new C++ exception declaration.
bool isArrow() const
Definition: ExprObjC.h:567
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:872
This represents &#39;#pragma omp teams distribute parallel for simd&#39; composite directive.
Definition: StmtOpenMP.h:3556
BinaryOperatorKind
Expr * getArraySize()
Definition: ExprCXX.h:2022
Represents a C++ unqualified-id that has been parsed.
Definition: DeclSpec.h:922
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
UnresolvedUsingTypenameDecl * getDecl() const
Definition: Type.h:3897
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2297
ForStmt - This represents a &#39;for (init;cond;inc)&#39; stmt.
Definition: Stmt.h:1256
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:738
Represents the results of name lookup.
Definition: Lookup.h:47
PtrTy get() const
Definition: Ownership.h:174
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ExprResult RebuildMemberExpr(Expr *Base, SourceLocation OpLoc, bool isArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &MemberNameInfo, ValueDecl *Member, NamedDecl *FoundDecl, const TemplateArgumentListInfo *ExplicitTemplateArgs, NamedDecl *FirstQualifierInScope)
Build a new member access expression.
ExprResult RebuildUnaryExprOrTypeTrait(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a new sizeof, alignof or vec_step expression with a type argument.
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:2293
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:2197
friend bool operator!=(const TemplateArgumentLocInventIterator &X, const TemplateArgumentLocInventIterator &Y)
Expr * getBaseExpr() const
Definition: ExprObjC.h:869
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
OMPClause * RebuildOMPScheduleClause(OpenMPScheduleClauseModifier M1, OpenMPScheduleClauseModifier M2, OpenMPScheduleClauseKind Kind, Expr *ChunkSize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation M1Loc, SourceLocation M2Loc, SourceLocation KindLoc, SourceLocation CommaLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;schedule&#39; clause.
bool isElidable() const
Whether this construction is elidable.
Definition: ExprCXX.h:1361
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2184
Expr * getOperand() const
Definition: ExprCXX.h:3721
const Expr * getThrowExpr() const
Definition: StmtObjC.h:335
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:2047
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:552
SourceLocation getLocation() const
Definition: ExprCXX.h:2248
ExprResult ActOnDesignatedInitializer(Designation &Desig, SourceLocation Loc, bool GNUSyntax, ExprResult Init)
Definition: SemaInit.cpp:2851
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:892
SourceLocation getLBracLoc() const
Definition: Stmt.h:708
QualType RebuildRecordType(RecordDecl *Record)
Build a new class/struct/union type.
ExprResult TransformAddressOfOperand(Expr *E)
The operand of a unary address-of operator has special rules: it&#39;s allowed to refer to a non-static m...
SourceLocation getRParenLoc() const
Definition: StmtCXX.h:198
Expr * getInitializer()
The initializer of this new-expression.
Definition: ExprCXX.h:2060
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:1493
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:2759
Stmt * getBody()
Definition: Stmt.h:1291
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2067
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:284
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
Definition: Type.h:1711
QualType FunctionType
BlockType - The function type of the block, if one was given.
Definition: ScopeInfo.h:704
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: ExprCXX.h:3485
Represents a declaration of a type.
Definition: Decl.h:2829
A builtin binary operation expression such as "x + y" or "x <= y".
Definition: Expr.h:3143
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:1494
const Expr * getAssocExpr(unsigned i) const
Definition: Expr.h:4913
Stmt * getInit()
Definition: Stmt.h:1270
Expr * getOutputExpr(unsigned i)
Definition: Stmt.cpp:421
SourceLocation getLocStart() const LLVM_READONLY
Returns starting location of directive kind.
Definition: StmtOpenMP.h:168
SourceLocation getLParenLoc() const
Definition: TypeLoc.h:1431
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1865
SourceLocation getThrowLoc() const
Definition: ExprCXX.h:1053
const StringLiteral * getInputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1810
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:2646
CXXForRangeStmt - This represents C++0x [stmt.ranged]&#39;s ranged for statement, represented as &#39;for (ra...
Definition: StmtCXX.h:130
CXXRecordDecl * getDecl() const
Definition: Type.cpp:3274
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:2695
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:2686
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:608
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Definition: Expr.cpp:2544
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:4513
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:2156
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3454
Expr * getRHS() const
Definition: ExprCXX.h:4288
Expr * getSizeExpr() const
Definition: Type.h:2847
const CallExpr * getConfig() const
Definition: ExprCXX.h:218
bool isArrow() const
Definition: ExprCXX.h:818
Wrapper for source info for ObjC interfaces.
Definition: TypeLoc.h:1118
FPOptions getFPFeatures() const
Definition: ExprCXX.h:149
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:3800
NonTagKind
Common ways to introduce type names without a tag for use in diagnostics.
Definition: Sema.h:2165
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Definition: Expr.h:5444
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:332
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
SourceLocation getCaretLocation() const
Definition: Expr.cpp:2086
Expr * getCond()
Definition: Stmt.h:1289
This represents &#39;#pragma omp teams&#39; directive.
Definition: StmtOpenMP.h:2629
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:4938
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:1184
Helper class for OffsetOfExpr.
Definition: Expr.h:1921
Expr * getOperand() const
Definition: ExprCXX.h:4480
This represents &#39;#pragma omp teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3486
Represents binding an expression to a temporary.
Definition: ExprCXX.h:1245
StringLiteral * getClobberStringLiteral(unsigned i)
Definition: Stmt.h:1844
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:91
Expr * Key
The key for the dictionary element.
Definition: ExprObjC.h:249
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3983
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:1057
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1005
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
Definition: ExprCXX.h:1649
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:752
NestedNameSpecifierLoc getQualifierLoc() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name, with source-location information.
Definition: Expr.h:1080
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:2989
SourceLocation getTryLoc() const
Definition: Stmt.h:2063
ExprResult RebuildCXXUnresolvedConstructExpr(TypeSourceInfo *TSInfo, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, bool ListInitialization)
Build a new object-construction expression.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Definition: ExprCXX.h:3300
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1419
Represents the body of a CapturedStmt, and serves as its DeclContext.
Definition: Decl.h:4037
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "for" statement, if any.
Definition: Stmt.cpp:839
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:1836
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Definition: Lookup.h:415
QualType RebuildReferenceType(QualType ReferentType, bool LValue, SourceLocation Sigil)
Build a new reference type given the type it references.
Member name lookup, which finds the names of class/struct/union members.
Definition: Sema.h:3024
bool isInitCapture(const LambdaCapture *Capture) const
Determine whether one of this lambda&#39;s captures is an init-capture.
Definition: ExprCXX.cpp:971
StmtClass
Definition: Stmt.h:68
const Stmt * getBody() const
Definition: Expr.cpp:2089
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1892
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:2124
Expr * getSizeExpr() const
Definition: Type.h:2904
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO, bool Postfix)
Retrieve the unary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1160
A default argument (C++ [dcl.fct.default]).
Definition: ExprCXX.h:1087
Stmt * getInit()
Definition: Stmt.h:1007
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1738
QualType getPointeeTypeAsWritten() const
Definition: Type.h:2548
bool isTypeOperand() const
Definition: ExprCXX.h:924
Expr * getSizeExpr() const
Definition: Type.h:3114
Stmt * getReturnStmt() const
Definition: StmtCXX.h:403
QualType getElementType() const
Definition: Type.h:3000
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1942
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:3642
RAII object used to change the argument pack substitution index within a Sema object.
Definition: Sema.h:7315
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:2984
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:3420
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:986
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
ObjCIvarDecl * getDecl()
Definition: ExprObjC.h:559
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:225
SourceLocation getRParenLoc() const
Retrieve the location of the right parentheses (&#39;)&#39;) that follows the argument list.
Definition: ExprCXX.h:3234
A helper class for building up ExtParameterInfos.
Definition: Sema.h:7683
TypeSourceInfo * getAllocatedTypeSourceInfo() const
Definition: ExprCXX.h:1994
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:1545
NestedNameSpecifierLoc getQualifierLoc() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name...
Definition: Expr.h:2615
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:2556
ExprResult RebuildCXXTemporaryObjectExpr(TypeSourceInfo *TSInfo, SourceLocation LParenOrBraceLoc, MultiExprArg Args, SourceLocation RParenOrBraceLoc, bool ListInitialization)
Build a new object-construction expression.
SourceLocation getTemplateKeywordLoc() const
Definition: TypeLoc.h:1625
bool isArrayForm() const
Definition: ExprCXX.h:2186
Expr ** getSubExprs()
Retrieve the array of expressions.
Definition: Expr.h:3740
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Definition: StmtObjC.h:212
Represents a K&R-style &#39;int foo()&#39; function, which has no information available about its arguments...
Definition: Type.h:3397
Expr * getAddrSpaceExpr() const
Definition: Type.h:2955
helper_expr_const_range reduction_ops() const
This represents &#39;#pragma omp target parallel for simd&#39; directive.
Definition: StmtOpenMP.h:3284
llvm::Optional< bool > getKnownValue() const
Definition: Sema.h:9816
OpenMP 4.0 [2.4, Array Sections].
Definition: ExprOpenMP.h:45
StmtResult TransformSEHHandler(Stmt *Handler)
ConditionalOperator - The ?: ternary operator.
Definition: Expr.h:3429
An error occurred.
Definition: Sema.h:4504
SourceLocation getBuiltinLoc() const
Definition: TypeLoc.h:550
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:1616
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:277
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:1377
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Definition: ExprCXX.h:2275
CompoundStmt - This represents a group of statements like { stmt stmt }.
Definition: Stmt.h:616
OpenMPDefaultClauseKind getDefaultKind() const
Returns kind of the clause.
Definition: OpenMPClause.h:655
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3432
SourceLocation getRBracket() const
Definition: ExprObjC.h:858
void setParensRange(SourceRange Range)
Definition: TypeLoc.h:1966
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:5380
CompoundStmt * getSubStmt() const
Retrieve the compound statement that will be included in the program only if the existence of the sym...
Definition: StmtCXX.h:284
This represents &#39;#pragma omp taskgroup&#39; directive.
Definition: StmtOpenMP.h:1939
Expr * getSimdlen() const
Return safe iteration space distance.
Definition: OpenMPClause.h:537
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:1355
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:3699
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:3476
OpenMPClauseKind getClauseKind() const
Returns kind of OpenMP clause (private, shared, reduction, etc.).
Definition: OpenMPClause.h:81
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:207
SourceLocation getNameLoc() const
Definition: TypeLoc.h:2087
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:2134
ArraySizeModifier
Capture whether this is a normal array (e.g.
Definition: Type.h:2674
SourceLocation getTryLoc() const
Definition: StmtCXX.h:95
bool isConstexpr() const
Definition: Stmt.h:1026
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:874
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
SourceLocation getLocation() const
Definition: Expr.h:1067
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:5324
Represents a call to the builtin function __builtin_va_arg.
Definition: Expr.h:3954
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2192
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
Definition: ExprCXX.h:1112
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:725
SourceLocation getLabelLoc() const
Definition: Stmt.h:1346
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:339
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:4098
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:4310
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2168
This represents &#39;#pragma omp distribute&#39; directive.
Definition: StmtOpenMP.h:2940
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
Definition: Specifiers.h:136
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:2882
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:1620
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1618
SourceLocation getDestroyedTypeLoc() const
Retrieve the starting location of the type being destroyed.
Definition: ExprCXX.h:2383
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:190
SourceLocation getFinallyLoc() const
Definition: Stmt.h:2023
TypeSourceInfo * getUnderlyingTInfo() const
Definition: TypeLoc.h:1950
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:2164
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type...
Definition: ExprCXX.h:1873
Retains information about a block that is currently being parsed.
Definition: ScopeInfo.h:694
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:3627
const Stmt * getAssociatedStmt() const
Returns statement associated with the directive.
Definition: StmtOpenMP.h:198
CXXMethodDecl * CallOperator
The lambda&#39;s compiler-generated operator().
Definition: ScopeInfo.h:774
Expr * getCond() const
Definition: Expr.h:3463
Type source information for an attributed type.
Definition: TypeLoc.h:859
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:956
Pepresents a block literal declaration, which is like an unnamed FunctionDecl.
Definition: Decl.h:3860
unsigned getFunctionScopeDepth() const
Definition: Decl.h:1582
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2140
llvm::MutableArrayRef< Designator > designators()
Definition: Expr.h:4491
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:677
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:2600
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:637
ExprResult RebuildCoyieldExpr(SourceLocation CoyieldLoc, Expr *Result)
Build a new co_yield expression.
Expr - This represents one expression.
Definition: Expr.h:106
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:1433
SourceLocation getLocalRangeEnd() const
Definition: TypeLoc.h:1423
SourceLocation getElseLoc() const
Definition: Stmt.h:1023
DeclStmt * getEndStmt()
Definition: StmtCXX.h:160
SourceLocation End
QualType RebuildPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new pointer type given its pointee type.
ExprResult RebuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool RequiresADL)
Build a new expression that references a declaration.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
Definition: Type.h:4884
SourceLocation getCaptureDefaultLoc() const
Retrieve the location of this lambda&#39;s capture-default, if any.
Definition: ExprCXX.h:1725
TemplateArgumentLoc const * getTemplateArgs() const
Definition: ExprCXX.h:2784
ArrayRef< StringRef > getClobbers() const
Definition: Stmt.h:1932
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:1426
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:3624
int Id
Definition: ASTDiff.cpp:191
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:531
QualType TransformFunctionProtoType(TypeLocBuilder &TLB, FunctionProtoTypeLoc TL, CXXRecordDecl *ThisContext, unsigned ThisTypeQuals, Fn TransformExceptionSpec)
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:503
Expr * getNumTasks() const
Return safe iteration space distance.
SourceLocation getDefaultLoc() const
Definition: Stmt.h:847
StmtResult TransformCompoundStmt(CompoundStmt *S, bool IsStmtExpr)
SourceLocation getScheduleKindLoc()
Get kind location.
Definition: OpenMPClause.h:889
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:1257
SourceLocation getWhileLoc() const
Definition: Stmt.h:1183
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:6589
Represents a C++ functional cast expression that builds a temporary object.
Definition: ExprCXX.h:1597
ElaboratedTypeKeyword
The elaboration keyword that precedes a qualified type name or introduces an elaborated-type-specifie...
Definition: Type.h:4866
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:1012
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:145
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
A C++ const_cast expression (C++ [expr.const.cast]).
Definition: ExprCXX.h:439
unsigned getNumParams() const
Definition: Decl.h:4082
const TypeSourceInfo * getAssocTypeSourceInfo(unsigned i) const
Definition: Expr.h:4923
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Definition: Expr.h:5051
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:2700
VarDecl * getExceptionDecl() const
Definition: StmtCXX.h:52
IdentifierInfo * getDestroyedTypeIdentifier() const
In a dependent pseudo-destructor expression for which we do not have full type information on the des...
Definition: ExprCXX.h:2375
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:4080
bool isImplicitAccess() const
True if this is an implicit access, i.e.
Definition: ExprCXX.cpp:1204
TemplateArgumentLocInventIterator & operator++()
const Expr * getCallee() const
Definition: Expr.h:2356
This represents &#39;#pragma omp target teams distribute parallel for simd&#39; combined directive.
Definition: StmtOpenMP.h:3916
bool isIfNotExists() const
Determine whether this is an __if_exists statement.
Definition: StmtCXX.h:272
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:2338
Stmt * getBody()
Definition: Stmt.h:1179
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:2790
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:296
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:290
DeclContext * getDeclContext()
Definition: DeclBase.h:428
SourceLocation getLParenLoc() const
Definition: Expr.h:4830
Expr * getRHS()
Definition: Stmt.h:792
const IdentifierInfo * getIdentifier() const
Retrieve the type named by the typename specifier as an identifier.
Definition: Type.h:5046
Represents Objective-C&#39;s @synchronized statement.
Definition: StmtObjC.h:270
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:441
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Definition: ExprObjC.h:1354
SourceLocation Begin
SourceLocation getEllipsisLoc() const
Definition: TypeLoc.h:2245
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:2069
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:3830
SourceLocation getRBracketLoc() const
Definition: ExprOpenMP.h:114
CXXTryStmt - A C++ try block, including all handlers.
Definition: StmtCXX.h:67
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
Definition: Expr.h:5102
OpenMPDistScheduleClauseKind getDistScheduleKind() const
Get kind of the clause.
SourceLocation getAtTryLoc() const
Retrieve the location of the @ in the @try.
Definition: StmtObjC.h:199
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:2305
IdentifierInfo & getAccessor() const
Definition: Expr.h:5010
Represents a C++ template name within the type system.
Definition: TemplateName.h:178
Represents the type decltype(expr) (C++11).
Definition: Type.h:4011
This represents &#39;#pragma omp target teams distribute simd&#39; combined directive.
Definition: StmtOpenMP.h:3989
ArrayTypeTrait getTrait() const
Definition: ExprCXX.h:2552
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:1857
A namespace alias, stored as a NamespaceAliasDecl*.
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:927
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:287
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:1975
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1857
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:2638
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:3714
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:266
Wrapper for source info for enum types.
Definition: TypeLoc.h:725
This represents &#39;#pragma omp for&#39; directive.
Definition: StmtOpenMP.h:1072
A unary type transform, which is a type constructed from another.
Definition: Type.h:4054
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:4299
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:259
SourceLocation getSwitchLoc() const
Definition: Stmt.h:1105
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2249
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:1341
const Stmt * getTryBody() const
Retrieve the @try body.
Definition: StmtObjC.h:203
Represents a folding of a pack over an operator.
Definition: ExprCXX.h:4262
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:1476
This represents &#39;#pragma omp target teams&#39; directive.
Definition: StmtOpenMP.h:3705
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:925
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:1860
SourceLocation getDoLoc() const
Definition: Stmt.h:1230
SourceLocation getAtLoc() const
Definition: StmtObjC.h:379
ObjCMethodDecl * getImplicitPropertyGetter() const
Definition: ExprObjC.h:693
ConditionKind
Definition: Sema.h:9824
bool isInvalid() const
Definition: Ownership.h:170
Expr * getSubExprAsWritten()
Retrieve the cast subexpression as it was written in the source code, looking through any implicit ca...
Definition: Expr.cpp:1693
SourceLocation getRBracketLoc() const
Definition: Expr.h:2290
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:1805
bool isInstanceMethod() const
Definition: DeclObjC.h:454
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of &#39;F&#39;...
Definition: Expr.h:2700
Represents a GCC generic vector type.
Definition: Type.h:3024
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Definition: ExprObjC.h:1209
ArraySizeModifier getSizeModifier() const
Definition: Type.h:2705
bool usesGNUSyntax() const
Determines whether this designated initializer used the deprecated GNU syntax for designated initiali...
Definition: Expr.h:4518
struct CXXOpName CXXOperatorName
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
Definition: SemaExpr.cpp:13209
AtomicOp getOp() const
Definition: Expr.h:5377
A member reference to an MSPropertyDecl.
Definition: ExprCXX.h:763
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
UTTKind getUTTKind() const
Definition: Type.h:4082
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Definition: ExprCXX.h:3946
const OffsetOfNode & getComponent(unsigned Idx) const
Definition: Expr.h:2076
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:7702
This represents &#39;#pragma omp cancel&#39; directive.
Definition: StmtOpenMP.h:2744
This represents &#39;collapse&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:557
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:4494
ValueDecl * getDecl()
Definition: Expr.h:1059
SourceLocation getKWLoc() const
Definition: TypeLoc.h:1941
SourceLocation getLocation() const
Definition: Expr.h:1238
bool isUsable() const
Definition: Ownership.h:171
SourceLocation getRParenLoc() const
Definition: Expr.h:3986
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:1381
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:1767
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
Definition: ExprObjC.h:1634
const Expr * getSubExpr() const
Definition: ExprCXX.h:1268
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2080
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:3073
SourceLocation getPackLoc() const
Determine the location of the parameter pack.
Definition: ExprCXX.h:3895
CXXMethodDecl * getCallOperator() const
Retrieve the function call operator associated with this lambda expression.
Definition: ExprCXX.cpp:1018
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:720
InitializationStyle getInitStyle() const
The style of initialization for this declaration.
Definition: Decl.h:1278
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
Definition: Expr.h:2259
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:1535
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:2012
This represents &#39;#pragma omp parallel for simd&#39; directive.
Definition: StmtOpenMP.h:1600
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:1205
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:3397
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:3229
QualType getAutoType(QualType DeducedType, AutoTypeKeyword Keyword, bool IsDependent) const
C++11 deduced auto type.
bool hasTrailingReturn() const
Definition: Type.h:3784
RecordDecl * getDecl() const
Definition: Type.h:4145
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
Definition: ExprCXX.h:3401
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
Definition: ExprCXX.h:126
void setIsVariadic(bool value)
Definition: Decl.h:3939
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Definition: DeclSpec.h:76
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1849
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
Definition: ExprCXX.h:2986
Expr * getArgument()
Definition: ExprCXX.h:2199
This represents &#39;#pragma omp target enter data&#39; directive.
Definition: StmtOpenMP.h:2372
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:886
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
Definition: Expr.cpp:1846
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
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
SourceLocation getColonLoc() const
Returns the location of &#39;:&#39;.
StmtResult RebuildMSDependentExistsStmt(SourceLocation KeywordLoc, bool IsIfExists, NestedNameSpecifierLoc QualifierLoc, DeclarationNameInfo NameInfo, Stmt *Nested)
Build a new C++0x range-based for statement.
StmtResult RebuildCXXCatchStmt(SourceLocation CatchLoc, VarDecl *ExceptionDecl, Stmt *Handler)
Build a new C++ catch statement.
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
OMPClause * TransformOMPClause(OMPClause *S)
Transform the given statement.
void InventTemplateArgumentLoc(const TemplateArgument &Arg, TemplateArgumentLoc &ArgLoc)
Fakes up a TemplateArgumentLoc for a given TemplateArgument.
A C++ dynamic_cast expression (C++ [expr.dynamic.cast]).
Definition: ExprCXX.h:347
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Definition: Expr.h:875
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:936
SourceLocation getTemplateNameLoc() const
Definition: TypeLoc.h:1987
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Definition: Expr.h:3771
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver. ...
Definition: ExprObjC.h:1350
VarDecl * RebuildObjCExceptionDecl(VarDecl *ExceptionDecl, TypeSourceInfo *TInfo, QualType T)
Rebuild an Objective-C exception declaration.
CanQualType BuiltinFnTy
Definition: ASTContext.h:1034
SourceLocation getLParenLoc() const
Definition: Expr.h:2785
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Definition: Sema.h:3019
Kind
TypeLoc getPatternLoc() const
Definition: TypeLoc.h:2261
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
Definition: ExprCXX.h:2636
This captures a statement into a function.
Definition: Stmt.h:2125
A field in a dependent type, known only by its name.
Definition: Expr.h:1930
Expr * getInit() const
Get the operand that doesn&#39;t contain a pack, for a binary fold.
Definition: ExprCXX.h:4302
QualType getCanonicalType() const
Definition: Type.h:5928
Represents a call to an inherited base class constructor from an inheriting constructor.
Definition: ExprCXX.h:1455
ExpressionTrait getTrait() const
Definition: ExprCXX.h:2618
Token * getAsmToks()
Definition: Stmt.h:1891
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
Definition: Ownership.h:157
ExceptionSpecificationType Type
The kind of exception specification this is.
Definition: Type.h:3529
Expr ** getPlacementArgs()
Definition: ExprCXX.h:2031
SourceLocation getLParenLoc()
Get location of &#39;(&#39;.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Definition: Expr.h:5177
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, QualType NamedType, TagDecl *OwnedTagDecl=nullptr) const
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2176
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:1128
QualType RebuildObjCObjectPointerType(QualType PointeeType, SourceLocation Star)
Build a new Objective-C object pointer type given the pointee type.
ElaboratedTypeKeyword getKeyword() const
Definition: Type.h:4906
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3679
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2613
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:2746
const ExtParameterInfo * ExtParameterInfos
Definition: Type.h:3558
bool inheritedFromVBase() const
Determine whether the inherited constructor is inherited from a virtual base of the object we constru...
Definition: ExprCXX.h:1504
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: Expr.h:2645
unsigned getNumExprs() const
Definition: Expr.h:4812
This represents &#39;#pragma omp single&#39; directive.
Definition: StmtOpenMP.h:1344
Encodes a location in the source.
SourceLocation getStarLoc() const
Definition: TypeLoc.h:1343
body_range body()
Definition: Stmt.h:647
capture_iterator explicit_capture_begin() const
Retrieve an iterator pointing to the first explicit lambda capture.
Definition: ExprCXX.cpp:988
QualType getReturnType() const
Definition: Type.h:3365
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:740
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:4161
SourceLocation getOperatorLoc() const
Definition: Expr.h:3181
StmtResult RebuildLabelStmt(SourceLocation IdentLoc, LabelDecl *L, SourceLocation ColonLoc, Stmt *SubStmt)
Build a new label statement.
const Stmt * getCatchBody() const
Definition: StmtObjC.h:92
unsigned getNumHandlers() const
Definition: StmtCXX.h:107
Expr * getSubExpr() const
Definition: Expr.h:1832
bool hasExplicitTemplateArgs() const
Determines whether this member expression actually had a C++ template argument list explicitly specif...
Definition: ExprCXX.h:3464
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:3022
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:1121
std::pair< NullabilityKind, bool > DiagNullabilityKind
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
Definition: Diagnostic.h:1289
NestedNameSpecifierLoc getQualifierLoc() const
Retrieves the nested-name-specifier that qualifies the type name, with source-location information...
Definition: ExprCXX.h:2327
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:278
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
Definition: ExprCXX.h:1915
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Definition: ExprObjC.h:350
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:773
Expr * getLHS()
Definition: Stmt.h:791
StmtResult ActOnLabelStmt(SourceLocation IdentLoc, LabelDecl *TheDecl, SourceLocation ColonLoc, Stmt *SubStmt)
Definition: SemaStmt.cpp:495
A call to a literal operator (C++11 [over.literal]) written as a user-defined literal (C++11 [lit...
Definition: ExprCXX.h:481
DeclarationName getName() const
getName - Returns the embedded declaration name.
ArrayRef< const Attr * > getAttrs() const
Definition: Stmt.h:952
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3020
MutableArrayRef< Expr * > MultiExprArg
Definition: Ownership.h:277
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:746
SourceLocation getEllipsisLoc() const
Retrieve the location of the ellipsis that describes this pack expansion.
Definition: ExprCXX.h:3792
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:1328
Represents a call to a member function that may be written either with member call syntax (e...
Definition: ExprCXX.h:166
SourceLocation getExceptLoc() const
Definition: Stmt.h:1984
SourceRange getSourceRange() const LLVM_READONLY
Definition: ExprObjC.h:374
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:401
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:3059
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Definition: Stmt.h:503
OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:23
Represents the declaration of a label.
Definition: Decl.h:468
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
Represents a vector type where either the type or size is dependent.
Definition: Type.h:3101
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1044
SourceLocation getProcBindKindKwLoc() const
Returns location of clause kind.
Definition: OpenMPClause.h:728
DeclarationNameInfo getDirectiveName() const
Return name of the directive.
Definition: StmtOpenMP.h:1504
SourceLocation getLBraceLoc() const
Definition: Stmt.h:1883
SourceLocation getLocStart() const LLVM_READONLY
Definition: ExprCXX.h:2208
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:2045
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:111
SourceLocation getRParenLoc() const
Definition: Expr.h:3681
OpenMPLinearClauseKind Modifier
Modifier of &#39;linear&#39; clause.
Definition: OpenMPClause.h:96
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:414
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
C-style initialization with assignment.
Definition: Decl.h:819
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:1269
SourceLocation getAtLoc() const
Definition: ExprObjC.h:412
This represents &#39;#pragma omp taskwait&#39; directive.
Definition: StmtOpenMP.h:1895
QualType getAllocatedType() const
Definition: ExprCXX.h:1989
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:2254
QualType RebuildBlockPointerType(QualType PointeeType, SourceLocation Sigil)
Build a new block pointer type given its pointee type.
Name lookup found an unresolvable value declaration and cannot yet complete.
Definition: Lookup.h:69
void reserve(size_t Requested)
Ensures that this buffer has at least as much capacity as described.
QualType RebuildUnresolvedUsingType(SourceLocation NameLoc, Decl *D)
Rebuild an unresolved typename type, given the decl that the UnresolvedUsingTypenameDecl was transfor...
ExprResult RebuildUnresolvedMemberExpr(Expr *BaseE, QualType BaseType, SourceLocation OperatorLoc, bool IsArrow, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierInScope, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs)
Build a new member reference expression.
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Definition: SemaExpr.cpp:5779
QualType getEquivalentType() const
Definition: Type.h:4265
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:5313
UnaryExprOrTypeTrait getKind() const
Definition: Expr.h:2165
bool isArray() const
Definition: ExprCXX.h:2020
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:488
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:3679
SourceLocation getGotoLoc() const
Definition: Stmt.h:1344
SourceLocation getAtFinallyLoc() const
Definition: StmtObjC.h:147
bool isObjCObjectPointerType() const
Definition: Type.h:6210
SourceLocation getNameModifierLoc() const
Return the location of directive name modifier.
Definition: OpenMPClause.h:316
SourceLocation getLocStart() const LLVM_READONLY
Returns the starting location of the clause.
Definition: OpenMPClause.h:67
const Attr * TransformAttr(const Attr *S)
Transform the given attribute.
const StringLiteral * getOutputConstraintLiteral(unsigned i) const
Definition: Stmt.h:1782
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:1178
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:748
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2486
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2128
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Definition: Expr.h:2961
Stmt * getCapturedStmt()
Retrieve the statement being captured.
Definition: Stmt.h:2226
OpenMPMapClauseKind getMapTypeModifier() const LLVM_READONLY
Fetches the map type modifier for the clause.
SourceLocation getAtCatchLoc() const
Definition: StmtObjC.h:104
Expr ** getInits()
Retrieve the set of initializers.
Definition: Expr.h:4083
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:2256
Expr * getInputExpr(unsigned i)
Definition: Stmt.cpp:432
ExprResult RebuildCXXDefaultInitExpr(SourceLocation Loc, FieldDecl *Field)
Build a new C++11 default-initialization expression.
ExprResult RebuildCXXTypeidExpr(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a new C++ typeid(type) expression.
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: Stmt.h:403
Expr * getNumForLoops() const
Return the number of associated for-loops.
Definition: OpenMPClause.h:592
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1538
No entity found met the criteria.
Definition: Lookup.h:51
AutoTypeKeyword getKeyword() const
Definition: Type.h:4577
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:1236
SourceLocation getEndLoc() const
Definition: Stmt.h:1885
Expr * getArrayRangeStart(const Designator &D) const
Definition: Expr.cpp:3897
SourceLocation getRAngleLoc() const
Definition: TypeLoc.h:1641
Expr * getSubExpr()
Definition: ExprObjC.h:139
The name is a dependent name, so the results will differ from one instantiation to the next...
Definition: Sema.h:4501
An expression trait intrinsic.
Definition: ExprCXX.h:2579
EnumDecl * getDecl() const
Definition: Type.h:4168
Expr ** getExprs()
Definition: Expr.h:4824
const ObjCMethodDecl * getMethodDecl() const
Definition: ExprObjC.h:1324
This represents &#39;#pragma omp ordered&#39; directive.
Definition: StmtOpenMP.h:2067
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Definition: Expr.h:3654
void set(unsigned index, FunctionProtoType::ExtParameterInfo info)
Set the ExtParameterInfo for the parameter at the given index,.
Definition: Sema.h:7690
ArrayRef< ParmVarDecl * > getParams() const
Definition: TypeLoc.h:1462
This represents &#39;#pragma omp target update&#39; directive.
Definition: StmtOpenMP.h:3008
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
ObjCBoxedExpr - used for generalized expression boxing.
Definition: ExprObjC.h:121
bool isArgumentType() const
Definition: Expr.h:2170
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:2555
Optional< unsigned > getNumExpansions() const
Retrieve the number of expansions that this pack expansion will generate, if known.
Definition: Type.h:5196
OMPClause * RebuildOMPHintClause(Expr *Hint, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;hint&#39; clause.
SourceLocation getStarLoc() const
Definition: Stmt.h:1383
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:425
void setLAngleLoc(SourceLocation Loc)
Definition: TemplateBase.h:571
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:592
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
FunctionDecl * getOperatorDelete() const
Definition: ExprCXX.h:2017
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding this name, if any.
Definition: ExprCXX.h:3008
Representation of a Microsoft __if_exists or __if_not_exists statement with a dependent name...
Definition: StmtCXX.h:244
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:2944
TypeLoc getElementLoc() const
Definition: TypeLoc.h:1562
Expr * Value
The value of the dictionary element.
Definition: ExprObjC.h:252
const Expr * getInitializer() const
Definition: Expr.h:2778
QualType getPointeeType() const
Definition: Type.h:2956
Represents a pack expansion of types.
Definition: Type.h:5165
Expr * getLHS() const
Definition: Expr.h:3187
CompoundAssignOperator - For compound assignments (e.g.
Definition: Expr.h:3351
SourceLocation getLocation() const LLVM_READONLY
Definition: ExprCXX.h:1506
Expr ** getElements()
Retrieve elements of array of literals.
Definition: ExprObjC.h:210
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
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1629
Represents a C11 generic selection.
Definition: Expr.h:4880
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:3923
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1006
const Expr * getBase() const
Definition: Expr.h:5006
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Definition: ExprObjC.h:1228
AddrLabelExpr - The GNU address of label extension, representing &&label.
Definition: Expr.h:3608
An Objective-C "bridged" cast expression, which casts between Objective-C pointers and C pointers...
Definition: ExprObjC.h:1602
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:2872
SourceLocation getTypeofLoc() const
Definition: TypeLoc.h:1845
Represents a reference to a function parameter pack that has been substituted but not yet expanded...
Definition: ExprCXX.h:4070
Represents a template argument.
Definition: TemplateBase.h:51
bool isDeduced() const
Definition: Type.h:4551
SourceLocation getMemberLoc() const
Definition: ExprCXX.h:819
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Definition: ExprCXX.h:2368
VarDecl * getConditionVariable() const
Retrieve the variable declared in this "if" statement, if any.
Definition: Stmt.cpp:804
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:13695
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Definition: Expr.h:3563
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:4847
NullStmt - This is the null statement ";": C99 6.8.3p3.
Definition: Stmt.h:575
bool isMutable() const
Determine whether the lambda is mutable, meaning that any captures values can be modified.
Definition: ExprCXX.cpp:1040
OpenMPScheduleClauseModifier
OpenMP modifiers for &#39;schedule&#39; clause.
Definition: OpenMPKinds.h:67
bool isTypeOperand() const
Definition: ExprCXX.h:711
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition: Decl.cpp:2501
bool isNull() const
Determine whether this template name is NULL.
unsigned getNumAssocs() const
Definition: Expr.h:4907
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:1562
DeducedType * getContainedDeducedType() const
Get the DeducedType whose type will be deduced for a variable with an initializer of this type...
Definition: Type.cpp:1727
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
Definition: Sema.h:7309
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:2667
Stmt * getReturnStmtOnAllocFailure() const
Definition: StmtCXX.h:404
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:499
not evaluated yet, for special member function
Expr * getAllocate() const
Definition: StmtCXX.h:393
[C99 6.4.2.2] - A predefined identifier such as func.
Definition: Expr.h:1208
DeclarationNameInfo getMemberNameInfo() const
Retrieve the member declaration name info.
Definition: Expr.h:2688
UnaryOperatorKind
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1264
SourceLocation getLocation() const
Definition: ExprObjC.h:744
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
Definition: ExprCXX.h:2145
ArrayRef< Capture > captures() const
Definition: Decl.h:3990
IdentifierInfo * getOutputIdentifier(unsigned i) const
Definition: Stmt.h:1771
SourceLocation getStartLoc() const LLVM_READONLY
Definition: Stmt.h:527
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:1559
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:99
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:22
bool isVariadic() const
Definition: Decl.h:3938
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:1251
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:470
MSPropertyDecl * getPropertyDecl() const
Definition: ExprCXX.h:817
const Stmt * getFinallyBody() const
Definition: StmtObjC.h:136
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:1010
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:362
This represents &#39;#pragma omp section&#39; directive.
Definition: StmtOpenMP.h:1282
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:3418
Expr * getReturnValueInit() const
Definition: StmtCXX.h:399
ExprResult RebuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *Sub, SourceLocation RParenLoc, bool ListInitialization)
Build a new C++ functional-style cast expression.
Expr * getSourceExpression() const
Definition: TemplateBase.h:512
SourceLocation EllipsisLoc
The location of the ellipsis, if this is a pack expansion.
Definition: ExprObjC.h:255
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:3225
AccessSpecifier getAccess() const
Definition: DeclBase.h:463
A constant boolean condition from &#39;if constexpr&#39;.
static ExprResult Owned(Expr *E)
A runtime availability query.
Definition: ExprObjC.h:1670
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:757
A C++ reinterpret_cast expression (C++ [expr.reinterpret.cast]).
Definition: ExprCXX.h:394
This represents &#39;#pragma omp simd&#39; directive.
Definition: StmtOpenMP.h:1007
TypeSourceInfo * getTypeSourceInfo() const
Definition: ExprCXX.h:2240
Stmt * getHandler() const
Definition: Stmt.h:2072
Represents a &#39;co_yield&#39; expression.
Definition: ExprCXX.h:4504
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3432
SourceLocation getLBraceLoc() const
Definition: Expr.h:4195
DeclarationName - The name of a declaration.
StmtClass getStmtClass() const
Definition: Stmt.h:391
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
VectorKind getVectorKind() const
Definition: Type.h:3069
Expr * getDefaultArg()
Definition: Decl.cpp:2539
SourceRange getIntroducerRange() const
Retrieve the source range covering the lambda introducer, which contains the explicit capture list su...
Definition: ExprCXX.h:1819
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Definition: Decl.h:345
Expr * getOperand() const
Retrieve the operand of the &#39;co_return&#39; statement.
Definition: StmtCXX.h:466
Represents a C++11 pack expansion that produces a sequence of expressions.
Definition: ExprCXX.h:3756
bool isListInitialization() const
Whether this constructor call was written as list-initialization.
Definition: ExprCXX.h:1370
OMPClause * RebuildOMPOrderedClause(SourceLocation StartLoc, SourceLocation EndLoc, SourceLocation LParenLoc, Expr *Num)
Build a new OpenMP &#39;ordered&#39; clause.
QualType RebuildFunctionProtoType(QualType T, MutableArrayRef< QualType > ParamTypes, const FunctionProtoType::ExtProtoInfo &EPI)
Build a new function type.
bool isImplicit() const
Definition: ExprCXX.h:4445
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
Represents an enum.
Definition: Decl.h:3313
const Expr * getSynchExpr() const
Definition: StmtObjC.h:298
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:379
A pointer to member type per C++ 8.3.3 - Pointers to members.
Definition: Type.h:2612
bool hasObjCLifetime() const
Definition: Type.h:342
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:269
Expr * get() const
Definition: Sema.h:3658
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:820
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:3634
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:1023
This represents &#39;#pragma omp atomic&#39; directive.
Definition: StmtOpenMP.h:2122
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:4432
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:1631
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
const Expr * Replacement
Definition: ParsedAttr.h:67
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:718
Expr * getArrayRangeEnd(const Designator &D) const
Definition: Expr.cpp:3903
TemplateNameKindForDiagnostics getTemplateNameKindForDiagnostics(TemplateName Name)
Definition: SemaDecl.cpp:1153
const Stmt * getBody() const
Definition: Stmt.h:1093
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2016
Represents a __leave statement.
Definition: Stmt.h:2088
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:2905
SourceLocation getElaboratedKeywordLoc() const
Definition: TypeLoc.h:2008
QualType getModifiedType() const
Definition: Type.h:4264
unsigned getNumParams() const
Definition: TypeLoc.h:1471
LabelDecl * getLabel() const
Definition: Expr.h:3632
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2091
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:3702
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:1054
SourceLocation getColonColonLoc() const
Retrieve the location of the &#39;::&#39; in a qualified pseudo-destructor expression.
Definition: ExprCXX.h:2356
Name lookup found a single declaration that met the criteria.
Definition: Lookup.h:60
ExprResult RebuildTemplateIdExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, bool RequiresADL, const TemplateArgumentListInfo *TemplateArgs)
Build a new template-id expression.
OMPClause * RebuildOMPCopyprivateClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;copyprivate&#39; clause.
QualType RebuildIncompleteArrayType(QualType ElementType, ArrayType::ArraySizeModifier SizeMod, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new incomplete array type given the element type, size modifier, and index type qualifiers...
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:2998
SourceLocation getRParenLoc() const
Definition: StmtObjC.h:55
DeclarationNameInfo getNameInfo() const
Definition: Expr.h:1063
void setAttrEnumOperandLoc(SourceLocation loc)
Definition: TypeLoc.h:923
Represents the body of a coroutine.
Definition: StmtCXX.h:307
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4135
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:450
unsigned getIndexTypeCVRQualifiers() const
Definition: Type.h:2713
ExprResult RebuildVAArgExpr(SourceLocation BuiltinLoc, Expr *SubExpr, TypeSourceInfo *TInfo, SourceLocation RParenLoc)
Build a new va_arg expression.
Expr * getBase() const
Definition: ExprObjC.h:1486
ExprResult RebuildBinaryOperator(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build a new binary operator expression.
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:2615
SourceLocation getBuiltinLoc() const
Definition: Expr.h:3719
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:2226
TypeSourceInfo * getTypeArgTInfo(unsigned i) const
Definition: TypeLoc.h:1022
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:652
OpenMPDirectiveKind getNameModifier() const
Return directive name modifier associated with the clause.
Definition: OpenMPClause.h:313
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Definition: ExprObjC.h:218
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:396
SourceLocation getRParenLoc() const
Determine the location of the right parenthesis.
Definition: ExprCXX.h:3898
SourceLocation getKWLoc() const
Definition: TypeLoc.h:2285
SourceLocation getRParenLoc() const
Definition: TypeLoc.h:2301
OMPClause * RebuildOMPGrainsizeClause(Expr *Grainsize, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc)
Build a new OpenMP &#39;grainsize&#39; clause.
SourceLocation getLocation() const
Definition: ExprObjC.h:572
An implicit indirection through a C++ base class, when the field found is in a base class...
Definition: Expr.h:1933
const llvm::APInt & getSize() const
Definition: Type.h:2746
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1991
Kind getAttrKind() const
Definition: Type.h:4260
Represents a call to a CUDA kernel function.
Definition: ExprCXX.h:205
bool isFunctionType() const
Definition: Type.h:6109
SourceLocation getRParenLoc() const
Definition: Expr.h:3891
Represents a &#39;co_await&#39; expression.
Definition: ExprCXX.h:4419
StmtResult RebuildSwitchStmtStart(SourceLocation SwitchLoc, Stmt *Init, Sema::ConditionResult Cond)
Start building a new switch statement.
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:364
QualType RebuildVariableArrayType(QualType ElementType, ArrayType::ArraySizeModifier SizeMod, Expr *SizeExpr, unsigned IndexTypeQuals, SourceRange BracketsRange)
Build a new variable-length array type given the element type, size modifier, size expression...
std::iterator_traits< InputIterator >::difference_type difference_type
TypeSourceInfo * getTypeSourceInfo() const
Definition: Decl.h:716
Stmt * getInit()
Definition: Stmt.h:1089
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:1303
SourceRange getDirectInitRange() const
Definition: ExprCXX.h:2124
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier that qualifies the member name, with source location information...
Definition: ExprCXX.h:3407
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:1829
Expr * getArg(unsigned Arg)
Return the specified argument.
Definition: ExprCXX.h:1418
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:2529
SourceLocation getEndLoc() const
Retrieve the location of the end of this nested-name-specifier.
decl_range decls()
Definition: Stmt.h:551
ImplicitParamDecl * getParam(unsigned i) const
Definition: Decl.h:4084
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:1135
SourceLocation getLBracketLoc() const
Definition: TypeLoc.h:1534
Represents Objective-C&#39;s @finally statement.
Definition: StmtObjC.h:124
SourceLocation getDefaultLoc() const
Definition: Expr.h:4910
The template argument is a type.
Definition: TemplateBase.h:60
ExceptionSpecificationType
The various types of exception specifications that exist in C++11.
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1339
SourceLocation getLocStart() const LLVM_READONLY
Definition: Stmt.h:2317
StringRef getAsmString() const
Definition: Stmt.h:1894
OpenMPDefaultClauseKind
OpenMP attributes for &#39;default&#39; clause.
Definition: OpenMPKinds.h:43
ArrayRef< StringRef > getAllConstraints() const
Definition: Stmt.h:1928
SourceLocation getDistScheduleKindLoc()
Get kind location.
bool hasAssociatedStmt() const
Returns true if directive has associated statement.
Definition: StmtOpenMP.h:195
ExprResult RebuildDependentCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, UnresolvedLookupExpr *Lookup)
Build a new co_await expression.
const Expr * getBase() const
Definition: ExprObjC.h:563
The template argument is actually a parameter pack.
Definition: TemplateBase.h:91
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
Definition: ScopeInfo.h:618
bool isArrow() const
Determine whether this member expression used the &#39;->&#39; operator; otherwise, it used the &#39;...
Definition: ExprCXX.h:3394
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
Definition: Expr.h:2676
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)
void setNamedTypeInfo(TypeSourceInfo *TInfo)
setNamedTypeInfo - Sets the source type info associated to the name.
unsigned getNumClobbers() const
Definition: Stmt.h:1609
bool isImplicit() const
Definition: StmtCXX.h:475
SourceLocation getRParenLoc() const
Definition: Stmt.h:1307
ObjCIvarRefExpr - A reference to an ObjC instance variable.
Definition: ExprObjC.h:529
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
Definition: Type.h:3532
bool isPartiallySubstituted() const
Determine whether this represents a partially-substituted sizeof...
Definition: ExprCXX.h:3918
ExprResult RebuildCoawaitExpr(SourceLocation CoawaitLoc, Expr *Result, bool IsImplicit)
Build a new co_await expression.
DeclStmt * getRangeStmt()
Definition: StmtCXX.h:156
unsigned arg_size() const
Retrieve the number of arguments.
Definition: ExprCXX.h:3243
bool capturesCXXThis() const
Definition: Decl.h:3995
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:2549
Expr * getRHS() const
Definition: Expr.h:3885
llvm::iterator_range< decls_iterator > decls() const
Definition: ExprCXX.h:2732
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
Definition: ExprCXX.h:3183
SourceLocation getAsmLoc() const
Definition: Stmt.h:1556
GotoStmt - This represents a direct goto.
Definition: Stmt.h:1329
A use of a default initializer in a constructor or in aggregate initialization.
Definition: ExprCXX.h:1160
Expr * getTarget()
Definition: Stmt.h:1385
VectorType::VectorKind getVectorKind() const
Definition: Type.h:3117
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:239
bool isListInitialization() const
Determine whether this expression models list-initialization.
Definition: ExprCXX.h:1570
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Definition: Expr.h:3795
SourceLocation getLAngleLoc() const
Retrieve the location of the left angle bracket starting the explicit template argument list followin...
Definition: ExprCXX.h:3447
TypedefNameDecl * getDecl() const
Definition: Type.h:3932
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
Definition: SemaDecl.cpp:13820
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 a computed noexcept specification.
Definition: Type.h:3535
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:982
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:4190
bool isFreeIvar() const
Definition: ExprObjC.h:568
Expr * getCond()
Definition: Stmt.h:1223
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2289
Call-style initialization (C++98)
Definition: Decl.h:822
const DeclarationNameInfo & getNameInfo() const
Gets the name info for specified reduction identifier.
Represents a type parameter type in Objective C.
Definition: Type.h:5281
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:881
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:997
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition: Expr.h:2500
SourceLocation getWhileLoc() const
Definition: Stmt.h:1232
OMPClause * RebuildOMPTaskReductionClause(ArrayRef< Expr *> VarList, SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation ColonLoc, SourceLocation EndLoc, CXXScopeSpec &ReductionIdScopeSpec, const DeclarationNameInfo &ReductionId, ArrayRef< Expr *> UnresolvedReductions)
Build a new OpenMP &#39;task_reduction&#39; clause.
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
bool DropCallArgument(Expr *E)
Determine whether the given call argument should be dropped, e.g., because it is a default argument...
ActionResult< Expr * > ExprResult
Definition: Ownership.h:267
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
Definition: Type.h:5969
This represents &#39;#pragma omp target parallel&#39; directive.
Definition: StmtOpenMP.h:2489
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Represents a C++ struct/union/class.
Definition: DeclCXX.h:302
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:5072
ContinueStmt - This represents a continue.
Definition: Stmt.h:1410
SourceLocation getExprLoc() const LLVM_READONLY
Definition: ExprCXX.h:877
OpenMPScheduleClauseModifier getFirstScheduleModifier() const
Get the first modifier of the clause.
Definition: OpenMPClause.h:876
Represents a loop initializing the elements of an array.
Definition: Expr.h:4678
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:1507
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:76
Stmt * getFallthroughHandler() const
Definition: StmtCXX.h:389
SourceLocation getColonLoc() const
Definition: StmtCXX.h:197
Represents a C array with an unspecified size.
Definition: Type.h:2782
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Definition: Expr.h:3836
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:1987
QualType RebuildAutoType(QualType Deduced, AutoTypeKeyword Keyword)
Build a new C++11 auto type.
SourceLocation getAttrLoc() const
Definition: Stmt.h:951
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
Definition: Expr.h:3504
CXXCatchStmt - This represents a C++ catch block.
Definition: StmtCXX.h:29
An index into an array.
Definition: Expr.h:1926
Represents an explicit C++ type conversion that uses "functional" notation (C++ [expr.type.conv]).
Definition: ExprCXX.h:1528
SourceLocation getRParenLoc() const
Definition: Expr.h:4831
OpenMPScheduleClauseKind getScheduleKind() const
Get kind of the clause.
Definition: OpenMPClause.h:873
bool isPackExpansion() const
Determines whether this dictionary element is a pack expansion.
Definition: ExprObjC.h:262
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:5916
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:3475
Expr * getOperand() const
Definition: ExprCXX.h:4440
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1966
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:4978
WhileStmt - This represents a &#39;while&#39; stmt.
Definition: Stmt.h:1147
SourceLocation getFirstScheduleModifierLoc() const
Get the first modifier location.
Definition: OpenMPClause.h:892
SourceRange getParenOrBraceRange() const
Definition: ExprCXX.h:1437
TryCaptureKind
Definition: Sema.h:4051
unsigned getNumProtocols() const
Definition: TypeLoc.h:1048
helper_expr_const_range reduction_ops() const
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1170
QualType RebuildDependentTemplateSpecializationType(ElaboratedTypeKeyword Keyword, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const IdentifierInfo *Name, SourceLocation NameLoc, TemplateArgumentListInfo &Args, bool AllowInjectedClassName)
Build a new typename type that refers to a template-id.
QualType getReplacementType() const
Gets the type that was substituted for the template parameter.
Definition: Type.h:4438
Location information for a TemplateArgument.
Definition: TemplateBase.h:393
SourceRange getParensRange() const
Definition: TypeLoc.h:1962
bool isCXXThisCaptured() const
Determine whether the C++ &#39;this&#39; is captured.
Definition: ScopeInfo.h:657
SourceLocation getLParenLoc() const
Definition: ExprCXX.h:1564
SourceLocation getAtSynchronizedLoc() const
Definition: StmtObjC.h:287
SourceLocation getLocEnd() const LLVM_READONLY
Definition: ExprCXX.h:137
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:3796
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:100
SourceLocation getCaseLoc() const
Definition: Stmt.h:784
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:4304
The receiver is a class.
Definition: ExprObjC.h:1073
Represents Objective-C&#39;s @try ... @catch ... @finally statement.
Definition: StmtObjC.h:160
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:266
bool isGlobalDelete() const
Definition: ExprCXX.h:2185
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:2874
SourceLocation getBuiltinLoc() const
getBuiltinLoc - Return the location of the __builtin_convertvector token.
Definition: Expr.h:3806
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Definition: StmtObjC.h:209
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Definition: ExprCXX.h:3385
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1585
bool hasExplicitParameters() const
Determine whether this lambda has an explicit parameter list vs.
Definition: ExprCXX.h:1848
ExprResult RebuildShuffleVectorExpr(SourceLocation BuiltinLoc, MultiExprArg SubExprs, SourceLocation RParenLoc)
Build a new shuffle vector expression.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Definition: Expr.h:2316
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:2045
Expr * getPattern()
Retrieve the pattern of the pack expansion.
Definition: ExprCXX.h:3785
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1645
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:275
ExprResult ExprError()
Definition: Ownership.h:283
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:3996
bool TransformExceptionSpec(SourceLocation Loc, FunctionProtoType::ExceptionSpecInfo &ESI, SmallVectorImpl< QualType > &Exceptions, bool &Changed)
Expr * getLHS() const
Definition: Expr.h:3883
capture_iterator capture_begin() const
Retrieve an iterator pointing to the first lambda capture.
Definition: ExprCXX.cpp:976
Stmt * getBody() const
Retrieve the body of the coroutine as written.
Definition: StmtCXX.h:368
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:248
unsigned getNumElements() const
Definition: Type.h:3060
SourceLocation getRAngleLoc() const
Retrieve the location of the right angle bracket ending the explicit template argument list following...
Definition: ExprCXX.h:2773
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:1214
Designation - Represent a full designation, which is a sequence of designators.
Definition: Designator.h:181
Expr * getHint() const
Returns number of threads.
static OpaquePtr make(QualType P)
Definition: Ownership.h:61
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
Definition: ExprObjC.h:84
bool isObjectReceiver() const
Definition: ExprObjC.h:756
The top declaration context.
Definition: Decl.h:107
unsigned getNumComponents() const
Definition: Expr.h:2086
This represents &#39;#pragma omp target data&#39; directive.
Definition: StmtOpenMP.h:2314
bool isReadOnly() const
Definition: Type.h:5852
ExprResult RebuildStmtExpr(SourceLocation LParenLoc, Stmt *SubStmt, SourceLocation RParenLoc)
Build a new GNU statement expression.
const ParmVarDecl * getParam() const
Definition: ExprCXX.h:1118
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
Definition: Type.h:1942
ExprResult RebuildConvertVectorExpr(SourceLocation BuiltinLoc, Expr *SrcExpr, TypeSourceInfo *DstTInfo, SourceLocation RParenLoc)
Build a new convert vector expression.
QualType getAsType() const
Retrieve the type for a type template argument.
Definition: TemplateBase.h:257
A reference to a declared variable, function, enum, etc.
Definition: Expr.h:974
Represents an extended address space qualifier where the input address space value is dependent...
Definition: Type.h:2942
Represents a type template specialization; the template must be a class template, a type alias templa...
Definition: Type.h:4654
ArrayRef< ParmVarDecl * > parameters() const
Definition: Decl.h:3949
Expr * getRHS() const
Definition: Expr.h:3189
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:788
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:2755
NestedNameSpecifierLoc getQualifierLoc() const
Gets the nested name specifier.
bool isPointerType() const
Definition: Type.h:6113
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:1438
Expr * getChunkSize()
Get chunk size.
Definition: OpenMPClause.h:905
const VarDecl * getCatchParamDecl() const
Definition: StmtObjC.h:96
SourceLocation getTemplateNameLoc() const
Definition: TemplateBase.h:538
Expr * getOperand() const
Definition: ExprCXX.h:4517
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:3440
bool isDefaultArgument() const
Determine whether this expression is a default function argument.
Definition: Expr.cpp:2699
Expr * getNumThreads() const
Returns number of threads.
Definition: OpenMPClause.h:428
Stmt * getSubStmt()
Definition: Stmt.h:895
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:1642
bool hadMultipleCandidates() const
Whether the referred constructor was resolved from an overloaded set having size greater than 1...
Definition: ExprCXX.h:1366
An instance of this class represents the declaration of a property member.
Definition: DeclCXX.h:3920
DeclStmt * getLoopVarStmt()
Definition: StmtCXX.h:163
QualType getType() const
Definition: Decl.h:648
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:114
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1174
unsigned getNumArgs() const
Definition: ExprCXX.h:1415
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:737
const Expr * getCond() const
Definition: Stmt.h:1010
SourceLocation getLocEnd() const LLVM_READONLY
Returns ending location of directive.
Definition: StmtOpenMP.h:171
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:319
This represents &#39;#pragma omp taskyield&#39; directive.
Definition: StmtOpenMP.h:1807
This represents a decl that may have a name.
Definition: Decl.h:248
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
Definition: DeclSpec.h:1011
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:3147
A boolean literal, per ([C++ lex.bool] Boolean literals).
Definition: ExprCXX.h:556
SourceLocation getTemplateKeywordLoc() const
Retrieve the location of the template keyword preceding the member name, if any.
Definition: Expr.h:2631
SourceLocation getLParenLoc() const
Returns the location of &#39;(&#39;.
Definition: OpenMPClause.h:480
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type, member-designator).
Definition: Expr.h:2027
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:2827
Expr * getQueriedExpression() const
Definition: ExprCXX.h:2620
This represents &#39;#pragma omp parallel sections&#39; directive.
Definition: StmtOpenMP.h:1668
Represents a C++ namespace alias.
Definition: DeclCXX.h:3028
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:5403
NestedNameSpecifierLoc getQualifierLoc() const
Definition: TypeLoc.h:2132
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
Definition: ExprCXX.h:895
No keyword precedes the qualified type name.
Definition: Type.h:4887
SourceLocation getRParenLoc() const
Definition: ExprCXX.h:1566
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc, MultiStmtArg Statements, SourceLocation RBraceLoc, bool IsStmtExpr)
Build a new compound statement.
Expr * getUnderlyingExpr() const
Definition: TypeLoc.h:1893
SourceLocation getAttributeLoc() const
Definition: Type.h:2957
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:3544
unsigned getNumTemplateArgs() const
Definition: ExprCXX.h:3048
TypeSourceInfo * getWrittenTypeInfo() const
Definition: Expr.h:3980
DeclStmt * getBeginStmt()
Definition: StmtCXX.h:157
QualType getElementType() const
Definition: Type.h:3115
const ExtParameterInfo * getExtParameterInfosOrNull() const
Return a pointer to the beginning of the array of extra parameter information, if present...
Definition: Type.h:3837
SourceLocation getRightLoc() const
Definition: ExprObjC.h:1385
const Expr * getCond() const
Definition: Stmt.h:1092
static Designator getArrayRange(Expr *Start, Expr *End, SourceLocation LBracketLoc, SourceLocation EllipsisLoc)
Definition: Designator.h:146
attr::Kind getKind() const
Definition: Attr.h:86
The receiver is a superclass.
Definition: ExprObjC.h:1079
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:304
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
Definition: Lookup.h:513
SourceLocation getGenericLoc() const
Definition: Expr.h:4909
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:2971
Wrapper for source info for pointers.
Definition: TypeLoc.h:1271
SourceLocation getBegin() const
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
Definition: Expr.h:3798
BinaryOperatorKind getOperator() const
Definition: ExprCXX.h:4305
SourceLocation ColonLoc
Location of &#39;:&#39;.
Definition: OpenMPClause.h:102
SourceLocation getRParenLoc() const
Return the location of the right parentheses.
Definition: Expr.h:2066
ExprResult RebuildCXXNewExpr(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocatedType, TypeSourceInfo *AllocatedTypeInfo, Expr *ArraySize, SourceRange DirectInitRange, Expr *Initializer)
Build a new C++ "new" expression.
SourceLocation getInnerLocStart() const
Return start of source range ignoring outer template declarations.
Definition: Decl.h:730
ExprResult RebuildCallExpr(Expr *Callee, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig=nullptr)
Build a new call expression.
NamedDecl * getPack() const
Retrieve the parameter pack.
Definition: ExprCXX.h:3901
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:357
llvm::Optional< NullabilityKind > getImmediateNullability() const
Definition: Type.cpp:3840
SourceLocation getKeywordLoc() const
Definition: ExprCXX.h:4379
Represents the canonical version of C arrays with a specified constant size.
Definition: Type.h:2728
CompoundStmt * getTryBlock() const
Definition: Stmt.h:2068
Stmt * getSubStmt()
Definition: Stmt.h:956
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3557
QualType getBaseType() const
Definition: ExprCXX.h:3616
InitListExpr * getSyntacticForm() const
Definition: Expr.h:4207
QualType RebuildDeducedTemplateSpecializationType(TemplateName Template, QualType Deduced)
By default, builds a new DeducedTemplateSpecializationType with the given deduced type...
Expr * getBaseExpr() const
Definition: ExprCXX.h:816
QualType RebuildTypedefType(TypedefNameDecl *Typedef)
Build a new typedef type.
The symbol does not exist.
Definition: Sema.h:4497
void clear()
Clears out any current state.
Definition: Lookup.h:543
Represents an implicitly-generated value initialization of an object of a given type.
Definition: Expr.h:4772
CompoundStmt * getBlock() const
Definition: Stmt.h:1991
static StmtResult Owned(Stmt *S)
SourceLocation getReturnLoc() const
Definition: Stmt.h:1495
Stmt * getFinalSuspendStmt() const
Definition: StmtCXX.h:382
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2012
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:2549
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:419
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:2632
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:2460
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:1914
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
Definition: ExprCXX.h:3426
const IdentifierInfo * getIdentifier() const
Definition: Type.h:5103
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:1718
ConstructionKind getConstructionKind() const
Determine whether this constructor is actually constructing a base class (rather than a complete obje...
Definition: ExprCXX.h:1389
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:1256
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:1079
A RAII object to temporarily push a declaration context.
Definition: Sema.h:706
Stmt * getSubStmt()
Definition: Stmt.h:793
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:2809