X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=utils%2FTableGen%2FOptParserEmitter.cpp;h=9c4daaf7747dbed13c427dbfec7a1c46d767e778;hb=087ab613f42890b2e84fb8a058f346ead2bfd595;hp=d37939f635dfb527d1811fb96e1211467a0f12fd;hpb=9dd8c0cffe7de82900823c05159bba765120f1e3;p=oota-llvm.git diff --git a/utils/TableGen/OptParserEmitter.cpp b/utils/TableGen/OptParserEmitter.cpp index d37939f635d..9c4daaf7747 100644 --- a/utils/TableGen/OptParserEmitter.cpp +++ b/utils/TableGen/OptParserEmitter.cpp @@ -13,18 +13,23 @@ #include "llvm/ADT/Twine.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" +#include +#include #include using namespace llvm; +// Ordering on Info. The logic should match with the consumer-side function in +// llvm/Option/OptTable.h. static int StrCmpOptionName(const char *A, const char *B) { - char a = *A, b = *B; + const char *X = A, *Y = B; + char a = tolower(*A), b = tolower(*B); while (a == b) { if (a == '\0') - return 0; + return strcmp(A, B); - a = *++A; - b = *++B; + a = tolower(*++X); + b = tolower(*++Y); } if (a == '\0') // A is a prefix of B. @@ -36,9 +41,9 @@ static int StrCmpOptionName(const char *A, const char *B) { return (a < b) ? -1 : 1; } -static int CompareOptionRecords(const void *Av, const void *Bv) { - const Record *A = *(const Record*const*) Av; - const Record *B = *(const Record*const*) Bv; +static int CompareOptionRecords(Record *const *Av, Record *const *Bv) { + const Record *A = *Av; + const Record *B = *Bv; // Sentinel options precede all others and are only ordered by precedence. bool ASent = A->getValueAsDef("Kind")->getValueAsBit("Sentinel"); @@ -50,7 +55,7 @@ static int CompareOptionRecords(const void *Av, const void *Bv) { if (!ASent) if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(), B->getValueAsString("Name").c_str())) - return Cmp; + return Cmp; if (!ASent) { std::vector APrefixes = A->getValueAsListOfStrings("Prefixes"); @@ -74,7 +79,7 @@ static int CompareOptionRecords(const void *Av, const void *Bv) { if (APrec == BPrec && A->getValueAsListOfStrings("Prefixes") == B->getValueAsListOfStrings("Prefixes")) { - PrintError(A->getLoc(), Twine("Option is equivilent to")); + PrintError(A->getLoc(), Twine("Option is equivalent to")); PrintError(B->getLoc(), Twine("Other defined here")); PrintFatalError("Equivalent Options found."); } @@ -152,22 +157,11 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) { OS << "/////////\n"; OS << "// Groups\n\n"; OS << "#ifdef OPTION\n"; - - // FIXME: Remove when option parsing clients are updated. - OS << "#ifdef SUPPORT_ALIASARGS\n"; - OS << "#define OPTIONX OPTION\n"; - OS << "#else\n"; - OS << "#define OPTIONX(prefix, name, id, kind, group, alias, aliasargs, " - << "flags, param, helptext, metavar) " - << "OPTION(prefix, name, id, kind, " - << "group, alias, flags, param, helptext, metavar)\n"; - OS << "#endif\n"; - for (unsigned i = 0, e = Groups.size(); i != e; ++i) { const Record &R = *Groups[i]; // Start a single option entry. - OS << "OPTIONX("; + OS << "OPTION("; // The option prefix; OS << "0"; @@ -210,7 +204,7 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) { const Record &R = *Opts[i]; // Start a single option entry. - OS << "OPTIONX("; + OS << "OPTION("; // The option prefix; std::vector prf = R.getValueAsListOfStrings("Prefixes"); @@ -287,7 +281,6 @@ void EmitOptParser(RecordKeeper &Records, raw_ostream &OS) { OS << ")\n"; } - OS << "#undef OPTIONX\n"; // FIXME: Remove when option clients are updated. OS << "#endif\n"; } } // end namespace llvm