diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-09-01 05:09:24 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-09-01 05:09:24 +0000 |
commit | 305c613af6cfc40e519c75d9d2c84c6fa9a841c0 (patch) | |
tree | 4f7b6849cefc8dce39b4eb5056330fbb7112deb1 /include/clang/Rewrite/Core/DeltaTree.h | |
parent | f143ae9b68cdd40dfb120094baaa702b810eb52c (diff) |
Split library clangRewrite into clangRewriteCore and clangRewriteFrontend.
This is similar to how we divide up the StaticAnalyzer libraries to separate
core functionality to what is clearly associated with Frontend actions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163050 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Rewrite/Core/DeltaTree.h')
-rw-r--r-- | include/clang/Rewrite/Core/DeltaTree.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/clang/Rewrite/Core/DeltaTree.h b/include/clang/Rewrite/Core/DeltaTree.h new file mode 100644 index 0000000000..f32906a323 --- /dev/null +++ b/include/clang/Rewrite/Core/DeltaTree.h @@ -0,0 +1,48 @@ +//===--- DeltaTree.h - B-Tree for Rewrite Delta tracking --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines the DeltaTree class. +// +//===----------------------------------------------------------------------===// + +#ifndef CLANG_REWRITE_DELTATREE_H +#define CLANG_REWRITE_DELTATREE_H + +namespace clang { + + /// DeltaTree - a multiway search tree (BTree) structure with some fancy + /// features. B-Trees are generally more memory and cache efficient than + /// binary trees, because they store multiple keys/values in each node. This + /// implements a key/value mapping from index to delta, and allows fast lookup + /// on index. However, an added (important) bonus is that it can also + /// efficiently tell us the full accumulated delta for a specific file offset + /// as well, without traversing the whole tree. + class DeltaTree { + void *Root; // "DeltaTreeNode *" + void operator=(const DeltaTree&); // DO NOT IMPLEMENT + public: + DeltaTree(); + + // Note: Currently we only support copying when the RHS is empty. + DeltaTree(const DeltaTree &RHS); + ~DeltaTree(); + + /// getDeltaAt - Return the accumulated delta at the specified file offset. + /// This includes all insertions or delections that occurred *before* the + /// specified file index. + int getDeltaAt(unsigned FileIndex) const; + + /// AddDelta - When a change is made that shifts around the text buffer, + /// this method is used to record that info. It inserts a delta of 'Delta' + /// into the current DeltaTree at offset FileIndex. + void AddDelta(unsigned FileIndex, int Delta); + }; +} // end namespace clang + +#endif |