Commit Graph

488 Commits

Author SHA1 Message Date
Ted Kremenek 289c37ad8d Use llvm::raw_string_ostream instead of std::ostringstream.
llvm-svn: 58479
2008-10-31 00:18:30 +00:00
Ted Kremenek 83214f9f9a Enhance path-sensitive return-of-stack-address check to print out the line number of a compound literal (whose address is being returned) instead of printing out the hex representation of the pointer address of the CompoundLiteralExpr.
llvm-svn: 58478
2008-10-31 00:13:20 +00:00
Ted Kremenek 4c276c736c Extend "followsFundamentalRule" to ignore prefix '_' characters.
llvm-svn: 58469
2008-10-30 23:14:58 +00:00
Ted Kremenek 828e6dff9b Handle the case in VisitInitListExprs where there are no initializers in the compound literal.
llvm-svn: 58468
2008-10-30 23:14:36 +00:00
Ted Kremenek 6955463c24 Distinguish between self.X = ... where self.X is a property reference and self.X is an implicit call to setX.
llvm-svn: 58462
2008-10-30 22:28:48 +00:00
Ted Kremenek 0f0adc97c5 Use the correct predecessor node.
llvm-svn: 58446
2008-10-30 18:37:08 +00:00
Ted Kremenek e40b698953 Pretty-printing for SVals now mainly uses llvm::raw_ostream. We have an adapter for std::ostream, but this will be removed in the future.
llvm-svn: 58445
2008-10-30 18:35:10 +00:00
Ted Kremenek 28f41ba829 Add missing return statement.
llvm-svn: 58444
2008-10-30 18:34:31 +00:00
Ted Kremenek cbdce2e53a Added iterators to nonloc::CompoundSVal.
Added pretty-printing for nonloc::CompoundSVal.

llvm-svn: 58442
2008-10-30 18:01:28 +00:00
Ted Kremenek 0e19c03382 80 col violation.
llvm-svn: 58441
2008-10-30 17:53:23 +00:00
Ted Kremenek f68bf63611 Use a worklist in GRExprEngine::VisitInitListExpr to process subexpressions.
llvm-svn: 58440
2008-10-30 17:47:32 +00:00
Ted Kremenek ec9a252a9b CompoundVal now uses an ImmutableList<SVal> to store its set of SVals. This change was motivated by the need to allow state-splitting in GRExprEngine::VisitInitListExpr. As a side-benefit, we no longer need to perform any copies of SVals when creating a CompoundSVal, and the profiling of CompoundSVal is now constant time.
llvm-svn: 58437
2008-10-30 17:44:46 +00:00
Ted Kremenek 689ec0eb32 Patch by Nikita Zhuk:
Fix PR 2978 false positive for missing release in -dealloc of an ivar retained via a property and then released by assigning nil to that property:

  http://llvm.org/bugs/show_bug.cgi?id=2978

llvm-svn: 58431
2008-10-30 15:13:43 +00:00
Zhongxing Xu 610634fe39 Merge the array and struct case. They are essentially the same.
llvm-svn: 58422
2008-10-30 05:35:59 +00:00
Zhongxing Xu a15cfd4db9 Rename:
- SetSVal(GRState*, Loc, SVal) => BindLoc
 - SetSVal(GRState*, Expr*, SVal) => BindExpr 

llvm-svn: 58421
2008-10-30 05:33:54 +00:00
Zhongxing Xu b281cdda87 Implement VisitInitListExpr(). InitListExpr will have a nonloc::CompoundVal value.
llvm-svn: 58419
2008-10-30 05:02:23 +00:00
Zhongxing Xu ef5f25a05f Add CompoundVal and CompoundValData for representing the value of InitListExpr.
llvm-svn: 58418
2008-10-30 04:58:00 +00:00
Zhongxing Xu 51ac923ca3 Fix 80-col.
llvm-svn: 58417
2008-10-30 04:53:23 +00:00
Ted Kremenek 204ae1f0d9 Mark yy_fatal_error as a panic function.
llvm-svn: 58410
2008-10-30 00:00:57 +00:00
Zhongxing Xu 9c15820ea6 Add notes for SCA.
llvm-svn: 58373
2008-10-29 07:05:10 +00:00
Ted Kremenek 3f04949b2a Patch by Nikita Zhuk:
The attached patch adds additional checks to -warn-objc-missing-dealloc. It checks that all ivars which are used in implementation of synthesized properties are either

