[llvm] r261173 - [DebugInfoPDB] A few cleanups on PDB Variant class.
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 18 09:21:00 PST 2016
On Wed, Feb 17, 2016 at 2:46 PM, Zachary Turner via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> 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);
>
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)
> }
>
> void PDBSymbolCompilandEnv::dump(PDBSymDumper &Dumper) const {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160218/a60dc934/attachment.html>
More information about the llvm-commits
mailing list