This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3134d7c44f1: [clang] Replaced some manual pointer tagging 
with llvm::PointerIntPair. (authored by haberman, committed by rsmith).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D98889/new/

https://reviews.llvm.org/D98889

Files:
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaInit.cpp

Index: clang/lib/Sema/SemaInit.cpp
===================================================================
--- clang/lib/Sema/SemaInit.cpp
+++ 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<uintptr_t>(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<ParmVarDecl*>(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<ParmVarDecl*>(Parameter & ~0x1);
+    return Parameter.getPointer();
 
   case EK_Result:
   case EK_StmtExprResult:
Index: clang/lib/Sema/SemaDeclCXX.cpp
===================================================================
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ 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))
Index: clang/include/clang/Sema/Sema.h
===================================================================
--- clang/include/clang/Sema/Sema.h
+++ 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);
Index: clang/include/clang/Sema/Initialization.h
===================================================================
--- clang/include/clang/Sema/Initialization.h
+++ 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<ParmVarDecl *, 1> 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<const CXXBaseSpecifier *, 1> 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<NSConsumedAttr>());
 
@@ -269,8 +268,7 @@
     Entity.Type =
       Context.getVariableArrayDecayedType(Type.getUnqualifiedType());
     Entity.Parent = nullptr;
-    Entity.Parameter
-      = (static_cast<uintptr_t>(Consumed) | reinterpret_cast<uintptr_t>(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<const CXXBaseSpecifier *>(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.
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D98889: [... Josh Haberman via Phabricator via cfe-commits
    • [PATCH] D988... Richard Smith - zygoloid via Phabricator via cfe-commits
    • [PATCH] D988... Josh Haberman via Phabricator via cfe-commits
    • [PATCH] D988... Josh Haberman via Phabricator via cfe-commits
    • [PATCH] D988... Josh Haberman via Phabricator via cfe-commits
    • [PATCH] D988... Richard Smith - zygoloid via Phabricator via cfe-commits

Reply via email to