aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker
AgeCommit message (Collapse)Author
2010-04-21Overhaul the AST representation of Objective-C message sendDouglas Gregor
expressions, to improve source-location information, clarify the actual receiver of the message, and pave the way for proper C++ support. The ObjCMessageExpr node represents four different kinds of message sends in a single AST node: 1) Send to a object instance described by an expression (e.g., [x method:5]) 2) Send to a class described by the class name (e.g., [NSString method:5]) 3) Send to a superclass class (e.g, [super method:5] in class method) 4) Send to a superclass instance (e.g., [super method:5] in instance method) Previously these four cases where tangled together. Now, they have more distinct representations. Specific changes: 1) Unchanged; the object instance is represented by an Expr*. 2) Previously stored the ObjCInterfaceDecl* referring to the class receiving the message. Now stores a TypeSourceInfo* so that we know how the class was spelled. This both maintains typedef information and opens the door for more complicated C++ types (e.g., dependent types). There was an alternative, unused representation of these sends by naming the class via an IdentifierInfo *. In practice, we either had an ObjCInterfaceDecl *, from which we would get the IdentifierInfo *, or we fell into the case below... 3) Previously represented by a class message whose IdentifierInfo * referred to "super". Sema and CodeGen would use isStr("super") to determine if they had a send to super. Now represented as a "class super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). 4) Previously represented by an instance message whose receiver is a an ObjCSuperExpr, which Sema and CodeGen would check for via isa<ObjCSuperExpr>(). Now represented as an "instance super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). Note that ObjCSuperExpr only has one remaining use in the AST, which is for "super.prop" references. The new representation of ObjCMessageExpr is 2 pointers smaller than the old one, since it combines more storage. It also eliminates a leak when we loaded message-send expressions from a precompiled header. The representation also feels much cleaner to me; comments welcome! This patch attempts to maintain the same semantics we previously had with Objective-C message sends. In several places, there are massive changes that boil down to simply replacing a nested-if structure such as: if (message has a receiver expression) { // instance message if (isa<ObjCSuperExpr>(...)) { // send to super } else { // send to an object } } else { // class message if (name->isStr("super")) { // class send to super } else { // send to class } } with a switch switch (E->getReceiverKind()) { case ObjCMessageExpr::SuperInstance: ... case ObjCMessageExpr::Instance: ... case ObjCMessageExpr::SuperClass: ... case ObjCMessageExpr::Class:... } There are quite a few places (particularly in the checkers) where send-to-super is effectively ignored. I've placed FIXMEs in most of them, and attempted to address send-to-super in a reasonable way. This could use some review. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101972 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20Replace code with a method call. No functionality change.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101876 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20Use GetState() to get the possible cleaned state.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101867 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-20Improve handling of CXXNewExpr.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101862 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19Fix -Wcast-qual warnings.Dan Gohman
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101786 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19Move all C++ expression evaluation logic into its own file.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101772 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-19Analyzer: add support for CXXNewExpr.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101771 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer
users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101632 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-16Static analyzer: Don't crash when casting a symbolic region address to a ↵Ted Kremenek
float. Fixes PR 6854. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101499 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-15Fix PR 6844, a regression caused by the introduction of llvm_unreachable for ↵Ted Kremenek
the default case in GRExprEngine::Visit (in r101129). Instead, enumerate all Stmt cases and have no 'default' case in the switch statement. When we encounter a Stmt we don't handle, we should explicitly add it to the switch statement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101378 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14Move GRStmtNodeBuilder::MakeNode() out of line. No functionality change.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101239 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-14Add support for CXXBoolLiteralExpr.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101238 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13Make all cases that we don't handle explicit. Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101129 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13Dispatch all C++ cast expr to VisitCast().Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101128 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-09Remove copy of 'Optional' in Clang tree, and convert clients to use the one ↵Ted Kremenek
now in the LLVM tree. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100891 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08For 'open' check in UnixAPIChecker, hard code value of 'O_CREAT' on Darwin.Ted Kremenek
This is still not an ideal solution, but should disable the check for other targets where the value of O_CREAT is different. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100818 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08Temporarily only enable 'open' check on Mac OS X to unbreak Windows ↵Ted Kremenek
buildbot. I'm looking into an alternate fix right now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100816 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-08Add static analyzer check for calls to 'pthread_once()' where the ↵Ted Kremenek
control-flow has automatic storage. This matches the corresponding check for 'dispatch_once()'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-07Fix crash in StoreManager::CastRegion() when the base region is a type with ↵Ted Kremenek
0 size. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100594 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-06Teach MemRegion::getBaseRegion() about ObjCIvarRegions. We want to treatTed Kremenek
them the same way as fields. This fixes a regression in RegionStore::RemoveDeadbindings() that emerged from going to the cluster-based analysis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100570 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-06Fix PR 6725. It looks like the copy constructor gets elided during inlining.Zhongxing Xu
This bug only shows up with GCC 4.4.1 Release-Asserts build. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100516 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05Always assume block-level expressions in the caller are alive when analyzingZhongxing Xu
the callee. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100429 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-05Since now we process regions in clusters when removing dead bindings, thisZhongxing Xu
code can be removed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100428 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01Use the element type to compute the array size when the base region is a ↵Zhongxing Xu
VarRegion. Patch by Jordy Rose. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100099 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01Initial support for visiting CXXMemberCallExpr.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100098 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01Improve C++ constructor handling.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100080 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-01Fix a bug (PR 6699) in RegionStore::RemoveDeadBindings() whereTed Kremenek
array values with a non-zero offset would get prematurely pruned from the store. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100067 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor
the C-only "optimization". git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100022 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100018 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-31Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor
term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100008 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30Introduce a new kind of derived-to-base cast which bypasses the need forJohn McCall
null checks, and make sure we elide null checks when accessing base class members. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99963 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30RegionStore: specially handle loads from integer global variables declared ↵Ted Kremenek
'const'. Fixes a false positive reported in PR 6288. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99922 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30Use 'const Optional<SVal>&' to avoid an extra copy.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99921 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30the big refactoring bits of PR3782.Rafael Espindola
This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99920 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-30Change the analyzer to recognize (but ignore) assignments to isa. Fixes PR ↵Ted Kremenek
6302. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99904 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-29Be a bit more consistent in using operator->Rafael Espindola
This patch moves some methods from QualType to Type and changes the users to use -> instead of . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99805 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-27Checker: random include cleanup.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99731 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-26Fix NoReturnFunctionChecker to properly look at a function's typeTed Kremenek
when determining if it returns. Fixes <rdar://problem/7796563>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99663 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-25Add methods to remove a GDM entry.Zhongxing Xu
Instead of setting the ReturnExpr GDM to NULL, remove it. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99470 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24Use llvm::SmallString instead of std::string.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99442 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-24Improve static analyzer diagnostic concerning the use of 'mktemp'Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99441 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23Bind the constructed object value to CXXConstructExpr.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99271 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23update CMakeLists.txtZhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99269 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23Clear the return expr GDM after using it.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99268 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23Add a AggExprVisitor class. It contains lots of boilerZhongxing Xu
plate code for evaluating expressions of C++ class type. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99267 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23merge line.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99259 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23Since we now may have basicblocks with the same block is in different function,Zhongxing Xu
change the block counter map from unsigned -> unsigned to <StackFrameContext*, unsigned> -> unsigned. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99255 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-23Tweak null dereference diagnostics to give clearer diagnostics whenTed Kremenek
a null dereference results from a field access. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99236 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-22Improve the diagnostics for the UndefinedAssignmentChecker when anTed Kremenek
uninitialized value is used in the LHS of a compound assignment. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99221 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-22Sort calls to add_clang_library()Kovarththanan Rajaratnam
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@99191 91177308-0d34-0410-b5e6-96231b3b80d8