<div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(68,68,68)">Thanks. You are right. It was solved by adding <span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Menlo;font-size:11px">clangToolingInclusions and clangFormat to the <span class="gmail-gr_ gmail-gr_422 gmail-gr-alert gmail-gr_spell gmail-gr_inline_cards gmail-gr_disable_anim_appear gmail-ContextualSpelling gmail-ins-del gmail-multiReplace" id="gmail-422" style="display:inline;border-bottom:2px solid transparent;background-repeat:no-repeat;color:inherit;font-size:inherit">cmake module</span>.</span></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:rgb(68,68,68)"><span style="font-variant-ligatures:no-common-ligatures;color:rgb(0,0,0);font-family:Menlo;font-size:11px"><br></span></div><div><div dir="ltr" class="gmail_signature"><div dir="ltr">Best,<div>Pardis</div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Dec 5, 2018 at 4:28 PM Kristóf Umann <<a href="mailto:dkszelethus@gmail.com">dkszelethus@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Hi!<div dir="auto"><br></div><div dir="auto">I suspect the problem will be in you CMakeLists.txt file. Can you copy it here?</div><div dir="auto"><br></div><div dir="auto">Cheers,</div><div dir="auto">Kristóf Umann</div><br><div class="gmail_extra"><br><div class="gmail_quote">On 5 Dec 2018 22:08, "Pardis Pashakhanloo via cfe-dev" <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="m_2437090760621871358quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-family:tahoma,sans-serif;color:#444444">Hi all,</div><div style="font-family:tahoma,sans-serif;color:#444444"><br></div><div style="font-family:tahoma,sans-serif;color:#444444">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.</div><div style="font-family:tahoma,sans-serif;color:#444444"><br></div><div style="font-family:tahoma,sans-serif;color:#444444">Here is the toy code I have currently written:</div><div style="font-family:tahoma,sans-serif;color:#444444">





<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><br></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">std::string teststr = "int main() { int i = 0 ; <span>  </span>}"; <span> </span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">clang::tooling::Range NewRange(0, teststr.size());</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">std::vector<clang::tooling::Range> ranges;</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">ranges.emplace_back(NewRange);</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">clang::tooling::Replacements Rs = clang::format::reformat(</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    clang::format::getLLVMStyle(),</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    teststr,</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    ranges,</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">    "ref.c"</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">);</span></p></div><div style="font-family:tahoma,sans-serif;color:#444444"><br></div><div style="font-family:tahoma,sans-serif;color:#444444">After compiling, I get the following errors:</div><div style="font-family:tahoma,sans-serif;color:#444444">





<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">error: undefined reference to 'clang::format::getLLVMStyle()'</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"> </span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">error: undefined reference to 'clang::format::reformat(clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling::Range>, llvm::StringRef, clang::format::FormattingAttemptStatus*)'</span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"> </span></p><p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">clang: </span><span style="font-variant-ligatures:no-common-ligatures;color:rgb(202,51,35)"><b>error: </b></span><span style="font-variant-ligatures:no-common-ligatures">linker command failed with exit code 1 (use -v to see invocation)</span></p></div><div style="font-family:tahoma,sans-serif;color:#444444"><br></div><div style="font-family:tahoma,sans-serif;color:#444444">I have also included "clang/Format/Format.h" and "clang/Lex/Lex.h".</div><div style="font-family:tahoma,sans-serif;color:#444444"><br></div><div style="font-family:tahoma,sans-serif;color:#444444">Any ideas?</div><div style="font-family:tahoma,sans-serif;color:#444444"><br></div><div style="font-family:tahoma,sans-serif;color:#444444">Thanks,</div><div style="font-family:tahoma,sans-serif;color:#444444">Pardis</div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div></div>