-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix #13523 CTU: Mention including cpp file for error in header #7174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 21 commits
11a1f22
f864c2b
bf3a994
f6b31de
46239d5
12b2dd0
1ab20e6
791b066
e04d0a6
706c5ca
9a57c31
e0a623c
e28646c
65e54b5
25d1801
7309cf3
9a41138
fbe7f87
1a219d8
a9b9de4
750b92c
f65bc60
33cedb5
cc60882
4f288ff
155eea9
e6c30a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "nullpointer1.h" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #include "nullpointer1_1.h" | ||
|
|
||
| template<typename T> | ||
| void f(T* p) { | ||
| if (sizeof(T) == 4) | ||
| p = nullptr; | ||
| g(p); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| template<typename T> | ||
| void g(T* p) { | ||
| *p = 0; | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |||||||||||||||||||||||||||||||||||
| import json | ||||||||||||||||||||||||||||||||||||
| import shutil | ||||||||||||||||||||||||||||||||||||
| from testutils import cppcheck | ||||||||||||||||||||||||||||||||||||
| import xml.etree.ElementTree as ET | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| __script_dir = os.path.dirname(os.path.abspath(__file__)) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
@@ -358,3 +359,35 @@ def test_checkclass_project_builddir_j(tmpdir): | |||||||||||||||||||||||||||||||||||
| build_dir = os.path.join(tmpdir, 'b1') | ||||||||||||||||||||||||||||||||||||
| os.mkdir(build_dir) | ||||||||||||||||||||||||||||||||||||
| __test_checkclass_project(tmpdir, ['-j2', '--cppcheck-build-dir={}'.format(build_dir)]) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def __test_nullpointer_file0(extra_args): | ||||||||||||||||||||||||||||||||||||
| args = [ | ||||||||||||||||||||||||||||||||||||
| '-q', | ||||||||||||||||||||||||||||||||||||
| '--xml', | ||||||||||||||||||||||||||||||||||||
| '--error-exitcode=1', | ||||||||||||||||||||||||||||||||||||
| 'whole-program/nullpointer1.cpp' | ||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| args += extra_args | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| ret, stdout, stderr = cppcheck(args, cwd=__script_dir) | ||||||||||||||||||||||||||||||||||||
| results = ET.fromstring(stderr) | ||||||||||||||||||||||||||||||||||||
| file0 = '' | ||||||||||||||||||||||||||||||||||||
| for e in results.findall('errors/error[@id="ctunullpointer"]'): | ||||||||||||||||||||||||||||||||||||
| file0 = e.attrib['file0'] | ||||||||||||||||||||||||||||||||||||
| assert file0 == 'whole-program/nullpointer1.cpp' | ||||||||||||||||||||||||||||||||||||
| assert stdout == '' | ||||||||||||||||||||||||||||||||||||
| assert ret == 1, stdout | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def test_nullpointer_file0(): | ||||||||||||||||||||||||||||||||||||
| __test_nullpointer_file0(['-j1']) | ||||||||||||||||||||||||||||||||||||
|
chrchr-github marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| @pytest.mark.skip(reason="flaky!?") | ||||||||||||||||||||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Usually I would assume it is an issue with running the test in parallel but there is nothing in this test which could cause that. But this test is build with UBSAN so it might indicate such an issue. The asserts are in a bad order so that would be obfuscated. I adjusted them so we should get more details (that needs to be applied across all the tests - there are already some initial helpers but something for later).
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The xfail is still in, so it might pass now but we might not see the error reported by the sanitizer.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With xfail in,
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The injection stuff checks if any of the parameters in question already exists and only injects those is necessary. The This looks weird though. Will take a look later. |
||||||||||||||||||||||||||||||||||||
| def test_nullpointer_file0_j(): | ||||||||||||||||||||||||||||||||||||
| __test_nullpointer_file0(['-j2']) | ||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||
| def test_nullpointer_file0_builddir_j(tmpdir): | ||||||||||||||||||||||||||||||||||||
| build_dir = os.path.join(tmpdir, 'b1') | ||||||||||||||||||||||||||||||||||||
|
chrchr-github marked this conversation as resolved.
|
||||||||||||||||||||||||||||||||||||
| os.mkdir(build_dir) | ||||||||||||||||||||||||||||||||||||
| __test_nullpointer_file0(['-j2', '--cppcheck-build-dir={}'.format(build_dir)]) | ||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.