[PATCH] D82281: [clang-tidy] llvm-twine-local ignores parameters

2020-06-22 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9a8b04114480: [clang-tidy] llvm-twine-local ignores 
parameters (authored by njames93).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82281/new/

https://reviews.llvm.org/D82281

Files:
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine &x);
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to 
use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine &x);
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82281: [clang-tidy] llvm-twine-local ignores parameters

2020-06-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D82281/new/

https://reviews.llvm.org/D82281



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D82281: [clang-tidy] llvm-twine-local ignores parameters

2020-06-21 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: bkramer, alexfh, aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Ignore paramater declarations of type `::llvm::Twine`, These don't suffer the 
same use after free risks as local twines.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D82281

Files:
  clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine &x);
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to 
use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {


Index: clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp
@@ -13,6 +13,7 @@
 using namespace llvm;
 
 void foo(const Twine &x);
+void bar(Twine x);
 
 static Twine Moo = Twine("bark") + "bah";
 // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: twine variables are prone to use-after-free bugs
Index: clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
===
--- clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
+++ clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp
@@ -19,8 +19,10 @@
 
 void TwineLocalCheck::registerMatchers(MatchFinder *Finder) {
   auto TwineType =
-  qualType(hasDeclaration(recordDecl(hasName("::llvm::Twine";
-  Finder->addMatcher(varDecl(hasType(TwineType)).bind("variable"), this);
+  qualType(hasDeclaration(cxxRecordDecl(hasName("::llvm::Twine";
+  Finder->addMatcher(
+  varDecl(unless(parmVarDecl()), hasType(TwineType)).bind("variable"),
+  this);
 }
 
 void TwineLocalCheck::check(const MatchFinder::MatchResult &Result) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits