[spirv] Require source location for createReturnValue.
This commit is contained in:
Родитель
58464191cc
Коммит
13dd1b3377
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче