summaryrefslogtreecommitdiff
path: root/utils/TableGen/OptParserEmitter.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-19 18:22:16 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-19 18:22:16 +0000
commita627ef57ec0a0652bd5922fb86568b43f94d9361 (patch)
treec2a819507f61119a13346a67dfa2631eb26e84de /utils/TableGen/OptParserEmitter.cpp
parenteeebecfcb4156319899c8dc63cd28c05f313538b (diff)
downloadllvm-a627ef57ec0a0652bd5922fb86568b43f94d9361.tar.gz
llvm-a627ef57ec0a0652bd5922fb86568b43f94d9361.tar.bz2
llvm-a627ef57ec0a0652bd5922fb86568b43f94d9361.tar.xz
TableGen/OptParser: When ordering options, make "sentinel" options appear before
everything else. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/OptParserEmitter.cpp')
-rw-r--r--utils/TableGen/OptParserEmitter.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/utils/TableGen/OptParserEmitter.cpp b/utils/TableGen/OptParserEmitter.cpp
index a09ba083f3..ce1aef5e4d 100644
--- a/utils/TableGen/OptParserEmitter.cpp
+++ b/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;