clang 8.0.0

Namespaces | Functions | Variables
Replacement.cpp File Reference
`#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/RewriteBuffer.h"`
`#include "clang/Rewrite/Core/Rewriter.h"`
`#include "llvm/ADT/IntrusiveRefCntPtr.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>`
Include dependency graph for Replacement.cpp:

Go to the source code of this file.

## Namespaces
| clang
| Dataflow Directional Tag Classes.
| clang::tooling

## Functions
bool | clang::tooling::operator< (const Replacement &LHS, const Replacement &RHS)
| Less-than operator between two Replacements. More...
bool | clang::tooling::operator== (const Replacement &LHS, const Replacement &RHS)
| Equal-to operator between two Replacements. More...
static int | getRangeSize (const SourceManager &Sources, const CharSourceRange &Range, const LangOptions &LangOpts)
static std::string | getReplacementErrString (replacement_error Err)
static std::vector< Range > | combineAndSortRanges (std::vector< Range > Ranges)
std::vector< Range > | clang::tooling::calculateRangesAfterReplacements (const Replacements &Replaces, const std::vector< Range > &Ranges)
| Calculates the new ranges after `Replaces` are applied. More...
bool | clang::tooling::applyAllReplacements (const Replacements &Replaces, Rewriter &Rewrite)
| Apply all replacements in `Replaces` to the Rewriter `Rewrite`. More...
llvm::Expected< std::string > | clang::tooling::applyAllReplacements (StringRef Code, const Replacements &Replaces)
| Applies all replacements in `Replaces` to `Code`. More...
std::map< std::string, Replacements > | clang::tooling::groupReplacementsByFile (FileManager &FileMgr, const std::map< std::string, Replacements > &FileToReplaces)
| If there are multiple <File, Replacements> pairs with the same file entry, we only keep one pair and discard the rest. More...

## Variables
static const char *const | InvalidLocation = ""

## Function Documentation

## ◆ combineAndSortRanges()

static std::vector<Range> combineAndSortRanges | ( | std::vector< Range > | Ranges | ) |
| static

Definition at line 485 of file Replacement.cpp.

References clang::tooling::Range::getLength(), clang::tooling::Replacement::getLength(), clang::tooling::Range::getOffset(), clang::tooling::Replacement::getOffset(), and max().

Referenced by clang::tooling::calculateRangesAfterReplacements(), and clang::tooling::Replacements::getAffectedRanges().

## ◆ getRangeSize()

static int getRangeSize | ( | const SourceManager & | Sources,
|  | const CharSourceRange & | Range,
|  | const LangOptions & | LangOpts
| ) |  |
| static

Definition at line 135 of file Replacement.cpp.

References End, clang::CharSourceRange::getBegin(), clang::SourceManager::getDecomposedLoc(), clang::CharSourceRange::getEnd(), clang::tooling::Replacement::getFilePath(), clang::tooling::Replacement::getLength(), clang::tooling::Replacement::getOffset(), clang::tooling::Replacement::getReplacementText(), clang::SourceManager::getSpellingLoc(), clang::CharSourceRange::isTokenRange(), clang::Lexer::MeasureTokenLength(), and clang::tooling::Replacement::Replacement().

Referenced by clang::Rewriter::getRangeSize(), clang::Rewriter::InsertTextAfterToken(), and clang::Rewriter::ReplaceText().

## ◆ getReplacementErrString()

static std::string getReplacementErrString | ( | replacement_error | Err | ) |
| static

Definition at line 165 of file Replacement.cpp.

References clang::tooling::fail_to_apply, clang::tooling::insert_conflict, clang::tooling::overlap_conflict, and clang::tooling::wrong_file_path.

Referenced by clang::tooling::ReplacementError::message().

## Variable Documentation

## ◆ InvalidLocation

const char* const InvalidLocation = ""
| static

Definition at line 44 of file Replacement.cpp.

Referenced by clang::tooling::Replacement::isApplicable(), and clang::tooling::operator==().