summaryrefslogtreecommitdiffstats
path: root/clang/lib/Edit
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2018-03-27 00:01:49 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2018-03-27 00:01:49 +0000
commitdb914a46dabc7723319f47682813543883621aac (patch)
tree2c76f0882cc975eb4d6a8b16c221649075301fb8 /clang/lib/Edit
parent373c445c241697caf0f0632d643af824cdf5762c (diff)
downloadbcm5719-llvm-db914a46dabc7723319f47682813543883621aac.tar.gz
bcm5719-llvm-db914a46dabc7723319f47682813543883621aac.zip
[Edit, Rewrite] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 328597
Diffstat (limited to 'clang/lib/Edit')
-rw-r--r--clang/lib/Edit/Commit.cpp19
-rw-r--r--clang/lib/Edit/EditedSource.cpp13
2 files changed, 24 insertions, 8 deletions
diff --git a/clang/lib/Edit/Commit.cpp b/clang/lib/Edit/Commit.cpp
index 0cc152bf1e7..afc1a131eb2 100644
--- a/clang/lib/Edit/Commit.cpp
+++ b/clang/lib/Edit/Commit.cpp
@@ -1,4 +1,4 @@
-//===----- Commit.cpp - A unit of edits -----------------------------------===//
+//===- Commit.cpp - A unit of edits ---------------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -8,10 +8,16 @@
//===----------------------------------------------------------------------===//
#include "clang/Edit/Commit.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Edit/EditedSource.h"
+#include "clang/Edit/FileOffset.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/PPConditionalDirectiveRecord.h"
+#include "llvm/ADT/StringRef.h"
+#include <cassert>
+#include <utility>
using namespace clang;
using namespace edit;
@@ -36,9 +42,9 @@ CharSourceRange Commit::Edit::getInsertFromRange(SourceManager &SM) const {
}
Commit::Commit(EditedSource &Editor)
- : SourceMgr(Editor.getSourceManager()), LangOpts(Editor.getLangOpts()),
- PPRec(Editor.getPPCondDirectiveRecord()),
- Editor(&Editor), IsCommitable(true) { }
+ : SourceMgr(Editor.getSourceManager()), LangOpts(Editor.getLangOpts()),
+ PPRec(Editor.getPPCondDirectiveRecord()),
+ Editor(&Editor) {}
bool Commit::insert(SourceLocation loc, StringRef text,
bool afterToken, bool beforePreviousInsertions) {
@@ -276,14 +282,12 @@ bool Commit::canInsertAfterToken(SourceLocation loc, FileOffset &offs,
}
bool Commit::canInsertInOffset(SourceLocation OrigLoc, FileOffset Offs) {
- for (unsigned i = 0, e = CachedEdits.size(); i != e; ++i) {
- Edit &act = CachedEdits[i];
+ for (const auto &act : CachedEdits)
if (act.Kind == Act_Remove) {
if (act.Offset.getFID() == Offs.getFID() &&
Offs > act.Offset && Offs < act.Offset.getWithOffset(act.Length))
return false; // position has been removed.
}
- }
if (!Editor)
return true;
@@ -338,6 +342,7 @@ bool Commit::isAtStartOfMacroExpansion(SourceLocation loc,
SourceLocation *MacroBegin) const {
return Lexer::isAtStartOfMacroExpansion(loc, SourceMgr, LangOpts, MacroBegin);
}
+
bool Commit::isAtEndOfMacroExpansion(SourceLocation loc,
SourceLocation *MacroEnd) const {
return Lexer::isAtEndOfMacroExpansion(loc, SourceMgr, LangOpts, MacroEnd);
diff --git a/clang/lib/Edit/EditedSource.cpp b/clang/lib/Edit/EditedSource.cpp
index 444d0393ccc..0ff2447f77a 100644
--- a/clang/lib/Edit/EditedSource.cpp
+++ b/clang/lib/Edit/EditedSource.cpp
@@ -1,4 +1,4 @@
-//===----- EditedSource.cpp - Collection of source edits ------------------===//
+//===- EditedSource.cpp - Collection of source edits ----------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -9,12 +9,21 @@
#include "clang/Edit/EditedSource.h"
#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Edit/Commit.h"
#include "clang/Edit/EditsReceiver.h"
+#include "clang/Edit/FileOffset.h"
#include "clang/Lex/Lexer.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include <algorithm>
+#include <cassert>
+#include <tuple>
+#include <utility>
using namespace clang;
using namespace edit;
@@ -269,9 +278,11 @@ bool EditedSource::commit(const Commit &commit) {
struct CommitRAII {
EditedSource &Editor;
+
CommitRAII(EditedSource &Editor) : Editor(Editor) {
Editor.startingCommit();
}
+
~CommitRAII() {
Editor.finishedCommit();
}
OpenPOWER on IntegriCloud