diff --git a/clang/include/clang/Sema/Initialization.h b/clang/include/clang/Sema/Initialization.h --- a/clang/include/clang/Sema/Initialization.h +++ b/clang/include/clang/Sema/Initialization.h @@ -187,8 +187,8 @@ ObjCMethodDecl *MethodDecl; /// When Kind == EK_Parameter, the ParmVarDecl, with the - /// low bit indicating whether the parameter is "consumed". - uintptr_t Parameter; + /// integer indicating whether the parameter is "consumed". + llvm::PointerIntPair Parameter; /// When Kind == EK_Temporary or EK_CompoundLiteralInit, the type /// source information for the temporary. @@ -197,9 +197,9 @@ struct LN LocAndNRVO; /// When Kind == EK_Base, the base specifier that provides the - /// base class. The lower bit specifies whether the base is an inherited + /// base class. The integer specifies whether the base is an inherited /// virtual base. - uintptr_t Base; + llvm::PointerIntPair Base; /// When Kind == EK_ArrayElement, EK_VectorElement, or /// EK_ComplexElement, the index of the array or vector element being @@ -252,15 +252,14 @@ /// Create the initialization entity for a parameter. static InitializedEntity InitializeParameter(ASTContext &Context, - const ParmVarDecl *Parm) { + ParmVarDecl *Parm) { return InitializeParameter(Context, Parm, Parm->getType()); } /// Create the initialization entity for a parameter, but use /// another type. - static InitializedEntity InitializeParameter(ASTContext &Context, - const ParmVarDecl *Parm, - QualType Type) { + static InitializedEntity + InitializeParameter(ASTContext &Context, ParmVarDecl *Parm, QualType Type) { bool Consumed = (Context.getLangOpts().ObjCAutoRefCount && Parm->hasAttr()); @@ -269,8 +268,7 @@ Entity.Type = Context.getVariableArrayDecayedType(Type.getUnqualifiedType()); Entity.Parent = nullptr; - Entity.Parameter - = (static_cast(Consumed) | reinterpret_cast(Parm)); + Entity.Parameter = {Parm, Consumed}; return Entity; } @@ -283,7 +281,7 @@ Entity.Kind = EK_Parameter; Entity.Type = Context.getVariableArrayDecayedType(Type); Entity.Parent = nullptr; - Entity.Parameter = (Consumed); + Entity.Parameter = {nullptr, Consumed}; return Entity; } @@ -466,19 +464,19 @@ /// parameter. bool isParameterConsumed() const { assert(isParameterKind() && "Not a parameter"); - return (Parameter & 1); + return Parameter.getInt(); } /// Retrieve the base specifier. const CXXBaseSpecifier *getBaseSpecifier() const { assert(getKind() == EK_Base && "Not a base specifier"); - return reinterpret_cast(Base & ~0x1); + return Base.getPointer(); } /// Return whether the base is an inherited virtual base. bool isInheritedVirtualBase() const { assert(getKind() == EK_Base && "Not a base specifier"); - return Base & 0x1; + return Base.getInt(); } /// Determine whether this is an array new with an unknown bound. diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -2702,8 +2702,7 @@ void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc, SourceLocation ArgLoc); void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc); - ExprResult ConvertParamDefaultArgument(const ParmVarDecl *Param, - Expr *DefaultArg, + ExprResult ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc); void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg, SourceLocation EqualLoc); diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -254,8 +254,7 @@ ComputedEST = EST_None; } -ExprResult Sema::ConvertParamDefaultArgument(const ParmVarDecl *Param, - Expr *Arg, +ExprResult Sema::ConvertParamDefaultArgument(ParmVarDecl *Param, Expr *Arg, SourceLocation EqualLoc) { if (RequireCompleteType(Param->getLocation(), Param->getType(), diag::err_typecheck_decl_incomplete_type)) diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -24,6 +24,7 @@ #include "clang/Sema/Lookup.h" #include "clang/Sema/SemaInternal.h" #include "llvm/ADT/APInt.h" +#include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" @@ -3281,10 +3282,7 @@ InitializedEntity Result; Result.Kind = EK_Base; Result.Parent = Parent; - Result.Base = reinterpret_cast(Base); - if (IsInheritedVirtualBase) - Result.Base |= 0x01; - + Result.Base = {Base, IsInheritedVirtualBase}; Result.Type = Base->getType(); return Result; } @@ -3293,7 +3291,7 @@ switch (getKind()) { case EK_Parameter: case EK_Parameter_CF_Audited: { - ParmVarDecl *D = reinterpret_cast(Parameter & ~0x1); + ParmVarDecl *D = Parameter.getPointer(); return (D ? D->getDeclName() : DeclarationName()); } @@ -3336,7 +3334,7 @@ case EK_Parameter: case EK_Parameter_CF_Audited: - return reinterpret_cast(Parameter & ~0x1); + return Parameter.getPointer(); case EK_Result: case EK_StmtExprResult: