[llvm] r308383 - Object: handle extensions properly in def files
Saleem Abdulrasool via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 18 15:11:00 PDT 2017
Author: compnerd
Date: Tue Jul 18 15:11:00 2017
New Revision: 308383
URL: http://llvm.org/viewvc/llvm-project?rev=308383&view=rev
Log:
Object: handle extensions properly in def files
When given an extension as part of the `library` directive in a def
file, the extension is preserved/honoured by link/lib. Behave similarly
when parsing the def file. This requires checking if a native extension
is provided as a keyword parameter. If no extension is present, append
a standard `.dll` or `.exe` extension.
This is best tested via lld, and I will add tests there as a follow up.
Modified:
llvm/trunk/lib/Object/COFFModuleDefinition.cpp
Modified: llvm/trunk/lib/Object/COFFModuleDefinition.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFModuleDefinition.cpp?rev=308383&r1=308382&r2=308383&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFModuleDefinition.cpp (original)
+++ llvm/trunk/lib/Object/COFFModuleDefinition.cpp Tue Jul 18 15:11:00 2017
@@ -22,6 +22,7 @@
#include "llvm/Object/COFFImportFile.h"
#include "llvm/Object/Error.h"
#include "llvm/Support/Error.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm::COFF;
@@ -188,9 +189,8 @@ private:
if (Error Err = parseName(&Name, &Info.ImageBase))
return Err;
// Append the appropriate file extension if not already present.
- StringRef Ext = IsDll ? ".dll" : ".exe";
- if (!StringRef(Name).endswith_lower(Ext))
- Name += Ext;
+ if (!sys::path::has_extension(Name))
+ Name += IsDll ? ".dll" : ".exe";
// Set the output file, but don't override /out if it was already passed.
if (Info.OutputFile.empty())
More information about the llvm-commits
mailing list