File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,10 @@ AST_MATCHER(CXXRecordDecl, isPairType) {
184
184
});
185
185
}
186
186
187
+ AST_MATCHER (VarDecl, isDirectInitialization) {
188
+ return Node.getInitStyle () != VarDecl::InitializationStyle::CInit;
189
+ }
190
+
187
191
} // namespace
188
192
189
193
static auto getVarInitWithMemberMatcher (
@@ -267,7 +271,7 @@ void UseStructuredBindingCheck::registerMatchers(MatchFinder *Finder) {
267
271
declStmt (
268
272
unless (isInMarco ()),
269
273
hasSingleDecl (
270
- varDecl (UnlessShouldBeIgnored,
274
+ varDecl (UnlessShouldBeIgnored, unless ( isDirectInitialization ()),
271
275
hasType (qualType (anyOf (PairType, lValueReferenceType (
272
276
pointee (PairType))))
273
277
.bind (PairVarTypeName)),
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ namespace std {
3
3
struct pair {
4
4
T1 first;
5
5
T2 second;
6
+
7
+ pair () = default ;
8
+ pair (T1 first, T2 second) : first(first), second(second) {}
6
9
};
7
10
8
11
template <typename ... Args>
Original file line number Diff line number Diff line change @@ -600,3 +600,23 @@ void StaticFieldPairTests() {
600
600
int y = P.second ;
601
601
}
602
602
}
603
+
604
+ void IgnoreDirectInit () {
605
+ {
606
+ std::pair<int , int > P{1 , 1 };
607
+ int x = P.first ;
608
+ int y = P.second ;
609
+ }
610
+
611
+ {
612
+ std::pair<int , int > P (1 , 1 );
613
+ int x = P.first ;
614
+ int y = P.second ;
615
+ }
616
+
617
+ {
618
+ std::pair<int , int > P;
619
+ int x = P.first ;
620
+ int y = P.second ;
621
+ }
622
+ }
You can’t perform that action at this time.
0 commit comments