<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">cfe-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">Hi all,</div><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:#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 class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">Here is the toy code I have currently written:</div><div class="gmail_default" 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::<wbr>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 class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">After compiling, I get the following errors:</div><div class="gmail_default" 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()<wbr>'</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(<wbr>clang::format::FormatStyle const&, llvm::StringRef, llvm::ArrayRef<clang::tooling:<wbr>:Range>, llvm::StringRef, clang::format::<wbr>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 class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444"><br></div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">I have also included "clang/Format/Format.h" and "clang/Lex/Lex.h".</div><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:#444444">Any ideas?</div><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:#444444">Thanks,</div><div class="gmail_default" style="font-family:tahoma,sans-serif;color:#444444">Pardis</div></div>
<br>______________________________<wbr>_________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org">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/<wbr>mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div></div></div>