Skip to content

Commit

Permalink
[LLD][NFC] Make InputFile::getMachineType const. (#102737)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjacek authored Aug 10, 2024
1 parent 955be52 commit 2849ebb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions lld/COFF/InputFiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ std::optional<Symbol *> ObjFile::createDefined(
return createRegular(sym);
}

MachineTypes ObjFile::getMachineType() {
MachineTypes ObjFile::getMachineType() const {
if (coffObj)
return static_cast<MachineTypes>(coffObj->getMachine());
return IMAGE_FILE_MACHINE_UNKNOWN;
Expand Down Expand Up @@ -1139,7 +1139,7 @@ void BitcodeFile::parseLazy() {
ctx.symtab.addLazyObject(this, sym.getName());
}

MachineTypes BitcodeFile::getMachineType() {
MachineTypes BitcodeFile::getMachineType() const {
switch (Triple(obj->getTargetTriple()).getArch()) {
case Triple::x86_64:
return AMD64;
Expand Down Expand Up @@ -1220,7 +1220,7 @@ void DLLFile::parse() {
}
}

MachineTypes DLLFile::getMachineType() {
MachineTypes DLLFile::getMachineType() const {
if (coffObj)
return static_cast<MachineTypes>(coffObj->getMachine());
return IMAGE_FILE_MACHINE_UNKNOWN;
Expand Down
10 changes: 6 additions & 4 deletions lld/COFF/InputFiles.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ class InputFile {
virtual void parse() = 0;

// Returns the CPU type this file was compiled to.
virtual MachineTypes getMachineType() { return IMAGE_FILE_MACHINE_UNKNOWN; }
virtual MachineTypes getMachineType() const {
return IMAGE_FILE_MACHINE_UNKNOWN;
}

MemoryBufferRef mb;

Expand Down Expand Up @@ -133,7 +135,7 @@ class ObjFile : public InputFile {
static bool classof(const InputFile *f) { return f->kind() == ObjectKind; }
void parse() override;
void parseLazy();
MachineTypes getMachineType() override;
MachineTypes getMachineType() const override;
ArrayRef<Chunk *> getChunks() { return chunks; }
ArrayRef<SectionChunk *> getDebugChunks() { return debugChunks; }
ArrayRef<SectionChunk *> getSXDataChunks() { return sxDataChunks; }
Expand Down Expand Up @@ -376,7 +378,7 @@ class BitcodeFile : public InputFile {
~BitcodeFile();
static bool classof(const InputFile *f) { return f->kind() == BitcodeKind; }
ArrayRef<Symbol *> getSymbols() { return symbols; }
MachineTypes getMachineType() override;
MachineTypes getMachineType() const override;
void parseLazy();
std::unique_ptr<llvm::lto::InputFile> obj;

Expand All @@ -393,7 +395,7 @@ class DLLFile : public InputFile {
: InputFile(ctx, DLLKind, m) {}
static bool classof(const InputFile *f) { return f->kind() == DLLKind; }
void parse() override;
MachineTypes getMachineType() override;
MachineTypes getMachineType() const override;

struct Symbol {
StringRef dllName;
Expand Down

0 comments on commit 2849ebb

Please sign in to comment.