Hi all,
I am trying to embed clang-format inside a clang tool I am implementing. As I learned, there is tooling::format::reformat(…) that can be used in this case. However, I have not been able to find any good tutorials, documentation, or examples on it.
Here is the toy code I have currently written:
std::string teststr = “int main() { int i = 0 ; }”;
clang::tooling::Range NewRange(0, teststr.size());
std::vectorclang::tooling::Range ranges;
ranges.emplace_back(NewRange);
clang::tooling::Replacements Rs = clang::format::reformat(
clang::format::getLLVMStyle(),
teststr,
ranges,
“ref.c”
);
After compiling, I get the following errors:
error: undefined reference to ‘clang::format::getLLVMStyle()’
error: undefined reference to ‘clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRefclang::tooling::Range, llvm::StringRef, clang::format::FormattingAttemptStatus*)’
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have also included “clang/Format/Format.h” and “clang/Lex/Lex.h”.
Any ideas?
Thanks,
Pardis