Skip to content

Commit bf20d43

Browse files
committed
[lld/mac] Use C++17 nested namespace syntax in most places
Some header files used namespace lld { namespace macho { // ... } // namespace macho std::string toString(const Type &t); } // namespace lld In those files, I didn't use a nested namespace since it's not a big win there. No behavior change. Differential Revision: https://reviews.llvm.org/D131354
1 parent ab4fc87 commit bf20d43

22 files changed

+46
-94
lines changed

lld/MachO/Arch/ARM64Common.h

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

1717
#include "llvm/BinaryFormat/MachO.h"
1818

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

2221
struct ARM64Common : TargetInfo {
2322
template <class LP> ARM64Common(LP lp) : TargetInfo(lp) {}
@@ -148,7 +147,6 @@ inline void writeStubHelperEntry(uint8_t *buf8,
148147
buf32[2] = sym.lazyBindOffset;
149148
}
150149

151-
} // namespace macho
152-
} // namespace lld
150+
} // namespace lld::macho
153151

154152
#endif

lld/MachO/ConcatOutputSection.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
#include "llvm/ADT/DenseMap.h"
1616
#include "llvm/ADT/MapVector.h"
1717

18-
namespace lld {
19-
namespace macho {
18+
namespace lld::macho {
2019

2120
class Defined;
2221

@@ -109,7 +108,6 @@ extern llvm::MapVector<NamePair, ConcatOutputSection *> concatOutputSections;
109108

110109
extern llvm::DenseMap<Symbol *, ThunkInfo> thunkMap;
111110

112-
} // namespace macho
113-
} // namespace lld
111+
} // namespace lld::macho
114112

115113
#endif

lld/MachO/Driver.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
#include <set>
2121
#include <type_traits>
2222

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

2625
class DylibFile;
2726
class InputFile;
@@ -111,7 +110,6 @@ class DependencyTracker {
111110

112111
extern std::unique_ptr<DependencyTracker> depTracker;
113112

114-
} // namespace macho
115-
} // namespace lld
113+
} // namespace lld::macho
116114

117115
#endif

lld/MachO/Dwarf.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include "llvm/ADT/StringRef.h"
1313
#include "llvm/DebugInfo/DWARF/DWARFObject.h"
1414

15-
namespace lld {
16-
namespace macho {
15+
namespace lld::macho {
1716

1817
class ObjFile;
1918

@@ -57,7 +56,6 @@ class DwarfObject final : public llvm::DWARFObject {
5756
llvm::StringRef strSection;
5857
};
5958

60-
} // namespace macho
61-
} // namespace lld
59+
} // namespace lld::macho
6260

6361
#endif

lld/MachO/EhFrame.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
* 5. (Optional) LSDA address (pointer-sized pcrel offset)
5151
* 6. DWARF instructions (ignored by LLD)
5252
*/
53-
namespace lld {
54-
namespace macho {
53+
namespace lld::macho {
5554

5655
class EhReader {
5756
public:
@@ -112,7 +111,6 @@ class EhRelocator {
112111
SmallVector<Reloc, 6> newRelocs;
113112
};
114113

115-
} // namespace macho
116-
} // namespace lld
114+
} // namespace lld::macho
117115

118116
#endif

lld/MachO/ExportTrie.h

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

1515
#include <vector>
1616

17-
namespace lld {
18-
namespace macho {
17+
namespace lld::macho {
1918

2019
struct TrieNode;
2120
class Symbol;
@@ -44,7 +43,6 @@ using TrieEntryCallback =
4443

4544
void parseTrie(const uint8_t *buf, size_t size, const TrieEntryCallback &);
4645

47-
} // namespace macho
48-
} // namespace lld
46+
} // namespace lld::macho
4947

5048
#endif

lld/MachO/ICF.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,13 @@
1313
#include "lld/Common/LLVM.h"
1414
#include <vector>
1515

16-
namespace lld {
17-
namespace macho {
16+
namespace lld::macho {
1817
class Symbol;
1918

2019
void markAddrSigSymbols();
2120
void markSymAsAddrSig(Symbol *s);
2221
void foldIdenticalSections(bool onlyCfStrings);
2322

24-
} // namespace macho
25-
} // namespace lld
23+
} // namespace lld::macho
2624

2725
#endif

lld/MachO/LTO.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,11 @@
1414
#include <memory>
1515
#include <vector>
1616

17-
namespace llvm {
18-
namespace lto {
17+
namespace llvm::lto {
1918
class LTO;
20-
} // namespace lto
21-
} // namespace llvm
19+
} // namespace llvm::lto
2220

23-
namespace lld {
24-
namespace macho {
21+
namespace lld::macho {
2522

2623
class BitcodeFile;
2724
class ObjFile;
@@ -39,7 +36,6 @@ class BitcodeCompiler {
3936
std::vector<std::unique_ptr<llvm::MemoryBuffer>> files;
4037
};
4138

42-
} // namespace macho
43-
} // namespace lld
39+
} // namespace lld::macho
4440

4541
#endif

lld/MachO/MachOStructs.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717

1818
#include "llvm/Support/Endian.h"
1919

20-
namespace lld {
21-
22-
namespace structs {
20+
namespace lld::structs {
2321

2422
struct nlist_64 {
2523
llvm::support::ulittle32_t n_strx;
@@ -44,8 +42,6 @@ struct entry_point_command {
4442
llvm::support::ulittle64_t stacksize;
4543
};
4644

47-
} // namespace structs
48-
49-
} // namespace lld
45+
} // namespace lld::structs
5046

5147
#endif

lld/MachO/MapFile.h

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

12-
namespace lld {
13-
namespace macho {
12+
namespace lld::macho {
1413
void writeMapFile();
15-
} // namespace macho
16-
} // namespace lld
14+
} // namespace lld::macho
1715

1816
#endif

lld/MachO/MarkLive.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
#include "mach-o/compact_unwind_encoding.h"
1616
#include "llvm/Support/TimeProfiler.h"
1717

18-
namespace lld {
19-
namespace macho {
18+
namespace lld::macho {
2019

2120
using namespace llvm;
2221
using namespace llvm::MachO;
@@ -288,5 +287,4 @@ void markLive() {
288287
marker->markTransitively();
289288
}
290289

291-
} // namespace macho
292-
} // namespace lld
290+
} // namespace lld::macho

lld/MachO/MarkLive.h

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

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

1514
void markLive();
1615

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

2018
#endif // LLD_MACHO_MARKLIVE_H

lld/MachO/ObjC.h

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

1212
#include "llvm/Support/MemoryBuffer.h"
1313

14-
namespace lld {
15-
namespace macho {
14+
namespace lld::macho {
1615

1716
namespace objc {
1817

@@ -25,7 +24,6 @@ constexpr const char ivar[] = "_OBJC_IVAR_$_";
2524

2625
bool hasObjCSection(llvm::MemoryBufferRef);
2726

28-
} // namespace macho
29-
} // namespace lld
27+
} // namespace lld::macho
3028

3129
#endif

lld/MachO/OutputSection.h

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

1717
#include <limits>
1818

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

2221
class Defined;
2322
class InputSection;
@@ -98,7 +97,6 @@ class OutputSection {
9897
Kind sectionKind;
9998
};
10099

101-
} // namespace macho
102-
} // namespace lld
100+
} // namespace lld::macho
103101

