File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 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,
18571857
18581858 if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
18591859 // 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);
18611862 continue ;
18621863 }
18631864
Original file line number Diff line number Diff line change @@ -78,6 +78,19 @@ int main() {
7878 }
7979}
8080
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+
8194TEST (FindRecordTypeAt, Method) {
8295 Annotations Source (R"cpp(
8396struct Child2 {
@@ -119,7 +132,7 @@ int main() {
119132
120133 for (Position Pt : Source.points ()) {
121134 // 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,
123136 // or the type of the record that the field is a member of).
124137 EXPECT_THAT (findRecordTypeAt (AST, Pt), SizeIs (0 ));
125138 }
You can’t perform that action at this time.
0 commit comments