@@ -411,26 +411,30 @@ AST_MATCHER(ArraySubscriptExpr, isSafeArraySubscript) {
411
411
// FIXME: Proper solution:
412
412
// - refactor Sema::CheckArrayAccess
413
413
// - split safe/OOB/unknown decision logic from diagnostics emitting code
414
- // - e. g. "Try harder to find a NamedDecl to point at in the note." already duplicated
414
+ // - e. g. "Try harder to find a NamedDecl to point at in the note."
415
+ // already duplicated
415
416
// - call both from Sema and from here
416
417
417
- const DeclRefExpr * BaseDRE = dyn_cast_or_null<DeclRefExpr>(Node.getBase ()->IgnoreParenImpCasts ());
418
+ const DeclRefExpr *BaseDRE =
419
+ dyn_cast_or_null<DeclRefExpr>(Node.getBase ()->IgnoreParenImpCasts ());
418
420
if (!BaseDRE)
419
421
return false ;
420
422
if (!BaseDRE->getDecl ())
421
423
return false ;
422
424
auto BaseVarDeclTy = BaseDRE->getDecl ()->getType ();
423
425
if (!BaseVarDeclTy->isConstantArrayType ())
424
426
return false ;
425
- const auto * CATy = dyn_cast_or_null<ConstantArrayType>(BaseVarDeclTy);
427
+ const auto *CATy = dyn_cast_or_null<ConstantArrayType>(BaseVarDeclTy);
426
428
if (!CATy)
427
429
return false ;
428
430
const APInt ArrSize = CATy->getSize ();
429
431
430
- if (const auto * IdxLit = dyn_cast<IntegerLiteral>(Node.getIdx ())) {
432
+ if (const auto *IdxLit = dyn_cast<IntegerLiteral>(Node.getIdx ())) {
431
433
const APInt ArrIdx = IdxLit->getValue ();
432
- // FIXME: ArrIdx.isNegative() we could immediately emit an error as that's a bug
433
- if (ArrIdx.isNonNegative () && ArrIdx.getLimitedValue () < ArrSize.getLimitedValue ())
434
+ // FIXME: ArrIdx.isNegative() we could immediately emit an error as that's a
435
+ // bug
436
+ if (ArrIdx.isNonNegative () &&
437
+ ArrIdx.getLimitedValue () < ArrSize.getLimitedValue ())
434
438
return true ;
435
439
}
436
440
0 commit comments