From 8d228dda413a3c4b40cf0480f06b0edb232ba2c4 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Wed, 30 Dec 2015 11:35:50 +0000 Subject: [clang-tidy] Use hasLocalStorage() to identify unnecessary copy initializations to exclude static local variables. Summary: Since local static variables can outlive other local variables exclude them from the unnecessary copy initialization check. Reviewers: alexfh Patch by Felix Berger! Differential Revision: http://reviews.llvm.org/D15822 llvm-svn: 256636 --- .../test/clang-tidy/performance-unnecessary-copy-initialization.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp') diff --git a/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp b/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp index 7eb7d2fef67..aaaeffd652a 100644 --- a/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp +++ b/clang-tools-extra/test/clang-tidy/performance-unnecessary-copy-initialization.cpp @@ -110,6 +110,10 @@ void NegativeFunctionCallTrivialType() { const TrivialToCopyType VarCopyConstructed(TrivialTypeReference()); } +void NegativeStaticLocalVar(const ExpensiveToCopyType &Obj) { + static const auto StaticVar = Obj.reference(); +} + void NegativeFunctionCallExpensiveTypeNonConstVariable() { auto AutoAssigned = ExpensiveTypeReference(); auto AutoCopyConstructed(ExpensiveTypeReference()); -- cgit v1.2.3