[lld] 2849ebb - [LLD][NFC] Make InputFile::getMachineType const. (#102737)

via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 10 06:03:27 PDT 2024


Author: Jacek Caban
Date: 2024-08-10T15:03:23+02:00
New Revision: 2849ebb19c4c9bfe9e3ec716e0f2b1bfe5dd3607

URL: https://github.com/llvm/llvm-project/commit/2849ebb19c4c9bfe9e3ec716e0f2b1bfe5dd3607
DIFF: https://github.com/llvm/llvm-project/commit/2849ebb19c4c9bfe9e3ec716e0f2b1bfe5dd3607.diff

LOG: [LLD][NFC] Make InputFile::getMachineType const. (#102737)

Added: 
    

Modified: 
    lld/COFF/InputFiles.cpp
    lld/COFF/InputFiles.h

Removed: 
    


################################################################################
diff  --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index fdbe90390f5cac..8b21e12152f4b5 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -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;
@@ -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;
@@ -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;

diff  --git a/lld/COFF/InputFiles.h b/lld/COFF/InputFiles.h
index cabd87ba673e3c..dd034e5cb43ee7 100644
--- a/lld/COFF/InputFiles.h
+++ b/lld/COFF/InputFiles.h
@@ -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;
 
@@ -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; }
@@ -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;
 
@@ -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;


        


More information about the llvm-commits mailing list