Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 1 | //== ArrayBoundCheckerV2.cpp ------------------------------------*- C++ -*--==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines ArrayBoundCheckerV2, which is a path-sensitive check |
| 11 | // which looks for an out-of-bound array element access. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 15 | #include "ClangSACheckers.h" |
Chandler Carruth | 55fc873 | 2012-12-04 09:13:33 +0000 | [diff] [blame] | 16 | #include "clang/AST/CharUnits.h" |
| 17 | #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h" |
Argyrios Kyrtzidis | ec8605f | 2011-03-01 01:16:21 +0000 | [diff] [blame] | 18 | #include "clang/StaticAnalyzer/Core/Checker.h" |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 19 | #include "clang/StaticAnalyzer/Core/CheckerManager.h" |
| 20 | #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h" |
Ted Kremenek | 9b66371 | 2011-02-10 01:03:03 +0000 | [diff] [blame] | 21 | #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h" |
Benjamin Kramer | 8fe83e1 | 2012-02-04 13:45:25 +0000 | [diff] [blame] | 22 | #include "llvm/ADT/SmallString.h" |
Benjamin Kramer | a93d0f2 | 2012-12-01 17:12:56 +0000 | [diff] [blame] | 23 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 24 | |
| 25 | using namespace clang; |
Ted Kremenek | 9ef6537 | 2010-12-23 07:20:52 +0000 | [diff] [blame] | 26 | using namespace ento; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 27 | |
| 28 | namespace { |
| 29 | class ArrayBoundCheckerV2 : |
Argyrios Kyrtzidis | ec8605f | 2011-03-01 01:16:21 +0000 | [diff] [blame] | 30 | public Checker<check::Location> { |
Dylan Noblesmith | 6f42b62 | 2012-02-05 02:12:40 +0000 | [diff] [blame] | 31 | mutable OwningPtr<BuiltinBug> BT; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 32 | |
Anna Zaks | 3bfd6d7 | 2012-01-21 05:07:33 +0000 | [diff] [blame] | 33 | enum OOB_Kind { OOB_Precedes, OOB_Excedes, OOB_Tainted }; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 34 | |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 35 | void reportOOB(CheckerContext &C, ProgramStateRef errorState, |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 36 | OOB_Kind kind) const; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 37 | |
| 38 | public: |
Anna Zaks | 390909c | 2011-10-06 00:43:15 +0000 | [diff] [blame] | 39 | void checkLocation(SVal l, bool isLoad, const Stmt*S, |
| 40 | CheckerContext &C) const; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | // FIXME: Eventually replace RegionRawOffset with this class. |
| 44 | class RegionRawOffsetV2 { |
| 45 | private: |
| 46 | const SubRegion *baseRegion; |
| 47 | SVal byteOffset; |
| 48 | |
| 49 | RegionRawOffsetV2() |
| 50 | : baseRegion(0), byteOffset(UnknownVal()) {} |
| 51 | |
| 52 | public: |
| 53 | RegionRawOffsetV2(const SubRegion* base, SVal offset) |
| 54 | : baseRegion(base), byteOffset(offset) {} |
| 55 | |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 56 | NonLoc getByteOffset() const { return byteOffset.castAs<NonLoc>(); } |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 57 | const SubRegion *getRegion() const { return baseRegion; } |
| 58 | |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 59 | static RegionRawOffsetV2 computeOffset(ProgramStateRef state, |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 60 | SValBuilder &svalBuilder, |
| 61 | SVal location); |
| 62 | |
| 63 | void dump() const; |
Ted Kremenek | 9c378f7 | 2011-08-12 23:37:29 +0000 | [diff] [blame] | 64 | void dumpToStream(raw_ostream &os) const; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 65 | }; |
| 66 | } |
| 67 | |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 68 | static SVal computeExtentBegin(SValBuilder &svalBuilder, |
| 69 | const MemRegion *region) { |
| 70 | while (true) |
| 71 | switch (region->getKind()) { |
| 72 | default: |
| 73 | return svalBuilder.makeZeroArrayIndex(); |
| 74 | case MemRegion::SymbolicRegionKind: |
| 75 | // FIXME: improve this later by tracking symbolic lower bounds |
| 76 | // for symbolic regions. |
| 77 | return UnknownVal(); |
| 78 | case MemRegion::ElementRegionKind: |
| 79 | region = cast<SubRegion>(region)->getSuperRegion(); |
| 80 | continue; |
| 81 | } |
| 82 | } |
| 83 | |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 84 | void ArrayBoundCheckerV2::checkLocation(SVal location, bool isLoad, |
Anna Zaks | 390909c | 2011-10-06 00:43:15 +0000 | [diff] [blame] | 85 | const Stmt* LoadS, |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 86 | CheckerContext &checkerContext) const { |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 87 | |
Ted Kremenek | 18c66fd | 2011-08-15 22:09:50 +0000 | [diff] [blame] | 88 | // NOTE: Instead of using ProgramState::assumeInBound(), we are prototyping |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 89 | // some new logic here that reasons directly about memory region extents. |
| 90 | // Once that logic is more mature, we can bring it back to assumeInBound() |
| 91 | // for all clients to use. |
| 92 | // |
| 93 | // The algorithm we are using here for bounds checking is to see if the |
| 94 | // memory access is within the extent of the base region. Since we |
| 95 | // have some flexibility in defining the base region, we can achieve |
| 96 | // various levels of conservatism in our buffer overflow checking. |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 97 | ProgramStateRef state = checkerContext.getState(); |
| 98 | ProgramStateRef originalState = state; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 99 | |
| 100 | SValBuilder &svalBuilder = checkerContext.getSValBuilder(); |
| 101 | const RegionRawOffsetV2 &rawOffset = |
| 102 | RegionRawOffsetV2::computeOffset(state, svalBuilder, location); |
| 103 | |
| 104 | if (!rawOffset.getRegion()) |
| 105 | return; |
| 106 | |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 107 | // CHECK LOWER BOUND: Is byteOffset < extent begin? |
| 108 | // If so, we are doing a load/store |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 109 | // before the first valid offset in the memory region. |
| 110 | |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 111 | SVal extentBegin = computeExtentBegin(svalBuilder, rawOffset.getRegion()); |
| 112 | |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 113 | if (llvm::Optional<NonLoc> NV = extentBegin.getAs<NonLoc>()) { |
| 114 | SVal lowerBound = |
| 115 | svalBuilder.evalBinOpNN(state, BO_LT, rawOffset.getByteOffset(), *NV, |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 116 | svalBuilder.getConditionType()); |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 117 | |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 118 | llvm::Optional<NonLoc> lowerBoundToCheck = lowerBound.getAs<NonLoc>(); |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 119 | if (!lowerBoundToCheck) |
| 120 | return; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 121 | |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 122 | ProgramStateRef state_precedesLowerBound, state_withinLowerBound; |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 123 | llvm::tie(state_precedesLowerBound, state_withinLowerBound) = |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 124 | state->assume(*lowerBoundToCheck); |
| 125 | |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 126 | // Are we constrained enough to definitely precede the lower bound? |
| 127 | if (state_precedesLowerBound && !state_withinLowerBound) { |
| 128 | reportOOB(checkerContext, state_precedesLowerBound, OOB_Precedes); |
| 129 | return; |
| 130 | } |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 131 | |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 132 | // Otherwise, assume the constraint of the lower bound. |
| 133 | assert(state_withinLowerBound); |
| 134 | state = state_withinLowerBound; |
| 135 | } |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 136 | |
| 137 | do { |
| 138 | // CHECK UPPER BOUND: Is byteOffset >= extent(baseRegion)? If so, |
| 139 | // we are doing a load/store after the last valid offset. |
| 140 | DefinedOrUnknownSVal extentVal = |
| 141 | rawOffset.getRegion()->getExtent(svalBuilder); |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 142 | if (!extentVal.getAs<NonLoc>()) |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 143 | break; |
| 144 | |
| 145 | SVal upperbound |
| 146 | = svalBuilder.evalBinOpNN(state, BO_GE, rawOffset.getByteOffset(), |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 147 | extentVal.castAs<NonLoc>(), |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 148 | svalBuilder.getConditionType()); |
| 149 | |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 150 | llvm::Optional<NonLoc> upperboundToCheck = upperbound.getAs<NonLoc>(); |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 151 | if (!upperboundToCheck) |
| 152 | break; |
| 153 | |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 154 | ProgramStateRef state_exceedsUpperBound, state_withinUpperBound; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 155 | llvm::tie(state_exceedsUpperBound, state_withinUpperBound) = |
| 156 | state->assume(*upperboundToCheck); |
Anna Zaks | 9b0970f | 2011-11-16 19:58:17 +0000 | [diff] [blame] | 157 | |
| 158 | // If we are under constrained and the index variables are tainted, report. |
| 159 | if (state_exceedsUpperBound && state_withinUpperBound) { |
| 160 | if (state->isTainted(rawOffset.getByteOffset())) |
Anna Zaks | 3bfd6d7 | 2012-01-21 05:07:33 +0000 | [diff] [blame] | 161 | reportOOB(checkerContext, state_exceedsUpperBound, OOB_Tainted); |
Anna Zaks | 9b0970f | 2011-11-16 19:58:17 +0000 | [diff] [blame] | 162 | return; |
| 163 | } |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 164 | |
Anna Zaks | 9b0970f | 2011-11-16 19:58:17 +0000 | [diff] [blame] | 165 | // If we are constrained enough to definitely exceed the upper bound, report. |
| 166 | if (state_exceedsUpperBound) { |
| 167 | assert(!state_withinUpperBound); |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 168 | reportOOB(checkerContext, state_exceedsUpperBound, OOB_Excedes); |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | assert(state_withinUpperBound); |
| 173 | state = state_withinUpperBound; |
| 174 | } |
| 175 | while (false); |
| 176 | |
| 177 | if (state != originalState) |
Anna Zaks | 0bd6b11 | 2011-10-26 21:06:34 +0000 | [diff] [blame] | 178 | checkerContext.addTransition(state); |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | void ArrayBoundCheckerV2::reportOOB(CheckerContext &checkerContext, |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 182 | ProgramStateRef errorState, |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 183 | OOB_Kind kind) const { |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 184 | |
| 185 | ExplodedNode *errorNode = checkerContext.generateSink(errorState); |
| 186 | if (!errorNode) |
| 187 | return; |
| 188 | |
| 189 | if (!BT) |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 190 | BT.reset(new BuiltinBug("Out-of-bound access")); |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 191 | |
| 192 | // FIXME: This diagnostics are preliminary. We should get far better |
| 193 | // diagnostics for explaining buffer overruns. |
| 194 | |
Dylan Noblesmith | f7ccbad | 2012-02-05 02:13:05 +0000 | [diff] [blame] | 195 | SmallString<256> buf; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 196 | llvm::raw_svector_ostream os(buf); |
Anna Zaks | 3bfd6d7 | 2012-01-21 05:07:33 +0000 | [diff] [blame] | 197 | os << "Out of bound memory access "; |
| 198 | switch (kind) { |
| 199 | case OOB_Precedes: |
| 200 | os << "(accessed memory precedes memory block)"; |
| 201 | break; |
| 202 | case OOB_Excedes: |
| 203 | os << "(access exceeds upper limit of memory block)"; |
| 204 | break; |
| 205 | case OOB_Tainted: |
| 206 | os << "(index is tainted)"; |
| 207 | break; |
| 208 | } |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 209 | |
Jordan Rose | 785950e | 2012-11-02 01:53:40 +0000 | [diff] [blame] | 210 | checkerContext.emitReport(new BugReport(*BT, os.str(), errorNode)); |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | void RegionRawOffsetV2::dump() const { |
| 214 | dumpToStream(llvm::errs()); |
| 215 | } |
| 216 | |
Ted Kremenek | 9c378f7 | 2011-08-12 23:37:29 +0000 | [diff] [blame] | 217 | void RegionRawOffsetV2::dumpToStream(raw_ostream &os) const { |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 218 | os << "raw_offset_v2{" << getRegion() << ',' << getByteOffset() << '}'; |
| 219 | } |
| 220 | |
| 221 | // FIXME: Merge with the implementation of the same method in Store.cpp |
| 222 | static bool IsCompleteType(ASTContext &Ctx, QualType Ty) { |
| 223 | if (const RecordType *RT = Ty->getAs<RecordType>()) { |
| 224 | const RecordDecl *D = RT->getDecl(); |
| 225 | if (!D->getDefinition()) |
| 226 | return false; |
| 227 | } |
| 228 | |
| 229 | return true; |
| 230 | } |
| 231 | |
| 232 | |
| 233 | // Lazily computes a value to be used by 'computeOffset'. If 'val' |
| 234 | // is unknown or undefined, we lazily substitute '0'. Otherwise, |
| 235 | // return 'val'. |
| 236 | static inline SVal getValue(SVal val, SValBuilder &svalBuilder) { |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 237 | return val.getAs<UndefinedVal>() ? svalBuilder.makeArrayIndex(0) : val; |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 238 | } |
| 239 | |
| 240 | // Scale a base value by a scaling factor, and return the scaled |
| 241 | // value as an SVal. Used by 'computeOffset'. |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 242 | static inline SVal scaleValue(ProgramStateRef state, |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 243 | NonLoc baseVal, CharUnits scaling, |
| 244 | SValBuilder &sb) { |
| 245 | return sb.evalBinOpNN(state, BO_Mul, baseVal, |
| 246 | sb.makeArrayIndex(scaling.getQuantity()), |
| 247 | sb.getArrayIndexType()); |
| 248 | } |
| 249 | |
| 250 | // Add an SVal to another, treating unknown and undefined values as |
| 251 | // summing to UnknownVal. Used by 'computeOffset'. |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 252 | static SVal addValue(ProgramStateRef state, SVal x, SVal y, |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 253 | SValBuilder &svalBuilder) { |
| 254 | // We treat UnknownVals and UndefinedVals the same here because we |
| 255 | // only care about computing offsets. |
| 256 | if (x.isUnknownOrUndef() || y.isUnknownOrUndef()) |
| 257 | return UnknownVal(); |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 258 | |
| 259 | return svalBuilder.evalBinOpNN(state, BO_Add, x.castAs<NonLoc>(), |
| 260 | y.castAs<NonLoc>(), |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 261 | svalBuilder.getArrayIndexType()); |
| 262 | } |
| 263 | |
| 264 | /// Compute a raw byte offset from a base region. Used for array bounds |
| 265 | /// checking. |
Ted Kremenek | 8bef823 | 2012-01-26 21:29:00 +0000 | [diff] [blame] | 266 | RegionRawOffsetV2 RegionRawOffsetV2::computeOffset(ProgramStateRef state, |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 267 | SValBuilder &svalBuilder, |
| 268 | SVal location) |
| 269 | { |
| 270 | const MemRegion *region = location.getAsRegion(); |
| 271 | SVal offset = UndefinedVal(); |
| 272 | |
| 273 | while (region) { |
| 274 | switch (region->getKind()) { |
| 275 | default: { |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 276 | if (const SubRegion *subReg = dyn_cast<SubRegion>(region)) { |
| 277 | offset = getValue(offset, svalBuilder); |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 278 | if (!offset.isUnknownOrUndef()) |
| 279 | return RegionRawOffsetV2(subReg, offset); |
Ted Kremenek | 82cfc68 | 2011-04-12 17:21:33 +0000 | [diff] [blame] | 280 | } |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 281 | return RegionRawOffsetV2(); |
| 282 | } |
| 283 | case MemRegion::ElementRegionKind: { |
| 284 | const ElementRegion *elemReg = cast<ElementRegion>(region); |
| 285 | SVal index = elemReg->getIndex(); |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 286 | if (!index.getAs<NonLoc>()) |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 287 | return RegionRawOffsetV2(); |
| 288 | QualType elemType = elemReg->getElementType(); |
| 289 | // If the element is an incomplete type, go no further. |
| 290 | ASTContext &astContext = svalBuilder.getContext(); |
| 291 | if (!IsCompleteType(astContext, elemType)) |
| 292 | return RegionRawOffsetV2(); |
| 293 | |
| 294 | // Update the offset. |
| 295 | offset = addValue(state, |
| 296 | getValue(offset, svalBuilder), |
| 297 | scaleValue(state, |
David Blaikie | 5251abe | 2013-02-20 05:52:05 +0000 | [diff] [blame^] | 298 | index.castAs<NonLoc>(), |
Anna Zaks | 9b0970f | 2011-11-16 19:58:17 +0000 | [diff] [blame] | 299 | astContext.getTypeSizeInChars(elemType), |
| 300 | svalBuilder), |
Ted Kremenek | c478a14 | 2010-12-23 02:42:43 +0000 | [diff] [blame] | 301 | svalBuilder); |
| 302 | |
| 303 | if (offset.isUnknownOrUndef()) |
| 304 | return RegionRawOffsetV2(); |
| 305 | |
| 306 | region = elemReg->getSuperRegion(); |
| 307 | continue; |
| 308 | } |
| 309 | } |
| 310 | } |
| 311 | return RegionRawOffsetV2(); |
| 312 | } |
| 313 | |
| 314 | |
Argyrios Kyrtzidis | 0535701 | 2011-02-28 01:26:57 +0000 | [diff] [blame] | 315 | void ento::registerArrayBoundCheckerV2(CheckerManager &mgr) { |
| 316 | mgr.registerChecker<ArrayBoundCheckerV2>(); |
| 317 | } |