Skip to content

Commit 2849ebb

Browse files
authored
[LLD][NFC] Make InputFile::getMachineType const. (#102737)
1 parent 955be52 commit 2849ebb

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lld/COFF/InputFiles.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ std::optional<Symbol *> ObjFile::createDefined(
724724
return createRegular(sym);
725725
}
726726

727-
MachineTypes ObjFile::getMachineType() {
727+
MachineTypes ObjFile::getMachineType() const {
728728
if (coffObj)
729729
return static_cast<MachineTypes>(coffObj->getMachine());
730730
return IMAGE_FILE_MACHINE_UNKNOWN;
@@ -1139,7 +1139,7 @@ void BitcodeFile::parseLazy() {
11391139
ctx.symtab.addLazyObject(this, sym.getName());
11401140
}
11411141

1142-
MachineTypes BitcodeFile::getMachineType() {
1142+
MachineTypes BitcodeFile::getMachineType() const {
11431143
switch (Triple(obj->getTargetTriple()).getArch()) {
11441144
case Triple::x86_64:
11451145
return AMD64;
@@ -1220,7 +1220,7 @@ void DLLFile::parse() {
12201220
}
12211221
}
12221222

1223-
MachineTypes DLLFile::getMachineType() {
1223+
MachineTypes DLLFile::getMachineType() const {
12241224
if (coffObj)
12251225
return static_cast<MachineTypes>(coffObj->getMachine());
12261226
return IMAGE_FILE_MACHINE_UNKNOWN;

lld/COFF/InputFiles.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ class InputFile {
8282
virtual void parse() = 0;
8383

8484
// Returns the CPU type this file was compiled to.
85-
virtual MachineTypes getMachineType() { return IMAGE_FILE_MACHINE_UNKNOWN; }
85+
virtual MachineTypes getMachineType() const {
86+
return IMAGE_FILE_MACHINE_UNKNOWN;
87+
}
8688

8789
MemoryBufferRef mb;
8890

@@ -133,7 +135,7 @@ class ObjFile : public InputFile {
133135
static bool classof(const InputFile *f) { return f->kind() == ObjectKind; }
134136
void parse() override;
135137
void parseLazy();
136-
MachineTypes getMachineType() override;
138+
MachineTypes getMachineType() const override;
137139
ArrayRef<Chunk *> getChunks() { return chunks; }
138140
ArrayRef<SectionChunk *> getDebugChunks() { return debugChunks; }
139141
ArrayRef<SectionChunk *> getSXDataChunks() { return sxDataChunks; }
@@ -376,7 +378,7 @@ class BitcodeFile : public InputFile {
376378
~BitcodeFile();
377379
static bool classof(const InputFile *f) { return f->kind() == BitcodeKind; }
378380
ArrayRef<Symbol *> getSymbols() { return symbols; }
379-
MachineTypes getMachineType() override;
381+
MachineTypes getMachineType() const override;
380382
void parseLazy();
381383
std::unique_ptr<llvm::lto::InputFile> obj;
382384

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

398400
struct Symbol {
399401
StringRef dllName;

0 commit comments

Comments
 (0)