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