diff options
author | Joel E. Denny <jdenny.ornl@gmail.com> | 2018-03-13 14:51:22 +0000 |
---|---|---|
committer | Joel E. Denny <jdenny.ornl@gmail.com> | 2018-03-13 14:51:22 +0000 |
commit | 8150810556479b04e00578c9d7d4c30814898694 (patch) | |
tree | 459599c964149019a07d0e26c4dfe14dfc441f3c /clang/lib/AST/ExprConstant.cpp | |
parent | 204edeca5661d7dc80139d43507a0e268afff330 (diff) | |
download | bcm5719-llvm-8150810556479b04e00578c9d7d4c30814898694.tar.gz bcm5719-llvm-8150810556479b04e00578c9d7d4c30814898694.zip |
Reland "[Attr] Fix parameter indexing for several attributes"
Relands r326602 (reverted in r326862) with new test and fix for
PR36620.
Differential Revision: https://reviews.llvm.org/D43248
llvm-svn: 327405
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 851a03aa2ed..84ac4daeef9 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -5475,9 +5475,8 @@ static bool getBytesReturnedByAllocSizeCall(const ASTContext &Ctx, llvm::APInt &Result) { const AllocSizeAttr *AllocSize = getAllocSizeAttr(Call); - // alloc_size args are 1-indexed, 0 means not present. - assert(AllocSize && AllocSize->getElemSizeParam() != 0); - unsigned SizeArgNo = AllocSize->getElemSizeParam() - 1; + assert(AllocSize && AllocSize->getElemSizeParam().isValid()); + unsigned SizeArgNo = AllocSize->getElemSizeParam().getASTIndex(); unsigned BitsInSizeT = Ctx.getTypeSize(Ctx.getSizeType()); if (Call->getNumArgs() <= SizeArgNo) return false; @@ -5495,14 +5494,13 @@ static bool getBytesReturnedByAllocSizeCall(const ASTContext &Ctx, if (!EvaluateAsSizeT(Call->getArg(SizeArgNo), SizeOfElem)) return false; - if (!AllocSize->getNumElemsParam()) { + if (!AllocSize->getNumElemsParam().isValid()) { Result = std::move(SizeOfElem); return true; } APSInt NumberOfElems; - // Argument numbers start at 1 - unsigned NumArgNo = AllocSize->getNumElemsParam() - 1; + unsigned NumArgNo = AllocSize->getNumElemsParam().getASTIndex(); if (!EvaluateAsSizeT(Call->getArg(NumArgNo), NumberOfElems)) return false; |