Clang Project

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