1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

TableGen/OptParser: When ordering options, make "sentinel" options appear before

everything else.

llvm-svn: 89368
This commit is contained in:
Daniel Dunbar 2009-11-19 18:22:16 +00:00
parent 55f7bd16f2
commit d03317047d

View File

@ -35,9 +35,16 @@ static int CompareOptionRecords(const void *Av, const void *Bv) {
const Record *A = *(Record**) Av; const Record *A = *(Record**) Av;
const Record *B = *(Record**) Bv; const Record *B = *(Record**) Bv;
// Compare options by name first. // Sentinel options preceed all others and are only ordered by precedence.
if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(), bool ASent = A->getValueAsDef("Kind")->getValueAsBit("Sentinel");
B->getValueAsString("Name").c_str())) bool BSent = B->getValueAsDef("Kind")->getValueAsBit("Sentinel");
if (ASent != BSent)
return ASent ? -1 : 1;
// Compare options by name, unless they are sentinels.
if (!ASent)
if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(),
B->getValueAsString("Name").c_str()))
return Cmp; return Cmp;
// Then by the kind precedence; // Then by the kind precedence;