The pointer is always dereferenced immediately below, so assert the cast is correct instead of returning nullptr
void CSProfileGenerator::generateLineNumBasedProfile() {
for (const auto &CI : SampleCounters) {
- const StringBasedCtxKey *CtxKey =
- dyn_cast<StringBasedCtxKey>(CI.first.getPtr());
+ const auto *CtxKey = cast<StringBasedCtxKey>(CI.first.getPtr());
+
// Get or create function profile for the range
FunctionSamples &FunctionProfile =
getFunctionProfileForContext(CtxKey->Context, CtxKey->WasLeafInlined);