[Openmp-commits] [PATCH] D119187: [Libomptarget] Replace Value RAII with default value

Joseph Huber via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon Feb 7 14:12:26 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rGd28051c4ab44: [Libomptarget] Replace Value RAII with default value (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119187

Files:
  openmp/libomptarget/DeviceRTL/include/State.h


Index: openmp/libomptarget/DeviceRTL/include/State.h
===================================================================
--- openmp/libomptarget/DeviceRTL/include/State.h
+++ openmp/libomptarget/DeviceRTL/include/State.h
@@ -124,20 +124,21 @@
 
 template <typename VTy, typename Ty> struct ValueRAII {
   ValueRAII(VTy &V, Ty NewValue, Ty OldValue, bool Active, IdentTy *Ident)
-      : Ptr(Active ? V.lookup(/* IsReadonly */ false, Ident) : Val),
+      : Ptr(Active ? &V.lookup(/* IsReadonly */ false, Ident) : nullptr),
         Val(OldValue), Active(Active) {
     if (!Active)
       return;
-    ASSERT(Ptr == OldValue && "ValueRAII initialization with wrong old value!");
-    Ptr = NewValue;
+    ASSERT(*Ptr == OldValue &&
+           "ValueRAII initialization with wrong old value!");
+    *Ptr = NewValue;
   }
   ~ValueRAII() {
     if (Active)
-      Ptr = Val;
+      *Ptr = Val;
   }
 
 private:
-  Ty &Ptr;
+  Ty *Ptr;
   Ty Val;
   bool Active;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119187.406606.patch
Type: text/x-patch
Size: 966 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220207/9bef91cc/attachment-0001.bin>


More information about the Openmp-commits mailing list