<commit_before>//===-- BasicCalleePrinter.cpp - Callee cache printing pass ---*- C++ -*---===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This pass prints the callees of functions as determined by the
// BasicCalleeAnalysis. The pass is strictly for testing that
// analysis.
//
//===----------------------------------------------------------------------===//

#include "swift/SILAnalysis/BasicCalleeAnalysis.h"
#include "swift/SIL/SILFunction.h"
#include "swift/SIL/SILInstruction.h"
#include "swift/SIL/SILModule.h"
#include "swift/SILPasses/Transforms.h"
#include "llvm/ADT/StringRef.h"

using namespace swift;

#define DEBUG_TYPE "basic-callee-printer"

namespace {

class BasicCalleePrinterPass : public SILFunctionTransform {
  BasicCalleeAnalysis *BCA;

  void printCallees(FullApplySite FAS) {
    llvm::outs() << "Function call site:\n";
    if (auto *Callee = dyn_cast<SILInstruction>(FAS.getCallee()))
      llvm::outs() << *Callee;
    llvm::outs() << *FAS.getInstruction();

    auto Callees = BCA->getCalleeList(FAS);
    llvm::outs() << "Incomplete callee list? : "
                 << (Callees.isIncomplete() ? "Yes" : "No") << "\n";
    llvm::outs() << "Known callees:\n";
    for (auto *CalleeFn : Callees)
      llvm::outs() << CalleeFn->getName() << "\n";
    llvm::outs() << "\n";
  }

  /// The entry point to the transformation.
  void run() override {
    BCA = getAnalysis<BasicCalleeAnalysis>();
    auto &F = *getFunction();

    for (auto &B : F)
      for (auto &I : B)
        if (auto FAS = FullApplySite::isa(&I))
          printCallees(FAS);
  }

  StringRef getName() override { return "Basic Callee Printer"; }
};

} // end anonymous namespace

SILTransform *swift::createBasicCalleePrinter() {
  return new BasicCalleePrinterPass();
}
<commit_msg>Add missing include to BasicCalleePrinter.cpp.<commit_after>//===-- BasicCalleePrinter.cpp - Callee cache printing pass ---*- C++ -*---===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This pass prints the callees of functions as determined by the
// BasicCalleeAnalysis. The pass is strictly for testing that
// analysis.
//
//===----------------------------------------------------------------------===//

#include "swift/SILAnalysis/BasicCalleeAnalysis.h"
#include "swift/SIL/SILFunction.h"
#include "swift/SIL/SILInstruction.h"
#include "swift/SIL/SILModule.h"
#include "swift/SILPasses/Transforms.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/raw_ostream.h"

using namespace swift;

#define DEBUG_TYPE "basic-callee-printer"

namespace {

class BasicCalleePrinterPass : public SILFunctionTransform {
  BasicCalleeAnalysis *BCA;

  void printCallees(FullApplySite FAS) {
    llvm::outs() << "Function call site:\n";
    if (auto *Callee = dyn_cast<SILInstruction>(FAS.getCallee()))
      llvm::outs() << *Callee;
    llvm::outs() << *FAS.getInstruction();

    auto Callees = BCA->getCalleeList(FAS);
    llvm::outs() << "Incomplete callee list? : "
                 << (Callees.isIncomplete() ? "Yes" : "No") << "\n";
    llvm::outs() << "Known callees:\n";
    for (auto *CalleeFn : Callees)
      llvm::outs() << CalleeFn->getName() << "\n";
    llvm::outs() << "\n";
  }

  /// The entry point to the transformation.
  void run() override {
    BCA = getAnalysis<BasicCalleeAnalysis>();
    auto &F = *getFunction();

    for (auto &B : F)
      for (auto &I : B)
        if (auto FAS = FullApplySite::isa(&I))
          printCallees(FAS);
  }

  StringRef getName() override { return "Basic Callee Printer"; }
};

} // end anonymous namespace

SILTransform *swift::createBasicCalleePrinter() {
  return new BasicCalleePrinterPass();
}

{'fraction_non_alphanumeric': 0.21185485688528286, 'fraction_numerical': 0.00450755014649538, 'mean_word_length': 2.6436781609195403, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '248858', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1346, 'n_words': 360}