[PATCH] D132640: [clang-tidy] Fix modernize-use-emplace to support alias cases

Dong-hee Na via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 25 04:30:41 PDT 2022


corona10 updated this revision to Diff 455536.

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

https://reviews.llvm.org/D132640

Files:
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp


Index: clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
@@ -132,17 +132,20 @@
   // because this requires special treatment (it could cause performance
   // regression)
   // + match for emplace calls that should be replaced with insertion
-  auto CallPushBack = cxxMemberCallExpr(
-      hasDeclaration(functionDecl(hasName("push_back"))),
-      on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushBack)))));
-
-  auto CallPush = cxxMemberCallExpr(
-      hasDeclaration(functionDecl(hasName("push"))),
-      on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPush)))));
-
-  auto CallPushFront = cxxMemberCallExpr(
-      hasDeclaration(functionDecl(hasName("push_front"))),
-      on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushFront)))));
+  auto CallPushBack =
+      cxxMemberCallExpr(hasDeclaration(functionDecl(hasName("push_back"))),
+                        on(hasType(hasCanonicalType(hasDeclaration(
+                            namedDecl(hasAnyName(ContainersWithPushBack)))))));
+
+  auto CallPush =
+      cxxMemberCallExpr(hasDeclaration(functionDecl(hasName("push"))),
+                        on(hasType(hasCanonicalType(hasDeclaration(
+                            namedDecl(hasAnyName(ContainersWithPush)))))));
+
+  auto CallPushFront =
+      cxxMemberCallExpr(hasDeclaration(functionDecl(hasName("push_front"))),
+                        on(hasType(hasCanonicalType(hasDeclaration(
+                            namedDecl(hasAnyName(ContainersWithPushFront)))))));
 
   auto CallEmplacy = cxxMemberCallExpr(
       hasDeclaration(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132640.455536.patch
Type: text/x-patch
Size: 1768 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220825/283c87f9/attachment.bin>


More information about the cfe-commits mailing list