class LangOptions;
class Rewriter;
class SourceManager;
- class Stmt;
/// RewriteBuffer - As code is rewritten, SourceBuffer's from the original
/// input with modifications get a new RewriteBuffer associated with them. The
parentIndent);
}
- /// ConvertToString converts statement 'From' to a string using the
- /// pretty printer.
- std::string ConvertToString(Stmt *From);
-
/// getEditBuffer - This is like getRewriteBufferFor, but always returns a
/// buffer, and allows you to write on it directly. This is useful if you
/// want efficient low-level access to apis for scribbling on one specific
#include "clang/Rewrite/Core/Rewriter.h"
#include "clang/AST/Decl.h"
#include "clang/AST/PrettyPrinter.h"
-#include "clang/AST/Stmt.h"
#include "clang/Basic/DiagnosticIDs.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/SourceManager.h"
return ReplaceText(start, origLength, MB.substr(newOffs, newLength));
}
-std::string Rewriter::ConvertToString(Stmt *From) {
- assert(From != nullptr && "Expected non-null Stmt");
- std::string SStr;
- llvm::raw_string_ostream S(SStr);
- From->printPretty(S, nullptr, PrintingPolicy(*LangOpts));
- return S.str();
-}
-
bool Rewriter::IncreaseIndentation(CharSourceRange range,
SourceLocation parentIndent) {
if (range.isInvalid()) return true;