[llvm] r261173 - [DebugInfoPDB] A few cleanups on PDB Variant class.

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 14:46:33 PST 2016


Author: zturner
Date: Wed Feb 17 16:46:33 2016
New Revision: 261173

URL: http://llvm.org/viewvc/llvm-project?rev=261173&view=rev
Log:
[DebugInfoPDB] A few cleanups on PDB Variant class.

Also implements the PDBSymbolCompilandEnv::getValue() method,
which until now had been unimplemented specifically because
variant did not support string values.

Modified:
    llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h
    llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp

Modified: llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h?rev=261173&r1=261172&r2=261173&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/PDB/PDBTypes.h Wed Feb 17 16:46:33 2016
@@ -363,7 +363,7 @@ struct Variant {
   }
 
   ~Variant() {
-    if (Type == PDB_VariantType::String && Value.String != nullptr)
+    if (Type == PDB_VariantType::String)
       delete[] Value.String;
   }
 
@@ -410,7 +410,7 @@ struct Variant {
   Variant &operator=(const Variant &Other) {
     if (this == &Other)
       return *this;
-    if (Type == PDB_VariantType::String && Value.String != nullptr)
+    if (Type == PDB_VariantType::String)
       delete[] Value.String;
     Type = Other.Type;
     Value = Other.Value;

Modified: llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp?rev=261173&r1=261172&r2=261173&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp (original)
+++ llvm/trunk/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp Wed Feb 17 16:46:33 2016
@@ -22,8 +22,10 @@ PDBSymbolCompilandEnv::PDBSymbolCompilan
     : PDBSymbol(PDBSession, std::move(Symbol)) {}
 
 std::string PDBSymbolCompilandEnv::getValue() const {
-  // call RawSymbol->getValue() and convert the result to an std::string.
-  return std::string();
+    llvm::Variant Value = RawSymbol->getValue();
+    if (Value.Type != PDB_VariantType::String)
+        return std::string();
+    return std::string(Value.Value.String);
 }
 
 void PDBSymbolCompilandEnv::dump(PDBSymDumper &Dumper) const {




More information about the llvm-commits mailing list