[lld] r206831 - [PECOFF] Handle line comment in module-definition file.
Rui Ueyama
ruiu at google.com
Mon Apr 21 17:11:52 PDT 2014
Author: ruiu
Date: Mon Apr 21 19:11:52 2014
New Revision: 206831
URL: http://llvm.org/viewvc/llvm-project?rev=206831&view=rev
Log:
[PECOFF] Handle line comment in module-definition file.
In .def files, ';' is the start of line comment.
Modified:
lld/trunk/lib/Driver/WinLinkModuleDef.cpp
lld/trunk/test/pecoff/Inputs/exports.def
Modified: lld/trunk/lib/Driver/WinLinkModuleDef.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkModuleDef.cpp?rev=206831&r1=206830&r2=206831&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkModuleDef.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkModuleDef.cpp Mon Apr 21 19:11:52 2014
@@ -19,48 +19,55 @@ namespace lld {
namespace moduledef {
Token Lexer::lex() {
- _buffer = _buffer.trim();
- if (_buffer.empty() || _buffer[0] == '\0')
- return Token(Kind::eof, _buffer);
+ for (;;) {
+ _buffer = _buffer.trim();
+ if (_buffer.empty() || _buffer[0] == '\0')
+ return Token(Kind::eof, _buffer);
- switch (_buffer[0]) {
- case '=':
- _buffer = _buffer.drop_front();
- return Token(Kind::equal, "=");
- case ',':
- _buffer = _buffer.drop_front();
- return Token(Kind::comma, ",");
- case '"': {
- size_t end = _buffer.find('"', 1);
- Token ret;
- if (end == _buffer.npos) {
- ret = Token(Kind::identifier, _buffer.substr(1, end));
- _buffer = "";
- } else {
- ret = Token(Kind::identifier, _buffer.substr(1, end - 1));
- _buffer = _buffer.drop_front(end);
+ switch (_buffer[0]) {
+ case ';': {
+ size_t end = _buffer.find('\n');
+ _buffer = (end == _buffer.npos) ? "" : _buffer.drop_front(end);
+ continue;
+ }
+ case '=':
+ _buffer = _buffer.drop_front();
+ return Token(Kind::equal, "=");
+ case ',':
+ _buffer = _buffer.drop_front();
+ return Token(Kind::comma, ",");
+ case '"': {
+ size_t end = _buffer.find('"', 1);
+ Token ret;
+ if (end == _buffer.npos) {
+ ret = Token(Kind::identifier, _buffer.substr(1, end));
+ _buffer = "";
+ } else {
+ ret = Token(Kind::identifier, _buffer.substr(1, end - 1));
+ _buffer = _buffer.drop_front(end);
+ }
+ return ret;
+ }
+ default: {
+ size_t end = _buffer.find_first_not_of(
+ "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789_.*~+!@#$%^&*()/");
+ StringRef word = _buffer.substr(0, end);
+ Kind kind = llvm::StringSwitch<Kind>(word)
+ .Case("BASE", Kind::kw_base)
+ .Case("DATA", Kind::kw_data)
+ .Case("EXPORTS", Kind::kw_exports)
+ .Case("HEAPSIZE", Kind::kw_heapsize)
+ .Case("LIBRARY", Kind::kw_library)
+ .Case("NAME", Kind::kw_name)
+ .Case("NONAME", Kind::kw_noname)
+ .Case("STACKSIZE", Kind::kw_stacksize)
+ .Case("VERSION", Kind::kw_version)
+ .Default(Kind::identifier);
+ _buffer = (end == _buffer.npos) ? "" : _buffer.drop_front(end);
+ return Token(kind, word);
+ }
}
- return ret;
- }
- default: {
- size_t end = _buffer.find_first_not_of(
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789_.*~+!@#$%^&*()/");
- StringRef word = _buffer.substr(0, end);
- Kind kind = llvm::StringSwitch<Kind>(word)
- .Case("BASE", Kind::kw_base)
- .Case("DATA", Kind::kw_data)
- .Case("EXPORTS", Kind::kw_exports)
- .Case("HEAPSIZE", Kind::kw_heapsize)
- .Case("LIBRARY", Kind::kw_library)
- .Case("NAME", Kind::kw_name)
- .Case("NONAME", Kind::kw_noname)
- .Case("STACKSIZE", Kind::kw_stacksize)
- .Case("VERSION", Kind::kw_version)
- .Default(Kind::identifier);
- _buffer = (end == _buffer.npos) ? "" : _buffer.drop_front(end);
- return Token(kind, word);
- }
}
}
Modified: lld/trunk/test/pecoff/Inputs/exports.def
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/pecoff/Inputs/exports.def?rev=206831&r1=206830&r2=206831&view=diff
==============================================================================
--- lld/trunk/test/pecoff/Inputs/exports.def (original)
+++ lld/trunk/test/pecoff/Inputs/exports.def Mon Apr 21 19:11:52 2014
@@ -1,3 +1,5 @@
+; This is a comment line
+
EXPORTS
- exportfn1 @5
+ exportfn1 @5 ; foo
exportfn2
More information about the llvm-commits
mailing list