aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/ScriptParser.cpp
diff options
context:
space:
mode:
authorGeorge Rimar <grimar@accesssoftek.com>2017-05-16 08:19:25 +0000
committerGeorge Rimar <grimar@accesssoftek.com>2017-05-16 08:19:25 +0000
commitab94768cc1038d468cda84f0623839dcbcccb976 (patch)
tree95a42b494e54cef2776f40227c0dc39af29e7397 /lld/ELF/ScriptParser.cpp
parentb09b5db7939f28e956882336961005e842cd5137 (diff)
downloadllvm-ab94768cc1038d468cda84f0623839dcbcccb976.zip
llvm-ab94768cc1038d468cda84f0623839dcbcccb976.tar.gz
llvm-ab94768cc1038d468cda84f0623839dcbcccb976.tar.bz2
[ELF] - Use llvm::to_integer() instead of StringRef::getAsInteger().
Switch to llvm::to_integer() everywhere in LLD instead of StringRef::getAsInteger() because API of latter is confusing. It returns true on error and false otherwise what makes reading the code incomfortable. Differential revision: https://reviews.llvm.org/D33187 llvm-svn: 303149
Diffstat (limited to 'lld/ELF/ScriptParser.cpp')
-rw-r--r--lld/ELF/ScriptParser.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index ca4f4cd..f1bc245c 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -639,7 +639,7 @@ ScriptParser::readOutputSectionDescription(StringRef OutSec) {
// We are compatible with ld.gold because it's easier to implement.
uint32_t ScriptParser::parseFill(StringRef Tok) {
uint32_t V = 0;
- if (Tok.getAsInteger(0, V))
+ if (!to_integer(Tok, V))
setError("invalid filler expression: " + Tok);
uint32_t Buf;
@@ -778,23 +778,23 @@ static Optional<uint64_t> parseInt(StringRef Tok) {
// Hexadecimal
uint64_t Val;
- if (Tok.startswith_lower("0x") && !Tok.substr(2).getAsInteger(16, Val))
+ if (Tok.startswith_lower("0x") && to_integer(Tok.substr(2), Val, 16))
return Val;
- if (Tok.endswith_lower("H") && !Tok.drop_back().getAsInteger(16, Val))
+ if (Tok.endswith_lower("H") && to_integer(Tok.drop_back(), Val, 16))
return Val;
// Decimal
if (Tok.endswith_lower("K")) {
- if (Tok.drop_back().getAsInteger(10, Val))
+ if (!to_integer(Tok.drop_back(), Val, 10))
return None;
return Val * 1024;
}
if (Tok.endswith_lower("M")) {
- if (Tok.drop_back().getAsInteger(10, Val))
+ if (!to_integer(Tok.drop_back(), Val, 10))
return None;
return Val * 1024 * 1024;
}
- if (Tok.getAsInteger(10, Val))
+ if (!to_integer(Tok, Val, 10))
return None;
return Val;
}