<commit_before>//===-- Core/ReplacementHandling.cpp --------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief This file provides implementations for the ReplacementHandling class.
///
//===----------------------------------------------------------------------===//

#include "Core/ReplacementHandling.h"
#include "clang/Tooling/ReplacementsYaml.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/system_error.h"

using namespace llvm;
using namespace llvm::sys;
using namespace clang::tooling;

bool ReplacementHandling::findClangApplyReplacements(const char *Argv0) {
  CARPath = FindProgramByName("clang-apply-replacements");

  if (!CARPath.empty())
    return true;

  static int StaticSymbol;
  CARPath = fs::getMainExecutable(Argv0, &StaticSymbol);
  SmallString<128> TestPath = path::parent_path(CARPath);
  path::append(TestPath, "clang-apply-replacements");
  if (fs::can_execute(Twine(TestPath)))
    CARPath = TestPath.str();

  return !CARPath.empty();
}

StringRef ReplacementHandling::useTempDestinationDir() {
  DestinationDir = generateTempDir();
  return DestinationDir;
}

void ReplacementHandling::enableFormatting(StringRef Style,
                                           StringRef StyleConfigDir) {
  DoFormat = true;
  FormatStyle = Style;
  this->StyleConfigDir = StyleConfigDir;
}

bool ReplacementHandling::serializeReplacements(
    const TUReplacementsMap &Replacements) {
  assert(!DestinationDir.empty() && "Destination directory not set");
<commit_msg>clang-modernize: fix invalid assignment in findClangApplyReplacements()<commit_after>//===-- Core/ReplacementHandling.cpp --------------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
///
/// \file
/// \brief This file provides implementations for the ReplacementHandling class.
///
//===----------------------------------------------------------------------===//

#include "Core/ReplacementHandling.h"
#include "clang/Tooling/ReplacementsYaml.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/system_error.h"

using namespace llvm;
using namespace llvm::sys;
using namespace clang::tooling;

bool ReplacementHandling::findClangApplyReplacements(const char *Argv0) {
  CARPath = FindProgramByName("clang-apply-replacements");

  if (!CARPath.empty())
    return true;

  static int StaticSymbol;
  std::string ClangModernizePath = fs::getMainExecutable(Argv0, &StaticSymbol);
  SmallString<128> TestPath = path::parent_path(ClangModernizePath);
  path::append(TestPath, "clang-apply-replacements");
  if (fs::can_execute(Twine(TestPath)))
    CARPath = TestPath.str();

  return !CARPath.empty();
}

StringRef ReplacementHandling::useTempDestinationDir() {
  DestinationDir = generateTempDir();
  return DestinationDir;
}

void ReplacementHandling::enableFormatting(StringRef Style,
                                           StringRef StyleConfigDir) {
  DoFormat = true;
  FormatStyle = Style;
  this->StyleConfigDir = StyleConfigDir;
}

bool ReplacementHandling::serializeReplacements(
    const TUReplacementsMap &Replacements) {
  assert(!DestinationDir.empty() && "Destination directory not set");

{'fraction_non_alphanumeric': 0.21234309623430964, 'fraction_numerical': 0.002615062761506276, 'mean_word_length': 2.772189349112426, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2548502', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1050, 'n_words': 224}