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:
Mehdi Amini 2019-11-09 21:30:42 -08:00 committed by A. Unique TensorFlower
parent 1328f93e91
commit 85612fe6d1
6 changed files with 12 additions and 0 deletions

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}