<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Seems to me you're missing clangFormat library<br>
</p>
<pre class="moz-signature" cols="72">Best regards,
Alexey Bataev</pre>
<div class="moz-cite-prefix">On 09/21/2016 04:57 PM, xiaohui chen wrote:<br>
</div>
<blockquote cite="mid:CALpPt08zvsK8iq_+d7y7Ln9g9jHn7eVQBfNm3U0KOqTLf0AP7w@mail.gmail.com" type="cite">
<div dir="ltr">
<div class="gmail_quote"><br>
<div dir="ltr">Hi guys,
<div><br>
</div>
<div>I am writing a libtooling tool. </div>
<div>My tool can compile and run with Clang version 3.6.2.</div>
<div>However, if I compile with Clang version 3.9.0, it reports an error:</div>
<div><br>
</div>
<div>
<div>/Project/clang+llvm-3.9.0-x86_<wbr>64-linux-gnu-ubuntu-14.04/bin/<wbr>../lib/libclangTooling.a(<wbr>Refactoring.cpp.o): In function `clang::tooling::<wbr>formatAndApplyAllReplacements(<wbr>std::set<clang::tooling::<wbr>Replacement, std::less<clang::tooling::<wbr>Replacement>,
 std::allocator<clang::tooling:<wbr>:Replacement> > const&, clang::Rewriter&, llvm::StringRef)':</div>
<div>/home/development/llvm/3.9.0/<wbr>final/llvm.src/tools/clang/<wbr>lib/Tooling/Refactoring.cpp:(.<wbr>text._<wbr>ZN5clang7tooling29formatAndApp<wbr>lyAllReplacementsERKSt3setINS0<wbr>_11ReplacementESt4lessIS2_<wbr>ESaIS2_EERNS_<wbr>8RewriterEN4llvm9StringRefE+<wbr>0x184):
 undefined reference to `clang::format::getStyle(llvm:<wbr>:StringRef, llvm::StringRef, llvm::StringRef, clang::vfs::FileSystem*)'</div>
<div>/home/development/llvm/3.9.0/<wbr>final/llvm.src/tools/clang/<wbr>lib/Tooling/Refactoring.cpp:(.<wbr>text._<wbr>ZN5clang7tooling29formatAndApp<wbr>lyAllReplacementsERKSt3setINS0<wbr>_11ReplacementESt4lessIS2_<wbr>ESaIS2_EERNS_<wbr>8RewriterEN4llvm9StringRefE+<wbr>0x19f):
 undefined reference to `clang::format::<wbr>formatReplacements(llvm::<wbr>StringRef, std::set<clang::tooling::<wbr>Replacement, std::less<clang::tooling::<wbr>Replacement>, std::allocator<clang::tooling:<wbr>:Replacement> > const&, clang::format::FormatStyle
 const&)'</div>
<div>clang-3.9: error: linker command failed with exit code 1 (use -v to see invocation)</div>
<div>make: *** [main] Error 1</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Do you have any hints?</div>
<div><br>
</div>
<div>Best </div>
<span class="HOEnZb"><font color="#888888">
<div>xiaohui</div>
<div><br>
</div>
</font></span></div>
<div class="HOEnZb">
<div class="h5">
<div class="gmail_extra"><br>
<div class="gmail_quote">On Wed, Mar 18, 2015 at 10:01 AM, xiaohui chen <span dir="ltr">
<<a moz-do-not-send="true" href="mailto:xchen198812@gmail.com" target="_blank">xchen198812@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
                    .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">Hi, 
<div>I am using clang version 3.6.0 (trunk 224915).</div>
<div><br>
</div>
<div>Clang can not parse the following valid OpenMP code:</div>
<div><br>
</div>
<div>
<div> 1 #include<omp.h></div>
<div>  2 void main()</div>
<div>  3 {</div>
<div>  4         int i;</div>
<div>  5         #pragma omp parallel</div>
<div>  6         #pragma omp sections</div>
<div>  7         {</div>
<div>  8                 i++;</div>
<div>  9                 i++;</div>
<div> 10                 #pragma omp section</div>
<div> 11                 i++;</div>
<div> 12         }</div>
<div> 13 }</div>
</div>
<div><br>
</div>
<div>The bug comes from line 8 and 9.</div>
<div><br>
</div>
<div>In OpenMP documentation (<a moz-do-not-send="true" href="http://www.openmp.org/mp-documents/OpenMP4.0.0.pdf" target="_blank">http://www.openmp.org/mp-docu<wbr>ments/OpenMP4.0.0.pdf</a>) page 62,</div>
<div>it says"Each structured block in the sections construct is preceded by a section directive </div>
<div>except possibly the first block, for which a preceding section directive is optional." .</div>
<div><br>
</div>
<div>it means that the section directive is optional for the first block, but not the first statement.</div>
<div><br>
</div>
<div>in function  StmtResult Sema::ActOnOpenMPSectionsDirec<wbr>tive, </div>
<div><br>
</div>
<div>
<div>3021 StmtResult Sema::ActOnOpenMPSectionsDirec<wbr>tive(ArrayRef<OMPClause *> Clauses,</div>
<div>3022                                               Stmt *AStmt,</div>
<div>3023                                               SourceLocation StartLoc,</div>
<div>3024                                               SourceLocation EndLoc) {</div>
<div>3025   assert(AStmt && isa<CapturedStmt>(AStmt) && "Captured statement expected");</div>
<div>3026   auto BaseStmt = AStmt;</div>
<div>3027   while (CapturedStmt *CS = dyn_cast_or_null<CapturedStmt><wbr>(BaseStmt))</div>
<div>3028     BaseStmt = CS->getCapturedStmt();</div>
<div>3029   if (auto C = dyn_cast_or_null<CompoundStmt><wbr>(BaseStmt)) {</div>
<div>3030     auto S = C->children();</div>
<div>3031     if (!S)</div>
<div>3032       return StmtError();</div>
<div>3033     // All associated statements must be '#pragma omp section' except for</div>
<div>3034     // the first one.</div>
<div>3035     for (++S; S; ++S) {</div>
<div>3036       auto SectionStmt = *S;</div>
<div>3037       if (!SectionStmt || !isa<OMPSectionDirective>(Sect<wbr>ionStmt)) {</div>
<div>3038         if (SectionStmt)</div>
<div>3039           Diag(SectionStmt->getLocStart(<wbr>),</div>
<div>3040                diag::err_omp_sections_substm<wbr>t_not_section);</div>
<div>3041         return StmtError();</div>
<div>3042       }</div>
<div>3043     }</div>
<div>3044   } else {</div>
<div>3045     Diag(AStmt->getLocStart(), diag::err_omp_sections_not_com<wbr>pound_stmt);</div>
<div>3046     return StmtError();</div>
<div>3047   }</div>
<div>3048 </div>
<div>3049   getCurFunction()->setHasBranch<wbr>ProtectedScope();</div>
<div>3050 </div>
<div>3051   return OMPSectionsDirective::Create(C<wbr>ontext, StartLoc, EndLoc, Clauses,</div>
<div>3052                                       AStmt);</div>
<div>3053 }</div>
</div>
<div><br>
</div>
<div>Notice from line 3035 to line 3042, it just checks the first statement not the first statement.</div>
<div><br>
</div>
<div><br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div>
<br>
</div>
</blockquote>
<br>
</body>
</html>