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 236fcbc21a.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D74882
This commit is contained in:
Reid Kleckner 2020-02-19 17:05:42 -08:00
parent 5517d3b80b
commit 8a310f40d0
7 changed files with 36 additions and 60 deletions

View File

@ -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 @@ public:
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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 @@ private:
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