[lld] r211367 - MachO: rename _outputFileType to avoid shadowing parent field.

Tim Northover tnorthover at apple.com
Fri Jun 20 08:59:01 PDT 2014


Author: tnorthover
Date: Fri Jun 20 10:59:00 2014
New Revision: 211367

URL: http://llvm.org/viewvc/llvm-project?rev=211367&view=rev
Log:
MachO: rename _outputFileType to avoid shadowing parent field.

Modified:
    lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
    lld/trunk/lib/Driver/DarwinLdDriver.cpp
    lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
    lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
    lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
    lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp

Modified: lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=211367&r1=211366&r2=211367&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h Fri Jun 20 10:59:00 2014
@@ -68,7 +68,7 @@ public:
 
   mach_o::KindHandler &kindHandler() const;
 
-  HeaderFileType outputFileType() const { return _outputFileType; }
+  HeaderFileType outputMachOType() const { return _outputMachOType; }
 
   Arch arch() const { return _arch; }
   StringRef archName() const { return nameFromArch(_arch); }
@@ -153,8 +153,8 @@ private:
 
   static ArchInfo _s_archInfos[];
 
-  HeaderFileType _outputFileType;   // e.g MH_EXECUTE
-  bool _outputFileTypeStatic; // Disambiguate static vs dynamic prog
+  HeaderFileType _outputMachOType;   // e.g MH_EXECUTE
+  bool _outputMachOTypeStatic; // Disambiguate static vs dynamic prog
   bool _doNothing;            // for -help and -v which just print info
   Arch _arch;
   OS _os;

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=211367&r1=211366&r2=211367&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Fri Jun 20 10:59:00 2014
@@ -211,7 +211,7 @@ bool DarwinLdDriver::parse(int argc, con
   // Handle -compatibility_version and -current_version
   if (llvm::opt::Arg *vers =
           parsedArgs->getLastArg(OPT_compatibility_version)) {
-    if (ctx.outputFileType() != llvm::MachO::MH_DYLIB) {
+    if (ctx.outputMachOType() != llvm::MachO::MH_DYLIB) {
       diagnostics
           << "error: -compatibility_version can only be used with -dylib\n";
       return false;
@@ -225,7 +225,7 @@ bool DarwinLdDriver::parse(int argc, con
   }
 
   if (llvm::opt::Arg *vers = parsedArgs->getLastArg(OPT_current_version)) {
-    if (ctx.outputFileType() != llvm::MachO::MH_DYLIB) {
+    if (ctx.outputMachOType() != llvm::MachO::MH_DYLIB) {
       diagnostics << "-current_version can only be used with -dylib\n";
       return false;
     }

Modified: lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp?rev=211367&r1=211366&r2=211367&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ExecutableAtoms.hpp Fri Jun 20 10:59:00 2014
@@ -33,7 +33,7 @@ public:
   CRuntimeFile(const MachOLinkingContext &context)
       : SimpleFile("C runtime"), _undefMain(*this, context.entrySymbolName()) {
       // only main executables need _main
-      if (context.outputFileType() == llvm::MachO::MH_EXECUTE) {
+      if (context.outputMachOType() == llvm::MachO::MH_EXECUTE) {
         this->addAtom(_undefMain);
       }
    }

Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=211367&r1=211366&r2=211367&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Fri Jun 20 10:59:00 2014
@@ -119,7 +119,7 @@ uint32_t MachOLinkingContext::cpuSubtype
 }
 
 MachOLinkingContext::MachOLinkingContext()
-    : _outputFileType(MH_EXECUTE), _outputFileTypeStatic(false),
+    : _outputMachOType(MH_EXECUTE), _outputMachOTypeStatic(false),
       _doNothing(false), _arch(arch_unknown), _os(OS::macOSX), _osMinVersion(0),
       _pageZeroSize(0), _pageSize(4096), _compatibilityVersion(0),
       _currentVersion(0), _deadStrippableDylib(false), _printAtoms(false),
@@ -129,12 +129,12 @@ MachOLinkingContext::~MachOLinkingContex
 
 void MachOLinkingContext::configure(HeaderFileType type, Arch arch, OS os,
                                     uint32_t minOSVersion) {
-  _outputFileType = type;
+  _outputMachOType = type;
   _arch = arch;
   _os = os;
   _osMinVersion = minOSVersion;
 
-  switch (_outputFileType) {
+  switch (_outputMachOType) {
   case llvm::MachO::MH_EXECUTE:
     // If targeting newer OS, use _main
     if (minOS("10.8", "6.0")) {
@@ -211,7 +211,7 @@ bool MachOLinkingContext::is64Bit() cons
 }
 
 bool MachOLinkingContext::outputTypeHasEntry() const {
-  switch (_outputFileType) {
+  switch (_outputMachOType) {
   case MH_EXECUTE:
   case MH_DYLINKER:
   case MH_PRELOAD:
@@ -240,16 +240,16 @@ bool MachOLinkingContext::minOS(StringRe
 }
 
 bool MachOLinkingContext::addEntryPointLoadCommand() const {
-  if ((_outputFileType == MH_EXECUTE) && !_outputFileTypeStatic) {
+  if ((_outputMachOType == MH_EXECUTE) && !_outputMachOTypeStatic) {
     return minOS("10.8", "6.0");
   }
   return false;
 }
 
 bool MachOLinkingContext::addUnixThreadLoadCommand() const {
-  switch (_outputFileType) {
+  switch (_outputMachOType) {
   case MH_EXECUTE:
-    if (_outputFileTypeStatic)
+    if (_outputMachOTypeStatic)
       return true;
     else
       return !minOS("10.8", "6.0");
@@ -265,24 +265,24 @@ bool MachOLinkingContext::addUnixThreadL
 bool MachOLinkingContext::validateImpl(raw_ostream &diagnostics) {
   // TODO: if -arch not specified, look at arch of first .o file.
 
-  if (_currentVersion && _outputFileType != MH_DYLIB) {
+  if (_currentVersion && _outputMachOType != MH_DYLIB) {
     diagnostics << "error: -current_version can only be used with dylibs\n";
     return false;
   }
 
-  if (_compatibilityVersion && _outputFileType != MH_DYLIB) {
+  if (_compatibilityVersion && _outputMachOType != MH_DYLIB) {
     diagnostics
         << "error: -compatibility_version can only be used with dylibs\n";
     return false;
   }
 
-  if (_deadStrippableDylib && _outputFileType != MH_DYLIB) {
+  if (_deadStrippableDylib && _outputMachOType != MH_DYLIB) {
     diagnostics
         << "error: -mark_dead_strippable_dylib can only be used with dylibs.\n";
     return false;
   }
 
-  if (!_bundleLoader.empty() && outputFileType() != MH_BUNDLE) {
+  if (!_bundleLoader.empty() && outputMachOType() != MH_BUNDLE) {
     diagnostics
         << "error: -bundle_loader can only be used with Mach-O bundles\n";
     return false;
@@ -292,7 +292,7 @@ bool MachOLinkingContext::validateImpl(r
 }
 
 void MachOLinkingContext::addPasses(PassManager &pm) {
-  if (outputFileType() != MH_OBJECT) {
+  if (outputMachOType() != MH_OBJECT) {
     pm.add(std::unique_ptr<Pass>(new mach_o::GOTPass));
     pm.add(std::unique_ptr<Pass>(new mach_o::StubsPass(*this)));
   }
@@ -300,9 +300,8 @@ void MachOLinkingContext::addPasses(Pass
 }
 
 Writer &MachOLinkingContext::writer() const {
-  if (!_writer) {
+  if (!_writer)
     _writer = createWriterMachO(*this);
-  }
   return *_writer;
 }
 

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp?rev=211367&r1=211366&r2=211367&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp Fri Jun 20 10:59:00 2014
@@ -263,7 +263,7 @@ SectionInfo *Util::sectionForAtom(const
     auto pos = _sectionMap.find(type);
     if ( pos != _sectionMap.end() )
       return pos->second;
-    bool rMode = (_context.outputFileType() == llvm::MachO::MH_OBJECT);
+    bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT);
     return rMode ? getRelocatableSection(type) : getFinalSection(type);
   } else {
     // This atom needs to be in a custom section.
@@ -365,7 +365,7 @@ bool Util::TextSectionSorter::operator()
 
 
 void Util::organizeSections() {
-  if (_context.outputFileType() == llvm::MachO::MH_OBJECT) {
+  if (_context.outputMachOType() == llvm::MachO::MH_OBJECT) {
     // Leave sections ordered as normalized file specified.
     uint32_t sectionIndex = 1;
     for (SectionInfo *si : _sectionInfos) {
@@ -373,7 +373,7 @@ void Util::organizeSections() {
     }
   } else {
     // Main executables, need a zero-page segment
-    if (_context.outputFileType() == llvm::MachO::MH_EXECUTE)
+    if (_context.outputMachOType() == llvm::MachO::MH_EXECUTE)
       segmentForName("__PAGEZERO");
     // Group sections into segments.
     for (SectionInfo *si : _sectionInfos) {
@@ -442,7 +442,7 @@ void Util::layoutSectionsInTextSegment(S
 
 void Util::assignAddressesToSections() {
   uint64_t address = 0;  // FIXME
-  if (_context.outputFileType() != llvm::MachO::MH_OBJECT) {
+  if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) {
     for (SegmentInfo *seg : _segmentInfos) {
       if (seg->name.equals("__PAGEZERO")) {
         seg->size = _context.pageZeroSize();
@@ -538,7 +538,7 @@ void Util::appendSection(SectionInfo *si
 void Util::copySections(NormalizedFile &file) {
   file.sections.reserve(_sectionInfos.size());
   // For final linked images, write sections grouped by segment.
-  if (_context.outputFileType() != llvm::MachO::MH_OBJECT) {
+  if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) {
     for (SegmentInfo *sgi : _segmentInfos) {
       for (SectionInfo *si : sgi->sections) {
         appendSection(si, file);
@@ -622,7 +622,7 @@ bool Util::AtomSorter::operator()(const
 bool Util::belongsInGlobalSymbolsSection(const DefinedAtom* atom) {
   // ScopeLinkageUnit symbols are in globals area of symbol table
   // in object files, but in locals area for final linked images. 
-  if (_context.outputFileType() == llvm::MachO::MH_OBJECT)
+  if (_context.outputMachOType() == llvm::MachO::MH_OBJECT)
     return (atom->scope() != Atom::scopeTranslationUnit);
   else
     return (atom->scope() == Atom::scopeGlobal);
@@ -826,7 +826,7 @@ void Util::appendReloc(const DefinedAtom
 }
 
 void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) {
-  if (_context.outputFileType() != llvm::MachO::MH_OBJECT)
+  if (_context.outputMachOType() != llvm::MachO::MH_OBJECT)
     return;
 
   for (SectionInfo *si : _sectionInfos) {
@@ -842,7 +842,7 @@ void Util::addSectionRelocs(const lld::F
 
 void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
                                                         NormalizedFile &nFile) {
-  if (_context.outputFileType() == llvm::MachO::MH_OBJECT)
+  if (_context.outputMachOType() == llvm::MachO::MH_OBJECT)
     return;
 
   uint8_t segmentIndex;
@@ -918,7 +918,7 @@ normalizedFromAtoms(const lld::File &ato
   std::unique_ptr<NormalizedFile> f(new NormalizedFile());
   NormalizedFile &normFile = *f.get();
   f->arch = context.arch();
-  f->fileType = context.outputFileType();
+  f->fileType = context.outputMachOType();
   f->flags = util.fileFlags();
   util.copySegmentInfo(normFile);
   util.copySections(normFile);

Modified: lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp?rev=211367&r1=211366&r2=211367&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/WriterMachO.cpp Fri Jun 20 10:59:00 2014
@@ -46,7 +46,7 @@ public:
   }
 
   bool createImplicitFiles(std::vector<std::unique_ptr<File> > &r) override {
-    if (_context.outputFileType() == llvm::MachO::MH_EXECUTE) {
+    if (_context.outputMachOType() == llvm::MachO::MH_EXECUTE) {
       // When building main executables, add _main as required entry point.
       r.emplace_back(new CRuntimeFile(_context));
     }

Modified: lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp?rev=211367&r1=211366&r2=211367&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/DarwinLdDriverTest.cpp Fri Jun 20 10:59:00 2014
@@ -45,27 +45,27 @@ TEST_F(DarwinLdParserTest, Output) {
 
 TEST_F(DarwinLdParserTest, Dylib) {
   EXPECT_TRUE(parse("ld", "-dylib", "foo.o", nullptr));
-  EXPECT_EQ(llvm::MachO::MH_DYLIB, _context.outputFileType());
+  EXPECT_EQ(llvm::MachO::MH_DYLIB, _context.outputMachOType());
 }
 
 TEST_F(DarwinLdParserTest, Relocatable) {
   EXPECT_TRUE(parse("ld", "-r", "foo.o", nullptr));
-  EXPECT_EQ(llvm::MachO::MH_OBJECT, _context.outputFileType());
+  EXPECT_EQ(llvm::MachO::MH_OBJECT, _context.outputMachOType());
 }
 
 TEST_F(DarwinLdParserTest, Bundle) {
   EXPECT_TRUE(parse("ld", "-bundle", "foo.o", nullptr));
-  EXPECT_EQ(llvm::MachO::MH_BUNDLE, _context.outputFileType());
+  EXPECT_EQ(llvm::MachO::MH_BUNDLE, _context.outputMachOType());
 }
 
 TEST_F(DarwinLdParserTest, Preload) {
   EXPECT_TRUE(parse("ld", "-preload", "foo.o", nullptr));
-  EXPECT_EQ(llvm::MachO::MH_PRELOAD, _context.outputFileType());
+  EXPECT_EQ(llvm::MachO::MH_PRELOAD, _context.outputMachOType());
 }
 
 TEST_F(DarwinLdParserTest, Static) {
   EXPECT_TRUE(parse("ld", "-static", "foo.o", nullptr));
-  EXPECT_EQ(llvm::MachO::MH_EXECUTE, _context.outputFileType());
+  EXPECT_EQ(llvm::MachO::MH_EXECUTE, _context.outputMachOType());
 }
 
 TEST_F(DarwinLdParserTest, Entry) {





More information about the llvm-commits mailing list