<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 17, 2016 at 2:46 PM, Zachary Turner via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: zturner<br>
Date: Wed Feb 17 16:46:33 2016<br>
New Revision: 261173<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=261173&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=261173&view=rev</a><br>
Log:<br>
[DebugInfoPDB] A few cleanups on PDB Variant class.<br>
<br>
Also implements the PDBSymbolCompilandEnv::getValue() method,<br>
which until now had been unimplemented specifically because<br>
variant did not support string values.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h<br>
    llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp<br>
<br>
Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h?rev=261173&r1=261172&r2=261173&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h?rev=261173&r1=261172&r2=261173&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h (original)<br>
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h Wed Feb 17 16:46:33 2016<br>
@@ -363,7 +363,7 @@ struct Variant {<br>
   }<br>
<br>
   ~Variant() {<br>
-    if (Type == PDB_VariantType::String && Value.String != nullptr)<br>
+    if (Type == PDB_VariantType::String)<br>
       delete[] Value.String;<br>
   }<br>
<br>
@@ -410,7 +410,7 @@ struct Variant {<br>
   Variant &operator=(const Variant &Other) {<br>
     if (this == &Other)<br>
       return *this;<br>
-    if (Type == PDB_VariantType::String && Value.String != nullptr)<br>
+    if (Type == PDB_VariantType::String)<br>
       delete[] Value.String;<br>
     Type = Other.Type;<br>
     Value = Other.Value;<br>
<br>
Modified: llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp?rev=261173&r1=261172&r2=261173&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp?rev=261173&r1=261172&r2=261173&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp (original)<br>
+++ llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp Wed Feb 17 16:46:33 2016<br>
@@ -22,8 +22,10 @@ PDBSymbolCompilandEnv::PDBSymbolCompilan<br>
     : PDBSymbol(PDBSession, std::move(Symbol)) {}<br>
<br>
 std::string PDBSymbolCompilandEnv::getValue() const {<br>
-  // call RawSymbol->getValue() and convert the result to an std::string.<br>
-  return std::string();<br>
+    llvm::Variant Value = RawSymbol->getValue();<br>
+    if (Value.Type != PDB_VariantType::String)<br>
+        return std::string();<br>
+    return std::string(Value.Value.String);<br></blockquote><div><br></div><div>You can just rely on std::string's implicit const char* ctor here and "return Value.Value.String" if you like. (& on the line above, just 'return "";' if you like, too)</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 }<br>
<br>
 void PDBSymbolCompilandEnv::dump(PDBSymDumper &Dumper) const {<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>