[PATCH] D12805: [mips] Save a copy of MipsABIInfo in the MipsTargetStreamer to escape a dangling pointer

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 04:19:29 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL247546: [mips] Save a copy of MipsABIInfo in the MipsTargetStreamer to escape a… (authored by atanasyan).

Changed prior to commit:
  http://reviews.llvm.org/D12805?vs=34551&id=34663#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12805

Files:
  llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h

Index: llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
===================================================================
--- llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
+++ llvm/trunk/lib/Target/Mips/MipsTargetStreamer.h
@@ -12,6 +12,7 @@
 
 #include "MCTargetDesc/MipsABIFlagsSection.h"
 #include "MCTargetDesc/MipsABIInfo.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/MC/MCELFStreamer.h"
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
@@ -97,18 +98,18 @@
   // structure values.
   template <class PredicateLibrary>
   void updateABIInfo(const PredicateLibrary &P) {
-    ABI = &P.getABI();
+    ABI = P.getABI();
     ABIFlagsSection.setAllFromPredicates(P);
   }
 
   MipsABIFlagsSection &getABIFlagsSection() { return ABIFlagsSection; }
   const MipsABIInfo &getABI() const {
-    assert(ABI && "ABI hasn't been set!");
+    assert(ABI.hasValue() && "ABI hasn't been set!");
     return *ABI;
   }
 
 protected:
-  const MipsABIInfo *ABI;
+  llvm::Optional<MipsABIInfo> ABI;
   MipsABIFlagsSection ABIFlagsSection;
 
   bool GPRInfoSet;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12805.34663.patch
Type: text/x-patch
Size: 1076 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150914/b2e011ec/attachment.bin>


More information about the llvm-commits mailing list