File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1857,7 +1857,8 @@ std::vector<const CXXRecordDecl *> findRecordTypeAt(ParsedAST &AST,
1857
1857
1858
1858
if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1859
1859
// If this is a variable, use the type of the variable.
1860
- Records.push_back (VD->getType ().getTypePtr ()->getAsCXXRecordDecl ());
1860
+ if (const auto *RD = VD->getType ().getTypePtr ()->getAsCXXRecordDecl ())
1861
+ Records.push_back (RD);
1861
1862
continue ;
1862
1863
}
1863
1864
Original file line number Diff line number Diff line change @@ -78,6 +78,19 @@ int main() {
78
78
}
79
79
}
80
80
81
+ TEST (FindRecordTypeAt, Nonexistent) {
82
+ Annotations Source (R"cpp(
83
+ int *wa^ldo;
84
+ )cpp" );
85
+ TestTU TU = TestTU::withCode (Source.code ());
86
+ auto AST = TU.build ();
87
+
88
+ for (Position Pt : Source.points ()) {
89
+ auto Records = findRecordTypeAt (AST, Pt);
90
+ ASSERT_THAT (Records, SizeIs (0 ));
91
+ }
92
+ }
93
+
81
94
TEST (FindRecordTypeAt, Method) {
82
95
Annotations Source (R"cpp(
83
96
struct Child2 {
@@ -119,7 +132,7 @@ int main() {
119
132
120
133
for (Position Pt : Source.points ()) {
121
134
// A field does not unambiguously specify a record type
122
- // (possible associated reocrd types could be the field's type,
135
+ // (possible associated record types could be the field's type,
123
136
// or the type of the record that the field is a member of).
124
137
EXPECT_THAT (findRecordTypeAt (AST, Pt), SizeIs (0 ));
125
138
}
You can’t perform that action at this time.
0 commit comments