diff options
Diffstat (limited to 'include/clang/Sema/Initialization.h')
-rw-r--r-- | include/clang/Sema/Initialization.h | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/include/clang/Sema/Initialization.h b/include/clang/Sema/Initialization.h index 7a510f391bda4..8582e971d0b6c 100644 --- a/include/clang/Sema/Initialization.h +++ b/include/clang/Sema/Initialization.h @@ -102,7 +102,7 @@ public: /// complex number. EK_ComplexElement, - /// The entity being initialized is the field that captures a + /// The entity being initialized is the field that captures a /// variable in a lambda. EK_LambdaCapture, @@ -178,7 +178,7 @@ private: union { /// When Kind == EK_Variable, EK_Member or EK_Binding, the variable. VD Variable; - + /// When Kind == EK_RelatedResult, the ObjectiveC method where /// result type was implicitly changed to accommodate ARC semantics. ObjCMethodDecl *MethodDecl; @@ -186,21 +186,21 @@ private: /// When Kind == EK_Parameter, the ParmVarDecl, with the /// low bit indicating whether the parameter is "consumed". uintptr_t Parameter; - + /// When Kind == EK_Temporary or EK_CompoundLiteralInit, the type /// source information for the temporary. TypeSourceInfo *TypeInfo; struct LN LocAndNRVO; - - /// When Kind == EK_Base, the base specifier that provides the + + /// When Kind == EK_Base, the base specifier that provides the /// base class. The lower bit specifies whether the base is an inherited /// virtual base. uintptr_t Base; /// When Kind == EK_ArrayElement, EK_VectorElement, or /// EK_ComplexElement, the index of the array or vector element being - /// initialized. + /// initialized. unsigned Index; struct C Capture; @@ -211,7 +211,7 @@ private: /// Create the initialization entity for a variable. InitializedEntity(VarDecl *Var, EntityKind EK = EK_Variable) : Kind(EK), Type(Var->getType()), Variable{Var, false, false} {} - + /// Create the initialization entity for the result of a /// function, throwing an object, performing an explicit cast, or /// initializing a parameter for which there is no declaration. @@ -221,15 +221,15 @@ private: LocAndNRVO.Location = Loc.getRawEncoding(); LocAndNRVO.NRVO = NRVO; } - + /// Create the initialization entity for a member subobject. InitializedEntity(FieldDecl *Member, const InitializedEntity *Parent, bool Implicit, bool DefaultMemberInit) : Kind(EK_Member), Parent(Parent), Type(Member->getType()), Variable{Member, Implicit, DefaultMemberInit} {} - + /// Create the initialization entity for an array element. - InitializedEntity(ASTContext &Context, unsigned Index, + InitializedEntity(ASTContext &Context, unsigned Index, const InitializedEntity &Parent); /// Create the initialization entity for a lambda capture. @@ -238,7 +238,7 @@ private: Capture.VarID = VarID; Capture.Location = Loc.getRawEncoding(); } - + public: /// Create the initialization entity for a variable. static InitializedEntity InitializeVariable(VarDecl *Var) { @@ -314,7 +314,7 @@ public: static InitializedEntity InitializeNew(SourceLocation NewLoc, QualType Type) { return InitializedEntity(EK_New, NewLoc, Type); } - + /// Create the initialization entity for a temporary. static InitializedEntity InitializeTemporary(QualType Type) { return InitializeTemporary(nullptr, Type); @@ -324,7 +324,7 @@ public: static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo) { return InitializeTemporary(TypeInfo, TypeInfo->getType()); } - + /// Create the initialization entity for a temporary. static InitializedEntity InitializeTemporary(TypeSourceInfo *TypeInfo, QualType Type) { @@ -332,7 +332,7 @@ public: Result.TypeInfo = TypeInfo; return Result; } - + /// Create the initialization entity for a related result. static InitializedEntity InitializeRelatedResult(ObjCMethodDecl *MD, QualType Type) { @@ -375,8 +375,8 @@ public: } /// Create the initialization entity for an array element. - static InitializedEntity InitializeElement(ASTContext &Context, - unsigned Index, + static InitializedEntity InitializeElement(ASTContext &Context, + unsigned Index, const InitializedEntity &Parent) { return InitializedEntity(Context, Index, Parent); } @@ -403,7 +403,7 @@ public: /// Determine the kind of initialization. EntityKind getKind() const { return Kind; } - + /// Retrieve the parent of the entity being initialized, when /// the initialization itself is occurring within the context of a /// larger initialization. @@ -411,27 +411,27 @@ public: /// Retrieve type being initialized. QualType getType() const { return Type; } - - /// Retrieve complete type-source information for the object being + + /// Retrieve complete type-source information for the object being /// constructed, if known. TypeSourceInfo *getTypeSourceInfo() const { if (Kind == EK_Temporary || Kind == EK_CompoundLiteralInit) return TypeInfo; - + return nullptr; } - + /// Retrieve the name of the entity being initialized. DeclarationName getName() const; /// Retrieve the variable, parameter, or field being /// initialized. ValueDecl *getDecl() const; - + /// Retrieve the ObjectiveC method being initialized. ObjCMethodDecl *getMethodDecl() const { return MethodDecl; } - /// Determine whether this initialization allows the named return + /// Determine whether this initialization allows the named return /// value optimization, which also applies to thrown objects. bool allowsNRVO() const; @@ -446,7 +446,7 @@ public: assert(isParameterKind() && "Not a parameter"); return (Parameter & 1); } - + /// Retrieve the base specifier. const CXXBaseSpecifier *getBaseSpecifier() const { assert(getKind() == EK_Base && "Not a base specifier"); @@ -519,7 +519,7 @@ public: assert(getKind() == EK_LambdaCapture && "Not a lambda capture!"); return SourceLocation::getFromRawEncoding(Capture.Location); } - + void setParameterCFAudited() { Kind = EK_Parameter_CF_Audited; } @@ -533,8 +533,8 @@ public: private: unsigned dumpImpl(raw_ostream &OS) const; }; - -/// Describes the kind of initialization being performed, along with + +/// Describes the kind of initialization being performed, along with /// location information for tokens related to the initialization (equal sign, /// parentheses). class InitializationKind { @@ -556,7 +556,7 @@ public: /// Value initialization IK_Value }; - + private: /// The context of the initialization. enum InitContext { @@ -578,24 +578,24 @@ private: /// Functional cast context IC_FunctionalCast }; - + /// The kind of initialization being performed. InitKind Kind : 8; /// The context of the initialization. InitContext Context : 8; - + /// The source locations involved in the initialization. SourceLocation Locations[3]; - - InitializationKind(InitKind Kind, InitContext Context, SourceLocation Loc1, + + InitializationKind(InitKind Kind, InitContext Context, SourceLocation Loc1, SourceLocation Loc2, SourceLocation Loc3) : Kind(Kind), Context(Context) { Locations[0] = Loc1; Locations[1] = Loc2; Locations[2] = Loc3; } - + public: /// Create a direct initialization. static InitializationKind CreateDirect(SourceLocation InitLoc, @@ -617,13 +617,13 @@ public: RBraceLoc); } - /// Create a direct initialization due to a cast that isn't a C-style + /// Create a direct initialization due to a cast that isn't a C-style /// or functional cast. static InitializationKind CreateCast(SourceRange TypeRange) { return InitializationKind(IK_Direct, IC_StaticCast, TypeRange.getBegin(), TypeRange.getBegin(), TypeRange.getEnd()); } - + /// Create a direct initialization for a C-style cast. static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, @@ -647,16 +647,16 @@ public: static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs = false) { - return InitializationKind(IK_Copy, + return InitializationKind(IK_Copy, AllowExplicitConvs? IC_ExplicitConvs : IC_Normal, InitLoc, EqualLoc, EqualLoc); } - + /// Create a default initialization. static InitializationKind CreateDefault(SourceLocation InitLoc) { return InitializationKind(IK_Default, IC_Normal, InitLoc, InitLoc, InitLoc); } - + /// Create a value initialization. static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, @@ -676,20 +676,20 @@ public: return CreateDirectList(Loc, Init->getLocStart(), Init->getLocEnd()); return CreateDirect(Loc, Init->getLocStart(), Init->getLocEnd()); } - + /// Determine the initialization kind. InitKind getKind() const { return Kind; } - + /// Determine whether this initialization is an explicit cast. bool isExplicitCast() const { return Context >= IC_StaticCast; } - + /// Determine whether this initialization is a C-style cast. - bool isCStyleOrFunctionalCast() const { - return Context >= IC_CStyleCast; + bool isCStyleOrFunctionalCast() const { + return Context >= IC_CStyleCast; } /// Determine whether this is a C-style cast. @@ -709,12 +709,12 @@ public: /// Retrieve the location at which initialization is occurring. SourceLocation getLocation() const { return Locations[0]; } - + /// Retrieve the source range that covers the initialization. - SourceRange getRange() const { + SourceRange getRange() const { return SourceRange(Locations[0], Locations[2]); } - + /// Retrieve the location of the equal sign for copy initialization /// (if present). SourceLocation getEqualLoc() const { @@ -741,7 +741,7 @@ public: bool hasParenOrBraceRange() const { return Kind == IK_Direct || Kind == IK_Value || Kind == IK_DirectList; } - + /// Retrieve the source range containing the locations of the open /// and closing parentheses or braces for value, direct, and direct list /// initializations. @@ -771,7 +771,7 @@ public: /// A normal sequence. NormalSequence }; - + /// Describes the kind of a particular step in an initialization /// sequence. enum StepKind { @@ -898,13 +898,13 @@ public: /// Passing zero to a function where OpenCL event_t is expected. SK_OCLZeroEvent }; - + /// A single step in the initialization sequence. class Step { public: /// The kind of conversion or initialization step we are taking. StepKind Kind; - + // The type that results from this initialization. QualType Type; @@ -916,7 +916,7 @@ public: union { /// When Kind == SK_ResolvedOverloadedFunction or Kind == - /// SK_UserConversion, the function that the expression should be + /// SK_UserConversion, the function that the expression should be /// resolved to or the conversion function to call, respectively. /// When Kind == SK_ConstructorInitialization or SK_ListConstruction, /// the constructor to be called. @@ -938,14 +938,14 @@ public: void Destroy(); }; - + private: /// The kind of initialization sequence computed. enum SequenceKind SequenceKind; - + /// Steps taken by this initialization. SmallVector<Step, 4> Steps; - + public: /// Describes why initialization failed. enum FailureKind { @@ -958,7 +958,7 @@ public: /// Array must be initialized with an initializer list. FK_ArrayNeedsInitList, - /// Array must be initialized with an initializer list or a + /// Array must be initialized with an initializer list or a /// string literal. FK_ArrayNeedsInitListOrStringLiteral, @@ -1067,14 +1067,14 @@ public: /// List-copy-initialization chose an explicit constructor. FK_ExplicitConstructor, }; - + private: /// The reason why initialization failed. FailureKind Failure; /// The failed result of overload resolution. OverloadingResult FailedOverloadResult; - + /// The candidate set created when initialization failed. OverloadCandidateSet FailedCandidateSet; @@ -1100,11 +1100,11 @@ private: void PrintInitLocationNote(Sema &S, const InitializedEntity &Entity); public: - /// Try to perform initialization of the given entity, creating a + /// Try to perform initialization of the given entity, creating a /// record of the steps required to perform the initialization. /// /// The generated initialization sequence will either contain enough - /// information to diagnose + /// information to diagnose /// /// \param S the semantic analysis object. /// @@ -1119,7 +1119,7 @@ public: /// narrowing conversions in C++11 onwards. /// \param TreatUnavailableAsInvalid true if we want to treat unavailable /// as invalid. - InitializationSequence(Sema &S, + InitializationSequence(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, @@ -1130,7 +1130,7 @@ public: bool TopLevelOfInitList, bool TreatUnavailableAsInvalid); ~InitializationSequence(); - + /// Perform the actual initialization of the given entity based on /// the computed initialization sequence. /// @@ -1157,22 +1157,22 @@ public: const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType = nullptr); - + /// Diagnose an potentially-invalid initialization sequence. /// - /// \returns true if the initialization sequence was ill-formed, + /// \returns true if the initialization sequence was ill-formed, /// false otherwise. - bool Diagnose(Sema &S, + bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef<Expr *> Args); - + /// Determine the kind of initialization sequence computed. enum SequenceKind getKind() const { return SequenceKind; } - + /// Set the kind of sequence computed. void setSequenceKind(enum SequenceKind SK) { SequenceKind = SK; } - + /// Determine whether the initialization sequence is valid. explicit operator bool() const { return !Failed(); } @@ -1188,14 +1188,14 @@ public: step_range steps() const { return {step_begin(), step_end()}; } - /// Determine whether this initialization is a direct reference + /// Determine whether this initialization is a direct reference /// binding (C++ [dcl.init.ref]). bool isDirectReferenceBinding() const; - + /// Determine whether this initialization failed due to an ambiguity. bool isAmbiguous() const; - - /// Determine whether this initialization is direct call to a + + /// Determine whether this initialization is direct call to a /// constructor. bool isConstructorInitialization() const; @@ -1228,7 +1228,7 @@ public: /// rvalue, an xvalue, or an lvalue. void AddDerivedToBaseCastStep(QualType BaseType, ExprValueKind Category); - + /// Add a new step binding a reference to an object. /// /// \param BindingTemporary True if we are binding a reference to a temporary @@ -1351,11 +1351,11 @@ public: assert((Failure != FK_Incomplete || !FailedIncompleteType.isNull()) && "Incomplete type failure requires a type!"); } - + /// Note that this initialization sequence failed due to failed /// overload resolution. void SetOverloadFailure(FailureKind Failure, OverloadingResult Result); - + /// Retrieve a reference to the candidate set when overload /// resolution fails. OverloadCandidateSet &getFailedCandidateSet() { @@ -1381,15 +1381,15 @@ public: return Failure; } - /// Dump a representation of this initialization sequence to + /// Dump a representation of this initialization sequence to /// the given stream, for debugging purposes. void dump(raw_ostream &OS) const; - - /// Dump a representation of this initialization sequence to + + /// Dump a representation of this initialization sequence to /// standard error, for debugging purposes. void dump() const; }; - + } // namespace clang #endif // LLVM_CLANG_SEMA_INITIALIZATION_H |