LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 27383 - modernize-make-unique check doesn't apply to unique_ptr.reset()
Summary: modernize-make-unique check doesn't apply to unique_ptr.reset()
Status: RESOLVED FIXED
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Malcolm Parsons
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-16 07:34 PDT by Malcolm Parsons
Modified: 2016-11-01 05:06 PDT (History)
3 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Malcolm Parsons 2016-04-16 07:34:29 PDT
$ cat makeuniquetest.cpp 
#include <memory>
int main()
{
    auto p = std::unique_ptr<int>{new int()};
    p.reset(new int());
}

clang-tidy warns about line 4, but not line 5:
 
$ clang-tidy makeuniquetest.cpp -checks=-*,modernize-make-unique -- -std=c++14
1 warning generated.
/makeuniquetest.cpp:4:14: warning: use std::make_unique instead [modernize-make-unique]
    auto p = std::unique_ptr<int>{new int()};
             ^
             std::make_unique    (        )

Expected result after applying fixes:

#include <memory>
int main()
{
    auto p = std::make_unique<int>();
    p = std::make_unique<int>();
}
Comment 1 Malcolm Parsons 2016-11-01 05:06:24 PDT
Fixed in https://reviews.llvm.org/rL285589