Path: blob/main/contrib/llvm-project/llvm/tools/llvm-diff/lib/DiffLog.cpp
35291 views
//===-- DiffLog.h - Difference Log Builder and accessories ------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// This header defines the interface to the LLVM difference log builder.9//10//===----------------------------------------------------------------------===//1112#include "DiffLog.h"13#include "DiffConsumer.h"14#include "llvm/ADT/StringRef.h"1516using namespace llvm;1718LogBuilder::~LogBuilder() {19if (consumer)20consumer->logf(*this);21}2223StringRef LogBuilder::getFormat() const { return Format; }2425unsigned LogBuilder::getNumArguments() const { return Arguments.size(); }26const Value *LogBuilder::getArgument(unsigned I) const { return Arguments[I]; }2728DiffLogBuilder::~DiffLogBuilder() { consumer.logd(*this); }2930void DiffLogBuilder::addMatch(const Instruction *L, const Instruction *R) {31Diff.push_back(DiffRecord(L, R));32}33void DiffLogBuilder::addLeft(const Instruction *L) {34// HACK: VS 2010 has a bug in the stdlib that requires this.35Diff.push_back(DiffRecord(L, DiffRecord::second_type(nullptr)));36}37void DiffLogBuilder::addRight(const Instruction *R) {38// HACK: VS 2010 has a bug in the stdlib that requires this.39Diff.push_back(DiffRecord(DiffRecord::first_type(nullptr), R));40}4142unsigned DiffLogBuilder::getNumLines() const { return Diff.size(); }4344DiffChange DiffLogBuilder::getLineKind(unsigned I) const {45return (Diff[I].first ? (Diff[I].second ? DC_match : DC_left)46: DC_right);47}48const Instruction *DiffLogBuilder::getLeft(unsigned I) const {49return Diff[I].first;50}51const Instruction *DiffLogBuilder::getRight(unsigned I) const {52return Diff[I].second;53}545556