LLVM 22.0.0git
DeltaTree.h
Go to the documentation of this file.
1//===- DeltaTree.h - B-Tree for Rewrite Delta tracking ----------*- C++ -*-===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the DeltaTree class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_ADT_DELTATREE_H
14#define LLVM_ADT_DELTATREE_H
15
17
18namespace llvm {
19
20/// DeltaTree - a multiway search tree (BTree) structure with some fancy
21/// features. B-Trees are generally more memory and cache efficient than
22/// binary trees, because they store multiple keys/values in each node. This
23/// implements a key/value mapping from index to delta, and allows fast lookup
24/// on index. However, an added (important) bonus is that it can also
25/// efficiently tell us the full accumulated delta for a specific file offset
26/// as well, without traversing the whole tree.
27class DeltaTree {
28 void *Root; // "DeltaTreeNode *"
29
30public:
32
33 // Note: Currently we only support copying when the RHS is empty.
35
36 DeltaTree &operator=(const DeltaTree &) = delete;
38
39 /// getDeltaAt - Return the accumulated delta at the specified file offset.
40 /// This includes all insertions or delections that occurred *before* the
41 /// specified file index.
42 LLVM_ABI int getDeltaAt(unsigned FileIndex) const;
43
44 /// AddDelta - When a change is made that shifts around the text buffer,
45 /// this method is used to record that info. It inserts a delta of 'Delta'
46 /// into the current DeltaTree at offset FileIndex.
47 LLVM_ABI void AddDelta(unsigned FileIndex, int Delta);
48};
49
50} // namespace llvm
51
52#endif // LLVM_ADT_DELTATREE_H
#define LLVM_ABI
Definition Compiler.h:213
Value * RHS
DeltaTree & operator=(const DeltaTree &)=delete
LLVM_ABI void AddDelta(unsigned FileIndex, int Delta)
AddDelta - When a change is made that shifts around the text buffer, this method is used to record th...
LLVM_ABI DeltaTree()
LLVM_ABI int getDeltaAt(unsigned FileIndex) const
getDeltaAt - Return the accumulated delta at the specified file offset.
LLVM_ABI ~DeltaTree()
This is an optimization pass for GlobalISel generic memory operations.