Bug 362943 - false positive for reserve candidate
Summary: false positive for reserve candidate
Status: RESOLVED FIXED
Alias: None
Product: clazy
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Sergio Martins
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-11 13:52 UTC by eric.lemanissier
Modified: 2016-05-14 18:05 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description eric.lemanissier 2016-05-11 13:52:30 UTC
In the following code, I get the warning "Reserve candidate [-Wclazy-reserve-candidates]" on the last line:

    m_tmpBuf.reserve(m_tmpBuf.size() + vect.size());
    for(const auto &i:vect)
    {
        m_tmpBuf << i;
    }

Reproducible: Always
Comment 1 eric.lemanissier 2016-05-11 13:54:27 UTC
I forgot to mention the following:
m_tmpBuf is a QQueue and vect is a QVector
Comment 2 Sergio Martins 2016-05-11 17:55:07 UTC
Git commit d4205769b406d526c706118cbb34ffaeb2103785 by Sergio Martins.
Committed on 11/05/2016 at 17:54.
Pushed by smartins into branch 'master'.

Add test-case for false positive

M  +10   -0    tests/reserve-candidates/main.cpp

http://commits.kde.org/clazy/d4205769b406d526c706118cbb34ffaeb2103785
Comment 3 Sergio Martins 2016-05-14 18:05:26 UTC
Git commit ce9f92e2ba0cb3823983d75637487f85905a7665 by Sergio Martins.
Committed on 14/05/2016 at 18:02.
Pushed by smartins into branch 'master'.

Make Utils::valueDeclForOperatorCall() more robust.

There were situations where we were picking the wrong DeclRefExpr.
Unit-test already added in reserve-candidates/main.cpp

M  +13   -9    Utils.cpp

http://commits.kde.org/clazy/ce9f92e2ba0cb3823983d75637487f85905a7665