<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2017-06-14 4:24 GMT+07:00 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Ah, I find that the test passes if I remove the compile_commands.json file from my build directory (I have Ninja configured to generate a compile_commands.json file).<br><br>Looks like what happens is it finds the compilation database and fails hard when the database doesn't contain a compile command for the file in question. If the database is not found, it falls back to some basic command behavior, perhaps?<br><br></div></blockquote><div><br></div><div>You are right, constructor of `CommonOptionsParser` calls `autoDetectFromSource` or `autoDetectFromDirectory` prior to final construction of `FixedCompilationDatabase.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Is there some way this test could be fixed to cope with this, otherwise it seems to get in the way of people actually using clang tools in their LLVM/Clang build environment?</div><div class="gmail-m_8674514643682799494gmail-HOEnZb"><div class="gmail-m_8674514643682799494gmail-h5"><br></div></div></blockquote><div><br></div><div>IIUC, presence of stale compilation database file in test directory could break many tests. I don't understand why only diagnostic.cpp fails, probably there is something wrong with the clang-tidy application cleanup in this case?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail-m_8674514643682799494gmail-HOEnZb"><div class="gmail-m_8674514643682799494gmail-h5"><div class="gmail_quote"><div dir="ltr">On Tue, Jun 13, 2017 at 7:41 AM Serge Pavlov <<a href="mailto:sepavloff@gmail.com" target="_blank">sepavloff@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I cannot reproduce such fail, so I can only guess how changes made in <a href="https://reviews.llvm.org/rL303756" target="_blank">https://reviews.llvm.org/rL303<wbr>756</a> and <a href="https://reviews.llvm.org/rL303741" target="_blank">https://reviews.llvm.org/rL303<wbr>741</a> could cause such problem. Behavior of `Driver::BuildCompilation` is changed so that it returns null pointer if errors occur during driver argument parse. It is called in `CompilationDatabase.cpp` from `stripPositionalArgs`. The call stack at this point is:</div><div><span class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>stripPositionalArgs</div><div><span class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>clang::tooling::FixedCompilati<wbr>onDatabase::loadFromCommandLin<wbr>e</div><div><span class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>clang::tooling::CommonOptionsP<wbr>arser::CommonOptionsParser</div><div><span class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>clang::tidy::clangTidyMain</div><div><span class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554gmail-Apple-tab-span" style="white-space:pre-wrap"> </span>main</div><div>`FixedCompilationDatabase::loa<wbr>dFromCommandLine` returns null and CommonOptionsParser uses another method to create compilation database. The output "Compile command not found" means that no input file were found in `ClangTool::run`. Maybe some file names are nulls?</div><div><br></div><div class="gmail_extra"><br clear="all"><div><div class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554gmail_signature">Thanks,<br>--Serge<br></div></div></div></div><div dir="ltr"><div class="gmail_extra">
<br><div class="gmail_quote">2017-06-13 3:42 GMT+07:00 David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I've been seeing errors from this test recently:<br><br><div>Command Output (stderr):</div><div>--</div><div>1 error generated.</div><div>Error while processing /usr/local/google/home/blaikie<wbr>/dev/llvm/src/tools/clang/<wbr>tools/extra/test/clang-tidy/<wbr>diagnostic.cpp.nonexistent.<wbr>cpp.</div><div>/usr/local/google/home/blaikie<wbr>/dev/llvm/src/tools/clang/<wbr>tools/extra/test/clang-tidy/<wbr>diagnostic.cpp:10:12: error: expected string not found in input</div><span><div>// CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conv<wbr>ersion]</div></span><div> ^</div><div><stdin>:2:1: note: scanning from here</div><div>Skipping /usr/local/google/home/blaikie<wbr>/dev/llvm/src/tools/clang/<wbr>tools/extra/test/clang-tidy/<wbr>diagnostic.cpp. Compile command not found.</div><div>^</div><div><stdin>:2:1: note: with expression "@LINE+2" equal to "12"</div><div>Skipping /usr/local/google/home/blaikie<wbr>/dev/llvm/src/tools/clang/<wbr>tools/extra/test/clang-tidy/<wbr>diagnostic.cpp. Compile command not found.</div><div>^<br><br><br>Specifically, the output is:<br>$ ./bin/clang-tidy -checks='-*,clang-diagnostic-*<wbr>,google-explicit-constructor' /usr/local/google/home/blaikie<wbr>/dev/llvm/src/tools/clang/<wbr>tools/extra/test/clang-tidy/<wbr>diagnostic.cpp -- -fan-unknown-option 2>&1 error: unknown argument: '-fan-unknown-option' Skipping /usr/local/google/home/blaikie<wbr>/dev/llvm/src/tools/clang/<wbr>tools/extra/test/clang-tidy/<wbr>diagnostic.cpp. Compile command not found.<br><br><br>Does this look like it might be related to any of your changes in this area? Perhaps the error due to unknown argument is causing clang-tidy not to continue on to run the check & report the warning?<br><br></div></div><div class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554HOEnZb"><div class="gmail-m_8674514643682799494gmail-m_8339286651193700295m_260147376041695554h5"><br><div class="gmail_quote"><div dir="ltr">On Wed, May 24, 2017 at 3:51 AM Serge Pavlov via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: sepavloff<br>
Date: Wed May 24 05:50:56 2017<br>
New Revision: 303735<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=303735&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=303735&view=rev</a><br>
Log:<br>
Modify test so that it looks for patterns in stderr as well<br>
<br>
With the change <a href="https://reviews.llvm.org/D33013" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3301<wbr>3</a> driver will not build<br>
compilation object if command line is invalid, in particular, if<br>
unrecognized option is provided. In such cases it will prints diagnostics<br>
on stderr. The test 'clang-tidy/diagnostic.cpp' checks reaction on<br>
unrecognized option and will fail when D33013 is applied because it checks<br>
only stdout for test patterns and expects the name of diagnostic category<br>
prepared by clang-tidy. With this change the test makes more general check<br>
and must work in either case.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D33173" rel="noreferrer" target="_blank">https://reviews.llvm.org/D3317<wbr>3</a><br>
<br>
Modified:<br>
clang-tools-extra/trunk/test/c<wbr>lang-tidy/diagnostic.cpp<br>
<br>
Modified: clang-tools-extra/trunk/test/c<wbr>lang-tidy/diagnostic.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp?rev=303735&r1=303734&r2=303735&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-pr<wbr>oject/clang-tools-extra/trunk/<wbr>test/clang-tidy/diagnostic.<wbr>cpp?rev=303735&r1=303734&r2=<wbr>303735&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- clang-tools-extra/trunk/test/c<wbr>lang-tidy/diagnostic.cpp (original)<br>
+++ clang-tools-extra/trunk/test/c<wbr>lang-tidy/diagnostic.cpp Wed May 24 05:50:56 2017<br>
@@ -1,11 +1,11 @@<br>
// RUN: clang-tidy -checks='-*,modernize-use-over<wbr>ride' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 -implicit-check-not='{{warning<wbr>:|error:}}' %s<br>
-// RUN: clang-tidy -checks='-*,clang-diagnostic-*<wbr>,google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning<wbr>:|error:}}' %s<br>
-// RUN: clang-tidy -checks='-*,google-explicit-co<wbr>nstructor,clang-diagnostic-lit<wbr>eral-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning<wbr>:|error:}}' %s<br>
+// RUN: clang-tidy -checks='-*,clang-diagnostic-*<wbr>,google-explicit-constructor' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK2 -implicit-check-not='{{warning<wbr>:|error:}}' %s<br>
+// RUN: clang-tidy -checks='-*,google-explicit-co<wbr>nstructor,clang-diagnostic-lit<wbr>eral-conversion' %s -- -fan-unknown-option 2>&1 | FileCheck -check-prefix=CHECK3 -implicit-check-not='{{warning<wbr>:|error:}}' %s<br>
// RUN: clang-tidy -checks='-*,modernize-use-over<wbr>ride,clang-diagnostic-macro-<wbr>redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 -implicit-check-not='{{warning<wbr>:|error:}}' %s<br>
<br>
// CHECK1: error: error reading '{{.*}}.nonexistent.cpp' [clang-diagnostic-error]<br>
-// CHECK2: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]<br>
-// CHECK3: error: unknown argument: '-fan-unknown-option' [clang-diagnostic-error]<br>
+// CHECK2: error: unknown argument: '-fan-unknown-option'<br>
+// CHECK3: error: unknown argument: '-fan-unknown-option'<br>
<br>
// CHECK2: :[[@LINE+2]]:9: warning: implicit conversion from 'double' to 'int' changes value from 1.5 to 1 [clang-diagnostic-literal-conv<wbr>ersion]<br>
// CHECK3: :[[@LINE+1]]:9: warning: implicit conversion from 'double' to 'int' changes value<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div>
</div></div></blockquote></div><br></div></div></blockquote></div>
</div></div></blockquote></div><br></div></div>