diff options
author | Haojian Wu <hokein@google.com> | 2018-10-18 09:13:34 +0000 |
---|---|---|
committer | Haojian Wu <hokein@google.com> | 2018-10-18 09:13:34 +0000 |
commit | 547f89d607044004969f2556e1d10770917b753d (patch) | |
tree | a84dadc58e55668a8364289c0a037eeefbd8783b /clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp | |
parent | 5ee0188f2b87c7600ab2fef8f630efb75aeb57d5 (diff) | |
download | bcm5719-llvm-547f89d607044004969f2556e1d10770917b753d.tar.gz bcm5719-llvm-547f89d607044004969f2556e1d10770917b753d.zip |
[clang-tidy] Ignore a case where the fix of make_unique check introduces side effect.
Summary:
Previously, ptr.reset(new char[5]) will be replaced with `p =
make_unique<char[]>(5)`, the fix has side effect -- doing
default initialization, it may cause performace regression (we are
bitten by this rececntly)
The check should be conservative for these cases.
Reviewers: alexfh
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D53377
llvm-svn: 344733
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp b/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp index d2a73f3f311..aeeb6dbd809 100644 --- a/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp +++ b/clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp @@ -403,18 +403,15 @@ void initialization(int T, Base b) { // CHECK-FIXES: FFs = std::make_unique<Foo[]>(Num2); std::unique_ptr<int[]> FI; - FI.reset(new int[5]); - // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: - // CHECK-FIXES: FI = std::make_unique<int[]>(5); - FI.reset(new int[5]()); + FI.reset(new int[5]()); // default initialization. // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: // CHECK-FIXES: FI = std::make_unique<int[]>(5); + + // The check doesn't give warnings and fixes for cases where the original new + // expresion doesn't do any initialization. + FI.reset(new int[5]); FI.reset(new int[Num]); - // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: - // CHECK-FIXES: FI = std::make_unique<int[]>(Num); FI.reset(new int[Num2]); - // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: - // CHECK-FIXES: FI = std::make_unique<int[]>(Num2); } void aliases() { |