mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-10 01:55:08 +00:00
[COFF] Wrap definitions in namespace lld { namespace coff {. NFC
Similar to D67323, but for COFF. Many lld/COFF/ files already use `namespace lld { namespace coff {`. Only a few need changing. Reviewed By: ruiu Differential Revision: https://reviews.llvm.org/D68772 llvm-svn: 374314
This commit is contained in:
parent
95e264fc8a
commit
d79c3be618
@ -17,11 +17,12 @@
|
||||
#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
|
||||
#include "llvm/Support/Path.h"
|
||||
|
||||
using namespace lld;
|
||||
using namespace lld::coff;
|
||||
using namespace llvm;
|
||||
using namespace llvm::codeview;
|
||||
|
||||
namespace lld {
|
||||
namespace coff {
|
||||
|
||||
namespace {
|
||||
// The TypeServerSource class represents a PDB type server, a file referenced by
|
||||
// OBJ files compiled with MSVC /Zi. A single PDB can be shared by several OBJ
|
||||
@ -96,27 +97,25 @@ TpiSource::TpiSource(TpiKind k, const ObjFile *f) : kind(k), file(f) {
|
||||
GC.push_back(std::unique_ptr<TpiSource>(this));
|
||||
}
|
||||
|
||||
TpiSource *lld::coff::makeTpiSource(const ObjFile *f) {
|
||||
TpiSource *makeTpiSource(const ObjFile *f) {
|
||||
return new TpiSource(TpiSource::Regular, f);
|
||||
}
|
||||
|
||||
TpiSource *lld::coff::makeUseTypeServerSource(const ObjFile *f,
|
||||
TpiSource *makeUseTypeServerSource(const ObjFile *f,
|
||||
const TypeServer2Record *ts) {
|
||||
TypeServerSource::enqueue(f, *ts);
|
||||
return new UseTypeServerSource(f, ts);
|
||||
}
|
||||
|
||||
TpiSource *lld::coff::makePrecompSource(const ObjFile *f) {
|
||||
TpiSource *makePrecompSource(const ObjFile *f) {
|
||||
return new PrecompSource(f);
|
||||
}
|
||||
|
||||
TpiSource *lld::coff::makeUsePrecompSource(const ObjFile *f,
|
||||
TpiSource *makeUsePrecompSource(const ObjFile *f,
|
||||
const PrecompRecord *precomp) {
|
||||
return new UsePrecompSource(f, precomp);
|
||||
}
|
||||
|
||||
namespace lld {
|
||||
namespace coff {
|
||||
template <>
|
||||
const PrecompRecord &retrieveDependencyInfo(const TpiSource *source) {
|
||||
assert(source->kind == TpiSource::UsingPCH);
|
||||
@ -128,8 +127,6 @@ 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;
|
||||
@ -210,8 +207,7 @@ TypeServerSource::findFromFile(const ObjFile *dependentFile) {
|
||||
|
||||
// FIXME: Temporary interface until PDBLinker::maybeMergeTypeServerPDB() is
|
||||
// moved here.
|
||||
Expected<llvm::pdb::NativeSession *>
|
||||
lld::coff::findTypeServerSource(const ObjFile *f) {
|
||||
Expected<llvm::pdb::NativeSession *> findTypeServerSource(const ObjFile *f) {
|
||||
Expected<TypeServerSource *> ts = TypeServerSource::findFromFile(f);
|
||||
if (!ts)
|
||||
return ts.takeError();
|
||||
@ -239,7 +235,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 lld::coff::loadTypeServerSource(llvm::MemoryBufferRef m) {
|
||||
void loadTypeServerSource(llvm::MemoryBufferRef m) {
|
||||
std::string path = normalizePdbPath(m.getBufferIdentifier());
|
||||
|
||||
Expected<TypeServerSource *> ts = TypeServerSource::getInstance(m);
|
||||
@ -266,3 +262,6 @@ Expected<TypeServerSource *> TypeServerSource::getInstance(MemoryBufferRef m) {
|
||||
return info.takeError();
|
||||
return new TypeServerSource(m, session.release());
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
@ -47,6 +47,24 @@ 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) {
|
||||
if (!file)
|
||||
return "<internal>";
|
||||
if (file->parentName.empty() || file->kind() == coff::InputFile::ImportKind)
|
||||
return file->getName();
|
||||
|
||||
return (getBasename(file->parentName) + "(" + getBasename(file->getName()) +
|
||||
")")
|
||||
.str();
|
||||
}
|
||||
|
||||
namespace coff {
|
||||
|
||||
std::vector<ObjFile *> ObjFile::instances;
|
||||
@ -908,22 +926,6 @@ std::string replaceThinLTOSuffix(StringRef path) {
|
||||
return (path + repl).str();
|
||||
return path;
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // 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 lld::toString(const coff::InputFile *file) {
|
||||
if (!file)
|
||||
return "<internal>";
|
||||
if (file->parentName.empty() || file->kind() == coff::InputFile::ImportKind)
|
||||
return file->getName();
|
||||
|
||||
return (getBasename(file->parentName) + "(" + getBasename(file->getName()) +
|
||||
")")
|
||||
.str();
|
||||
}
|
||||
|
@ -39,8 +39,8 @@
|
||||
using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
|
||||
using namespace lld;
|
||||
using namespace lld::coff;
|
||||
namespace lld {
|
||||
namespace 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) {
|
||||
@ -206,3 +206,6 @@ std::vector<StringRef> BitcodeCompiler::compile() {
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
@ -29,8 +29,8 @@
|
||||
using namespace llvm;
|
||||
using namespace llvm::object;
|
||||
|
||||
using namespace lld;
|
||||
using namespace lld::coff;
|
||||
namespace lld {
|
||||
namespace coff {
|
||||
|
||||
using SymbolMapTy =
|
||||
DenseMap<const SectionChunk *, SmallVector<DefinedRegular *, 4>>;
|
||||
@ -87,7 +87,7 @@ getSymbolStrings(ArrayRef<DefinedRegular *> syms) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void coff::writeMapFile(ArrayRef<OutputSection *> outputSections) {
|
||||
void writeMapFile(ArrayRef<OutputSection *> outputSections) {
|
||||
if (config->mapFile.empty())
|
||||
return;
|
||||
|
||||
@ -122,3 +122,6 @@ void coff::writeMapFile(ArrayRef<OutputSection *> outputSections) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
@ -13,11 +13,12 @@
|
||||
#include "llvm/Support/Path.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
||||
using namespace lld;
|
||||
using namespace lld::coff;
|
||||
using namespace llvm;
|
||||
using namespace llvm::COFF;
|
||||
|
||||
namespace lld {
|
||||
namespace coff {
|
||||
|
||||
AutoExporter::AutoExporter() {
|
||||
excludeLibs = {
|
||||
"libgcc",
|
||||
@ -146,7 +147,7 @@ bool AutoExporter::shouldExport(Defined *sym) const {
|
||||
return !excludeObjects.count(fileName);
|
||||
}
|
||||
|
||||
void coff::writeDefFile(StringRef name) {
|
||||
void writeDefFile(StringRef name) {
|
||||
std::error_code ec;
|
||||
raw_fd_ostream os(name, ec, sys::fs::OF_None);
|
||||
if (ec)
|
||||
@ -164,3 +165,6 @@ void coff::writeDefFile(StringRef name) {
|
||||
os << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
@ -59,13 +59,14 @@
|
||||
#include "llvm/Support/ScopedPrinter.h"
|
||||
#include <memory>
|
||||
|
||||
using namespace lld;
|
||||
using namespace lld::coff;
|
||||
using namespace llvm;
|
||||
using namespace llvm::codeview;
|
||||
|
||||
using llvm::object::coff_section;
|
||||
|
||||
namespace lld {
|
||||
namespace coff {
|
||||
|
||||
static ExitOnError exitOnErr;
|
||||
|
||||
static Timer totalPdbLinkTimer("PDB Emission (Cumulative)", Timer::root());
|
||||
@ -1597,7 +1598,7 @@ void PDBLinker::addImportFilesToPDB(ArrayRef<OutputSection *> outputSections) {
|
||||
}
|
||||
|
||||
// Creates a PDB file.
|
||||
void coff::createPDB(SymbolTable *symtab,
|
||||
void createPDB(SymbolTable *symtab,
|
||||
ArrayRef<OutputSection *> outputSections,
|
||||
ArrayRef<uint8_t> sectionTable,
|
||||
llvm::codeview::DebugInfo *buildId) {
|
||||
@ -1798,7 +1799,7 @@ static bool findLineTable(const SectionChunk *c, uint32_t addr,
|
||||
// Use CodeView line tables to resolve a file and line number for the given
|
||||
// offset into the given chunk and return them, or {"", 0} if a line table was
|
||||
// not found.
|
||||
std::pair<StringRef, uint32_t> coff::getFileLineCodeView(const SectionChunk *c,
|
||||
std::pair<StringRef, uint32_t> getFileLineCodeView(const SectionChunk *c,
|
||||
uint32_t addr) {
|
||||
ExitOnError exitOnErr;
|
||||
|
||||
@ -1833,3 +1834,6 @@ std::pair<StringRef, uint32_t> coff::getFileLineCodeView(const SectionChunk *c,
|
||||
StringRef filename = exitOnErr(getFileName(cVStrTab, checksums, *nameIndex));
|
||||
return {filename, *lineNumber};
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
@ -40,8 +40,9 @@ using namespace llvm::COFF;
|
||||
using namespace llvm::object;
|
||||
using namespace llvm::support;
|
||||
using namespace llvm::support::endian;
|
||||
using namespace lld;
|
||||
using namespace lld::coff;
|
||||
|
||||
namespace lld {
|
||||
namespace coff {
|
||||
|
||||
/* To re-generate DOSProgram:
|
||||
$ cat > /tmp/DOSProgram.asm
|
||||
@ -285,9 +286,6 @@ private:
|
||||
};
|
||||
} // anonymous namespace
|
||||
|
||||
namespace lld {
|
||||
namespace coff {
|
||||
|
||||
static Timer codeLayoutTimer("Code Layout", Timer::root());
|
||||
static Timer diskCommitTimer("Commit Output File", Timer::root());
|
||||
|
||||
@ -333,9 +331,6 @@ void OutputSection::addContributingPartialSection(PartialSection *sec) {
|
||||
contribSections.push_back(sec);
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
||||
// Check whether the target address S is in range from a relocation
|
||||
// of type relType at address P.
|
||||
static bool isInRange(uint16_t relType, uint64_t s, uint64_t p, int margin) {
|
||||
@ -1945,3 +1940,6 @@ PartialSection *Writer::findPartialSection(StringRef name, uint32_t outChars) {
|
||||
return it->second;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
Loading…
Reference in New Issue
Block a user