Mercurial > projects > ldc
comparison gen/cl_helpers.cpp @ 1650:40bd4a0d4870
Update to work with LLVM 2.7.
Removed use of dyn_cast, llvm no compiles
without exceptions and rtti by
default. We do need exceptions for the libconfig stuff, but rtti isn't
necessary (anymore).
Debug info needs to be rewritten, as in LLVM 2.7 the format has
completely changed. To have something to look at while rewriting, the
old code has been wrapped inside #ifndef DISABLE_DEBUG_INFO , this means
that you have to define this to compile at the moment.
Updated tango 0.99.9 patch to include updated EH runtime code, which is
needed for LLVM 2.7 as well.
author | Tomas Lindquist Olsen |
---|---|
date | Wed, 19 May 2010 12:42:32 +0200 |
parents | b30fe7e1dbb9 |
children |
comparison
equal
deleted
inserted
replaced
1649:36da40ecbbe0 | 1650:40bd4a0d4870 |
---|---|
15 if (isupper(c)) | 15 if (isupper(c)) |
16 return tolower(c); | 16 return tolower(c); |
17 return c; | 17 return c; |
18 } | 18 } |
19 | 19 |
20 bool FlagParser::parse(cl::Option &O, const char *ArgName, const std::string &Arg, bool &Val) { | 20 bool FlagParser::parse(cl::Option &O, llvm::StringRef ArgName, llvm::StringRef Arg, bool &Val) { |
21 // Make a std::string out of it to make comparisons easier | 21 // Make a std::string out of it to make comparisons easier |
22 // (and avoid repeated conversion) | 22 // (and avoid repeated conversion) |
23 std::string argname = ArgName; | 23 llvm::StringRef argname = ArgName; |
24 | 24 |
25 typedef std::vector<std::pair<std::string, bool> >::iterator It; | 25 typedef std::vector<std::pair<std::string, bool> >::iterator It; |
26 for (It I = switches.begin(), E = switches.end(); I != E; ++I) { | 26 for (It I = switches.begin(), E = switches.end(); I != E; ++I) { |
27 std::string name = I->first; | 27 llvm::StringRef name = I->first; |
28 if (name == argname | 28 if (name == argname |
29 || (name.length() < argname.length() | 29 || (name.size() < argname.size() |
30 && argname.substr(0, name.length()) == name | 30 && argname.substr(0, name.size()) == name |
31 && argname[name.length()] == '=')) { | 31 && argname[name.size()] == '=')) { |
32 | 32 |
33 if (!cl::parser<bool>::parse(O, ArgName, Arg, Val)) { | 33 if (!cl::parser<bool>::parse(O, ArgName, Arg, Val)) { |
34 Val = (Val == I->second); | 34 Val = (Val == I->second); |
35 return false; | 35 return false; |
36 } | 36 } |
37 // Invalid option value | 37 // Invalid option value |
39 } | 39 } |
40 } | 40 } |
41 return true; | 41 return true; |
42 } | 42 } |
43 | 43 |
44 void FlagParser::getExtraOptionNames(std::vector<const char*> &Names) { | 44 void FlagParser::getExtraOptionNames(llvm::SmallVectorImpl<const char*> &Names) { |
45 typedef std::vector<std::pair<std::string, bool> >::iterator It; | 45 typedef std::vector<std::pair<std::string, bool> >::iterator It; |
46 for (It I = switches.begin() + 1, E = switches.end(); I != E; ++I) { | 46 for (It I = switches.begin() + 1, E = switches.end(); I != E; ++I) { |
47 Names.push_back(I->first.c_str()); | 47 Names.push_back(I->first.data()); |
48 } | 48 } |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 MultiSetter::MultiSetter(bool invert, bool* p, ...) { | 52 MultiSetter::MultiSetter(bool invert, bool* p, ...) { |
58 while (p = va_arg(va, bool*)) { | 58 while (p = va_arg(va, bool*)) { |
59 locations.push_back(p); | 59 locations.push_back(p); |
60 } | 60 } |
61 } | 61 } |
62 } | 62 } |
63 | 63 |
64 void MultiSetter::operator=(bool val) { | 64 void MultiSetter::operator=(bool val) { |
65 typedef std::vector<bool*>::iterator It; | 65 typedef std::vector<bool*>::iterator It; |
66 for (It I = locations.begin(), E = locations.end(); I != E; ++I) { | 66 for (It I = locations.begin(), E = locations.end(); I != E; ++I) { |
67 **I = (val != invert); | 67 **I = (val != invert); |
68 } | 68 } |
70 | 70 |
71 | 71 |
72 void ArrayAdapter::push_back(const char* cstr) { | 72 void ArrayAdapter::push_back(const char* cstr) { |
73 if (!cstr || !*cstr) | 73 if (!cstr || !*cstr) |
74 error("Expected argument to '-%s'", name); | 74 error("Expected argument to '-%s'", name); |
75 | 75 |
76 if (!*arrp) | 76 if (!*arrp) |
77 *arrp = new Array; | 77 *arrp = new Array; |
78 (*arrp)->push(mem.strdup(cstr)); | 78 (*arrp)->push(mem.strdup(cstr)); |
79 } | 79 } |
80 | 80 |