clang  14.0.0git
Initialization.h
Go to the documentation of this file.
1 //===- Initialization.h - Semantic Analysis for Initializers ----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file provides supporting data types for initialization of objects.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_CLANG_SEMA_INITIALIZATION_H
14 #define LLVM_CLANG_SEMA_INITIALIZATION_H
15 
16 #include "clang/AST/ASTContext.h"
17 #include "clang/AST/Attr.h"
18 #include "clang/AST/Decl.h"
21 #include "clang/AST/Expr.h"
22 #include "clang/AST/Type.h"
24 #include "clang/Basic/LLVM.h"
27 #include "clang/Basic/Specifiers.h"
28 #include "clang/Sema/Overload.h"
29 #include "clang/Sema/Ownership.h"
30 #include "llvm/ADT/ArrayRef.h"
31 #include "llvm/ADT/SmallVector.h"
32 #include "llvm/ADT/StringRef.h"
33 #include "llvm/ADT/iterator_range.h"
34 #include "llvm/Support/Casting.h"
35 #include <cassert>
36 #include <cstdint>
37 #include <string>
38 
39 namespace clang {
40 
41 class APValue;
42 class CXXBaseSpecifier;
43 class CXXConstructorDecl;
44 class ObjCMethodDecl;
45 class Sema;
46 
47 /// Describes an entity that is being initialized.
48 class alignas(8) InitializedEntity {
49 public:
50  /// Specifies the kind of entity being initialized.
51  enum EntityKind {
52  /// The entity being initialized is a variable.
54 
55  /// The entity being initialized is a function parameter.
57 
58  /// The entity being initialized is a non-type template parameter.
60 
61  /// The entity being initialized is the result of a function call.
63 
64  /// The entity being initialized is the result of a statement expression.
66 
67  /// The entity being initialized is an exception object that
68  /// is being thrown.
70 
71  /// The entity being initialized is a non-static data member
72  /// subobject.
74 
75  /// The entity being initialized is an element of an array.
77 
78  /// The entity being initialized is an object (or array of
79  /// objects) allocated via new.
81 
82  /// The entity being initialized is a temporary object.
84 
85  /// The entity being initialized is a base member subobject.
87 
88  /// The initialization is being done by a delegating constructor.
90 
91  /// The entity being initialized is an element of a vector.
92  /// or vector.
94 
95  /// The entity being initialized is a field of block descriptor for
96  /// the copied-in c++ object.
98 
99  /// The entity being initialized is a field of block descriptor for the
100  /// copied-in lambda object that's used in the lambda to block conversion.
102 
103  /// The entity being initialized is the real or imaginary part of a
104  /// complex number.
106 
107  /// The entity being initialized is the field that captures a
108  /// variable in a lambda.
110 
111  /// The entity being initialized is the initializer for a compound
112  /// literal.
114 
115  /// The entity being implicitly initialized back to the formal
116  /// result type.
118 
119  /// The entity being initialized is a function parameter; function
120  /// is member of group of audited CF APIs.
122 
123  /// The entity being initialized is a structured binding of a
124  /// decomposition declaration.
126 
127  // Note: err_init_conversion_failed in DiagnosticSemaKinds.td uses this
128  // enum as an index for its first %select. When modifying this list,
129  // that diagnostic text needs to be updated as well.
130  };
131 
132 private:
133  /// The kind of entity being initialized.
134  EntityKind Kind;
135 
136  /// If non-NULL, the parent entity in which this
137  /// initialization occurs.
138  const InitializedEntity *Parent = nullptr;
139 
140  /// The type of the object or reference being initialized.
141  QualType Type;
142 
143  /// The mangling number for the next reference temporary to be created.
144  mutable unsigned ManglingNumber = 0;
145 
146  struct LN {
147  /// When Kind == EK_Result, EK_Exception, EK_New, the
148  /// location of the 'return', 'throw', or 'new' keyword,
149  /// respectively. When Kind == EK_Temporary, the location where
150  /// the temporary is being created.
151  SourceLocation Location;
152 
153  /// Whether the entity being initialized may end up using the
154  /// named return value optimization (NRVO).
155  bool NRVO;
156  };
157 
158  struct VD {
159  /// The VarDecl, FieldDecl, or BindingDecl being initialized.
160  ValueDecl *VariableOrMember;
161 
162  /// When Kind == EK_Member, whether this is an implicit member
163  /// initialization in a copy or move constructor. These can perform array
164  /// copies.
165  bool IsImplicitFieldInit;
166 
167  /// When Kind == EK_Member, whether this is the initial initialization
168  /// check for a default member initializer.
169  bool IsDefaultMemberInit;
170  };
171 
172  struct C {
173  /// The name of the variable being captured by an EK_LambdaCapture.
174  IdentifierInfo *VarID;
175 
176  /// The source location at which the capture occurs.
177  SourceLocation Location;
178  };
179 
180  union {
181  /// When Kind == EK_Variable, EK_Member, EK_Binding, or
182  /// EK_TemplateParameter, the variable, binding, or template parameter.
184 
185  /// When Kind == EK_RelatedResult, the ObjectiveC method where
186  /// result type was implicitly changed to accommodate ARC semantics.
188 
189  /// When Kind == EK_Parameter, the ParmVarDecl, with the
190  /// integer indicating whether the parameter is "consumed".
191  llvm::PointerIntPair<ParmVarDecl *, 1> Parameter;
192 
193  /// When Kind == EK_Temporary or EK_CompoundLiteralInit, the type
194  /// source information for the temporary.
196 
197  struct LN LocAndNRVO;
198 
199  /// When Kind == EK_Base, the base specifier that provides the
200  /// base class. The integer specifies whether the base is an inherited
201  /// virtual base.
202  llvm::PointerIntPair<const CXXBaseSpecifier *, 1> Base;
203 
204  /// When Kind == EK_ArrayElement, EK_VectorElement, or
205  /// EK_ComplexElement, the index of the array or vector element being
206  /// initialized.
207  unsigned Index;
208 
209  struct C Capture;
210  };
211 
212  InitializedEntity() {};
213 
214  /// Create the initialization entity for a variable.
215  InitializedEntity(VarDecl *Var, EntityKind EK = EK_Variable)
216  : Kind(EK), Type(Var->getType()), Variable{Var, false, false} {}
217 
218  /// Create the initialization entity for the result of a
219  /// function, throwing an object, performing an explicit cast, or
220  /// initializing a parameter for which there is no declaration.
221  InitializedEntity(EntityKind Kind, SourceLocation Loc, QualType Type,
222  bool NRVO = false)
223  : Kind(Kind), Type(Type) {
224  new (&LocAndNRVO) LN;
225  LocAndNRVO.Location = Loc;
226  LocAndNRVO.NRVO = NRVO;
227  }
228 
229  /// Create the initialization entity for a member subobject.
230  InitializedEntity(FieldDecl *Member, const InitializedEntity *Parent,
231  bool Implicit, bool DefaultMemberInit)
233  Variable{Member, Implicit, DefaultMemberInit} {}
234 
235  /// Create the initialization entity for an array element.
236  InitializedEntity(ASTContext &Context, unsigned Index,
237  const InitializedEntity &Parent);
238 
239  /// Create the initialization entity for a lambda capture.
240  InitializedEntity(IdentifierInfo *VarID, QualType FieldType, SourceLocation Loc)
241  : Kind(EK_LambdaCapture), Type(FieldType) {
242  new (&Capture) C;
243  Capture.VarID = VarID;
244  Capture.Location = Loc;
245  }
246 
247 public:
248  /// Create the initialization entity for a variable.
250  return InitializedEntity(Var);
251  }
252 
253  /// Create the initialization entity for a parameter.
255  ParmVarDecl *Parm) {
256  return InitializeParameter(Context, Parm, Parm->getType());
257  }
258 
259  /// Create the initialization entity for a parameter, but use
260  /// another type.
261  static InitializedEntity
263  bool Consumed = (Context.getLangOpts().ObjCAutoRefCount &&
264  Parm->hasAttr<NSConsumedAttr>());
265 
266  InitializedEntity Entity;
267  Entity.Kind = EK_Parameter;
268  Entity.Type =
269  Context.getVariableArrayDecayedType(Type.getUnqualifiedType());
270  Entity.Parent = nullptr;
271  Entity.Parameter = {Parm, Consumed};
272  return Entity;
273  }
274 
275  /// Create the initialization entity for a parameter that is
276  /// only known by its type.
278  QualType Type,
279  bool Consumed) {
280  InitializedEntity Entity;
281  Entity.Kind = EK_Parameter;
282  Entity.Type = Context.getVariableArrayDecayedType(Type);
283  Entity.Parent = nullptr;
284  Entity.Parameter = {nullptr, Consumed};
285  return Entity;
286  }
287 
288  /// Create the initialization entity for a template parameter.
289  static InitializedEntity
291  InitializedEntity Entity;
292  Entity.Kind = EK_TemplateParameter;
293  Entity.Type = T;
294  Entity.Parent = nullptr;
295  Entity.Variable = {Param, false, false};
296  return Entity;
297  }
298 
299  /// Create the initialization entity for the result of a function.
301  QualType Type) {
302  return InitializedEntity(EK_Result, ReturnLoc, Type);
303  }
304 
306  QualType Type) {
307  return InitializedEntity(EK_StmtExprResult, ReturnLoc, Type);
308  }
309 
311  QualType Type) {
312  return InitializedEntity(EK_BlockElement, BlockVarLoc, Type);
313  }
314 
316  QualType Type) {
318  BlockVarLoc, Type);
319  }
320 
321  /// Create the initialization entity for an exception object.
323  QualType Type) {
324  return InitializedEntity(EK_Exception, ThrowLoc, Type);
325  }
326 
327  /// Create the initialization entity for an object allocated via new.
329  return InitializedEntity(EK_New, NewLoc, Type);
330  }
331 
332  /// Create the initialization entity for a temporary.
334  return InitializeTemporary(nullptr, Type);
335  }
336 
337  /// Create the initialization entity for a temporary.
340  QualType Type = TypeInfo->getType();
341  if (Context.getLangOpts().OpenCLCPlusPlus) {
342  assert(!Type.hasAddressSpace() && "Temporary already has address space!");
343  Type = Context.getAddrSpaceQualType(Type, LangAS::opencl_private);
344  }
345 
347  }
348 
349  /// Create the initialization entity for a temporary.
351  QualType Type) {
353  Result.TypeInfo = TypeInfo;
354  return Result;
355  }
356 
357  /// Create the initialization entity for a related result.
359  QualType Type) {
361  Result.MethodDecl = MD;
362  return Result;
363  }
364 
365  /// Create the initialization entity for a base class subobject.
366  static InitializedEntity
368  bool IsInheritedVirtualBase,
369  const InitializedEntity *Parent = nullptr);
370 
371  /// Create the initialization entity for a delegated constructor.
374  }
375 
376  /// Create the initialization entity for a member subobject.
377  static InitializedEntity
379  const InitializedEntity *Parent = nullptr,
380  bool Implicit = false) {
381  return InitializedEntity(Member, Parent, Implicit, false);
382  }
383 
384  /// Create the initialization entity for a member subobject.
385  static InitializedEntity
387  const InitializedEntity *Parent = nullptr,
388  bool Implicit = false) {
389  return InitializedEntity(Member->getAnonField(), Parent, Implicit, false);
390  }
391 
392  /// Create the initialization entity for a default member initializer.
393  static InitializedEntity
395  return InitializedEntity(Member, nullptr, false, true);
396  }
397 
398  /// Create the initialization entity for an array element.
400  unsigned Index,
401  const InitializedEntity &Parent) {
402  return InitializedEntity(Context, Index, Parent);
403  }
404 
405  /// Create the initialization entity for a structured binding.
407  return InitializedEntity(Binding, EK_Binding);
408  }
409 
410  /// Create the initialization entity for a lambda capture.
411  ///
412  /// \p VarID The name of the entity being captured, or nullptr for 'this'.
414  QualType FieldType,
415  SourceLocation Loc) {
416  return InitializedEntity(VarID, FieldType, Loc);
417  }
418 
419  /// Create the entity for a compound literal initializer.
422  TSI->getType());
423  Result.TypeInfo = TSI;
424  return Result;
425  }
426 
427  /// Determine the kind of initialization.
428  EntityKind getKind() const { return Kind; }
429 
430  /// Retrieve the parent of the entity being initialized, when
431  /// the initialization itself is occurring within the context of a
432  /// larger initialization.
433  const InitializedEntity *getParent() const { return Parent; }
434 
435  /// Retrieve type being initialized.
436  QualType getType() const { return Type; }
437 
438  /// Retrieve complete type-source information for the object being
439  /// constructed, if known.
442  return TypeInfo;
443 
444  return nullptr;
445  }
446 
447  /// Retrieve the name of the entity being initialized.
448  DeclarationName getName() const;
449 
450  /// Retrieve the variable, parameter, or field being
451  /// initialized.
452  ValueDecl *getDecl() const;
453 
454  /// Retrieve the ObjectiveC method being initialized.
456 
457  /// Determine whether this initialization allows the named return
458  /// value optimization, which also applies to thrown objects.
459  bool allowsNRVO() const;
460 
461  bool isParameterKind() const {
462  return (getKind() == EK_Parameter ||
464  }
465 
468  }
469 
470  /// Determine whether this initialization consumes the
471  /// parameter.
472  bool isParameterConsumed() const {
473  assert(isParameterKind() && "Not a parameter");
474  return Parameter.getInt();
475  }
476 
477  /// Retrieve the base specifier.
479  assert(getKind() == EK_Base && "Not a base specifier");
480  return Base.getPointer();
481  }
482 
483  /// Return whether the base is an inherited virtual base.
484  bool isInheritedVirtualBase() const {
485  assert(getKind() == EK_Base && "Not a base specifier");
486  return Base.getInt();
487  }
488 
489  /// Determine whether this is an array new with an unknown bound.
491  return getKind() == EK_New && isa_and_nonnull<IncompleteArrayType>(
492  getType()->getAsArrayTypeUnsafe());
493  }
494 
495  /// Is this the implicit initialization of a member of a class from
496  /// a defaulted constructor?
498  return getKind() == EK_Member && Variable.IsImplicitFieldInit;
499  }
500 
501  /// Is this the default member initializer of a member (specified inside
502  /// the class definition)?
504  return getKind() == EK_Member && Variable.IsDefaultMemberInit;
505  }
506 
507  /// Determine the location of the 'return' keyword when initializing
508  /// the result of a function call.
510  assert(getKind() == EK_Result && "No 'return' location!");
511  return LocAndNRVO.Location;
512  }
513 
514  /// Determine the location of the 'throw' keyword when initializing
515  /// an exception object.
517  assert(getKind() == EK_Exception && "No 'throw' location!");
518  return LocAndNRVO.Location;
519  }
520 
521  /// If this is an array, vector, or complex number element, get the
522  /// element's index.
523  unsigned getElementIndex() const {
524  assert(getKind() == EK_ArrayElement || getKind() == EK_VectorElement ||
526  return Index;
527  }
528 
529  /// If this is already the initializer for an array or vector
530  /// element, sets the element index.
531  void setElementIndex(unsigned Index) {
532  assert(getKind() == EK_ArrayElement || getKind() == EK_VectorElement ||
534  this->Index = Index;
535  }
536 
537  /// For a lambda capture, return the capture's name.
538  StringRef getCapturedVarName() const {
539  assert(getKind() == EK_LambdaCapture && "Not a lambda capture!");
540  return Capture.VarID ? Capture.VarID->getName() : "this";
541  }
542 
543  /// Determine the location of the capture when initializing
544  /// field from a captured variable in a lambda.
546  assert(getKind() == EK_LambdaCapture && "Not a lambda capture!");
547  return Capture.Location;
548  }
549 
552  }
553 
554  unsigned allocateManglingNumber() const { return ++ManglingNumber; }
555 
556  /// Dump a representation of the initialized entity to standard error,
557  /// for debugging purposes.
558  void dump() const;
559 
560 private:
561  unsigned dumpImpl(raw_ostream &OS) const;
562 };
563 
564 /// Describes the kind of initialization being performed, along with
565 /// location information for tokens related to the initialization (equal sign,
566 /// parentheses).
568 public:
569  /// The kind of initialization being performed.
570  enum InitKind {
571  /// Direct initialization
573 
574  /// Direct list-initialization
576 
577  /// Copy initialization
579 
580  /// Default initialization
582 
583  /// Value initialization
585  };
586 
587 private:
588  /// The context of the initialization.
589  enum InitContext {
590  /// Normal context
591  IC_Normal,
592 
593  /// Normal context, but allows explicit conversion functionss
594  IC_ExplicitConvs,
595 
596  /// Implicit context (value initialization)
597  IC_Implicit,
598 
599  /// Static cast context
600  IC_StaticCast,
601 
602  /// C-style cast context
603  IC_CStyleCast,
604 
605  /// Functional cast context
606  IC_FunctionalCast
607  };
608 
609  /// The kind of initialization being performed.
610  InitKind Kind : 8;
611 
612  /// The context of the initialization.
613  InitContext Context : 8;
614 
615  /// The source locations involved in the initialization.
616  SourceLocation Locations[3];
617 
618  InitializationKind(InitKind Kind, InitContext Context, SourceLocation Loc1,
619  SourceLocation Loc2, SourceLocation Loc3)
620  : Kind(Kind), Context(Context) {
621  Locations[0] = Loc1;
622  Locations[1] = Loc2;
623  Locations[2] = Loc3;
624  }
625 
626 public:
627  /// Create a direct initialization.
629  SourceLocation LParenLoc,
630  SourceLocation RParenLoc) {
631  return InitializationKind(IK_Direct, IC_Normal,
632  InitLoc, LParenLoc, RParenLoc);
633  }
634 
636  return InitializationKind(IK_DirectList, IC_Normal, InitLoc, InitLoc,
637  InitLoc);
638  }
639 
641  SourceLocation LBraceLoc,
642  SourceLocation RBraceLoc) {
643  return InitializationKind(IK_DirectList, IC_Normal, InitLoc, LBraceLoc,
644  RBraceLoc);
645  }
646 
647  /// Create a direct initialization due to a cast that isn't a C-style
648  /// or functional cast.
650  return InitializationKind(IK_Direct, IC_StaticCast, TypeRange.getBegin(),
651  TypeRange.getBegin(), TypeRange.getEnd());
652  }
653 
654  /// Create a direct initialization for a C-style cast.
656  SourceRange TypeRange,
657  bool InitList) {
658  // C++ cast syntax doesn't permit init lists, but C compound literals are
659  // exactly that.
660  return InitializationKind(InitList ? IK_DirectList : IK_Direct,
661  IC_CStyleCast, StartLoc, TypeRange.getBegin(),
662  TypeRange.getEnd());
663  }
664 
665  /// Create a direct initialization for a functional cast.
667  bool InitList) {
668  return InitializationKind(InitList ? IK_DirectList : IK_Direct,
669  IC_FunctionalCast, TypeRange.getBegin(),
670  TypeRange.getBegin(), TypeRange.getEnd());
671  }
672 
673  /// Create a copy initialization.
675  SourceLocation EqualLoc,
676  bool AllowExplicitConvs = false) {
678  AllowExplicitConvs? IC_ExplicitConvs : IC_Normal,
679  InitLoc, EqualLoc, EqualLoc);
680  }
681 
682  /// Create a default initialization.
684  return InitializationKind(IK_Default, IC_Normal, InitLoc, InitLoc, InitLoc);
685  }
686 
687  /// Create a value initialization.
689  SourceLocation LParenLoc,
690  SourceLocation RParenLoc,
691  bool isImplicit = false) {
692  return InitializationKind(IK_Value, isImplicit ? IC_Implicit : IC_Normal,
693  InitLoc, LParenLoc, RParenLoc);
694  }
695 
696  /// Create an initialization from an initializer (which, for direct
697  /// initialization from a parenthesized list, will be a ParenListExpr).
698  static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit,
699  Expr *Init) {
700  if (!Init) return CreateDefault(Loc);
701  if (!DirectInit)
702  return CreateCopy(Loc, Init->getBeginLoc());
703  if (isa<InitListExpr>(Init))
704  return CreateDirectList(Loc, Init->getBeginLoc(), Init->getEndLoc());
705  return CreateDirect(Loc, Init->getBeginLoc(), Init->getEndLoc());
706  }
707 
708  /// Determine the initialization kind.
709  InitKind getKind() const {
710  return Kind;
711  }
712 
713  /// Determine whether this initialization is an explicit cast.
714  bool isExplicitCast() const {
715  return Context >= IC_StaticCast;
716  }
717 
718  /// Determine whether this initialization is a static cast.
719  bool isStaticCast() const { return Context == IC_StaticCast; }
720 
721  /// Determine whether this initialization is a C-style cast.
723  return Context >= IC_CStyleCast;
724  }
725 
726  /// Determine whether this is a C-style cast.
727  bool isCStyleCast() const {
728  return Context == IC_CStyleCast;
729  }
730 
731  /// Determine whether this is a functional-style cast.
732  bool isFunctionalCast() const {
733  return Context == IC_FunctionalCast;
734  }
735 
736  /// Determine whether this initialization is an implicit
737  /// value-initialization, e.g., as occurs during aggregate
738  /// initialization.
739  bool isImplicitValueInit() const { return Context == IC_Implicit; }
740 
741  /// Retrieve the location at which initialization is occurring.
742  SourceLocation getLocation() const { return Locations[0]; }
743 
744  /// Retrieve the source range that covers the initialization.
746  return SourceRange(Locations[0], Locations[2]);
747  }
748 
749  /// Retrieve the location of the equal sign for copy initialization
750  /// (if present).
752  assert(Kind == IK_Copy && "Only copy initialization has an '='");
753  return Locations[1];
754  }
755 
756  bool isCopyInit() const { return Kind == IK_Copy; }
757 
758  /// Retrieve whether this initialization allows the use of explicit
759  /// constructors.
760  bool AllowExplicit() const { return !isCopyInit(); }
761 
762  /// Retrieve whether this initialization allows the use of explicit
763  /// conversion functions when binding a reference. If the reference is the
764  /// first parameter in a copy or move constructor, such conversions are
765  /// permitted even though we are performing copy-initialization.
767  return !isCopyInit() || Context == IC_ExplicitConvs;
768  }
769 
770  /// Determine whether this initialization has a source range containing the
771  /// locations of open and closing parentheses or braces.
772  bool hasParenOrBraceRange() const {
773  return Kind == IK_Direct || Kind == IK_Value || Kind == IK_DirectList;
774  }
775 
776  /// Retrieve the source range containing the locations of the open
777  /// and closing parentheses or braces for value, direct, and direct list
778  /// initializations.
780  assert(hasParenOrBraceRange() && "Only direct, value, and direct-list "
781  "initialization have parentheses or "
782  "braces");
783  return SourceRange(Locations[1], Locations[2]);
784  }
785 };
786 
787 /// Describes the sequence of initializations required to initialize
788 /// a given object or reference with a set of arguments.
790 public:
791  /// Describes the kind of initialization sequence computed.
793  /// A failed initialization sequence. The failure kind tells what
794  /// happened.
796 
797  /// A dependent initialization, which could not be
798  /// type-checked due to the presence of dependent types or
799  /// dependently-typed expressions.
801 
802  /// A normal sequence.
804  };
805 
806  /// Describes the kind of a particular step in an initialization
807  /// sequence.
808  enum StepKind {
809  /// Resolve the address of an overloaded function to a specific
810  /// function declaration.
812 
813  /// Perform a derived-to-base cast, producing an rvalue.
815 
816  /// Perform a derived-to-base cast, producing an xvalue.
818 
819  /// Perform a derived-to-base cast, producing an lvalue.
821 
822  /// Reference binding to an lvalue.
824 
825  /// Reference binding to a temporary.
827 
828  /// An optional copy of a temporary object to another
829  /// temporary object, which is permitted (but not required) by
830  /// C++98/03 but not C++0x.
832 
833  /// Direct-initialization from a reference-related object in the
834  /// final stage of class copy-initialization.
836 
837  /// Perform a user-defined conversion, either via a conversion
838  /// function or via a constructor.
840 
841  /// Perform a qualification conversion, producing a prvalue.
843 
844  /// Perform a qualification conversion, producing an xvalue.
846 
847  /// Perform a qualification conversion, producing an lvalue.
849 
850  /// Perform a function reference conversion, see [dcl.init.ref]p4.
852 
853  /// Perform a conversion adding _Atomic to a type.
855 
856  /// Perform an implicit conversion sequence.
858 
859  /// Perform an implicit conversion sequence without narrowing.
861 
862  /// Perform list-initialization without a constructor.
864 
865  /// Unwrap the single-element initializer list for a reference.
867 
868  /// Rewrap the single-element initializer list for a reference.
870 
871  /// Perform initialization via a constructor.
873 
874  /// Perform initialization via a constructor, taking arguments from
875  /// a single InitListExpr.
877 
878  /// Zero-initialize the object
880 
881  /// C assignment
883 
884  /// Initialization by string
886 
887  /// An initialization that "converts" an Objective-C object
888  /// (not a point to an object) to another Objective-C object type.
890 
891  /// Array indexing for initialization by elementwise copy.
893 
894  /// Array initialization by elementwise copy.
896 
897  /// Array initialization (from an array rvalue).
899 
900  /// Array initialization (from an array rvalue) as a GNU extension.
902 
903  /// Array initialization from a parenthesized initializer list.
904  /// This is a GNU C++ extension.
906 
907  /// Pass an object by indirect copy-and-restore.
909 
910  /// Pass an object by indirect restore.
912 
913  /// Produce an Objective-C object pointer.
915 
916  /// Construct a std::initializer_list from an initializer list.
918 
919  /// Perform initialization via a constructor taking a single
920  /// std::initializer_list argument.
922 
923  /// Initialize an OpenCL sampler from an integer.
925 
926  /// Initialize an opaque OpenCL type (event_t, queue_t, etc.) with zero
928  };
929 
930  /// A single step in the initialization sequence.
931  class Step {
932  public:
933  /// The kind of conversion or initialization step we are taking.
935 
936  // The type that results from this initialization.
938 
939  struct F {
943  };
944 
945  union {
946  /// When Kind == SK_ResolvedOverloadedFunction or Kind ==
947  /// SK_UserConversion, the function that the expression should be
948  /// resolved to or the conversion function to call, respectively.
949  /// When Kind == SK_ConstructorInitialization or SK_ListConstruction,
950  /// the constructor to be called.
951  ///
952  /// Always a FunctionDecl, plus a Boolean flag telling if it was
953  /// selected from an overloaded set having size greater than 1.
954  /// For conversion decls, the naming class is the source type.
955  /// For construct decls, the naming class is the target type.
956  struct F Function;
957 
958  /// When Kind = SK_ConversionSequence, the implicit conversion
959  /// sequence.
961 
962  /// When Kind = SK_RewrapInitList, the syntactic form of the
963  /// wrapping list.
965  };
966 
967  void Destroy();
968  };
969 
970 private:
971  /// The kind of initialization sequence computed.
973 
974  /// Steps taken by this initialization.
975  SmallVector<Step, 4> Steps;
976 
977 public:
978  /// Describes why initialization failed.
979  enum FailureKind {
980  /// Too many initializers provided for a reference.
982 
983  /// Reference initialized from a parenthesized initializer list.
985 
986  /// Array must be initialized with an initializer list.
988 
989  /// Array must be initialized with an initializer list or a
990  /// string literal.
992 
993  /// Array must be initialized with an initializer list or a
994  /// wide string literal.
996 
997  /// Initializing a wide char array with narrow string literal.
999 
1000  /// Initializing char array with wide string literal.
1002 
1003  /// Initializing wide char array with incompatible wide string
1004  /// literal.
1006 
1007  /// Initializing char8_t array with plain string literal.
1009 
1010  /// Initializing char array with UTF-8 string literal.
1012 
1013  /// Array type mismatch.
1015 
1016  /// Non-constant array initializer
1018 
1019  /// Cannot resolve the address of an overloaded function.
1021 
1022  /// Overloading due to reference initialization failed.
1024 
1025  /// Non-const lvalue reference binding to a temporary.
1027 
1028  /// Non-const lvalue reference binding to a bit-field.
1030 
1031  /// Non-const lvalue reference binding to a vector element.
1033 
1034  /// Non-const lvalue reference binding to a matrix element.
1036 
1037  /// Non-const lvalue reference binding to an lvalue of unrelated
1038  /// type.
1040 
1041  /// Rvalue reference binding to an lvalue.
1043 
1044  /// Reference binding drops qualifiers.
1046 
1047  /// Reference with mismatching address space binding to temporary.
1049 
1050  /// Reference binding failed.
1052 
1053  /// Implicit conversion failed.
1055 
1056  /// Implicit conversion failed.
1058 
1059  /// Too many initializers for scalar
1061 
1062  /// Scalar initialized from a parenthesized initializer list.
1064 
1065  /// Reference initialization from an initializer list
1067 
1068  /// Initialization of some unused destination type with an
1069  /// initializer list.
1071 
1072  /// Overloading for a user-defined conversion failed.
1074 
1075  /// Overloading for initialization by constructor failed.
1077 
1078  /// Overloading for list-initialization by constructor failed.
1080 
1081  /// Default-initialization of a 'const' object.
1083 
1084  /// Initialization of an incomplete type.
1086 
1087  /// Variable-length array must not have an initializer.
1089 
1090  /// List initialization failed at some point.
1092 
1093  /// Initializer has a placeholder type which cannot be
1094  /// resolved by initialization.
1096 
1097  /// Trying to take the address of a function that doesn't support
1098  /// having its address taken.
1100 
1101  /// List-copy-initialization chose an explicit constructor.
1103  };
1104 
1105 private:
1106  /// The reason why initialization failed.
1107  FailureKind Failure;
1108 
1109  /// The failed result of overload resolution.
1110  OverloadingResult FailedOverloadResult;
1111 
1112  /// The candidate set created when initialization failed.
1113  OverloadCandidateSet FailedCandidateSet;
1114 
1115  /// The incomplete type that caused a failure.
1116  QualType FailedIncompleteType;
1117 
1118  /// The fixit that needs to be applied to make this initialization
1119  /// succeed.
1120  std::string ZeroInitializationFixit;
1121  SourceLocation ZeroInitializationFixitLoc;
1122 
1123 public:
1124  /// Call for initializations are invalid but that would be valid
1125  /// zero initialzations if Fixit was applied.
1127  ZeroInitializationFixit = Fixit;
1128  ZeroInitializationFixitLoc = L;
1129  }
1130 
1131 private:
1132  /// Prints a follow-up note that highlights the location of
1133  /// the initialized entity, if it's remote.
1134  void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity);
1135 
1136 public:
1137  /// Try to perform initialization of the given entity, creating a
1138  /// record of the steps required to perform the initialization.
1139  ///
1140  /// The generated initialization sequence will either contain enough
1141  /// information to diagnose
1142  ///
1143  /// \param S the semantic analysis object.
1144  ///
1145  /// \param Entity the entity being initialized.
1146  ///
1147  /// \param Kind the kind of initialization being performed.
1148  ///
1149  /// \param Args the argument(s) provided for initialization.
1150  ///
1151  /// \param TopLevelOfInitList true if we are initializing from an expression
1152  /// at the top level inside an initializer list. This disallows
1153  /// narrowing conversions in C++11 onwards.
1154  /// \param TreatUnavailableAsInvalid true if we want to treat unavailable
1155  /// as invalid.
1157  const InitializedEntity &Entity,
1158  const InitializationKind &Kind,
1159  MultiExprArg Args,
1160  bool TopLevelOfInitList = false,
1161  bool TreatUnavailableAsInvalid = true);
1162  void InitializeFrom(Sema &S, const InitializedEntity &Entity,
1163  const InitializationKind &Kind, MultiExprArg Args,
1164  bool TopLevelOfInitList, bool TreatUnavailableAsInvalid);
1165 
1167 
1168  /// Perform the actual initialization of the given entity based on
1169  /// the computed initialization sequence.
1170  ///
1171  /// \param S the semantic analysis object.
1172  ///
1173  /// \param Entity the entity being initialized.
1174  ///
1175  /// \param Kind the kind of initialization being performed.
1176  ///
1177  /// \param Args the argument(s) provided for initialization, ownership of
1178  /// which is transferred into the routine.
1179  ///
1180  /// \param ResultType if non-NULL, will be set to the type of the
1181  /// initialized object, which is the type of the declaration in most
1182  /// cases. However, when the initialized object is a variable of
1183  /// incomplete array type and the initializer is an initializer
1184  /// list, this type will be set to the completed array type.
1185  ///
1186  /// \returns an expression that performs the actual object initialization, if
1187  /// the initialization is well-formed. Otherwise, emits diagnostics
1188  /// and returns an invalid expression.
1189  ExprResult Perform(Sema &S,
1190  const InitializedEntity &Entity,
1191  const InitializationKind &Kind,
1192  MultiExprArg Args,
1193  QualType *ResultType = nullptr);
1194 
1195  /// Diagnose an potentially-invalid initialization sequence.
1196  ///
1197  /// \returns true if the initialization sequence was ill-formed,
1198  /// false otherwise.
1199  bool Diagnose(Sema &S,
1200  const InitializedEntity &Entity,
1201  const InitializationKind &Kind,
1202  ArrayRef<Expr *> Args);
1203 
1204  /// Determine the kind of initialization sequence computed.
1205  enum SequenceKind getKind() const { return SequenceKind; }
1206 
1207  /// Set the kind of sequence computed.
1209 
1210  /// Determine whether the initialization sequence is valid.
1211  explicit operator bool() const { return !Failed(); }
1212 
1213  /// Determine whether the initialization sequence is invalid.
1214  bool Failed() const { return SequenceKind == FailedSequence; }
1215 
1217 
1218  step_iterator step_begin() const { return Steps.begin(); }
1219  step_iterator step_end() const { return Steps.end(); }
1220 
1221  using step_range = llvm::iterator_range<step_iterator>;
1222 
1223  step_range steps() const { return {step_begin(), step_end()}; }
1224 
1225  /// Determine whether this initialization is a direct reference
1226  /// binding (C++ [dcl.init.ref]).
1227  bool isDirectReferenceBinding() const;
1228 
1229  /// Determine whether this initialization failed due to an ambiguity.
1230  bool isAmbiguous() const;
1231 
1232  /// Determine whether this initialization is direct call to a
1233  /// constructor.
1234  bool isConstructorInitialization() const;
1235 
1236  /// Add a new step in the initialization that resolves the address
1237  /// of an overloaded function to a specific function declaration.
1238  ///
1239  /// \param Function the function to which the overloaded function reference
1240  /// resolves.
1242  DeclAccessPair Found,
1243  bool HadMultipleCandidates);
1244 
1245  /// Add a new step in the initialization that performs a derived-to-
1246  /// base cast.
1247  ///
1248  /// \param BaseType the base type to which we will be casting.
1249  ///
1250  /// \param Category Indicates whether the result will be treated as an
1251  /// rvalue, an xvalue, or an lvalue.
1252  void AddDerivedToBaseCastStep(QualType BaseType,
1254 
1255  /// Add a new step binding a reference to an object.
1256  ///
1257  /// \param BindingTemporary True if we are binding a reference to a temporary
1258  /// object (thereby extending its lifetime); false if we are binding to an
1259  /// lvalue or an lvalue treated as an rvalue.
1260  void AddReferenceBindingStep(QualType T, bool BindingTemporary);
1261 
1262  /// Add a new step that makes an extraneous copy of the input
1263  /// to a temporary of the same class type.
1264  ///
1265  /// This extraneous copy only occurs during reference binding in
1266  /// C++98/03, where we are permitted (but not required) to introduce
1267  /// an extra copy. At a bare minimum, we must check that we could
1268  /// call the copy constructor, and produce a diagnostic if the copy
1269  /// constructor is inaccessible or no copy constructor matches.
1270  //
1271  /// \param T The type of the temporary being created.
1273 
1274  /// Add a new step that makes a copy of the input to an object of
1275  /// the given type, as the final step in class copy-initialization.
1276  void AddFinalCopy(QualType T);
1277 
1278  /// Add a new step invoking a conversion function, which is either
1279  /// a constructor or a conversion function.
1280  void AddUserConversionStep(FunctionDecl *Function,
1281  DeclAccessPair FoundDecl,
1282  QualType T,
1283  bool HadMultipleCandidates);
1284 
1285  /// Add a new step that performs a qualification conversion to the
1286  /// given type.
1289 
1290  /// Add a new step that performs a function reference conversion to the
1291  /// given type.
1293 
1294  /// Add a new step that performs conversion from non-atomic to atomic
1295  /// type.
1297 
1298  /// Add a new step that applies an implicit conversion sequence.
1300  QualType T, bool TopLevelOfInitList = false);
1301 
1302  /// Add a list-initialization step.
1304 
1305  /// Add a constructor-initialization step.
1306  ///
1307  /// \param FromInitList The constructor call is syntactically an initializer
1308  /// list.
1309  /// \param AsInitList The constructor is called as an init list constructor.
1311  CXXConstructorDecl *Constructor,
1312  QualType T,
1313  bool HadMultipleCandidates,
1314  bool FromInitList, bool AsInitList);
1315 
1316  /// Add a zero-initialization step.
1318 
1319  /// Add a C assignment step.
1320  //
1321  // FIXME: It isn't clear whether this should ever be needed;
1322  // ideally, we would handle everything needed in C in the common
1323  // path. However, that isn't the case yet.
1324  void AddCAssignmentStep(QualType T);
1325 
1326  /// Add a string init step.
1327  void AddStringInitStep(QualType T);
1328 
1329  /// Add an Objective-C object conversion step, which is
1330  /// always a no-op.
1332 
1333  /// Add an array initialization loop step.
1334  void AddArrayInitLoopStep(QualType T, QualType EltTy);
1335 
1336  /// Add an array initialization step.
1337  void AddArrayInitStep(QualType T, bool IsGNUExtension);
1338 
1339  /// Add a parenthesized array initialization step.
1341 
1342  /// Add a step to pass an object by indirect copy-restore.
1343  void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy);
1344 
1345  /// Add a step to "produce" an Objective-C object (by
1346  /// retaining it).
1348 
1349  /// Add a step to construct a std::initializer_list object from an
1350  /// initializer list.
1352 
1353  /// Add a step to initialize an OpenCL sampler from an integer
1354  /// constant.
1356 
1357  /// Add a step to initialzie an OpenCL opaque type (event_t, queue_t, etc.)
1358  /// from a zero constant.
1360 
1361  /// Add steps to unwrap a initializer list for a reference around a
1362  /// single element and rewrap it at the end.
1363  void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic);
1364 
1365  /// Note that this initialization sequence failed.
1366  void SetFailed(FailureKind Failure) {
1368  this->Failure = Failure;
1369  assert((Failure != FK_Incomplete || !FailedIncompleteType.isNull()) &&
1370  "Incomplete type failure requires a type!");
1371  }
1372 
1373  /// Note that this initialization sequence failed due to failed
1374  /// overload resolution.
1375  void SetOverloadFailure(FailureKind Failure, OverloadingResult Result);
1376 
1377  /// Retrieve a reference to the candidate set when overload
1378  /// resolution fails.
1380  return FailedCandidateSet;
1381  }
1382 
1383  /// Get the overloading result, for when the initialization
1384  /// sequence failed due to a bad overload.
1386  return FailedOverloadResult;
1387  }
1388 
1389  /// Note that this initialization sequence failed due to an
1390  /// incomplete type.
1391  void setIncompleteTypeFailure(QualType IncompleteType) {
1392  FailedIncompleteType = IncompleteType;
1394  }
1395 
1396  /// Determine why initialization failed.
1398  assert(Failed() && "Not an initialization failure!");
1399  return Failure;
1400  }
1401 
1402  /// Dump a representation of this initialization sequence to
1403  /// the given stream, for debugging purposes.
1404  void dump(raw_ostream &OS) const;
1405 
1406  /// Dump a representation of this initialization sequence to
1407  /// standard error, for debugging purposes.
1408  void dump() const;
1409 };
1410 
1411 } // namespace clang
1412 
1413 #endif // LLVM_CLANG_SEMA_INITIALIZATION_H
clang::InitializationSequence::FK_ArrayNeedsInitListOrWideStringLiteral
@ FK_ArrayNeedsInitListOrWideStringLiteral
Array must be initialized with an initializer list or a wide string literal.
Definition: Initialization.h:995
clang::InitializedEntity::EK_TemplateParameter
@ EK_TemplateParameter
The entity being initialized is a non-type template parameter.
Definition: Initialization.h:59
clang::InitializedEntity::EK_Delegating
@ EK_Delegating
The initialization is being done by a delegating constructor.
Definition: Initialization.h:89
clang::InitializedEntity::EK_Variable
@ EK_Variable
The entity being initialized is a variable.
Definition: Initialization.h:53
clang::InitializedEntity::InitializeResult
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type)
Create the initialization entity for the result of a function.
Definition: Initialization.h:300
clang::LangAS::opencl_private
@ opencl_private
clang::InitializationSequence::SK_ConversionSequenceNoNarrowing
@ SK_ConversionSequenceNoNarrowing
Perform an implicit conversion sequence without narrowing.
Definition: Initialization.h:860
clang::InitializationSequence::SK_FinalCopy
@ SK_FinalCopy
Direct-initialization from a reference-related object in the final stage of class copy-initialization...
Definition: Initialization.h:835
clang::InitializedEntity::InitializeMember
static InitializedEntity InitializeMember(FieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
Definition: Initialization.h:378
clang::InitializationSequence::dump
void dump() const
Dump a representation of this initialization sequence to standard error, for debugging purposes.
Definition: SemaInit.cpp:9779
clang::InitializationKind::CreateForInit
static InitializationKind CreateForInit(SourceLocation Loc, bool DirectInit, Expr *Init)
Create an initialization from an initializer (which, for direct initialization from a parenthesized l...
Definition: Initialization.h:698
clang::InitializationSequence::SK_ConstructorInitializationFromList
@ SK_ConstructorInitializationFromList
Perform initialization via a constructor, taking arguments from a single InitListExpr.
Definition: Initialization.h:876
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2401
clang::InitializedEntity::InitializeElement
static InitializedEntity InitializeElement(ASTContext &Context, unsigned Index, const InitializedEntity &Parent)
Create the initialization entity for an array element.
Definition: Initialization.h:399
clang::InitializationKind::IK_Default
@ IK_Default
Default initialization.
Definition: Initialization.h:581
clang::InitializationSequence::StepKind
StepKind
Describes the kind of a particular step in an initialization sequence.
Definition: Initialization.h:808
clang::InitializationSequence::DependentSequence
@ DependentSequence
A dependent initialization, which could not be type-checked due to the presence of dependent types or...
Definition: Initialization.h:800
Specifiers.h
clang::InitializedEntity::getReturnLoc
SourceLocation getReturnLoc() const
Determine the location of the 'return' keyword when initializing the result of a function call.
Definition: Initialization.h:509
clang::InitializationSequence::steps
step_range steps() const
Definition: Initialization.h:1223
clang::InitializationSequence::AddConversionSequenceStep
void AddConversionSequenceStep(const ImplicitConversionSequence &ICS, QualType T, bool TopLevelOfInitList=false)
Add a new step that applies an implicit conversion sequence.
Definition: SemaInit.cpp:3666
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6410
clang::InitializedEntity::EK_StmtExprResult
@ EK_StmtExprResult
The entity being initialized is the result of a statement expression.
Definition: Initialization.h:65
clang::InitializationSequence::setIncompleteTypeFailure
void setIncompleteTypeFailure(QualType IncompleteType)
Note that this initialization sequence failed due to an incomplete type.
Definition: Initialization.h:1391
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:210
DeclAccessPair.h
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::InitializationSequence::SK_BindReferenceToTemporary
@ SK_BindReferenceToTemporary
Reference binding to a temporary.
Definition: Initialization.h:826
clang::InitializationSequence::Step::ICS
ImplicitConversionSequence * ICS
When Kind = SK_ConversionSequence, the implicit conversion sequence.
Definition: Initialization.h:960
clang::InitializationSequence::SK_ArrayLoopInit
@ SK_ArrayLoopInit
Array initialization by elementwise copy.
Definition: Initialization.h:895
clang::Decl::hasAttr
bool hasAttr() const
Definition: DeclBase.h:547
clang::InitializationSequence::SK_StringInit
@ SK_StringInit
Initialization by string.
Definition: Initialization.h:885
clang::InitializedEntity::EK_Temporary
@ EK_Temporary
The entity being initialized is a temporary object.
Definition: Initialization.h:83
clang::InitializationSequence::FK_ConversionFromPropertyFailed
@ FK_ConversionFromPropertyFailed
Implicit conversion failed.
Definition: Initialization.h:1057
clang::InitializedEntity::allowsNRVO
bool allowsNRVO() const
Determine whether this initialization allows the named return value optimization, which also applies ...
Definition: SemaInit.cpp:3372
clang::InitializedEntity::getParent
const InitializedEntity * getParent() const
Retrieve the parent of the entity being initialized, when the initialization itself is occurring with...
Definition: Initialization.h:433
clang::InitializedEntity::getBaseSpecifier
const CXXBaseSpecifier * getBaseSpecifier() const
Retrieve the base specifier.
Definition: Initialization.h:478
clang::InitializationKind::isImplicitValueInit
bool isImplicitValueInit() const
Determine whether this initialization is an implicit value-initialization, e.g., as occurs during agg...
Definition: Initialization.h:739
llvm::SmallVector
Definition: LLVM.h:38
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::InitializationKind::getKind
InitKind getKind() const
Determine the initialization kind.
Definition: Initialization.h:709
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:219
clang::InitializationSequence::SK_OCLSamplerInit
@ SK_OCLSamplerInit
Initialize an OpenCL sampler from an integer.
Definition: Initialization.h:924
clang::InitializationSequence::SK_ConversionSequence
@ SK_ConversionSequence
Perform an implicit conversion sequence.
Definition: Initialization.h:857
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:673
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1385
Attr.h
clang::InitializationSequence::FailureKind
FailureKind
Describes why initialization failed.
Definition: Initialization.h:979
clang::InitializationKind::isCStyleOrFunctionalCast
bool isCStyleOrFunctionalCast() const
Determine whether this initialization is a C-style cast.
Definition: Initialization.h:722
clang::InitializedEntity::dump
void dump() const
Dump a representation of the initialized entity to standard error, for debugging purposes.
Definition: SemaInit.cpp:3449
Ownership.h
AttributeLangSupport::C
@ C
Definition: SemaDeclAttr.cpp:54
clang::InitializationSequence::FK_NonConstLValueReferenceBindingToTemporary
@ FK_NonConstLValueReferenceBindingToTemporary
Non-const lvalue reference binding to a temporary.
Definition: Initialization.h:1026
clang::InitializationSequence::Failed
bool Failed() const
Determine whether the initialization sequence is invalid.
Definition: Initialization.h:1214
clang::InitializedEntity::InitializeLambdaCapture
static InitializedEntity InitializeLambdaCapture(IdentifierInfo *VarID, QualType FieldType, SourceLocation Loc)
Create the initialization entity for a lambda capture.
Definition: Initialization.h:413
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2840
clang::InitializationSequence::FK_VariableLengthArrayHasInitializer
@ FK_VariableLengthArrayHasInitializer
Variable-length array must not have an initializer.
Definition: Initialization.h:1088
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1665
clang::InitializationSequence::Step::F::Function
FunctionDecl * Function
Definition: Initialization.h:941
clang::InitializationSequence::FK_IncompatWideStringIntoWideChar
@ FK_IncompatWideStringIntoWideChar
Initializing wide char array with incompatible wide string literal.
Definition: Initialization.h:1005
clang::InitializationSequence::Step::Type
QualType Type
Definition: Initialization.h:937
clang::InitializedEntity::Variable
VD Variable
When Kind == EK_Variable, EK_Member, EK_Binding, or EK_TemplateParameter, the variable,...
Definition: Initialization.h:183
clang::InitializationSequence::InitializationSequence
InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList=false, bool TreatUnavailableAsInvalid=true)
Try to perform initialization of the given entity, creating a record of the steps required to perform...
Definition: SemaInit.cpp:5638
clang::InitializationSequence::AddUserConversionStep
void AddUserConversionStep(FunctionDecl *Function, DeclAccessPair FoundDecl, QualType T, bool HadMultipleCandidates)
Add a new step invoking a conversion function, which is either a constructor or a conversion function...
Definition: SemaInit.cpp:3620
clang::InitializationSequence::isAmbiguous
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
Definition: SemaInit.cpp:3513
clang::InitListExpr
Describes an C or C++ initializer list.
Definition: Expr.h:4786
clang::InitializationSequence::AddObjCObjectConversionStep
void AddObjCObjectConversionStep(QualType T)
Add an Objective-C object conversion step, which is always a no-op.
Definition: SemaInit.cpp:3719
clang::InitializationSequence::SK_ConstructorInitialization
@ SK_ConstructorInitialization
Perform initialization via a constructor.
Definition: Initialization.h:872
clang::InitializationSequence::NormalSequence
@ NormalSequence
A normal sequence.
Definition: Initialization.h:803
clang::InitializationSequence::AddParenthesizedArrayInitStep
void AddParenthesizedArrayInitStep(QualType T)
Add a parenthesized array initialization step.
Definition: SemaInit.cpp:3744
clang::InitializationSequence::Step::F
Definition: Initialization.h:939
clang::InitializationKind::CreateDirect
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
Definition: Initialization.h:628
clang::InitializedEntity::EK_Base
@ EK_Base
The entity being initialized is a base member subobject.
Definition: Initialization.h:86
clang::InitializationKind::CreateDirectList
static InitializationKind CreateDirectList(SourceLocation InitLoc, SourceLocation LBraceLoc, SourceLocation RBraceLoc)
Definition: Initialization.h:640
clang::InitializedEntity::InitializeParameter
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm)
Create the initialization entity for a parameter.
Definition: Initialization.h:254
clang::InitializedEntity::isDefaultMemberInitializer
bool isDefaultMemberInitializer() const
Is this the default member initializer of a member (specified inside the class definition)?
Definition: Initialization.h:503
clang::InitializationSequence::AddOCLSamplerInitStep
void AddOCLSamplerInitStep(QualType T)
Add a step to initialize an OpenCL sampler from an integer constant.
Definition: SemaInit.cpp:3774
clang::InitializedEntity::EK_Parameter_CF_Audited
@ EK_Parameter_CF_Audited
The entity being initialized is a function parameter; function is member of group of audited CF APIs.
Definition: Initialization.h:121
clang::InitializationSequence::getFailureKind
FailureKind getFailureKind() const
Determine why initialization failed.
Definition: Initialization.h:1397
clang::sema::Capture
Definition: ScopeInfo.h:529
clang::InitializationSequence
Describes the sequence of initializations required to initialize a given object or reference with a s...
Definition: Initialization.h:789
clang::InitializationSequence::SK_StdInitializerList
@ SK_StdInitializerList
Construct a std::initializer_list from an initializer list.
Definition: Initialization.h:917
clang::InitializationSequence::SK_ParenthesizedArrayInit
@ SK_ParenthesizedArrayInit
Array initialization from a parenthesized initializer list.
Definition: Initialization.h:905
clang::InitializedEntity::InitializeTemporary
static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo, QualType Type)
Create the initialization entity for a temporary.
Definition: Initialization.h:350
clang::InitializedEntity::InitializeParameter
static InitializedEntity InitializeParameter(ASTContext &Context, ParmVarDecl *Parm, QualType Type)
Create the initialization entity for a parameter, but use another type.
Definition: Initialization.h:262
clang::InitializationSequence::FK_ArrayTypeMismatch
@ FK_ArrayTypeMismatch
Array type mismatch.
Definition: Initialization.h:1014
clang::InitializationSequence::RewrapReferenceInitList
void RewrapReferenceInitList(QualType T, InitListExpr *Syntactic)
Add steps to unwrap a initializer list for a reference around a single element and rewrap it at the e...
Definition: SemaInit.cpp:3788
clang::InitializedEntity::EntityKind
EntityKind
Specifies the kind of entity being initialized.
Definition: Initialization.h:51
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
clang::InitializationSequence::Step::Kind
StepKind Kind
The kind of conversion or initialization step we are taking.
Definition: Initialization.h:934
clang::LambdaCaptureInitKind::DirectInit
@ DirectInit
[a(b)]
clang::InitializationSequence::FK_Incomplete
@ FK_Incomplete
Initialization of an incomplete type.
Definition: Initialization.h:1085
clang::InitializationSequence::FK_NonConstLValueReferenceBindingToVectorElement
@ FK_NonConstLValueReferenceBindingToVectorElement
Non-const lvalue reference binding to a vector element.
Definition: Initialization.h:1032
clang::InitializationSequence::AddAddressOverloadResolutionStep
void AddAddressOverloadResolutionStep(FunctionDecl *Function, DeclAccessPair Found, bool HadMultipleCandidates)
Add a new step in the initialization that resolves the address of an overloaded function to a specifi...
Definition: SemaInit.cpp:3571
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1490
clang::InitializedEntity::Base
llvm::PointerIntPair< const CXXBaseSpecifier *, 1 > Base
When Kind == EK_Base, the base specifier that provides the base class.
Definition: Initialization.h:202
Overload.h
clang::InitializedEntity::EK_VectorElement
@ EK_VectorElement
The entity being initialized is an element of a vector.
Definition: Initialization.h:93
Decl.h
clang::InitializedEntity::InitializeNew
static InitializedEntity InitializeNew(SourceLocation NewLoc, QualType Type)
Create the initialization entity for an object allocated via new.
Definition: Initialization.h:328
clang::InitializedEntity::InitializeRelatedResult
static InitializedEntity InitializeRelatedResult(ObjCMethodDecl *MD, QualType Type)
Create the initialization entity for a related result.
Definition: Initialization.h:358
clang::InitializationSequence::SK_ProduceObjCObject
@ SK_ProduceObjCObject
Produce an Objective-C object pointer.
Definition: Initialization.h:914
clang::InitializationSequence::FK_ListInitializationFailed
@ FK_ListInitializationFailed
List initialization failed at some point.
Definition: Initialization.h:1091
clang::InitializedEntity::getMethodDecl
ObjCMethodDecl * getMethodDecl() const
Retrieve the ObjectiveC method being initialized.
Definition: Initialization.h:455
clang::InitializationSequence::FK_ReferenceAddrspaceMismatchTemporary
@ FK_ReferenceAddrspaceMismatchTemporary
Reference with mismatching address space binding to temporary.
Definition: Initialization.h:1048
clang::InitializationSequence::FK_TooManyInitsForScalar
@ FK_TooManyInitsForScalar
Too many initializers for scalar.
Definition: Initialization.h:1060
clang::InitializationKind::IK_Value
@ IK_Value
Value initialization.
Definition: Initialization.h:584
clang::TypeInfo
Definition: ASTContext.h:182
clang::InitializationSequence::getFailedOverloadResult
OverloadingResult getFailedOverloadResult() const
Get the overloading result, for when the initialization sequence failed due to a bad overload.
Definition: Initialization.h:1385
llvm::MutableArrayRef
Definition: LLVM.h:35
clang::InitializedEntity::InitializeException
static InitializedEntity InitializeException(SourceLocation ThrowLoc, QualType Type)
Create the initialization entity for an exception object.
Definition: Initialization.h:322
clang::InitializationSequence::SK_QualificationConversionXValue
@ SK_QualificationConversionXValue
Perform a qualification conversion, producing an xvalue.
Definition: Initialization.h:845
clang::InitializationSequence::SK_QualificationConversionLValue
@ SK_QualificationConversionLValue
Perform a qualification conversion, producing an lvalue.
Definition: Initialization.h:848
clang::InitializedEntity::InitializeCompoundLiteralInit
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
Definition: Initialization.h:420
clang::InitializationSequence::SK_ArrayLoopIndex
@ SK_ArrayLoopIndex
Array indexing for initialization by elementwise copy.
Definition: Initialization.h:892
clang::InitializationSequence::SK_RewrapInitList
@ SK_RewrapInitList
Rewrap the single-element initializer list for a reference.
Definition: Initialization.h:869
clang::InitializationSequence::~InitializationSequence
~InitializationSequence()
Definition: SemaInit.cpp:6045
clang::InitializedEntity::allocateManglingNumber
unsigned allocateManglingNumber() const
Definition: Initialization.h:554
clang::InitializationKind::CreateValue
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
Definition: Initialization.h:688
clang::InitializedEntity::InitializeStmtExprResult
static InitializedEntity InitializeStmtExprResult(SourceLocation ReturnLoc, QualType Type)
Definition: Initialization.h:305
clang::InitializationSequence::Step::WrappingSyntacticList
InitListExpr * WrappingSyntacticList
When Kind = SK_RewrapInitList, the syntactic form of the wrapping list.
Definition: Initialization.h:964
clang::InitializationSequence::AddAtomicConversionStep
void AddAtomicConversionStep(QualType Ty)
Add a new step that performs conversion from non-atomic to atomic type.
Definition: SemaInit.cpp:3659
clang::InitializedEntity::InitializeLambdaToBlock
static InitializedEntity InitializeLambdaToBlock(SourceLocation BlockVarLoc, QualType Type)
Definition: Initialization.h:315
clang::InitializationSequence::AddArrayInitStep
void AddArrayInitStep(QualType T, bool IsGNUExtension)
Add an array initialization step.
Definition: SemaInit.cpp:3726
clang::InitializedEntity::EK_Parameter
@ EK_Parameter
The entity being initialized is a function parameter.
Definition: Initialization.h:56
clang::InitializationSequence::Step::Function
struct F Function
When Kind == SK_ResolvedOverloadedFunction or Kind == SK_UserConversion, the function that the expres...
Definition: Initialization.h:956
clang::InitializationSequence::AddOCLZeroOpaqueTypeStep
void AddOCLZeroOpaqueTypeStep(QualType T)
Add a step to initialzie an OpenCL opaque type (event_t, queue_t, etc.) from a zero constant.
Definition: SemaInit.cpp:3781
clang::InitializedEntity::Index
unsigned Index
When Kind == EK_ArrayElement, EK_VectorElement, or EK_ComplexElement, the index of the array or vecto...
Definition: Initialization.h:207
clang::InitializationKind::isCStyleCast
bool isCStyleCast() const
Determine whether this is a C-style cast.
Definition: Initialization.h:727
clang::InitializedEntity::isParameterConsumed
bool isParameterConsumed() const
Determine whether this initialization consumes the parameter.
Definition: Initialization.h:472
clang::InitializationSequence::SK_UnwrapInitList
@ SK_UnwrapInitList
Unwrap the single-element initializer list for a reference.
Definition: Initialization.h:866
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:220
clang::InitializedEntity::getTypeSourceInfo
TypeSourceInfo * getTypeSourceInfo() const
Retrieve complete type-source information for the object being constructed, if known.
Definition: Initialization.h:440
clang::DeclAccessPair
A POD class for pairing a NamedDecl* with an access specifier.
Definition: DeclAccessPair.h:29
clang::InitializedEntity::Parameter
llvm::PointerIntPair< ParmVarDecl *, 1 > Parameter
When Kind == EK_Parameter, the ParmVarDecl, with the integer indicating whether the parameter is "con...
Definition: Initialization.h:191
clang::InitializationSequence::FK_AddressOfUnaddressableFunction
@ FK_AddressOfUnaddressableFunction
Trying to take the address of a function that doesn't support having its address taken.
Definition: Initialization.h:1099
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:212
clang::index::SymbolRole::Implicit
@ Implicit
clang::InitializationSequence::FK_ReferenceInitDropsQualifiers
@ FK_ReferenceInitDropsQualifiers
Reference binding drops qualifiers.
Definition: Initialization.h:1045
clang::DeclaratorContext::Member
@ Member
clang::InitializationSequence::FK_ParenthesizedListInitForScalar
@ FK_ParenthesizedListInitForScalar
Scalar initialized from a parenthesized initializer list.
Definition: Initialization.h:1063
LangOptions.h
clang::InitializationSequence::setSequenceKind
void setSequenceKind(enum SequenceKind SK)
Set the kind of sequence computed.
Definition: Initialization.h:1208
clang::InitializedEntity::MethodDecl
ObjCMethodDecl * MethodDecl
When Kind == EK_RelatedResult, the ObjectiveC method where result type was implicitly changed to acco...
Definition: Initialization.h:187
clang::InitializationSequence::SetFailed
void SetFailed(FailureKind Failure)
Note that this initialization sequence failed.
Definition: Initialization.h:1366
clang::InitializedEntity::isParamOrTemplateParamKind
bool isParamOrTemplateParamKind() const
Definition: Initialization.h:466
clang::InitializationSequence::AddExtraneousCopyToTemporary
void AddExtraneousCopyToTemporary(QualType T)
Add a new step that makes an extraneous copy of the input to a temporary of the same class type.
Definition: SemaInit.cpp:3612
clang::InitializedEntity::EK_Member
@ EK_Member
The entity being initialized is a non-static data member subobject.
Definition: Initialization.h:73
clang::InitializedEntity::Capture
struct C Capture
Definition: Initialization.h:209
clang::InitializationSequence::SK_ResolveAddressOfOverloadedFunction
@ SK_ResolveAddressOfOverloadedFunction
Resolve the address of an overloaded function to a specific function declaration.
Definition: Initialization.h:811
clang::InitializedEntity::getCaptureLoc
SourceLocation getCaptureLoc() const
Determine the location of the capture when initializing field from a captured variable in a lambda.
Definition: Initialization.h:545
clang::InitializedEntity::InitializeBinding
static InitializedEntity InitializeBinding(VarDecl *Binding)
Create the initialization entity for a structured binding.
Definition: Initialization.h:406
clang::InitializationSequence::AddArrayInitLoopStep
void AddArrayInitLoopStep(QualType T, QualType EltTy)
Add an array initialization loop step.
Definition: SemaInit.cpp:3733
clang::InitializationSequence::getFailedCandidateSet
OverloadCandidateSet & getFailedCandidateSet()
Retrieve a reference to the candidate set when overload resolution fails.
Definition: Initialization.h:1379
clang::InitializationKind::IK_DirectList
@ IK_DirectList
Direct list-initialization.
Definition: Initialization.h:575
IdentifierTable.h
clang::InitializedEntity::InitializeBase
static InitializedEntity InitializeBase(ASTContext &Context, const CXXBaseSpecifier *Base, bool IsInheritedVirtualBase, const InitializedEntity *Parent=nullptr)
Create the initialization entity for a base class subobject.
Definition: SemaInit.cpp:3290
Type.h
clang::InitializedEntity::EK_Exception
@ EK_Exception
The entity being initialized is an exception object that is being thrown.
Definition: Initialization.h:69
clang::InitializationSequence::FK_NonConstLValueReferenceBindingToBitfield
@ FK_NonConstLValueReferenceBindingToBitfield
Non-const lvalue reference binding to a bit-field.
Definition: Initialization.h:1029
Expr.h
bool
#define bool
Definition: stdbool.h:15
ASTContext.h
clang::InitializedEntity::EK_New
@ EK_New
The entity being initialized is an object (or array of objects) allocated via new.
Definition: Initialization.h:80
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:876
clang::InitializationSequence::SK_CAssignment
@ SK_CAssignment
C assignment.
Definition: Initialization.h:882
Category
int Category
Definition: Format.cpp:2382
clang::InitializationSequence::step_range
llvm::iterator_range< step_iterator > step_range
Definition: Initialization.h:1221
clang::InitializationSequence::SK_PassByIndirectRestore
@ SK_PassByIndirectRestore
Pass an object by indirect restore.
Definition: Initialization.h:911
clang::InitializedEntity::EK_BlockElement
@ EK_BlockElement
The entity being initialized is a field of block descriptor for the copied-in c++ object.
Definition: Initialization.h:97
clang::InitializationSequence::FK_AddressOfOverloadFailed
@ FK_AddressOfOverloadFailed
Cannot resolve the address of an overloaded function.
Definition: Initialization.h:1020
clang::InitializedEntity::isInheritedVirtualBase
bool isInheritedVirtualBase() const
Return whether the base is an inherited virtual base.
Definition: Initialization.h:484
clang::InitializationSequence::FK_ParenthesizedListInitForReference
@ FK_ParenthesizedListInitForReference
Reference initialized from a parenthesized initializer list.
Definition: Initialization.h:984
clang::InitializationSequence::AddDerivedToBaseCastStep
void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category)
Add a new step in the initialization that performs a derived-to- base cast.
Definition: SemaInit.cpp:3583
clang::InitializationKind::getRange
SourceRange getRange() const
Retrieve the source range that covers the initialization.
Definition: Initialization.h:745
clang::InitializedEntity::setElementIndex
void setElementIndex(unsigned Index)
If this is already the initializer for an array or vector element, sets the element index.
Definition: Initialization.h:531
clang::InitializationSequence::SK_QualificationConversionPRValue
@ SK_QualificationConversionPRValue
Perform a qualification conversion, producing a prvalue.
Definition: Initialization.h:842
Base
clang::InitializationSequence::Diagnose
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
Definition: SemaInit.cpp:8968
clang::InitializationKind::InitKind
InitKind
The kind of initialization being performed.
Definition: Initialization.h:570
clang::InitializationSequence::InitializeFrom
void InitializeFrom(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, bool TopLevelOfInitList, bool TreatUnavailableAsInvalid)
Definition: SemaInit.cpp:5694
clang::InitializationSequence::SetOverloadFailure
void SetOverloadFailure(FailureKind Failure, OverloadingResult Result)
Note that this initialization sequence failed due to failed overload resolution.
Definition: SemaInit.cpp:3803
clang::InitializationSequence::AddZeroInitializationStep
void AddZeroInitializationStep(QualType T)
Add a zero-initialization step.
Definition: SemaInit.cpp:3698
clang::InitializationSequence::FK_PlainStringIntoUTF8Char
@ FK_PlainStringIntoUTF8Char
Initializing char8_t array with plain string literal.
Definition: Initialization.h:1008
clang::InitializedEntity::getType
QualType getType() const
Retrieve type being initialized.
Definition: Initialization.h:436
clang::InitializedEntity::EK_ComplexElement
@ EK_ComplexElement
The entity being initialized is the real or imaginary part of a complex number.
Definition: Initialization.h:105
clang::InitializationSequence::AddConstructorInitializationStep
void AddConstructorInitializationStep(DeclAccessPair FoundDecl, CXXConstructorDecl *Constructor, QualType T, bool HadMultipleCandidates, bool FromInitList, bool AsInitList)
Add a constructor-initialization step.
Definition: SemaInit.cpp:3684
clang::InitializedEntity::InitializeMember
static InitializedEntity InitializeMember(IndirectFieldDecl *Member, const InitializedEntity *Parent=nullptr, bool Implicit=false)
Create the initialization entity for a member subobject.
Definition: Initialization.h:386
clang::InitializationSequence::SK_UserConversion
@ SK_UserConversion
Perform a user-defined conversion, either via a conversion function or via a constructor.
Definition: Initialization.h:839
clang::InitializationKind::AllowExplicit
bool AllowExplicit() const
Retrieve whether this initialization allows the use of explicit constructors.
Definition: Initialization.h:760
clang::InitializationSequence::SK_AtomicConversion
@ SK_AtomicConversion
Perform a conversion adding _Atomic to a type.
Definition: Initialization.h:854
clang::InitializationSequence::SK_BindReference
@ SK_BindReference
Reference binding to an lvalue.
Definition: Initialization.h:823
clang::InitializationSequence::AddStdInitializerListConstructionStep
void AddStdInitializerListConstructionStep(QualType T)
Add a step to construct a std::initializer_list object from an initializer list.
Definition: SemaInit.cpp:3767
clang::InitializationKind::CreateDefault
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
Definition: Initialization.h:683
clang::InitializationSequence::SK_StdInitializerListConstructorCall
@ SK_StdInitializerListConstructorCall
Perform initialization via a constructor taking a single std::initializer_list argument.
Definition: Initialization.h:921
clang::InitializationSequence::SequenceKind
SequenceKind
Describes the kind of initialization sequence computed.
Definition: Initialization.h:792
clang::InitializedEntity::InitializeTemporary
static InitializedEntity InitializeTemporary(ASTContext &Context, TypeSourceInfo *TypeInfo)
Create the initialization entity for a temporary.
Definition: Initialization.h:338
clang::OverloadCandidateSet
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
Definition: Overload.h:936
clang::InitializationSequence::FK_InitListBadDestinationType
@ FK_InitListBadDestinationType
Initialization of some unused destination type with an initializer list.
Definition: Initialization.h:1070
clang::InitializationSequence::FK_ListConstructorOverloadFailed
@ FK_ListConstructorOverloadFailed
Overloading for list-initialization by constructor failed.
Definition: Initialization.h:1079
clang::InitializationSequence::Perform
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence.
Definition: SemaInit.cpp:7987
clang::InitializationSequence::SK_ListInitialization
@ SK_ListInitialization
Perform list-initialization without a constructor.
Definition: Initialization.h:863
clang::InitializationSequence::FK_ReferenceBindingToInitList
@ FK_ReferenceBindingToInitList
Reference initialization from an initializer list.
Definition: Initialization.h:1066
SourceLocation.h
clang::InitializedEntity::getCapturedVarName
StringRef getCapturedVarName() const
For a lambda capture, return the capture's name.
Definition: Initialization.h:538
clang::InitializedEntity::EK_Result
@ EK_Result
The entity being initialized is the result of a function call.
Definition: Initialization.h:62
clang::InitializedEntity::getName
DeclarationName getName() const
Retrieve the name of the entity being initialized.
Definition: SemaInit.cpp:3302
clang::InitializationSequence::AddProduceObjCObjectStep
void AddProduceObjCObjectStep(QualType T)
Add a step to "produce" an Objective-C object (by retaining it).
Definition: SemaInit.cpp:3760
clang::InitializedEntity::EK_RelatedResult
@ EK_RelatedResult
The entity being implicitly initialized back to the formal result type.
Definition: Initialization.h:117
clang::InitializationSequence::step_begin
step_iterator step_begin() const
Definition: Initialization.h:1218
clang::InitializedEntity::getElementIndex
unsigned getElementIndex() const
If this is an array, vector, or complex number element, get the element's index.
Definition: Initialization.h:523
clang::InitializationKind::isFunctionalCast
bool isFunctionalCast() const
Determine whether this is a functional-style cast.
Definition: Initialization.h:732
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:676
clang::InitializationKind::getLocation
SourceLocation getLocation() const
Retrieve the location at which initialization is occurring.
Definition: Initialization.h:742
clang::InitializationSequence::AddQualificationConversionStep
void AddQualificationConversionStep(QualType Ty, ExprValueKind Category)
Add a new step that performs a qualification conversion to the given type.
Definition: SemaInit.cpp:3633
clang::InitializationSequence::FK_NarrowStringIntoWideCharArray
@ FK_NarrowStringIntoWideCharArray
Initializing a wide char array with narrow string literal.
Definition: Initialization.h:998
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Definition: Type.h:738
llvm::ArrayRef
Definition: LLVM.h:34
clang::InitializationKind::CreateFunctionalCast
static InitializationKind CreateFunctionalCast(SourceRange TypeRange, bool InitList)
Create a direct initialization for a functional cast.
Definition: Initialization.h:666
clang::InitializedEntity::InitializeDelegation
static InitializedEntity InitializeDelegation(QualType Type)
Create the initialization entity for a delegated constructor.
Definition: Initialization.h:372
clang::InitializationSequence::isConstructorInitialization
bool isConstructorInitialization() const
Determine whether this initialization is direct call to a constructor.
Definition: SemaInit.cpp:3565
clang::InitializedEntity::setParameterCFAudited
void setParameterCFAudited()
Definition: Initialization.h:550
clang::InitializedEntity::isImplicitMemberInitializer
bool isImplicitMemberInitializer() const
Is this the implicit initialization of a member of a class from a defaulted constructor?
Definition: Initialization.h:497
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:354
LLVM.h
clang::InitializedEntity::EK_CompoundLiteralInit
@ EK_CompoundLiteralInit
The entity being initialized is the initializer for a compound literal.
Definition: Initialization.h:113
clang::InitializationSequence::FK_ConstructorOverloadFailed
@ FK_ConstructorOverloadFailed
Overloading for initialization by constructor failed.
Definition: Initialization.h:1076
clang::InitializedEntity::isVariableLengthArrayNew
bool isVariableLengthArrayNew() const
Determine whether this is an array new with an unknown bound.
Definition: Initialization.h:490
clang::InitializedEntity::TypeInfo
TypeSourceInfo * TypeInfo
When Kind == EK_Temporary or EK_CompoundLiteralInit, the type source information for the temporary.
Definition: Initialization.h:195
clang::InitializationSequence::FK_TooManyInitsForReference
@ FK_TooManyInitsForReference
Too many initializers provided for a reference.
Definition: Initialization.h:981
clang::ExprValueKind
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:117
clang::InitializationSequence::AddListInitializationStep
void AddListInitializationStep(QualType T)
Add a list-initialization step.
Definition: SemaInit.cpp:3677
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:84
clang::InitializationSequence::FK_ConversionFailed
@ FK_ConversionFailed
Implicit conversion failed.
Definition: Initialization.h:1054
clang::InitializedEntity::EK_ArrayElement
@ EK_ArrayElement
The entity being initialized is an element of an array.
Definition: Initialization.h:76
clang::InitializationSequence::SK_PassByIndirectCopyRestore
@ SK_PassByIndirectCopyRestore
Pass an object by indirect copy-and-restore.
Definition: Initialization.h:908
clang::OverloadingResult
OverloadingResult
OverloadingResult - Capture the result of performing overload resolution.
Definition: Overload.h:51
clang::InitializationKind::IK_Direct
@ IK_Direct
Direct initialization.
Definition: Initialization.h:572
clang::InitializedEntity::EK_Binding
@ EK_Binding
The entity being initialized is a structured binding of a decomposition declaration.
Definition: Initialization.h:125
clang::ObjCPropertyAttribute::Kind
Kind
Definition: DeclObjCCommon.h:22
clang::InitializationSequence::step_iterator
SmallVectorImpl< Step >::const_iterator step_iterator
Definition: Initialization.h:1216
clang::InitializationKind
Describes the kind of initialization being performed, along with location information for tokens rela...
Definition: Initialization.h:567
clang::ActionResult
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc.
Definition: Ownership.h:152
clang::InitializationKind::CreateDirectList
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Definition: Initialization.h:635
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:139
DeclarationName.h
clang::InitializationKind::hasParenOrBraceRange
bool hasParenOrBraceRange() const
Determine whether this initialization has a source range containing the locations of open and closing...
Definition: Initialization.h:772
clang::InitializationSequence::FailedSequence
@ FailedSequence
A failed initialization sequence.
Definition: Initialization.h:795
clang::InitializationKind::allowExplicitConversionFunctionsInRefBinding
bool allowExplicitConversionFunctionsInRefBinding() const
Retrieve whether this initialization allows the use of explicit conversion functions when binding a r...
Definition: Initialization.h:766
clang
Definition: CalledOnceCheck.h:17
clang::InitializationSequence::AddReferenceBindingStep
void AddReferenceBindingStep(QualType T, bool BindingTemporary)
Add a new step binding a reference to an object.
Definition: SemaInit.cpp:3597
clang::IndirectFieldDecl
Represents a field injected from an anonymous union/struct into the parent scope.
Definition: Decl.h:3094
clang::InitializedEntity::InitializeMemberFromDefaultMemberInitializer
static InitializedEntity InitializeMemberFromDefaultMemberInitializer(FieldDecl *Member)
Create the initialization entity for a default member initializer.
Definition: Initialization.h:394
clang::InitializationSequence::FK_ArrayNeedsInitList
@ FK_ArrayNeedsInitList
Array must be initialized with an initializer list.
Definition: Initialization.h:987
clang::InitializedEntity::isParameterKind
bool isParameterKind() const
Definition: Initialization.h:461
clang::InitializationSequence::SK_FunctionReferenceConversion
@ SK_FunctionReferenceConversion
Perform a function reference conversion, see [dcl.init.ref]p4.
Definition: Initialization.h:851
clang::InitializationSequence::SK_GNUArrayInit
@ SK_GNUArrayInit
Array initialization (from an array rvalue) as a GNU extension.
Definition: Initialization.h:901
clang::InitializationSequence::AddFunctionReferenceConversionStep
void AddFunctionReferenceConversionStep(QualType Ty)
Add a new step that performs a function reference conversion to the given type.
Definition: SemaInit.cpp:3652
clang::InitializationKind::getEqualLoc
SourceLocation getEqualLoc() const
Retrieve the location of the equal sign for copy initialization (if present).
Definition: Initialization.h:751
clang::InitializationKind::IK_Copy
@ IK_Copy
Copy initialization.
Definition: Initialization.h:578
clang::InitializationSequence::FK_ReferenceInitOverloadFailed
@ FK_ReferenceInitOverloadFailed
Overloading due to reference initialization failed.
Definition: Initialization.h:1023
clang::InitializedEntity::getDecl
ValueDecl * getDecl() const
Retrieve the variable, parameter, or field being initialized.
Definition: SemaInit.cpp:3339
clang::InitializationSequence::FK_PlaceholderType
@ FK_PlaceholderType
Initializer has a placeholder type which cannot be resolved by initialization.
Definition: Initialization.h:1095
clang::InitializedEntity::getKind
EntityKind getKind() const
Determine the kind of initialization.
Definition: Initialization.h:428
clang::InitializationSequence::AddCAssignmentStep
void AddCAssignmentStep(QualType T)
Add a C assignment step.
Definition: SemaInit.cpp:3705
clang::InitializationSequence::SK_ZeroInitialization
@ SK_ZeroInitialization
Zero-initialize the object.
Definition: Initialization.h:879
clang::InitializedEntity::LocAndNRVO
struct LN LocAndNRVO
Definition: Initialization.h:197
clang::InitializationKind::isExplicitCast
bool isExplicitCast() const
Determine whether this initialization is an explicit cast.
Definition: Initialization.h:714
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:147
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6399
clang::InitializationSequence::SK_OCLZeroOpaqueType
@ SK_OCLZeroOpaqueType
Initialize an opaque OpenCL type (event_t, queue_t, etc.) with zero.
Definition: Initialization.h:927
clang::InitializationSequence::Step
A single step in the initialization sequence.
Definition: Initialization.h:931
clang::InitializedEntity::getThrowLoc
SourceLocation getThrowLoc() const
Determine the location of the 'throw' keyword when initializing an exception object.
Definition: Initialization.h:516
clang::InitializedEntity
Describes an entity that is being initialized.
Definition: Initialization.h:48
clang::InitializedEntity::InitializeVariable
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
Definition: Initialization.h:249
clang::InitializedEntity::EK_LambdaToBlockConversionBlockElement
@ EK_LambdaToBlockConversionBlockElement
The entity being initialized is a field of block descriptor for the copied-in lambda object that's us...
Definition: Initialization.h:101
clang::InitializedEntity::InitializeBlock
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type)
Definition: Initialization.h:310
clang::InitializationSequence::FK_ReferenceInitFailed
@ FK_ReferenceInitFailed
Reference binding failed.
Definition: Initialization.h:1051
clang::InitializedEntity::InitializeParameter
static InitializedEntity InitializeParameter(ASTContext &Context, QualType Type, bool Consumed)
Create the initialization entity for a parameter that is only known by its type.
Definition: Initialization.h:277
clang::InitializationKind::isCopyInit
bool isCopyInit() const
Definition: Initialization.h:756
clang::InitializationSequence::FK_UserConversionOverloadFailed
@ FK_UserConversionOverloadFailed
Overloading for a user-defined conversion failed.
Definition: Initialization.h:1073
clang::InitializedEntity::InitializeTemporary
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
Definition: Initialization.h:333
clang::InitializationSequence::SK_CastDerivedToBaseXValue
@ SK_CastDerivedToBaseXValue
Perform a derived-to-base cast, producing an xvalue.
Definition: Initialization.h:817
clang::InitializationSequence::isDirectReferenceBinding
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init....
Definition: SemaInit.cpp:3502
Parent
NodeId Parent
Definition: ASTDiff.cpp:192
clang::InitializationSequence::SK_ObjCObjectConversion
@ SK_ObjCObjectConversion
An initialization that "converts" an Objective-C object (not a point to an object) to another Objecti...
Definition: Initialization.h:889
clang::InitializationSequence::FK_NonConstantArrayInit
@ FK_NonConstantArrayInit
Non-constant array initializer.
Definition: Initialization.h:1017
clang::InitializationSequence::AddStringInitStep
void AddStringInitStep(QualType T)
Add a string init step.
Definition: SemaInit.cpp:3712
clang::InitializationSequence::FK_ArrayNeedsInitListOrStringLiteral
@ FK_ArrayNeedsInitListOrStringLiteral
Array must be initialized with an initializer list or a string literal.
Definition: Initialization.h:991
clang::InitializationKind::CreateCast
static InitializationKind CreateCast(SourceRange TypeRange)
Create a direct initialization due to a cast that isn't a C-style or functional cast.
Definition: Initialization.h:649
llvm::SmallVectorImpl
Definition: LLVM.h:39
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:687
clang::InitializationSequence::Step::F::HadMultipleCandidates
bool HadMultipleCandidates
Definition: Initialization.h:940
clang::InitializationSequence::getKind
enum SequenceKind getKind() const
Determine the kind of initialization sequence computed.
Definition: Initialization.h:1205
clang::Expr
This represents one expression.
Definition: Expr.h:109
clang::InitializationSequence::FK_NonConstLValueReferenceBindingToUnrelated
@ FK_NonConstLValueReferenceBindingToUnrelated
Non-const lvalue reference binding to an lvalue of unrelated type.
Definition: Initialization.h:1039
clang::InitializationSequence::Step::F::FoundDecl
DeclAccessPair FoundDecl
Definition: Initialization.h:942
clang::InitializationSequence::FK_DefaultInitOfConst
@ FK_DefaultInitOfConst
Default-initialization of a 'const' object.
Definition: Initialization.h:1082
clang::InitializationKind::getParenOrBraceRange
SourceRange getParenOrBraceRange() const
Retrieve the source range containing the locations of the open and closing parentheses or braces for ...
Definition: Initialization.h:779
clang::InitializedEntity::EK_LambdaCapture
@ EK_LambdaCapture
The entity being initialized is the field that captures a variable in a lambda.
Definition: Initialization.h:109
clang::InitializationSequence::SK_ExtraneousCopyToTemporary
@ SK_ExtraneousCopyToTemporary
An optional copy of a temporary object to another temporary object, which is permitted (but not requi...
Definition: Initialization.h:831
clang::InitializationSequence::FK_UTF8StringIntoPlainChar
@ FK_UTF8StringIntoPlainChar
Initializing char array with UTF-8 string literal.
Definition: Initialization.h:1011
clang::InitializationSequence::FK_NonConstLValueReferenceBindingToMatrixElement
@ FK_NonConstLValueReferenceBindingToMatrixElement
Non-const lvalue reference binding to a matrix element.
Definition: Initialization.h:1035
clang::InitializationKind::CreateCopy
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
Definition: Initialization.h:674
clang::InitializationSequence::step_end
step_iterator step_end() const
Definition: Initialization.h:1219
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1857
clang::InitializationSequence::SK_CastDerivedToBasePRValue
@ SK_CastDerivedToBasePRValue
Perform a derived-to-base cast, producing an rvalue.
Definition: Initialization.h:814
clang::InitializationSequence::SK_ArrayInit
@ SK_ArrayInit
Array initialization (from an array rvalue).
Definition: Initialization.h:898
clang::InitializedEntity::InitializeTemplateParameter
static InitializedEntity InitializeTemplateParameter(QualType T, NonTypeTemplateParmDecl *Param)
Create the initialization entity for a template parameter.
Definition: Initialization.h:290
clang::InitializationSequence::FK_ExplicitConstructor
@ FK_ExplicitConstructor
List-copy-initialization chose an explicit constructor.
Definition: Initialization.h:1102
clang::InitializationKind::CreateCStyleCast
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
Definition: Initialization.h:655
clang::InitializationSequence::FK_RValueReferenceBindingToLValue
@ FK_RValueReferenceBindingToLValue
Rvalue reference binding to an lvalue.
Definition: Initialization.h:1042
clang::InitializationSequence::SK_CastDerivedToBaseLValue
@ SK_CastDerivedToBaseLValue
Perform a derived-to-base cast, producing an lvalue.
Definition: Initialization.h:820
clang::InitializationSequence::FK_WideStringIntoCharArray
@ FK_WideStringIntoCharArray
Initializing char array with wide string literal.
Definition: Initialization.h:1001
clang::InitializationSequence::SetZeroInitializationFixit
void SetZeroInitializationFixit(const std::string &Fixit, SourceLocation L)
Call for initializations are invalid but that would be valid zero initialzations if Fixit was applied...
Definition: Initialization.h:1126
clang::InitializationSequence::AddPassByIndirectCopyRestoreStep
void AddPassByIndirectCopyRestoreStep(QualType T, bool shouldCopy)
Add a step to pass an object by indirect copy-restore.
Definition: SemaInit.cpp:3751
clang::InitializationKind::isStaticCast
bool isStaticCast() const
Determine whether this initialization is a static cast.
Definition: Initialization.h:719
clang::InitializationSequence::AddFinalCopy
void AddFinalCopy(QualType T)
Add a new step that makes a copy of the input to an object of the given type, as the final step in cl...
Definition: SemaInit.cpp:3605
clang::ImplicitConversionSequence
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
Definition: Overload.h:518
Type
MatchType Type
Definition: ASTMatchFinder.cpp:70
clang::InitializationSequence::Step::Destroy
void Destroy()
Definition: SemaInit.cpp:3457