[llvm] r260166 - [llvm-nm] Yet another attempt of simplifying code.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 8 15:51:56 PST 2016


On Mon, Feb 8, 2016 at 3:04 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>
> On Mon, Feb 8, 2016 at 2:58 PM, Davide Italiano via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: davide
>> Date: Mon Feb  8 16:58:26 2016
>> New Revision: 260166
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=260166&view=rev
>> Log:
>> [llvm-nm] Yet another attempt of simplifying code.
>>
>> Modified:
>>     llvm/trunk/tools/llvm-nm/llvm-nm.cpp
>>
>> Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=260166&r1=260165&r2=260166&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
>> +++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Mon Feb  8 16:58:26 2016
>> @@ -791,26 +791,20 @@ static char getSymbolNMTypeChar(MachOObj
>>  }
>>
>>  static char getSymbolNMTypeChar(const GlobalValue &GV) {
>> -  if (GV.getValueType()->isFunctionTy())
>> -    return 't';
>>    // FIXME: should we print 'b'? At the IR level we cannot be sure if
>> this
>>    // will be in bss or not, but we could approximate.
>> -  return 'd';
>> +  return (GV.getValueType()->isFunctionTy()) ? 't' : 'd';
>
>
> Drop the excess parens around the condition expression ^
>
>>
>>  }
>>
>>  static char getSymbolNMTypeChar(IRObjectFile &Obj, basic_symbol_iterator
>> I) {
>>    const GlobalValue *GV = Obj.getSymbolGV(I->getRawDataRefImpl());
>> -  if (!GV)
>> -    return 't';
>> -  return getSymbolNMTypeChar(*GV);
>> +  return (!GV) ? 't' : getSymbolNMTypeChar(*GV);
>
>
> Same here (though I admit this one's a bit more interesting/might be helpful
> for precedence comfort) and below.
>
>>
>>  }
>>
>>  static bool isObject(SymbolicFile &Obj, basic_symbol_iterator I) {
>> -  auto *ELF = dyn_cast<ELFObjectFileBase>(&Obj);
>> -  if (!ELF)
>> -    return false;
>> -
>> -  return elf_symbol_iterator(I)->getELFType() == ELF::STT_OBJECT;
>> +  return (!dyn_cast<ELFObjectFileBase>(&Obj))
>> +             ? false
>> +             : elf_symbol_iterator(I)->getELFType() == ELF::STT_OBJECT;
>>  }
>>
>>  static char getNMTypeChar(SymbolicFile &Obj, basic_symbol_iterator I) {
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>

Uh, sure. The second one makes me a little bit uncomfortable, but, if
it's the preferred style, I won't argue further.

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list