<commit_before>//===- ModuleDebugLineFragment.cpp -------------------------------*- C++-*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"

#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"
#include "llvm/DebugInfo/CodeView/StringTable.h"

using namespace llvm;
using namespace llvm::codeview;

Error LineColumnExtractor::extract(BinaryStreamRef Stream, uint32_t &Len,
                                   LineColumnEntry &Item,
                                   const LineFragmentHeader *Header) {
  using namespace codeview;
  const LineBlockFragmentHeader *BlockHeader;
  BinaryStreamReader Reader(Stream);
  if (auto EC = Reader.readObject(BlockHeader))
    return EC;
  bool HasColumn = Header->Flags & uint16_t(LF_HaveColumns);
  uint32_t LineInfoSize =
      BlockHeader->NumLines *
      (sizeof(LineNumberEntry) + (HasColumn ? sizeof(ColumnNumberEntry) : 0));
  if (BlockHeader->BlockSize < sizeof(LineBlockFragmentHeader))
    return make_error<CodeViewError>(cv_error_code::corrupt_record,
                                     "Invalid line block record size");
  uint32_t Size = BlockHeader->BlockSize - sizeof(LineBlockFragmentHeader);
  if (LineInfoSize > Size)
    return make_error<CodeViewError>(cv_error_code::corrupt_record,
                                     "Invalid line block record size");
  // The value recorded in BlockHeader->BlockSize includes the size of
  // LineBlockFragmentHeader.
  Len = BlockHeader->BlockSize;
  Item.NameIndex = BlockHeader->NameIndex;
  if (auto EC = Reader.readArray(Item.LineNumbers, BlockHeader->NumLines))
    return EC;
  if (HasColumn) {
    if (auto EC = Reader.readArray(Item.Columns, BlockHeader->NumLines))
      return EC;
  }
  return Error::success();
}

ModuleDebugLineFragmentRef::ModuleDebugLineFragmentRef()
    : ModuleDebugFragmentRef(ModuleDebugFragmentKind::Lines) {}

Error ModuleDebugLineFragmentRef::initialize(BinaryStreamReader Reader) {
  if (auto EC = Reader.readObject(Header))
    return EC;

  if (auto EC =
          Reader.readArray(LinesAndColumns, Reader.bytesRemaining(), Header))
    return EC;

  return Error::success();
}

bool ModuleDebugLineFragmentRef::hasColumnInfo() const {
  return !!(Header->Flags & LF_HaveColumns);
}

ModuleDebugLineFragment::ModuleDebugLineFragment(
    ModuleDebugFileChecksumFragment &Checksums, StringTable &Strings)
    : ModuleDebugFragment(ModuleDebugFragmentKind::Lines), Checksums(Checksums),
      Strings(Strings) {}<commit_msg>[CodeView] Remove constructor initialization of a removed field.<commit_after>//===- ModuleDebugLineFragment.cpp -------------------------------*- C++-*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "llvm/DebugInfo/CodeView/ModuleDebugLineFragment.h"

#include "llvm/DebugInfo/CodeView/CodeViewError.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFileChecksumFragment.h"
#include "llvm/DebugInfo/CodeView/ModuleDebugFragmentRecord.h"
#include "llvm/DebugInfo/CodeView/StringTable.h"

using namespace llvm;
using namespace llvm::codeview;

Error LineColumnExtractor::extract(BinaryStreamRef Stream, uint32_t &Len,
                                   LineColumnEntry &Item,
                                   const LineFragmentHeader *Header) {
  using namespace codeview;
  const LineBlockFragmentHeader *BlockHeader;
  BinaryStreamReader Reader(Stream);
  if (auto EC = Reader.readObject(BlockHeader))
    return EC;
  bool HasColumn = Header->Flags & uint16_t(LF_HaveColumns);
  uint32_t LineInfoSize =
      BlockHeader->NumLines *
      (sizeof(LineNumberEntry) + (HasColumn ? sizeof(ColumnNumberEntry) : 0));
  if (BlockHeader->BlockSize < sizeof(LineBlockFragmentHeader))
    return make_error<CodeViewError>(cv_error_code::corrupt_record,
                                     "Invalid line block record size");
  uint32_t Size = BlockHeader->BlockSize - sizeof(LineBlockFragmentHeader);
  if (LineInfoSize > Size)
    return make_error<CodeViewError>(cv_error_code::corrupt_record,
                                     "Invalid line block record size");
  // The value recorded in BlockHeader->BlockSize includes the size of
  // LineBlockFragmentHeader.
  Len = BlockHeader->BlockSize;
  Item.NameIndex = BlockHeader->NameIndex;
  if (auto EC = Reader.readArray(Item.LineNumbers, BlockHeader->NumLines))
    return EC;
  if (HasColumn) {
    if (auto EC = Reader.readArray(Item.Columns, BlockHeader->NumLines))
      return EC;
  }
  return Error::success();
}

ModuleDebugLineFragmentRef::ModuleDebugLineFragmentRef()
    : ModuleDebugFragmentRef(ModuleDebugFragmentKind::Lines) {}

Error ModuleDebugLineFragmentRef::initialize(BinaryStreamReader Reader) {
  if (auto EC = Reader.readObject(Header))
    return EC;

  if (auto EC =
          Reader.readArray(LinesAndColumns, Reader.bytesRemaining(), Header))
    return EC;

  return Error::success();
}

bool ModuleDebugLineFragmentRef::hasColumnInfo() const {
  return !!(Header->Flags & LF_HaveColumns);
}

ModuleDebugLineFragment::ModuleDebugLineFragment(
    ModuleDebugFileChecksumFragment &Checksums, StringTable &Strings)
    : ModuleDebugFragment(ModuleDebugFragmentKind::Lines),
      Checksums(Checksums) {}
{'fraction_non_alphanumeric': 0.13630859712852447, 'fraction_numerical': 0.0031136481577581734, 'mean_word_length': 3.2956909361069835, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2268551', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1533, 'n_words': 336}