Path: blob/main/contrib/llvm-project/llvm/tools/llvm-diff/lib/DiffLog.h
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#ifndef LLVM_TOOLS_LLVM_DIFF_DIFFLOG_H13#define LLVM_TOOLS_LLVM_DIFF_DIFFLOG_H1415#include "llvm/ADT/SmallVector.h"16#include "llvm/ADT/StringRef.h"1718namespace llvm {19class Instruction;20class Value;21class Consumer;2223/// Trichotomy assumption24enum DiffChange { DC_match, DC_left, DC_right };2526/// A temporary-object class for building up log messages.27class LogBuilder {28Consumer *consumer;2930/// The use of a stored StringRef here is okay because31/// LogBuilder should be used only as a temporary, and as a32/// temporary it will be destructed before whatever temporary33/// might be initializing this format.34StringRef Format;3536SmallVector<const Value *, 4> Arguments;3738public:39LogBuilder(Consumer &c, StringRef Format) : consumer(&c), Format(Format) {}40LogBuilder(LogBuilder &&L)41: consumer(L.consumer), Format(L.Format),42Arguments(std::move(L.Arguments)) {43L.consumer = nullptr;44}4546LogBuilder &operator<<(const Value *V) {47Arguments.push_back(V);48return *this;49}5051~LogBuilder();5253StringRef getFormat() const;54unsigned getNumArguments() const;55const Value *getArgument(unsigned I) const;56};5758/// A temporary-object class for building up diff messages.59class DiffLogBuilder {60typedef std::pair<const Instruction *, const Instruction *> DiffRecord;61SmallVector<DiffRecord, 20> Diff;6263Consumer &consumer;6465public:66DiffLogBuilder(Consumer &c) : consumer(c) {}67~DiffLogBuilder();6869void addMatch(const Instruction *L, const Instruction *R);70// HACK: VS 2010 has a bug in the stdlib that requires this.71void addLeft(const Instruction *L);72void addRight(const Instruction *R);7374unsigned getNumLines() const;75DiffChange getLineKind(unsigned I) const;76const Instruction *getLeft(unsigned I) const;77const Instruction *getRight(unsigned I) const;78};7980}8182#endif838485