diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:39 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:03:39 +0000 |
| commit | d2d3ebb81992e107edf95c1c136d7a342d9b1418 (patch) | |
| tree | bb1af8fff2b1400cf240e3b2532a1e5d22a121da /COFF/ModuleDef.cpp | |
| parent | 16787c9ce0b96aaa669d7fab3a495916b35ce758 (diff) | |
Notes
Diffstat (limited to 'COFF/ModuleDef.cpp')
| -rw-r--r-- | COFF/ModuleDef.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/COFF/ModuleDef.cpp b/COFF/ModuleDef.cpp index a273b6f535db..c9a40ac5ab8c 100644 --- a/COFF/ModuleDef.cpp +++ b/COFF/ModuleDef.cpp @@ -163,17 +163,25 @@ private: case KwHeapsize: parseNumbers(&Config->HeapReserve, &Config->HeapCommit); return; - case KwLibrary: - parseName(&Config->OutputFile, &Config->ImageBase); - if (!StringRef(Config->OutputFile).endswith_lower(".dll")) - Config->OutputFile += ".dll"; - return; case KwStacksize: parseNumbers(&Config->StackReserve, &Config->StackCommit); return; - case KwName: - parseName(&Config->OutputFile, &Config->ImageBase); + case KwLibrary: + case KwName: { + bool IsDll = Tok.K == KwLibrary; // Check before parseName. + std::string Name; + parseName(&Name, &Config->ImageBase); + + // Append the appropriate file extension if not already present. + StringRef Ext = IsDll ? ".dll" : ".exe"; + if (!StringRef(Name).endswith_lower(Ext)) + Name += Ext; + + // Set the output file, but don't override /out if it was already passed. + if (Config->OutputFile.empty()) + Config->OutputFile = Name; return; + } case KwVersion: parseVersion(&Config->MajorImageVersion, &Config->MinorImageVersion); return; |
