[lld/win] Use C++17 nested namespace syntax in most places

Like D131354, but for COFF.

No behavior change.

Differential Revision: https://reviews.llvm.org/D131405
This commit is contained in:
Nico Weber 2022-08-08 11:32:26 -04:00
parent e4b2c52420
commit 7c26641d9d
25 changed files with 49 additions and 103 deletions

View File

@ -13,8 +13,7 @@
#include "lld/Common/Memory.h" #include "lld/Common/Memory.h"
#include "llvm/DebugInfo/CodeView/TypeHashing.h" #include "llvm/DebugInfo/CodeView/TypeHashing.h"
namespace lld { namespace lld::coff {
namespace coff {
COFFLinkerContext::COFFLinkerContext() COFFLinkerContext::COFFLinkerContext()
: symtab(*this), rootTimer("Total Linking Time"), : symtab(*this), rootTimer("Total Linking Time"),
@ -36,5 +35,4 @@ COFFLinkerContext::COFFLinkerContext()
tpiStreamLayoutTimer("TPI Stream Layout", totalPdbLinkTimer), tpiStreamLayoutTimer("TPI Stream Layout", totalPdbLinkTimer),
diskCommitTimer("Commit to Disk", totalPdbLinkTimer) {} diskCommitTimer("Commit to Disk", totalPdbLinkTimer) {}
} // namespace coff } // namespace lld::coff
} // namespace lld

View File

@ -18,8 +18,7 @@
#include "lld/Common/CommonLinkerContext.h" #include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/Timer.h" #include "lld/Common/Timer.h"
namespace lld { namespace lld::coff {
namespace coff {
class COFFLinkerContext : public CommonLinkerContext { class COFFLinkerContext : public CommonLinkerContext {
public: public:
@ -80,7 +79,6 @@ public:
Timer diskCommitTimer; Timer diskCommitTimer;
}; };
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -11,14 +11,12 @@
#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DenseMap.h"
namespace lld { namespace lld::coff {
namespace coff {
class SectionChunk; class SectionChunk;
class COFFLinkerContext; class COFFLinkerContext;
llvm::DenseMap<const SectionChunk *, int> llvm::DenseMap<const SectionChunk *, int>
computeCallGraphProfileOrder(const COFFLinkerContext &ctx); computeCallGraphProfileOrder(const COFFLinkerContext &ctx);
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -27,8 +27,7 @@ using namespace llvm::support::endian;
using namespace llvm::COFF; using namespace llvm::COFF;
using llvm::support::ulittle32_t; using llvm::support::ulittle32_t;
namespace lld { namespace lld::coff {
namespace coff {
SectionChunk::SectionChunk(ObjFile *f, const coff_section *h) SectionChunk::SectionChunk(ObjFile *f, const coff_section *h)
: Chunk(SectionKind), file(f), header(h), repl(this) { : Chunk(SectionKind), file(f), header(h), repl(this) {
@ -996,5 +995,4 @@ void AbsolutePointerChunk::writeTo(uint8_t *buf) const {
} }
} }
} // namespace coff } // namespace lld::coff
} // namespace lld

View File

@ -21,8 +21,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
namespace lld { namespace lld::coff {
namespace coff {
using llvm::COFF::ImportDirectoryTableEntry; using llvm::COFF::ImportDirectoryTableEntry;
using llvm::object::COFFSymbolRef; using llvm::object::COFFSymbolRef;
@ -698,8 +697,7 @@ void applyArm64Addr(uint8_t *off, uint64_t s, uint64_t p, int shift);
void applyArm64Imm(uint8_t *off, uint64_t imm, uint32_t rangeLimit); void applyArm64Imm(uint8_t *off, uint64_t imm, uint32_t rangeLimit);
void applyArm64Branch26(uint8_t *off, int64_t v); void applyArm64Branch26(uint8_t *off, int64_t v);
} // namespace coff } // namespace lld::coff
} // namespace lld
namespace llvm { namespace llvm {
template <> template <>

View File

@ -21,8 +21,7 @@
#include <set> #include <set>
#include <string> #include <string>
namespace lld { namespace lld::coff {
namespace coff {
using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN; using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
using llvm::COFF::WindowsSubsystem; using llvm::COFF::WindowsSubsystem;
@ -289,7 +288,6 @@ struct Configuration {
extern std::unique_ptr<Configuration> config; extern std::unique_ptr<Configuration> config;
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -31,8 +31,7 @@ using namespace llvm::object;
using namespace llvm::support::endian; using namespace llvm::support::endian;
using namespace llvm::COFF; using namespace llvm::COFF;
namespace lld { namespace lld::coff {
namespace coff {
namespace { namespace {
// Import table // Import table
@ -752,5 +751,4 @@ EdataContents::EdataContents() {
chunks.insert(chunks.end(), forwards.begin(), forwards.end()); chunks.insert(chunks.end(), forwards.begin(), forwards.end());
} }
} // namespace coff } // namespace lld::coff
} // namespace lld

View File

@ -12,8 +12,7 @@
#include "Chunks.h" #include "Chunks.h"
#include "Symbols.h" #include "Symbols.h"
namespace lld { namespace lld::coff {
namespace coff {
// Windows-specific. // Windows-specific.
// IdataContents creates all chunks for the DLL import table. // IdataContents creates all chunks for the DLL import table.
@ -76,7 +75,6 @@ public:
} }
}; };
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -953,15 +953,13 @@ public:
}; };
} // namespace } // namespace
namespace lld { namespace lld::coff {
namespace coff {
/// This type is just a wrapper around GHashTable with external linkage so it /// This type is just a wrapper around GHashTable with external linkage so it
/// can be used from a header. /// can be used from a header.
struct GHashState { struct GHashState {
GHashTable table; GHashTable table;
}; };
} // namespace coff } // namespace lld::coff
} // namespace lld
GHashTable::~GHashTable() { delete[] table; } GHashTable::~GHashTable() { delete[] table; }

View File

@ -17,18 +17,15 @@
#include "llvm/Support/Error.h" #include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/MemoryBuffer.h"
namespace llvm { namespace llvm::codeview {
namespace codeview {
struct GloballyHashedType; struct GloballyHashedType;
} // namespace codeview }
namespace pdb { namespace llvm::pdb {
class NativeSession; class NativeSession;
class TpiStream; class TpiStream;
} }
} // namespace llvm
namespace lld { namespace lld::coff {
namespace coff {
using llvm::codeview::GloballyHashedType; using llvm::codeview::GloballyHashedType;
using llvm::codeview::TypeIndex; using llvm::codeview::TypeIndex;
@ -175,7 +172,6 @@ TpiSource *makePrecompSource(COFFLinkerContext &ctx, ObjFile *file);
TpiSource *makeUsePrecompSource(COFFLinkerContext &ctx, ObjFile *file, TpiSource *makeUsePrecompSource(COFFLinkerContext &ctx, ObjFile *file,
llvm::codeview::PrecompRecord ts); llvm::codeview::PrecompRecord ts);
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -58,8 +58,7 @@ using namespace llvm::object;
using namespace llvm::COFF; using namespace llvm::COFF;
using namespace llvm::sys; using namespace llvm::sys;
namespace lld { namespace lld::coff {
namespace coff {
std::unique_ptr<Configuration> config; std::unique_ptr<Configuration> config;
std::unique_ptr<LinkerDriver> driver; std::unique_ptr<LinkerDriver> driver;
@ -2418,5 +2417,4 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
ctx.rootTimer.print(); ctx.rootTimer.print();
} }
} // namespace coff } // namespace lld::coff
} // namespace lld

View File

@ -28,8 +28,7 @@
#include <set> #include <set>
#include <vector> #include <vector>
namespace lld { namespace lld::coff {
namespace coff {
extern std::unique_ptr<class LinkerDriver> driver; extern std::unique_ptr<class LinkerDriver> driver;
@ -234,7 +233,6 @@ enum {
#undef OPTION #undef OPTION
}; };
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -34,8 +34,7 @@
using namespace llvm; using namespace llvm;
namespace lld { namespace lld::coff {
namespace coff {
class ICF { class ICF {
public: public:
@ -322,5 +321,4 @@ void doICF(COFFLinkerContext &ctx, ICFLevel icfLevel) {
ICF(ctx, icfLevel).run(); ICF(ctx, icfLevel).run();
} }
} // namespace coff } // namespace lld::coff
} // namespace lld

View File

@ -13,15 +13,13 @@
#include "lld/Common/LLVM.h" #include "lld/Common/LLVM.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
namespace lld { namespace lld::coff {
namespace coff {
class Chunk; class Chunk;
class COFFLinkerContext; class COFFLinkerContext;
void doICF(COFFLinkerContext &ctx, ICFLevel); void doICF(COFFLinkerContext &ctx, ICFLevel);
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -9,11 +9,9 @@
#ifndef LLD_COFF_LLDMAPFILE_H #ifndef LLD_COFF_LLDMAPFILE_H
#define LLD_COFF_LLDMAPFILE_H #define LLD_COFF_LLDMAPFILE_H
namespace lld { namespace lld::coff {
namespace coff {
class COFFLinkerContext; class COFFLinkerContext;
void writeLLDMapFile(const COFFLinkerContext &ctx); void writeLLDMapFile(const COFFLinkerContext &ctx);
} }
}
#endif #endif

View File

@ -27,14 +27,11 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
namespace llvm { namespace llvm::lto {
namespace lto {
class LTO; class LTO;
} }
}
namespace lld { namespace lld::coff {
namespace coff {
class BitcodeFile; class BitcodeFile;
class InputFile; class InputFile;
@ -56,6 +53,5 @@ private:
llvm::DenseSet<StringRef> thinIndices; llvm::DenseSet<StringRef> thinIndices;
}; };
} }
}
#endif #endif

View File

@ -9,11 +9,9 @@
#ifndef LLD_COFF_MAPFILE_H #ifndef LLD_COFF_MAPFILE_H
#define LLD_COFF_MAPFILE_H #define LLD_COFF_MAPFILE_H
namespace lld { namespace lld::coff {
namespace coff {
class COFFLinkerContext; class COFFLinkerContext;
void writeMapFile(COFFLinkerContext &ctx); void writeMapFile(COFFLinkerContext &ctx);
} }
}
#endif #endif

View File

@ -13,8 +13,7 @@
#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/STLExtras.h"
#include <vector> #include <vector>
namespace lld { namespace lld::coff {
namespace coff {
// Set live bit on for each reachable chunk. Unmarked (unreachable) // Set live bit on for each reachable chunk. Unmarked (unreachable)
// COMDAT chunks will be ignored by Writer, so they will be excluded // COMDAT chunks will be ignored by Writer, so they will be excluded
@ -70,4 +69,3 @@ void markLive(COFFLinkerContext &ctx) {
} }
} }
} }
}

View File

@ -11,14 +11,12 @@
#include "lld/Common/LLVM.h" #include "lld/Common/LLVM.h"
namespace lld { namespace lld::coff {
namespace coff {
class COFFLinkerContext; class COFFLinkerContext;
void markLive(COFFLinkerContext &ctx); void markLive(COFFLinkerContext &ctx);
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif // LLD_COFF_MARKLIVE_H #endif // LLD_COFF_MARKLIVE_H

View File

@ -17,8 +17,7 @@
#include "llvm/Option/ArgList.h" #include "llvm/Option/ArgList.h"
#include <vector> #include <vector>
namespace lld { namespace lld::coff {
namespace coff {
class COFFLinkerContext; class COFFLinkerContext;
// Logic for deciding what symbols to export, when exporting all // Logic for deciding what symbols to export, when exporting all
@ -59,7 +58,6 @@ std::vector<WrappedSymbol> addWrappedSymbols(COFFLinkerContext &ctx,
void wrapSymbols(COFFLinkerContext &ctx, ArrayRef<WrappedSymbol> wrapped); void wrapSymbols(COFFLinkerContext &ctx, ArrayRef<WrappedSymbol> wrapped);
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -13,11 +13,9 @@
#include "llvm/ADT/Optional.h" #include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringRef.h"
namespace llvm { namespace llvm::codeview {
namespace codeview {
union DebugInfo; union DebugInfo;
} }
}
namespace lld { namespace lld {
class Timer; class Timer;

View File

@ -26,8 +26,7 @@
using namespace llvm; using namespace llvm;
namespace lld { namespace lld::coff {
namespace coff {
StringRef ltrim1(StringRef s, const char *chars) { StringRef ltrim1(StringRef s, const char *chars) {
if (!s.empty() && strchr(chars, s[0])) if (!s.empty() && strchr(chars, s[0]))
@ -891,5 +890,4 @@ void SymbolTable::compileBitcodeFiles() {
} }
} }
} // namespace coff } // namespace lld::coff
} // namespace lld

View File

@ -20,8 +20,7 @@ namespace llvm {
struct LTOCodeGenerator; struct LTOCodeGenerator;
} }
namespace lld { namespace lld::coff {
namespace coff {
class Chunk; class Chunk;
class CommonChunk; class CommonChunk;
@ -142,7 +141,6 @@ std::vector<std::string> getSymbolLocations(ObjFile *file, uint32_t symIndex);
StringRef ltrim1(StringRef s, const char *chars); StringRef ltrim1(StringRef s, const char *chars);
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -17,8 +17,7 @@
#include "llvm/Support/Allocator.h" #include "llvm/Support/Allocator.h"
#include <atomic> #include <atomic>
namespace lld { namespace lld::coff {
namespace coff {
using llvm::codeview::GloballyHashedType; using llvm::codeview::GloballyHashedType;
using llvm::codeview::TypeIndex; using llvm::codeview::TypeIndex;
@ -79,7 +78,6 @@ private:
COFFLinkerContext &ctx; COFFLinkerContext &ctx;
}; };
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif

View File

@ -16,8 +16,7 @@
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
namespace lld { namespace lld::coff {
namespace coff {
static const int pageSize = 4096; static const int pageSize = 4096;
class COFFLinkerContext; class COFFLinkerContext;
@ -80,7 +79,6 @@ private:
uint32_t stringTableOff = 0; uint32_t stringTableOff = 0;
}; };
} // namespace coff } // namespace lld::coff
} // namespace lld
#endif #endif