aboutsummaryrefslogtreecommitdiff
path: root/lib/Checker/GRExprEngine.cpp
AgeCommit message (Collapse)Author
2010-06-25Relax assertion since non-pod C++ classes are not aggregates, but still can ↵Ted Kremenek
appear in this context. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106919 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-25Add "checker caching" to GRExprEngine::CheckerVisit to progressively buildTed Kremenek
a winowed list of checkers that actually do something for a given StmtClass. As the number of checkers grows, this may potentially significantly reduce the number of checkers called at any one time. My own measurements show that for the ~20 registered Checker objects, only ~5 of them respond at any one time to a give statement. While this isn't a net performance win right now (there is a minor slowdown on sqlite.3) this improvement does greatly improve debugging when stepping through the checkers used to evaluate a given statement. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106884 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-23Add 'VisitEndAnalysis' callback to Checker class. This callback is called ↵Ted Kremenek
by GRExprEngine when the worklist algorithm has terminated. This allows some checkers to do a post-analysis phase after all paths have been analyzed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106689 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-22Don't assert on C++ casts that are currently not handled by the static analyzer.Ted Kremenek
Instead, halt the analysis of the current path, which is what we do in GRExprEngine::ProcessStmt for all other C++ constructs not currently handled by the analyzer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16Register CallAndMessageChecker before AttrNonNullChecker. Then we can assumeZhongxing Xu
arguments are not undefined. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106083 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-09Merge StackAddrLeakChecker and ReturnStackAddressChecker.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105687 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-03Add comments.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105382 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Add option '-analyzer-max-loop', which specifies the maximum Zhongxing Xu
number of times the analyzer will go through a loop. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-15Substantially alter the design of the Objective C type AST by introducingJohn McCall
ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103870 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-11Fixes for compilation with Microsoft Visual Studio 2010, from Steven Watanabe!Douglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103458 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06Turn -analyzer-inline-call on for C functions. This also fixed a bug thatZhongxing Xu
after inlining post-call checking shouldn't be done. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103161 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-28Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor
Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102542 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-26Introduce Type::isStructureOrClassType(), which does the obviousDouglas Gregor
thing. Audit all uses of Type::isStructure(), changing those calls to isStructureOrClassType() as needed (which is alsmost everywhere). Fixes the remaining failure in Boost.Utility/Swap. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102386 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-21CXXNamedCastExpr is actually an abstract expression.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101994 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-21Add initial support for C++ delete expr.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101980 91177308-0d34-0410-b5e6-96231b3b80d8
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-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-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-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-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-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-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-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-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-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-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-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-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-17Mark CXXThisRegion in the current or parent stack frame context as live so thatZhongxing Xu
their bindings are not removed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98705 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-16Add VisitCXXContructExpr logic to the analyzer. This still has not fully workedZhongxing Xu
since RemoveDeadBinding mistakenly remove the binding to CXXThisRegion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98629 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-08Remove unused headers.Duncan Sands
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97941 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-05Remove reference to AnalysisContext in Environment. We already have ↵Zhongxing Xu
LocationContext information in ExplodedNode. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97785 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-04When profiling Environment, also profile with AnalysisContext*, bacauseZhongxing Xu
we now may have identical states with different analysis context. Set the right AnalysisContext in state when entering and leaving a callee. With both of the above changes, we can pass the test case. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97724 91177308-0d34-0410-b5e6-96231b3b80d8
2010-03-02Don't conjure a symbol for DeclStmts when the variable is a C++ reference.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97590 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26Use a GDM to record the returned expression in the state when VisitReturnStmt.Zhongxing Xu
Use this information to find the returned value and bind it to CallExpr in ProcessCallExit. And there is no need to remove dead bindings in ProcessCallExit, because a. it would clean up the return value bound to CallExpr b. we still would do it in the next ProcessStmt(), where we would not misclean up the return value. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97225 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-26Remove derelict GRStmtNodeBuilder::LastNode.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97207 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Restore Zhongxing's commits r97122 r97127 r97129 r97131 which were reverted ↵Douglas Gregor
due to a Clang-on-Clang failure git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97162 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Revert patches r97122 r97127 r97129 r97131.Jakob Stoklund Olesen
They were breaking clang-x86_64-darwin10-selfhost git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97138 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Move the dead bindings removal logic from CallInliner to ↵Zhongxing Xu
GRExprEngine::ProcessCallExit(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97129 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Call inliner improvements:Zhongxing Xu
This patch implements the CallEnter/CallExit idea of Ted. Add two interfaces to GRSubEngine: ProcessCallEnter, ProcessCallExit. The CallEnter program point uses caller's location context. The CallExit program point uses callee's location context. CallEnter is built by GRStmtNodeBuilder. CallExit is built by GREndPathNodeBuilder. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97122 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Add MacOSXAPIChecker, a meta checker to include various precondition checks ↵Ted Kremenek
for calls to various MacOS X functions. The checks in BasicObjCFoundationChecks.cpp will gradually be migrated here. As a first check, check that when 'dispatch_once()' is passed a predicate value that has non-local storage. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97116 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-25Add UnixAPIChecker, a meta checker to include various precondition checks ↵Ted Kremenek
for calls to various unix/posix functions, e.g. 'open()'. As a first check, check that when 'open()' is passed 'O_CREAT' that it has a third argument. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97086 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-16Add simpler checker to check if variables captured by a block are uninitialized.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96341 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-15Convert GRExprEngine's handling of ObjCMessageExprs to use a worklistTed Kremenek
to evaluate arguments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96293 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-08Revert 95541.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95545 91177308-0d34-0410-b5e6-96231b3b80d8