[clang] 400c7c7 - [clang][Interp][NFC] Simplify Pointer move/copy assignment op

Timm Bäder via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 2 19:59:35 PDT 2024


Author: Timm Bäder
Date: 2024-08-03T04:59:16+02:00
New Revision: 400c7c7cf2b15138aa674355983be74270de93bc

URL: https://github.com/llvm/llvm-project/commit/400c7c7cf2b15138aa674355983be74270de93bc
DIFF: https://github.com/llvm/llvm-project/commit/400c7c7cf2b15138aa674355983be74270de93bc.diff

LOG: [clang][Interp][NFC] Simplify Pointer move/copy assignment op

Added: 
    

Modified: 
    clang/lib/AST/Interp/Pointer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/AST/Interp/Pointer.cpp b/clang/lib/AST/Interp/Pointer.cpp
index 3ac8bc2b09709..afa9d19d62823 100644
--- a/clang/lib/AST/Interp/Pointer.cpp
+++ b/clang/lib/AST/Interp/Pointer.cpp
@@ -67,12 +67,10 @@ Pointer::~Pointer() {
 void Pointer::operator=(const Pointer &P) {
   // If the current storage type is Block, we need to remove
   // this pointer from the block.
-  bool WasBlockPointer = isBlockPointer();
-  if (StorageKind == Storage::Block) {
-    Block *Old = PointeeStorage.BS.Pointee;
-    if (WasBlockPointer && Old) {
-      PointeeStorage.BS.Pointee->removePointer(this);
-      Old->cleanup();
+  if (isBlockPointer()) {
+    if (Block *Pointee = PointeeStorage.BS.Pointee) {
+      Pointee->removePointer(this);
+      Pointee->cleanup();
     }
   }
 
@@ -97,12 +95,10 @@ void Pointer::operator=(const Pointer &P) {
 void Pointer::operator=(Pointer &&P) {
   // If the current storage type is Block, we need to remove
   // this pointer from the block.
-  bool WasBlockPointer = isBlockPointer();
-  if (StorageKind == Storage::Block) {
-    Block *Old = PointeeStorage.BS.Pointee;
-    if (WasBlockPointer && Old) {
-      PointeeStorage.BS.Pointee->removePointer(this);
-      Old->cleanup();
+  if (isBlockPointer()) {
+    if (Block *Pointee = PointeeStorage.BS.Pointee) {
+      Pointee->removePointer(this);
+      Pointee->cleanup();
     }
   }
 


        


More information about the cfe-commits mailing list