[PATCH] D34668: llvm-nm: Add suport for symbol demangling (-C/--demangle)
Jonathan Roelofs via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 10:22:50 PDT 2017
On 6/27/17 6:35 PM, Rafael Avila de Espindola via llvm-commits wrote:
> Sam Clegg via Phabricator <reviews at reviews.llvm.org> writes:
>> +static Optional<std::string> demangle(StringRef Name, bool StripUnderscore) {
>> + if (StripUnderscore && Name.size() > 0 && Name[0] == '_')
>> + Name = Name.substr(1);
>> +
>> + if (Name.size() < 2 || !Name.startswith("_Z"))
>> + return None;
>
> I don't think you need the .size() checks. It is safe to just use startswith.
>
>
>> @@ -724,6 +745,12 @@
>> for (SymbolListT::iterator I = SymbolList.begin(), E = SymbolList.end();
>> I != E; ++I) {
>> uint32_t SymFlags;
>> + std::string Name = I->Name.str();
>> + MachOObjectFile *MachO = dyn_cast<MachOObjectFile>(&Obj);
>> + if (Demangle) {
>> + if (Optional<std::string> Opt = demangle(I->Name, MachO != nullptr))
>
> You can just use isa<MachOObjectFile>(Obj).
MachO isn't the only target with a prefix of '_'. Shouldn't this be
inspecting `DataLayout::getGlobalPrefix()` for that instead?
Jon
>
> LGTM with that.
>
> Cheers,
> Rafael
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
--
Jon Roelofs
jonathan at codesourcery.com
CodeSourcery / Mentor Embedded / Siemens
More information about the llvm-commits
mailing list