diff options
author | Vitaly Buka <vitalybuka@google.com> | 2016-07-28 22:50:50 +0000 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2016-07-28 22:50:50 +0000 |
commit | 21a9e573ed7c2582982344692f0c6e7ada9813eb (patch) | |
tree | e2af0a6f2d896045b05a3336500dbda7cc4cffd4 /llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | |
parent | f0500b6ae526fef8238f4f6017ac9da2f5c3f756 (diff) | |
download | bcm5719-llvm-21a9e573ed7c2582982344692f0c6e7ada9813eb.tar.gz bcm5719-llvm-21a9e573ed7c2582982344692f0c6e7ada9813eb.zip |
[asan] Add const into few methods
Summary: No functional changes
Reviewers: eugenis
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D22899
llvm-svn: 277069
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp index 0dbd5c000fe..5a1cf103354 100644 --- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp @@ -460,20 +460,20 @@ struct AddressSanitizer : public FunctionPass { AU.addRequired<DominatorTreeWrapperPass>(); AU.addRequired<TargetLibraryInfoWrapperPass>(); } - uint64_t getAllocaSizeInBytes(AllocaInst *AI) const { + uint64_t getAllocaSizeInBytes(const AllocaInst &AI) const { uint64_t ArraySize = 1; - if (AI->isArrayAllocation()) { - ConstantInt *CI = dyn_cast<ConstantInt>(AI->getArraySize()); + if (AI.isArrayAllocation()) { + const ConstantInt *CI = dyn_cast<ConstantInt>(AI.getArraySize()); assert(CI && "non-constant array size"); ArraySize = CI->getZExtValue(); } - Type *Ty = AI->getAllocatedType(); + Type *Ty = AI.getAllocatedType(); uint64_t SizeInBytes = - AI->getModule()->getDataLayout().getTypeAllocSize(Ty); + AI.getModule()->getDataLayout().getTypeAllocSize(Ty); return SizeInBytes * ArraySize; } /// Check if we want (and can) handle this alloca. - bool isInterestingAlloca(AllocaInst &AI); + bool isInterestingAlloca(const AllocaInst &AI); /// If it is an interesting memory access, return the PointerOperand /// and set IsWrite/Alignment. Otherwise return nullptr. @@ -545,7 +545,7 @@ struct AddressSanitizer : public FunctionPass { Function *AsanMemmove, *AsanMemcpy, *AsanMemset; InlineAsm *EmptyAsm; GlobalsMetadata GlobalsMD; - DenseMap<AllocaInst *, bool> ProcessedAllocas; + DenseMap<const AllocaInst *, bool> ProcessedAllocas; friend struct FunctionStackPoisoner; }; @@ -917,7 +917,7 @@ void AddressSanitizer::instrumentMemIntrinsic(MemIntrinsic *MI) { } /// Check if we want (and can) handle this alloca. -bool AddressSanitizer::isInterestingAlloca(AllocaInst &AI) { +bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) { auto PreviouslySeenAllocaInfo = ProcessedAllocas.find(&AI); if (PreviouslySeenAllocaInfo != ProcessedAllocas.end()) @@ -926,7 +926,7 @@ bool AddressSanitizer::isInterestingAlloca(AllocaInst &AI) { bool IsInteresting = (AI.getAllocatedType()->isSized() && // alloca() may be called with 0 size, ignore it. - ((!AI.isStaticAlloca()) || getAllocaSizeInBytes(&AI) > 0) && + ((!AI.isStaticAlloca()) || getAllocaSizeInBytes(AI) > 0) && // We are only interested in allocas not promotable to registers. // Promotable allocas are common under -O0. (!ClSkipPromotableAllocas || !isAllocaPromotable(&AI)) && @@ -2078,7 +2078,7 @@ void FunctionStackPoisoner::poisonStack() { SVD.reserve(AllocaVec.size()); for (AllocaInst *AI : AllocaVec) { ASanStackVariableDescription D = {AI->getName().data(), - ASan.getAllocaSizeInBytes(AI), + ASan.getAllocaSizeInBytes(*AI), AI->getAlignment(), AI, 0}; SVD.push_back(D); } |