summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/copypaste
Commit message (Collapse)AuthorAgeFilesLines
* Reapply r362994 & co "[analyzer][tests] Add normalize_plist to replace ↵Hubert Tong2019-06-112-2/+2
| | | | | | | | | | | 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-102-2/+2
| | | | | | | | | | | 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 (`cat` 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 `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-083-5/+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] Emit an error rather than assert on invalid checker option inputKristof Umann2019-03-081-1/+4
| | | | | | | | | | | Asserting on invalid input isn't very nice, hence the patch to emit an error instead. This is the first of many patches to overhaul the way we handle checker options. Differential Revision: https://reviews.llvm.org/D57850 llvm-svn: 355704
* [analyzer] [NFC] Reverse the argument order for "diff" in testsGeorge Karpenkov2019-01-102-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [Analyzer] Define and use diff_plist in tests, NFCMikhail Maltsev2018-09-172-2/+2
| | | | | | | | | 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
* [analyzer] [NFC] Change the tests by making the version check more resilientGeorge Karpenkov2018-09-112-2/+2
| | | | llvm-svn: 341978
* Revert "Revert "Revert "Revert "[analyzer] Add coverage information to plist ↵George Karpenkov2018-09-075-2/+341
| | | | | | | | | | output, update tests"""" This reverts commit 2f5d71d9fa135be86bb299e7d773036e50bf1df6. Hopefully fixing tests on Windows. llvm-svn: 341719
* Revert "Revert "Revert "[analyzer] Add coverage information to plist output, ↵Simon Pilgrim2018-09-075-341/+2
| | | | | | | | update tests""" Reverts analyzer tests from rL341627 again as they still broke windows buildbots llvm-svn: 341648
* Revert "Revert "[analyzer] Add coverage information to plist output, update ↵George Karpenkov2018-09-075-2/+341
| | | | | | | | | | tests"" This reverts commit a39bcab414dd7ace7e490363ecdf01ecce7743fc. Reverting the revert, fixing tests. llvm-svn: 341627
* Revert "[analyzer] Add coverage information to plist output, update tests"George Karpenkov2018-09-073-329/+10
| | | | | | | | This reverts commit 03d183b6b94eda27ce66a4f9b87a00b0a148cf9e. Temporary revert until the tests are fixed. llvm-svn: 341626
* [analyzer] Add coverage information to plist output, update testsGeorge Karpenkov2018-09-073-10/+329
| | | | | | | | Split tests which were still using FileCheck to compare plists. Differential Revision: https://reviews.llvm.org/D51515 llvm-svn: 341621
* Move test inputs into Inputs directory.Richard Smith2018-08-144-2/+163
| | | | | | | We don't need a new ExpectedOutputs/ convention. Expected outputs are just another form of test input. llvm-svn: 339634
* [analyzer] [NFC] [tests] Move plist-based diagnostics tests to separate ↵George Karpenkov2018-08-102-159/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | files, use diff instead of a FileCheck Some of the analyzer tests check the exact plist output, in order to verify that the diagnostics produced is correct. Current testing setup has many issues: plist output clobbers tests, making them harder to read it is impossible to debug test failures given error messages from FileCheck. The only recourse is manually creating the files and using the diff again, it is impossible to update the tests given the error message: the only process is a tedious manual one, going from a separate plist file to CHECK directives. This patch offers a much better approach of using "diff" directly in place of FileCheck, and moving tests to separate files. Generated using the following script: ``` import os import glob import re import subprocess diagnostics_key = "// CHECK: <key>diagnostics</key>" def process_file(f, data): idx = data.index(diagnostics_key) plist_out_f = 'ExpectedOutputs/plists/%s.plist' % f plist_out_folder = os.path.join('ExpectedOutputs/plists/', os.path.dirname(f)) plist_data = data[idx:] plist_data = plist_data.replace('// CHECK: ', '') plist_data = plist_data.replace('// CHECK-NEXT: ', '') plist_data += "</dict>\n</plist>\n" data = data[:idx] ptn = re.compile("FileCheck --?input-file(=| )(%t|%t\.plist) %s") if not ptn.findall(data): print "none found =/ skipping..." return data = ptn.sub(lambda m: "tail -n +11 %s | diff -u -w - %%S/../%s" % (m.group(2), plist_out_f), data) with open(f, 'w') as out_f: out_f.write(data) subprocess.check_call(["mkdir", "-p", plist_out_folder]) with open(plist_out_f, 'w') as out_f: out_f.write(plist_data) def main(): files = glob.glob("**/*.*") for f in files: with open(f) as f_handler: data = f_handler.read() if diagnostics_key in data: print "Converting %s" %f process_file(f, data) if __name__ == "__main__": main() ``` Differential Revision: https://reviews.llvm.org/D50545 llvm-svn: 339475
* [analyzer] Add support for the note diagnostic pieces to plist output format.Artem Dergachev2018-04-241-3/+30
| | | | | | | | | | | | | | | | | Note diagnostic pieces are an additional way of highlighting code sections to the user. They aren't part of the normal path diagnostic sequence. They can also be attached to path-insensitive reports. Notes are already supported by the text output and scan-build. Expanding our machine-readable plist output format to be able to represent notes opens up the possibility for various analyzer GUIs to pick them up. Patch by Umann Kristóf! Differential Revision: https://reviews.llvm.org/D45407 llvm-svn: 330766
* 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
* [NFC] fix trivial typos in commentsHiroshi Inoue2018-01-221-1/+1
| | | | | | "the the" -> "the" llvm-svn: 323078
* [analyzer] Increase minimum complexity filter of the CloneChecker.Raphael Isemann2017-09-0423-23/+23
| | | | | | | | | | | | | | | Summary: So far we used a value of 10 which was useful for testing but produces many false-positives in real programs. The usual suspicious clones we find seem to be at around a complexity value of 70 and for normal clone-reporting everything above 50 seems to be a valid normal clone for users, so let's just go with 50 for now and set this as the new default value. This patch also explicitly sets the complexity value for the regression tests as they serve more of a regression testing/debugging purpose and shouldn't really be reported by default in real programs. I'll add more tests that reflect actual found bugs that then need to pass with the default setting in the future. Reviewers: NoQ Subscribers: cfe-commits, javed.absar, xazax.hun, v.g.vassilev Differential Revision: https://reviews.llvm.org/D34178 llvm-svn: 312468
* [analyzer] Teach CloneDetection about Qt Meta-Object CompilerLeslie Zhai2017-06-195-0/+90
| | | | | | | | | | Reviewers: v.g.vassilev, zaks.anna, NoQ, teemperor Reviewed By: v.g.vassilev, zaks.anna, NoQ, teemperor Differential Revision: https://reviews.llvm.org/D31320 llvm-svn: 305659
* Reland 4: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-0322-22/+22
| | | | | | | | | | | | | | 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-0222-22/+22
| | | | | | | | multiple constraint managers" This reverts commit ea36f1406e1f36bf456c3f3929839b024128e468. llvm-svn: 296841
* Reland 3: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-0222-22/+22
| | | | | | | | | | | | | | 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-0222-22/+22
| | | | | | | | multiple constraint managers" This reverts commit f93343c099fff646a2314cc7f4925833708298b1. llvm-svn: 296836
* Reland 2: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-03-0222-22/+22
| | | | | | | | | | | | | | 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-2822-22/+22
| | | | | | | | multiple constraint managers" This reverts commit 1b28d0b10e1c8feccb971abb6ef7a18bee589830. llvm-svn: 296422
* Reland: [analyzer] NFC: Update test infrastructure to support multiple ↵Dominic Chen2017-02-2822-22/+22
| | | | | | | | | | | | | | 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-2722-22/+22
| | | | | | | | constraint managers" This reverts commit 8e7780b9e59ddaad1800baf533058d2c064d4787. llvm-svn: 296317
* [analyzer] NFC: Update test infrastructure to support multiple constraint ↵Dominic Chen2017-02-2722-22/+22
| | | | | | | | | | | | | | 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
* [analyzer] Re-apply r283094 "Improve CloneChecker diagnostics"Artem Dergachev2016-10-0811-29/+214
| | | | | | The parent commit (r283092) was reverted before and now finally landed. llvm-svn: 283661
* Revert "[analyzer] Improve CloneChecker diagnostics" as its depends on ↵Vitaly Buka2016-10-0411-214/+29
| | | | | | | | reverted r283092 This reverts commit r283094. llvm-svn: 283182
* [analyzer] Improve CloneChecker diagnosticsArtem Dergachev2016-10-0311-29/+214
| | | | | | | | | | | | | | | | | | Highlight code clones referenced by the warning message with the help of the extra notes feature recently introduced in r283092. Change warning text to more clang-ish. Remove suggestions from the copy-paste error checker diagnostics, because currently our suggestions are strictly 50% wrong (we do not know which of the two code clones contains the error), and for that reason we should not sound as if we're actually suggesting this. Hopefully a better solution would bring them back. Make sure the suspicious clone pair structure always mentions the correct variable for the second clone. Differential Revision: https://reviews.llvm.org/D24916 llvm-svn: 283094
* [analyzer] Fix CloneDetector crash on calling methods of class templates.Artem Dergachev2016-08-231-0/+12
| | | | | | | | | | | | | | If a call expression represents a method call of a class template, and the method itself isn't templated, then the method may be considered to be a template instantiation without template specialization arguments. No longer crash when we could not find template specialization arguments. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23780 llvm-svn: 279529
* [analyzer] Make CloneDetector consider macro expansions.Artem Dergachev2016-08-202-0/+117
| | | | | | | | | | | | | | | | | So far macro-generated code was treated by the CloneDetector as normal code. This caused that some macros where reported as false-positive clones because large chunks of code coming from otherwise concise macro expansions were treated as copy-pasted code. This patch ensures that macros are treated in the same way as literals/function calls. This prevents macros that expand into multiple statements from being reported as clones. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23316 llvm-svn: 279367
* [analyzer] Make CloneDetector consider template arguments.Artem Dergachev2016-08-201-0/+54
| | | | | | | | | | | For example, code samples `isa<Stmt>(S)' and `isa<Expr>(S)' are no longer considered to be clones. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23555 llvm-svn: 279366
* [analyzer] Teach CloneDetector to find clones that look like copy-paste errors.Artem Dergachev2016-08-181-0/+97
| | | | | | | | | | | | | | | | | | | The original clone checker tries to find copy-pasted code that is exactly identical to the original code, up to minor details. As an example, if the copy-pasted code has all references to variable 'a' replaced with references to variable 'b', it is still considered to be an exact clone. The new check finds copy-pasted code in which exactly one variable seems out of place compared to the original code, which likely indicates a copy-paste error (a variable was forgotten to be renamed in one place). Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23314 llvm-svn: 279056
* [analyzer] Fix a crash in CloneDetector when calling functions by pointers.Artem Dergachev2016-08-101-0/+12
| | | | | | | | | | | CallExpr may have a null direct callee when the callee function is not known in compile-time. Do not try to take callee name in this case. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D23320 llvm-svn: 278238
* [analyzer] Make CloneDetector recognize different variable patterns.Artem Dergachev2016-08-042-22/+9
| | | | | | | | | | | | | | | | | CloneDetector should be able to detect clones with renamed variables. However, if variables are referenced multiple times around the code sample, the usage patterns need to be recognized. For example, (x < y ? y : x) and (y < x ? y : x) are no longer clones, however (a < b ? b : a) is still a clone of the former. Variable patterns are computed and compared during a separate filtering pass. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D22982 llvm-svn: 277757
* [analyzer] Hotfix for buildbot failure due to unspecified triple in r277449Artem Dergachev2016-08-021-1/+1
| | | | | | | | | If a target triple is not specified, the default host triple is used, which is not good for compiling inline assembler code. Patch by Raphael Isemann! llvm-svn: 277473
* [analyzer] Respect statement-specific data in CloneDetection.Artem Dergachev2016-08-0214-8/+364
| | | | | | | | | | | | | | | | | So far the CloneDetector only respected the kind of each statement when searching for clones. This patch refines the way the CloneDetector collects data from each statement by providing methods for each statement kind, that will read the kind-specific attributes. For example, statements 'a < b' and 'a > b' are no longer considered to be clones, because they are different in operation code, which is an attribute specific to the BinaryOperator statement kind. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D22514 llvm-svn: 277449
* [analyzer] Add basic capabilities to detect source code clones.Artem Dergachev2016-07-265-0/+127
This patch adds the CloneDetector class which allows searching source code for clones. For every statement or group of statements within a compound statement, CloneDetector computes a hash value, and finds clones by detecting identical hash values. This initial patch only provides a simple hashing mechanism that hashes the kind of each sub-statement. This patch also adds CloneChecker - a simple static analyzer checker that uses CloneDetector to report copy-pasted code. Patch by Raphael Isemann! Differential Revision: https://reviews.llvm.org/D20795 llvm-svn: 276782
OpenPOWER on IntegriCloud