a) released in dealloc if the property has retain" or "copy" attribute OR
b) not released in dealloc if the property has "assign" attribute

llvm-svn: 58363
2008-10-29 04:30:28 +00:00
Ted Kremenek 3700b762ff IOServiceGetMatchingServices is a release function.
llvm-svn: 58362
2008-10-29 04:07:07 +00:00
Zhongxing Xu 628ae879ea Rename: AddDecl => BindDecl
BindDecl better describes what the function does:
  - Bind the VarDecl to its memory region
  - Bind the memory region to some initial value.

llvm-svn: 58359
2008-10-29 02:34:02 +00:00
Douglas Gregor f19b2319c9 Rename ExplicitCCastExpr to CStyleCastExpr
llvm-svn: 58331
2008-10-28 15:36:24 +00:00
Zhongxing Xu c3c104ec9c Add newline.
llvm-svn: 58322
2008-10-28 09:32:08 +00:00
Zhongxing Xu c94dce9f95 Update random notes.
llvm-svn: 58321
2008-10-28 09:09:48 +00:00
Douglas Gregor 6b75484ba6 Improve our handling of (C++) references within Clang. Specifically:
- Do not allow expressions to ever have reference type
  - Extend Expr::isLvalue to handle more cases where having written a
    reference into the source implies that the expression is an lvalue
    (e.g., function calls, C++ casts).
  - Make GRExprEngine::VisitCall treat the call arguments as lvalues when
    they are being bound to a reference parameter.

llvm-svn: 58306
2008-10-28 00:22:11 +00:00
Ted Kremenek 1a658a991e - Fix type-punning warning in SVals.cpp by using a real iterator class for symbol_iterator.
- Add symbol_iterator support for SymbolicRegions.

llvm-svn: 58300
2008-10-27 23:39:39 +00:00
Ted Kremenek 54d399ac5d Remove type-punning warning in GRExprEngine. No functionality change.
llvm-svn: 58292
2008-10-27 23:02:39 +00:00
Ted Kremenek bf26368255 Added preliminary support for CompoundLiterals in the static analyzer:
- GRExprEngine::VisitCompoundLiteral...
   (1) visits the initializer list (generating ExplodedNodes)
   (2) creates a CompoundMemRegion for the literal
   (3) creates a new state with the bound literal values using
       GRStateManager::BindCompoundLiteral

- GRStateManager::BindCompoundLiteral simply calls 
  StoreManager::BindCompoundLiteral to get a new store and returns a persistent
  GRState with that store.

- BasicStore::BindCompoundLiteral simply returns the same store, as it
  doesn't handle field sensitivity
  
- RegionStore::BindCompoundLiteral currently fires an assert (pending discussion
  of how to best implement mappings for CompoundLiteralRegion).

llvm-svn: 58277
2008-10-27 21:54:31 +00:00
Ted Kremenek eaf5e24cbb Pull determination of the super region for a VarRegion into a single getVarRegion() method. This provides a common clean API for clients.
llvm-svn: 58272
2008-10-27 21:01:26 +00:00
Ted Kremenek bc48caf383 Added CompoundLiteralRegion to represent the (temporary) memory allocated for a compound literal.
llvm-svn: 58270
2008-10-27 20:57:58 +00:00
Douglas Gregor e200adc503 Refactor the expression class hierarchy for casts. Most importantly:
- CastExpr is the root of all casts
  - ImplicitCastExpr is (still) used for all explicit casts
  - ExplicitCastExpr is now the root of all *explicit* casts
  - ExplicitCCastExpr (new name needed!?) is a C-style cast in C or C++
  - CXXFunctionalCastExpr inherits from ExplicitCastExpr
  - CXXNamedCastExpr inherits from ExplicitCastExpr and is the root of all
    of the C++ named cast expression types (static_cast, dynamic_cast, etc.)
  - Added classes CXXStaticCastExpr, CXXDynamicCastExpr, 
    CXXReinterpretCastExpr, and CXXConstCastExpr to 

