Skip to content

Commit

Permalink
Remove a call to std::exit in a library. Make "Help" return
Browse files Browse the repository at this point in the history
a 0 as a default answer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208009 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
echristo committed May 5, 2014
1 parent 32b6099 commit 9edfca8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/MC/SubtargetFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,9 @@ static size_t getLongestEntryLength(const SubtargetFeatureKV *Table,

/// Display help for feature choices.
///
static void Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize,
const SubtargetFeatureKV *FeatTable, size_t FeatTableSize) {
static uint64_t Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize,
const SubtargetFeatureKV *FeatTable,
size_t FeatTableSize) {
// Determine the length of the longest CPU and Feature entries.
unsigned MaxCPULen = getLongestEntryLength(CPUTable, CPUTableSize);
unsigned MaxFeatLen = getLongestEntryLength(FeatTable, FeatTableSize);
Expand All @@ -164,7 +165,8 @@ static void Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize,

errs() << "Use +feature to enable a feature, or -feature to disable it.\n"
"For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
std::exit(1);

return 0;
}

//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -275,7 +277,7 @@ uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,

// Check if help is needed
if (CPU == "help")
Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
return Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);

// Find CPU entry if CPU name is specified.
if (!CPU.empty()) {
Expand Down Expand Up @@ -304,7 +306,7 @@ uint64_t SubtargetFeatures::getFeatureBits(const StringRef CPU,

// Check for help
if (Feature == "+help")
Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
return Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);

// Find feature in table.
const SubtargetFeatureKV *FeatureEntry =
Expand Down

0 comments on commit 9edfca8

Please sign in to comment.