Do not crash if a CXXRecordDecl cannot be obtained for an object.
Special thanks for the reproduction to Alexander Kornienko.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@338918
91177308-0d34-0410-b5e6-
96231b3b80d8
return false;
CXXRecordDecl *Decl = ObjTy->getAsCXXRecordDecl();
- if (!Decl || Decl->getName() != "basic_string")
- return false;
-
- return true;
+ return Decl && Decl->getName() == "basic_string";
}
bool InnerPointerChecker::isInvalidatingMemberFunction(
// expected-note@-1 {{Inner pointer invalidated by call to destructor}}
} // expected-warning {{Use of memory after it is freed}}
// expected-note@-1 {{Use of memory after it is freed}}
+
+
+char *c();
+class A {};
+
+void no_CXXRecordDecl() {
+ A a, *b;
+ *(void **)&b = c() + 1;
+ *b = a; // no-crash
+}