diff options
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; |
