summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-262-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | giving them rough classifications (normal types, never-canonical types, always-dependent types, abstract type representations) and making it far easier to make sure that we've hit all of the cases when decoding types. Switched some switch() statements on the type class over to using this mechanism, and filtering out those things we don't care about. For example, CodeGen should never see always-dependent or non-canonical types, while debug info generation should never see always-dependent types. More switch() statements on the type class need to be moved over to using this approach, so that we'll get warnings when we add a new type then fail to account for it somewhere in the compiler. As part of this, some types have been renamed: TypeOfExpr -> TypeOfExprType FunctionTypeProto -> FunctionProtoType FunctionTypeNoProto -> FunctionNoProtoType There shouldn't be any functionality change... llvm-svn: 65591
* PathDiagnosticPiece now automatically strips off trailing periods in ↵Ted Kremenek2009-02-261-0/+27
| | | | | | diagnostic messages. llvm-svn: 65574
* Refine some grammar in the retain/release diagnostics.Ted Kremenek2009-02-261-21/+15
| | | | llvm-svn: 65571
* Introduce code modification hints into the diagnostics system. When weDouglas Gregor2009-02-261-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | know how to recover from an error, we can attach a hint to the diagnostic that states how to modify the code, which can be one of: - Insert some new code (a text string) at a particular source location - Remove the code within a given range - Replace the code within a given range with some new code (a text string) Right now, we use these hints to annotate diagnostic information. For example, if one uses the '>>' in a template argument in C++98, as in this code: template<int I> class B { }; B<1000 >> 2> *b1; we'll warn that the behavior will change in C++0x. The fix is to insert parenthese, so we use code insertion annotations to illustrate where the parentheses go: test.cpp:10:10: warning: use of right-shift operator ('>>') in template argument will require parentheses in C++0x B<1000 >> 2> *b1; ^ ( ) Use of these annotations is partially implemented for HTML diagnostics, but it's not (yet) producing valid HTML, which may be related to PR2386, so it has been #if 0'd out. In this future, we could consider hooking this mechanism up to the rewriter to actually try to fix these problems during compilation (or, after a compilation whose only errors have fixes). For now, however, I suggest that we use these code modification hints whenever we can, so that we get better diagnostics now and will have better coverage when we find better ways to use this information. This also fixes PR3410 by placing the complaint about missing tokens just after the previous token (rather than at the location of the next token). llvm-svn: 65570
* Use Loc::IsLocType() instead of isPointerType() and isReferenceType().Ted Kremenek2009-02-261-2/+1
| | | | llvm-svn: 65568
* Drop uses of isPointerLikeType.Daniel Dunbar2009-02-261-1/+1
| | | | | | - No functionality change. llvm-svn: 65560
* Fix subtle bug in EvalEagerlyAssume: Check if the previous node was at the ↵Ted Kremenek2009-02-251-10/+17
| | | | | | same statement. llvm-svn: 65486
* Fix recently introduced switch case fallthrough bug.Ted Kremenek2009-02-251-4/+4
| | | | llvm-svn: 65485
* Add experimental logic in GRExprEngine::EvalEagerlyAssume() to handleTed Kremenek2009-02-251-3/+49
| | | | | | | | | | | expressions of the form: 'short x = (y != 10);' While we handle 'int x = (y != 10)' lazily, the cast to another integer type currently loses the symbolic constraint. Eager evaluation of the constraint causes the paths to bifurcate and eagerly evaluate 'y != 10' to a constant of 1 or 0. This should address <rdar://problem/6619921> until we have a better (more lazy approach) for handling promotions/truncations of symbolic integer values. llvm-svn: 65480
* retain/release checker: Implement basic tracking of autorelease stack. Next ↵Ted Kremenek2009-02-251-6/+26
| | | | | | thing is to wire up pools with their contents. llvm-svn: 65425
* Fix broken logic from my last commit. Branches only occur at basic blocks ↵Ted Kremenek2009-02-241-1/+1
| | | | | | that end with terminators. llvm-svn: 65410
* Fix diagnostic regression where the leak diagnostic could appear earlier in ↵Ted Kremenek2009-02-241-1/+11
| | | | | | the path than the branches taken. llvm-svn: 65407
* retain/release checker:Ted Kremenek2009-02-241-70/+38
| | | | | | | | | | | | - For autorelease pool tracking, keep information about the stack of pools separate from their contents. Also, keep track of the number of times an autorelease pool will send the "release" message to an object when the pool is destroyed. - Update CFRefCount::Update to return a new state instead of a reference count binding. This will allow us to implement more complicated semantics with autorelease pools. llvm-svn: 65384
* Fix <rdar://problem/6611677>: Add basic transfer function support in the staticTed Kremenek2009-02-242-3/+18
| | | | | | | | | analyzer for array subscript expressions involving bases that are vectors. This solution is probably a hack: it gets the lvalue of the vector instead of an rvalue like all other types. This should be reviewed (big FIXME in GRExprEngine). llvm-svn: 65366
* Tidy up 'ExecutionContinues' to distinguish between jumping to the end of a ↵Ted Kremenek2009-02-231-17/+14
| | | | | | 'method' or 'funciton'. llvm-svn: 65346
* Tidy up the path diagnostic generation logic in BugReporter and remove a ↵Ted Kremenek2009-02-231-50/+53
| | | | | | case where an "Execution continues..." diagnostic could result in an empty message bubble. llvm-svn: 65342
* Add more boilerplate logic to more accurately reason about autorelease pools.Ted Kremenek2009-02-231-4/+52
| | | | | | | This doesn't change the current functionality, but better codifies the autorelease pool stack itself. llvm-svn: 65328
* Fix 80 col. violations.Ted Kremenek2009-02-231-2/+4
| | | | llvm-svn: 65322
* Per Chris L.'s suggestion, use getAsFunctionType() instead of ↵Ted Kremenek2009-02-231-5/+7
| | | | | | getDesguaredType(). Constify some pointers along the way. llvm-svn: 65321
* retain/release checker: For now don't track the retain count of NSWindow ↵Ted Kremenek2009-02-231-1/+5
| | | | | | objects (opt for false negatives). llvm-svn: 65304
* Remove typo.Ted Kremenek2009-02-231-1/+1
| | | | llvm-svn: 65302
* '[NSAutoreleasePool addObject:]' has an 'autorelease' effect, not a ↵Ted Kremenek2009-02-231-2/+2
| | | | | | DoNothing effect. llvm-svn: 65301
* Fix regression in naming convention derivation: a method only follows the ↵Ted Kremenek2009-02-221-1/+1
| | | | | | copy 'rule' if it doesn't already start with 'init', etc. llvm-svn: 65269
* Use llvm::StringsEqualNoCase instead of strncasecmp.Ted Kremenek2009-02-211-8/+5
| | | | llvm-svn: 65237
* Fix build on windows.Cedric Venet2009-02-211-0/+4
| | | | | | Should clang have a config.h or should we use the config.h of llvm or using the preprocessor is OK? I did a quick fix here, but having a guideline on how to handle non portable function would be great (or ask ted to stop breaking the windows build :)). llvm-svn: 65233
* Improved naming convention heuristics in the retain/release checker to betterTed Kremenek2009-02-211-9/+94
| | | | | | | | | handle method names that contain 'new', 'copy', etc., but those words might be the substring of larger words such as 'newsgroup' and 'photocopy' that do not indicate the allocation of objects. This should address the issues discussed in <rdar://problem/6552389>. llvm-svn: 65224
* Greatly simplify the logic in ExplodedGraphImpl::TrimGraph. Now we just do aTed Kremenek2009-02-201-111/+42
| | | | | | | | | vanilla reverse-BFS followed by a forward-DFS instead of resulting to strange histrionics (whose purpose I can no longer remember) in the reverse-BFS stage. This fixes an assertion failure in BugReporter due to edge cases where no root was being hit in the reverse-BFS phase. llvm-svn: 65160
* Add an example in comments.Zhongxing Xu2009-02-201-1/+6
| | | | llvm-svn: 65110
* Fix crash from <rdar://problem/6562655>: 'init' method only return a ↵Ted Kremenek2009-02-201-2/+5
| | | | | | receiver alias if the return type is a location. llvm-svn: 65084
* retain/release checker: Generate an intermediate simulation node for "leak"Ted Kremenek2009-02-191-17/+38
| | | | | | | | transitions and then generate a subsequent node that removes the dead symbol bindings. This should drastically improve caching in the simulation graph when retain-counted objects are being tracked. llvm-svn: 65082
* Added a new method to GRStmtNodeBuilder to build nodes using an arbitraryTed Kremenek2009-02-191-4/+7
| | | | | | | PostStmt program point. This allows clients to pass in PostStmtCustom program points. llvm-svn: 65080
* retain/release checker: Fix crasher when the leak site is the same ↵Ted Kremenek2009-02-191-12/+20
| | | | | | expression that allocates an object. llvm-svn: 65047
* only track integer and pointer values for now.Zhongxing Xu2009-02-191-2/+7
| | | | llvm-svn: 65041
* Convert the offset to signed before making an ElementRegion with it. It seemsZhongxing Xu2009-02-191-1/+11
| | | | | | | that this problem arises from time to time. We should find a fundamental solution for it. llvm-svn: 65035
* Implemented simple check in <rdar://problem/6600344>: When the receiver of aTed Kremenek2009-02-192-3/+59
| | | | | | | message expression is nil and the return type is struct then the returned value is undefined or potentially garbage. llvm-svn: 65003
* retain/release checker: Place the leak diagnostic after the last statement thatTed Kremenek2009-02-181-15/+37
| | | | | | references the tracked object. llvm-svn: 64980
* Remove unused variable.Ted Kremenek2009-02-181-1/+0
| | | | llvm-svn: 64974
* Remove logic for computing 'display hint'.Ted Kremenek2009-02-181-21/+2
| | | | llvm-svn: 64973
* More fun with retain checker diagnostics:Ted Kremenek2009-02-181-7/+17
| | | | | | | | - Fix some grammar. - Fix a bug where a "reference count incremented" diagnostic would not be shown if the previous typestate was "Released" (only happens in GC mode). llvm-svn: 64971
* Fix diagnostics bugs when computing ranges for the retain/release checker.Ted Kremenek2009-02-181-1/+4
| | | | llvm-svn: 64962
* retain/release checker: We now emit fancy diagnostics telling users about theTed Kremenek2009-02-181-50/+88
| | | | | | semantics of CFMakeCollectable and friends. llvm-svn: 64956
* retain/release checker: Distinguish in the function summaries betweenTed Kremenek2009-02-181-12/+27
| | | | | | | | retain/releases performed via [... release] and CFRetain(). The former are no-ops in GC. The checker already handled this, but now we emit nice diagnostics to the user telling them that these are no-ops. llvm-svn: 64937
* Revise comment. Comparing pointer values in 'Range' wasn't the performance ↵Ted Kremenek2009-02-181-5/+3
| | | | | | issue I thought it was, but it is still worth ordering Range objects by their APSInt values. llvm-svn: 64921
* Fix performance bug in RangeConstraintManager (that I introduced):Ted Kremenek2009-02-181-9/+23
| | | | | | | | | | | | | | When comparing if one Range is "less" than another, compare the actual APSInt numeric values instead of their pointer addresses. This ensures that the ImmutableSet in RangeSet always has a consistent ordering between Ranges. This is critical for generating the same digest/hash for the contents of the sets. This was a serious performance bug because it would often cause state caching to be disabled along complicated paths. Along the way: - Put Range and RangeSet in the "anonymous namespace" and mark them hidden llvm-svn: 64890
* Hooked up the necessary machinery to allow the retain/release checker referenceTed Kremenek2009-02-183-64/+169
| | | | | | | | | | | | | back to the summary used when evaluating the statement associated with a simulation node. This is now being used to help improve the checker's diagnostics. To get things started, the checker now emits a path diagnostic indicating that 'autorelease' is a no-op in GC mode. Some of these changes are exposing further grossness in the interface between BugReporter and the ExplodedGraph::Trim facilities. These really need to be cleaned up one day. llvm-svn: 64881
* retain/release checker: Record the summary used to generate a given node.Ted Kremenek2009-02-181-5/+10
| | | | llvm-svn: 64876
* Add panic function.Ted Kremenek2009-02-171-1/+2
| | | | llvm-svn: 64852
* Revised RangeConstraintManager based on several discussions with Ben Laurie andTed Kremenek2009-02-171-519/+180
| | | | | | | | | | | | | | | | | Zhongxing Xu. The resultant code is less than 1/2 the size of the original. Key highlights: - All CouldBeXXX methods have been removed. Checking for feasibility is now just done in the AddXXX methods. - RangeSets now represent "all possible values" explicitly as the range set { [min, max] } instead of the empty set. The empty set now represents "no feasible values". This change consolidated much of the core algorithm to only have one code path instead of alternate paths that considered the empty set to represent "all possible falues." llvm-svn: 64787
* Add '_assert' to list of known panic functions.Ted Kremenek2009-02-171-2/+4
| | | | llvm-svn: 64772
* add some files to fix the cmake build, patch by Piotr Rak!Chris Lattner2009-02-171-0/+2
| | | | llvm-svn: 64752
OpenPOWER on IntegriCloud