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 50157 - performance-inefficient-vector-operation not detected in member function
Summary: performance-inefficient-vector-operation not detected in member function
Status: CONFIRMED
Alias: None
Product: clang-tools-extra
Classification: Unclassified
Component: clang-tidy (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P enhancement
Assignee: Nathan James
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-28 15:07 PDT by oliverst
Modified: 2021-04-30 06:39 PDT (History)
6 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 oliverst 2021-04-28 15:07:39 PDT
#include <vector>

struct A
{
 void f() const
 {
   std::vector<int> v_s;

   for (const auto& s : v_) {
     v_s.emplace_back(s);
   }
 }

  std::vector<int> v_;
};

This was reduced from a much bigger class where the variable was actually filled.

If I make both members static or implement it with a function and a global warning the warning is being reported.

Tested with version 11.0.1.
Comment 1 Nathan James 2021-04-30 06:39:06 PDT
Proposed patch - https://reviews.llvm.org/D101624