@@ -130,14 +130,16 @@ struct Messages {
130130 std::string Short, Full;
131131};
132132
133- enum class BadOffsetKind {Negative, Overflowing, Indeterminate};
133+ enum class BadOffsetKind { Negative, Overflowing, Indeterminate };
134134
135- constexpr llvm::StringLiteral Adjectives[] = {" a negative" , " an overflowing" , " a negative or overflowing" };
135+ constexpr llvm::StringLiteral Adjectives[] = {" a negative" , " an overflowing" ,
136+ " a negative or overflowing" };
136137StringRef asAdjective (BadOffsetKind Problem) {
137138 return Adjectives[static_cast <int >(Problem)];
138139}
139140
140- constexpr llvm::StringLiteral Prepositions[] = {" preceding" , " after the end of" , " around" };
141+ constexpr llvm::StringLiteral Prepositions[] = {" preceding" , " after the end of" ,
142+ " around" };
141143StringRef asPreposition (BadOffsetKind Problem) {
142144 return Prepositions[static_cast <int >(Problem)];
143145}
@@ -420,9 +422,9 @@ static bool tryDividePair(std::optional<int64_t> &Val1,
420422}
421423
422424static Messages getNonTaintMsgs (ASTContext &ACtx, const MemSpaceRegion *Space,
423- const SubRegion *Region, NonLoc Offset,
424- std::optional<NonLoc> Extent, SVal Location,
425- BadOffsetKind Problem) {
425+ const SubRegion *Region, NonLoc Offset,
426+ std::optional<NonLoc> Extent, SVal Location,
427+ BadOffsetKind Problem) {
426428 std::string RegName = getRegionName (Space, Region);
427429 const auto *EReg = Location.getAsRegion ()->getAs <ElementRegion>();
428430 assert (EReg && " this checker only handles element access" );
@@ -471,8 +473,7 @@ static Messages getNonTaintMsgs(ASTContext &ACtx, const MemSpaceRegion *Space,
471473 }
472474
473475 return {formatv (" Out of bound access to memory {0} {1}" ,
474- asPreposition (Problem),
475- RegName),
476+ asPreposition (Problem), RegName),
476477 std::string (Buf)};
477478}
478479
@@ -642,7 +643,8 @@ void ArrayBoundChecker::performCheck(const Expr *E, CheckerContext &C) const {
642643 if (!WithinLowerBound) {
643644 // ...and it cannot be valid (>= 0), so report an error.
644645 Messages Msgs = getNonTaintMsgs (C.getASTContext (), Space, Reg,
645- ByteOffset, /* Extent=*/ std::nullopt , Location, BadOffsetKind::Negative);
646+ ByteOffset, /* Extent=*/ std::nullopt ,
647+ Location, BadOffsetKind::Negative);
646648 reportOOB (C, PrecedesLowerBound, Msgs, ByteOffset, std::nullopt );
647649 return ;
648650 }
@@ -684,10 +686,12 @@ void ArrayBoundChecker::performCheck(const Expr *E, CheckerContext &C) const {
684686 return ;
685687 }
686688
687- BadOffsetKind Problem = AlsoMentionUnderflow ? BadOffsetKind::Indeterminate : BadOffsetKind::Overflowing;
689+ BadOffsetKind Problem = AlsoMentionUnderflow
690+ ? BadOffsetKind::Indeterminate
691+ : BadOffsetKind::Overflowing;
688692 Messages Msgs =
689693 getNonTaintMsgs (C.getASTContext (), Space, Reg, ByteOffset,
690- *KnownSize, Location, Problem);
694+ *KnownSize, Location, Problem);
691695 reportOOB (C, ExceedsUpperBound, Msgs, ByteOffset, KnownSize);
692696 return ;
693697 }
0 commit comments