Bug ID: 41775
           Summary: SymbolTableSection::addSymbol - shadow variable names
           Product: tools
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: llvm-objcopy/strip
            Blocks: 41655

void SymbolTableSection::addSymbol(Twine Name, uint8_t Bind, uint8_t Type,
                                   SectionBase *DefinedIn, uint64_t Value,
                                   uint8_t Visibility, uint16_t Shndx,
                                   uint64_t Size) {
  Symbol Sym;
  Sym.Name = Name.str();
  Sym.Binding = Bind;
  Sym.Type = Type;
  Sym.DefinedIn = DefinedIn;
  if (DefinedIn != nullptr)
    DefinedIn->HasSymbol = true;
  if (DefinedIn == nullptr) {
    if (Shndx >= SHN_LORESERVE)
      Sym.ShndxType = static_cast<SymbolShndxType>(Shndx);
      Sym.ShndxType = SYMBOL_SIMPLE_INDEX;
  Sym.Value = Value;
  Sym.Visibility = Visibility;
  Sym.Size = Size;
  Sym.Index = Symbols.size();
  Size += this->EntrySize;

The final line "Size += this->EntrySize" is updating the passed in function
argument (which is then thrown away).

Should this have been "this->Size += this->EntrySize" instead? If not the line
it superfluous and should be deleted.

Reported in (Snippet No. 37).

Referenced Bugs:
[Bug 41655] Finding Bugs in LLVM 8 with PVS-Studio
You are receiving this mail because:
You are on the CC list for the bug.
llvm-bugs mailing list

Reply via email to