From: Teresa Johnson Date: Thu, 13 Apr 2017 21:51:49 +0000 (+0000) Subject: [Support] Fix ErrorOr assertion when /proc/cpuinfo doesn't exist. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6ac17df7d796c3cefd7e6eefa38221768fbcf43f;p=llvm [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300267 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp index ec51314fcbe..970ecfd7df9 100644 --- a/lib/Support/Host.cpp +++ b/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,