diff options
Diffstat (limited to 'include/clang/Rewrite')
-rw-r--r-- | include/clang/Rewrite/DeltaTree.h | 8 | ||||
-rw-r--r-- | include/clang/Rewrite/HTMLRewrite.h | 20 | ||||
-rw-r--r-- | include/clang/Rewrite/RewriteRope.h | 58 | ||||
-rw-r--r-- | include/clang/Rewrite/Rewriter.h | 50 | ||||
-rw-r--r-- | include/clang/Rewrite/TokenRewriter.h | 24 |
5 files changed, 80 insertions, 80 deletions
diff --git a/include/clang/Rewrite/DeltaTree.h b/include/clang/Rewrite/DeltaTree.h index 7bf9305e28..7e0796524c 100644 --- a/include/clang/Rewrite/DeltaTree.h +++ b/include/clang/Rewrite/DeltaTree.h @@ -15,7 +15,7 @@ #define CLANG_REWRITE_DELTATREE_H namespace clang { - + /// DeltaTree - a multiway search tree (BTree) structure with some fancy /// features. B-Trees are are generally more memory and cache efficient than /// binary trees, because they store multiple keys/values in each node. This @@ -32,16 +32,16 @@ namespace clang { // 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; + 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); + void AddDelta(unsigned FileIndex, int Delta); }; } // end namespace clang diff --git a/include/clang/Rewrite/HTMLRewrite.h b/include/clang/Rewrite/HTMLRewrite.h index f49d49e710..f77e0c61c5 100644 --- a/include/clang/Rewrite/HTMLRewrite.h +++ b/include/clang/Rewrite/HTMLRewrite.h @@ -19,36 +19,36 @@ #include <string> namespace clang { - + class Rewriter; class RewriteBuffer; class Preprocessor; class PreprocessorFactory; - + namespace html { - + /// HighlightRange - Highlight a range in the source code with the specified /// start/end tags. B/E must be in the same file. This ensures that /// start/end tags are placed at the start/end of each line if the range is /// multiline. void HighlightRange(Rewriter &R, SourceLocation B, SourceLocation E, const char *StartTag, const char *EndTag); - + /// HighlightRange - Highlight a range in the source code with the specified - /// start/end tags. The Start/end of the range must be in the same file. + /// start/end tags. The Start/end of the range must be in the same file. /// This ensures that start/end tags are placed at the start/end of each line /// if the range is multiline. inline void HighlightRange(Rewriter &R, SourceRange Range, const char *StartTag, const char *EndTag) { HighlightRange(R, Range.getBegin(), Range.getEnd(), StartTag, EndTag); } - + /// HighlightRange - This is the same as the above method, but takes /// decomposed file locations. void HighlightRange(RewriteBuffer &RB, unsigned B, unsigned E, const char *BufferStart, const char *StartTag, const char *EndTag); - + /// EscapeText - HTMLize a specified file so that special characters are /// are translated so that they are not interpreted as HTML tags. void EscapeText(Rewriter& R, FileID FID, @@ -61,9 +61,9 @@ namespace html { std::string EscapeText(const std::string& s, bool EscapeSpaces = false, bool ReplaceTabs = false); - void AddLineNumbers(Rewriter& R, FileID FID); - - void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID, + void AddLineNumbers(Rewriter& R, FileID FID); + + void AddHeaderFooterInternalBuiltinCSS(Rewriter& R, FileID FID, const char *title = NULL); /// SyntaxHighlight - Relex the specified FileID and annotate the HTML with diff --git a/include/clang/Rewrite/RewriteRope.h b/include/clang/Rewrite/RewriteRope.h index 3b8eeb2b6b..c0bd741d55 100644 --- a/include/clang/Rewrite/RewriteRope.h +++ b/include/clang/Rewrite/RewriteRope.h @@ -22,7 +22,7 @@ namespace clang { //===--------------------------------------------------------------------===// // RopeRefCountString Class //===--------------------------------------------------------------------===// - + /// RopeRefCountString - This struct is allocated with 'new char[]' from the /// heap, and represents a reference counted chunk of string data. When its /// ref count drops to zero, it is delete[]'d. This is primarily managed @@ -30,21 +30,21 @@ namespace clang { struct RopeRefCountString { unsigned RefCount; char Data[1]; // Variable sized. - + void addRef() { if (this) ++RefCount; } - + void dropRef() { if (this && --RefCount == 0) delete [] (char*)this; } }; - + //===--------------------------------------------------------------------===// // RopePiece Class //===--------------------------------------------------------------------===// - + /// RopePiece - This class represents a view into a RopeRefCountString object. /// This allows references to string data to be efficiently chopped up and /// moved around without having to push around the string data itself. @@ -57,9 +57,9 @@ namespace clang { RopeRefCountString *StrData; unsigned StartOffs; unsigned EndOffs; - + RopePiece() : StrData(0), StartOffs(0), EndOffs(0) {} - + RopePiece(RopeRefCountString *Str, unsigned Start, unsigned End) : StrData(Str), StartOffs(Start), EndOffs(End) { StrData->addRef(); @@ -68,11 +68,11 @@ namespace clang { : StrData(RP.StrData), StartOffs(RP.StartOffs), EndOffs(RP.EndOffs) { StrData->addRef(); } - + ~RopePiece() { StrData->dropRef(); } - + void operator=(const RopePiece &RHS) { if (StrData != RHS.StrData) { StrData->dropRef(); @@ -82,21 +82,21 @@ namespace clang { StartOffs = RHS.StartOffs; EndOffs = RHS.EndOffs; } - + const char &operator[](unsigned Offset) const { return StrData->Data[Offset+StartOffs]; } char &operator[](unsigned Offset) { return StrData->Data[Offset+StartOffs]; } - + unsigned size() const { return EndOffs-StartOffs; } }; - + //===--------------------------------------------------------------------===// // RopePieceBTreeIterator Class //===--------------------------------------------------------------------===// - + /// RopePieceBTreeIterator - This class provides read-only forward iteration /// over bytes that are in a RopePieceBTree. This first iterates over bytes /// in a RopePiece, then iterates over RopePiece's in a RopePieceBTreeLeaf, @@ -115,18 +115,18 @@ namespace clang { RopePieceBTreeIterator(const void /*RopePieceBTreeNode*/ *N); // end iterator RopePieceBTreeIterator() : CurNode(0), CurPiece(0), CurChar(0) {} - + char operator*() const { return (*CurPiece)[CurChar]; } - + bool operator==(const RopePieceBTreeIterator &RHS) const { return CurPiece == RHS.CurPiece && CurChar == RHS.CurChar; } bool operator!=(const RopePieceBTreeIterator &RHS) const { return !operator==(RHS); } - + RopePieceBTreeIterator& operator++() { // Preincrement if (CurChar+1 < CurPiece->size()) ++CurChar; @@ -140,11 +140,11 @@ namespace clang { private: void MoveToNextPiece(); }; - + //===--------------------------------------------------------------------===// // RopePieceBTree Class //===--------------------------------------------------------------------===// - + class RopePieceBTree { void /*RopePieceBTreeNode*/ *Root; void operator=(const RopePieceBTree &); // DO NOT IMPLEMENT @@ -152,15 +152,15 @@ namespace clang { RopePieceBTree(); RopePieceBTree(const RopePieceBTree &RHS); ~RopePieceBTree(); - + typedef RopePieceBTreeIterator iterator; iterator begin() const { return iterator(Root); } iterator end() const { return iterator(); } unsigned size() const; unsigned empty() const { return size() == 0; } - + void clear(); - + void insert(unsigned Offset, const RopePiece &R); void erase(unsigned Offset, unsigned NumBytes); @@ -169,13 +169,13 @@ namespace clang { //===--------------------------------------------------------------------===// // RewriteRope Class //===--------------------------------------------------------------------===// - + /// RewriteRope - A powerful string class. This class supports extremely /// efficient insertions and deletions into the middle of it, even for /// ridiculously long strings. class RewriteRope { RopePieceBTree Chunks; - + /// We allocate space for string data out of a buffer of size AllocChunkSize. /// This keeps track of how much space is left. RopeRefCountString *AllocBuffer; @@ -184,7 +184,7 @@ class RewriteRope { public: RewriteRope() : AllocBuffer(0), AllocOffs(AllocChunkSize) {} - RewriteRope(const RewriteRope &RHS) + RewriteRope(const RewriteRope &RHS) : Chunks(RHS.Chunks), AllocBuffer(0), AllocOffs(AllocChunkSize) { } @@ -192,23 +192,23 @@ public: // If we had an allocation buffer, drop our reference to it. AllocBuffer->dropRef(); } - + typedef RopePieceBTree::iterator iterator; typedef RopePieceBTree::iterator const_iterator; iterator begin() const { return Chunks.begin(); } iterator end() const { return Chunks.end(); } unsigned size() const { return Chunks.size(); } - + void clear() { Chunks.clear(); } - + void assign(const char *Start, const char *End) { clear(); if (Start != End) Chunks.insert(0, MakeRopeString(Start, End)); } - + void insert(unsigned Offset, const char *Start, const char *End) { assert(Offset <= size() && "Invalid position to insert!"); if (Start == End) return; @@ -224,7 +224,7 @@ public: private: RopePiece MakeRopeString(const char *Start, const char *End); }; - + } // end namespace clang #endif diff --git a/include/clang/Rewrite/Rewriter.h b/include/clang/Rewrite/Rewriter.h index ea4b08e71b..29e78fa279 100644 --- a/include/clang/Rewrite/Rewriter.h +++ b/include/clang/Rewrite/Rewriter.h @@ -29,7 +29,7 @@ namespace clang { class LangOptions; class Rewriter; class Stmt; - + /// RewriteBuffer - As code is rewritten, SourceBuffer's from the original /// input with modifications get a new RewriteBuffer associated with them. The /// RewriteBuffer captures the modified text itself as well as information used @@ -41,7 +41,7 @@ class RewriteBuffer { /// Deltas - Keep track of all the deltas in the source code due to insertions /// and deletions. DeltaTree Deltas; - + /// Buffer - This is the actual buffer itself. Note that using a vector or /// string is a horribly inefficient way to do this, we should use a rope /// instead. @@ -52,17 +52,17 @@ public: iterator begin() const { return Buffer.begin(); } iterator end() const { return Buffer.end(); } unsigned size() const { return Buffer.size(); } - + /// RemoveText - Remove the specified text. void RemoveText(unsigned OrigOffset, unsigned Size); - + /// InsertText - Insert some text at the specified point, where the offset in /// the buffer is specified relative to the original SourceBuffer. The /// text is inserted after the specified location. /// void InsertText(unsigned OrigOffset, const llvm::StringRef &Str, bool InsertAfter = true); - + /// InsertTextBefore - Insert some text before the specified point, where the /// offset in the buffer is specified relative to the original @@ -71,28 +71,28 @@ public: void InsertTextBefore(unsigned OrigOffset, const llvm::StringRef &Str) { InsertText(OrigOffset, Str, false); } - + /// InsertTextAfter - Insert some text at the specified point, where the /// offset in the buffer is specified relative to the original SourceBuffer. /// The text is inserted after the specified location. void InsertTextAfter(unsigned OrigOffset, const llvm::StringRef &Str) { InsertText(OrigOffset, Str); } - + /// ReplaceText - This method replaces a range of characters in the input /// buffer with a new string. This is effectively a combined "remove/insert" /// operation. void ReplaceText(unsigned OrigOffset, unsigned OrigLength, const llvm::StringRef &NewStr); - + private: // Methods only usable by Rewriter. - + /// Initialize - Start this rewrite buffer out with a copy of the unmodified /// input buffer. void Initialize(const char *BufStart, const char *BufEnd) { Buffer.assign(BufStart, BufEnd); } - + /// getMappedOffset - Given an offset into the original SourceBuffer that this /// RewriteBuffer is based on, map it into the offset space of the /// RewriteBuffer. If AfterInserts is true and if the OrigOffset indicates a @@ -102,7 +102,7 @@ private: // Methods only usable by Rewriter. bool AfterInserts = false) const{ return Deltas.getDeltaAt(2*OrigOffset+AfterInserts)+OrigOffset; } - + /// AddInsertDelta - When an insertion is made at a position, this /// method is used to record that information. void AddInsertDelta(unsigned OrigOffset, int Change) { @@ -115,7 +115,7 @@ private: // Methods only usable by Rewriter. return Deltas.AddDelta(2*OrigOffset+1, Change); } }; - + /// Rewriter - This is the main interface to the rewrite buffers. Its primary /// job is to dispatch high-level requests to the low-level RewriteBuffers that @@ -128,14 +128,14 @@ public: explicit Rewriter(SourceManager &SM, const LangOptions &LO) : SourceMgr(&SM), LangOpts(&LO) {} explicit Rewriter() : SourceMgr(0), LangOpts(0) {} - + void setSourceMgr(SourceManager &SM, const LangOptions &LO) { SourceMgr = &SM; LangOpts = &LO; } SourceManager &getSourceMgr() { return *SourceMgr; } const LangOptions &getLangOpts() { return *LangOpts; } - + /// isRewritable - Return true if this location is a raw file location, which /// is rewritable. Locations from macros, etc are not rewritable. static bool isRewritable(SourceLocation Loc) { @@ -145,7 +145,7 @@ public: /// getRangeSize - Return the size in bytes of the specified range if they /// are in the same file. If not, this returns -1. int getRangeSize(SourceRange Range) const; - + /// getRewritenText - Return the rewritten form of the text in the specified /// range. If the start or end of the range was unrewritable or if they are /// in different buffers, this returns an empty string. @@ -153,22 +153,22 @@ public: /// Note that this method is not particularly efficient. /// std::string getRewritenText(SourceRange Range) const; - + /// InsertText - Insert the specified string at the specified location in the /// original buffer. This method returns true (and does nothing) if the input /// location was not rewritable, false otherwise. bool InsertText(SourceLocation Loc, const llvm::StringRef &Str, bool InsertAfter = true); - + /// InsertTextAfter - Insert the specified string at the specified location in - /// the original buffer. This method returns true (and does nothing) if + /// the original buffer. This method returns true (and does nothing) if /// the input location was not rewritable, false otherwise. Text is /// inserted after any other text that has been previously inserted /// at the some point (the default behavior for InsertText). bool InsertTextAfter(SourceLocation Loc, const llvm::StringRef &Str) { return InsertText(Loc, Str); - } - + } + /// InsertText - Insert the specified string at the specified location in the /// original buffer. This method returns true (and does nothing) if the input /// location was not rewritable, false otherwise. Text is @@ -177,21 +177,21 @@ public: bool InsertTextBefore(SourceLocation Loc, const llvm::StringRef &Str) { return InsertText(Loc, Str, false); } - + /// RemoveText - Remove the specified text region. bool RemoveText(SourceLocation Start, unsigned Length); - + /// ReplaceText - This method replaces a range of characters in the input /// buffer with a new string. This is effectively a combined "remove/insert" /// operation. bool ReplaceText(SourceLocation Start, unsigned OrigLength, const llvm::StringRef &NewStr); - + /// ReplaceStmt - This replaces a Stmt/Expr with another, using the pretty /// printer to generate the replacement code. This returns true if the input /// could not be rewritten, or false if successful. bool ReplaceStmt(Stmt *From, Stmt *To); - + /// getRewriteBufferFor - Return the rewrite buffer for the specified FileID. /// If no modification has been made to it, return null. const RewriteBuffer *getRewriteBufferFor(FileID FID) const { @@ -209,7 +209,7 @@ public: private: unsigned getLocationOffsetAndFileID(SourceLocation Loc, FileID &FID) const; }; - + } // end namespace clang #endif diff --git a/include/clang/Rewrite/TokenRewriter.h b/include/clang/Rewrite/TokenRewriter.h index c8fd0f532c..62ea12af1f 100644 --- a/include/clang/Rewrite/TokenRewriter.h +++ b/include/clang/Rewrite/TokenRewriter.h @@ -24,7 +24,7 @@ namespace clang { class Token; class LangOptions; class ScratchBuffer; - + class TokenRewriter { /// TokenList - This is the list of raw tokens that make up this file. Each /// of these tokens has a unique SourceLocation, which is a FileID. @@ -32,17 +32,17 @@ namespace clang { /// TokenRefTy - This is the type used to refer to a token in the TokenList. typedef std::list<Token>::iterator TokenRefTy; - + /// TokenAtLoc - This map indicates which token exists at a specific /// SourceLocation. Since each token has a unique SourceLocation, this is a /// one to one map. The token can return its own location directly, to map /// backwards. std::map<SourceLocation, TokenRefTy> TokenAtLoc; - + /// ScratchBuf - This is the buffer that we create scratch tokens from. /// llvm::OwningPtr<ScratchBuffer> ScratchBuf; - + TokenRewriter(const TokenRewriter&); // DO NOT IMPLEMENT void operator=(const TokenRewriter&); // DO NOT IMPLEMENT. public: @@ -50,30 +50,30 @@ namespace clang { /// specified FileID. TokenRewriter(FileID FID, SourceManager &SM, const LangOptions &LO); ~TokenRewriter(); - + typedef std::list<Token>::const_iterator token_iterator; token_iterator token_begin() const { return TokenList.begin(); } token_iterator token_end() const { return TokenList.end(); } - - + + token_iterator AddTokenBefore(token_iterator I, const char *Val); token_iterator AddTokenAfter(token_iterator I, const char *Val) { assert(I != token_end() && "Cannot insert after token_end()!"); return AddTokenBefore(++I, Val); } - + private: /// RemapIterator - Convert from token_iterator (a const iterator) to /// TokenRefTy (a non-const iterator). TokenRefTy RemapIterator(token_iterator I); - + /// AddToken - Add the specified token into the Rewriter before the other /// position. TokenRefTy AddToken(const Token &T, TokenRefTy Where); }; - - - + + + } // end namespace clang #endif |