From 9709e2b76d621f9ce2074ba07c453ce438ea8922 Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Thu, 13 Apr 2017 21:51:49 +0000 Subject: [PATCH] [Support] Fix ErrorOr assertion when /proc/cpuinfo doesn't exist. The ErrorOr should not be dereferenced on the error path. Patch by Jacob Young Reviewers: tejohnson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D32032 llvm-svn: 300267 --- llvm/lib/Support/Host.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/Support/Host.cpp b/llvm/lib/Support/Host.cpp index ec51314fcbe1..970ecfd7df90 100644 --- a/llvm/lib/Support/Host.cpp +++ b/llvm/lib/Support/Host.cpp @@ -1245,6 +1245,7 @@ static int computeHostNumPhysicalCores() { if (std::error_code EC = Text.getError()) { llvm::errs() << "Can't read " << "/proc/cpuinfo: " << EC.message() << "\n"; + return -1; } SmallVector strs; (*Text)->getBuffer().split(strs, "\n", /*MaxSplit=*/-1,