summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/new.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Move analyzer-eagerly-assume to AnalyzerOptions, enable by defaultGeorge Karpenkov2018-08-291-2/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D51251 llvm-svn: 340963
* [analyzer] Fix operator delete[] array-type-sub-expression handling.Artem Dergachev2018-04-271-0/+18
| | | | | | | | | | | | Avoid crash when the sub-expression of operator delete[] is of array type. This is not the same as simply using a delete[] syntax. We're still not properly calling destructors in this case in the analyzer. Differential Revision: https://reviews.llvm.org/D46146 llvm-svn: 331014
* Fix typos in clangAlexander Kornienko2018-04-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* [analyzer] Decide on inlining destructors via EvalCallOptions.Artem Dergachev2018-02-151-1/+2
| | | | | | | | | | | | | | | | | | | | EvalCallOptions were introduced in r324018 for allowing various parts of ExprEngine to notify the inlining mechanism, while preparing for evaluating a function call, of possible difficulties with evaluating the call that they foresee. Then mayInlineCall() would still be a single place for making the decision. Use that mechanism for destructors as well - pass the necessary flags from the CFG-element-specific destructor handlers. Part of this patch accidentally leaked into r324018, which led into a change in tests; this change is reverted now, because even though the change looked correct, the underlying behavior wasn't. Both of these commits were not intended to introduce any function changes otherwise. Differential Revision: https://reviews.llvm.org/D42991 llvm-svn: 325209
* [analyzer] Don't communicate evaluation failures through memregion hierarchy.Artem Dergachev2018-02-011-2/+1
| | | | | | | | | | | | | | | | | | | | | | | We use CXXTempObjectRegion exclusively as a bailout value for construction targets when we are unable to find the correct construction region. Sometimes it works correctly, but rather accidentally than intentionally. Now that we want to increase the amount of situations where it works correctly, the first step is to introduce a different way of communicating our failure to find the correct construction region. EvalCallOptions are introduced for this purpose. For now EvalCallOptions are communicating two kinds of problems: - We have been completely unable to find the correct construction site. - We have found the construction site correctly, and there's more than one of them (i.e. array construction which we currently don't support). Accidentally find and fix a test in which the new approach to communicating failures produces better results. Differential Revision: https://reviews.llvm.org/D42457 llvm-svn: 324018
* [analyzer] NFC: Run many existing C++ tests with a custom operator new().Artem Dergachev2018-01-241-0/+1
| | | | | | | | | | | In order to provide more test coverage for inlined operator new(), add more run-lines to existing test cases, which would trigger our fake header to provide a body for operator new(). Most of the code should still behave reasonably. When behavior intentionally changes, #ifs are provided. Differential Revision: https://reviews.llvm.org/D42221 llvm-svn: 323376
* [analyzer] Enable c++-allocator-inlining by default.Artem Dergachev2018-01-241-3/+2
| | | | | | | | | | | | | | | | | | | | | | This allows the analyzer to analyze ("inline") custom operator new() calls and, even more importantly, inline constructors of objects that were allocated by any operator new() - not necessarily a custom one. All changes in the tests in the current commit are intended improvements, even if they didn't carry any explicit FIXME flag. It is possible to restore the old behavior via -analyzer-config c++-allocator-inlining=false (this flag is supported by scan-build as well, and it can be into a clang --analyze invocation via -Xclang .. -Xclang ..). There is no intention to remove the old behavior for now. Differential Revision: https://reviews.llvm.org/D42219 rdar://problem/12180598 llvm-svn: 323373
* Reland 4: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-031-1/+1
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296895
* Revert "Reland 3: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-03-021-1/+1
| | | | | | | | multiple constraint managers" This reverts commit ea36f1406e1f36bf456c3f3929839b024128e468. llvm-svn: 296841
* Reland 3: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-021-1/+1
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296837
* Revert "Reland 2: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-03-021-1/+1
| | | | | | | | multiple constraint managers" This reverts commit f93343c099fff646a2314cc7f4925833708298b1. llvm-svn: 296836
* Reland 2: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-021-1/+1
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296835
* Revert "Reland: [analyzer] NFC: Update test infrastructure to support ↵Dominic Chen2017-02-281-1/+1
| | | | | | | | multiple constraint managers" This reverts commit 1b28d0b10e1c8feccb971abb6ef7a18bee589830. llvm-svn: 296422
* Reland: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-02-281-1/+1
| | | | | | | | | | | | | | constraint managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296414
* Revert "[analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-02-271-1/+1
| | | | | | | | constraint managers" This reverts commit 8e7780b9e59ddaad1800baf533058d2c064d4787. llvm-svn: 296317
* [analyzer] NFC: Update test infrastructure to support multiple constraint ↵Dominic Chen2017-02-271-1/+1
| | | | | | | | | | | | | | managers Summary: Replace calls to %clang/%clang_cc1 with %clang_analyze_cc1 when invoking static analyzer, and perform runtime substitution to select the appropriate constraint manager, per D28952. Reviewers: xazax.hun, NoQ, zaks.anna, dcoughlin Subscribers: mgorny, rgov, mikhail.ramalho, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D30373 llvm-svn: 296312
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* [analyzer] Handle destructors for the argument to C++ 'delete'.Jordan Rose2013-09-251-0/+145
| | | | | | | | | | | | | | | | | Now that the CFG includes nodes for the destructors in a delete-expression, process them in the analyzer using the same common destructor interface currently used for local, member, and base destructors. Also, check for when the value is known to be null, in which case no destructor is actually run. This does not yet handle destructors for deleted /arrays/, which may need more CFG work. It also causes a slight regression in the location of double delete warnings; the double delete is detected at the destructor call, which is implicit, and so is reported on the first access within the destructor instead of at the 'delete' statement. This will be fixed soon. Patch by Karthik Bhat! llvm-svn: 191381
* [analyzer] Remove bogus assert: in C++11, 'new' can do list-initialization.Jordan Rose2013-07-101-0/+10
| | | | | | | | | | | | | | Previously, we asserted that whenever 'new' did not include a constructor call, the type must be a non-record type. In C++11, however, uniform initialization syntax (braces) allow 'new' to construct records with list-initialization: "new Point{1, 2}". Removing this assertion should be perfectly safe; the code here matches what VisitDeclStmt does for regions allocated on the stack. <rdar://problem/14403437> llvm-svn: 186028
* [analyzer] Switched to checkPreCall interface for detecting usage after free.Anton Yartsev2013-04-101-0/+18
| | | | | | Now the check is also applied to arguments for Objective-C method calls and to 'this' pointer. llvm-svn: 179230
* [analyzer] Shorten the malloc checker’s leak messageAnna Zaks2013-04-061-1/+1
| | | | | | As per Ted’s suggestion! llvm-svn: 178938
* [analyzer] Handle caching out while evaluating a C++ new expression.Jordan Rose2013-03-301-0/+8
| | | | | | | | | | | | | Evaluating a C++ new expression now includes generating an intermediate ExplodedNode, and this node could very well represent a previously- reachable state in the ExplodedGraph. If so, we can short-circuit the rest of the evaluation. Caught by the assertion a few lines later. <rdar://problem/13510065> llvm-svn: 178401
* [analyzer] Use evalBind for C++ new of scalar types.Jordan Rose2013-03-271-1/+16
| | | | | | | | | | These types will not have a CXXConstructExpr to do the initialization for them. Previously we just used a simple call to ProgramState::bindLoc, but that doesn't trigger proper checker callbacks (like pointer escape). Found by Anton Yartsev. llvm-svn: 178160
* [analyzer] Adds cplusplus.NewDelete checker that check for memory leaks, ↵Anton Yartsev2013-03-251-8/+53
| | | | | | double free, and use-after-free problems of memory managed by new/delete. llvm-svn: 177849
* [analyzer] Inline constructors for any object with a trivial destructor.Jordan Rose2012-08-271-0/+12
| | | | | | | | | | | | This allows us to better reason about status objects, like Clang's own llvm::Optional (when its contents are trivially destructible), which are often intended to be passed around by value. We still don't inline constructors for temporaries in the general case. <rdar://problem/11986434> llvm-svn: 162681
* [analyzer] Handle new-expressions with initializers for scalars.Jordan Rose2012-07-161-8/+27
| | | | | | <rdar://problem/11818967> llvm-svn: 160328
* [analyzer] Introduce CXXAllocatorCall to handle placement arg invalidation.Jordan Rose2012-07-021-11/+10
| | | | | | | This is NOT full-blown support for operator new, but removes some nasty duplicated code introduced in r158784. llvm-svn: 159608
* [analyzer] Be careful about implicitly-declared operator new/delete. (PR13090)Jordan Rose2012-06-251-0/+15
| | | | | | | | The implicit global allocation functions do not have valid source locations, but we still want to treat them as being "system header" functions for the purposes of how they affect program state. llvm-svn: 159160
* [analyzer] Move failing 'new' test cases back into new.cpp instead of XFAILing.Jordan Rose2012-06-201-0/+31
| | | | | | | | Per Anna's comment, this is a better way to handle "to-do list"-type failures. This way we'll know if any of the features get fixed; in an XFAIL file, /all/ the cases have to be fixed before lit would tell us anything. llvm-svn: 158791
* [analyzer] Invalidate placement args; return the pointer given to placement newJordan Rose2012-06-201-10/+31
| | | | | | | | | | | | | | | | | | | | | | | | | The default global placement new just returns the pointer it is given. Note that other custom 'new' implementations with placement args are not guaranteed to do this. In addition, we need to invalidate placement args, since they may be updated by the allocator function. (Also, right now we don't properly handle the constructor inside a CXXNewExpr, so we need to invalidate the placement args just so that callers know something changed!) This invalidation is not perfect because CallOrObjCMessage doesn't support CXXNewExpr, and all of our invalidation callbacks expect that if there's no CallOrObjCMessage, the invalidation is happening manually (e.g. by a direct assignment) and shouldn't affect checker-specific metadata (like malloc state); hence the malloc test case in new-fail.cpp. But region values are now properly invalidated, at least. The long-term solution to this problem is to rework CallOrObjCMessage into something more general, rather than the morass of branches it is today. <rdar://problem/11679031> llvm-svn: 158784
* Revert "Revert "Make CXXNewExpr contain only a single initialier, and not ↵Sebastian Redl2012-02-161-0/+1
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
* Revert "Make CXXNewExpr contain only a single initialier, and not hold the ↵Sebastian Redl2012-02-161-1/+0
| | | | | | | | | | used constructor itself." It leads to a compiler crash in the Bullet benchmark. This reverts commit r12014. llvm-svn: 150684
* Make CXXNewExpr contain only a single initialier, and not hold the used ↵Sebastian Redl2012-02-161-0/+1
| | | | | | | | | | constructor itself. Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities. This breaks the static analysis of new expressions. I've filed PR12014 to track this. llvm-svn: 150682
* [analyzer] Remove '-analyzer-check-objc-mem' flag, the nominee for best ↵Argyrios Kyrtzidis2011-02-281-1/+1
| | | | | | misnomer award. llvm-svn: 126676
* [analyzer] Migrate UndefBranchChecker to CheckerV2.Argyrios Kyrtzidis2011-02-281-1/+1
| | | | llvm-svn: 126616
* The second check point in the old test case was invalid.Zhongxing Xu2010-04-211-4/+6
| | | | llvm-svn: 101983
* Add test cases.Zhongxing Xu2010-04-201-0/+12
llvm-svn: 101878
OpenPOWER on IntegriCloud