From 2a9ac0d2c538a97711bb39f44551a7836ca07fb5 Mon Sep 17 00:00:00 2001 From: Zachary Turner Date: Wed, 17 Feb 2016 22:46:33 +0000 Subject: [PATCH] [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. llvm-svn: 261173 --- llvm/include/llvm/DebugInfo/PDB/PDBTypes.h | 4 ++-- llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h index 77b98fb85742..adec27a357df 100644 --- a/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h +++ b/llvm/include/llvm/DebugInfo/PDB/PDBTypes.h @@ -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; diff --git a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp index e863ccf1ffa3..1b30c446a440 100644 --- a/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp +++ b/llvm/lib/DebugInfo/PDB/PDBSymbolCompilandEnv.cpp @@ -22,8 +22,10 @@ PDBSymbolCompilandEnv::PDBSymbolCompilandEnv( : 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 {