From bf20d43f8263b1df43c26a2ac9fec7220bcb735e Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 7 Aug 2022 10:37:49 -0400 Subject: [PATCH] [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 --- lld/MachO/Arch/ARM64Common.h | 6 ++---- lld/MachO/ConcatOutputSection.h | 6 ++---- lld/MachO/Driver.h | 6 ++---- lld/MachO/Dwarf.h | 6 ++---- lld/MachO/EhFrame.h | 6 ++---- lld/MachO/ExportTrie.h | 6 ++---- lld/MachO/ICF.h | 6 ++---- lld/MachO/LTO.h | 12 ++++-------- lld/MachO/MachOStructs.h | 8 ++------ lld/MachO/MapFile.h | 6 ++---- lld/MachO/MarkLive.cpp | 6 ++---- lld/MachO/MarkLive.h | 6 ++---- lld/MachO/ObjC.h | 6 ++---- lld/MachO/OutputSection.h | 6 ++---- lld/MachO/OutputSegment.h | 6 ++---- lld/MachO/Relocations.h | 6 ++---- lld/MachO/SectionPriorities.h | 6 ++---- lld/MachO/SymbolTable.h | 6 ++---- lld/MachO/SyntheticSections.h | 6 ++---- lld/MachO/Target.h | 6 ++---- lld/MachO/UnwindInfoSection.h | 6 ++---- lld/MachO/Writer.h | 6 ++---- 22 files changed, 46 insertions(+), 94 deletions(-) diff --git a/lld/MachO/Arch/ARM64Common.h b/lld/MachO/Arch/ARM64Common.h index 1bd85066b35a..8b75a5f3160d 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 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 c7404f48e27a..9af661d0ab1e 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 concatOutputSections; extern llvm::DenseMap thunkMap; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/Driver.h b/lld/MachO/Driver.h index 355816272f87..7249fe3b4520 100644 --- a/lld/MachO/Driver.h +++ b/lld/MachO/Driver.h @@ -20,8 +20,7 @@ #include #include -namespace lld { -namespace macho { +namespace lld::macho { class DylibFile; class InputFile; @@ -111,7 +110,6 @@ private: extern std::unique_ptr depTracker; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/Dwarf.h b/lld/MachO/Dwarf.h index d1f40844181f..7cd6ef1bef42 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 @@ private: llvm::StringRef strSection; }; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/EhFrame.h b/lld/MachO/EhFrame.h index 609a3bb8b1fe..091a92e80174 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 @@ private: SmallVector newRelocs; }; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/ExportTrie.h b/lld/MachO/ExportTrie.h index 0675d8257a2a..aa7e3b0d4a14 100644 --- a/lld/MachO/ExportTrie.h +++ b/lld/MachO/ExportTrie.h @@ -14,8 +14,7 @@ #include -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 b7e695d81d34..34ceb1cf284b 100644 --- a/lld/MachO/ICF.h +++ b/lld/MachO/ICF.h @@ -13,15 +13,13 @@ #include "lld/Common/LLVM.h" #include -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 d64016fb588c..3e5f1a69057d 100644 --- a/lld/MachO/LTO.h +++ b/lld/MachO/LTO.h @@ -14,14 +14,11 @@ #include #include -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 @@ private: std::vector> files; }; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/MachOStructs.h b/lld/MachO/MachOStructs.h index 44715bf29dac..42390a2cc15b 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 bf16ffdd0382..37436d797d7b 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 7239e30bbdb2..cc9afe181d0f 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 4db657c5728d..d7fe7ffa200e 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 8db459ad8e2b..67fa4114db00 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 51f39dd3498d..5297a03c2cfa 100644 --- a/lld/MachO/OutputSection.h +++ b/lld/MachO/OutputSection.h @@ -16,8 +16,7 @@ #include -namespace lld { -namespace macho { +namespace lld::macho { class Defined; class InputSection; @@ -98,7 +97,6 @@ private: Kind sectionKind; }; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/OutputSegment.h b/lld/MachO/OutputSegment.h index bff99e28a88f..a1b6cef9e2c7 100644 --- a/lld/MachO/OutputSegment.h +++ b/lld/MachO/OutputSegment.h @@ -17,8 +17,7 @@ #include #include -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 6c0475fe0200..04ef42035768 100644 --- a/lld/MachO/Relocations.h +++ b/lld/MachO/Relocations.h @@ -17,8 +17,7 @@ #include #include -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 d27fef92f559..cfd4837f1356 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; @@ -76,7 +75,6 @@ private: }; extern PriorityBuilder priorityBuilder; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/SymbolTable.h b/lld/MachO/SymbolTable.h index 1b090105e0ca..a393f9c91808 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 symtab; -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h index 29c2d98c6625..1d2f219973c6 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 syntheticSections; void createSyntheticSymbols(); -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/Target.h b/lld/MachO/Target.h index ef54dbb80408..61fabf406015 100644 --- a/lld/MachO/Target.h +++ b/lld/MachO/Target.h @@ -20,8 +20,7 @@ #include #include -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 c6b334731c75..2be59534c88e 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 @@ protected: UnwindInfoSection *makeUnwindInfoSection(); -} // namespace macho -} // namespace lld +} // namespace lld::macho #endif diff --git a/lld/MachO/Writer.h b/lld/MachO/Writer.h index 5ab40cabe64b..066a0fd5fd3a 100644 --- a/lld/MachO/Writer.h +++ b/lld/MachO/Writer.h @@ -11,8 +11,7 @@ #include -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