-
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 14 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,33 @@ 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'): | ||
| if e.attrib['id'] == 'ctunullpointer': | ||
| if 'file0' in e.attrib: | ||
|
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. Not sure why this is necessary, but there was a
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. That means that it doesn't contain that key.
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. Yeah, but there should only be one
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. We should probably add a few more asserts on the results. Like the amount of returned nodes and such. You could also limit the XPath to only return the node in question by adding
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.
Not so easy, since getting both
Done. |
||
| 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.
|
||
|
|
||
| def test_nullpointer_file0_j(): | ||
| 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.