diff --git a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp b/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp --- a/clang-tools-extra/clang-tidy/llvm/TwineLocalCheck.cpp +++ b/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) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp b/clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/llvm-twine-local.cpp +++ b/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