Fix an ASAN detected bug introduced by cr/227067644. While MLFunctions always

have one block, CFG Functions don't necessarily have one (e.g. when they are
being first constructed by the parser).

PiperOrigin-RevId: 227075636
This commit is contained in:
Chris Lattner 2018-12-27 16:38:33 -08:00 committed by jpienaar
parent 1b430f1d32
commit bd24a131d3
1 changed files with 5 additions and 2 deletions

View File

@ -163,10 +163,13 @@ protected:
/// automatically inserted at an insertion point. The builder is copyable.
class FuncBuilder : public Builder {
public:
/// Create an ML function builder and set the insertion point to the start of
/// Create a function builder and set the insertion point to the start of
/// the function.
FuncBuilder(Function *func) : Builder(func->getContext()), function(func) {
if (!func->empty())
setInsertionPoint(&func->front(), func->front().begin());
else
clearInsertionPoint();
}
/// Create a function builder and set insertion point to the given statement,