corona10 created this revision.
Herald added subscribers: carlosgalvezp, jeroen.dobbelaere, xazax.hun.
Herald added a project: All.
corona10 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.
Fix modernize-use-emplace to support alias cases
Repository:
rG LLVM Github Monorepo
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
@@ -134,15 +134,21 @@
// + match for emplace calls that should be replaced with insertion
auto CallPushBack = cxxMemberCallExpr(
hasDeclaration(functionDecl(hasName("push_back"))),
- on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushBack)))));
+ on(anyOf(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushBack))),
+ hasType(hasCanonicalType(hasDeclaration(
+ namedDecl(hasAnyName(ContainersWithPushBack))))))));
auto CallPush = cxxMemberCallExpr(
hasDeclaration(functionDecl(hasName("push"))),
- on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPush)))));
+ on(anyOf(hasType(cxxRecordDecl(hasAnyName(ContainersWithPush))),
+ hasType(hasCanonicalType(hasDeclaration(
+ namedDecl(hasAnyName(ContainersWithPush))))))));
auto CallPushFront = cxxMemberCallExpr(
hasDeclaration(functionDecl(hasName("push_front"))),
- on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushFront)))));
+ on(anyOf(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushFront))),
+ hasType(hasCanonicalType(hasDeclaration(
+ namedDecl(hasAnyName(ContainersWithPushFront))))))));
auto CallEmplacy = cxxMemberCallExpr(
hasDeclaration(
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
@@ -134,15 +134,21 @@
// + match for emplace calls that should be replaced with insertion
auto CallPushBack = cxxMemberCallExpr(
hasDeclaration(functionDecl(hasName("push_back"))),
- on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushBack)))));
+ on(anyOf(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushBack))),
+ hasType(hasCanonicalType(hasDeclaration(
+ namedDecl(hasAnyName(ContainersWithPushBack))))))));
auto CallPush = cxxMemberCallExpr(
hasDeclaration(functionDecl(hasName("push"))),
- on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPush)))));
+ on(anyOf(hasType(cxxRecordDecl(hasAnyName(ContainersWithPush))),
+ hasType(hasCanonicalType(hasDeclaration(
+ namedDecl(hasAnyName(ContainersWithPush))))))));
auto CallPushFront = cxxMemberCallExpr(
hasDeclaration(functionDecl(hasName("push_front"))),
- on(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushFront)))));
+ on(anyOf(hasType(cxxRecordDecl(hasAnyName(ContainersWithPushFront))),
+ hasType(hasCanonicalType(hasDeclaration(
+ namedDecl(hasAnyName(ContainersWithPushFront))))))));
auto CallEmplacy = cxxMemberCallExpr(
hasDeclaration(
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits