summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ParentMap.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [OPENMP]Fix PR42632: crash on the analysis of the OpenMP constructs.Alexey Bataev2019-07-171-0/+12
| | | | | | | Fixed processing of the CapturedStmt children to fix the crash of the OpenMP constructs during analysis. llvm-svn: 366357
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* Create ConstantExpr classBill Wendling2018-10-311-1/+1
| | | | | | | | | | | | | | | | A ConstantExpr class represents a full expression that's in a context where a constant expression is required. This class reflects the path the evaluator took to reach the expression rather than the syntactic context in which the expression occurs. In the future, the class will be expanded to cache the result of the evaluated expression so that it's not needlessly re-evaluated Reviewed By: rsmith Differential Revision: https://reviews.llvm.org/D53475 llvm-svn: 345692
* Remove trailing spaceFangrui Song2018-07-301-1/+1
| | | | | | sed -Ei 's/[[:space:]]+$//' include/**/*.{def,h,td} lib/**/*.{cpp,h} llvm-svn: 338291
* [analyzer] Correctly model iteration through "nil" objectsGeorge Karpenkov2018-03-081-0/+3
| | | | | | | | | | | | | | | | | | | | Previously, iteration through nil objects which resulted from objc-messages being set to nil were modeled incorrectly. There are a couple of notes about this patch: In principle, ExprEngineObjC might be left untouched IFF osx.loops checker is enabled. I however think that we should not do something completely incorrect depending on what checkers are left on. We should evaluate and potentially remove altogether the isConsumedExpr performance heuristic, as it seems very fragile. rdar://22205149 Differential Revision: https://reviews.llvm.org/D44178 llvm-svn: 326982
* [arcmt/objcmt] Fix ParentMap crash with invalid code.Argyrios Kyrtzidis2016-07-141-0/+2
| | | | | | rdar://22489560 llvm-svn: 275466
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-021-6/+6
| | | | | | | | | ++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
* [C++11] Use 'nullptr'. AST edition.Craig Topper2014-05-121-4/+4
| | | | llvm-svn: 208517
* [analyzer; new edges] Simplify edges in a C++11 for-range loop.Jordan Rose2013-06-061-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously our edges were completely broken here; now, the final result is a very simple set of edges in most cases: one up to the "for" keyword for context, and one into the body of the loop. This matches the behavior for ObjC for-in loops. In the AST, however, CXXForRangeStmts are handled very differently from ObjCForCollectionStmts. Since they are specified in terms of equivalent statements in the C++ standard, we actually have implicit AST nodes for all of the semantic statements. This makes evaluation very easy, but diagnostic locations a bit trickier. Fortunately, the problem can be generally defined away by marking all of the implicit statements as part of the top-level for-range statement. One of the implicit statements in a for-range statement is the declaration of implicit iterators __begin and __end. The CFG synthesizes two separate DeclStmts to match each of these decls, but until now these synthetic DeclStmts weren't in the function's ParentMap. Now, the CFG keeps track of its synthetic statements, and the AnalysisDeclContext will make sure to add them to the ParentMap. <rdar://problem/14038483> llvm-svn: 183449
* [analyzer] Look through ExprWithCleanups to see if an expr's consumed.Jordan Rose2013-06-061-2/+4
| | | | | | | | | | We based decisions during analysis and during path generation on whether or not an expression is consumed, so if a top-level expression has cleanups it's important for us to look through that. <rdar://problem/14076125> llvm-svn: 183368
* Removed invalid character.Serge Pavlov2013-05-181-1/+1
| | | | llvm-svn: 182189
* [analyzer] "Fix" ParentMap to handle non-syntactic OpaqueValueExprs.Jordan Rose2013-05-181-3/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | Constructs like PseudoObjectExpr, where an expression can appear more than once in the AST, use OpaqueValueExprs to guard against inadvertent re-processing of the shared expression during AST traversal. The most common form of this is to share expressions between the syntactic "as-written" form of, say, an Objective-C property access 'obj.prop', and the underlying "semantic" form '[obj prop]'. However, some constructs can produce OpaqueValueExprs that don't appear in the syntactic form at all; in these cases the ParentMap wasn't ever traversing the children of these expressions. This patch fixes that by checking to see if an OpaqueValueExpr's child has ever been traversed before. There's also a bit of reset logic when visiting a PseudoObjectExpr to handle the case of updating the ParentMap, which some external clients depend on. This still isn't exactly the right fix because we probably want the parent of the OpaqueValueExpr itself to be its location in the syntactic form if it's syntactic and the PseudoObjectExpr or BinaryConditionalOperator itself if it's semantic. Whe I originally wrote the code to do this, I didn't realize that OpaqueValueExprs themselves are shared in the AST, not just their source expressions. This patch doesn't change the existing behavior so as not to break anything inadvertently relying on it; we'll come back to this later. llvm-svn: 182187
* Revert "[analyzer; alternate edges] improve support for edges with ↵Jordan Rose2013-05-181-17/+13
| | | | | | | | | | | | | PseudoObjectExprs." Ted and I spent a long time discussing this today and found out that neither the existing code nor the new code was doing what either of us thought it was, which is never good. The good news is we found a much simpler way to fix the motivating test case (an ObjCSubscriptExpr). This reverts r182083, but pieces of it will come back in subsequent commits. llvm-svn: 182185
* [analyzer; alternate edges] improve support for edges with PseudoObjectExprs.Ted Kremenek2013-05-171-13/+17
| | | | | | | | | | | | | | | | | | This optimizes some spurious edges resulting from PseudoObjectExprs. This required far more changes than I anticipated. The current ParentMap does not record any hierarchy information between a PseudoObjectExpr and its *semantic* expressions that may be wrapped in OpaqueValueExprs, which are the expressions actually laid out in the CFG. This means the arrow pruning logic could not map from an expression to its containing PseudoObjectExprs. To solve this, this patch adds a variant of ParentMap that returns the "semantic" parentage of expressions (essentially as they are viewed by the CFG). This alternate ParentMap is then used by the arrow reducing logic to identify edges into pseudo object expressions, and then eliminate them. llvm-svn: 182083
* ParentMap: Restore the ability to update an existing map.Jordan Rose2012-10-061-14/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | The Clang ASTs are a DAG, not a pure tree. However, ParentMap has to choose a single parent for each object. In the main (only?) cases in which the AST forms a DAG, it protects from multiple traversal by using OpaqueValueExprs. Previously, ParentMap would just unconditionally look through all OpaqueValueExprs when building its map. In order to make this behavior better for the analyzer's diagnostics, ParentMap was changed to not set a statement's parent if there already was one in the map. However, ParentMap is supposed to allow updating existing mappings by calling addStmt once again. This change makes the "transparency" of OpaqueValueExprs explicit, and disables it when it is not desired, rather than checking the current contents of the map. This new code seems like a big change, but it should actually have essentially the same performance as before. Only OpaqueValueExprs and their users (PseudoObjectExpr and BinaryConditionalOperator) will have any different behavior. There should be no user-visible functionality change, though a test has been added for the current behavior of BinaryConditionalOperator source locations and accompanying Xcode arrows (which are not so great...). llvm-svn: 165355
* [analyzer] Improve arrow locations for PseudoObjectExprs.Jordan Rose2012-08-061-3/+10
| | | | llvm-svn: 161350
* Fix crash in analyzer diagnostic generation involving subexpressions of ↵Ted Kremenek2012-02-181-0/+4
| | | | | | OpaqueValueExpr not appearing in the ParentMap. Fixes <rdar://problem/10797980>. llvm-svn: 150894
* [arcmt] More automatic transformations and safety improvements; rdar://9615812 :Argyrios Kyrtzidis2011-07-271-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Replace calling -zone with 'nil'. -zone is obsolete in ARC. - Allow removing retain/release on a static global var. - Fix assertion hit when scanning for name references outside a NSAutoreleasePool scope. - Automatically add bridged casts for results of objc method calls and when calling CFRetain, for example: NSString *s; CFStringRef ref = [s string]; -> CFStringRef ref = (__bridge CFStringRef)([s string]); ref = s.string; -> ref = (__bridge CFStringRef)(s.string); ref = [NSString new]; -> ref = (__bridge_retained CFStringRef)([NSString new]); ref = [s newString]; -> ref = (__bridge_retained CFStringRef)([s newString]); ref = [[NSString alloc] init]; -> ref = (__bridge_retained CFStringRef)([[NSString alloc] init]); ref = [[s string] retain]; -> ref = (__bridge_retained CFStringRef)([s string]); ref = CFRetain(s); -> ref = (__bridge_retained CFTypeRef)(s); ref = [s retain]; -> ref = (__bridge_retained CFStringRef)(s); - Emit migrator error when trying to cast to CF type the result of autorelease/release: for CFStringRef f3() { return (CFStringRef)[[[NSString alloc] init] autorelease]; } emits: t.m:12:10: error: [rewriter] it is not safe to cast to 'CFStringRef' the result of 'autorelease' message; a __bridge cast may result in a pointer to a destroyed object and a __bridge_retained may leak the object return (CFStringRef)[[[NSString alloc] init] autorelease]; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ t.m:12:3: note: [rewriter] remove the cast and change return type of function to 'NSString *' to have the object automatically autoreleased return (CFStringRef)[[[NSString alloc] init] autorelease]; ^ - Before changing attributes to weak/unsafe_unretained, check if the backing ivar is set to a +1 object, in which case use 'strong' instead. llvm-svn: 136208
* Automatic Reference Counting.John McCall2011-06-151-0/+9
| | | | | | | | | | Language-design credit goes to a lot of people, but I particularly want to single out Blaine Garst and Patrick Beard for their contributions. Compiler implementation credit goes to Argyrios, Doug, Fariborz, and myself, in no particular order. llvm-svn: 133103
* Give some convenient idiomatic accessors to Stmt::child_range andJohn McCall2011-02-131-1/+1
| | | | | | | Stmt::const_child_range, then make a bunch of places use them instead of the individual iterator accessors. llvm-svn: 125450
* Don't emit a dead store for '++' operations unless it occurs with a return ↵Ted Kremenek2011-02-121-0/+9
| | | | | | | | statement. We've never seen any other cases that were real bugs. Fixes <rdar://problem/6962292>. llvm-svn: 125419
* Add method ParentMap::addStmt().Ted Kremenek2010-11-151-0/+6
| | | | llvm-svn: 119181
* GCC didn't care for my attempt at API compatibility, so brute-force everythingJohn McCall2010-08-251-1/+1
| | | | | | to the new constants. llvm-svn: 112047
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-5/+5
| | | | llvm-svn: 81346
* Add ParentMap:getParentIgnoreParens().Ted Kremenek2009-05-111-0/+5
| | | | llvm-svn: 71469
* Fix subtle bug in ParentMap::isConsumedExpr(): correctly ignore *parents* thatTed Kremenek2009-05-051-1/+1
| | | | | | are ParenExpr or CastExprs. llvm-svn: 71026
* Another ParentMap bug: only the right side of a comma expression is consumed.Ted Kremenek2009-04-091-2/+2
| | | | llvm-svn: 68680
* Fix bug in ParentMap::isConsumedExpr. A BinaryOperator always "consumes" theTed Kremenek2009-04-081-1/+3
| | | | | | | value of its subexpressions unless it is a comma (in which case it doesn't consume the left subexpression). llvm-svn: 68628
* Fix: <rdar://problem/6740387>. Sending nil to an object that returns a structTed Kremenek2009-04-011-0/+40
| | | | | | | should only be an error if that value is consumed. This fix was largely accomplished by moving 'isConsumedExpr' back to ParentMap. llvm-svn: 68195
* Dead stores checker: Fix <rdar://problem/6506065> by being more selective ↵Ted Kremenek2009-01-201-8/+0
| | | | | | when say that a store is dead even though the computed value is used in the enclosing expression. llvm-svn: 62552
* More #include cleaningDaniel Dunbar2008-08-111-0/+1
| | | | | | | | | | | - Kill unnecessary #includes in .cpp files. This is an automatic sweep so some things removed are actually used, but happen to be included by a previous header. I tried to get rid of the obvious examples and this was the easiest way to trim the #includes in one fell swoop. - We now return to regularly scheduled development. llvm-svn: 54632
* Added ParentMap, a class to represent a lazily constructed mapping from ↵Ted Kremenek2008-06-201-0/+54
child to parents. llvm-svn: 52553
OpenPOWER on IntegriCloud