Skip to content

Commit d32f71a

Browse files
committed
[lld][WebAssembly] Use C++17 nested namespace syntax in most places. NFC
Like D131405, but for wasm-ld. Differential Revision: https://reviews.llvm.org/D145399
1 parent 7c2a357 commit d32f71a

17 files changed

+34
-69
lines changed

lld/wasm/Config.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ namespace llvm::CodeGenOpt {
2020
enum Level : int;
2121
} // namespace llvm::CodeGenOpt
2222

23-
namespace lld {
24-
namespace wasm {
23+
namespace lld::wasm {
2524

2625
class InputFile;
2726
class Symbol;
@@ -125,7 +124,6 @@ struct Configuration {
125124
// The only instance of Configuration struct.
126125
extern Configuration *config;
127126

128-
} // namespace wasm
129-
} // namespace lld
127+
} // namespace lld::wasm
130128

131129
#endif

lld/wasm/Driver.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ using namespace llvm::object;
4242
using namespace llvm::sys;
4343
using namespace llvm::wasm;
4444

45-
namespace lld {
46-
namespace wasm {
45+
namespace lld::wasm {
4746
Configuration *config;
4847

4948
namespace {
@@ -1218,5 +1217,4 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
12181217
writeResult();
12191218
}
12201219

1221-
} // namespace wasm
1222-
} // namespace lld
1220+
} // namespace wasm::lld

lld/wasm/LTO.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737

3838
using namespace llvm;
3939

40-
namespace lld {
41-
namespace wasm {
40+
namespace lld::wasm {
4241
static std::unique_ptr<lto::LTO> createLTO() {
4342
lto::Config c;
4443
c.Options = initTargetOptionsFromCodeGenFlags();
@@ -165,5 +164,4 @@ std::vector<StringRef> BitcodeCompiler::compile() {
165164
return ret;
166165
}
167166

168-
} // namespace wasm
169-
} // namespace lld
167+
} // namespace lld::wasm

lld/wasm/LTO.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class LTO;
3232
}
3333
} // namespace llvm
3434

35-
namespace lld {
36-
namespace wasm {
35+
namespace lld::wasm {
3736

3837
class BitcodeFile;
3938
class InputFile;
@@ -51,7 +50,6 @@ class BitcodeCompiler {
5150
std::vector<SmallString<0>> buf;
5251
std::vector<std::unique_ptr<MemoryBuffer>> files;
5352
};
54-
} // namespace wasm
55-
} // namespace lld
53+
} // namespace lld::wasm
5654

5755
#endif

lld/wasm/MapFile.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111

1212
#include "llvm/ADT/ArrayRef.h"
1313

14-
namespace lld {
15-
namespace wasm {
14+
namespace lld::wasm {
1615
class OutputSection;
1716
void writeMapFile(llvm::ArrayRef<OutputSection *> outputSections);
18-
} // namespace wasm
19-
} // namespace lld
17+
} // namespace lld::wasm
2018

2119
#endif

lld/wasm/MarkLive.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
using namespace llvm;
3131
using namespace llvm::wasm;
3232

