diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-01-11 18:03:24 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-01-11 18:03:24 +0000 |
| commit | c6fe3c3273f46fff995c344e728aea761ec13d4a (patch) | |
| tree | b497ad63f40b50e7cc6d2e1728db90050533d343 /llvm/lib/VMCore | |
| parent | e99a3c191e28c66dc00677d02b3090481865a6e9 (diff) | |
| download | bcm5719-llvm-c6fe3c3273f46fff995c344e728aea761ec13d4a.tar.gz bcm5719-llvm-c6fe3c3273f46fff995c344e728aea761ec13d4a.zip | |
Reimplement getToken and SplitString as "StringRef helper functions"
- getToken is modeled after StringRef::split but it can split on multiple
separator chars and skips leading seperators.
- SplitString is a StringRef::split variant for more than 2 elements with the
same behaviour as getToken.
llvm-svn: 93161
Diffstat (limited to 'llvm/lib/VMCore')
| -rw-r--r-- | llvm/lib/VMCore/Module.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/VMCore/Module.cpp b/llvm/lib/VMCore/Module.cpp index 03b12528491..510f3d5bd77 100644 --- a/llvm/lib/VMCore/Module.cpp +++ b/llvm/lib/VMCore/Module.cpp @@ -76,11 +76,12 @@ Module::~Module() { /// Target endian information... Module::Endianness Module::getEndianness() const { - std::string temp = DataLayout; + StringRef temp = DataLayout; Module::Endianness ret = AnyEndianness; while (!temp.empty()) { - std::string token = getToken(temp, "-"); + StringRef token = DataLayout; + tie(token, temp) = getToken(DataLayout, "-"); if (token[0] == 'e') { ret = LittleEndian; @@ -94,15 +95,17 @@ Module::Endianness Module::getEndianness() const { /// Target Pointer Size information... Module::PointerSize Module::getPointerSize() const { - std::string temp = DataLayout; + StringRef temp = DataLayout; Module::PointerSize ret = AnyPointerSize; while (!temp.empty()) { - std::string token = getToken(temp, "-"); - char signal = getToken(token, ":")[0]; + StringRef token, signalToken; + tie(token, temp) = getToken(temp, "-"); + tie(signalToken, token) = getToken(token, ":"); - if (signal == 'p') { - int size = atoi(getToken(token, ":").c_str()); + if (signalToken[0] == 'p') { + int size = 0; + getToken(token, ":").first.getAsInteger(10, size); if (size == 32) ret = Pointer32; else if (size == 64) |

