COFF: Separate DefinedCOMDAT from DefinedRegular symbol type. NFC.
Before this change, you got to cast a symbol to DefinedRegular and then
call isCOMDAT() to determine if a given symbol is a COMDAT symbol.
Now you can just use isa<DefinedCOMDAT>().
As to the class definition of DefinedCOMDAT, I could remove duplicate
code from DefinedRegular and DefinedCOMDAT by introducing another base
class for them, but I chose to not do that to keep the class hierarchy
shallow. This amount of code duplication doesn't worth to define a new
class.
llvm-svn: 240319
diff --git a/lld/COFF/InputFiles.cpp b/lld/COFF/InputFiles.cpp
index d9cdd2f..f2734ea 100644
--- a/lld/COFF/InputFiles.cpp
+++ b/lld/COFF/InputFiles.cpp
@@ -211,8 +211,11 @@
}
}
}
- if (Chunk *C = SparseChunks[Sym.getSectionNumber()])
+ if (Chunk *C = SparseChunks[Sym.getSectionNumber()]) {
+ if (C->isCOMDAT())
+ return new (Alloc) DefinedCOMDAT(COFFObj.get(), Sym, C);
return new (Alloc) DefinedRegular(COFFObj.get(), Sym, C);
+ }
return nullptr;
}