[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-08-29 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Ping.

I feel like Phabricator is not sending notifications for this patch like it 
usually does (I'm not getting any emails).
I'll create a new, identical patch tomorrow if there's still no activity.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-08-29 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

In D131939#3755399 , @Eugene.Zelenko 
wrote:

> I got notification.

Thank you. I got an email for this message but not my own updates, which 
usually also CC me 🤷.
Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-06 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-13 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Mid-CppCon ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-06-29 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a reviewer: LegalizeAdulthood.
nicovank added a comment.

Ping, adding one more person who has history changing this script.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127807/new/

https://reviews.llvm.org/D127807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-06-30 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a reviewer: serge-sans-paille.
nicovank added a comment.

Did some digging, looks like this was added in rG7f92a1a84b96 
, most 
likely to also fix that CI build error with `misc-misleading-identifier`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127807/new/

https://reviews.llvm.org/D127807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-07-01 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

I do not have commit access for the LLVM repository, could one of you commit 
this for me (Nicolas van Kempen )?

I can keep an eye on this today, otherwise I will discuss with someone 
internally and commit Tuesday.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127807/new/

https://reviews.llvm.org/D127807

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2022-05-23 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 431387.
nicovank added a comment.

Update!

1. Rebased.
2. Fixed a minor bug which occasionaly caused false negatives.
3. Cleared up fix/hint generation and another nit following comments.
4. Re-organized and added a couple tests.
5. Made a note of this extension in documentation.

This check has been enabled internally as Facebook (pre-changes discussed 
above) for a bit over a year, with no reported issues.
It should be safe and ready to be upstreamed at this point.
Please let me know of any issues, let's get this landed!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-emplace.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -27,54 +48,230 @@
 
   template 
   void emplace_back(Args &&... args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&... args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&... args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&... args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&... args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  template  pair(const pair &){};
-  template  pair(pair &&){};
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
 };
 
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  c

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2022-05-23 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 431426.
nicovank added a comment.

Fix formatting issues


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/docs/clang-tidy/checks/modernize-use-emplace.rst
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -27,54 +48,230 @@
 
   template 
   void emplace_back(Args &&... args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&...args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&...args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_multiset {
+public:
+  us

[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-08-16 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun, mgorny.
Herald added a project: All.
nicovank edited the summary of this revision.
nicovank edited the summary of this revision.
nicovank updated this revision to Diff 452886.
nicovank updated this revision to Diff 452894.
nicovank added a comment.
nicovank updated this revision to Diff 452896.
Eugene.Zelenko added reviewers: alex, aaron.ballman, njames93, 
LegalizeAdulthood.
Eugene.Zelenko added a project: clang-tools-extra.
nicovank updated this revision to Diff 453026.
nicovank marked an inline comment as done.
nicovank published this revision for review.
nicovank added subscribers: marksantaniello, ivanmurashko, 0x1eaf.
nicovank marked an inline comment as done.
Herald added a subscriber: cfe-commits.

Rename second test file


nicovank added a comment.

Add isLanguageVersionSupported.




Comment at: 
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.h:31
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:

Please add `isLanguageVersionSupported`.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/performance/expensive-flat-container-operation.rst:6
+
+This check operates on vector-based containers such as
+``boost::container::flat_(map|set)`` and ``folly::sorted_vector_(map|set)``.

Please synchronize first statement with Release Notes.


This check has been enabled internally at Facebook for a few months now (with 
`OnlyWarnInLoops` disabled), where `folly::sorted_vector_map` is pretty widely 
used.

I saw `std::flat_(map|set)` and `std::flat_multi(map|set)` will appear in 
C++23, at which point this check can be updated to include these.

`folly::heap_vector_(map|set)` is another example of such containers, though 
still relatively new so not included here yet.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131939

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.cpp
  
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.h
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance/expensive-flat-container-operation.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation-only-warn-in-loops.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp
@@ -0,0 +1,383 @@
+// RUN: %check_clang_tidy %s performance-expensive-flat-container-operation %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: performance-expensive-flat-container-operation.OnlyWarnInLoops, \
+// RUN:   value: false}] \
+// RUN: }"
+
+namespace std {
+template 
+struct pair {
+  pair(T1, T2);
+};
+
+template
+struct initializer_list {
+  initializer_list();
+};
+
+template struct remove_reference  { typedef T type; };
+template struct remove_reference  { typedef T type; };
+template struct remove_reference { typedef T type; };
+
+template
+typename std::remove_reference::type&& move(T&&) noexcept;
+} // namespace std
+
+// Copied from boost/container/flat_map.hpp and boost/container/flat_set.hpp and simplified.
+namespace boost {
+namespace container {
+struct ordered_unique_range_t {};
+
+template 
+struct flat_map {
+  typedef Key key_type;
+  typedef T mapped_type;
+  typedef std::pair value_type;
+
+  typedef int size_type;
+  typedef struct {} iterator;
+  typedef struct {} const_iterator;
+
+  const_iterator begin() const noexcept;
+  const_iterator end() const noexcept;
+
+  template  std::pair emplace(Args&&...);
+
+  template  iterator emplace_hint(const_iterator, Args&&...);
+
+  template  std::pair try_emplace(const key_type&, Args&&...);
+  template  iterator try_emplace(const_iterator, const key_type&, Args&&...);
+  template  std::pair try_emplace(key_type&&, Args&&...);
+  template  iterator try_emplace(const_iterator, key_type&&, Args&&...);
+
+  std::pair insert(const value_type&);
+  std::pair insert(value_type&&);
+  iterator insert(const_iterator, const value_type&);
+  iterator insert(const_iterator, value_type&&);
+  template  void insert(InputIterator, InputIterator);
+  template  void insert(ordered_unique_range_t, InputIterator, InputIterator);
+  void insert(std::initializer_list);
+  void insert(ordered_unique_range_t, std::initializer_list);
+
+  iterator erase(const_iterator);
+  size_type erase(cons

[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-08-23 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a reviewer: alexfh.
nicovank added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-20 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 461592.
nicovank added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.cpp
  
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.h
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance/expensive-flat-container-operation.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation-only-warn-in-loops.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp
@@ -0,0 +1,383 @@
+// RUN: %check_clang_tidy %s performance-expensive-flat-container-operation %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: performance-expensive-flat-container-operation.OnlyWarnInLoops, \
+// RUN:   value: false}] \
+// RUN: }"
+
+namespace std {
+template 
+struct pair {
+  pair(T1, T2);
+};
+
+template
+struct initializer_list {
+  initializer_list();
+};
+
+template struct remove_reference  { typedef T type; };
+template struct remove_reference  { typedef T type; };
+template struct remove_reference { typedef T type; };
+
+template
+typename std::remove_reference::type&& move(T&&) noexcept;
+} // namespace std
+
+// Copied from boost/container/flat_map.hpp and boost/container/flat_set.hpp and simplified.
+namespace boost {
+namespace container {
+struct ordered_unique_range_t {};
+
+template 
+struct flat_map {
+  typedef Key key_type;
+  typedef T mapped_type;
+  typedef std::pair value_type;
+
+  typedef int size_type;
+  typedef struct {} iterator;
+  typedef struct {} const_iterator;
+
+  const_iterator begin() const noexcept;
+  const_iterator end() const noexcept;
+
+  template  std::pair emplace(Args&&...);
+
+  template  iterator emplace_hint(const_iterator, Args&&...);
+
+  template  std::pair try_emplace(const key_type&, Args&&...);
+  template  iterator try_emplace(const_iterator, const key_type&, Args&&...);
+  template  std::pair try_emplace(key_type&&, Args&&...);
+  template  iterator try_emplace(const_iterator, key_type&&, Args&&...);
+
+  std::pair insert(const value_type&);
+  std::pair insert(value_type&&);
+  iterator insert(const_iterator, const value_type&);
+  iterator insert(const_iterator, value_type&&);
+  template  void insert(InputIterator, InputIterator);
+  template  void insert(ordered_unique_range_t, InputIterator, InputIterator);
+  void insert(std::initializer_list);
+  void insert(ordered_unique_range_t, std::initializer_list);
+
+  iterator erase(const_iterator);
+  size_type erase(const key_type&);
+  iterator erase(const_iterator, const_iterator);
+};
+
+template 
+struct flat_set {
+  typedef Key key_type;
+  typedef Key value_type;
+
+  typedef int size_type;
+  typedef struct {} iterator;
+  typedef struct {} const_iterator;
+
+  const_iterator begin() const noexcept;
+  const_iterator end() const noexcept;
+
+  template  std::pair emplace(Args&&...);
+
+  template  iterator emplace_hint(const_iterator, Args&&...);
+
+  std::pair insert(const value_type&);
+  std::pair insert(value_type&&);
+  iterator insert(const_iterator, const value_type&);
+  iterator insert(const_iterator, value_type&&);
+  template  void insert(InputIterator, InputIterator);
+  template  void insert(ordered_unique_range_t, InputIterator, InputIterator);
+  void insert(std::initializer_list);
+  void insert(ordered_unique_range_t, std::initializer_list);
+
+  iterator erase(const_iterator);
+  size_type erase(const key_type&);
+  iterator erase(const_iterator, const_iterator);
+};
+} // namespace container
+} // namespace boost
+
+// Copied from folly/sorted_vector_types.h and simplified.
+namespace folly {
+template  struct sorted_vector_map {
+  typedef Key key_type;
+  typedef Value mapped_type;
+  typedef std::pair value_type;
+
+  typedef int size_type;
+  typedef struct {} iterator;
+  typedef struct {} const_iterator;
+
+  const_iterator begin() const;
+  const_iterator end() const;
+
+  std::pair insert(const value_type&);
+  std::pair insert(value_type&&);
+  iterator insert(const_iterator, const value_type&);
+  iterator insert(const_iterator, value_type&&);
+  template  void insert(InputIterator, InputIterator);
+  void insert(std::initializer_list);
+
+  template  std::pair emplace(Args&&...);
+  std::pair emplace(const

[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-20 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Ping.

F24615059: image.png 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-27 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a reviewer: JonasToth.
nicovank added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-30 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 464362.
nicovank added a comment.

Rename OnlyWarnInLoops to WarnOutsideLoops, cover missed cxxForRangeStmt


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.cpp
  
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.h
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance/expensive-flat-container-operation.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation-warn-outside-loops.cpp
  
clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation.cpp
@@ -0,0 +1,106 @@
+// RUN: %check_clang_tidy %s performance-expensive-flat-container-operation %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: performance-expensive-flat-container-operation.WarnOutsideLoops, \
+// RUN:   value: false}] \
+// RUN: }"
+
+namespace std {
+template 
+struct pair {
+  pair(T1, T2);
+};
+
+template
+struct initializer_list {
+  initializer_list();
+};
+} // namespace std
+
+// Copied from boost/container/flat_map.hpp and simplified.
+namespace boost {
+namespace container {
+struct ordered_unique_range_t {};
+
+template 
+struct flat_set {
+  typedef Key key_type;
+  typedef Key value_type;
+
+  typedef int size_type;
+  typedef struct {} iterator;
+  typedef struct {} const_iterator;
+
+  const_iterator begin() const noexcept;
+  const_iterator end() const noexcept;
+
+  template  std::pair emplace(Args&&...);
+
+  template  iterator emplace_hint(const_iterator, Args&&...);
+
+  std::pair insert(const value_type&);
+  std::pair insert(value_type&&);
+  iterator insert(const_iterator, const value_type&);
+  iterator insert(const_iterator, value_type&&);
+  template  void insert(InputIterator, InputIterator);
+  template  void insert(ordered_unique_range_t, InputIterator, InputIterator);
+  void insert(std::initializer_list);
+  void insert(ordered_unique_range_t, std::initializer_list);
+
+  iterator erase(const_iterator);
+  size_type erase(const key_type&);
+  iterator erase(const_iterator, const_iterator);
+};
+} // namespace container
+} // namespace boost
+
+static boost::container::flat_set gbfs;
+boost::container::flat_set& getGlobalSetRef() {
+  return gbfs;
+};
+
+void TestCheckWithLoops() {
+  boost::container::flat_set bfs;
+  bfs.insert(13);
+  bfs.erase(13);
+
+  for (int i = 0; i < 10; ++i) {
+bfs.insert(i);
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+
+if (i % 2 == 0) {
+  bfs.erase(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+}
+  }
+
+  while (true) {
+bfs.erase(bfs.begin());
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+  }
+
+  do {
+(&bfs)->emplace(13);
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+  } while (false);
+
+  for (int i = 0; i < 10; ++i) {
+boost::container::flat_set bfs;
+if (i % 2 == 0) {
+  bfs.insert(i);
+
+  gbfs.insert(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+
+  getGlobalSetRef().insert(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+
+  (gbfs).insert(i);
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+}
+
+for (int j = 0; j < i; ++j) {
+  bfs.insert(2 * j);
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Single element operations are expensive for flat containers.
+}
+  }
+}
Index: clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation-warn-outside-loops.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance/expensive-flat-container-operation-warn-outside-loops.cpp
@@ -0,0 +1,383 @@
+// RUN: %check_clang_tidy %s performance-expensive-flat-container-operation %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: 

[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-09-30 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Thank you for the feedback!

In D131939#3822766 , @njames93 wrote:

> I have a feeling the default should be to only warm in loops otherwise this 
> could get noisy.

Agreed, the less noisy version was already the default, renaming it is a good 
idea to avoid confusions.




Comment at: 
clang-tools-extra/clang-tidy/performance/ExpensiveFlatContainerOperationCheck.cpp:70
+const auto IsWithinLoop = cxxMemberCallExpr(
+hasAncestor(stmt(anyOf(forStmt(), whileStmt(), 
doStmt())).bind("loop")),
+// An easy false positive case: the variable is declared in the loop.

njames93 wrote:
> Rather than checking for an ancestor. Use the mapAnyOf matcher to check for a 
> descendant in a loops body, this would remove the need for the false positive 
> check below.
> Also you aren't checking a ranged for.
Thank you for catching the missing `cxxForRangeStmt`. Didn't know of `mapAnyOf`.

The idea is to not warn in cases such as below, where the declaration is in the 
same loop block as the insert/erase operation. Here, relatively, the insert is 
not in the loop. Of course, it's not possible to check the lifetime of the 
object in every case to make sure it's constrained to the loop, but from what 
I've seen this is the main false-positive case.

```
while(...) {
flat_set<...> s;
s.insert(...);
}
```

I don't think `mapAnyOf` makes expressing this any simpler (still need to check 
that the declaration is not within the same loop) so I kept the current 
version. If you really prefer `mapAnyOf` I can look into it again.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-10-11 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-11-17 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Ping.

@njames93 If you have a minute, could you please take a second look at this? 
Let me know what's needed to get this change landed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank accepted this revision.
nicovank added a comment.
This revision is now accepted and ready to land.

This is becoming repetitive, but I guess that's the nature of those things. 
Maybe something like this would help clean it up, not sure if any better for 
right now.

  template  // Lambda templates would have been nice.
  auto onTypeOrPointerType(const T &Type) { // onUnderlyingType ?
return on(anyOf(hasType(Type), hasType(pointerType(pointee(Type);
  }


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142939/new/

https://reviews.llvm.org/D142939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:100
+auto cxxMemberCallExprOnContainer(StringRef MethodName,
+  const std::vector ContainerNames) 
{
+  return cxxMemberCallExpr(

```
const std::vector &ContainerNames
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142939/new/

https://reviews.llvm.org/D142939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142939: Fix handling of -> calls for modernize-use-emplace

2023-01-31 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Nevermind, this was fixed as I was looking at it. LGTM.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142939/new/

https://reviews.llvm.org/D142939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-06-14 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank created this revision.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
nicovank retitled this revision from "[clang-tidy] Remove encode when 
outputting tool ouput running tests" to "[clang-tidy] Properly forward 
clang-tidy output when running tests".
nicovank updated this revision to Diff 436977.
nicovank added a comment.
nicovank published this revision for review.
nicovank added reviewers: rnk, alexfh.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Rebase.


When running tests, the check_clang_tidy script encodes the output string, 
making it hard to read when debugging checks. This removes the `.encode()` call.

Test Plan:
Making a new default check for testing (as of right now, it includes a failing 
test):

  [~/llvm-project/clang-tools-extra] python3 clang-tidy/add_new_check.py 
bugprone example
  <...>

Pre-changes:

  [~/llvm-project/build] ninja check-clang-tools
  <...>
   clang-tidy output ---
  b"1 warning 
generated.\n/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
 warning: function 'f' is insufficiently awesome [bugprone-example]\nvoid 
f();\n 
^\n/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
 note: insert 'awesome'\nvoid f();\n ^\n awesome_\n"
  
  --
  <...>

Post-changes:

  [~/llvm-project/build] ninja check-clang-tools
  <...>
   clang-tidy output ---
  1 warning generated.
  
/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
 warning: function 'f' is insufficiently awesome [bugprone-example]
  void f();
   ^
  
/data/users/nvankempen/llvm-project/build/Debug/tools/clang/tools/extra/test/clang-tidy/checkers/Output/bugprone-example.cpp.tmp.cpp:4:6:
 note: insert 'awesome'
  void f();
   ^
   awesome_
  
  --
  <...>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127807

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@
 print('Running ' + repr(args) + '...')
 clang_tidy_output = try_run(args)
 print(' clang-tidy output ---')
-print(clang_tidy_output.encode())
-
print('\n--')
+print(clang_tidy_output)
+print('--')
 
 diff_output = try_run(['diff', '-u', self.original_file_name, 
self.temp_file_name], False)
-print('-- Fixes 
-\n' +
-  diff_output +
-  
'\n--')
+print('-- Fixes -')
+print(diff_output)
+print('--')
 return clang_tidy_output
 
   def check_fixes(self):


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@
 print('Running ' + repr(args) + '...')
 clang_tidy_output = try_run(args)
 print(' clang-tidy output ---')
-print(clang_tidy_output.encode())
-print('\n--')
+print(clang_tidy_output)
+print('--')
 
 diff_output = try_run(['diff', '-u', self.original_file_name, self.temp_file_name], False)
-print('-- Fixes -\n' +
-  diff_output +
-  '\n--')
+print('-- Fixes -')
+print(diff_output)
+print('--')
 return clang_tidy_output
 
   def check_fixes(self):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-06-15 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 437163.
nicovank added a comment.

Looks like this causes the `misc-misleading-identifier` test to fail on the 
BuildKite Windows setup because it uses cp1252 and not utf-8. I think this is 
why the encode was added in the first place. This workaround should hopefully 
fix this, it will display unicode characters as '?' when stdout does not 
support utf-8.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127807/new/

https://reviews.llvm.org/D127807

Files:
  clang-tools-extra/test/clang-tidy/check_clang_tidy.py


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@
 print('Running ' + repr(args) + '...')
 clang_tidy_output = try_run(args)
 print(' clang-tidy output ---')
-print(clang_tidy_output.encode())
-
print('\n--')
+print(clang_tidy_output.encode(sys.stdout.encoding, 
errors="replace").decode(sys.stdout.encoding))
+print('--')
 
 diff_output = try_run(['diff', '-u', self.original_file_name, 
self.temp_file_name], False)
-print('-- Fixes 
-\n' +
-  diff_output +
-  
'\n--')
+print('-- Fixes -')
+print(diff_output)
+print('--')
 return clang_tidy_output
 
   def check_fixes(self):


Index: clang-tools-extra/test/clang-tidy/check_clang_tidy.py
===
--- clang-tools-extra/test/clang-tidy/check_clang_tidy.py
+++ clang-tools-extra/test/clang-tidy/check_clang_tidy.py
@@ -173,13 +173,13 @@
 print('Running ' + repr(args) + '...')
 clang_tidy_output = try_run(args)
 print(' clang-tidy output ---')
-print(clang_tidy_output.encode())
-print('\n--')
+print(clang_tidy_output.encode(sys.stdout.encoding, errors="replace").decode(sys.stdout.encoding))
+print('--')
 
 diff_output = try_run(['diff', '-u', self.original_file_name, self.temp_file_name], False)
-print('-- Fixes -\n' +
-  diff_output +
-  '\n--')
+print('-- Fixes -')
+print(diff_output)
+print('--')
 return clang_tidy_output
 
   def check_fixes(self):
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127886: [clang-tidy] Allow access to the SourceManager in clang-tidy checks

2022-06-15 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a project: All.
nicovank added reviewers: alexfh, aaron.ballman, njames93.
nicovank published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

I am writing a prototype check that needs source file and line numbers to map 
code to external data. As far as I know, the only way to achieve that is to 
expose the SourceManager which is so far only used to emit diagnostics.

Test Plan:
On a blank new check, 
`MatchedDecl->getBeginLoc().dump(Context->getSourceManager());` does properly 
show the matched declaration's origin filename and line number.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127886

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -121,6 +121,9 @@
   /// This is called from the \c ClangTidyCheck base class.
   void setSourceManager(SourceManager *SourceMgr);
 
+  /// Gets the \c SourceManager from the used \c DiagnosticsEngine.
+  SourceManager &getSourceManager();
+
   /// Should be called when starting to process new translation unit.
   void setCurrentFile(StringRef File);
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -221,6 +221,10 @@
   DiagEngine->setSourceManager(SourceMgr);
 }
 
+SourceManager &ClangTidyContext::getSourceManager() {
+  return DiagEngine->getSourceManager();
+}
+
 void ClangTidyContext::setCurrentFile(StringRef File) {
   CurrentFile = std::string(File);
   CurrentOptions = getOptionsForFile(CurrentFile);


Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
@@ -121,6 +121,9 @@
   /// This is called from the \c ClangTidyCheck base class.
   void setSourceManager(SourceManager *SourceMgr);
 
+  /// Gets the \c SourceManager from the used \c DiagnosticsEngine.
+  SourceManager &getSourceManager();
+
   /// Should be called when starting to process new translation unit.
   void setCurrentFile(StringRef File);
 
Index: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -221,6 +221,10 @@
   DiagEngine->setSourceManager(SourceMgr);
 }
 
+SourceManager &ClangTidyContext::getSourceManager() {
+  return DiagEngine->getSourceManager();
+}
+
 void ClangTidyContext::setCurrentFile(StringRef File) {
   CurrentFile = std::string(File);
   CurrentOptions = getOptionsForFile(CurrentFile);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127886: [clang-tidy] Allow access to the SourceManager in clang-tidy checks

2022-06-15 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank planned changes to this revision.
nicovank added a comment.

Thanks! Looks like `registerPPCallbacks` might be what I am looking for, I was 
not aware of it. I will mark this as planning changes temporarily, then abandon 
if solved.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127886/new/

https://reviews.llvm.org/D127886

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127886: [clang-tidy] Allow access to the SourceManager in clang-tidy checks

2022-06-16 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank abandoned this revision.
nicovank added a comment.

Looks like `registerPPCallbacks` / `Result.Context->getSourceManager()` gives 
me the information I need. Thank you @gribozavr2 for your help!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127886/new/

https://reviews.llvm.org/D127886

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2022-12-01 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank marked an inline comment as done.
nicovank added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D131939: [clang-tidy] Add performance-expensive-flat-container-operation check

2023-02-08 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

Ping :)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131939/new/

https://reviews.llvm.org/D131939

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank created this revision.
nicovank added reviewers: alexfh, Prazek, kuhar.
nicovank added projects: clang, clang-tools-extra.
Herald added a subscriber: xazax.hun.
nicovank requested review of this revision.
Herald added a subscriber: cfe-commits.

modernize-use-emplace only recommends going from a push_back to an
emplace_back, but does not provide a recommendation when emplace_back is
improperly used. This adds the functionality of warning the user when
an unecessary temporary is created while calling emplace_back or other "emplacy"
functions from the STL containers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -26,55 +47,231 @@
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  void emplace_back(Args &&...args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&...args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&...args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  t

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a comment.

As you can see, this will fail some tests as there is one corner case which is 
tricky to handle:

  std::vector>> vec;
  // This is valid and should not be changed.
  vec.emplace_back(std::make_tuple(13, 31));

Does anyone have a suggestion for a good way to handle this?

Ideally, it would be nice to just check that the type of the temporary matches 
the type of the `value_type`, but I've tried that with a simple `==`, and it 
then becomes a problem with strings, where for example

  std::vector> vec;
  vec.emplace_back(std::make_pair("foo", "bar"));

would not be changed as it would list the pair as a `std::pair`, and not match with `std::pair`.
Is there some way that I couldn't find to check if two `clang::Types` are 
"compatible"?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 341342.
nicovank added a comment.

Fix a couple variable names and explicitely specify a couple types


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -26,55 +47,231 @@
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  void emplace_back(Args &&...args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&...args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&...args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  template  pair(const pair &){};
-  template  pair(pair &&){};
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; 

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 341349.
nicovank added a comment.

Explicitely specify one more type


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -26,55 +47,231 @@
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  void emplace_back(Args &&...args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&...args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
   template 
-  void emplace_back(Args &&... args){};
+  iterator emplace(const_iterator pos, Args &&...args){};
+  template 
+  void emplace_back(Args &&...args){};
+  template 
+  void emplace_front(Args &&...args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&...args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&...args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  template  pair(const pair &){};
-  template  pair(pair &&){};
+  template 
+  void emplace(Args &&...args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&...args){};
+};
+
+template 
+class unordered_map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-04-28 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank marked 3 inline comments as done.
nicovank added a comment.

Thank you for the feedback, I appreciate it! Let me know if there is any other 
I missed, AFAIK all `auto` uses introduced by me should be good now.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-05-06 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank updated this revision to Diff 343399.
nicovank marked 7 inline comments as done.
nicovank added a comment.

Fix some style comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.h
  clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize-use-emplace.cpp
@@ -10,15 +10,36 @@
 
 namespace std {
 template 
-class initializer_list
-{
+class initializer_list {
 public:
   initializer_list() noexcept {}
 };
 
+template 
+class pair {
+public:
+  pair() = default;
+  pair(const pair &) = default;
+  pair(pair &&) = default;
+
+  pair(const T1 &, const T2 &) {}
+  pair(T1 &&, T2 &&) {}
+
+  template 
+  pair(const pair &){};
+  template 
+  pair(pair &&){};
+};
+
 template 
 class vector {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   vector() = default;
   vector(initializer_list) {}
 
@@ -27,54 +48,230 @@
 
   template 
   void emplace_back(Args &&... args){};
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   ~vector();
 };
+
 template 
 class list {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&... args){};
   ~list();
 };
 
 template 
 class deque {
 public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
   void push_back(const T &) {}
   void push_back(T &&) {}
 
+  template 
+  iterator emplace(const_iterator pos, Args &&... args){};
   template 
   void emplace_back(Args &&... args){};
+  template 
+  void emplace_front(Args &&... args){};
   ~deque();
 };
 
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
-template  struct remove_reference { using type = T; };
+template 
+class forward_list {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace_front(Args &&... args){};
+  template 
+  iterator emplace_after(const_iterator pos, Args &&... args){};
+};
 
-template  class pair {
+template 
+class set {
 public:
-  pair() = default;
-  pair(const pair &) = default;
-  pair(pair &&) = default;
+  using value_type = T;
 
-  pair(const T1 &, const T2 &) {}
-  pair(T1 &&, T2 &&) {}
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class multiset {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class multimap {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class unordered_set {
+public:
+  using value_type = T;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
 
-  template  pair(const pair &){};
-  template  pair(pair &&){};
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};
+};
+
+template 
+class unordered_map {
+public:
+  using value_type = std::pair;
+
+  class iterator {};
+  class const_iterator {};
+  const_iterator begin() { return const_iterator{}; }
+
+  template 
+  void emplace(Args &&... args){};
+  template 
+  iterator emplace_hint(const_iterator pos, Args &&... args){};

[PATCH] D101471: [clang-tidy] Add proper emplace checks to modernize-use-emplace

2021-05-06 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp:294
+  } else {
+if ((MakeCall ? MakeCall->getNumArgs() : CtorCall->getNumArgs()) == 0) {
+  Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(

kuhar wrote:
> Can you pull this ternary expression into a variable so that it does not have 
> to repeated when the diagnostic is emitted?
This is a bit tricky, since `MakeCall` is a `CallExpr` and `CtorCall` is a 
`CXXConstructExpr`, and they have no common base class. Even if I pull it out 
it'll be a lot of repetition.

I think there may be some elegant way to join the previous removal hints with 
these, but haven't had time to think about it. I'll probably post another 
update by the end of this week.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101471/new/

https://reviews.llvm.org/D101471

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits