[cfe-dev] clang reformat

Kristóf Umann via cfe-dev cfe-dev at lists.llvm.org
Wed Dec 5 13:28:56 PST 2018


Hi!

I suspect the problem will be in you CMakeLists.txt file. Can you copy it
here?

Cheers,
Kristóf Umann


On 5 Dec 2018 22:08, "Pardis Pashakhanloo via cfe-dev" <
cfe-dev at lists.llvm.org> wrote:

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::vector<clang::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::ArrayRef<clang::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

_______________________________________________
cfe-dev mailing list
cfe-dev at lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20181205/63853de4/attachment.html>


More information about the cfe-dev mailing list