This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog
ClosedPublic

Authored by ahatanak on Feb 4 2016, 6:54 PM.

Details

Summary

The assert near CGCall.cpp:2465 is triggered because QualType::isObjCRetainableType() is called on different types. In CodeGenFunction::StartFunction, it returns true because it is called on the typedef marked with attribute((NSObject)), whereas in CodeGenFunction::EmitFunctionEpilog it returns false because it's called on the canonical type.

To fix the assert, this patch changes the code in CodeGenFunction::EmitFunctionEpilog to get the function's return type from CodeGenFunction::CurCodeDecl or BlockInfo instead of from CGFunctionInfo.

Diff Detail

Event Timeline

ahatanak updated this revision to Diff 46990.Feb 4 2016, 6:54 PM
ahatanak retitled this revision from to [CodeGen] Fix an assert in CodeGenFunction::EmitFunctionEpilog.
ahatanak updated this object.
ahatanak added a subscriber: cfe-commits.
ahatanak updated this revision to Diff 47062.Feb 5 2016, 4:09 PM
ahatanak added a reviewer: rjmccall.

Enclose the code with "#ifndef NDEBUG".

manmanren edited edge metadata.Feb 17 2016, 12:00 PM

LGTM otherwise.

Cheers,
Manman

lib/CodeGen/CGCall.cpp
2468

Maybe add comments here on the if else block?

This revision was automatically updated to reflect the committed changes.