[llvm-commits] [PATCH] [ARM] simplify memory management for ConstantPoolValue

Saleem Abdulrasool compnerd at compnerd.org
Fri Dec 21 18:48:48 PST 2012



================
Comment at: lib/Target/ARM/ARMConstantPoolValue.cpp:243
@@ -255,3 +242,3 @@
 void ARMConstantPoolSymbol::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
-  ID.AddPointer(S);
+  ID.AddPointer(S.c_str());
   ARMConstantPoolValue::addSelectionDAGCSEId(ID);
----------------
Eli Friedman wrote:
> AddString?
I must have missed that AddString was part of the interface.  Thanks.

================
Comment at: lib/Target/ARM/ARMConstantPoolValue.h:174
@@ -175,3 +173,3 @@
 
-  const char *getSymbol() const { return S; }
+  const char *getSymbol() const { return S.c_str(); }
 
----------------
Eli Friedman wrote:
> char*'s make me uncomfortable... particularly given how this function is used.  What are the lifetime rules for this string?
I agree, char * isnt ideal.  I think that it goes beyond the scope of this change to change that.  However, I may take a stab at changing that as a separate change.

The lifetime for the returned string is governed by the lifetime of the symbol itself.


http://llvm-reviews.chandlerc.com/D230



More information about the llvm-commits mailing list