[lld] 8a310f4 - Remove namespace lld { namespace coff { from COFF LLD cpp files

Reid Kleckner via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 25 17:35:17 PST 2020


Author: Reid Kleckner
Date: 2020-02-25T17:30:53-08:00
New Revision: 8a310f40d0a325daf0c81af204c93adc3e885d10

URL: https://github.com/llvm/llvm-project/commit/8a310f40d0a325daf0c81af204c93adc3e885d10
DIFF: https://github.com/llvm/llvm-project/commit/8a310f40d0a325daf0c81af204c93adc3e885d10.diff

LOG: Remove namespace lld { namespace coff { from COFF LLD cpp files

Instead, use `using namespace lld(::coff)`, and fully qualify the names
of free functions where they are defined in cpp files.

This effectively reverts d79c3be618 to follow the new style guide added
in 236fcbc21a7a8872.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D74882

Added: 
    

Modified: 
    lld/COFF/DebugTypes.cpp
    lld/COFF/InputFiles.cpp
    lld/COFF/LTO.cpp
    lld/COFF/MapFile.cpp
    lld/COFF/MinGW.cpp
    lld/COFF/PDB.cpp
    lld/COFF/Writer.cpp

Removed: 
    


################################################################################
diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index cd59b4310dbb..a0d190b4a762 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -20,9 +20,8 @@
 
 using namespace llvm;
 using namespace llvm::codeview;
-
-namespace lld {
-namespace coff {
+using namespace lld;
+using namespace lld::coff;
 
 namespace {
 // The TypeServerSource class represents a PDB type server, a file referenced by
@@ -94,25 +93,27 @@ class UsePrecompSource : public TpiSource {
 
 TpiSource::TpiSource(TpiKind k, const ObjFile *f) : kind(k), file(f) {}
 
-TpiSource *makeTpiSource(const ObjFile *f) {
+TpiSource *lld::coff::makeTpiSource(const ObjFile *f) {
   return make<TpiSource>(TpiSource::Regular, f);
 }
 
-TpiSource *makeUseTypeServerSource(const ObjFile *f,
+TpiSource *lld::coff::makeUseTypeServerSource(const ObjFile *f,
                                               const TypeServer2Record *ts) {
   TypeServerSource::enqueue(f, *ts);
   return make<UseTypeServerSource>(f, ts);
 }
 
-TpiSource *makePrecompSource(const ObjFile *f) {
+TpiSource *lld::coff::makePrecompSource(const ObjFile *f) {
   return make<PrecompSource>(f);
 }
 
-TpiSource *makeUsePrecompSource(const ObjFile *f,
+TpiSource *lld::coff::makeUsePrecompSource(const ObjFile *f,
                                            const PrecompRecord *precomp) {
   return make<UsePrecompSource>(f, precomp);
 }
 
+namespace lld {
+namespace coff {
 template <>
 const PrecompRecord &retrieveDependencyInfo(const TpiSource *source) {
   assert(source->kind == TpiSource::UsingPCH);
@@ -124,6 +125,8 @@ const TypeServer2Record &retrieveDependencyInfo(const TpiSource *source) {
   assert(source->kind == TpiSource::UsingPDB);
   return ((const UseTypeServerSource *)source)->typeServerDependency;
 }
+} // namespace coff
+} // namespace lld
 
 std::map<std::string, std::pair<std::string, TypeServerSource *>>
     TypeServerSource::instances;
@@ -204,7 +207,8 @@ TypeServerSource::findFromFile(const ObjFile *dependentFile) {
 
 // FIXME: Temporary interface until PDBLinker::maybeMergeTypeServerPDB() is
 // moved here.
-Expected<llvm::pdb::NativeSession *> findTypeServerSource(const ObjFile *f) {
+Expected<llvm::pdb::NativeSession *>
+lld::coff::findTypeServerSource(const ObjFile *f) {
   Expected<TypeServerSource *> ts = TypeServerSource::findFromFile(f);
   if (!ts)
     return ts.takeError();
@@ -232,7 +236,7 @@ void TypeServerSource::enqueue(const ObjFile *dependentFile,
 // will be merged in. NOTE - a PDB load failure is not a link error: some
 // debug info will simply be missing from the final PDB - that is the default
 // accepted behavior.
-void loadTypeServerSource(llvm::MemoryBufferRef m) {
+void lld::coff::loadTypeServerSource(llvm::MemoryBufferRef m) {
   std::string path = normalizePdbPath(m.getBufferIdentifier());
 
   Expected<TypeServerSource *> ts = TypeServerSource::getInstance(m);
@@ -259,6 +263,3 @@ Expected<TypeServerSource *> TypeServerSource::getInstance(MemoryBufferRef m) {
     return info.takeError();
   return make<TypeServerSource>(m, session.release());
 }
-
-} // namespace coff
-} // namespace lld

diff  --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index 58b0c97c700b..f322e6a9db2d 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -44,19 +44,19 @@ using namespace llvm::COFF;
 using namespace llvm::codeview;
 using namespace llvm::object;
 using namespace llvm::support::endian;
+using namespace lld;
+using namespace lld::coff;
 
 using llvm::Triple;
 using llvm::support::ulittle32_t;
 
-namespace lld {
-
 // Returns the last element of a path, which is supposed to be a filename.
 static StringRef getBasename(StringRef path) {
   return sys::path::filename(path, sys::path::Style::windows);
 }
 
 // Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".
-std::string toString(const coff::InputFile *file) {
+std::string lld::toString(const coff::InputFile *file) {
   if (!file)
     return "<internal>";
   if (file->parentName.empty() || file->kind() == coff::InputFile::ImportKind)
@@ -67,8 +67,6 @@ std::string toString(const coff::InputFile *file) {
       .str();
 }
 
-namespace coff {
-
 std::vector<ObjFile *> ObjFile::instances;
 std::vector<ImportFile *> ImportFile::instances;
 std::vector<BitcodeFile *> BitcodeFile::instances;
@@ -121,7 +119,7 @@ void ArchiveFile::addMember(const Archive::Symbol &sym) {
   driver->enqueueArchiveMember(c, sym, getName());
 }
 
-std::vector<MemoryBufferRef> getArchiveMembers(Archive *file) {
+std::vector<MemoryBufferRef> lld::coff::getArchiveMembers(Archive *file) {
   std::vector<MemoryBufferRef> v;
   Error err = Error::success();
   for (const Archive::Child &c : file->children(err)) {
@@ -967,7 +965,7 @@ MachineTypes BitcodeFile::getMachineType() {
   }
 }
 
-std::string replaceThinLTOSuffix(StringRef path) {
+std::string lld::coff::replaceThinLTOSuffix(StringRef path) {
   StringRef suffix = config->thinLTOObjectSuffixReplace.first;
   StringRef repl = config->thinLTOObjectSuffixReplace.second;
 
@@ -975,6 +973,3 @@ std::string replaceThinLTOSuffix(StringRef path) {
     return (path + repl).str();
   return std::string(path);
 }
-
-} // namespace coff
-} // namespace lld

diff  --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp
index 609871deeb69..247331b16928 100644
--- a/lld/COFF/LTO.cpp
+++ b/lld/COFF/LTO.cpp
@@ -38,9 +38,8 @@
 
 using namespace llvm;
 using namespace llvm::object;
-
-namespace lld {
-namespace coff {
+using namespace lld;
+using namespace lld::coff;
 
 // Creates an empty file to and returns a raw_fd_ostream to write to it.
 static std::unique_ptr<raw_fd_ostream> openFile(StringRef file) {
@@ -207,6 +206,3 @@ std::vector<StringRef> BitcodeCompiler::compile() {
 
   return ret;
 }
-
-} // namespace coff
-} // namespace lld

diff  --git a/lld/COFF/MapFile.cpp b/lld/COFF/MapFile.cpp
index 0fea60aab99b..a80c553637aa 100644
--- a/lld/COFF/MapFile.cpp
+++ b/lld/COFF/MapFile.cpp
@@ -28,9 +28,8 @@
 
 using namespace llvm;
 using namespace llvm::object;
-
-namespace lld {
-namespace coff {
+using namespace lld;
+using namespace lld::coff;
 
 using SymbolMapTy =
     DenseMap<const SectionChunk *, SmallVector<DefinedRegular *, 4>>;
@@ -87,7 +86,7 @@ getSymbolStrings(ArrayRef<DefinedRegular *> syms) {
   return ret;
 }
 
-void writeMapFile(ArrayRef<OutputSection *> outputSections) {
+void lld::coff::writeMapFile(ArrayRef<OutputSection *> outputSections) {
   if (config->mapFile.empty())
     return;
 
@@ -122,6 +121,3 @@ void writeMapFile(ArrayRef<OutputSection *> outputSections) {
     }
   }
 }
-
-} // namespace coff
-} // namespace lld

diff  --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp
index 270cdaab4d9c..bded985f04d0 100644
--- a/lld/COFF/MinGW.cpp
+++ b/lld/COFF/MinGW.cpp
@@ -15,9 +15,8 @@
 
 using namespace llvm;
 using namespace llvm::COFF;
-
-namespace lld {
-namespace coff {
+using namespace lld;
+using namespace lld::coff;
 
 AutoExporter::AutoExporter() {
   excludeLibs = {
@@ -147,7 +146,7 @@ bool AutoExporter::shouldExport(Defined *sym) const {
   return !excludeObjects.count(fileName);
 }
 
-void writeDefFile(StringRef name) {
+void lld::coff::writeDefFile(StringRef name) {
   std::error_code ec;
   raw_fd_ostream os(name, ec, sys::fs::OF_None);
   if (ec)
@@ -165,6 +164,3 @@ void writeDefFile(StringRef name) {
     os << "\n";
   }
 }
-
-} // namespace coff
-} // namespace lld

diff  --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp
index 52740ae393a9..3754bd0d1cf6 100644
--- a/lld/COFF/PDB.cpp
+++ b/lld/COFF/PDB.cpp
@@ -63,12 +63,11 @@
 
 using namespace llvm;
 using namespace llvm::codeview;
+using namespace lld;
+using namespace lld::coff;
 
 using llvm::object::coff_section;
 
-namespace lld {
-namespace coff {
-
 static ExitOnError exitOnErr;
 
 static Timer totalPdbLinkTimer("PDB Emission (Cumulative)", Timer::root());
@@ -1679,10 +1678,10 @@ void PDBLinker::addImportFilesToPDB(ArrayRef<OutputSection *> outputSections) {
 }
 
 // Creates a PDB file.
-void createPDB(SymbolTable *symtab,
-                     ArrayRef<OutputSection *> outputSections,
-                     ArrayRef<uint8_t> sectionTable,
-                     llvm::codeview::DebugInfo *buildId) {
+void lld::coff::createPDB(SymbolTable *symtab,
+                          ArrayRef<OutputSection *> outputSections,
+                          ArrayRef<uint8_t> sectionTable,
+                          llvm::codeview::DebugInfo *buildId) {
   ScopedTimer t1(totalPdbLinkTimer);
   PDBLinker pdb(symtab);
 
@@ -1880,7 +1879,7 @@ static bool findLineTable(const SectionChunk *c, uint32_t addr,
 // offset into the given chunk and return them, or None if a line table was
 // not found.
 Optional<std::pair<StringRef, uint32_t>>
-getFileLineCodeView(const SectionChunk *c, uint32_t addr) {
+lld::coff::getFileLineCodeView(const SectionChunk *c, uint32_t addr) {
   ExitOnError exitOnErr;
 
   DebugStringTableSubsectionRef cVStrTab;
@@ -1914,6 +1913,3 @@ getFileLineCodeView(const SectionChunk *c, uint32_t addr) {
   StringRef filename = exitOnErr(getFileName(cVStrTab, checksums, *nameIndex));
   return std::make_pair(filename, *lineNumber);
 }
-
-} // namespace coff
-} // namespace lld

diff  --git a/lld/COFF/Writer.cpp b/lld/COFF/Writer.cpp
index fcad7739d300..fbef82af9d36 100644
--- a/lld/COFF/Writer.cpp
+++ b/lld/COFF/Writer.cpp
@@ -41,9 +41,8 @@ using namespace llvm::COFF;
 using namespace llvm::object;
 using namespace llvm::support;
 using namespace llvm::support::endian;
-
-namespace lld {
-namespace coff {
+using namespace lld;
+using namespace lld::coff;
 
 /* To re-generate DOSProgram:
 $ cat > /tmp/DOSProgram.asm
@@ -290,7 +289,7 @@ class Writer {
 static Timer codeLayoutTimer("Code Layout", Timer::root());
 static Timer diskCommitTimer("Commit Output File", Timer::root());
 
-void writeResult() { Writer().run(); }
+void lld::coff::writeResult() { Writer().run(); }
 
 void OutputSection::addChunk(Chunk *c) {
   chunks.push_back(c);
@@ -1950,6 +1949,3 @@ PartialSection *Writer::findPartialSection(StringRef name, uint32_t outChars) {
     return it->second;
   return nullptr;
 }
-
-} // namespace coff
-} // namespace lld


        


More information about the llvm-commits mailing list