[opaque pointer type] Serialize the type of an llvm::Function as a function type...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 17 Apr 2015 16:28:26 +0000 (16:28 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 17 Apr 2015 16:28:26 +0000 (16:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@235200 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/BitcodeReader.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp

index e37e8f49b33120577793d5cc11ef2e519d44d768..a3552e92a53a1126d58ab60047147c4b25d5d1b8 100644 (file)
@@ -2935,10 +2935,9 @@ std::error_code BitcodeReader::ParseModule(bool Resume,
       Type *Ty = getTypeByID(Record[0]);
       if (!Ty)
         return Error("Invalid record");
-      if (!Ty->isPointerTy())
-        return Error("Invalid type for value");
-      FunctionType *FTy =
-        dyn_cast<FunctionType>(cast<PointerType>(Ty)->getElementType());
+      if (auto *PTy = dyn_cast<PointerType>(Ty))
+        Ty = PTy->getElementType();
+      auto *FTy = dyn_cast<FunctionType>(Ty);
       if (!FTy)
         return Error("Invalid type for value");
 
index bfcaac112579e74589ce42f11aeb898c86e99d94..aace5e165278d5cfd6607d27c70b130eb72c553c 100644 (file)
@@ -690,7 +690,7 @@ static void WriteModuleInfo(const Module *M, const ValueEnumerator &VE,
     // FUNCTION:  [type, callingconv, isproto, linkage, paramattrs, alignment,
     //             section, visibility, gc, unnamed_addr, prologuedata,
     //             dllstorageclass, comdat, prefixdata]
-    Vals.push_back(VE.getTypeID(F.getType()));
+    Vals.push_back(VE.getTypeID(F.getFunctionType()));
     Vals.push_back(F.getCallingConv());
     Vals.push_back(F.isDeclaration());
     Vals.push_back(getEncodedLinkage(F));