<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Jul 8, 2014 at 5:04 PM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@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><div>On Tue, Jul 8, 2014 at 5:58 PM, Alexander Kornienko <<a href="mailto:alexfh@google.com" target="_blank">alexfh@google.com</a>> wrote:<br>
> Thanks! See one nit below.<br>
><br>
> On Tue, Jul 8, 2014 at 4:41 PM, Benjamin Kramer <<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>><br>
> wrote:<br>
>><br>
>> Author: d0k<br>
>> Date: Tue Jul 8 10:41:20 2014<br>
>> New Revision: 212540<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=212540&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=212540&view=rev</a><br>
>> Log:<br>
>> [clang-tidy] Address review comments for the Twine checker.<br>
>><br>
>> - Remove unused includes.<br>
>> - Minor wording fix.<br>
>> - Added support to check for clang-tidy messages to<br>
>> check_clang_tidy_fix.sh<br>
>> = Updated test case.<br>
>><br>
>> Modified:<br>
>> clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp<br>
>> clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h<br>
>> clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh<br>
>> clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp<br>
>><br>
>> Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp?rev=212540&r1=212539&r2=212540&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp?rev=212540&r1=212539&r2=212540&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp (original)<br>
>> +++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp Tue Jul 8<br>
>> 10:41:20 2014<br>
>> @@ -11,7 +11,6 @@<br>
>> #include "clang/AST/ASTContext.h"<br>
>> #include "clang/ASTMatchers/ASTMatchers.h"<br>
>> #include "clang/Lex/Lexer.h"<br>
>> -#include "llvm/Support/raw_ostream.h"<br>
>><br>
>> using namespace clang::ast_matchers;<br>
>><br>
>> @@ -29,7 +28,7 @@ void TwineLocalCheck::registerMatchers(M<br>
>> void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {<br>
>> const VarDecl *VD = Result.Nodes.getNodeAs<VarDecl>("variable");<br>
>> auto Diag = diag(VD->getLocation(),<br>
>> - "twine variables are prone to use after free bugs");<br>
>> + "twine variables are prone to use-after-free bugs");<br>
>><br>
>> // If this VarDecl has an initializer try to fix it.<br>
>> if (VD->hasInit()) {<br>
>><br>
>> Modified: clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h?rev=212540&r1=212539&r2=212540&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h?rev=212540&r1=212539&r2=212540&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h (original)<br>
>> +++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h Tue Jul 8<br>
>> 10:41:20 2014<br>
>> @@ -11,7 +11,6 @@<br>
>> #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LLVM_TWINE_LOCAL_CHECK_H<br>
>><br>
>> #include "../ClangTidy.h"<br>
>> -#include "llvm/Support/Regex.h"<br>
>><br>
>> namespace clang {<br>
>> namespace tidy {<br>
>><br>
>> Modified: clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh?rev=212540&r1=212539&r2=212540&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh?rev=212540&r1=212539&r2=212540&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh<br>
>> (original)<br>
>> +++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh Tue<br>
>> Jul 8 10:41:20 2014<br>
>> @@ -7,5 +7,6 @@ CHECK_TO_RUN=$2<br>
>> TEMPORARY_FILE=$3.cpp<br>
>><br>
>> grep -Ev "// *[A-Z-]+:" ${INPUT_FILE} > ${TEMPORARY_FILE}<br>
>> -clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" --<br>
>> --std=c++11<br>
>> +clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" --<br>
>> --std=c++11 > ${TEMPORARY_FILE}.msg 2>&1<br>
>> FileCheck -input-file=${TEMPORARY_FILE} ${INPUT_FILE} -strict-whitespace<br>
>> +not grep CHECK-MESSAGES ${INPUT_FILE} || FileCheck<br>
>> -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} -check-prefix=CHECK-MESSAGES<br>
><br>
><br>
> Any reason to use "not X || Y" instead of "X && Y" or even "if X ; then Y ;<br>
> fi"?<br>
<br>
</div></div>I care about the return value.</blockquote><div><br></div><div>You're right. But it seems like we've started ignoring the return value of the first FileCheck. We either need to use "bash -e" or add "|| exit $?".</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
X && Y would return failure if X<br>
failed, I want it to succeed if X failed or Y passed so the other<br>
tests keep functioning.<br>
<br>
I guess an explicit if-then would be doable. Have to check how return<br>
values work when doing that.<br></blockquote><div><br></div><div>They should work fine in ifs. In any case you could use explicit "exit".</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
- Ben<br>
<div><div><br>
><br>
>><br>
>><br>
>> Modified: clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp<br>
>> URL:<br>
>> <a href="http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp?rev=212540&r1=212539&r2=212540&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp?rev=212540&r1=212539&r2=212540&view=diff</a><br>
>><br>
>> ==============================================================================<br>
>> --- clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp<br>
>> (original)<br>
>> +++ clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp Tue Jul<br>
>> 8 10:41:20 2014<br>
>> @@ -1,7 +1,5 @@<br>
>> -// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp<br>
>> -// RUN: clang-tidy %t.cpp -checks='-*,llvm-twine-local' -fix -- > %t.msg<br>
>> 2>&1<br>
>> -// RUN: FileCheck -input-file=%t.cpp %s<br>
>> -// RUN: FileCheck -input-file=%t.msg -check-prefix=CHECK-MESSAGES %s<br>
>> +// RUN: $(dirname %s)/check_clang_tidy_fix.sh %s llvm-twine-local %t<br>
>> +// REQUIRES: shell<br>
>><br>
>> namespace llvm {<br>
>> class Twine {<br>
>> @@ -17,19 +15,19 @@ using namespace llvm;<br>
>> void foo(const Twine &x);<br>
>><br>
>> static Twine Moo = Twine("bark") + "bah";<br>
>> -// CHECK-MASSAGES: twine variables are prone to use after free bugs<br>
>> +// CHECK-MASSAGES: twine variables are prone to use-after-free bugs<br>
>> // CHECK-MESSAGES: note: FIX-IT applied suggested code changes<br>
>> // CHECK: static std::string Moo = (Twine("bark") + "bah").str();<br>
>><br>
>> int main() {<br>
>> const Twine t = Twine("a") + "b" + Twine(42);<br>
>> -// CHECK-MASSAGES: twine variables are prone to use after free bugs<br>
>> +// CHECK-MASSAGES: twine variables are prone to use-after-free bugs<br>
>> // CHECK-MESSAGES: note: FIX-IT applied suggested code changes<br>
>> // CHECK: std::string t = (Twine("a") + "b" + Twine(42)).str();<br>
>> foo(Twine("a") + "b");<br>
>><br>
>> Twine Prefix = false ? "__INT_FAST" : "__UINT_FAST";<br>
>> -// CHECK-MASSAGES: twine variables are prone to use after free bugs<br>
>> +// CHECK-MASSAGES: twine variables are prone to use-after-free bugs<br>
>> // CHECK-MESSAGES: note: FIX-IT applied suggested code changes<br>
>> // CHECK: const char * Prefix = false ? "__INT_FAST" : "__UINT_FAST";<br>
>> }<br>
>><br>
>><br>
>> _______________________________________________<br>
>> cfe-commits mailing list<br>
>> <a href="mailto:cfe-commits@cs.uiuc.edu" target="_blank">cfe-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
><br>
></div></div></blockquote></div>
</div></div>