<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Thanks! See one nit below.</div><div class="gmail_quote"><br></div><div class="gmail_quote">On Tue, Jul 8, 2014 at 4:41 PM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@googlemail.com" target="_blank">benny.kra@googlemail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 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: <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>
--- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp (original)<br>
+++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.cpp Tue Jul  8 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: <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>
--- clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h (original)<br>
+++ clang-tools-extra/trunk/clang-tidy/llvm/TwineLocalCheck.h Tue Jul  8 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: <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>
--- clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh (original)<br>
+++ clang-tools-extra/trunk/test/clang-tidy/check_clang_tidy_fix.sh Tue 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}" -- --std=c++11<br>
+clang-tidy ${TEMPORARY_FILE} -fix --checks="-*,${CHECK_TO_RUN}" -- --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 -input-file=${TEMPORARY_FILE}.msg ${INPUT_FILE} -check-prefix=CHECK-MESSAGES<br></blockquote><div><br></div><div>Any reason to use "not X || Y" instead of "X && Y" or even "if X ; then Y ; fi"?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Modified: clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp<br>
URL: <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>
--- clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp (original)<br>
+++ clang-tools-extra/trunk/test/clang-tidy/llvm-twine-local.cpp Tue Jul  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 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">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>
</blockquote></div><br>
</div></div>