diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-11-19 18:22:16 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-11-19 18:22:16 +0000 |
| commit | 73cb65f70411b4a1be862875eb24d6ae0a8b37a1 (patch) | |
| tree | 50ddf9f967e5d8af2c0d4562a19534bfb9837401 /llvm/utils | |
| parent | 0f32a4bc86309d9a04cc2eed753addb3f16767b1 (diff) | |
| download | bcm5719-llvm-73cb65f70411b4a1be862875eb24d6ae0a8b37a1.tar.gz bcm5719-llvm-73cb65f70411b4a1be862875eb24d6ae0a8b37a1.zip | |
TableGen/OptParser: When ordering options, make "sentinel" options appear before
everything else.
llvm-svn: 89368
Diffstat (limited to 'llvm/utils')
| -rw-r--r-- | llvm/utils/TableGen/OptParserEmitter.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/utils/TableGen/OptParserEmitter.cpp b/llvm/utils/TableGen/OptParserEmitter.cpp index a09ba083f3e..ce1aef5e4da 100644 --- a/llvm/utils/TableGen/OptParserEmitter.cpp +++ b/llvm/utils/TableGen/OptParserEmitter.cpp @@ -35,9 +35,16 @@ static int CompareOptionRecords(const void *Av, const void *Bv) { const Record *A = *(Record**) Av; const Record *B = *(Record**) Bv; - // Compare options by name first. - if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(), - B->getValueAsString("Name").c_str())) + // Sentinel options preceed all others and are only ordered by precedence. + bool ASent = A->getValueAsDef("Kind")->getValueAsBit("Sentinel"); + 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; // Then by the kind precedence; |

