[spirv] Require source location for createReturnValue.

This commit is contained in:
Ehsan Nasiri 2019-03-14 10:50:47 -04:00 коммит произвёл Ehsan
Родитель 58464191cc
Коммит 13dd1b3377
2 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -371,7 +371,7 @@ public:
/// \brief Creates a return instruction.
void createReturn(SourceLocation loc = {});
/// \brief Creates a return value instruction.
void createReturnValue(SpirvInstruction *value, SourceLocation loc = {});
void createReturnValue(SpirvInstruction *value, SourceLocation);
/// \brief Creates an OpExtInst instruction with the given instruction set,
/// instruction number, and operands. Returns the resulting instruction

Просмотреть файл

@ -1059,6 +1059,7 @@ void SpirvEmitter::doFunctionDecl(const FunctionDecl *decl) {
// basic block. Make sure we have a termination instruction.
if (!spvBuilder.isCurrentBasicBlockTerminated()) {
const auto retType = decl->getReturnType();
const auto returnLoc = decl->getBody()->getLocEnd();
if (retType->isVoidType()) {
spvBuilder.createReturn();
@ -1066,7 +1067,8 @@ void SpirvEmitter::doFunctionDecl(const FunctionDecl *decl) {
// If the source code does not provide a proper return value for some
// control flow path, it's undefined behavior. We just return null
// value here.
spvBuilder.createReturnValue(spvBuilder.getConstantNull(retType));
spvBuilder.createReturnValue(spvBuilder.getConstantNull(retType),
returnLoc);
}
}
}