Skip to content

Commit 45453b1

Browse files
committed
Simplify return and break cmd
1 parent ad50d49 commit 45453b1

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

mlir/lib/Target/SPIRV/TranslateRegistration.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,22 +97,19 @@ serializeModule(spirv::ModuleOp moduleOp, raw_ostream &output,
9797
if (dirSeparator != std::string::npos) {
9898
llvm::StringRef parentDir =
9999
llvm::sys::path::parent_path(options.validationFilePrefix);
100-
if (!llvm::sys::fs::is_directory(parentDir)) {
101-
moduleOp.emitError("validation prefix directory does not exist\n");
102-
return failure();
103-
}
100+
if (!llvm::sys::fs::is_directory(parentDir))
101+
return moduleOp.emitError(
102+
"validation prefix directory does not exist\n");
104103
}
105104

106105
SmallString<128> filename;
107106
int fd = 0;
108107

109108
std::error_code errorCode = llvm::sys::fs::createUniqueFile(
110109
options.validationFilePrefix + "%%%%%%", fd, filename);
111-
if (errorCode) {
112-
moduleOp.emitError("error creating validation output file: ")
113-
<< errorCode.message() << "\n";
114-
return failure();
115-
}
110+
if (errorCode)
111+
return moduleOp.emitError("error creating validation output file: ")
112+
<< errorCode.message() << "\n";
116113

117114
llvm::raw_fd_ostream validationOutput(fd, /*shouldClose=*/true);
118115
validationOutput.write(reinterpret_cast<char *>(binary.data()),

mlir/test/Target/SPIRV/mlir-translate.mlir

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
// REQUIRES: shell
55
// RUN: rm -rf %t
6-
// RUN: mkdir %t && mlir-translate --serialize-spirv --no-implicit-module --split-input-file --spirv-save-validation-files-with-prefix=%t/foo %s && ls %t | wc -l | FileCheck %s
6+
// RUN: mkdir %t && mlir-translate --serialize-spirv --no-implicit-module \
7+
// RUN: --split-input-file --spirv-save-validation-files-with-prefix=%t/foo %s \
8+
// RUN: && ls %t | wc -l | FileCheck %s
79
// RUN: rm -rf %t
810

911
// CHECK: 4

0 commit comments

Comments
 (0)