1 //===-- DiffLog.h - Difference Log Builder and accessories ------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This header defines the interface to the LLVM difference log builder.
11 //===----------------------------------------------------------------------===//
14 #include "DiffConsumer.h"
15 #include "llvm/ADT/StringRef.h"
19 LogBuilder::~LogBuilder() {
21 consumer
->logf(*this);
24 StringRef
LogBuilder::getFormat() const { return Format
; }
26 unsigned LogBuilder::getNumArguments() const { return Arguments
.size(); }
27 const Value
*LogBuilder::getArgument(unsigned I
) const { return Arguments
[I
]; }
29 DiffLogBuilder::~DiffLogBuilder() { consumer
.logd(*this); }
31 void DiffLogBuilder::addMatch(const Instruction
*L
, const Instruction
*R
) {
32 Diff
.push_back(DiffRecord(L
, R
));
34 void DiffLogBuilder::addLeft(const Instruction
*L
) {
35 // HACK: VS 2010 has a bug in the stdlib that requires this.
36 Diff
.push_back(DiffRecord(L
, DiffRecord::second_type(nullptr)));
38 void DiffLogBuilder::addRight(const Instruction
*R
) {
39 // HACK: VS 2010 has a bug in the stdlib that requires this.
40 Diff
.push_back(DiffRecord(DiffRecord::first_type(nullptr), R
));
43 unsigned DiffLogBuilder::getNumLines() const { return Diff
.size(); }
45 DiffChange
DiffLogBuilder::getLineKind(unsigned I
) const {
46 return (Diff
[I
].first
? (Diff
[I
].second
? DC_match
: DC_left
)
49 const Instruction
*DiffLogBuilder::getLeft(unsigned I
) const {
52 const Instruction
*DiffLogBuilder::getRight(unsigned I
) const {
53 return Diff
[I
].second
;