[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
This commit is contained in:
Zachary Turner 2016-02-17 22:46:33 +00:00
parent 22d2878399
commit 2a9ac0d2c5
2 changed files with 6 additions and 4 deletions

View File

@ -363,7 +363,7 @@ struct Variant {
} }
~Variant() { ~Variant() {
if (Type == PDB_VariantType::String && Value.String != nullptr) if (Type == PDB_VariantType::String)
delete[] Value.String; delete[] Value.String;
} }
@ -410,7 +410,7 @@ struct Variant {
Variant &operator=(const Variant &Other) { Variant &operator=(const Variant &Other) {
if (this == &Other) if (this == &Other)
return *this; return *this;
if (Type == PDB_VariantType::String && Value.String != nullptr) if (Type == PDB_VariantType::String)
delete[] Value.String; delete[] Value.String;
Type = Other.Type; Type = Other.Type;
Value = Other.Value; Value = Other.Value;

View File

@ -22,8 +22,10 @@ PDBSymbolCompilandEnv::PDBSymbolCompilandEnv(
: PDBSymbol(PDBSession, std::move(Symbol)) {} : PDBSymbol(PDBSession, std::move(Symbol)) {}
std::string PDBSymbolCompilandEnv::getValue() const { std::string PDBSymbolCompilandEnv::getValue() const {
// call RawSymbol->getValue() and convert the result to an std::string. llvm::Variant Value = RawSymbol->getValue();
return std::string(); if (Value.Type != PDB_VariantType::String)
return std::string();
return std::string(Value.Value.String);
} }
void PDBSymbolCompilandEnv::dump(PDBSymDumper &Dumper) const { void PDBSymbolCompilandEnv::dump(PDBSymDumper &Dumper) const {