[lld] r199019 - [PECOFF] Add a helper function to read an integer from .def file.
Rui Ueyama
ruiu at google.com
Sat Jan 11 13:37:26 PST 2014
Author: ruiu
Date: Sat Jan 11 15:37:25 2014
New Revision: 199019
URL: http://llvm.org/viewvc/llvm-project?rev=199019&view=rev
Log:
[PECOFF] Add a helper function to read an integer from .def file.
Modified:
lld/trunk/include/lld/Driver/WinLinkModuleDef.h
lld/trunk/lib/Driver/WinLinkModuleDef.cpp
Modified: lld/trunk/include/lld/Driver/WinLinkModuleDef.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/WinLinkModuleDef.h?rev=199019&r1=199018&r2=199019&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/WinLinkModuleDef.h (original)
+++ lld/trunk/include/lld/Driver/WinLinkModuleDef.h Sat Jan 11 15:37:25 2014
@@ -115,6 +115,7 @@ public:
private:
void consumeToken();
+ bool consumeTokenAsInt(uint64_t &result);
void ungetToken();
void error(const Token &tok, Twine msg);
Modified: lld/trunk/lib/Driver/WinLinkModuleDef.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkModuleDef.cpp?rev=199019&r1=199018&r2=199019&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkModuleDef.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkModuleDef.cpp Sat Jan 11 15:37:25 2014
@@ -68,6 +68,20 @@ void Parser::consumeToken() {
_tokBuf.pop_back();
}
+bool Parser::consumeTokenAsInt(uint64_t &result) {
+ consumeToken();
+ if (_tok._kind != Kind::identifier) {
+ ungetToken();
+ error(_tok, "Integer expected");
+ return false;
+ }
+ if (_tok._range.getAsInteger(10, result)) {
+ error(_tok, "Integer expected");
+ return false;
+ }
+ return true;
+}
+
void Parser::ungetToken() { _tokBuf.push_back(_tok); }
void Parser::error(const Token &tok, Twine msg) {
@@ -128,12 +142,7 @@ bool Parser::parseExport(PECOFFLinkingCo
}
bool Parser::parseHeapsize(uint64_t &reserve, uint64_t &commit) {
- consumeToken();
- if (_tok._kind != Kind::identifier) {
- ungetToken();
- return false;
- }
- if (_tok._range.getAsInteger(0, reserve))
+ if (!consumeTokenAsInt(reserve))
return false;
consumeToken();
@@ -142,12 +151,8 @@ bool Parser::parseHeapsize(uint64_t &res
commit = 0;
return true;
}
- consumeToken();
- if (_tok._kind != Kind::identifier) {
- ungetToken();
- return false;
- }
- if (_tok._range.getAsInteger(0, commit))
+
+ if (!consumeTokenAsInt(commit))
return false;
return true;
}
More information about the llvm-commits
mailing list