[llvm] 4d477ba - [BitcodeReader] Rename method for element type by ID (NFC)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 14 02:17:13 PST 2022


Author: Nikita Popov
Date: 2022-02-14T11:15:43+01:00
New Revision: 4d477ba50f44ea14efba5bd6155a579cab2883a9

URL: https://github.com/llvm/llvm-project/commit/4d477ba50f44ea14efba5bd6155a579cab2883a9
DIFF: https://github.com/llvm/llvm-project/commit/4d477ba50f44ea14efba5bd6155a579cab2883a9.diff

LOG: [BitcodeReader] Rename method for element type by ID (NFC)

Make it clearer that this method is specifically for pointer
element types, and not other element types. This distinction will
be relevant in the future.

The somewhat unusual spelling is to make sure this does not show
up when grepping for getPointerElementType.

Added: 
    

Modified: 
    llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 624533bd35046..3d4b1f64b11c4 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -594,7 +594,7 @@ class BitcodeReader : public BitcodeReaderBase, public GVMaterializer {
   StructType *createIdentifiedStructType(LLVMContext &Context);
 
   Type *getTypeByID(unsigned ID);
-  Type *getElementTypeByID(unsigned ID);
+  Type *getPtrElementTypeByID(unsigned ID);
 
   Value *getFnValueByID(unsigned ID, Type *Ty) {
     if (Ty && Ty->isMetadataTy())
@@ -1180,7 +1180,7 @@ Type *BitcodeReader::getTypeByID(unsigned ID) {
   return TypeList[ID] = createIdentifiedStructType(Context);
 }
 
-Type *BitcodeReader::getElementTypeByID(unsigned ID) {
+Type *BitcodeReader::getPtrElementTypeByID(unsigned ID) {
   if (ID >= TypeList.size())
     return nullptr;
 
@@ -2486,7 +2486,7 @@ Error BitcodeReader::parseConstants() {
       if (TypeList[Record[0]] == VoidType)
         return error("Invalid constant type");
       CurTy = TypeList[Record[0]];
-      CurElemTy = getElementTypeByID(Record[0]);
+      CurElemTy = getPtrElementTypeByID(Record[0]);
       continue;  // Skip the ValueList manipulation.
     case bitc::CST_CODE_NULL:      // NULL
       if (CurTy->isVoidTy() || CurTy->isFunctionTy() || CurTy->isLabelTy())
@@ -3319,7 +3319,7 @@ Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
     if (!Ty->isPointerTy())
       return error("Invalid type for value");
     AddressSpace = cast<PointerType>(Ty)->getAddressSpace();
-    Ty = getElementTypeByID(Record[0]);
+    Ty = getPtrElementTypeByID(Record[0]);
     if (!Ty)
       return error("Missing element type for old-style global");
   }
@@ -3414,7 +3414,7 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
   if (!FTy)
     return error("Invalid record");
   if (isa<PointerType>(FTy)) {
-    FTy = getElementTypeByID(Record[0]);
+    FTy = getPtrElementTypeByID(Record[0]);
     if (!FTy)
       return error("Missing element type for old-style function");
   }
@@ -3583,7 +3583,7 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord(
     if (!PTy)
       return error("Invalid type for value");
     AddrSpace = PTy->getAddressSpace();
-    Ty = getElementTypeByID(TypeID);
+    Ty = getPtrElementTypeByID(TypeID);
     if (!Ty)
       return error("Missing element type for old-style indirect symbol");
   } else {
@@ -5044,7 +5044,7 @@ Error BitcodeReader::parseFunctionBody(Function *F) {
       const bool SwiftError = Bitfield::get<APV::SwiftError>(Rec);
       Type *Ty = getTypeByID(Record[0]);
       if (!Bitfield::get<APV::ExplicitType>(Rec)) {
-        Ty = getElementTypeByID(Record[0]);
+        Ty = getPtrElementTypeByID(Record[0]);
         if (!Ty)
           return error("Missing element type for old-style alloca");
       }


        


More information about the llvm-commits mailing list