llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.52k stars 11.79k forks source link

llvm/lib/Object/ELF.cpp:415: Poor style ? #97623

Open dcb314 opened 3 months ago

dcb314 commented 3 months ago

Static analyser cppcheck says:

llvm/lib/Object/ELF.cpp:415:54: style: Clarify calculation precedence for '&' and '?'. [clarifyCalculation]

Source code is

const size_t FlagBits = Hdr & ELF::CREL_HDR_ADDEND ? 3 : 2;

I think

const size_t FlagBits = (Hdr & ELF::CREL_HDR_ADDEND) ? 3 : 2;

was probably intended but the code isn't clear.

MaskRay commented 3 months ago

I think this is low-value report. \w+ \& \w+ \? is very common and we don't want to change them.

Some people are more fond of appeasing such linter reports but some some disagree.