You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[analyzer] Use dynamic type when invalidating by a member function call (#111138)
When instantiating "callable<T>", the "class CallableType" nested type
will only have a declaration in the copy for the instantiation - because
it's not refereed to directly by any other code that would need a
complete definition.
However, in the past, when conservative eval calling member function, we
took the static type of the "this" expr, and looked up the CXXRecordDecl
it refereed to to see if it has any mutable members (to decide if it
needs to refine invalidation or not). Unfortunately, that query needs a
definition, and it asserts otherwise, thus we crashed.
To fix this, we should consult the dynamic type of the object, because
that will have the definition.
I anyways added a check for "hasDefinition" just to be on the safe side.
Fixes#77378
// This should not crash when conservative eval calling the member function
303
+
// when it unwinds the call stack due to exhausting the budget or reaching
304
+
// the inlining limit.
305
+
if (this->const_method()) {
306
+
break;
307
+
}
308
+
}
309
+
returntrue;
310
+
};
311
+
return L;
312
+
}
313
+
};
314
+
315
+
voidentry() {
316
+
callable<bool()>{}.call().const_method();
317
+
// expected-warning@-1 {{Address of stack memory associated with temporary object of type 'callable<bool ()>' is still referred to by the static variable 'L' upon returning to the caller. This will be a dangling reference}}
0 commit comments