33-
namespace lld {
34-
namespace wasm {
33+
namespace lld::wasm {
3534

3635
namespace {
3736

@@ -205,5 +204,4 @@ bool MarkLive::isCallCtorsLive() {
205204
return false;
206205
}
207206

208-
} // namespace wasm
209-
} // namespace lld
207+
} // namespace lld::wasm

lld/wasm/MarkLive.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
#ifndef LLD_WASM_MARKLIVE_H
1010
#define LLD_WASM_MARKLIVE_H
1111

12-
namespace lld {
13-
namespace wasm {
12+
namespace lld::wasm {
1413

1514
void markLive();
1615

17-
} // namespace wasm
18-
} // namespace lld
16+
} // namespace lld::wasm
1917

2018
#endif // LLD_WASM_MARKLIVE_H

lld/wasm/OutputSegment.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
using namespace llvm;
1616
using namespace llvm::wasm;
1717

18-
namespace lld {
19-
20-
namespace wasm {
18+
namespace lld::wasm {
2119

2220
void OutputSegment::addInputSegment(InputChunk *inSeg) {
2321
alignment = std::max(alignment, inSeg->alignment);
@@ -82,5 +80,4 @@ void OutputSegment::finalizeInputSegments() {
8280
}
8381
}
8482

85-
} // namespace wasm
86-
} // namespace lld
83+
} // namespace lld::wasm

lld/wasm/OutputSegment.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#include "lld/Common/ErrorHandler.h"
1414
#include "llvm/Object/Wasm.h"
1515

16-
namespace lld {
17-
namespace wasm {
16+
namespace lld::wasm {
1817

1918
class InputSegment;
2019

@@ -49,7 +48,6 @@ class OutputSegment {
4948
std::string header;
5049
};
5150

52-
} // namespace wasm
53-
} // namespace lld
51+
} // namespace lld::wasm
5452

5553
#endif // LLD_WASM_OUTPUT_SEGMENT_H

lld/wasm/Relocations.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
using namespace llvm;
1717
using namespace llvm::wasm;
1818

19-
namespace lld {
20-
namespace wasm {
19+
namespace lld::wasm {
2120

2221
static bool requiresGOTAccess(const Symbol *sym) {
2322
if (!config->isPic &&
@@ -176,5 +175,4 @@ void scanRelocations(InputChunk *chunk) {
176175
}
177176
}
178177

179-
} // namespace wasm
180-
} // namespace lld
178+
} // namespace lld::wasm

lld/wasm/Relocations.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
#ifndef LLD_WASM_RELOCATIONS_H
1010
#define LLD_WASM_RELOCATIONS_H
1111

12-
namespace lld {
13-
namespace wasm {
12+
namespace lld::wasm {
1413

1514
class InputChunk;
1615

1716
void scanRelocations(InputChunk *chunk);
1817

19-
} // namespace wasm
20-
} // namespace lld
18+
} // namespace lld::wasm
2119

2220
#endif

lld/wasm/SymbolTable.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ using namespace llvm;
2020
using namespace llvm::wasm;
2121
using namespace llvm::object;
2222

23-
namespace lld {
24-
namespace wasm {
23+
namespace lld::wasm {
2524
SymbolTable *symtab;
2625

2726
void SymbolTable::addFile(InputFile *file) {
@@ -966,5 +965,4 @@ void SymbolTable::handleSymbolVariants() {
966965
}
967966
}
968967

969-
} // namespace wasm
970-
} // namespace lld
968+
} // namespace wasm::lld

lld/wasm/SymbolTable.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
#include "llvm/BinaryFormat/WasmTraits.h"
1919
#include <optional>
2020

21-
namespace lld {
22-
namespace wasm {
21+
namespace lld::wasm {
2322

2423
class InputSegment;
2524

@@ -144,7 +143,6 @@ class SymbolTable {
144143

145144
extern SymbolTable *symtab;
146145

147-
} // namespace wasm
148-
} // namespace lld
146+
} // namespace lld::wasm
149147

150148
#endif

lld/wasm/SyntheticSections.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
using namespace llvm;
2323
using namespace llvm::wasm;
2424

25-
namespace lld {
26-
namespace wasm {
25+
namespace lld::wasm {
2726

2827
OutStruct out;
2928

@@ -922,5 +921,4 @@ void BuildIdSection::writeBuildId(llvm::ArrayRef<uint8_t> buf) {
922921
memcpy(hashPlaceholderPtr, buf.data(), hashSize);
923922
}
924923

925-
} // namespace wasm
926-
} // namespace lld
924+
} // namespace wasm::lld

lld/wasm/SyntheticSections.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@
2424

2525
#define DEBUG_TYPE "lld"
2626

27-
namespace lld {
28-
namespace wasm {
27+
namespace lld::wasm {
2928

3029
// An init entry to be written to either the synthetic init func or the
3130
// linking metadata.
@@ -127,8 +126,7 @@ inline bool operator==(const ImportKey<T> &lhs, const ImportKey<T> &rhs) {
127126
lhs.importName == rhs.importName && lhs.type == rhs.type;
128127
}
129128

130-
} // namespace wasm
131-
} // namespace lld
129+
} // namespace wasm::lld
132130

133131
// `ImportKey<T>` can be used as a key in a `DenseMap` if `T` can be used as a
134132
// key in a `DenseMap`.

lld/wasm/Writer.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545
using namespace llvm;
4646
using namespace llvm::wasm;
4747

48-
namespace lld {
49-
namespace wasm {
48+
namespace lld::wasm {
5049
static constexpr int stackAlignment = 16;
5150
static constexpr int heapAlignment = 16;
5251

@@ -1865,5 +1864,4 @@ void Writer::createHeader() {
18651864

18661865
void writeResult() { Writer().run(); }
18671866

1868-
} // namespace wasm
1869-
} // namespace lld
1867+
} // namespace wasm::lld

lld/wasm/Writer.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@
99
#ifndef LLD_WASM_WRITER_H
1010
#define LLD_WASM_WRITER_H
1111

12-
namespace lld {
13-
namespace wasm {
12+
namespace lld::wasm {
1413

1514
void writeResult();
1615

17-
} // namespace wasm
18-
} // namespace lld
16+
} // namespace lld::wasm
1917

2018
#endif

0 commit comments

Comments
 (0)