1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 20:23:11 +01:00

use 'auto' with 'dyn_cast'; fix formatting; NFC

llvm-svn: 270370
This commit is contained in:
Sanjay Patel 2016-05-22 16:07:20 +00:00
parent be15a9a346
commit 80f08c1c8b

View File

@ -1653,8 +1653,7 @@ static bool isGEPKnownNonNull(GEPOperator *GEP, unsigned Depth,
/// Does the 'Range' metadata (which must be a valid MD_range operand list)
/// ensure that the value it's attached to is never Value? 'RangeType' is
/// is the type of the value described by the range.
static bool rangeMetadataExcludesValue(MDNode* Ranges,
const APInt& Value) {
static bool rangeMetadataExcludesValue(MDNode* Ranges, const APInt& Value) {
const unsigned NumRanges = Ranges->getNumOperands() / 2;
assert(NumRanges >= 1);
for (unsigned i = 0; i < NumRanges; ++i) {
@ -1674,7 +1673,7 @@ static bool rangeMetadataExcludesValue(MDNode* Ranges,
/// defined. Supports values with integer or pointer type and vectors of
/// integers.
bool isKnownNonZero(Value *V, unsigned Depth, const Query &Q) {
if (Constant *C = dyn_cast<Constant>(V)) {
if (auto *C = dyn_cast<Constant>(V)) {
if (C->isNullValue())
return false;
if (isa<ConstantInt>(C))
@ -1684,11 +1683,11 @@ bool isKnownNonZero(Value *V, unsigned Depth, const Query &Q) {
return false;
}
if (Instruction* I = dyn_cast<Instruction>(V)) {
if (auto *I = dyn_cast<Instruction>(V)) {
if (MDNode *Ranges = I->getMetadata(LLVMContext::MD_range)) {
// If the possible ranges don't contain zero, then the value is
// definitely non-zero.
if (IntegerType* Ty = dyn_cast<IntegerType>(V->getType())) {
if (auto *Ty = dyn_cast<IntegerType>(V->getType())) {
const APInt ZeroValue(Ty->getBitWidth(), 0);
if (rangeMetadataExcludesValue(Ranges, ZeroValue))
return true;
@ -2816,7 +2815,7 @@ bool llvm::getConstantStringInfo(const Value *V, StringRef &Str,
if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer())
return false;
// Handle the all-zeros case
// Handle the all-zeros case.
if (GV->getInitializer()->isNullValue()) {
// This is a degenerate case. The initializer is constant zero so the
// length of the string must be zero.
@ -2824,13 +2823,12 @@ bool llvm::getConstantStringInfo(const Value *V, StringRef &Str,
return true;
}
// Must be a Constant Array
const ConstantDataArray *Array =
dyn_cast<ConstantDataArray>(GV->getInitializer());
// This must be a ConstantDataArray.
const auto *Array = dyn_cast<ConstantDataArray>(GV->getInitializer());
if (!Array || !Array->isString())
return false;
// Get the number of elements in the array
// Get the number of elements in the array.
uint64_t NumElts = Array->getType()->getArrayNumElements();
// Start out with the entire array in the StringRef.