Author: Timm Bäder
Date: 2024-07-09T10:12:53+02:00
New Revision: 4f68d20d87b5a4c06c4ec954c93069cebeb6dfee

URL: 
https://github.com/llvm/llvm-project/commit/4f68d20d87b5a4c06c4ec954c93069cebeb6dfee
DIFF: 
https://github.com/llvm/llvm-project/commit/4f68d20d87b5a4c06c4ec954c93069cebeb6dfee.diff

LOG: [clang][Interp][NFC] Simplify Pointer Block accessing code

Try to get PointeeStorage.BS.Pointee only once and reuse that.

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 157892ea492f6..b2e3a7ff70881 100644
--- a/clang/lib/AST/Interp/Pointer.cpp
+++ b/clang/lib/AST/Interp/Pointer.cpp
@@ -57,9 +57,9 @@ Pointer::~Pointer() {
   if (isIntegralPointer())
     return;
 
-  if (PointeeStorage.BS.Pointee) {
-    PointeeStorage.BS.Pointee->removePointer(this);
-    PointeeStorage.BS.Pointee->cleanup();
+  if (Block *Pointee = PointeeStorage.BS.Pointee) {
+    Pointee->removePointer(this);
+    Pointee->cleanup();
   }
 }
 
@@ -188,6 +188,7 @@ APValue Pointer::toAPValue() const {
 void Pointer::print(llvm::raw_ostream &OS) const {
   OS << PointeeStorage.BS.Pointee << " (";
   if (isBlockPointer()) {
+    const Block *B = PointeeStorage.BS.Pointee;
     OS << "Block) {";
 
     if (isRoot())
@@ -200,8 +201,8 @@ void Pointer::print(llvm::raw_ostream &OS) const {
     else
       OS << Offset << ", ";
 
-    if (PointeeStorage.BS.Pointee)
-      OS << PointeeStorage.BS.Pointee->getSize();
+    if (B)
+      OS << B->getSize();
     else
       OS << "nullptr";
   } else {


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to