Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 1 | //=-- GRExprEngineInternalChecks.cpp - Builtin GRExprEngine Checks---*- 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 the BugType classes used by GRExprEngine to report |
| 11 | // bugs derived from builtin checks in the path-sensitive engine. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "clang/Analysis/PathSensitive/BugReporter.h" |
| 16 | #include "clang/Analysis/PathSensitive/GRExprEngine.h" |
Ted Kremenek | 8aed806 | 2008-10-31 00:13:20 +0000 | [diff] [blame] | 17 | #include "clang/Basic/SourceManager.h" |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 18 | #include "llvm/Support/Compiler.h" |
Ted Kremenek | ad51a60 | 2008-10-31 00:18:30 +0000 | [diff] [blame^] | 19 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 20 | |
| 21 | using namespace clang; |
| 22 | |
| 23 | //===----------------------------------------------------------------------===// |
| 24 | // Utility functions. |
| 25 | //===----------------------------------------------------------------------===// |
| 26 | |
| 27 | template <typename ITERATOR> inline |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 28 | ExplodedNode<GRState>* GetNode(ITERATOR I) { |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 29 | return *I; |
| 30 | } |
| 31 | |
| 32 | template <> inline |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 33 | ExplodedNode<GRState>* GetNode(GRExprEngine::undef_arg_iterator I) { |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 34 | return I->first; |
| 35 | } |
| 36 | |
| 37 | //===----------------------------------------------------------------------===// |
| 38 | // Bug Descriptions. |
| 39 | //===----------------------------------------------------------------------===// |
| 40 | |
| 41 | namespace { |
| 42 | class VISIBILITY_HIDDEN BuiltinBug : public BugTypeCacheLocation { |
| 43 | const char* name; |
| 44 | const char* desc; |
| 45 | public: |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 46 | BuiltinBug(const char* n, const char* d = 0) : name(n), desc(d) {} |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 47 | virtual const char* getName() const { return name; } |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 48 | virtual const char* getDescription() const { |
| 49 | return desc ? desc : name; |
| 50 | } |
| 51 | |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 52 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) = 0; |
| 53 | virtual void EmitWarnings(BugReporter& BR) { |
| 54 | EmitBuiltinWarnings(BR, cast<GRBugReporter>(BR).getEngine()); |
| 55 | } |
| 56 | |
| 57 | template <typename ITER> |
| 58 | void Emit(BugReporter& BR, ITER I, ITER E) { |
| 59 | for (; I != E; ++I) { |
| 60 | BugReport R(*this, GetNode(I)); |
| 61 | BR.EmitWarning(R); |
| 62 | } |
| 63 | } |
Ted Kremenek | 2713347 | 2008-09-21 18:57:28 +0000 | [diff] [blame] | 64 | |
| 65 | virtual const char* getCategory() const { return "Logic Errors"; } |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | class VISIBILITY_HIDDEN NullDeref : public BuiltinBug { |
| 69 | public: |
| 70 | NullDeref() : BuiltinBug("null dereference", |
| 71 | "Dereference of null pointer.") {} |
| 72 | |
| 73 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 74 | Emit(BR, Eng.null_derefs_begin(), Eng.null_derefs_end()); |
| 75 | } |
| 76 | }; |
| 77 | |
| 78 | class VISIBILITY_HIDDEN UndefinedDeref : public BuiltinBug { |
| 79 | public: |
Ted Kremenek | 2713347 | 2008-09-21 18:57:28 +0000 | [diff] [blame] | 80 | UndefinedDeref() : BuiltinBug("uninitialized pointer dereference", |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 81 | "Dereference of undefined value.") {} |
| 82 | |
| 83 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 84 | Emit(BR, Eng.undef_derefs_begin(), Eng.undef_derefs_end()); |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | class VISIBILITY_HIDDEN DivZero : public BuiltinBug { |
| 89 | public: |
| 90 | DivZero() : BuiltinBug("divide-by-zero", |
| 91 | "Division by zero/undefined value.") {} |
| 92 | |
| 93 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 94 | Emit(BR, Eng.explicit_bad_divides_begin(), Eng.explicit_bad_divides_end()); |
| 95 | } |
| 96 | }; |
| 97 | |
| 98 | class VISIBILITY_HIDDEN UndefResult : public BuiltinBug { |
| 99 | public: |
| 100 | UndefResult() : BuiltinBug("undefined result", |
| 101 | "Result of operation is undefined.") {} |
| 102 | |
| 103 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 104 | Emit(BR, Eng.undef_results_begin(), Eng.undef_results_end()); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | class VISIBILITY_HIDDEN BadCall : public BuiltinBug { |
| 109 | public: |
| 110 | BadCall() |
| 111 | : BuiltinBug("invalid function call", |
| 112 | "Called function is a NULL or undefined function pointer value.") {} |
| 113 | |
| 114 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 115 | Emit(BR, Eng.bad_calls_begin(), Eng.bad_calls_end()); |
| 116 | } |
| 117 | }; |
| 118 | |
| 119 | class VISIBILITY_HIDDEN BadArg : public BuiltinBug { |
| 120 | public: |
Ted Kremenek | 2713347 | 2008-09-21 18:57:28 +0000 | [diff] [blame] | 121 | BadArg() : BuiltinBug("uninitialized argument", |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 122 | "Pass-by-value argument in function is undefined.") {} |
| 123 | |
Ted Kremenek | 2713347 | 2008-09-21 18:57:28 +0000 | [diff] [blame] | 124 | BadArg(const char* d) : BuiltinBug("uninitialized argument", d) {} |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 125 | |
| 126 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 127 | for (GRExprEngine::UndefArgsTy::iterator I = Eng.undef_arg_begin(), |
| 128 | E = Eng.undef_arg_end(); I!=E; ++I) { |
| 129 | |
| 130 | // Generate a report for this bug. |
| 131 | RangedBugReport report(*this, I->first); |
| 132 | report.addRange(I->second->getSourceRange()); |
| 133 | |
| 134 | // Emit the warning. |
| 135 | BR.EmitWarning(report); |
| 136 | } |
| 137 | } |
| 138 | }; |
| 139 | |
| 140 | class VISIBILITY_HIDDEN BadMsgExprArg : public BadArg { |
| 141 | public: |
| 142 | BadMsgExprArg() |
| 143 | : BadArg("Pass-by-value argument in message expression is undefined.") {} |
| 144 | |
| 145 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 146 | for (GRExprEngine::UndefArgsTy::iterator I=Eng.msg_expr_undef_arg_begin(), |
| 147 | E = Eng.msg_expr_undef_arg_end(); I!=E; ++I) { |
| 148 | |
| 149 | // Generate a report for this bug. |
| 150 | RangedBugReport report(*this, I->first); |
| 151 | report.addRange(I->second->getSourceRange()); |
| 152 | |
| 153 | // Emit the warning. |
| 154 | BR.EmitWarning(report); |
| 155 | } |
| 156 | } |
| 157 | }; |
| 158 | |
| 159 | class VISIBILITY_HIDDEN BadReceiver : public BuiltinBug { |
| 160 | public: |
| 161 | BadReceiver() |
Ted Kremenek | 2713347 | 2008-09-21 18:57:28 +0000 | [diff] [blame] | 162 | : BuiltinBug("uninitialized receiver", |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 163 | "Receiver in message expression is an uninitialized value.") {} |
| 164 | |
| 165 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 166 | for (GRExprEngine::UndefReceiversTy::iterator I=Eng.undef_receivers_begin(), |
| 167 | End = Eng.undef_receivers_end(); I!=End; ++I) { |
| 168 | |
| 169 | // Generate a report for this bug. |
| 170 | RangedBugReport report(*this, *I); |
| 171 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 172 | ExplodedNode<GRState>* N = *I; |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 173 | Stmt *S = cast<PostStmt>(N->getLocation()).getStmt(); |
| 174 | Expr* E = cast<ObjCMessageExpr>(S)->getReceiver(); |
| 175 | assert (E && "Receiver cannot be NULL"); |
| 176 | report.addRange(E->getSourceRange()); |
| 177 | |
| 178 | // Emit the warning. |
| 179 | BR.EmitWarning(report); |
| 180 | } |
| 181 | } |
| 182 | }; |
| 183 | |
| 184 | class VISIBILITY_HIDDEN RetStack : public BuiltinBug { |
| 185 | public: |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 186 | RetStack() : BuiltinBug("return of stack address") {} |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 187 | |
| 188 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
Ted Kremenek | b7714b2 | 2008-07-30 17:49:12 +0000 | [diff] [blame] | 189 | for (GRExprEngine::ret_stackaddr_iterator I=Eng.ret_stackaddr_begin(), |
| 190 | End = Eng.ret_stackaddr_end(); I!=End; ++I) { |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 191 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 192 | ExplodedNode<GRState>* N = *I; |
Ted Kremenek | b7714b2 | 2008-07-30 17:49:12 +0000 | [diff] [blame] | 193 | Stmt *S = cast<PostStmt>(N->getLocation()).getStmt(); |
| 194 | Expr* E = cast<ReturnStmt>(S)->getRetValue(); |
| 195 | assert (E && "Return expression cannot be NULL"); |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 196 | |
| 197 | // Get the value associated with E. |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 198 | loc::MemRegionVal V = |
| 199 | cast<loc::MemRegionVal>(Eng.getStateManager().GetSVal(N->getState(), |
Ted Kremenek | 9e24049 | 2008-10-04 05:50:14 +0000 | [diff] [blame] | 200 | E)); |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 201 | |
| 202 | // Generate a report for this bug. |
Ted Kremenek | ad51a60 | 2008-10-31 00:18:30 +0000 | [diff] [blame^] | 203 | std::string buf; |
| 204 | llvm::raw_string_ostream os(buf); |
Ted Kremenek | 8aed806 | 2008-10-31 00:13:20 +0000 | [diff] [blame] | 205 | SourceRange R; |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 206 | |
Ted Kremenek | 8aed806 | 2008-10-31 00:13:20 +0000 | [diff] [blame] | 207 | // Check if the region is a compound literal. |
| 208 | if (const CompoundLiteralRegion* CR = |
| 209 | dyn_cast<CompoundLiteralRegion>(V.getRegion())) { |
| 210 | |
| 211 | const CompoundLiteralExpr* CL = CR->getLiteralExpr(); |
| 212 | os << "Address of stack memory associated with a compound literal " |
| 213 | "declared on line " |
| 214 | << BR.getSourceManager().getLogicalLineNumber(CL->getLocStart()) |
| 215 | << " returned."; |
| 216 | |
| 217 | R = CL->getSourceRange(); |
| 218 | } |
| 219 | else { |
| 220 | os << "Address of stack memory associated with local variable '" |
| 221 | << V.getRegion()->getString() << "' returned."; |
| 222 | } |
Ted Kremenek | 22bda88 | 2008-07-31 20:31:27 +0000 | [diff] [blame] | 223 | |
Ted Kremenek | ad51a60 | 2008-10-31 00:18:30 +0000 | [diff] [blame^] | 224 | RangedBugReport report(*this, N, os.str().c_str()); |
Ted Kremenek | b7714b2 | 2008-07-30 17:49:12 +0000 | [diff] [blame] | 225 | report.addRange(E->getSourceRange()); |
Ted Kremenek | 8aed806 | 2008-10-31 00:13:20 +0000 | [diff] [blame] | 226 | if (R.isValid()) report.addRange(R); |
Ted Kremenek | b7714b2 | 2008-07-30 17:49:12 +0000 | [diff] [blame] | 227 | |
| 228 | // Emit the warning. |
| 229 | BR.EmitWarning(report); |
| 230 | } |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 231 | } |
| 232 | }; |
| 233 | |
| 234 | |
| 235 | class VISIBILITY_HIDDEN UndefBranch : public BuiltinBug { |
| 236 | struct VISIBILITY_HIDDEN FindUndefExpr { |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 237 | GRStateManager& VM; |
| 238 | const GRState* St; |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 239 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 240 | FindUndefExpr(GRStateManager& V, const GRState* S) : VM(V), St(S) {} |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 241 | |
Ted Kremenek | b7714b2 | 2008-07-30 17:49:12 +0000 | [diff] [blame] | 242 | Expr* FindExpr(Expr* Ex) { |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 243 | if (!MatchesCriteria(Ex)) |
Ted Kremenek | b7714b2 | 2008-07-30 17:49:12 +0000 | [diff] [blame] | 244 | return 0; |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 245 | |
Ted Kremenek | b7714b2 | 2008-07-30 17:49:12 +0000 | [diff] [blame] | 246 | for (Stmt::child_iterator I=Ex->child_begin(), E=Ex->child_end();I!=E;++I) |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 247 | if (Expr* ExI = dyn_cast_or_null<Expr>(*I)) { |
| 248 | Expr* E2 = FindExpr(ExI); |
| 249 | if (E2) return E2; |
| 250 | } |
| 251 | |
| 252 | return Ex; |
| 253 | } |
| 254 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 255 | bool MatchesCriteria(Expr* Ex) { return VM.GetSVal(St, Ex).isUndef(); } |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
| 258 | public: |
| 259 | UndefBranch() |
| 260 | : BuiltinBug("uninitialized value", |
| 261 | "Branch condition evaluates to an uninitialized value.") {} |
| 262 | |
| 263 | virtual void EmitBuiltinWarnings(BugReporter& BR, GRExprEngine& Eng) { |
| 264 | for (GRExprEngine::undef_branch_iterator I=Eng.undef_branches_begin(), |
| 265 | E=Eng.undef_branches_end(); I!=E; ++I) { |
| 266 | |
| 267 | // What's going on here: we want to highlight the subexpression of the |
| 268 | // condition that is the most likely source of the "uninitialized |
| 269 | // branch condition." We do a recursive walk of the condition's |
| 270 | // subexpressions and roughly look for the most nested subexpression |
| 271 | // that binds to Undefined. We then highlight that expression's range. |
| 272 | |
| 273 | BlockEdge B = cast<BlockEdge>((*I)->getLocation()); |
| 274 | Expr* Ex = cast<Expr>(B.getSrc()->getTerminatorCondition()); |
| 275 | assert (Ex && "Block must have a terminator."); |
| 276 | |
| 277 | // Get the predecessor node and check if is a PostStmt with the Stmt |
| 278 | // being the terminator condition. We want to inspect the state |
| 279 | // of that node instead because it will contain main information about |
| 280 | // the subexpressions. |
| 281 | |
| 282 | assert (!(*I)->pred_empty()); |
| 283 | |
| 284 | // Note: any predecessor will do. They should have identical state, |
| 285 | // since all the BlockEdge did was act as an error sink since the value |
| 286 | // had to already be undefined. |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 287 | ExplodedNode<GRState> *N = *(*I)->pred_begin(); |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 288 | ProgramPoint P = N->getLocation(); |
| 289 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 290 | const GRState* St = (*I)->getState(); |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 291 | |
| 292 | if (PostStmt* PS = dyn_cast<PostStmt>(&P)) |
| 293 | if (PS->getStmt() == Ex) |
| 294 | St = N->getState(); |
| 295 | |
| 296 | FindUndefExpr FindIt(Eng.getStateManager(), St); |
| 297 | Ex = FindIt.FindExpr(Ex); |
| 298 | |
| 299 | RangedBugReport R(*this, *I); |
| 300 | R.addRange(Ex->getSourceRange()); |
| 301 | |
| 302 | BR.EmitWarning(R); |
| 303 | } |
| 304 | } |
| 305 | }; |
| 306 | |
| 307 | //===----------------------------------------------------------------------===// |
| 308 | // __attribute__(nonnull) checking |
| 309 | |
| 310 | class VISIBILITY_HIDDEN CheckAttrNonNull : public GRSimpleAPICheck { |
| 311 | SimpleBugType BT; |
| 312 | std::list<RangedBugReport> Reports; |
| 313 | |
| 314 | public: |
| 315 | CheckAttrNonNull() : |
Ted Kremenek | 8c036c7 | 2008-09-20 04:23:38 +0000 | [diff] [blame] | 316 | BT("'nonnull' argument passed null", "API", |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 317 | "Null pointer passed as an argument to a 'nonnull' parameter") {} |
| 318 | |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 319 | virtual bool Audit(ExplodedNode<GRState>* N, GRStateManager& VMgr) { |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 320 | CallExpr* CE = cast<CallExpr>(cast<PostStmt>(N->getLocation()).getStmt()); |
Ted Kremenek | 4adc81e | 2008-08-13 04:27:00 +0000 | [diff] [blame] | 321 | const GRState* state = N->getState(); |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 322 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 323 | SVal X = VMgr.GetSVal(state, CE->getCallee()); |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 324 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 325 | if (!isa<loc::FuncVal>(X)) |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 326 | return false; |
| 327 | |
Zhongxing Xu | 1c96b24 | 2008-10-17 05:57:07 +0000 | [diff] [blame] | 328 | FunctionDecl* FD = dyn_cast<FunctionDecl>(cast<loc::FuncVal>(X).getDecl()); |
Ted Kremenek | 78d4624 | 2008-07-22 16:21:24 +0000 | [diff] [blame] | 329 | const NonNullAttr* Att = FD->getAttr<NonNullAttr>(); |
| 330 | |
| 331 | if (!Att) |
| 332 | return false; |
| 333 | |
| 334 | // Iterate through the arguments of CE and check them for null. |
| 335 | |
| 336 | unsigned idx = 0; |
| 337 | bool hasError = false; |
| 338 | |
| 339 | for (CallExpr::arg_iterator I=CE->arg_begin(), E=CE->arg_end(); I!=E; |
| 340 | ++I, ++idx) { |
| 341 | |
| 342 | if (!VMgr.isEqual(state, *I, 0) || !Att->isNonNull(idx)) |
| 343 | continue; |
| 344 | |
| 345 | RangedBugReport R(BT, N); |
| 346 | R.addRange((*I)->getSourceRange()); |
| 347 | Reports.push_back(R); |
| 348 | hasError = true; |
| 349 | } |
| 350 | |
| 351 | return hasError; |
| 352 | } |
| 353 | |
| 354 | virtual void EmitWarnings(BugReporter& BR) { |
| 355 | for (std::list<RangedBugReport>::iterator I=Reports.begin(), |
| 356 | E=Reports.end(); I!=E; ++I) |
| 357 | BR.EmitWarning(*I); |
| 358 | } |
| 359 | }; |
| 360 | } // end anonymous namespace |
| 361 | |
| 362 | //===----------------------------------------------------------------------===// |
| 363 | // Check registration. |
| 364 | |
| 365 | void GRExprEngine::RegisterInternalChecks() { |
| 366 | Register(new NullDeref()); |
| 367 | Register(new UndefinedDeref()); |
| 368 | Register(new UndefBranch()); |
| 369 | Register(new DivZero()); |
| 370 | Register(new UndefResult()); |
| 371 | Register(new BadCall()); |
| 372 | Register(new RetStack()); |
| 373 | Register(new BadArg()); |
| 374 | Register(new BadMsgExprArg()); |
| 375 | Register(new BadReceiver()); |
| 376 | AddCheck(new CheckAttrNonNull(), Stmt::CallExprClass); |
| 377 | } |