[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
diff --git a/lld/ELF/AArch64ErrataFix.h b/lld/ELF/AArch64ErrataFix.h
index 1ca4ea7..fa34beb 100644
--- a/lld/ELF/AArch64ErrataFix.h
+++ b/lld/ELF/AArch64ErrataFix.h
@@ -13,8 +13,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include <vector>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 
 class Defined;
 class InputSection;
@@ -43,7 +42,6 @@
   bool initialized = false;
 };
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/ARMErrataFix.h b/lld/ELF/ARMErrataFix.h
index dd0927f..2a7e6aa 100644
--- a/lld/ELF/ARMErrataFix.h
+++ b/lld/ELF/ARMErrataFix.h
@@ -13,8 +13,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include <vector>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 
 class Defined;
 class InputSection;
@@ -43,7 +42,6 @@
   bool initialized = false;
 };
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/CallGraphSort.h b/lld/ELF/CallGraphSort.h
index 5a09227..4997cb1 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<const InputSectionBase *, int> computeCallGraphProfileOrder();
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/Config.h b/lld/ELF/Config.h
index fd9d3b6..accf1fd 100644
--- a/lld/ELF/Config.h
+++ b/lld/ELF/Config.h
@@ -26,8 +26,7 @@
 #include <memory>
 #include <vector>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 
 class InputFile;
 class BinaryFile;
@@ -419,7 +418,6 @@
               llvm::getBugReportMsg());
 }
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/DWARF.h b/lld/ELF/DWARF.h
index 900c63d..1b6bb49 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 @@
   StringRef lineStrSection;
 };
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h
index 474cf3c..f864daa 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<class LinkerDriver> driver;
@@ -71,7 +70,6 @@
 llvm::Optional<std::string> searchLibraryBaseName(StringRef path);
 llvm::Optional<std::string> searchLibrary(StringRef path);
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/EhFrame.h b/lld/ELF/EhFrame.h
index 0741e91..9526416 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 ed828fc..3246cc3 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 <class ELFT> void doIcf();
 
-} // namespace elf
-} // namespace lld
+}
 
 #endif
diff --git a/lld/ELF/LTO.h b/lld/ELF/LTO.h
index 19388f3..7ab6541 100644
--- a/lld/ELF/LTO.h
+++ b/lld/ELF/LTO.h
@@ -27,14 +27,11 @@
 #include <memory>
 #include <vector>
 
-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 @@
   std::unique_ptr<llvm::raw_fd_ostream> indexFile;
   llvm::DenseSet<StringRef> thinIndices;
 };
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h
index 315b643..dc3d32e 100644
--- a/lld/ELF/LinkerScript.h
+++ b/lld/ELF/LinkerScript.h
@@ -22,8 +22,7 @@
 #include <functional>
 #include <memory>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 
 class Defined;
 class InputFile;
@@ -365,7 +364,6 @@
 
 extern std::unique_ptr<LinkerScript> 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 36bd1d2..b271f62 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 63b5b26..ef62fdf 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 <class ELFT> void markLive();
 
-} // namespace elf
-} // namespace lld
+}
 
 #endif // LLD_ELF_MARKLIVE_H
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 6bdbcfc..328daad 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -15,8 +15,7 @@
 
 #include <array>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 
 struct PhdrEntry;
 
@@ -154,7 +153,6 @@
 uint64_t getHeaderSize();
 
 extern llvm::SmallVector<OutputSection *, 0> outputSections;
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/Relocations.h b/lld/ELF/Relocations.h
index f70d255..6e427b3 100644
--- a/lld/ELF/Relocations.h
+++ b/lld/ELF/Relocations.h
@@ -14,8 +14,7 @@
 #include "llvm/ADT/STLExtras.h"
 #include <vector>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 class Symbol;
 class InputSection;
 class InputSectionBase;
@@ -212,7 +211,6 @@
   }
   return rels;
 }
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/ScriptLexer.h b/lld/ELF/ScriptLexer.h
index 6c8ba60..17c0b52 100644
--- a/lld/ELF/ScriptLexer.h
+++ b/lld/ELF/ScriptLexer.h
@@ -14,8 +14,7 @@
 #include "llvm/Support/MemoryBufferRef.h"
 #include <vector>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 
 class ScriptLexer {
 public:
@@ -52,7 +51,6 @@
   size_t getColumnNumber();
 };
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/ScriptParser.h b/lld/ELF/ScriptParser.h
index cd3971f..34b27d2 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 @@
 
 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 5cc0eae..142ec71 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 @@
 
 extern std::unique_ptr<SymbolTable> symtab;
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 215d1ae..8b29cbb 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 @@
 
 extern InStruct in;
 
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif
diff --git a/lld/ELF/Thunks.h b/lld/ELF/Thunks.h
index 5558da1..86aaee1 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 @@
   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 c79be8b..a302caa 100644
--- a/lld/ELF/Writer.h
+++ b/lld/ELF/Writer.h
@@ -13,8 +13,7 @@
 #include "llvm/ADT/StringRef.h"
 #include <cstdint>
 
-namespace lld {
-namespace elf {
+namespace lld::elf {
 class InputFile;
 class OutputSection;
 void copySectionsIntoPartitions();
@@ -56,7 +55,6 @@
 bool isMipsN32Abi(const InputFile *f);
 bool isMicroMips();
 bool isMipsR6();
-} // namespace elf
-} // namespace lld
+} // namespace lld::elf
 
 #endif