Chris Lattner | bda0b62 | 2008-03-15 23:59:48 +0000 | [diff] [blame] | 1 | // CFRefCount.cpp - Transfer functions for tracking simple values -*- C++ -*--// |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 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 | // |
Gabor Greif | 843e934 | 2008-03-06 10:40:09 +0000 | [diff] [blame] | 10 | // This file defines the methods for CFRefCount, which implements |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 11 | // a reference count checker for Core Foundation (Mac OS X). |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 15 | #include "GRSimpleVals.h" |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 16 | #include "clang/Analysis/PathSensitive/ValueState.h" |
| 17 | #include "clang/Basic/Diagnostic.h" |
| 18 | #include "clang/Analysis/LocalCheckers.h" |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/DenseMap.h" |
| 20 | #include "llvm/ADT/FoldingSet.h" |
| 21 | #include "llvm/ADT/ImmutableMap.h" |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 22 | #include <ostream> |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 23 | |
| 24 | using namespace clang; |
| 25 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 26 | namespace { |
| 27 | enum ArgEffect { IncRef, DecRef, DoNothing }; |
| 28 | typedef std::vector<ArgEffect> ArgEffects; |
| 29 | } |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 30 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 31 | namespace llvm { |
| 32 | template <> struct FoldingSetTrait<ArgEffects> { |
| 33 | static void Profile(const ArgEffects& X, FoldingSetNodeID ID) { |
| 34 | for (ArgEffects::const_iterator I = X.begin(), E = X.end(); I!= E; ++I) |
| 35 | ID.AddInteger((unsigned) *I); |
| 36 | } |
| 37 | |
| 38 | static void Profile(ArgEffects& X, FoldingSetNodeID ID) { |
| 39 | Profile(X, ID); |
| 40 | } |
| 41 | }; |
| 42 | } // end llvm namespace |
| 43 | |
| 44 | namespace { |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 45 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 46 | class RetEffect { |
| 47 | public: |
| 48 | enum Kind { Alias = 0x0, OwnedSymbol = 0x1, NotOwnedSymbol = 0x2 }; |
| 49 | |
| 50 | private: |
| 51 | unsigned Data; |
| 52 | RetEffect(Kind k, unsigned D) { Data = (Data << 2) | (unsigned) k; } |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 53 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 54 | public: |
| 55 | |
| 56 | Kind getKind() const { return (Kind) (Data & 0x3); } |
| 57 | |
| 58 | unsigned getValue() const { |
| 59 | assert(getKind() == Alias); |
| 60 | return Data & ~0x3; |
| 61 | } |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 62 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 63 | static RetEffect MakeAlias(unsigned Idx) { return RetEffect(Alias, Idx); } |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 64 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 65 | static RetEffect MakeOwned() { return RetEffect(OwnedSymbol, 0); } |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 66 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 67 | static RetEffect MakeNotOwned() { return RetEffect(NotOwnedSymbol, 0); } |
| 68 | |
| 69 | operator Kind() const { return getKind(); } |
| 70 | |
| 71 | void Profile(llvm::FoldingSetNodeID& ID) const { ID.AddInteger(Data); } |
| 72 | }; |
| 73 | |
| 74 | |
| 75 | class CFRefSummary : public llvm::FoldingSetNode { |
| 76 | ArgEffects* Args; |
| 77 | RetEffect Ret; |
| 78 | public: |
| 79 | |
| 80 | CFRefSummary(ArgEffects* A, RetEffect R) : Args(A), Ret(R) {} |
| 81 | |
| 82 | unsigned getNumArgs() const { return Args->size(); } |
| 83 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 84 | ArgEffect getArg(unsigned idx) const { |
| 85 | assert (idx < getNumArgs()); |
| 86 | return (*Args)[idx]; |
| 87 | } |
| 88 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 89 | RetEffect getRet() const { |
| 90 | return Ret; |
| 91 | } |
| 92 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 93 | typedef ArgEffects::const_iterator arg_iterator; |
| 94 | |
| 95 | arg_iterator begin_args() const { return Args->begin(); } |
| 96 | arg_iterator end_args() const { return Args->end(); } |
| 97 | |
| 98 | static void Profile(llvm::FoldingSetNodeID& ID, ArgEffects* A, RetEffect R) { |
| 99 | ID.AddPointer(A); |
| 100 | ID.Add(R); |
| 101 | } |
| 102 | |
| 103 | void Profile(llvm::FoldingSetNodeID& ID) const { |
| 104 | Profile(ID, Args, Ret); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | |
| 109 | class CFRefSummaryManager { |
| 110 | typedef llvm::FoldingSet<llvm::FoldingSetNodeWrapper<ArgEffects> > AESetTy; |
| 111 | typedef llvm::FoldingSet<CFRefSummary> SummarySetTy; |
| 112 | typedef llvm::DenseMap<FunctionDecl*, CFRefSummary*> SummaryMapTy; |
| 113 | |
| 114 | SummarySetTy SummarySet; |
| 115 | SummaryMapTy SummaryMap; |
| 116 | AESetTy AESet; |
| 117 | llvm::BumpPtrAllocator BPAlloc; |
| 118 | |
| 119 | ArgEffects ScratchArgs; |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 120 | |
| 121 | |
| 122 | ArgEffects* getArgEffects(); |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 123 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 124 | CFRefSummary* getCannedCFSummary(FunctionTypeProto* FT, bool isRetain); |
| 125 | |
| 126 | CFRefSummary* getCFSummary(FunctionDecl* FD, const char* FName); |
| 127 | |
| 128 | CFRefSummary* getCFSummaryCreateRule(FunctionTypeProto* FT); |
| 129 | CFRefSummary* getCFSummaryGetRule(FunctionTypeProto* FT); |
| 130 | |
| 131 | CFRefSummary* getPersistentSummary(ArgEffects* AE, RetEffect RE); |
| 132 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 133 | public: |
| 134 | CFRefSummaryManager() {} |
| 135 | ~CFRefSummaryManager(); |
| 136 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 137 | CFRefSummary* getSummary(FunctionDecl* FD, ASTContext& Ctx); |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | } // end anonymous namespace |
| 141 | |
| 142 | //===----------------------------------------------------------------------===// |
| 143 | // Implementation of checker data structures. |
| 144 | //===----------------------------------------------------------------------===// |
| 145 | |
| 146 | CFRefSummaryManager::~CFRefSummaryManager() { |
| 147 | |
| 148 | // FIXME: The ArgEffects could eventually be allocated from BPAlloc, |
| 149 | // mitigating the need to do explicit cleanup of the |
| 150 | // Argument-Effect summaries. |
| 151 | |
| 152 | for (AESetTy::iterator I = AESet.begin(), E = AESet.end(); I!=E; ++I) |
| 153 | I->getValue().~ArgEffects(); |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 154 | } |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 155 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 156 | ArgEffects* CFRefSummaryManager::getArgEffects() { |
| 157 | |
| 158 | assert (!ScratchArgs.empty()); |
| 159 | |
| 160 | llvm::FoldingSetNodeID profile; |
| 161 | profile.Add(ScratchArgs); |
| 162 | void* InsertPos; |
| 163 | |
| 164 | llvm::FoldingSetNodeWrapper<ArgEffects>* E = |
| 165 | AESet.FindNodeOrInsertPos(profile, InsertPos); |
| 166 | |
| 167 | if (E) { |
| 168 | ScratchArgs.clear(); |
| 169 | return &E->getValue(); |
| 170 | } |
| 171 | |
| 172 | E = (llvm::FoldingSetNodeWrapper<ArgEffects>*) |
| 173 | BPAlloc.Allocate<llvm::FoldingSetNodeWrapper<ArgEffects> >(); |
| 174 | |
| 175 | new (E) llvm::FoldingSetNodeWrapper<ArgEffects>(ScratchArgs); |
| 176 | AESet.InsertNode(E, InsertPos); |
| 177 | |
| 178 | ScratchArgs.clear(); |
| 179 | return &E->getValue(); |
| 180 | } |
| 181 | |
| 182 | CFRefSummary* CFRefSummaryManager::getPersistentSummary(ArgEffects* AE, |
| 183 | RetEffect RE) { |
| 184 | |
| 185 | llvm::FoldingSetNodeID profile; |
| 186 | CFRefSummary::Profile(profile, AE, RE); |
| 187 | void* InsertPos; |
| 188 | |
| 189 | CFRefSummary* Summ = SummarySet.FindNodeOrInsertPos(profile, InsertPos); |
| 190 | |
| 191 | if (Summ) |
| 192 | return Summ; |
| 193 | |
| 194 | Summ = (CFRefSummary*) BPAlloc.Allocate<CFRefSummary>(); |
| 195 | new (Summ) CFRefSummary(AE, RE); |
| 196 | SummarySet.InsertNode(Summ, InsertPos); |
| 197 | |
| 198 | return Summ; |
| 199 | } |
| 200 | |
| 201 | |
| 202 | CFRefSummary* CFRefSummaryManager::getSummary(FunctionDecl* FD, |
| 203 | ASTContext& Ctx) { |
| 204 | |
| 205 | SourceLocation Loc = FD->getLocation(); |
| 206 | |
| 207 | if (!Loc.isFileID()) |
| 208 | return NULL; |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 209 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 210 | { // Look into our cache of summaries to see if we have already computed |
| 211 | // a summary for this FunctionDecl. |
| 212 | |
| 213 | SummaryMapTy::iterator I = SummaryMap.find(FD); |
| 214 | |
| 215 | if (I != SummaryMap.end()) |
| 216 | return I->second; |
| 217 | } |
| 218 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 219 | #if 0 |
| 220 | SourceManager& SrcMgr = Ctx.getSourceManager(); |
| 221 | unsigned fid = Loc.getFileID(); |
| 222 | const FileEntry* FE = SrcMgr.getFileEntryForID(fid); |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 223 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 224 | if (!FE) |
| 225 | return NULL; |
| 226 | |
| 227 | const char* DirName = FE->getDir()->getName(); |
| 228 | assert (DirName); |
| 229 | assert (strlen(DirName) > 0); |
| 230 | |
| 231 | if (!strstr(DirName, "CoreFoundation")) { |
| 232 | SummaryMap[FD] = NULL; |
| 233 | return NULL; |
| 234 | } |
| 235 | #endif |
| 236 | |
| 237 | const char* FName = FD->getIdentifier()->getName(); |
| 238 | |
| 239 | if (FName[0] == 'C' && FName[1] == 'F') { |
| 240 | CFRefSummary* S = getCFSummary(FD, FName); |
| 241 | SummaryMap[FD] = S; |
| 242 | return S; |
| 243 | } |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 244 | |
| 245 | return NULL; |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 246 | } |
| 247 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 248 | CFRefSummary* CFRefSummaryManager::getCFSummary(FunctionDecl* FD, |
| 249 | const char* FName) { |
| 250 | |
| 251 | // For now, only generate summaries for functions that have a prototype. |
| 252 | |
| 253 | FunctionTypeProto* FT = |
| 254 | dyn_cast<FunctionTypeProto>(FD->getType().getTypePtr()); |
| 255 | |
| 256 | if (!FT) |
| 257 | return NULL; |
| 258 | |
| 259 | FName += 2; |
| 260 | |
| 261 | if (strcmp(FName, "Retain") == 0) |
| 262 | return getCannedCFSummary(FT, true); |
| 263 | |
| 264 | if (strcmp(FName, "Release") == 0) |
| 265 | return getCannedCFSummary(FT, false); |
| 266 | |
| 267 | assert (ScratchArgs.empty()); |
| 268 | bool usesCreateRule = false; |
| 269 | |
| 270 | if (strstr(FName, "Create")) |
| 271 | usesCreateRule = true; |
| 272 | |
| 273 | if (!usesCreateRule && strstr(FName, "Copy")) |
| 274 | usesCreateRule = true; |
| 275 | |
| 276 | if (usesCreateRule) |
| 277 | return getCFSummaryCreateRule(FT); |
| 278 | |
| 279 | if (strstr(FName, "Get")) |
| 280 | return getCFSummaryGetRule(FT); |
| 281 | |
| 282 | return NULL; |
| 283 | } |
| 284 | |
| 285 | CFRefSummary* CFRefSummaryManager::getCannedCFSummary(FunctionTypeProto* FT, |
| 286 | bool isRetain) { |
| 287 | |
| 288 | if (FT->getNumArgs() != 1) |
| 289 | return NULL; |
| 290 | |
| 291 | TypedefType* ArgT = dyn_cast<TypedefType>(FT->getArgType(0).getTypePtr()); |
| 292 | |
| 293 | if (!ArgT) |
| 294 | return NULL; |
| 295 | |
| 296 | // For CFRetain/CFRelease, the first (and only) argument is of type |
| 297 | // "CFTypeRef". |
| 298 | |
| 299 | const char* TDName = ArgT->getDecl()->getIdentifier()->getName(); |
| 300 | assert (TDName); |
| 301 | |
| 302 | if (strcmp("CFTypeRef", TDName) == 0) |
| 303 | return NULL; |
| 304 | |
| 305 | if (!ArgT->isPointerType()) |
| 306 | return NULL; |
| 307 | |
| 308 | // Check the return type. It should also be "CFTypeRef". |
| 309 | |
| 310 | QualType RetTy = FT->getResultType(); |
| 311 | |
| 312 | if (RetTy.getTypePtr() != ArgT) |
| 313 | return NULL; |
| 314 | |
| 315 | // The function's interface checks out. Generate a canned summary. |
| 316 | |
| 317 | assert (ScratchArgs.empty()); |
| 318 | ScratchArgs.push_back(isRetain ? IncRef : DecRef); |
| 319 | |
| 320 | return getPersistentSummary(getArgEffects(), RetEffect::MakeAlias(0)); |
| 321 | } |
| 322 | |
| 323 | static bool isCFRefType(QualType T) { |
| 324 | |
| 325 | if (!T->isPointerType()) |
| 326 | return false; |
| 327 | |
| 328 | // Check the typedef for the name "CF" and the substring "Ref". |
| 329 | |
| 330 | TypedefType* TD = dyn_cast<TypedefType>(T.getTypePtr()); |
| 331 | |
| 332 | if (!TD) |
| 333 | return false; |
| 334 | |
| 335 | const char* TDName = TD->getDecl()->getIdentifier()->getName(); |
| 336 | assert (TDName); |
| 337 | |
| 338 | if (TDName[0] != 'C' || TDName[1] != 'F') |
| 339 | return false; |
| 340 | |
| 341 | if (strstr(TDName, "Ref") == 0) |
| 342 | return false; |
| 343 | |
| 344 | return true; |
| 345 | } |
| 346 | |
| 347 | |
| 348 | CFRefSummary* |
| 349 | CFRefSummaryManager::getCFSummaryCreateRule(FunctionTypeProto* FT) { |
| 350 | |
| 351 | if (!isCFRefType(FT->getResultType())) |
| 352 | return NULL; |
| 353 | |
| 354 | assert (ScratchArgs.empty()); |
| 355 | |
| 356 | // FIXME: Add special-cases for functions that retain/release. For now |
| 357 | // just handle the default case. |
| 358 | |
| 359 | for (unsigned i = 0, n = FT->getNumArgs(); i != n; ++i) |
| 360 | ScratchArgs.push_back(DoNothing); |
| 361 | |
| 362 | return getPersistentSummary(getArgEffects(), RetEffect::MakeOwned()); |
| 363 | } |
| 364 | |
| 365 | CFRefSummary* |
| 366 | CFRefSummaryManager::getCFSummaryGetRule(FunctionTypeProto* FT) { |
| 367 | |
| 368 | if (!isCFRefType(FT->getResultType())) |
| 369 | return NULL; |
| 370 | |
| 371 | assert (ScratchArgs.empty()); |
| 372 | |
| 373 | // FIXME: Add special-cases for functions that retain/release. For now |
| 374 | // just handle the default case. |
| 375 | |
| 376 | for (unsigned i = 0, n = FT->getNumArgs(); i != n; ++i) |
| 377 | ScratchArgs.push_back(DoNothing); |
| 378 | |
| 379 | return getPersistentSummary(getArgEffects(), RetEffect::MakeNotOwned()); |
| 380 | } |
| 381 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 382 | //===----------------------------------------------------------------------===// |
| 383 | // Transfer functions. |
| 384 | //===----------------------------------------------------------------------===// |
| 385 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 386 | namespace { |
| 387 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 388 | class RefVal { |
| 389 | unsigned Data; |
| 390 | |
| 391 | RefVal(unsigned K, unsigned D) : Data((D << 3) | K) { |
| 392 | assert ((K & ~0x5) == 0x0); |
| 393 | } |
| 394 | |
| 395 | RefVal(unsigned K) : Data(K) { |
| 396 | assert ((K & ~0x5) == 0x0); |
| 397 | } |
| 398 | |
| 399 | public: |
| 400 | enum Kind { Owned = 0, AcqOwned = 1, NotOwned = 2, Released = 3, |
| 401 | ErrorUseAfterRelease = 4, ErrorReleaseNotOwned = 5 }; |
| 402 | |
| 403 | |
| 404 | Kind getKind() const { return (Kind) (Data & 0x5); } |
| 405 | |
| 406 | unsigned getCount() const { |
| 407 | assert (getKind() == Owned || getKind() == AcqOwned); |
| 408 | return Data >> 3; |
| 409 | } |
| 410 | |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 411 | static bool isError(Kind k) { return k >= ErrorUseAfterRelease; } |
| 412 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 413 | static RefVal makeOwned(unsigned Count) { return RefVal(Owned, Count); } |
| 414 | static RefVal makeAcqOwned(unsigned Count) { return RefVal(AcqOwned, Count); } |
| 415 | static RefVal makeNotOwned() { return RefVal(NotOwned); } |
| 416 | static RefVal makeReleased() { return RefVal(Released); } |
| 417 | static RefVal makeUseAfterRelease() { return RefVal(ErrorUseAfterRelease); } |
| 418 | static RefVal makeReleaseNotOwned() { return RefVal(ErrorReleaseNotOwned); } |
| 419 | |
| 420 | bool operator==(const RefVal& X) const { return Data == X.Data; } |
| 421 | void Profile(llvm::FoldingSetNodeID& ID) const { ID.AddInteger(Data); } |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 422 | |
| 423 | void print(std::ostream& Out) const; |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 424 | }; |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 425 | |
| 426 | void RefVal::print(std::ostream& Out) const { |
| 427 | switch (getKind()) { |
| 428 | default: assert(false); |
| 429 | case Owned: |
| 430 | Out << "Owned(" << getCount() << ")"; |
| 431 | break; |
| 432 | |
| 433 | case AcqOwned: |
| 434 | Out << "Acquired-Owned(" << getCount() << ")"; |
| 435 | break; |
| 436 | |
| 437 | case NotOwned: |
| 438 | Out << "Not-Owned"; |
| 439 | break; |
| 440 | |
| 441 | case Released: |
| 442 | Out << "Released"; |
| 443 | break; |
| 444 | |
| 445 | case ErrorUseAfterRelease: |
| 446 | Out << "Use-After-Release [ERROR]"; |
| 447 | break; |
| 448 | |
| 449 | case ErrorReleaseNotOwned: |
| 450 | Out << "Release of Not-Owned [ERROR]"; |
| 451 | break; |
| 452 | } |
| 453 | } |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 454 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 455 | class CFRefCount : public GRSimpleVals { |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 456 | |
| 457 | // Type definitions. |
| 458 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 459 | typedef llvm::ImmutableMap<SymbolID, RefVal> RefBindings; |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 460 | typedef RefBindings::Factory RefBFactoryTy; |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 461 | |
| 462 | typedef llvm::SmallPtrSet<GRExprEngine::NodeTy*,2> UseAfterReleasesTy; |
| 463 | typedef llvm::SmallPtrSet<GRExprEngine::NodeTy*,2> ReleasesNotOwnedTy; |
| 464 | |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 465 | class BindingsPrinter : public ValueState::CheckerStatePrinter { |
| 466 | public: |
| 467 | virtual void PrintCheckerState(std::ostream& Out, void* State, |
| 468 | const char* nl, const char* sep); |
| 469 | }; |
| 470 | |
| 471 | // Instance variables. |
| 472 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 473 | CFRefSummaryManager Summaries; |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 474 | RefBFactoryTy RefBFactory; |
| 475 | |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 476 | UseAfterReleasesTy UseAfterReleases; |
| 477 | ReleasesNotOwnedTy ReleasesNotOwned; |
| 478 | |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 479 | BindingsPrinter Printer; |
| 480 | |
| 481 | // Private methods. |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 482 | |
| 483 | static RefBindings GetRefBindings(ValueState& StImpl) { |
| 484 | return RefBindings((RefBindings::TreeTy*) StImpl.CheckerState); |
| 485 | } |
| 486 | |
| 487 | static void SetRefBindings(ValueState& StImpl, RefBindings B) { |
| 488 | StImpl.CheckerState = B.getRoot(); |
| 489 | } |
| 490 | |
| 491 | RefBindings Remove(RefBindings B, SymbolID sym) { |
| 492 | return RefBFactory.Remove(B, sym); |
| 493 | } |
| 494 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 495 | RefBindings Update(RefBindings B, SymbolID sym, RefVal V, ArgEffect E, |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 496 | RefVal::Kind& hasError); |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 497 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 498 | |
| 499 | public: |
| 500 | CFRefCount() {} |
| 501 | virtual ~CFRefCount() {} |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 502 | |
| 503 | virtual ValueState::CheckerStatePrinter* getCheckerStatePrinter() { |
| 504 | return &Printer; |
| 505 | } |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 506 | |
| 507 | // Calls. |
| 508 | |
| 509 | virtual void EvalCall(ExplodedNodeSet<ValueState>& Dst, |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 510 | GRExprEngine& Eng, |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 511 | GRStmtNodeBuilder<ValueState>& Builder, |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 512 | CallExpr* CE, LVal L, |
| 513 | ExplodedNode<ValueState>* Pred); |
| 514 | }; |
| 515 | |
| 516 | } // end anonymous namespace |
| 517 | |
Ted Kremenek | f394804 | 2008-03-11 19:44:10 +0000 | [diff] [blame] | 518 | void CFRefCount::BindingsPrinter::PrintCheckerState(std::ostream& Out, |
| 519 | void* State, const char* nl, |
| 520 | const char* sep) { |
| 521 | RefBindings B((RefBindings::TreeTy*) State); |
| 522 | |
| 523 | if (State) |
| 524 | Out << sep << nl; |
| 525 | |
| 526 | for (RefBindings::iterator I=B.begin(), E=B.end(); I!=E; ++I) { |
| 527 | Out << (*I).first << " : "; |
| 528 | (*I).second.print(Out); |
| 529 | Out << nl; |
| 530 | } |
| 531 | } |
| 532 | |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 533 | void CFRefCount::EvalCall(ExplodedNodeSet<ValueState>& Dst, |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 534 | GRExprEngine& Eng, |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 535 | GRStmtNodeBuilder<ValueState>& Builder, |
| 536 | CallExpr* CE, LVal L, |
| 537 | ExplodedNode<ValueState>* Pred) { |
| 538 | |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 539 | ValueStateManager& StateMgr = Eng.getStateManager(); |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 540 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 541 | // FIXME: Support calls to things other than lval::FuncVal. At the very |
| 542 | // least we should stop tracking ref-state for ref-counted objects passed |
| 543 | // to these functions. |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 544 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 545 | assert (isa<lval::FuncVal>(L) && "Not yet implemented."); |
| 546 | |
| 547 | // Get the summary. |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 548 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 549 | lval::FuncVal FV = cast<lval::FuncVal>(L); |
| 550 | FunctionDecl* FD = FV.getDecl(); |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 551 | CFRefSummary* Summ = Summaries.getSummary(FD, Eng.getContext()); |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 552 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 553 | // Get the state. |
| 554 | |
| 555 | ValueState* St = Builder.GetState(Pred); |
| 556 | |
| 557 | // Evaluate the effects of the call. |
| 558 | |
| 559 | ValueState StVals = *St; |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 560 | RefVal::Kind hasError = (RefVal::Kind) 0; |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 561 | |
| 562 | if (!Summ) { |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 563 | |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 564 | // This function has no summary. Invalidate all reference-count state |
| 565 | // for arguments passed to this function, and also nuke the values of |
| 566 | // arguments passed-by-reference. |
| 567 | |
| 568 | ValueState StVals = *St; |
| 569 | |
| 570 | for (CallExpr::arg_iterator I = CE->arg_begin(), E = CE->arg_end(); |
| 571 | I != E; ++I) { |
| 572 | |
| 573 | RVal V = StateMgr.GetRVal(St, *I); |
| 574 | |
| 575 | if (isa<lval::SymbolVal>(V)) { |
| 576 | SymbolID Sym = cast<lval::SymbolVal>(V).getSymbol(); |
| 577 | RefBindings B = GetRefBindings(StVals); |
| 578 | SetRefBindings(StVals, Remove(B, Sym)); |
| 579 | } |
| 580 | |
| 581 | if (isa<LVal>(V)) |
| 582 | StateMgr.Unbind(StVals, cast<LVal>(V)); |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | St = StateMgr.getPersistentState(StVals); |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 586 | |
| 587 | // Make up a symbol for the return value of this function. |
| 588 | |
| 589 | if (CE->getType() != Eng.getContext().VoidTy) { |
| 590 | unsigned Count = Builder.getCurrentBlockCount(); |
Ted Kremenek | 361fa8e | 2008-03-12 21:45:47 +0000 | [diff] [blame] | 591 | SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count); |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 592 | |
| 593 | RVal X = CE->getType()->isPointerType() |
| 594 | ? cast<RVal>(lval::SymbolVal(Sym)) |
| 595 | : cast<RVal>(nonlval::SymbolVal(Sym)); |
| 596 | |
| 597 | St = StateMgr.SetRVal(St, CE, X, Eng.getCFG().isBlkExpr(CE), false); |
| 598 | } |
| 599 | |
Ted Kremenek | 0e561a3 | 2008-03-21 21:30:14 +0000 | [diff] [blame^] | 600 | Builder.MakeNode(Dst, CE, Pred, St); |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 601 | return; |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 602 | } |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 603 | |
| 604 | // This function has a summary. Evaluate the effect of the arguments. |
| 605 | |
| 606 | unsigned idx = 0; |
| 607 | |
| 608 | for (CallExpr::arg_iterator I=CE->arg_begin(), E=CE->arg_end(); |
| 609 | I!=E; ++I, ++idx) { |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 610 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 611 | RVal V = StateMgr.GetRVal(St, *I); |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 612 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 613 | if (isa<lval::SymbolVal>(V)) { |
| 614 | SymbolID Sym = cast<lval::SymbolVal>(V).getSymbol(); |
| 615 | RefBindings B = GetRefBindings(StVals); |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 616 | |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 617 | if (RefBindings::TreeTy* T = B.SlimFind(Sym)) { |
| 618 | B = Update(B, Sym, T->getValue().second, Summ->getArg(idx), hasError); |
| 619 | SetRefBindings(StVals, B); |
| 620 | if (hasError) break; |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 621 | } |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 622 | } |
| 623 | } |
| 624 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 625 | if (hasError) { |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 626 | St = StateMgr.getPersistentState(StVals); |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 627 | GRExprEngine::NodeTy* N = Builder.generateNode(CE, St, Pred); |
| 628 | |
| 629 | if (N) { |
| 630 | N->markAsSink(); |
| 631 | |
| 632 | switch (hasError) { |
| 633 | default: assert(false); |
| 634 | case RefVal::ErrorUseAfterRelease: |
| 635 | UseAfterReleases.insert(N); |
| 636 | break; |
| 637 | |
| 638 | case RefVal::ErrorReleaseNotOwned: |
| 639 | ReleasesNotOwned.insert(N); |
| 640 | break; |
| 641 | } |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 642 | } |
| 643 | |
| 644 | return; |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 645 | } |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 646 | |
| 647 | // Finally, consult the summary for the return value. |
| 648 | |
| 649 | RetEffect RE = Summ->getRet(); |
| 650 | St = StateMgr.getPersistentState(StVals); |
| 651 | |
| 652 | |
| 653 | switch (RE.getKind()) { |
| 654 | default: |
| 655 | assert (false && "Unhandled RetEffect."); break; |
| 656 | |
| 657 | case RetEffect::Alias: { |
| 658 | unsigned idx = RE.getValue(); |
| 659 | assert (idx < CE->getNumArgs()); |
| 660 | RVal V = StateMgr.GetRVal(St, CE->getArg(idx)); |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 661 | St = StateMgr.SetRVal(St, CE, V, Eng.getCFG().isBlkExpr(CE), false); |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 662 | break; |
| 663 | } |
| 664 | |
| 665 | case RetEffect::OwnedSymbol: { |
| 666 | unsigned Count = Builder.getCurrentBlockCount(); |
Ted Kremenek | 361fa8e | 2008-03-12 21:45:47 +0000 | [diff] [blame] | 667 | SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count); |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 668 | |
| 669 | ValueState StImpl = *St; |
| 670 | RefBindings B = GetRefBindings(StImpl); |
| 671 | SetRefBindings(StImpl, RefBFactory.Add(B, Sym, RefVal::makeOwned(1))); |
| 672 | |
| 673 | St = StateMgr.SetRVal(StateMgr.getPersistentState(StImpl), |
| 674 | CE, lval::SymbolVal(Sym), |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 675 | Eng.getCFG().isBlkExpr(CE), false); |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 676 | |
| 677 | break; |
| 678 | } |
| 679 | |
| 680 | case RetEffect::NotOwnedSymbol: { |
| 681 | unsigned Count = Builder.getCurrentBlockCount(); |
Ted Kremenek | 361fa8e | 2008-03-12 21:45:47 +0000 | [diff] [blame] | 682 | SymbolID Sym = Eng.getSymbolManager().getConjuredSymbol(CE, Count); |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 683 | |
| 684 | ValueState StImpl = *St; |
| 685 | RefBindings B = GetRefBindings(StImpl); |
| 686 | SetRefBindings(StImpl, RefBFactory.Add(B, Sym, RefVal::makeNotOwned())); |
| 687 | |
| 688 | St = StateMgr.SetRVal(StateMgr.getPersistentState(StImpl), |
| 689 | CE, lval::SymbolVal(Sym), |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 690 | Eng.getCFG().isBlkExpr(CE), false); |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 691 | |
| 692 | break; |
| 693 | } |
| 694 | } |
| 695 | |
Ted Kremenek | 0e561a3 | 2008-03-21 21:30:14 +0000 | [diff] [blame^] | 696 | Builder.MakeNode(Dst, CE, Pred, St); |
Ted Kremenek | 2fff37e | 2008-03-06 00:08:09 +0000 | [diff] [blame] | 697 | } |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 698 | |
| 699 | |
| 700 | CFRefCount::RefBindings CFRefCount::Update(RefBindings B, SymbolID sym, |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 701 | RefVal V, ArgEffect E, |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 702 | RefVal::Kind& hasError) { |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 703 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 704 | // FIXME: This dispatch can potentially be sped up by unifiying it into |
| 705 | // a single switch statement. Opt for simplicity for now. |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 706 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 707 | switch (E) { |
| 708 | default: |
| 709 | assert (false && "Unhandled CFRef transition."); |
| 710 | |
| 711 | case DoNothing: |
Ted Kremenek | 00a3a5f | 2008-03-12 01:21:45 +0000 | [diff] [blame] | 712 | if (V.getKind() == RefVal::Released) { |
| 713 | V = RefVal::makeUseAfterRelease(); |
| 714 | hasError = V.getKind(); |
| 715 | break; |
| 716 | } |
| 717 | |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 718 | return B; |
| 719 | |
| 720 | case IncRef: |
| 721 | switch (V.getKind()) { |
| 722 | default: |
| 723 | assert(false); |
| 724 | |
| 725 | case RefVal::Owned: |
| 726 | V = RefVal::makeOwned(V.getCount()+1); break; |
| 727 | |
| 728 | case RefVal::AcqOwned: |
| 729 | V = RefVal::makeAcqOwned(V.getCount()+1); |
| 730 | break; |
| 731 | |
| 732 | case RefVal::NotOwned: |
| 733 | V = RefVal::makeAcqOwned(1); |
| 734 | break; |
| 735 | |
| 736 | case RefVal::Released: |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 737 | V = RefVal::makeUseAfterRelease(); |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 738 | hasError = V.getKind(); |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 739 | break; |
| 740 | } |
| 741 | |
| 742 | case DecRef: |
| 743 | switch (V.getKind()) { |
| 744 | default: |
| 745 | assert (false); |
| 746 | |
| 747 | case RefVal::Owned: { |
| 748 | unsigned Count = V.getCount() - 1; |
| 749 | V = Count ? RefVal::makeOwned(Count) : RefVal::makeReleased(); |
| 750 | break; |
| 751 | } |
| 752 | |
| 753 | case RefVal::AcqOwned: { |
| 754 | unsigned Count = V.getCount() - 1; |
| 755 | V = Count ? RefVal::makeAcqOwned(Count) : RefVal::makeNotOwned(); |
| 756 | break; |
| 757 | } |
| 758 | |
| 759 | case RefVal::NotOwned: |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 760 | V = RefVal::makeReleaseNotOwned(); |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 761 | hasError = V.getKind(); |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 762 | break; |
| 763 | |
| 764 | case RefVal::Released: |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 765 | V = RefVal::makeUseAfterRelease(); |
Ted Kremenek | 73c750b | 2008-03-11 18:14:09 +0000 | [diff] [blame] | 766 | hasError = V.getKind(); |
Ted Kremenek | 1ac08d6 | 2008-03-11 17:48:22 +0000 | [diff] [blame] | 767 | break; |
| 768 | } |
| 769 | } |
| 770 | |
| 771 | return RefBFactory.Add(B, sym, V); |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | //===----------------------------------------------------------------------===// |
| 775 | // Driver for the CFRefCount Checker. |
| 776 | //===----------------------------------------------------------------------===// |
| 777 | |
| 778 | namespace clang { |
| 779 | |
Ted Kremenek | 63bbe53 | 2008-03-14 17:31:00 +0000 | [diff] [blame] | 780 | void CheckCFRefCount(CFG& cfg, Decl& CD, ASTContext& Ctx, |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 781 | Diagnostic& Diag) { |
| 782 | |
| 783 | if (Diag.hasErrorOccurred()) |
| 784 | return; |
| 785 | |
| 786 | // FIXME: Refactor some day so this becomes a single function invocation. |
| 787 | |
Ted Kremenek | 63bbe53 | 2008-03-14 17:31:00 +0000 | [diff] [blame] | 788 | GRCoreEngine<GRExprEngine> Eng(cfg, CD, Ctx); |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 789 | GRExprEngine* CS = &Eng.getCheckerState(); |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 790 | CFRefCount TF; |
| 791 | CS->setTransferFunctions(TF); |
Ted Kremenek | 199e1a0 | 2008-03-12 21:06:49 +0000 | [diff] [blame] | 792 | Eng.ExecuteWorkList(20000); |
Ted Kremenek | 6b3a0f7 | 2008-03-11 06:39:11 +0000 | [diff] [blame] | 793 | |
| 794 | } |
| 795 | |
| 796 | } // end clang namespace |