diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp --- 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 @@ 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::Regular, f); } -TpiSource *makeUseTypeServerSource(const ObjFile *f, +TpiSource *lld::coff::makeUseTypeServerSource(const ObjFile *f, const TypeServer2Record *ts) { TypeServerSource::enqueue(f, *ts); return make(f, ts); } -TpiSource *makePrecompSource(const ObjFile *f) { +TpiSource *lld::coff::makePrecompSource(const ObjFile *f) { return make(f); } -TpiSource *makeUsePrecompSource(const ObjFile *f, +TpiSource *lld::coff::makeUsePrecompSource(const ObjFile *f, const PrecompRecord *precomp) { return make(f, precomp); } +namespace lld { +namespace coff { template <> const PrecompRecord &retrieveDependencyInfo(const TpiSource *source) { assert(source->kind == TpiSource::UsingPCH); @@ -124,6 +125,8 @@ assert(source->kind == TpiSource::UsingPDB); return ((const UseTypeServerSource *)source)->typeServerDependency; } +} // namespace coff +} // namespace lld std::map> TypeServerSource::instances; @@ -204,7 +207,8 @@ // FIXME: Temporary interface until PDBLinker::maybeMergeTypeServerPDB() is // moved here. -Expected findTypeServerSource(const ObjFile *f) { +Expected +lld::coff::findTypeServerSource(const ObjFile *f) { Expected ts = TypeServerSource::findFromFile(f); if (!ts) return ts.takeError(); @@ -232,7 +236,7 @@ // 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 ts = TypeServerSource::getInstance(m); @@ -259,6 +263,3 @@ return info.takeError(); return make(m, session.release()); } - -} // namespace coff -} // namespace lld diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp --- a/lld/COFF/InputFiles.cpp +++ b/lld/COFF/InputFiles.cpp @@ -44,19 +44,19 @@ 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 ""; if (file->parentName.empty() || file->kind() == coff::InputFile::ImportKind) @@ -67,8 +67,6 @@ .str(); } -namespace coff { - std::vector ObjFile::instances; std::vector ImportFile::instances; std::vector BitcodeFile::instances; @@ -121,7 +119,7 @@ driver->enqueueArchiveMember(c, sym, getName()); } -std::vector getArchiveMembers(Archive *file) { +std::vector lld::coff::getArchiveMembers(Archive *file) { std::vector v; Error err = Error::success(); for (const Archive::Child &c : file->children(err)) { @@ -967,7 +965,7 @@ } } -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 @@ return (path + repl).str(); return std::string(path); } - -} // namespace coff -} // namespace lld diff --git a/lld/COFF/LTO.cpp b/lld/COFF/LTO.cpp --- 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 openFile(StringRef file) { @@ -207,6 +206,3 @@ return ret; } - -} // namespace coff -} // namespace lld diff --git a/lld/COFF/MapFile.cpp b/lld/COFF/MapFile.cpp --- 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>; @@ -87,7 +86,7 @@ return ret; } -void writeMapFile(ArrayRef outputSections) { +void lld::coff::writeMapFile(ArrayRef outputSections) { if (config->mapFile.empty()) return; @@ -122,6 +121,3 @@ } } } - -} // namespace coff -} // namespace lld diff --git a/lld/COFF/MinGW.cpp b/lld/COFF/MinGW.cpp --- 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 @@ 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 @@ os << "\n"; } } - -} // namespace coff -} // namespace lld diff --git a/lld/COFF/PDB.cpp b/lld/COFF/PDB.cpp --- 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 @@ } // Creates a PDB file. -void createPDB(SymbolTable *symtab, - ArrayRef outputSections, - ArrayRef sectionTable, - llvm::codeview::DebugInfo *buildId) { +void lld::coff::createPDB(SymbolTable *symtab, + ArrayRef outputSections, + ArrayRef sectionTable, + llvm::codeview::DebugInfo *buildId) { ScopedTimer t1(totalPdbLinkTimer); PDBLinker pdb(symtab); @@ -1880,7 +1879,7 @@ // offset into the given chunk and return them, or None if a line table was // not found. Optional> -getFileLineCodeView(const SectionChunk *c, uint32_t addr) { +lld::coff::getFileLineCodeView(const SectionChunk *c, uint32_t addr) { ExitOnError exitOnErr; DebugStringTableSubsectionRef cVStrTab; @@ -1914,6 +1913,3 @@ 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 --- a/lld/COFF/Writer.cpp +++ b/lld/COFF/Writer.cpp @@ -41,9 +41,8 @@ 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 @@ 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 @@ return it->second; return nullptr; } - -} // namespace coff -} // namespace lld