[llvm] r300267 - [Support] Fix ErrorOr assertion when /proc/cpuinfo doesn't exist.

Teresa Johnson via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 13 14:51:50 PDT 2017


Author: tejohnson
Date: Thu Apr 13 16:51:49 2017
New Revision: 300267

URL: http://llvm.org/viewvc/llvm-project?rev=300267&view=rev
Log:
[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

Modified:
    llvm/trunk/lib/Support/Host.cpp

Modified: llvm/trunk/lib/Support/Host.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=300267&r1=300266&r2=300267&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Host.cpp (original)
+++ llvm/trunk/lib/Support/Host.cpp Thu Apr 13 16:51:49 2017
@@ -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,




More information about the llvm-commits mailing list