Also, fixed returned-stack-addr.cpp, which broke once when we fixed
reinterpret_cast to diagnose double->int* conversions and again when
we eliminated implicit conversions to reference types. The fix is in
both testcase and SemaChecking.cpp.

Most of this patch is simply support for the renaming. There's very
little actual change in semantics.

llvm-svn: 58264
2008-10-27 19:41:14 +00:00
Zhongxing Xu 144d7554c4 Use ASTContext::getCanonicalType() to get TypedRegion's type.
llvm-svn: 58247
2008-10-27 13:35:03 +00:00
Zhongxing Xu 7b700575dd An ElementRegion is really a typed region. Its super region's type has to be ArrayType.
llvm-svn: 58245
2008-10-27 13:17:02 +00:00
Zhongxing Xu 36d4ade4be We cannot get precise lvalue for symbolic base array region.
llvm-svn: 58243
2008-10-27 12:23:17 +00:00
Zhongxing Xu bb18b57f53 Get the canonical type for struct initialization. The original code would crash on TypedefType.
llvm-svn: 58236
2008-10-27 09:24:07 +00:00
Zhongxing Xu d7c44059d4 Only loc::MemRegionVal can be modified. This avoids crashing in RegionStore when a function pointer is used as an argument.
llvm-svn: 58233
2008-10-27 09:00:08 +00:00
Zhongxing Xu 60de6c6c63 Remove loc::StringLiteralVal. Now we allocate regions for string literals in the Store.
llvm-svn: 58182
2008-10-26 02:27:21 +00:00
Zhongxing Xu bf47dc85fe Simplify ArrayToPointer conversion. Actually the only thing we need to do is to get the first element region. It is not necessary to care about the kind of the base array region.
llvm-svn: 58181
2008-10-26 02:23:57 +00:00
Oscar Fuentes 07d9f9a6ec CMake: Builds and installs clang binary and libs (no docs yet). It
must be under the `tools' subdirectory of the LLVM *source* tree.

llvm-svn: 58180
2008-10-26 00:56:18 +00:00
Ted Kremenek e69a1fa342 Do not crash when performing VisitLValue on union types.
This fixes PR 2948.

llvm-svn: 58148
2008-10-25 20:09:21 +00:00
Zhongxing Xu 195839dd53 Add a note file for SCA module. Is it the right place?
llvm-svn: 58140
2008-10-25 14:56:36 +00:00
Zhongxing Xu 0d2706f6b8 Add code for get the lvalue for string literals. Now we return a StringRegion
for StringLiteral lvalue evaluation, instead of directly returning a
loc::StringLiteralVal by the Environment.

llvm-svn: 58138
2008-10-25 14:18:57 +00:00
Zhongxing Xu d1aac353e5 Add StringRegion to MemRegions.
llvm-svn: 58137
2008-10-25 14:13:41 +00:00
Zhongxing Xu ad20b671fc Now we can handle arrays.
llvm-svn: 58135
2008-10-25 10:26:46 +00:00
Ted Kremenek 920406b5ca Use "followsFundamentalRule" to determine if an instance method allocates memory.
llvm-svn: 58114
2008-10-24 21:22:44 +00:00
Ted Kremenek 01acb6284e followsFundamentalRule() returns true if "alloc" or "new" appear at the beginning of the string, not anywhere within it.
llvm-svn: 58112
2008-10-24 21:18:08 +00:00
Ted Kremenek 6e09d8f632 Implicit conversions from arrays can also be conversions to references (will add a test case shortly).
llvm-svn: 58110
2008-10-24 21:10:49 +00:00
Ted Kremenek 03466c2273 Issue warnings about owned objects returned from a method that does not match the established Cocoa naming conventions.
llvm-svn: 58108
2008-10-24 20:32:50 +00:00