[lld] r206638 - Use switch for readability.
Rui Ueyama
ruiu at google.com
Fri Apr 18 12:59:33 PDT 2014
Author: ruiu
Date: Fri Apr 18 14:59:33 2014
New Revision: 206638
URL: http://llvm.org/viewvc/llvm-project?rev=206638&view=rev
Log:
Use switch for readability.
Modified:
lld/trunk/lib/Driver/WinLinkModuleDef.cpp
Modified: lld/trunk/lib/Driver/WinLinkModuleDef.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkModuleDef.cpp?rev=206638&r1=206637&r2=206638&view=diff
==============================================================================
--- lld/trunk/lib/Driver/WinLinkModuleDef.cpp (original)
+++ lld/trunk/lib/Driver/WinLinkModuleDef.cpp Fri Apr 18 14:59:33 2014
@@ -105,8 +105,9 @@ void Parser::error(const Token &tok, Twi
llvm::Optional<Directive *> Parser::parse() {
consumeToken();
- // EXPORTS
- if (_tok._kind == Kind::kw_exports) {
+ switch (_tok._kind) {
+ case Kind::kw_exports: {
+ // EXPORTS
std::vector<PECOFFLinkingContext::ExportDesc> exports;
for (;;) {
PECOFFLinkingContext::ExportDesc desc;
@@ -116,37 +117,39 @@ llvm::Optional<Directive *> Parser::pars
}
return new (_alloc) Exports(exports);
}
- // HEAPSIZE
- if (_tok._kind == Kind::kw_heapsize) {
+ case Kind::kw_heapsize: {
+ // HEAPSIZE
uint64_t reserve, commit;
if (!parseMemorySize(reserve, commit))
return llvm::None;
return new (_alloc) Heapsize(reserve, commit);
}
- // STACKSIZE
- if (_tok._kind == Kind::kw_stacksize) {
+ case Kind::kw_stacksize: {
+ // STACKSIZE
uint64_t reserve, commit;
if (!parseMemorySize(reserve, commit))
return llvm::None;
return new (_alloc) Stacksize(reserve, commit);
}
- // NAME
- if (_tok._kind == Kind::kw_name) {
+ case Kind::kw_name: {
+ // NAME
std::string outputPath;
uint64_t baseaddr;
if (!parseName(outputPath, baseaddr))
return llvm::None;
return new (_alloc) Name(outputPath, baseaddr);
}
- // VERSION
- if (_tok._kind == Kind::kw_version) {
+ case Kind::kw_version: {
+ // VERSION
int major, minor;
if (!parseVersion(major, minor))
return llvm::None;
return new (_alloc) Version(major, minor);
}
- error(_tok, Twine("Unknown directive: ") + _tok._range);
- return llvm::None;
+ default:
+ error(_tok, Twine("Unknown directive: ") + _tok._range);
+ return llvm::None;
+ }
}
bool Parser::parseExport(PECOFFLinkingContext::ExportDesc &result) {
More information about the llvm-commits
mailing list