summaryrefslogtreecommitdiffstats
path: root/include/clang/Edit
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/Edit')
-rw-r--r--include/clang/Edit/Commit.h143
-rw-r--r--include/clang/Edit/EditedSource.h97
-rw-r--r--include/clang/Edit/EditsReceiver.h35
-rw-r--r--include/clang/Edit/FileOffset.h61
-rw-r--r--include/clang/Edit/Rewriters.h41
5 files changed, 0 insertions, 377 deletions
diff --git a/include/clang/Edit/Commit.h b/include/clang/Edit/Commit.h
deleted file mode 100644
index ac4bb47..0000000
--- a/include/clang/Edit/Commit.h
+++ /dev/null
@@ -1,143 +0,0 @@
-//===----- Commit.h - A unit of edits ---------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_EDIT_COMMIT_H
-#define LLVM_CLANG_EDIT_COMMIT_H
-
-#include "clang/Edit/FileOffset.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Allocator.h"
-
-namespace clang {
- class LangOptions;
- class PPConditionalDirectiveRecord;
-
-namespace edit {
- class EditedSource;
-
-class Commit {
-public:
- enum EditKind {
- Act_Insert,
- Act_InsertFromRange,
- Act_Remove
- };
-
- struct Edit {
- EditKind Kind;
- StringRef Text;
- SourceLocation OrigLoc;
- FileOffset Offset;
- FileOffset InsertFromRangeOffs;
- unsigned Length;
- bool BeforePrev;
-
- SourceLocation getFileLocation(SourceManager &SM) const;
- CharSourceRange getFileRange(SourceManager &SM) const;
- CharSourceRange getInsertFromRange(SourceManager &SM) const;
- };
-
-private:
- const SourceManager &SourceMgr;
- const LangOptions &LangOpts;
- const PPConditionalDirectiveRecord *PPRec;
- EditedSource *Editor;
-
- bool IsCommitable;
- SmallVector<Edit, 8> CachedEdits;
-
- llvm::BumpPtrAllocator StrAlloc;
-
-public:
- explicit Commit(EditedSource &Editor);
- Commit(const SourceManager &SM, const LangOptions &LangOpts,
- const PPConditionalDirectiveRecord *PPRec = nullptr)
- : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec), Editor(nullptr),
- IsCommitable(true) { }
-
- bool isCommitable() const { return IsCommitable; }
-
- bool insert(SourceLocation loc, StringRef text, bool afterToken = false,
- bool beforePreviousInsertions = false);
- bool insertAfterToken(SourceLocation loc, StringRef text,
- bool beforePreviousInsertions = false) {
- return insert(loc, text, /*afterToken=*/true, beforePreviousInsertions);
- }
- bool insertBefore(SourceLocation loc, StringRef text) {
- return insert(loc, text, /*afterToken=*/false,
- /*beforePreviousInsertions=*/true);
- }
- bool insertFromRange(SourceLocation loc, CharSourceRange range,
- bool afterToken = false,
- bool beforePreviousInsertions = false);
- bool insertWrap(StringRef before, CharSourceRange range, StringRef after);
-
- bool remove(CharSourceRange range);
-
- bool replace(CharSourceRange range, StringRef text);
- bool replaceWithInner(CharSourceRange range, CharSourceRange innerRange);
- bool replaceText(SourceLocation loc, StringRef text,
- StringRef replacementText);
-
- bool insertFromRange(SourceLocation loc, SourceRange TokenRange,
- bool afterToken = false,
- bool beforePreviousInsertions = false) {
- return insertFromRange(loc, CharSourceRange::getTokenRange(TokenRange),
- afterToken, beforePreviousInsertions);
- }
- bool insertWrap(StringRef before, SourceRange TokenRange, StringRef after) {
- return insertWrap(before, CharSourceRange::getTokenRange(TokenRange), after);
- }
- bool remove(SourceRange TokenRange) {
- return remove(CharSourceRange::getTokenRange(TokenRange));
- }
- bool replace(SourceRange TokenRange, StringRef text) {
- return replace(CharSourceRange::getTokenRange(TokenRange), text);
- }
- bool replaceWithInner(SourceRange TokenRange, SourceRange TokenInnerRange) {
- return replaceWithInner(CharSourceRange::getTokenRange(TokenRange),
- CharSourceRange::getTokenRange(TokenInnerRange));
- }
-
- typedef SmallVectorImpl<Edit>::const_iterator edit_iterator;
- edit_iterator edit_begin() const { return CachedEdits.begin(); }
- edit_iterator edit_end() const { return CachedEdits.end(); }
-
-private:
- void addInsert(SourceLocation OrigLoc,
- FileOffset Offs, StringRef text, bool beforePreviousInsertions);
- void addInsertFromRange(SourceLocation OrigLoc, FileOffset Offs,
- FileOffset RangeOffs, unsigned RangeLen,
- bool beforePreviousInsertions);
- void addRemove(SourceLocation OrigLoc, FileOffset Offs, unsigned Len);
-
- bool canInsert(SourceLocation loc, FileOffset &Offset);
- bool canInsertAfterToken(SourceLocation loc, FileOffset &Offset,
- SourceLocation &AfterLoc);
- bool canInsertInOffset(SourceLocation OrigLoc, FileOffset Offs);
- bool canRemoveRange(CharSourceRange range, FileOffset &Offs, unsigned &Len);
- bool canReplaceText(SourceLocation loc, StringRef text,
- FileOffset &Offs, unsigned &Len);
-
- void commitInsert(FileOffset offset, StringRef text,
- bool beforePreviousInsertions);
- void commitRemove(FileOffset offset, unsigned length);
-
- bool isAtStartOfMacroExpansion(SourceLocation loc,
- SourceLocation *MacroBegin = nullptr) const;
- bool isAtEndOfMacroExpansion(SourceLocation loc,
- SourceLocation *MacroEnd = nullptr) const;
-};
-
-}
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Edit/EditedSource.h b/include/clang/Edit/EditedSource.h
deleted file mode 100644
index b6ec8b8..0000000
--- a/include/clang/Edit/EditedSource.h
+++ /dev/null
@@ -1,97 +0,0 @@
-//===----- EditedSource.h - Collection of source edits ----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_EDIT_EDITEDSOURCE_H
-#define LLVM_CLANG_EDIT_EDITEDSOURCE_H
-
-#include "clang/Basic/IdentifierTable.h"
-#include "clang/Edit/FileOffset.h"
-#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/TinyPtrVector.h"
-#include "llvm/Support/Allocator.h"
-#include <map>
-
-namespace clang {
- class LangOptions;
- class PPConditionalDirectiveRecord;
-
-namespace edit {
- class Commit;
- class EditsReceiver;
-
-class EditedSource {
- const SourceManager &SourceMgr;
- const LangOptions &LangOpts;
- const PPConditionalDirectiveRecord *PPRec;
-
- struct FileEdit {
- StringRef Text;
- unsigned RemoveLen;
-
- FileEdit() : RemoveLen(0) {}
- };
-
- typedef std::map<FileOffset, FileEdit> FileEditsTy;
- FileEditsTy FileEdits;
-
- llvm::DenseMap<unsigned, llvm::TinyPtrVector<IdentifierInfo*>>
- ExpansionToArgMap;
- SmallVector<std::pair<SourceLocation, IdentifierInfo*>, 2>
- CurrCommitMacroArgExps;
-
- IdentifierTable IdentTable;
- llvm::BumpPtrAllocator StrAlloc;
-
-public:
- EditedSource(const SourceManager &SM, const LangOptions &LangOpts,
- const PPConditionalDirectiveRecord *PPRec = nullptr)
- : SourceMgr(SM), LangOpts(LangOpts), PPRec(PPRec), IdentTable(LangOpts),
- StrAlloc() { }
-
- const SourceManager &getSourceManager() const { return SourceMgr; }
- const LangOptions &getLangOpts() const { return LangOpts; }
- const PPConditionalDirectiveRecord *getPPCondDirectiveRecord() const {
- return PPRec;
- }
-
- bool canInsertInOffset(SourceLocation OrigLoc, FileOffset Offs);
-
- bool commit(const Commit &commit);
-
- void applyRewrites(EditsReceiver &receiver);
- void clearRewrites();
-
- StringRef copyString(StringRef str) { return str.copy(StrAlloc); }
- StringRef copyString(const Twine &twine);
-
-private:
- bool commitInsert(SourceLocation OrigLoc, FileOffset Offs, StringRef text,
- bool beforePreviousInsertions);
- bool commitInsertFromRange(SourceLocation OrigLoc, FileOffset Offs,
- FileOffset InsertFromRangeOffs, unsigned Len,
- bool beforePreviousInsertions);
- void commitRemove(SourceLocation OrigLoc, FileOffset BeginOffs, unsigned Len);
-
- StringRef getSourceText(FileOffset BeginOffs, FileOffset EndOffs,
- bool &Invalid);
- FileEditsTy::iterator getActionForOffset(FileOffset Offs);
- void deconstructMacroArgLoc(SourceLocation Loc,
- SourceLocation &ExpansionLoc,
- IdentifierInfo *&II);
-
- void startingCommit();
- void finishedCommit();
-};
-
-}
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Edit/EditsReceiver.h b/include/clang/Edit/EditsReceiver.h
deleted file mode 100644
index 600ac28..0000000
--- a/include/clang/Edit/EditsReceiver.h
+++ /dev/null
@@ -1,35 +0,0 @@
-//===----- EditedSource.h - Collection of source edits ----------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_EDIT_EDITSRECEIVER_H
-#define LLVM_CLANG_EDIT_EDITSRECEIVER_H
-
-#include "clang/Basic/LLVM.h"
-
-namespace clang {
- class SourceLocation;
- class CharSourceRange;
-
-namespace edit {
-
-class EditsReceiver {
-public:
- virtual ~EditsReceiver() { }
-
- virtual void insert(SourceLocation loc, StringRef text) = 0;
- virtual void replace(CharSourceRange range, StringRef text) = 0;
- /// \brief By default it calls replace with an empty string.
- virtual void remove(CharSourceRange range);
-};
-
-}
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Edit/FileOffset.h b/include/clang/Edit/FileOffset.h
deleted file mode 100644
index 0c1e72b..0000000
--- a/include/clang/Edit/FileOffset.h
+++ /dev/null
@@ -1,61 +0,0 @@
-//===----- FileOffset.h - Offset in a file ----------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_EDIT_FILEOFFSET_H
-#define LLVM_CLANG_EDIT_FILEOFFSET_H
-
-#include "clang/Basic/SourceLocation.h"
-
-namespace clang {
-
-namespace edit {
-
-class FileOffset {
- FileID FID;
- unsigned Offs;
-public:
- FileOffset() : Offs(0) { }
- FileOffset(FileID fid, unsigned offs) : FID(fid), Offs(offs) { }
-
- bool isInvalid() const { return FID.isInvalid(); }
-
- FileID getFID() const { return FID; }
- unsigned getOffset() const { return Offs; }
-
- FileOffset getWithOffset(unsigned offset) const {
- FileOffset NewOffs = *this;
- NewOffs.Offs += offset;
- return NewOffs;
- }
-
- friend bool operator==(FileOffset LHS, FileOffset RHS) {
- return LHS.FID == RHS.FID && LHS.Offs == RHS.Offs;
- }
- friend bool operator!=(FileOffset LHS, FileOffset RHS) {
- return !(LHS == RHS);
- }
- friend bool operator<(FileOffset LHS, FileOffset RHS) {
- return std::tie(LHS.FID, LHS.Offs) < std::tie(RHS.FID, RHS.Offs);
- }
- friend bool operator>(FileOffset LHS, FileOffset RHS) {
- return RHS < LHS;
- }
- friend bool operator>=(FileOffset LHS, FileOffset RHS) {
- return !(LHS < RHS);
- }
- friend bool operator<=(FileOffset LHS, FileOffset RHS) {
- return !(RHS < LHS);
- }
-};
-
-}
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/Edit/Rewriters.h b/include/clang/Edit/Rewriters.h
deleted file mode 100644
index 5e3425f..0000000
--- a/include/clang/Edit/Rewriters.h
+++ /dev/null
@@ -1,41 +0,0 @@
-//===--- Rewriters.h - Rewritings ---------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_EDIT_REWRITERS_H
-#define LLVM_CLANG_EDIT_REWRITERS_H
-#include "llvm/ADT/SmallVector.h"
-
-namespace clang {
- class ObjCMessageExpr;
- class ObjCMethodDecl;
- class ObjCInterfaceDecl;
- class ObjCProtocolDecl;
- class NSAPI;
- class EnumDecl;
- class TypedefDecl;
- class ParentMap;
-
-namespace edit {
- class Commit;
-
-bool rewriteObjCRedundantCallWithLiteral(const ObjCMessageExpr *Msg,
- const NSAPI &NS, Commit &commit);
-
-bool rewriteToObjCLiteralSyntax(const ObjCMessageExpr *Msg,
- const NSAPI &NS, Commit &commit,
- const ParentMap *PMap);
-
-bool rewriteToObjCSubscriptSyntax(const ObjCMessageExpr *Msg,
- const NSAPI &NS, Commit &commit);
-
-}
-
-} // end namespace clang
-
-#endif
OpenPOWER on IntegriCloud