From 87248ba5b1ddf779bbe4c17b719c4e5580ea58dd Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Wed, 10 Aug 2022 15:31:58 -0400 Subject: [PATCH] [lld/elf] Use C++17 nested namespace syntax in most places Like D131405, but for ELF. No behavior change. Differential Revision: https://reviews.llvm.org/D131612 --- lld/ELF/AArch64ErrataFix.h | 6 ++---- lld/ELF/ARMErrataFix.h | 6 ++---- lld/ELF/CallGraphSort.h | 6 ++---- lld/ELF/Config.h | 6 ++---- lld/ELF/DWARF.h | 6 ++---- lld/ELF/Driver.h | 6 ++---- lld/ELF/EhFrame.h | 6 ++---- lld/ELF/ICF.h | 6 ++---- lld/ELF/LTO.h | 10 +++------- lld/ELF/LinkerScript.h | 6 ++---- lld/ELF/MapFile.h | 6 ++---- lld/ELF/MarkLive.h | 6 ++---- lld/ELF/OutputSections.h | 6 ++---- lld/ELF/Relocations.h | 6 ++---- lld/ELF/ScriptLexer.h | 6 ++---- lld/ELF/ScriptParser.h | 6 ++---- lld/ELF/SymbolTable.h | 6 ++---- lld/ELF/SyntheticSections.h | 6 ++---- lld/ELF/Thunks.h | 6 ++---- lld/ELF/Writer.h | 6 ++---- 20 files changed, 41 insertions(+), 83 deletions(-) diff --git a/lld/ELF/AArch64ErrataFix.h b/lld/ELF/AArch64ErrataFix.h index 1ca4ea752031..fa34beb5d7a8 100644 --- a/lld/ELF/AArch64ErrataFix.h +++ b/lld/ELF/AArch64ErrataFix.h @@ -13,8 +13,7 @@ #include "llvm/ADT/DenseMap.h" #include -namespace lld { -namespace elf { +namespace lld::elf { class Defined; class InputSection; @@ -43,7 +42,6 @@ private: bool initialized = false; }; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/ARMErrataFix.h b/lld/ELF/ARMErrataFix.h index dd0927fb3c03..2a7e6aaeff1c 100644 --- a/lld/ELF/ARMErrataFix.h +++ b/lld/ELF/ARMErrataFix.h @@ -13,8 +13,7 @@ #include "llvm/ADT/DenseMap.h" #include -namespace lld { -namespace elf { +namespace lld::elf { class Defined; class InputSection; @@ -43,7 +42,6 @@ private: bool initialized = false; }; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/CallGraphSort.h b/lld/ELF/CallGraphSort.h index 5a092278a416..4997cb102c32 100644 --- a/lld/ELF/CallGraphSort.h +++ b/lld/ELF/CallGraphSort.h @@ -11,12 +11,10 @@ #include "llvm/ADT/DenseMap.h" -namespace lld { -namespace elf { +namespace lld::elf { class InputSectionBase; llvm::DenseMap computeCallGraphProfileOrder(); -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h index fd9d3b63b2a3..accf1fd41713 100644 --- a/lld/ELF/Config.h +++ b/lld/ELF/Config.h @@ -26,8 +26,7 @@ #include #include -namespace lld { -namespace elf { +namespace lld::elf { class InputFile; class BinaryFile; @@ -419,7 +418,6 @@ static inline void internalLinkerError(StringRef loc, const Twine &msg) { llvm::getBugReportMsg()); } -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/DWARF.h b/lld/ELF/DWARF.h index 900c63de26ff..1b6bb49c57c6 100644 --- a/lld/ELF/DWARF.h +++ b/lld/ELF/DWARF.h @@ -14,8 +14,7 @@ #include "llvm/DebugInfo/DWARF/DWARFContext.h" #include "llvm/Object/ELF.h" -namespace lld { -namespace elf { +namespace lld::elf { class InputSection; @@ -100,7 +99,6 @@ private: StringRef lineStrSection; }; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h index 474cf3c3adf0..f864daa72abe 100644 --- a/lld/ELF/Driver.h +++ b/lld/ELF/Driver.h @@ -15,8 +15,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Option/ArgList.h" -namespace lld { -namespace elf { +namespace lld::elf { class InputFile; extern std::unique_ptr driver; @@ -71,7 +70,6 @@ llvm::Optional searchScript(StringRef path); llvm::Optional searchLibraryBaseName(StringRef path); llvm::Optional searchLibrary(StringRef path); -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/EhFrame.h b/lld/ELF/EhFrame.h index 0741e91b6ccc..95264166e36c 100644 --- a/lld/ELF/EhFrame.h +++ b/lld/ELF/EhFrame.h @@ -11,13 +11,11 @@ #include "lld/Common/LLVM.h" -namespace lld { -namespace elf { +namespace lld::elf { struct EhSectionPiece; uint8_t getFdeEncoding(EhSectionPiece *p); bool hasLSDA(const EhSectionPiece &p); -} // namespace elf -} // namespace lld +} #endif diff --git a/lld/ELF/ICF.h b/lld/ELF/ICF.h index ed828fc4a949..3246cc33f43c 100644 --- a/lld/ELF/ICF.h +++ b/lld/ELF/ICF.h @@ -9,12 +9,10 @@ #ifndef LLD_ELF_ICF_H #define LLD_ELF_ICF_H -namespace lld { -namespace elf { +namespace lld::elf { template void doIcf(); -} // namespace elf -} // namespace lld +} #endif diff --git a/lld/ELF/LTO.h b/lld/ELF/LTO.h index 19388f37a146..7ab654101f24 100644 --- a/lld/ELF/LTO.h +++ b/lld/ELF/LTO.h @@ -27,14 +27,11 @@ #include #include -namespace llvm { -namespace lto { +namespace llvm::lto { class LTO; } -} // namespace llvm -namespace lld { -namespace elf { +namespace lld::elf { class BitcodeFile; class InputFile; @@ -55,7 +52,6 @@ private: std::unique_ptr indexFile; llvm::DenseSet thinIndices; }; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 315b64371b28..dc3d32e50ce0 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -22,8 +22,7 @@ #include #include -namespace lld { -namespace elf { +namespace lld::elf { class Defined; class InputFile; @@ -365,7 +364,6 @@ public: extern std::unique_ptr script; -} // end namespace elf -} // end namespace lld +} // end namespace lld::elf #endif // LLD_ELF_LINKER_SCRIPT_H diff --git a/lld/ELF/MapFile.h b/lld/ELF/MapFile.h index 36bd1d2d1703..b271f627df57 100644 --- a/lld/ELF/MapFile.h +++ b/lld/ELF/MapFile.h @@ -9,10 +9,8 @@ #ifndef LLD_ELF_MAPFILE_H #define LLD_ELF_MAPFILE_H -namespace lld { -namespace elf { +namespace lld::elf { void writeMapAndCref(); -} // namespace elf -} // namespace lld +} #endif diff --git a/lld/ELF/MarkLive.h b/lld/ELF/MarkLive.h index 63b5b2669146..ef62fdf964e4 100644 --- a/lld/ELF/MarkLive.h +++ b/lld/ELF/MarkLive.h @@ -9,12 +9,10 @@ #ifndef LLD_ELF_MARKLIVE_H #define LLD_ELF_MARKLIVE_H -namespace lld { -namespace elf { +namespace lld::elf { template void markLive(); -} // namespace elf -} // namespace lld +} #endif // LLD_ELF_MARKLIVE_H diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h index 6bdbcfce7b12..328daaddeb69 100644 --- a/lld/ELF/OutputSections.h +++ b/lld/ELF/OutputSections.h @@ -15,8 +15,7 @@ #include -namespace lld { -namespace elf { +namespace lld::elf { struct PhdrEntry; @@ -154,7 +153,6 @@ struct Out { uint64_t getHeaderSize(); extern llvm::SmallVector outputSections; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h index f70d255ba229..6e427b355f7d 100644 --- a/lld/ELF/Relocations.h +++ b/lld/ELF/Relocations.h @@ -14,8 +14,7 @@ #include "llvm/ADT/STLExtras.h" #include -namespace lld { -namespace elf { +namespace lld::elf { class Symbol; class InputSection; class InputSectionBase; @@ -212,7 +211,6 @@ ArrayRef sortRels(ArrayRef rels, SmallVector &storage) { } return rels; } -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/ScriptLexer.h b/lld/ELF/ScriptLexer.h index 6c8ba60eaaa8..17c0b529fa17 100644 --- a/lld/ELF/ScriptLexer.h +++ b/lld/ELF/ScriptLexer.h @@ -14,8 +14,7 @@ #include "llvm/Support/MemoryBufferRef.h" #include -namespace lld { -namespace elf { +namespace lld::elf { class ScriptLexer { public: @@ -52,7 +51,6 @@ private: size_t getColumnNumber(); }; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/ScriptParser.h b/lld/ELF/ScriptParser.h index cd3971f1c0c5..34b27d2b4787 100644 --- a/lld/ELF/ScriptParser.h +++ b/lld/ELF/ScriptParser.h @@ -12,8 +12,7 @@ #include "lld/Common/LLVM.h" #include "llvm/Support/MemoryBufferRef.h" -namespace lld { -namespace elf { +namespace lld::elf { // Parses a linker script. Calling this function updates // lld::elf::config and lld::elf::script. @@ -29,7 +28,6 @@ void readDefsym(StringRef name, MemoryBufferRef mb); bool hasWildcard(StringRef s); -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/SymbolTable.h b/lld/ELF/SymbolTable.h index 5cc0eae87bb9..142ec7186a53 100644 --- a/lld/ELF/SymbolTable.h +++ b/lld/ELF/SymbolTable.h @@ -13,8 +13,7 @@ #include "llvm/ADT/CachedHashString.h" #include "llvm/ADT/DenseMap.h" -namespace lld { -namespace elf { +namespace lld::elf { class InputFile; class SharedFile; @@ -86,7 +85,6 @@ private: extern std::unique_ptr symtab; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h index 215d1ae644cb..8b29cbb9c385 100644 --- a/lld/ELF/SyntheticSections.h +++ b/lld/ELF/SyntheticSections.h @@ -28,8 +28,7 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/Threading.h" -namespace lld { -namespace elf { +namespace lld::elf { class Defined; struct PhdrEntry; class SymbolTableBaseSection; @@ -1267,7 +1266,6 @@ struct InStruct { extern InStruct in; -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/Thunks.h b/lld/ELF/Thunks.h index 5558da1a2c79..86aaee15f93b 100644 --- a/lld/ELF/Thunks.h +++ b/lld/ELF/Thunks.h @@ -12,8 +12,7 @@ #include "llvm/ADT/SmallVector.h" #include "Relocations.h" -namespace lld { -namespace elf { +namespace lld::elf { class Defined; class InputFile; class Symbol; @@ -78,7 +77,6 @@ static inline uint16_t computeHiBits(uint32_t toCompute) { return (toCompute + 0x8000) >> 16; } -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif diff --git a/lld/ELF/Writer.h b/lld/ELF/Writer.h index c79be8b0db24..a302caad339f 100644 --- a/lld/ELF/Writer.h +++ b/lld/ELF/Writer.h @@ -13,8 +13,7 @@ #include "llvm/ADT/StringRef.h" #include -namespace lld { -namespace elf { +namespace lld::elf { class InputFile; class OutputSection; void copySectionsIntoPartitions(); @@ -56,7 +55,6 @@ uint8_t getMipsFpAbiFlag(uint8_t oldFlag, uint8_t newFlag, bool isMipsN32Abi(const InputFile *f); bool isMicroMips(); bool isMipsR6(); -} // namespace elf -} // namespace lld +} // namespace lld::elf #endif