Skip to content

Commit

Permalink
[lld][WebAssembly] Use C++17 nested namespace syntax in most places. NFC
Browse files Browse the repository at this point in the history
Like D131405, but for wasm-ld.

Differential Revision: https://reviews.llvm.org/D145399
  • Loading branch information
sbc100 committed Mar 10, 2023
1 parent 7c2a357 commit d32f71a
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 69 deletions.
6 changes: 2 additions & 4 deletions lld/wasm/Config.h
Expand Up @@ -20,8 +20,7 @@ namespace llvm::CodeGenOpt {
enum Level : int;
} // namespace llvm::CodeGenOpt

namespace lld {
namespace wasm {
namespace lld::wasm {

class InputFile;
class Symbol;
Expand Down Expand Up @@ -125,7 +124,6 @@ struct Configuration {
// The only instance of Configuration struct.
extern Configuration *config;

} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif
6 changes: 2 additions & 4 deletions lld/wasm/Driver.cpp
Expand Up @@ -42,8 +42,7 @@ using namespace llvm::object;
using namespace llvm::sys;
using namespace llvm::wasm;

namespace lld {
namespace wasm {
namespace lld::wasm {
Configuration *config;

namespace {
Expand Down Expand Up @@ -1218,5 +1217,4 @@ void LinkerDriver::linkerMain(ArrayRef<const char *> argsArr) {
writeResult();
}

} // namespace wasm
} // namespace lld
} // namespace wasm::lld
6 changes: 2 additions & 4 deletions lld/wasm/LTO.cpp
Expand Up @@ -37,8 +37,7 @@

using namespace llvm;

namespace lld {
namespace wasm {
namespace lld::wasm {
static std::unique_ptr<lto::LTO> createLTO() {
lto::Config c;
c.Options = initTargetOptionsFromCodeGenFlags();
Expand Down Expand Up @@ -165,5 +164,4 @@ std::vector<StringRef> BitcodeCompiler::compile() {
return ret;
}

} // namespace wasm
} // namespace lld
} // namespace lld::wasm
6 changes: 2 additions & 4 deletions lld/wasm/LTO.h
Expand Up @@ -32,8 +32,7 @@ class LTO;
}
} // namespace llvm

namespace lld {
namespace wasm {
namespace lld::wasm {

class BitcodeFile;
class InputFile;
Expand All @@ -51,7 +50,6 @@ class BitcodeCompiler {
std::vector<SmallString<0>> buf;
std::vector<std::unique_ptr<MemoryBuffer>> files;
};
} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif
6 changes: 2 additions & 4 deletions lld/wasm/MapFile.h
Expand Up @@ -11,11 +11,9 @@

#include "llvm/ADT/ArrayRef.h"

namespace lld {
namespace wasm {
namespace lld::wasm {
class OutputSection;
void writeMapFile(llvm::ArrayRef<OutputSection *> outputSections);
} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif
6 changes: 2 additions & 4 deletions lld/wasm/MarkLive.cpp
Expand Up @@ -30,8 +30,7 @@
using namespace llvm;
using namespace llvm::wasm;

namespace lld {
namespace wasm {
namespace lld::wasm {

namespace {

Expand Down Expand Up @@ -205,5 +204,4 @@ bool MarkLive::isCallCtorsLive() {
return false;
}

} // namespace wasm
} // namespace lld
} // namespace lld::wasm
6 changes: 2 additions & 4 deletions lld/wasm/MarkLive.h
Expand Up @@ -9,12 +9,10 @@
#ifndef LLD_WASM_MARKLIVE_H
#define LLD_WASM_MARKLIVE_H

namespace lld {
namespace wasm {
namespace lld::wasm {

void markLive();

} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif // LLD_WASM_MARKLIVE_H
7 changes: 2 additions & 5 deletions lld/wasm/OutputSegment.cpp
Expand Up @@ -15,9 +15,7 @@
using namespace llvm;
using namespace llvm::wasm;

namespace lld {

namespace wasm {
namespace lld::wasm {

void OutputSegment::addInputSegment(InputChunk *inSeg) {
alignment = std::max(alignment, inSeg->alignment);
Expand Down Expand Up @@ -82,5 +80,4 @@ void OutputSegment::finalizeInputSegments() {
}
}

} // namespace wasm
} // namespace lld
} // namespace lld::wasm
6 changes: 2 additions & 4 deletions lld/wasm/OutputSegment.h
Expand Up @@ -13,8 +13,7 @@
#include "lld/Common/ErrorHandler.h"
#include "llvm/Object/Wasm.h"

namespace lld {
namespace wasm {
namespace lld::wasm {

class InputSegment;

Expand Down Expand Up @@ -49,7 +48,6 @@ class OutputSegment {
std::string header;
};

} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif // LLD_WASM_OUTPUT_SEGMENT_H
6 changes: 2 additions & 4 deletions lld/wasm/Relocations.cpp
Expand Up @@ -16,8 +16,7 @@
using namespace llvm;
using namespace llvm::wasm;

namespace lld {
namespace wasm {
namespace lld::wasm {

static bool requiresGOTAccess(const Symbol *sym) {
if (!config->isPic &&
Expand Down Expand Up @@ -176,5 +175,4 @@ void scanRelocations(InputChunk *chunk) {
}
}

} // namespace wasm
} // namespace lld
} // namespace lld::wasm
6 changes: 2 additions & 4 deletions lld/wasm/Relocations.h
Expand Up @@ -9,14 +9,12 @@
#ifndef LLD_WASM_RELOCATIONS_H
#define LLD_WASM_RELOCATIONS_H

namespace lld {
namespace wasm {
namespace lld::wasm {

class InputChunk;

void scanRelocations(InputChunk *chunk);

} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif
6 changes: 2 additions & 4 deletions lld/wasm/SymbolTable.cpp
Expand Up @@ -20,8 +20,7 @@ using namespace llvm;
using namespace llvm::wasm;
using namespace llvm::object;

namespace lld {
namespace wasm {
namespace lld::wasm {
SymbolTable *symtab;

void SymbolTable::addFile(InputFile *file) {
Expand Down Expand Up @@ -966,5 +965,4 @@ void SymbolTable::handleSymbolVariants() {
}
}

} // namespace wasm
} // namespace lld
} // namespace wasm::lld
6 changes: 2 additions & 4 deletions lld/wasm/SymbolTable.h
Expand Up @@ -18,8 +18,7 @@
#include "llvm/BinaryFormat/WasmTraits.h"
#include <optional>

namespace lld {
namespace wasm {
namespace lld::wasm {

class InputSegment;

Expand Down Expand Up @@ -144,7 +143,6 @@ class SymbolTable {

extern SymbolTable *symtab;

} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif
6 changes: 2 additions & 4 deletions lld/wasm/SyntheticSections.cpp
Expand Up @@ -22,8 +22,7 @@
using namespace llvm;
using namespace llvm::wasm;

namespace lld {
namespace wasm {
namespace lld::wasm {

OutStruct out;

Expand Down Expand Up @@ -922,5 +921,4 @@ void BuildIdSection::writeBuildId(llvm::ArrayRef<uint8_t> buf) {
memcpy(hashPlaceholderPtr, buf.data(), hashSize);
}

} // namespace wasm
} // namespace lld
} // namespace wasm::lld
6 changes: 2 additions & 4 deletions lld/wasm/SyntheticSections.h
Expand Up @@ -24,8 +24,7 @@

#define DEBUG_TYPE "lld"

namespace lld {
namespace wasm {
namespace lld::wasm {

// An init entry to be written to either the synthetic init func or the
// linking metadata.
Expand Down Expand Up @@ -127,8 +126,7 @@ inline bool operator==(const ImportKey<T> &lhs, const ImportKey<T> &rhs) {
lhs.importName == rhs.importName && lhs.type == rhs.type;
}

} // namespace wasm
} // namespace lld
} // namespace wasm::lld

// `ImportKey<T>` can be used as a key in a `DenseMap` if `T` can be used as a
// key in a `DenseMap`.
Expand Down
6 changes: 2 additions & 4 deletions lld/wasm/Writer.cpp
Expand Up @@ -45,8 +45,7 @@
using namespace llvm;
using namespace llvm::wasm;

namespace lld {
namespace wasm {
namespace lld::wasm {
static constexpr int stackAlignment = 16;
static constexpr int heapAlignment = 16;

Expand Down Expand Up @@ -1865,5 +1864,4 @@ void Writer::createHeader() {

void writeResult() { Writer().run(); }

} // namespace wasm
} // namespace lld
} // namespace wasm::lld
6 changes: 2 additions & 4 deletions lld/wasm/Writer.h
Expand Up @@ -9,12 +9,10 @@
#ifndef LLD_WASM_WRITER_H
#define LLD_WASM_WRITER_H

namespace lld {
namespace wasm {
namespace lld::wasm {

void writeResult();

} // namespace wasm
} // namespace lld
} // namespace lld::wasm

#endif

0 comments on commit d32f71a

Please sign in to comment.