Commit Graph

133 Commits

Author SHA1 Message Date
Eric Sesterhenn 3b1c701766
fix casing in variable name (#5778)
The attribute movedValue is misspelled with an uppercase V, this leads
to errors when printing token values:

```
$ python3 runaddon.py test.py test.c.dump 
Checking test.c.dump...
Checking test.c.dump, config ...
line 2 str=""lala\n""
Traceback (most recent call last):
  File "/home/eric/tools/cppcheck/addons/runaddon.py", line 11, in <module>
    cppcheck.runcheckers()
  File "/home/eric/tools/cppcheck/addons/cppcheck.py", line 39, in runcheckers
    c(cfg, data)
  File "test.py", line 9, in func
    print(f'    {value}')
  File "/home/eric/tools/cppcheck/addons/cppcheckdata.py", line 907, in __repr__
    ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
  File "/home/eric/tools/cppcheck/addons/cppcheckdata.py", line 907, in <genexpr>
    ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs))
AttributeError: 'Value' object has no attribute 'movedValue'
```
2023-12-18 18:57:08 +01:00
Swasti Shrivastava db66105128
Fix #10854: False positive: misra-c2012-9.2: inner union (#5693) 2023-11-27 18:28:53 +01:00
Daniel Marjamäki 727d086dc4
Fix #12217 (misra 11.4: report conversion in macro) (#5692) 2023-11-22 12:47:48 +01:00
PeterSchops b689ca8d89
Update cppcheckdata.py (#5149)
* Update cppcheckdata.py

- added links to cpp-file/function that writes this part of the dump-file 
- updated documentation (Added list of possible return values for a number of variables) 
- added MacroUsage isKnownValue 
- added ValueType reference 
- added Token isBoolean 
- added Token isCast 
- added Token externLang 
- added Token isComplex 
- added Token isRestrict 
- added Token isAttributeExport 
- added Token originalName 
- added Scope functions 
- added Scope definedType 
- added Function hasVirtualSpecifier 
- removed Function isVirtual 
- added Function isAttributeNoreturn 
- added Function overriddenFunction 
- added Variable isVolatile 
- class Container added 
- added Value movedValue 
- added Value uninit 
- added Value bufferSize 
- removed Value inconclusive and added it to valueKind

* Update cppcheckdata.py

removed encoding from open (needed to make python 2.7 check pass) where python 2.7 should not be used anymore

* Update cppcheckdata.py after feedback

made sure that attributes I added to the class always have a value
added some missing attributes in the print
2023-06-15 20:42:58 +02:00
Long Radix c033c62190
Typos and stilistic updates (#5141) 2023-06-14 12:30:45 +02:00
Paul Fultz II 72c764b034
Expose exprId to addon (#4354) 2022-08-16 22:00:31 +02:00
Paul Fultz II a8c1cdca57
Add ** to match until in addons (#4353) 2022-08-16 19:05:37 +02:00
Paul Fultz II 754250cd57
Add methods to token class in addons (#4320) 2022-07-30 11:09:22 +02:00
Paul Fultz II 7b549b622f
Add match function to addons (#4268) 2022-07-12 22:00:15 +02:00
Daniel Marjamäki ef33ff628f cppcheckdata.py: fix cmd_output() function, handle errors better 2022-06-16 14:07:14 +02:00
Daniel Marjamäki 9e31d6d05d Revert "cppcheckdata.py: better handling when subprocess call fails"
This reverts commit 1cc3b46d32.
2022-06-15 19:38:40 +02:00
Daniel Marjamäki 1cc3b46d32 cppcheckdata.py: better handling when subprocess call fails 2022-06-15 17:13:14 +02:00
Daniel Marjamäki 9b807ba047 misra: fix problems when executing premium addon 2022-05-05 14:15:09 +02:00
Daniel Marjamäki d50823fd22 Fix misra crash when premium addon fails 2022-05-03 18:37:59 +02:00
Daniel Marjamäki a5e0a9fe08 cppcheckdata: if 'import pathlib' fails then print a proper error message that explains how user can solve the problem. 2022-04-22 21:39:14 +02:00
Daniel Marjamäki ea63b8e2bb misra: fix void parameter check 2022-04-01 21:34:47 +02:00
Daniel Marjamäki f907bba4e5 cppcheckdata.py: code cleanup 2022-03-19 12:27:24 +01:00
Daniel Marjamäki 7728c53cb9 Addons: Variable.constness will never be None 2022-03-19 10:36:46 +01:00
Daniel Marjamäki 7290ec0db6 cppcheckdata: remove debug output 2022-03-09 21:38:44 +01:00
Daniel Marjamäki 03deb4d31e addons: interface with premiumaddon if it exists 2022-02-24 16:08:59 +01:00
Daniel Marjamäki 3dd200930a Revert "misra,cert: use premiumaddon if it exists"
This reverts commit ef28c579bf.
2022-02-23 22:38:41 +01:00
Daniel Marjamäki f68b219300 Revert "cppcheckdata: a bit better handling for windows"
This reverts commit ef6bbcb6ad.
2022-02-23 22:38:26 +01:00
Daniel Marjamäki ef6bbcb6ad cppcheckdata: a bit better handling for windows 2022-02-23 20:40:00 +01:00
Daniel Marjamäki ef28c579bf misra,cert: use premiumaddon if it exists 2022-02-23 20:26:31 +01:00
Paul Fultz II ccea1da33a
Add missing valueflow attributes to cppcheckdata.py (#3663) 2022-01-02 08:11:36 +01:00
Daniel Marjamäki d0e68e0d77 misra; add rule 17.3 2021-12-11 12:42:15 +01:00
Daniel Marjamäki 10109a5ef7 dumpfile: remove redundant Variable attributes isArgument and isLocal. Add isVolatile. 2021-11-19 17:21:27 +01:00
PeterSchops 42f66433bc
Misra add c11 keywords (#3448) 2021-09-06 20:13:15 +02:00
Daniel Marjamäki ca047e57bf Switch from http to https on our sourceforge webpage 2021-08-28 12:46:54 +02:00
Daniel Marjamäki ec301b2447 cppcheckdata.py: fixed Value::tokvalue 2021-08-22 05:56:16 +02:00
Daniel Marjamäki f85f3c28e1 misra; implement rule 21.15 2021-07-30 15:53:10 +02:00
Daniel Marjamäki e08ee3bac7 addons; Add get_function_call_name_args 2021-07-24 19:34:11 +02:00
Daniel Marjamäki 388b7a0fae misra; implemented rule 20.12 2021-07-22 19:51:31 +02:00
Daniel Marjamäki 74ab8f1a48 misra; implemented rule 20.8 2021-07-22 08:46:28 +02:00
Daniel Marjamäki d1fe34e167 misra; implement rule 8.10 2021-07-18 21:18:07 +02:00
Daniel Marjamäki aa910d3c38 misra; implemented rule 8.5 2021-07-17 19:59:21 +02:00
Daniel Marjamäki 9d5c65fcce CI; Improved testing of misra addon 2021-07-11 17:24:14 +02:00
Daniel Marjamäki db58952a33 Addons CTU; pass all filenames for whole program analysis in file instead of through command line 2021-07-09 08:33:07 +02:00
Daniel Marjamäki e05a9d7e65 misra: implement rule 2.5 2021-07-08 22:03:27 +02:00
Daniel Marjamäki 4ecf3ccd17 misra: implement rule 22.5 2021-07-07 23:00:12 +02:00
Daniel Marjamäki 13d55c7060 misra; implement rule 2.3 2021-07-07 15:16:53 +02:00
Daniel Marjamäki 00a9671f46 misra: implement 8.1 2021-07-07 13:34:55 +02:00
Daniel Marjamäki 9172f2ab3b addons; add CTU infrastructure 2021-07-07 10:58:13 +02:00
Georgiy Komarov 6f389014f1
cppcheckdata: Fix crash on an empty union (#3326) 2021-07-06 17:01:58 +02:00
Georgiy Komarov b89f5fbeff
misra: Fix 8.2 false positives (#3309)
* misra: Fix 8.2 false positives

Fix false positives in rule 8.2 that occurred in cases when we have a
function definition and declaration in the same file.

For example, the following code generated false positives before this
commit:

```
void f(uint8_t * const x);
void f(uint8_t * const x)
{ (void)x; }
```

We need to distinguish the declaration and the definition, so the dump
file generation routine was extended to keep token where the definition
of the function. The analysis in the addon also been improved.

Closes Trac issue: https://trac.cppcheck.net/ticket/10219
2021-06-27 10:51:32 +02:00
Daniel Marjamäki 22727ee3ab Addons; split up possible/known values and impossible values. This is inconsistent with core Cppcheck, however the addons do not handle impossible values in general. A future improvement might be to clarify this somehow, maybe renaming Token.values. 2021-02-23 22:40:49 +01:00
Georgiy Komarov 35a42cd0fe
cppcheckdata: Make the source files for configuration public (#3030)
Extend CppcheckData class API to make the list of source files public.
This can be used by custom addons.
2021-01-08 22:59:58 +01:00
Georgiy Komarov 13b8ee8871
cppcheckdata: Use instance attributes in Cppcheckdata (#3029)
This commit makes CppcheckData class to use instance attributes instead
of class attributes.

Since class attributes are mutable (list), when you append to them, they
don't promote to instance variable which means when you call parsedump()
multiple times data just gets appended to them.

Found by samed on the forum:
https://sourceforge.net/p/cppcheck/discussion/general/thread/c6e1210ec2/
2021-01-08 10:25:51 +01:00
Daniel Marjamäki a810678b83 Addons: handle inline suppressions internally in cppcheckdata 2020-12-05 11:37:09 +01:00
Daniel Marjamäki 649a754cfd Revert "Addons: handle inline suppressions internally in cppcheckdata"
This reverts commit 1ce78a1086.

There was regressions in handling of suppressions.
2020-12-04 18:05:47 +01:00