ΒΆllvm::Expected<tooling::Replacements>
cleanupAroundReplacements(
    llvm::StringRef Code,
    const tooling::Replacements& Replaces,
    const clang::format::FormatStyle& Style)

Description

Returns the replacements corresponding to applying \p Replaces and cleaning up the code after that on success; otherwise, return an llvm::Error carrying llvm::StringError. This also supports inserting/deleting C++ #include directives: - If a replacement has offset UINT_MAX, length 0, and a replacement text that is an #include directive, this will insert the #include into the correct block in the \p Code. - If a replacement has offset UINT_MAX, length 1, and a replacement text that is the name of the header to be removed, the header will be removed from \p Code if it exists. The include manipulation is done via `tooling::HeaderInclude`, see its documentation for more details on how include insertion points are found and what edits are produced.

Declared at: clang/include/clang/Format/Format.h:4138

Parameters

llvm::StringRef Code
const tooling::Replacements& Replaces
const clang::format::FormatStyle& Style