[lld] bf20d43 - [lld/mac] Use C++17 nested namespace syntax in most places
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 8 04:11:42 PDT 2022
Author: Nico Weber
Date: 2022-08-08T07:11:17-04:00
New Revision: bf20d43f8263b1df43c26a2ac9fec7220bcb735e
URL: https://github.com/llvm/llvm-project/commit/bf20d43f8263b1df43c26a2ac9fec7220bcb735e
DIFF: https://github.com/llvm/llvm-project/commit/bf20d43f8263b1df43c26a2ac9fec7220bcb735e.diff
LOG: [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
Added:
Modified:
lld/MachO/Arch/ARM64Common.h
lld/MachO/ConcatOutputSection.h
lld/MachO/Driver.h
lld/MachO/Dwarf.h
lld/MachO/EhFrame.h
lld/MachO/ExportTrie.h
lld/MachO/ICF.h
lld/MachO/LTO.h
lld/MachO/MachOStructs.h
lld/MachO/MapFile.h
lld/MachO/MarkLive.cpp
lld/MachO/MarkLive.h
lld/MachO/ObjC.h
lld/MachO/OutputSection.h
lld/MachO/OutputSegment.h
lld/MachO/Relocations.h
lld/MachO/SectionPriorities.h
lld/MachO/SymbolTable.h
lld/MachO/SyntheticSections.h
lld/MachO/Target.h
lld/MachO/UnwindInfoSection.h
lld/MachO/Writer.h
Removed:
################################################################################
diff --git a/lld/MachO/Arch/ARM64Common.h b/lld/MachO/Arch/ARM64Common.h
index 1bd85066b35a8..8b75a5f3160d0 100644
--- a/lld/MachO/Arch/ARM64Common.h
+++ b/lld/MachO/Arch/ARM64Common.h
@@ -16,8 +16,7 @@
#include "llvm/BinaryFormat/MachO.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
struct ARM64Common : TargetInfo {
template <class LP> ARM64Common(LP lp) : TargetInfo(lp) {}
@@ -148,7 +147,6 @@ inline void writeStubHelperEntry(uint8_t *buf8,
buf32[2] = sym.lazyBindOffset;
}
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/ConcatOutputSection.h b/lld/MachO/ConcatOutputSection.h
index c7404f48e27a3..9af661d0ab1e0 100644
--- a/lld/MachO/ConcatOutputSection.h
+++ b/lld/MachO/ConcatOutputSection.h
@@ -15,8 +15,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/MapVector.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
class Defined;
@@ -109,7 +108,6 @@ extern llvm::MapVector<NamePair, ConcatOutputSection *> concatOutputSections;
extern llvm::DenseMap<Symbol *, ThunkInfo> thunkMap;
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h
index 355816272f87d..7249fe3b45203 100644
--- a/lld/MachO/Driver.h
+++ b/lld/MachO/Driver.h
@@ -20,8 +20,7 @@
#include <set>
#include <type_traits>
-namespace lld {
-namespace macho {
+namespace lld::macho {
class DylibFile;
class InputFile;
@@ -111,7 +110,6 @@ class DependencyTracker {
extern std::unique_ptr<DependencyTracker> depTracker;
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/Dwarf.h b/lld/MachO/Dwarf.h
index d1f40844181f5..7cd6ef1bef42b 100644
--- a/lld/MachO/Dwarf.h
+++ b/lld/MachO/Dwarf.h
@@ -12,8 +12,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/DebugInfo/DWARF/DWARFObject.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
class ObjFile;
@@ -57,7 +56,6 @@ class DwarfObject final : public llvm::DWARFObject {
llvm::StringRef strSection;
};
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/EhFrame.h b/lld/MachO/EhFrame.h
index 609a3bb8b1fe3..091a92e801745 100644
--- a/lld/MachO/EhFrame.h
+++ b/lld/MachO/EhFrame.h
@@ -50,8 +50,7 @@
* 5. (Optional) LSDA address (pointer-sized pcrel offset)
* 6. DWARF instructions (ignored by LLD)
*/
-namespace lld {
-namespace macho {
+namespace lld::macho {
class EhReader {
public:
@@ -112,7 +111,6 @@ class EhRelocator {
SmallVector<Reloc, 6> newRelocs;
};
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/ExportTrie.h b/lld/MachO/ExportTrie.h
index 0675d8257a2a6..aa7e3b0d4a14b 100644
--- a/lld/MachO/ExportTrie.h
+++ b/lld/MachO/ExportTrie.h
@@ -14,8 +14,7 @@
#include <vector>
-namespace lld {
-namespace macho {
+namespace lld::macho {
struct TrieNode;
class Symbol;
@@ -44,7 +43,6 @@ using TrieEntryCallback =
void parseTrie(const uint8_t *buf, size_t size, const TrieEntryCallback &);
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/ICF.h b/lld/MachO/ICF.h
index b7e695d81d343..34ceb1cf284bf 100644
--- a/lld/MachO/ICF.h
+++ b/lld/MachO/ICF.h
@@ -13,15 +13,13 @@
#include "lld/Common/LLVM.h"
#include <vector>
-namespace lld {
-namespace macho {
+namespace lld::macho {
class Symbol;
void markAddrSigSymbols();
void markSymAsAddrSig(Symbol *s);
void foldIdenticalSections(bool onlyCfStrings);
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/LTO.h b/lld/MachO/LTO.h
index d64016fb588c2..3e5f1a69057dc 100644
--- a/lld/MachO/LTO.h
+++ b/lld/MachO/LTO.h
@@ -14,14 +14,11 @@
#include <memory>
#include <vector>
-namespace llvm {
-namespace lto {
+namespace llvm::lto {
class LTO;
-} // namespace lto
-} // namespace llvm
+} // namespace llvm::lto
-namespace lld {
-namespace macho {
+namespace lld::macho {
class BitcodeFile;
class ObjFile;
@@ -39,7 +36,6 @@ class BitcodeCompiler {
std::vector<std::unique_ptr<llvm::MemoryBuffer>> files;
};
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/MachOStructs.h b/lld/MachO/MachOStructs.h
index 44715bf29dacc..42390a2cc15ba 100644
--- a/lld/MachO/MachOStructs.h
+++ b/lld/MachO/MachOStructs.h
@@ -17,9 +17,7 @@
#include "llvm/Support/Endian.h"
-namespace lld {
-
-namespace structs {
+namespace lld::structs {
struct nlist_64 {
llvm::support::ulittle32_t n_strx;
@@ -44,8 +42,6 @@ struct entry_point_command {
llvm::support::ulittle64_t stacksize;
};
-} // namespace structs
-
-} // namespace lld
+} // namespace lld::structs
#endif
diff --git a/lld/MachO/MapFile.h b/lld/MachO/MapFile.h
index bf16ffdd03823..37436d797d7b1 100644
--- a/lld/MachO/MapFile.h
+++ b/lld/MachO/MapFile.h
@@ -9,10 +9,8 @@
#ifndef LLD_MACHO_MAPFILE_H
#define LLD_MACHO_MAPFILE_H
-namespace lld {
-namespace macho {
+namespace lld::macho {
void writeMapFile();
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/MarkLive.cpp b/lld/MachO/MarkLive.cpp
index 7239e30bbdb22..cc9afe181d0f3 100644
--- a/lld/MachO/MarkLive.cpp
+++ b/lld/MachO/MarkLive.cpp
@@ -15,8 +15,7 @@
#include "mach-o/compact_unwind_encoding.h"
#include "llvm/Support/TimeProfiler.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
using namespace llvm;
using namespace llvm::MachO;
@@ -288,5 +287,4 @@ void markLive() {
marker->markTransitively();
}
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
diff --git a/lld/MachO/MarkLive.h b/lld/MachO/MarkLive.h
index 4db657c5728de..d7fe7ffa200e8 100644
--- a/lld/MachO/MarkLive.h
+++ b/lld/MachO/MarkLive.h
@@ -9,12 +9,10 @@
#ifndef LLD_MACHO_MARKLIVE_H
#define LLD_MACHO_MARKLIVE_H
-namespace lld {
-namespace macho {
+namespace lld::macho {
void markLive();
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif // LLD_MACHO_MARKLIVE_H
diff --git a/lld/MachO/ObjC.h b/lld/MachO/ObjC.h
index 8db459ad8e2ba..67fa4114db007 100644
--- a/lld/MachO/ObjC.h
+++ b/lld/MachO/ObjC.h
@@ -11,8 +11,7 @@
#include "llvm/Support/MemoryBuffer.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
namespace objc {
@@ -25,7 +24,6 @@ constexpr const char ivar[] = "_OBJC_IVAR_$_";
bool hasObjCSection(llvm::MemoryBufferRef);
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/OutputSection.h b/lld/MachO/OutputSection.h
index 51f39dd3498de..5297a03c2cfa7 100644
--- a/lld/MachO/OutputSection.h
+++ b/lld/MachO/OutputSection.h
@@ -16,8 +16,7 @@
#include <limits>
-namespace lld {
-namespace macho {
+namespace lld::macho {
class Defined;
class InputSection;
@@ -98,7 +97,6 @@ class OutputSection {
Kind sectionKind;
};
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/OutputSegment.h b/lld/MachO/OutputSegment.h
index bff99e28a88f1..a1b6cef9e2c7c 100644
--- a/lld/MachO/OutputSegment.h
+++ b/lld/MachO/OutputSegment.h
@@ -17,8 +17,7 @@
#include <limits>
#include <vector>
-namespace lld {
-namespace macho {
+namespace lld::macho {
namespace segment_names {
@@ -72,7 +71,6 @@ void resetOutputSegments();
OutputSegment *getOrCreateOutputSegment(StringRef name);
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/Relocations.h b/lld/MachO/Relocations.h
index 6c0475fe02000..04ef42035768a 100644
--- a/lld/MachO/Relocations.h
+++ b/lld/MachO/Relocations.h
@@ -17,8 +17,7 @@
#include <cstddef>
#include <cstdint>
-namespace lld {
-namespace macho {
+namespace lld::macho {
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
class Symbol;
@@ -124,7 +123,6 @@ inline void writeAddress(uint8_t *loc, uint64_t addr, uint8_t length) {
extern const RelocAttrs invalidRelocAttrs;
-} // namespace macho
-} // namespace lld
+} // namespace lld::Macho
#endif
diff --git a/lld/MachO/SectionPriorities.h b/lld/MachO/SectionPriorities.h
index d27fef92f559f..cfd4837f1356f 100644
--- a/lld/MachO/SectionPriorities.h
+++ b/lld/MachO/SectionPriorities.h
@@ -12,8 +12,7 @@
#include "InputSection.h"
#include "llvm/ADT/DenseMap.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
using SectionPair = std::pair<const InputSection *, const InputSection *>;
@@ -76,7 +75,6 @@ class PriorityBuilder {
};
extern PriorityBuilder priorityBuilder;
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/SymbolTable.h b/lld/MachO/SymbolTable.h
index 1b090105e0ca1..a393f9c918087 100644
--- a/lld/MachO/SymbolTable.h
+++ b/lld/MachO/SymbolTable.h
@@ -16,8 +16,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/Object/Archive.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
class ArchiveFile;
class DylibFile;
@@ -80,7 +79,6 @@ void treatUndefinedSymbol(const Undefined &, const InputSection *,
extern std::unique_ptr<SymbolTable> symtab;
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h
index 29c2d98c6625c..1d2f219973c68 100644
--- a/lld/MachO/SyntheticSections.h
+++ b/lld/MachO/SyntheticSections.h
@@ -31,8 +31,7 @@ namespace llvm {
class DWARFUnit;
} // namespace llvm
-namespace lld {
-namespace macho {
+namespace lld::macho {
class Defined;
class DylibSymbol;
@@ -645,7 +644,6 @@ extern std::vector<SyntheticSection *> syntheticSections;
void createSyntheticSymbols();
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/Target.h b/lld/MachO/Target.h
index ef54dbb804083..61fabf4060152 100644
--- a/lld/MachO/Target.h
+++ b/lld/MachO/Target.h
@@ -20,8 +20,7 @@
#include <cstddef>
#include <cstdint>
-namespace lld {
-namespace macho {
+namespace lld::macho {
LLVM_ENABLE_BITMASK_ENUMS_IN_NAMESPACE();
class Symbol;
@@ -164,7 +163,6 @@ struct ILP32 {
extern TargetInfo *target;
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/UnwindInfoSection.h b/lld/MachO/UnwindInfoSection.h
index c6b334731c75b..2be59534c88e2 100644
--- a/lld/MachO/UnwindInfoSection.h
+++ b/lld/MachO/UnwindInfoSection.h
@@ -15,8 +15,7 @@
#include "mach-o/compact_unwind_encoding.h"
-namespace lld {
-namespace macho {
+namespace lld::macho {
class UnwindInfoSection : public SyntheticSection {
public:
@@ -37,7 +36,6 @@ class UnwindInfoSection : public SyntheticSection {
UnwindInfoSection *makeUnwindInfoSection();
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
diff --git a/lld/MachO/Writer.h b/lld/MachO/Writer.h
index 5ab40cabe64b4..066a0fd5fd3aa 100644
--- a/lld/MachO/Writer.h
+++ b/lld/MachO/Writer.h
@@ -11,8 +11,7 @@
#include <cstdint>
-namespace lld {
-namespace macho {
+namespace lld::macho {
class OutputSection;
class InputSection;
@@ -36,7 +35,6 @@ void addNonLazyBindingEntries(const Symbol *, const InputSection *,
extern OutputSection *firstTLVDataSection;
-} // namespace macho
-} // namespace lld
+} // namespace lld::macho
#endif
More information about the llvm-commits
mailing list