]> granicus.if.org Git - llvm/commitdiff
[Support] Fix ErrorOr assertion when /proc/cpuinfo doesn't exist.
authorTeresa Johnson <tejohnson@google.com>
Thu, 13 Apr 2017 21:51:49 +0000 (21:51 +0000)
committerTeresa Johnson <tejohnson@google.com>
Thu, 13 Apr 2017 21:51:49 +0000 (21:51 +0000)
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

lib/Support/Host.cpp

index ec51314fcbe1d3d47634db3ab584c4c2a813cad5..970ecfd7df90bc7948c2696d15c0c7ce9cf370d4 100644 (file)
@@ -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<StringRef, 8> strs;
   (*Text)->getBuffer().split(strs, "\n", /*MaxSplit=*/-1,