[lld] r198396 - Use scoped enum.

Nick Kledzik kledzik at apple.com
Thu Jan 2 22:28:04 PST 2014


Will there be other formats beside exe and dll?  If not, wouldn't it be simpler to just have this be a bool (_isDLL)?

-Nick

On Jan 2, 2014, at 7:29 PM, Rui Ueyama wrote:
> Author: ruiu
> Date: Thu Jan  2 21:29:15 2014
> New Revision: 198396
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=198396&view=rev
> Log:
> Use scoped enum.
> 
> Modified:
>    lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
>    lld/trunk/lib/Driver/WinLinkDriver.cpp
>    lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h
>    lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
>    lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
> 
> Modified: lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h?rev=198396&r1=198395&r2=198396&view=diff
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h (original)
> +++ lld/trunk/include/lld/ReaderWriter/PECOFFLinkingContext.h Thu Jan  2 21:29:15 2014
> @@ -46,7 +46,7 @@ public:
>         _terminalServerAware(true), _dynamicBaseEnabled(true),
>         _createManifest(true), _embedManifest(false), _manifestId(1),
>         _manifestLevel("'asInvoker'"), _manifestUiAccess("'false'"),
> -        _imageType(ImageType::IMAGE_EXE),
> +        _imageType(ImageType::exe),
>         _dosStub(llvm::makeArrayRef(DEFAULT_DOS_STUB)) {
>     setDeadStripping(true);
>   }
> @@ -72,9 +72,9 @@ public:
>   /// \brief Casting support
>   static inline bool classof(const LinkingContext *info) { return true; }
> 
> -  enum ImageType {
> -    IMAGE_EXE,
> -    IMAGE_DLL
> +  enum class ImageType {
> +    exe,
> +    dll
>   };
> 
>   virtual Writer &writer() const;
> 
> Modified: lld/trunk/lib/Driver/WinLinkDriver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/WinLinkDriver.cpp?rev=198396&r1=198395&r2=198396&view=diff
> ==============================================================================
> --- lld/trunk/lib/Driver/WinLinkDriver.cpp (original)
> +++ lld/trunk/lib/Driver/WinLinkDriver.cpp Thu Jan  2 21:29:15 2014
> @@ -571,7 +571,7 @@ void processLibEnv(PECOFFLinkingContext
> // Returns a default entry point symbol name depending on context image type and
> // subsystem. These default names are MS CRT compliant.
> StringRef getDefaultEntrySymbolName(PECOFFLinkingContext &context) {
> -  if (context.getImageType() == PECOFFLinkingContext::ImageType::IMAGE_DLL)
> +  if (context.getImageType() == PECOFFLinkingContext::ImageType::dll)
>     return "_DllMainCRTStartup at 12";
>   llvm::COFF::WindowsSubsystem subsystem = context.getSubsystem();
>   if (subsystem == llvm::COFF::WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI)
> @@ -726,7 +726,7 @@ WinLinkDriver::parse(int argc, const cha
> 
>     case OPT_dll:
>       // Parse /dll command line option
> -      ctx.setImageType(PECOFFLinkingContext::IMAGE_DLL);
> +      ctx.setImageType(PECOFFLinkingContext::ImageType::dll);
>       // Default base address of a DLL is 0x10000000.
>       if (!parsedArgs->getLastArg(OPT_base))
>         ctx.setBaseAddress(0x10000000);
> 
> Modified: lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h?rev=198396&r1=198395&r2=198396&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h (original)
> +++ lld/trunk/lib/ReaderWriter/PECOFF/SetSubsystemPass.h Thu Jan  2 21:29:15 2014
> @@ -41,7 +41,7 @@ public:
>         return;
>       }
>     }
> -    if (_ctx.getImageType() == PECOFFLinkingContext::IMAGE_DLL) {
> +    if (_ctx.getImageType() == PECOFFLinkingContext::ImageType::dll) {
>       _ctx.setSubsystem(WindowsSubsystem::IMAGE_SUBSYSTEM_WINDOWS_GUI);
>       return;
>     }
> 
> Modified: lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp?rev=198396&r1=198395&r2=198396&view=diff
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp Thu Jan  2 21:29:15 2014
> @@ -911,7 +911,8 @@ error_code PECOFFWriter::writeFile(const
>   applyAllRelocations(buffer->getBufferStart());
>   DEBUG(printAllAtomAddresses());
> 
> -  if (_PECOFFLinkingContext.getImageType() == PECOFFLinkingContext::IMAGE_DLL)
> +  if (_PECOFFLinkingContext.getImageType() ==
> +      PECOFFLinkingContext::ImageType::dll)
>     writeImportLibrary(_PECOFFLinkingContext);
> 
>   return buffer->commit();
> @@ -983,7 +984,8 @@ void PECOFFWriter::setAddressOfEntryPoin
>   // PECOFF spec says that entry point for dll images is optional, in which
>   // case it must be set to 0.
>   if (_PECOFFLinkingContext.entrySymbolName().empty() &&
> -      _PECOFFLinkingContext.getImageType() == PECOFFLinkingContext::IMAGE_DLL) {
> +      _PECOFFLinkingContext.getImageType() ==
> +          PECOFFLinkingContext::ImageType::dll) {
>     peHeader->setAddressOfEntryPoint(0);
>   } else {
>     uint64_t entryPointAddress =
> 
> Modified: lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp?rev=198396&r1=198395&r2=198396&view=diff
> ==============================================================================
> --- lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp (original)
> +++ lld/trunk/unittests/DriverTests/WinLinkDriverTest.cpp Thu Jan  2 21:29:15 2014
> @@ -46,7 +46,7 @@ TEST_F(WinLinkParserTest, Basic) {
>   EXPECT_TRUE(_context.getInputSearchPaths().empty());
> 
>   // Unspecified flags will have default values.
> -  EXPECT_EQ(PECOFFLinkingContext::IMAGE_EXE, _context.getImageType());
> +  EXPECT_EQ(PECOFFLinkingContext::ImageType::exe, _context.getImageType());
>   EXPECT_EQ(6, _context.getMinOSVersion().majorVersion);
>   EXPECT_EQ(0, _context.getMinOSVersion().minorVersion);
>   EXPECT_EQ(0x400000U, _context.getBaseAddress());
> @@ -426,7 +426,7 @@ TEST_F(WinLinkParserTest, DisallowLib) {
> 
> TEST_F(WinLinkParserTest, NoEntry) {
>   EXPECT_TRUE(parse("link.exe", "/noentry", "/dll", "a.obj", nullptr));
> -  EXPECT_EQ(PECOFFLinkingContext::IMAGE_DLL, _context.getImageType());
> +  EXPECT_EQ(PECOFFLinkingContext::ImageType::dll, _context.getImageType());
>   EXPECT_EQ(0x10000000U, _context.getBaseAddress());
>   EXPECT_EQ("", _context.entrySymbolName());
> }
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list