diff options
author | David Blaikie <dblaikie@gmail.com> | 2015-04-02 18:55:32 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2015-04-02 18:55:32 +0000 |
commit | 4a2e73b06677a199591f004f8812811ec01e2e1f (patch) | |
tree | f6f2245fabc75040cc51b867a134d553cd36919a /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | e3b172afc33004cb11299e21dbea1dbb4cc4dc27 (diff) | |
download | bcm5719-llvm-4a2e73b06677a199591f004f8812811ec01e2e1f.tar.gz bcm5719-llvm-4a2e73b06677a199591f004f8812811ec01e2e1f.zip |
[opaque pointer type] API migration for GEP constant factories
Require the pointee type to be passed explicitly and assert that it is
correct. For now it's possible to pass nullptr here (and I've done so in
a few places in this patch) but eventually that will be disallowed once
all clients have been updated or removed. It'll be a long road to get
all the way there... but if you have the cahnce to update your callers
to pass the type explicitly without depending on a pointer's element
type, that would be a good thing to do soon and a necessary thing to do
eventually.
llvm-svn: 233938
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 09e3e75f99d..5771043e189 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2313,14 +2313,17 @@ std::error_code BitcodeReader::ParseConstants() { Elts.push_back(ValueList.getConstantFwdRef(Record[OpNum++], ElTy)); } - ArrayRef<Constant *> Indices(Elts.begin() + 1, Elts.end()); - V = ConstantExpr::getGetElementPtr(Elts[0], Indices, - BitCode == - bitc::CST_CODE_CE_INBOUNDS_GEP); if (PointeeType && - PointeeType != cast<GEPOperator>(V)->getSourceElementType()) + PointeeType != + cast<SequentialType>(Elts[0]->getType()->getScalarType()) + ->getElementType()) return Error("Explicit gep operator type does not match pointee type " "of pointer operand"); + + ArrayRef<Constant *> Indices(Elts.begin() + 1, Elts.end()); + V = ConstantExpr::getGetElementPtr(PointeeType, Elts[0], Indices, + BitCode == + bitc::CST_CODE_CE_INBOUNDS_GEP); break; } case bitc::CST_CODE_CE_SELECT: { // CE_SELECT: [opval#, opval#, opval#] |