104102
#endif

lld/MachO/OutputSegment.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#include <limits>
1818
#include <vector>
1919

20-
namespace lld {
21-
namespace macho {
20+
namespace lld::macho {
2221

2322
namespace segment_names {
2423

@@ -72,7 +71,6 @@ void resetOutputSegments();
7271

7372
OutputSegment *getOrCreateOutputSegment(StringRef name);
7473

75-
} // namespace macho
76-
} // namespace lld
74+
} // namespace lld::macho
7775

7876
#endif

lld/MachO/Relocations.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#include <cstddef>
1818
#include <cstdint>
1919

20-
namespace lld {
21-
namespace macho {
20+
namespace lld::macho {
2221
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
2322

2423
class Symbol;
@@ -124,7 +123,6 @@ inline void writeAddress(uint8_t *loc, uint64_t addr, uint8_t length) {
124123

125124
extern const RelocAttrs invalidRelocAttrs;
126125

127-
} // namespace macho
128-
} // namespace lld
126+
} // namespace lld::Macho
129127

130128
#endif

lld/MachO/SectionPriorities.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
#include "InputSection.h"
1313
#include "llvm/ADT/DenseMap.h"
1414

15-
namespace lld {
16-
namespace macho {
15+
namespace lld::macho {
1716

1817
using SectionPair = std::pair<const InputSection *, const InputSection *>;
1918

@@ -76,7 +75,6 @@ class PriorityBuilder {
7675
};
7776

7877
extern PriorityBuilder priorityBuilder;
79-
} // namespace macho
80-
} // namespace lld
78+
} // namespace lld::macho
8179

8280
#endif

lld/MachO/SymbolTable.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
#include "llvm/ADT/DenseMap.h"
1717
#include "llvm/Object/Archive.h"
1818

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

2221
class ArchiveFile;
2322
class DylibFile;
@@ -80,7 +79,6 @@ void treatUndefinedSymbol(const Undefined &, const InputSection *,
8079

8180
extern std::unique_ptr<SymbolTable> symtab;
8281

83-
} // namespace macho
84-
} // namespace lld
82+
} // namespace lld::macho
8583

8684
#endif

lld/MachO/SyntheticSections.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ namespace llvm {
3131
class DWARFUnit;
3232
} // namespace llvm
3333

34-
namespace lld {
35-
namespace macho {
34+
namespace lld::macho {
3635

3736
class Defined;
3837
class DylibSymbol;
@@ -645,7 +644,6 @@ extern std::vector<SyntheticSection *> syntheticSections;
645644

646645
void createSyntheticSymbols();
647646

648-
} // namespace macho
649-
} // namespace lld
647+
} // namespace lld::macho
650648

651649
#endif

lld/MachO/Target.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
#include <cstddef>
2121
#include <cstdint>
2222

23-
namespace lld {
24-
namespace macho {
23+
namespace lld::macho {
2524
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
2625

2726
class Symbol;
@@ -164,7 +163,6 @@ struct ILP32 {
164163

165164
extern TargetInfo *target;
166165

167-
} // namespace macho
168-
} // namespace lld
166+
} // namespace lld::macho
169167

170168
#endif

lld/MachO/UnwindInfoSection.h

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

1616
#include "mach-o/compact_unwind_encoding.h"
1717

18-
namespace lld {
19-
namespace macho {
18+
namespace lld::macho {
2019

2120
class UnwindInfoSection : public SyntheticSection {
2221
public:
@@ -37,7 +36,6 @@ class UnwindInfoSection : public SyntheticSection {
3736

3837
UnwindInfoSection *makeUnwindInfoSection();
3938

40-
} // namespace macho
41-
} // namespace lld
39+
} // namespace lld::macho
4240

4341
#endif

0 commit comments

Comments
 (0)