summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/diagnostics
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Fix SARIF column locationsJoe Ranieri2020-01-143-6/+82
| | | | Differential revision: https://reviews.llvm.org/D70689
* [Analyzer][NFC] Separate white-box tests for iterator modelling from ↵Adam Balogh2019-11-141-1/+1
| | | | | | | | | | | iterator checker tests The recently committed debug.IteratorDebugging checker enables standalone white-box testing of the modelling of containers and iterators. For the three checkers based on iterator modelling only simple tests are needed. Differential Revision: https://reviews.llvm.org/D70123
* [analyzer] Specify the C++ standard in more tests.Artem Dergachev2019-10-191-1/+1
| | | | | | Makes life easier for downstream developers with different default standard. llvm-svn: 375308
* [Analyzer] Iterator Checkers - Make range errors and invalidated access fatalAdam Balogh2019-08-291-1/+1
| | | | | | | | | | | | | | Range errors (dereferencing or incrementing the past-the-end iterator or decrementing the iterator of the first element of the range) and access of invalidated iterators lead to undefined behavior. There is no point to continue the analysis after such an error on the same execution path, but terminate it by a sink node (fatal error). This also improves the performance and helps avoiding double reports (e.g. in case of nested iterators). Differential Revision: https://reviews.llvm.org/D62893 llvm-svn: 370314
* Update the SARIF exporter to SARIF 2.1Joe Ranieri2019-08-272-108/+98
| | | | | | | | | | This updates the SARIF exporter to produce SARIF 2.1 output. The bulk of the diffs come from two changes to SARIF: * https://github.com/oasis-tcs/sarif-spec/issues/309 * https://github.com/oasis-tcs/sarif-spec/issues/179 Differential Revision: https://reviews.llvm.org/D65211 llvm-svn: 370068
* Fix a SARIF exporter crash with macro expansionsJoe Ranieri2019-08-272-21/+147
| | | | | | Differential Revision: https://reviews.llvm.org/D65209 llvm-svn: 370061
* Fix text range end columns in SARIF to be exclusiveJoe Ranieri2019-08-272-14/+11
| | | | | | | | According to the SARIF specification, "a text region does not include the character specified by endColumn". Differential Revision: https://reviews.llvm.org/D65206 llvm-svn: 370060
* [analyzer] Enable control dependency condition tracking by defaultKristof Umann2019-08-221-0/+1
| | | | | | | | This patch concludes my GSoC'19 project by enabling track-conditions by default. Differential Revision: https://reviews.llvm.org/D66381 llvm-svn: 369616
* [analyzer] Prune calls to functions with linear CFGs that return a non-zero ↵Kristof Umann2019-08-131-4/+2
| | | | | | | | | | | | | | | | constrained value During the evaluation of D62883, I noticed a bunch of totally meaningless notes with the pattern of "Calling 'A'" -> "Returning value" -> "Returning from 'A'", which added no value to the report at all. This patch (not only affecting tracked conditions mind you) prunes diagnostic messages to functions that return a value not constrained to be 0, and are also linear. Differential Revision: https://reviews.llvm.org/D64232 llvm-svn: 368771
* [Analyzer] Iterator Checkers - Fix for Crash on Iterator DifferencesAdam Balogh2019-08-051-1/+1
| | | | | | | Iterators differences were mistakenly handled as random decrements which causes an assertion. This patch fixes this. llvm-svn: 367802
* [analyzer] SARIF: Add EOF newline; replace diff_sarifHubert Tong2019-06-194-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch applies a change similar to rC363069, but for SARIF files. The `%diff_sarif` lit substitution invokes `diff` with a non-portable `-I` option. The intended effect can be achieved by normalizing the inputs to `diff` beforehand. Such normalization can be done with `grep -Ev`, which is also used by other tests. Additionally, this patch updates the SARIF output to have a newline at the end of the file. This makes it so that the SARIF file qualifies as a POSIX text file, which increases the consumability of the generated file in relation to various tools. Reviewers: NoQ, sfertile, xingxue, jasonliu, daltenty, aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62952 llvm-svn: 363822
* [analyzer][NFC][tests] Pre-normalize expected-sarif filesHubert Tong2019-06-192-20/+0
| | | | | | | | As discussed in the review for D62952, this patch pre-normalizes the reference expected output sarif files by removing lines containing fields for which we expect differences that should be ignored. llvm-svn: 363788
* [analyzer] Push correct version of 'Track indices of arrays'Kristof Umann2019-06-161-4/+43
| | | | | | Messed up the commit, oops. llvm-svn: 363512
* [analyzer] Track indices of arraysKristof Umann2019-06-161-0/+25
| | | | | | | | | | | | Often times, when an ArraySubscriptExpr was reported as null or undefined, the bug report was difficult to understand, because the analyzer explained why arr[i] has that value, but didn't realize that in fact i's value is very important as well. This patch fixes this by tracking the indices of arrays. Differential Revision: https://reviews.llvm.org/D63080 llvm-svn: 363510
* Reapply r362994 & co "[analyzer][tests] Add normalize_plist to replace ↵Hubert Tong2019-06-117-7/+7
| | | | | | | | | | | diff_plist" Following r363007, which reverted r362998, r362996, and r362994, reapply with adjustments for the CRLF differences encountered with Windows. Namely, the `-b` option of `diff` is employed, and the `grep` patterns have `$` replaced with `[[:space:]]*$`. llvm-svn: 363069
* Revert r362994 & co "[analyzer][tests] Add normalize_plist to replace ↵Reid Kleckner2019-06-107-7/+7
| | | | | | | | | | | diff_plist" Reverts r362998, r362996, and r362994 because the tests do not pass on Windows due to CRLF changes. Adding back `-w` to diff is not enough, the new grep substitution doesn't work on Windows, and fixing it is non-trivial. llvm-svn: 363007
* [analyzer][tests] Use normalize_plist in place of diff_plist (`tail` cases)Hubert Tong2019-06-102-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The `%diff_plist` lit substitution invokes `diff` with a non-portable `-I` option. The intended effect can be achieved by normalizing the inputs to `diff` beforehand. Such normalization can be done with `grep -Ev`, which is also used by other tests. This patch applies the change (adjusted for review comments) described in http://lists.llvm.org/pipermail/cfe-dev/2019-April/061904.html mechanically to the cases where the output file is piped to `%diff_plist` via `tail`. `%diff_plist` is then, being unused, removed. The changes were applied via a script. Reviewers: NoQ, sfertile, xingxue, jasonliu, daltenty Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62951 llvm-svn: 362998
* [analyzer][tests] Use normalize_plist in place of diff_plist (`cat` cases)Hubert Tong2019-06-105-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The `%diff_plist` lit substitution invokes `diff` with a non-portable `-I` option. The intended effect can be achieved by normalizing the inputs to `diff` beforehand. Such normalization can be done with `grep -Ev`, which is also used by other tests. This patch applies the change (adjusted for review comments) described in http://lists.llvm.org/pipermail/cfe-dev/2019-April/061904.html mechanically to the cases where the output file is piped to `%diff_plist` via `cat`. The changes were applied via a script, except that `clang/test/Analysis/NewDelete-path-notes.cpp` and `clang/test/Analysis/plist-macros-with-expansion.cpp` were each adjusted for the line-continuation on the relevant `RUN` step. Reviewers: NoQ, sfertile, xingxue, jasonliu, daltenty Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, Charusso, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62950 llvm-svn: 362996
* [analyzer][NFC][tests] Pre-normalize expected-plistsHubert Tong2019-06-087-17/+0
| | | | | | | | As suggested in the review for D62949, this patch pre-normalizes the reference expected output plist files by removing lines containing fields for which we expect differences that should be ignored. llvm-svn: 362877
* [analyzer] ConditionBRVisitor: Boolean supportCsaba Dabis2019-05-291-1/+1
| | | | | | | | | | | | | | | | | Summary: - Reviewers: NoQ, george.karpenkov Reviewed By: NoQ, george.karpenkov Subscribers: cfe-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D58207 llvm-svn: 362027
* [analyzer] ConditionBRVisitor: MemberExpr supportCsaba Dabis2019-05-293-12/+13
| | | | | | | | | | | | | | | | | Summary: - Reviewers: NoQ, george.karpenkov Reviewed By: NoQ Subscribers: cfe-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp Tags: #clang Differential Revision: https://reviews.llvm.org/D58206 llvm-svn: 362026
* [analyzer] ConditionBRVisitor: Enhance to write out more informationCsaba Dabis2019-05-293-11/+22
| | | | | | | | | | | | | | | | | | | | Summary: Add extra messages to the bug report to inform the user why the analyzer `Taking true/false branch`. Reviewers: NoQ, george.karpenkov Reviewed By: NoQ Subscribers: gerazo, gsd, dkrupp, whisperity, baloghadamsoftware, xazax.hun, eraman, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D53076 llvm-svn: 362020
* [analyzer] Add a prunable note for skipping vbase inits in subclasses.Artem Dergachev2019-05-241-0/+44
| | | | | | | | | | | | | When initialization of virtual base classes is skipped, we now tell the user about it, because this aspect of C++ isn't very well-known. The implementation is based on the new "note tags" feature (r358781). In order to make use of it, allow note tags to produce prunable notes, and move the note tag factory to CoreEngine. Differential Revision: https://reviews.llvm.org/D61817 llvm-svn: 361682
* [analyzer] NFC: Prevent multi-file plist test from spamming up the build folder.Artem Dergachev2019-05-242-6/+2
| | | | | | | It was producing an HTML report with a random name on every tests run and never cleaned those up. llvm-svn: 361592
* [analyzer][tests] Use diff_plist, correct order of arguments for missed ↵Hubert Tong2019-05-012-2/+2
| | | | | | | | | | | | | cases; NFC For various files under `clang/test/Analysis`, D52036 applied `%diff_plist` to replace `diff` invocations with certain options and D56340 swapped the order of the arguments so that the reference file comes first. The tests that used `tail` to filter the test output were not modified accordingly. This patch applies the corresponding update to those tests. llvm-svn: 359691
* [analyzer] Fix macro names in diagnostics within bigger macros.Artem Dergachev2019-04-231-1/+26
| | | | | | | | | If macro "CHECK_X(x)" expands to something like "if (x != NULL) ...", the "Assuming..." note no longer says "Assuming 'x' is equal to CHECK_X". Differential Revision: https://reviews.llvm.org/D59121 llvm-svn: 359037
* [analyzer] PR41239: Fix a crash on invalid source location in ↵Artem Dergachev2019-03-291-1/+11
| | | | | | | | | | | | | | | | | NoStoreFuncVisitor. It turns out that SourceManager::isInSystemHeader() crashes when an invalid source location is passed into it. Invalid source locations are relatively common: not only they come from body farms, but also, say, any function in C that didn't come with a forward declaration would have an implicit forward declaration with invalid source locations. There's a more comfy API for us to use in the Static Analyzer: CallEvent::isInSystemHeader(), so just use that. Differential Revision: https://reviews.llvm.org/D59901 llvm-svn: 357329
* [analyzer] ConditionBRVisitor: Unknown condition evaluation supportCsaba Dabis2019-03-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | Summary: If the constraint information is not changed between two program states the analyzer has not learnt new information and made no report. But it is possible to happen because we have no information at all. The new approach evaluates the condition to determine if that is the case and let the user know we just `Assuming...` some value. Reviewers: NoQ, george.karpenkov Reviewed By: NoQ Subscribers: llvm-commits, xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gsd, gerazo Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D57410 llvm-svn: 356323
* Revert "[analyzer] ConditionBRVisitor: Unknown condition evaluation support"Csaba Dabis2019-03-161-2/+1
| | | | | | This reverts commit 0fe67a61cd4aec13c7969a179517f1cc06ab05cd. llvm-svn: 356320
* [analyzer] ConditionBRVisitor: Unknown condition evaluation supportCsaba Dabis2019-03-161-1/+2
| | | | | | | | | | | | | | | | Summary: If the constraint information is not changed between two program states the analyzer has not learnt new information and made no report. But it is possible to happen because we have no information at all. The new approach evaluates the condition to determine if that is the case and let the user know we just 'Assuming...' some value. Reviewers: NoQ, george.karpenkov Reviewed By: NoQ Subscribers: xazax.hun, baloghadamsoftware, szepet, a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, gsd, gerazo Tags: #clang Differential Revision: https://reviews.llvm.org/D57410 llvm-svn: 356319
* [analyzer] Fix an assertation failure for invalid sourcelocation, add a new ↵Kristof Umann2019-03-141-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | debug checker For a rather short code snippet, if debug.ReportStmts (added in this patch) was enabled, a bug reporter visitor crashed: struct h { operator int(); }; int k() { return h(); } Ultimately, this originated from PathDiagnosticLocation::createMemberLoc, as it didn't handle the case where it's MemberExpr typed parameter returned and invalid SourceLocation for MemberExpr::getMemberLoc. The solution was to find any related valid SourceLocaion, and Stmt::getBeginLoc happens to be just that. Differential Revision: https://reviews.llvm.org/D58777 llvm-svn: 356161
* [analyzer] Make sure base-region and its sub-regions are either all alive or ↵Artem Dergachev2019-01-181-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | all dead. SymbolReaper now realizes that our liveness analysis isn't sharp enough to discriminate between liveness of, say, variables and their fields. Surprisingly, this didn't quite work before: having a variable live only through Environment (eg., calling a C++ method on a local variable as the last action ever performed on that variable) would not keep the region value symbol of a field of that variable alive. It would have been broken in the opposite direction as well, but both Environment and RegionStore use the scanReachableSymbols mechanism for finding live symbols regions within their values, and due to that they accidentally end up marking the whole chain of super-regions as live when at least one sub-region is known to be live. It is now a direct responsibility of SymbolReaper to maintain this invariant, and a unit test was added in order to make sure it stays that way. Differential Revision: https://reviews.llvm.org/D56632 rdar://problem/46914108 llvm-svn: 351499
* Remove irrelevant references to legacy git repositories fromJames Y Knight2019-01-151-1/+1
| | | | | | | | | compiler identification lines in test-cases. (Doing so only because it's then easier to search for references which are actually important and need fixing.) llvm-svn: 351200
* [analyzer] pr38838, pr39976: Fix crash on diagnosing before implicit destructor.Artem Dergachev2019-01-101-0/+25
| | | | | | | | | | | | | | | | | | | We need to be able to emit the diagnostic at PreImplicitCall, and the patch implements this functionality. However, for now the need for emitting such diagnostics is not all that great: it is only necessary to not crash when emitting a false positive due to an unrelated issue of having dead symbol collection not working properly. Coming up with a non-false-positive test seems impossible with the current set of checkers, though it is likely to be needed for good things as well in the future. Differential Revision: https://reviews.llvm.org/D56042 rdar://problem/46911462 llvm-svn: 350907
* [analyzer] [NFC] Reverse the argument order for "diff" in testsGeorge Karpenkov2019-01-109-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | The current argument order has "expected" and "actual" the wrong way around, so that the diff shows the change from expected to actual, not from actual to expected. Namely, if the expected diagnostics contains the string "foo", but the analyzer emits "bar", we really want to see: ``` - foo + bar ``` not ``` - bar + foo ``` since adapting to most changes would require applying that diff to the expected output. Differential Revision: https://reviews.llvm.org/D56340 llvm-svn: 350866
* Correct the spelling of helpURI to helpUri.Aaron Ballman2019-01-101-2/+2
| | | | | | JSON is case sensitive and the SARIF spec uses the corrected spelling. llvm-svn: 350817
* Allow direct navigation to static analysis checker documentation through ↵Aaron Ballman2018-12-201-0/+2
| | | | | | | | SARIF exports. This adds anchors to all of the documented checks so that you can directly link to a check by a stable name. This is useful because the SARIF file format has a field for specifying a URI to documentation for a rule and some viewers, like CodeSonar, make use of this information. These links are then exposed through the SARIF exporter. llvm-svn: 349812
* [analyzer] MoveChecker Pt.6: Suppress the warning for the move-safe STL classes.Artem Dergachev2018-12-141-1/+1
| | | | | | | | | | | Some C++ standard library classes provide additional guarantees about their state after move. Suppress warnings on such classes until a more precise behavior is implemented. Warnings for locals are not suppressed anyway because it's still most likely a bug. Differential Revision: https://reviews.llvm.org/D55307 llvm-svn: 349191
* Update our SARIF support from 10-10 to 11-28.Aaron Ballman2018-12-142-29/+51
| | | | | | | | | | | | | Functional changes include: * The run.files property is now an array instead of a mapping. * fileLocation objects now have a fileIndex property specifying the array index into run.files. * The resource.rules property is now an array instead of a mapping. * The result object was given a ruleIndex property that is an index into the resource.rules array. * rule objects now have their "id" field filled out in addition to the name field. * Updated the schema and spec version numbers to 11-28. llvm-svn: 349188
* [analyzer] Fix diagnostics/explicit-suppression.cppFangrui Song2018-11-021-1/+1
| | | | | | *OI++ = *II++ is on line 670, not 668 llvm-svn: 345992
* [analyzer] Put llvm.Conventions back in alphaKristof Umann2018-11-021-1/+1
| | | | | | | | | | | | Interestingly, this many year old (when I last looked I remember 2010ish) checker was committed without any tests, so I thought I'd implement them, but I was shocked to see how I barely managed to get it working. The code is severely outdated, I'm not even sure it has ever been used, so I'd propose to move it back into alpha, and possibly even remove it. Differential Revision: https://reviews.llvm.org/D53856 llvm-svn: 345990
* Output "rule" information in SARIF exports.Aaron Ballman2018-11-014-2/+344
| | | | | | SARIF allows you to export descriptions about rules that are present in the SARIF log. Expose the help text table generated into Checkers.inc as the rule's "full description" and export all of the rules present in the analysis output. This information is useful for analysis result viewers like CodeSonar. llvm-svn: 345874
* Update to the 10-10 SARIF spec.Aaron Ballman2018-11-012-8/+6
| | | | | | This removes the Step property (which can be calculated by consumers trivially), and updates the schema and version numbers accordingly. llvm-svn: 345823
* [analyzer] SARIF: Suppress version testing in a more downstream-friendly manner.Artem Dergachev2018-11-012-2/+2
| | | | | | No functional change intended. llvm-svn: 345807
* Changing the command line parameters sent to diff for this test.Aaron Ballman2018-10-302-2/+2
| | | | | | On some systems, -U 1 was being interpreted as -U -1. Trying -U1 to see if that's the universally accepted approach instead. llvm-svn: 345649
* Speculatively attempt to fix a failing testbot.Aaron Ballman2018-10-302-2/+2
| | | | | | A testbot ( http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/54690/) was failing with a complaint about an obsolete option that wasn't present in the command line in the first place. This replaces my guess at the "obsolete option" with a different spelling that will hopefully be more acceptable to this bot without breaking other bots. llvm-svn: 345635
* Add the ability to output static analysis results to SARIF.Aaron Ballman2018-10-302-0/+114
| | | | | | This allows users to specify SARIF (https://github.com/oasis-tcs/sarif-spec) as the output from the clang static analyzer so that the results can be read in by other tools, such as extensions to Visual Studio and VSCode, as well as static analyzers like CodeSonar. llvm-svn: 345628
* [analyzer] [tests] [quickfix] Make more test more resilient for non-defaut -std.Artem Dergachev2018-10-031-1/+1
| | | | | | | It is important to specify the version of the standard because tests should test the same thing regardless of the current default version of the standard. llvm-svn: 343736
* [analyzer] Prevent crashes in FindLastStoreBRVisitorGeorge Karpenkov2018-09-241-0/+17
| | | | | | | | | | This patch is a band-aid. A proper solution would be too change trackNullOrUndefValue to only try to dereference the pointer when it is relevant to the problem. Differential Revision: https://reviews.llvm.org/D52435 llvm-svn: 342920
* [Analyzer] Define and use diff_plist in tests, NFCMikhail Maltsev2018-09-175-5/+5
| | | | | | | | | This patch defines a new substitution and uses it to reduce duplication in the Clang Analyzer test cases. Differential Revision: https://reviews.llvm.org/D52036 llvm-svn: 342365
OpenPOWER on IntegriCloud