[lld] 7c26641 - [lld/win] Use C++17 nested namespace syntax in most places
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 08:48:21 PDT 2022
Author: Nico Weber
Date: 2022-08-08T11:48:12-04:00
New Revision: 7c26641d9dcea70a75ca48d2e3a5bf6ca7a925bb
URL: https://github.com/llvm/llvm-project/commit/7c26641d9dcea70a75ca48d2e3a5bf6ca7a925bb
DIFF: https://github.com/llvm/llvm-project/commit/7c26641d9dcea70a75ca48d2e3a5bf6ca7a925bb.diff
LOG: [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
Added:
Modified:
lld/COFF/COFFLinkerContext.cpp
lld/COFF/COFFLinkerContext.h
lld/COFF/CallGraphSort.h
lld/COFF/Chunks.cpp
lld/COFF/Chunks.h
lld/COFF/Config.h
lld/COFF/DLL.cpp
lld/COFF/DLL.h
lld/COFF/DebugTypes.cpp
lld/COFF/DebugTypes.h
lld/COFF/Driver.cpp
lld/COFF/Driver.h
lld/COFF/ICF.cpp
lld/COFF/ICF.h
lld/COFF/LLDMapFile.h
lld/COFF/LTO.h
lld/COFF/MapFile.h
lld/COFF/MarkLive.cpp
lld/COFF/MarkLive.h
lld/COFF/MinGW.h
lld/COFF/PDB.h
lld/COFF/SymbolTable.cpp
lld/COFF/SymbolTable.h
lld/COFF/TypeMerger.h
lld/COFF/Writer.h
Removed:
################################################################################
diff --git a/lld/COFF/COFFLinkerContext.cpp b/lld/COFF/COFFLinkerContext.cpp
index a280cacb932e..cd497903f183 100644
--- a/lld/COFF/COFFLinkerContext.cpp
+++ b/lld/COFF/COFFLinkerContext.cpp
@@ -13,8 +13,7 @@
#include "lld/Common/Memory.h"
#include "llvm/DebugInfo/CodeView/TypeHashing.h"
-namespace lld {
-namespace coff {
+namespace lld::coff {
COFFLinkerContext::COFFLinkerContext()
: symtab(*this), rootTimer("Total Linking Time"),
@@ -36,5 +35,4 @@ COFFLinkerContext::COFFLinkerContext()
tpiStreamLayoutTimer("TPI Stream Layout", totalPdbLinkTimer),
diskCommitTimer("Commit to Disk", totalPdbLinkTimer) {}
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
diff --git a/lld/COFF/COFFLinkerContext.h b/lld/COFF/COFFLinkerContext.h
index a3a6f94a9413..96b4de436398 100644
--- a/lld/COFF/COFFLinkerContext.h
+++ b/lld/COFF/COFFLinkerContext.h
@@ -18,8 +18,7 @@
#include "lld/Common/CommonLinkerContext.h"
#include "lld/Common/Timer.h"
-namespace lld {
-namespace coff {
+namespace lld::coff {
class COFFLinkerContext : public CommonLinkerContext {
public:
@@ -80,7 +79,6 @@ class COFFLinkerContext : public CommonLinkerContext {
Timer diskCommitTimer;
};
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/CallGraphSort.h b/lld/COFF/CallGraphSort.h
index 99f35d6b6276..60f2941d37a8 100644
--- a/lld/COFF/CallGraphSort.h
+++ b/lld/COFF/CallGraphSort.h
@@ -11,14 +11,12 @@
#include "llvm/ADT/DenseMap.h"
-namespace lld {
-namespace coff {
+namespace lld::coff {
class SectionChunk;
class COFFLinkerContext;
llvm::DenseMap<const SectionChunk *, int>
computeCallGraphProfileOrder(const COFFLinkerContext &ctx);
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/Chunks.cpp b/lld/COFF/Chunks.cpp
index 3cdbd6c0337b..a029b0145146 100644
--- a/lld/COFF/Chunks.cpp
+++ b/lld/COFF/Chunks.cpp
@@ -27,8 +27,7 @@ using namespace llvm::support::endian;
using namespace llvm::COFF;
using llvm::support::ulittle32_t;
-namespace lld {
-namespace coff {
+namespace lld::coff {
SectionChunk::SectionChunk(ObjFile *f, const coff_section *h)
: Chunk(SectionKind), file(f), header(h), repl(this) {
@@ -996,5 +995,4 @@ void AbsolutePointerChunk::writeTo(uint8_t *buf) const {
}
}
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
diff --git a/lld/COFF/Chunks.h b/lld/COFF/Chunks.h
index daaa043fface..af3f2d570483 100644
--- a/lld/COFF/Chunks.h
+++ b/lld/COFF/Chunks.h
@@ -21,8 +21,7 @@
#include <utility>
#include <vector>
-namespace lld {
-namespace coff {
+namespace lld::coff {
using llvm::COFF::ImportDirectoryTableEntry;
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 applyArm64Branch26(uint8_t *off, int64_t v);
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
namespace llvm {
template <>
diff --git a/lld/COFF/Config.h b/lld/COFF/Config.h
index dd089f5ab671..a5ee070d13dc 100644
--- a/lld/COFF/Config.h
+++ b/lld/COFF/Config.h
@@ -21,8 +21,7 @@
#include <set>
#include <string>
-namespace lld {
-namespace coff {
+namespace lld::coff {
using llvm::COFF::IMAGE_FILE_MACHINE_UNKNOWN;
using llvm::COFF::WindowsSubsystem;
@@ -289,7 +288,6 @@ struct Configuration {
extern std::unique_ptr<Configuration> config;
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/DLL.cpp b/lld/COFF/DLL.cpp
index 42a5a41f87ae..5537b142a3ea 100644
--- a/lld/COFF/DLL.cpp
+++ b/lld/COFF/DLL.cpp
@@ -31,8 +31,7 @@ using namespace llvm::object;
using namespace llvm::support::endian;
using namespace llvm::COFF;
-namespace lld {
-namespace coff {
+namespace lld::coff {
namespace {
// Import table
@@ -752,5 +751,4 @@ EdataContents::EdataContents() {
chunks.insert(chunks.end(), forwards.begin(), forwards.end());
}
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
diff --git a/lld/COFF/DLL.h b/lld/COFF/DLL.h
index 0d594e675bd2..a5de351897d2 100644
--- a/lld/COFF/DLL.h
+++ b/lld/COFF/DLL.h
@@ -12,8 +12,7 @@
#include "Chunks.h"
#include "Symbols.h"
-namespace lld {
-namespace coff {
+namespace lld::coff {
// Windows-specific.
// IdataContents creates all chunks for the DLL import table.
@@ -76,7 +75,6 @@ class EdataContents {
}
};
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index a92470e03748..d75833da8dd0 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -953,15 +953,13 @@ class GHashCell {
};
} // namespace
-namespace lld {
-namespace coff {
+namespace lld::coff {
/// This type is just a wrapper around GHashTable with external linkage so it
/// can be used from a header.
struct GHashState {
GHashTable table;
};
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
GHashTable::~GHashTable() { delete[] table; }
diff --git a/lld/COFF/DebugTypes.h b/lld/COFF/DebugTypes.h
index b02b5b884cf7..c3f2c5801200 100644
--- a/lld/COFF/DebugTypes.h
+++ b/lld/COFF/DebugTypes.h
@@ -17,18 +17,15 @@
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"
-namespace llvm {
-namespace codeview {
+namespace llvm::codeview {
struct GloballyHashedType;
-} // namespace codeview
-namespace pdb {
+}
+namespace llvm::pdb {
class NativeSession;
class TpiStream;
}
-} // namespace llvm
-namespace lld {
-namespace coff {
+namespace lld::coff {
using llvm::codeview::GloballyHashedType;
using llvm::codeview::TypeIndex;
@@ -175,7 +172,6 @@ TpiSource *makePrecompSource(COFFLinkerContext &ctx, ObjFile *file);
TpiSource *makeUsePrecompSource(COFFLinkerContext &ctx, ObjFile *file,
llvm::codeview::PrecompRecord ts);
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/Driver.cpp b/lld/COFF/Driver.cpp
index fac5e2f58f58..1e080b190027 100644
--- a/lld/COFF/Driver.cpp
+++ b/lld/COFF/Driver.cpp
@@ -58,8 +58,7 @@ using namespace llvm::object;
using namespace llvm::COFF;
using namespace llvm::sys;
-namespace lld {
-namespace coff {
+namespace lld::coff {
std::unique_ptr<Configuration> config;
std::unique_ptr<LinkerDriver> driver;
@@ -2418,5 +2417,4 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
ctx.rootTimer.print();
}
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
diff --git a/lld/COFF/Driver.h b/lld/COFF/Driver.h
index 162517340e80..64334ad1d982 100644
--- a/lld/COFF/Driver.h
+++ b/lld/COFF/Driver.h
@@ -28,8 +28,7 @@
#include <set>
#include <vector>
-namespace lld {
-namespace coff {
+namespace lld::coff {
extern std::unique_ptr<class LinkerDriver> driver;
@@ -234,7 +233,6 @@ enum {
#undef OPTION
};
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/ICF.cpp b/lld/COFF/ICF.cpp
index 49546ea8bdc2..f001225b7834 100644
--- a/lld/COFF/ICF.cpp
+++ b/lld/COFF/ICF.cpp
@@ -34,8 +34,7 @@
using namespace llvm;
-namespace lld {
-namespace coff {
+namespace lld::coff {
class ICF {
public:
@@ -322,5 +321,4 @@ void doICF(COFFLinkerContext &ctx, ICFLevel icfLevel) {
ICF(ctx, icfLevel).run();
}
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
diff --git a/lld/COFF/ICF.h b/lld/COFF/ICF.h
index 10e6792a5418..8aafdf7b2335 100644
--- a/lld/COFF/ICF.h
+++ b/lld/COFF/ICF.h
@@ -13,15 +13,13 @@
#include "lld/Common/LLVM.h"
#include "llvm/ADT/ArrayRef.h"
-namespace lld {
-namespace coff {
+namespace lld::coff {
class Chunk;
class COFFLinkerContext;
void doICF(COFFLinkerContext &ctx, ICFLevel);
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/LLDMapFile.h b/lld/COFF/LLDMapFile.h
index 72e999a61900..7cbc21fca5fc 100644
--- a/lld/COFF/LLDMapFile.h
+++ b/lld/COFF/LLDMapFile.h
@@ -9,11 +9,9 @@
#ifndef LLD_COFF_LLDMAPFILE_H
#define LLD_COFF_LLDMAPFILE_H
-namespace lld {
-namespace coff {
+namespace lld::coff {
class COFFLinkerContext;
void writeLLDMapFile(const COFFLinkerContext &ctx);
}
-}
#endif
diff --git a/lld/COFF/LTO.h b/lld/COFF/LTO.h
index b05befc7146a..2cc4c7c5ea1e 100644
--- a/lld/COFF/LTO.h
+++ b/lld/COFF/LTO.h
@@ -27,14 +27,11 @@
#include <memory>
#include <vector>
-namespace llvm {
-namespace lto {
+namespace llvm::lto {
class LTO;
}
-}
-namespace lld {
-namespace coff {
+namespace lld::coff {
class BitcodeFile;
class InputFile;
@@ -56,6 +53,5 @@ class BitcodeCompiler {
llvm::DenseSet<StringRef> thinIndices;
};
}
-}
#endif
diff --git a/lld/COFF/MapFile.h b/lld/COFF/MapFile.h
index d4572332b8b8..de1e99017423 100644
--- a/lld/COFF/MapFile.h
+++ b/lld/COFF/MapFile.h
@@ -9,11 +9,9 @@
#ifndef LLD_COFF_MAPFILE_H
#define LLD_COFF_MAPFILE_H
-namespace lld {
-namespace coff {
+namespace lld::coff {
class COFFLinkerContext;
void writeMapFile(COFFLinkerContext &ctx);
}
-}
#endif
diff --git a/lld/COFF/MarkLive.cpp b/lld/COFF/MarkLive.cpp
index f53005278e22..89a3394d7d03 100644
--- a/lld/COFF/MarkLive.cpp
+++ b/lld/COFF/MarkLive.cpp
@@ -13,8 +13,7 @@
#include "llvm/ADT/STLExtras.h"
#include <vector>
-namespace lld {
-namespace coff {
+namespace lld::coff {
// Set live bit on for each reachable chunk. Unmarked (unreachable)
// COMDAT chunks will be ignored by Writer, so they will be excluded
@@ -70,4 +69,3 @@ void markLive(COFFLinkerContext &ctx) {
}
}
}
-}
diff --git a/lld/COFF/MarkLive.h b/lld/COFF/MarkLive.h
index 6f211487236c..8382223d41a5 100644
--- a/lld/COFF/MarkLive.h
+++ b/lld/COFF/MarkLive.h
@@ -11,14 +11,12 @@
#include "lld/Common/LLVM.h"
-namespace lld {
-namespace coff {
+namespace lld::coff {
class COFFLinkerContext;
void markLive(COFFLinkerContext &ctx);
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif // LLD_COFF_MARKLIVE_H
diff --git a/lld/COFF/MinGW.h b/lld/COFF/MinGW.h
index 8f9343784fa0..59c2581f661d 100644
--- a/lld/COFF/MinGW.h
+++ b/lld/COFF/MinGW.h
@@ -17,8 +17,7 @@
#include "llvm/Option/ArgList.h"
#include <vector>
-namespace lld {
-namespace coff {
+namespace lld::coff {
class COFFLinkerContext;
// 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);
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/PDB.h b/lld/COFF/PDB.h
index 8381374dcc8a..9fd41fc5cdc2 100644
--- a/lld/COFF/PDB.h
+++ b/lld/COFF/PDB.h
@@ -13,11 +13,9 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringRef.h"
-namespace llvm {
-namespace codeview {
+namespace llvm::codeview {
union DebugInfo;
}
-}
namespace lld {
class Timer;
diff --git a/lld/COFF/SymbolTable.cpp b/lld/COFF/SymbolTable.cpp
index 9bd93a2ff1a7..6ae2cb861bf7 100644
--- a/lld/COFF/SymbolTable.cpp
+++ b/lld/COFF/SymbolTable.cpp
@@ -26,8 +26,7 @@
using namespace llvm;
-namespace lld {
-namespace coff {
+namespace lld::coff {
StringRef ltrim1(StringRef s, const char *chars) {
if (!s.empty() && strchr(chars, s[0]))
@@ -891,5 +890,4 @@ void SymbolTable::compileBitcodeFiles() {
}
}
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
diff --git a/lld/COFF/SymbolTable.h b/lld/COFF/SymbolTable.h
index 47f3238fd75b..167377ef3bc4 100644
--- a/lld/COFF/SymbolTable.h
+++ b/lld/COFF/SymbolTable.h
@@ -20,8 +20,7 @@ namespace llvm {
struct LTOCodeGenerator;
}
-namespace lld {
-namespace coff {
+namespace lld::coff {
class Chunk;
class CommonChunk;
@@ -142,7 +141,6 @@ std::vector<std::string> getSymbolLocations(ObjFile *file, uint32_t symIndex);
StringRef ltrim1(StringRef s, const char *chars);
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/TypeMerger.h b/lld/COFF/TypeMerger.h
index 838db691a822..17f019758e82 100644
--- a/lld/COFF/TypeMerger.h
+++ b/lld/COFF/TypeMerger.h
@@ -17,8 +17,7 @@
#include "llvm/Support/Allocator.h"
#include <atomic>
-namespace lld {
-namespace coff {
+namespace lld::coff {
using llvm::codeview::GloballyHashedType;
using llvm::codeview::TypeIndex;
@@ -79,7 +78,6 @@ class TypeMerger {
COFFLinkerContext &ctx;
};
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
diff --git a/lld/COFF/Writer.h b/lld/COFF/Writer.h
index d2b3b4b81d3c..d2c05e4ae0b5 100644
--- a/lld/COFF/Writer.h
+++ b/lld/COFF/Writer.h
@@ -16,8 +16,7 @@
#include <cstdint>
#include <vector>
-namespace lld {
-namespace coff {
+namespace lld::coff {
static const int pageSize = 4096;
class COFFLinkerContext;
@@ -80,7 +79,6 @@ class OutputSection {
uint32_t stringTableOff = 0;
};
-} // namespace coff
-} // namespace lld
+} // namespace lld::coff
#endif
More information about the llvm-commits
mailing list