#include "clang/Tooling/Core/Replacement.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/SourceLocation.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "clang/Rewrite/Core/Rewriter.h"
#include "llvm/ADT/IntrusiveRefCntPtr.h"
#include "llvm/ADT/RewriteBuffer.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
#include <cassert>
#include <limits>
#include <map>
#include <string>
#include <utility>
#include <vector>
usingnamespaceclang;
usingnamespacetooling;
static const char * const InvalidLocation = …;
Replacement::Replacement() : … { … }
Replacement::Replacement(StringRef FilePath, unsigned Offset, unsigned Length,
StringRef ReplacementText)
: … { … }
Replacement::Replacement(const SourceManager &Sources, SourceLocation Start,
unsigned Length, StringRef ReplacementText) { … }
Replacement::Replacement(const SourceManager &Sources,
const CharSourceRange &Range,
StringRef ReplacementText,
const LangOptions &LangOpts) { … }
bool Replacement::isApplicable() const { … }
bool Replacement::apply(Rewriter &Rewrite) const { … }
std::string Replacement::toString() const { … }
namespace clang {
namespace tooling {
bool operator<(const Replacement &LHS, const Replacement &RHS) { … }
bool operator==(const Replacement &LHS, const Replacement &RHS) { … }
}
}
void Replacement::setFromSourceLocation(const SourceManager &Sources,
SourceLocation Start, unsigned Length,
StringRef ReplacementText) { … }
static int getRangeSize(const SourceManager &Sources,
const CharSourceRange &Range,
const LangOptions &LangOpts) { … }
void Replacement::setFromSourceRange(const SourceManager &Sources,
const CharSourceRange &Range,
StringRef ReplacementText,
const LangOptions &LangOpts) { … }
Replacement
Replacements::getReplacementInChangedCode(const Replacement &R) const { … }
static std::string getReplacementErrString(replacement_error Err) { … }
std::string ReplacementError::message() const { … }
char ReplacementError::ID = …;
Replacements Replacements::getCanonicalReplacements() const { … }
llvm::Expected<Replacements>
Replacements::mergeIfOrderIndependent(const Replacement &R) const { … }
llvm::Error Replacements::add(const Replacement &R) { … }
namespace {
class MergedReplacement { … };
}
Replacements Replacements::merge(const Replacements &ReplacesToMerge) const { … }
static std::vector<Range> combineAndSortRanges(std::vector<Range> Ranges) { … }
namespace clang {
namespace tooling {
std::vector<Range>
calculateRangesAfterReplacements(const Replacements &Replaces,
const std::vector<Range> &Ranges) { … }
}
}
std::vector<Range> Replacements::getAffectedRanges() const { … }
unsigned Replacements::getShiftedCodePosition(unsigned Position) const { … }
namespace clang {
namespace tooling {
bool applyAllReplacements(const Replacements &Replaces, Rewriter &Rewrite) { … }
llvm::Expected<std::string> applyAllReplacements(StringRef Code,
const Replacements &Replaces) { … }
std::map<std::string, Replacements> groupReplacementsByFile(
FileManager &FileMgr,
const std::map<std::string, Replacements> &FileToReplaces) { … }
}
}