forked from OSchip/llvm-project
Fix segfault (nullptr dereference) when passing a non-existent file to the Toy tutorial compiler
Fix tensorflow/mlir#229 PiperOrigin-RevId: 279557863
This commit is contained in:
parent
1328f93e91
commit
85612fe6d1
|
@ -85,6 +85,8 @@ int dumpMLIR() {
|
|||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
mlir::OwningModuleRef module = mlirGen(context, *moduleAST);
|
||||
if (!module)
|
||||
return 1;
|
||||
|
|
|
@ -85,6 +85,8 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
|||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
module = mlirGen(context, *moduleAST);
|
||||
return !module ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,8 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
|||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
module = mlirGen(context, *moduleAST);
|
||||
return !module ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -88,6 +88,8 @@ int loadMLIR(llvm::SourceMgr &sourceMgr, mlir::MLIRContext &context,
|
|||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
module = mlirGen(context, *moduleAST);
|
||||
return !module ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,8 @@ int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
|||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
module = mlirGen(context, *moduleAST);
|
||||
return !module ? 1 : 0;
|
||||
}
|
||||
|
|
|
@ -106,6 +106,8 @@ int loadMLIR(mlir::MLIRContext &context, mlir::OwningModuleRef &module) {
|
|||
if (inputType != InputType::MLIR &&
|
||||
!llvm::StringRef(inputFilename).endswith(".mlir")) {
|
||||
auto moduleAST = parseInputFile(inputFilename);
|
||||
if (!moduleAST)
|
||||
return 6;
|
||||
module = mlirGen(context, *moduleAST);
|
||||
return !module ? 1 : 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue