summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-03-07 02:22:41 +0000
committerNico Weber <nicolasweber@gmx.de>2018-03-07 02:22:41 +0000
commitbbf648253d096b4e25f588583df8ed8e764a28bb (patch)
tree0b02e45d28db415c8f5fa00795969510f93c1fd0 /clang/lib/AST
parent204ade4102c7959cc56e03f163ad7473c94a0b38 (diff)
downloadbcm5719-llvm-bbf648253d096b4e25f588583df8ed8e764a28bb.tar.gz
bcm5719-llvm-bbf648253d096b4e25f588583df8ed8e764a28bb.zip
Revert r326602, it caused PR36620.
llvm-svn: 326862
Diffstat (limited to 'clang/lib/AST')
-rw-r--r--clang/lib/AST/ExprConstant.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 135e70e96ad..c3e41658c29 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -5467,8 +5467,9 @@ static bool getBytesReturnedByAllocSizeCall(const ASTContext &Ctx,
llvm::APInt &Result) {
const AllocSizeAttr *AllocSize = getAllocSizeAttr(Call);
- assert(AllocSize && AllocSize->elemSizeParam().isValid());
- unsigned SizeArgNo = AllocSize->elemSizeParam().getASTIndex();
+ // alloc_size args are 1-indexed, 0 means not present.
+ assert(AllocSize && AllocSize->getElemSizeParam() != 0);
+ unsigned SizeArgNo = AllocSize->getElemSizeParam() - 1;
unsigned BitsInSizeT = Ctx.getTypeSize(Ctx.getSizeType());
if (Call->getNumArgs() <= SizeArgNo)
return false;
@@ -5486,13 +5487,14 @@ static bool getBytesReturnedByAllocSizeCall(const ASTContext &Ctx,
if (!EvaluateAsSizeT(Call->getArg(SizeArgNo), SizeOfElem))
return false;
- if (!AllocSize->numElemsParam().isValid()) {
+ if (!AllocSize->getNumElemsParam()) {
Result = std::move(SizeOfElem);
return true;
}
APSInt NumberOfElems;
- unsigned NumArgNo = AllocSize->numElemsParam().getASTIndex();
+ // Argument numbers start at 1
+ unsigned NumArgNo = AllocSize->getNumElemsParam() - 1;
if (!EvaluateAsSizeT(Call->getArg(NumArgNo), NumberOfElems))
return false;
OpenPOWER on IntegriCloud