From 3601d1b3cf9485ac04f8107fa8e525d8866b6f3d Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 11 Jan 2010 18:03:24 +0000 Subject: 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@93161 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/Module.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'lib/VMCore/Module.cpp') diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 03b1252..510f3d5 100644 --- a/lib/VMCore/Module.cpp +++ b/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) -- cgit v1.1