GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — cppcheck/addons/cppcheckdata.py at main · cppcheck-opensource/cppcheck Expand file tree/ Copy pathcppcheckdata.pyMore file actions executable file ·1791 lines (1569 loc) · 59.9 KB / Copy pathcppcheckdata.pyFile metadata and controlsexecutable file ·1791 lines (1569 loc) · 59.9 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 """ cppcheckdata This is a Python module that helps you access Cppcheck dump data. License: No restrictions, use this as you need. """ import argparse import contextlib import functools import gc import json import mmap import os import sys import subprocess try: import pathlib except ImportError: message = "Failed to load pathlib. Upgrade Python to 3.x or install pathlib with 'pip install pathlib'." error_id = 'pythonError' if '--cli' in sys.argv: msg = { 'file': '', 'linenr': 0, 'column': 0, 'severity': 'error', 'message': message, 'addon': 'cppcheckdata', 'errorId': error_id, 'extra': ''} sys.stdout.write(json.dumps(msg) + '\n') else: sys.stderr.write('%s [%s]\n' % (message, error_id)) sys.exit(1) from xml.etree import ElementTree from fnmatch import fnmatch EXIT_CODE = 0 current_dumpfile_suppressions = [] # Size of the chunks that are fed to the XML parser _PARSE_CHUNK_SIZE = 1 << 16 _DUMP_START_TAG = b'<dump ' _DUMP_END_TAG = b'</dump>' @contextlib.contextmanager def _gc_disabled(): # Loading a dump file creates a lot of objects and none of them become # garbage. The cyclic garbage collector would traverse them again and # again, which takes about half of the loading time. enabled = gc.isenabled() gc.disable() try: yield finally: if enabled: gc.enable() def _feed_without_configurations(parser, filename): """ Feed the dump file to the parser, except for the <dump> elements. The configurations are most of the file, and skipping them avoids parsing the whole file to get the data that is written after them. A '<' in attribute values is escaped, so the tags are found with a plain search. """ with open(filename, 'rb') as f: if os.fstat(f.fileno()).st_size == 0: return with mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) as data: first = data.find(_DUMP_START_TAG) last = data.rfind(_DUMP_END_TAG) if first < 0 or last < first: parser.feed(data[:]) else: parser.feed(data[:first]) parser.feed(data[last + len(_DUMP_END_TAG):]) def _load_location(location, element): """Load location from element/dict""" location.file = element.get('file') line = element.get('line') if line is None: line = element.get('linenr') if line is None: line = '0' location.linenr = int(line) location.column = int(element.get('column', '0')) class Location: """Utility location class""" file = None linenr = None column = None def __init__(self, element): _load_location(self, element) class Directive: """ Directive class. Contains information about each preprocessor directive in the source code. Attributes: str The directive line, with all C or C++ comments removed file Name of (possibly included) file where directive is defined linenr Line number in (possibly included) file where directive is defined To iterate through all directives use such code: @code data = cppcheckdata.parsedump(...) for cfg in data.configurations: for directive in cfg.directives: print(directive.str) @endcode """ #preprocessor.cpp/Preprocessor::dump str = None file = None linenr = None column = None def __init__(self, element): self.str = element.get('str') _load_location(self, element) def __repr__(self): attrs = ["str", "file", "linenr"] return "{}({})".format( "Directive", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class MacroUsage: """ Tracks preprocessor macro usage Attributes: name Name of the macro usefile useline usecolumn isKnownValue """ #preprocessor.cpp/Preprocessor::dump name = None # Macro name file = None linenr = None column = None usefile = None uselinenr = None usecolumn = None def __init__(self, element): self.name = element.get('name') _load_location(self, element) self.usefile = element.get('usefile') self.useline = element.get('useline') self.usecolumn = element.get('usecolumn') self.isKnownValue = element.get('is-known-value', 'false') == 'true' def __repr__(self): attrs = ["name", "file", "linenr", "column", "usefile", "useline", "usecolumn", "isKnownValue"] return "{}({})".format( "MacroUsage", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class PreprocessorIfCondition: """ Information about #if/#elif conditions Attributes: E result """ #preprocessor.cpp/Preprocessor::dump file = None linenr = None column = None E = None result = None def __init__(self, element): _load_location(self, element) self.E = element.get('E') self.result = int(element.get('result')) def __repr__(self): attrs = ["file", "linenr", "column", "E", "result"] return "{}({})".format( "PreprocessorIfCondition", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class ValueType: """ ValueType class. Contains (promoted) type information for each node in the AST. Attributes: type nonstd/pod/record/smart-pointer/container/iterator/void/bool/char/short/wchar_t/int/long/long long/unknown int/float/double/long double sign signed/unsigned bits bit count for bit-fields, otherwise None pointer constness reference typeScopeId originalTypeName bool/const char */long/char */size_t/int/double/std::string/.. """ #symboldatabase.cpp/ValueType::dump type = None sign = None bits = None constness = 0 pointer = 0 typeScopeId = None typeScope = None originalTypeName = None def __init__(self, element): self.type = element.get('valueType-type') self.sign = element.get('valueType-sign') self.bits = element.get('valueType-bits', None) self.bits = int(self.bits) if self.bits else None self.pointer = int(element.get('valueType-pointer', 0)) self.constness = int(element.get('valueType-constness', 0)) self.reference = element.get('valueType-reference') self.typeScopeId = element.get('valueType-typeScope') self.originalTypeName = element.get('valueType-originalTypeName') #valueType-containerId TODO add def __repr__(self): attrs = ["type", "sign", "bits", "typeScopeId", "originalTypeName", "constness", "pointer"] return "{}({})".format( "ValueType", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.typeScope = IdMap[self.typeScopeId] def isIntegral(self): return self.type in {'bool', 'char', 'short', 'int', 'long', 'long long'} def isFloat(self): return self.type in {'float', 'double', 'long double'} def isEnum(self): return self.typeScope and self.typeScope.type == "Enum" class Token: """ Token class. Contains information about each token in the source code. The CppcheckData.tokenlist is a list of Token items C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classToken.html Attributes: str Token string next Next token in tokenlist. For last token, next is None. previous Previous token in tokenlist. For first token, previous is None. link Linked token in tokenlist. Each '(', '[' and '{' are linked to the corresponding '}', ']' and ')'. For templates, the '<' is linked to the corresponding '>'. scope Scope information for this token. See the Scope class. type Type information: name/op/number/string/.. isName Is this token a symbol name isUnsigned Is this token a unsigned type isSigned Is this token a signed type isNumber Is this token a number, for example 123, 12.34 isInt Is this token a int value such as 1234 isFloat Is this token a float value such as 12.34 isString Is this token a string literal such as "hello" strlen string length for string literal isChar Is this token a char literal such as 'x' isBoolean Is this token a boolean isOp Is this token a operator isArithmeticalOp Is this token a arithmetic operator isAssignmentOp Is this token a assignment operator isComparisonOp Is this token a comparison operator isLogicalOp Is this token a logical operator: && || isCast externLang isExpandedMacro Is this token a expanded macro token macroName Macro name that this token is expanded from isRemovedVoidParameter Has void parameter been removed? isSplittedVarDeclComma Is this a comma changed to semicolon in a split variable declaration ('int a,b;' => 'int a; int b;') isSplittedVarDeclEq Is this a '=' changed to semicolon in a split variable declaration ('int a=5;' => 'int a; a=5;') isImplicitInt Is this token an implicit "int"? isComplex isRestrict isAttributeExport isAnonymous varId varId for token, each variable has a unique non-zero id exprId exprId for token, each expression has a unique non-zero id variable Variable information for this token. See the Variable class. function If this token points at a function call, this attribute has the Function information. See the Function class. values Possible/Known values of token typeScope type scope (token->type()->classScope) astParent ast parent astOperand1 ast operand1 astOperand2 ast operand2 orriginalName original name of the token valueType type information: container/.. file file name linenr line number column column To iterate through all tokens use such code: @code data = cppcheckdata.parsedump(...) for cfg in data.configurations: code = '' for token in cfg.tokenlist: code = code + token.str + ' ' print(code) @endcode """ #tokenize.cpp/Tokenizer::dump Id = None str = None next = None previous = None linkId = None link = None scopeId = None scope = None isName = False isNumber = False isInt = False isFloat = False isString = False strlen = None isChar = False isBoolean = False isOp = False isArithmeticalOp = False isAssignmentOp = False isComparisonOp = False isLogicalOp = False isCast = False isUnsigned = False isSigned = False macroName = None isExpandedMacro = False isRemovedVoidParameter = False isSplittedVarDeclComma = False isSplittedVarDeclEq = False isImplicitInt = False isComplex = False isRestrict = False isAttributeExport = False isAnonymous = False exprId = None varId = None variableId = None variable = None functionId = None function = None valuesId = None values = None impossible_values = None valueType = None typeScopeId = None typeScope = None type = None astParentId = None astParent = None astOperand1Id = None astOperand1 = None astOperand2Id = None astOperand2 = None file = None linenr = None column = None def __init__(self, element): self.Id = element.get('id') self.str = element.get('str') self.next = None self.previous = None self.scopeId = element.get('scope') self.scope = None self.type = element.get('type') if self.type == 'name': self.isName = True if element.get('isUnsigned'): self.isUnsigned = True if element.get('isSigned'): self.isSigned = True elif self.type == 'number': self.isNumber = True if element.get('isInt'): self.isInt = True elif element.get('isFloat'): self.isFloat = True elif self.type == 'string': self.isString = True self.strlen = int(element.get('strlen')) elif self.type == 'char': self.isChar = True elif self.type == 'boolean': self.isBoolean = True elif self.type == 'op': self.isOp = True if element.get('isArithmeticalOp'): self.isArithmeticalOp = True elif element.get('isAssignmentOp'): self.isAssignmentOp = True elif element.get('isComparisonOp'): self.isComparisonOp = True elif element.get('isLogicalOp'): self.isLogicalOp = True if element.get('isCast'): self.isCast = True self.externLang = element.get('externLang') self.macroName = element.get('macroName') if self.macroName or element.get('isExpandedMacro'): self.isExpandedMacro = True if element.get('isRemovedVoidParameter'): self.isRemovedVoidParameter = True if element.get('isSplittedVarDeclComma'): self.isSplittedVarDeclComma = True if element.get('isSplittedVarDeclEq'): self.isSplittedVarDeclEq = True if element.get('isImplicitInt'): self.isImplicitInt = True if element.get('isComplex'): self.isComplex = True if element.get('isRestrict'): self.isRestrict = True if element.get('isAttributeExport'): self.isAttributeExport = True if element.get('isAnonymous'): self.isAnonymous = True self.linkId = element.get('link') self.link = None if element.get('varId'): self.varId = int(element.get('varId')) if element.get('exprId'): self.exprId = int(element.get('exprId')) self.variableId = element.get('variable') self.variable = None self.functionId = element.get('function') self.function = None self.valuesId = element.get('values') self.values = None self.typeScopeId = element.get('type-scope') self.typeScope = None self.astParentId = element.get('astParent') self.astParent = None self.astOperand1Id = element.get('astOperand1') self.astOperand1 = None self.astOperand2Id = element.get('astOperand2') self.astOperand2 = None self.originalName = element.get('originalName') if element.get('valueType-type'): self.valueType = ValueType(element) else: self.valueType = None _load_location(self, element) def __repr__(self): attrs = ["Id", "str", "scopeId", "isName", "isUnsigned", "isSigned", "isNumber", "isInt", "isFloat", "isString", "strlen", "isChar", "isBoolean", "isOp", "isArithmeticalOp", "isAssignmentOp", "isComparisonOp", "isLogicalOp", "isCast", "externLang", "isExpandedMacro", "isRemovedVoidParameter", "isSplittedVarDeclComma", "isSplittedVarDeclEq", "isImplicitInt", "isComplex", "isRestrict", "isAttributeExport", "isAnonymous", "linkId", "varId", "variableId", "functionId", "valuesId", "valueType", "typeScopeId", "astParentId", "astOperand1Id", "file", "linenr", "column"] return "{}({})".format( "Token", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.scope = IdMap[self.scopeId] self.link = IdMap[self.linkId] self.variable = IdMap[self.variableId] self.function = IdMap[self.functionId] self.values = [] self.impossible_values = [] if IdMap[self.valuesId]: for v in IdMap[self.valuesId]: if v.isImpossible(): self.impossible_values.append(v) else: self.values.append(v) v.setId(IdMap) self.typeScope = IdMap[self.typeScopeId] self.astParent = IdMap[self.astParentId] self.astOperand1 = IdMap[self.astOperand1Id] self.astOperand2 = IdMap[self.astOperand2Id] if self.valueType: self.valueType.setId(IdMap) def getValue(self, v): """ Get value if it exists Returns None if it doesn't exist """ if not self.values: return None for value in self.values: if value.intvalue == v: return value return None def getKnownIntValue(self): """ If token has a known int value then return that. Otherwise returns None """ if not self.values: return None for value in self.values: if value.valueKind == 'known': return value.intvalue return None def isUnaryOp(self, op): return self.astOperand1 and (self.astOperand2 is None) and self.str == op def isBinaryOp(self): return self.astOperand1 and self.astOperand2 def forward(self, end=None): token = self while token and token != end: yield token token = token.next def backward(self, start=None): token = self while token and token != start: yield token token = token.previous def astParents(self): token = self while token and token.astParent: token = token.astParent yield token def astTop(self): top = None for parent in self.astParents(): top = parent return top def tokAt(self, n): tl = self.forward() if n < 0: tl = self.backward() n = -n for i, t in enumerate(tl): if i == n: return t return None def linkAt(self, n): token = self.tokAt(n) if token: return token.link return None class Scope: """ Scope. Information about global scope, function scopes, class scopes, inner scopes, etc. C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classScope.html Attributes bodyStart The { Token for this scope bodyEnd The } Token for this scope className Name of this scope. For a function scope, this is the function name; For a class scope, this is the class name. function If this scope belongs at a function call, this attribute has the Function information. See the Function class. functions if this is a Class type, it may have functions defined nestedIn type Type of scope: Function, If/Else/For/While/Switch/Global/Enum/Struct/Namespace/Class/Constructor/Destructor isExecutable True when the type is: Function/If/Else/For/While/Do/Switch/Try/Catch/Unconditional/Lambda definedType """ #symboldatabase.cpp/SymbolDatabase::printXml Id = None bodyStartId = None bodyStart = None bodyEndId = None bodyEnd = None className = None functionId = None function = None nestedInId = None nestedIn = None nestedList = None type = None isExecutable = None varlistId = None varlist = None def __init__(self, element): self.Id = element.get('id') self.className = element.get('className') self.functionId = element.get('function') self.function = None self.functions = [] self.bodyStartId = element.get('bodyStart') self.bodyStart = None self.bodyEndId = element.get('bodyEnd') self.bodyEnd = None self.nestedInId = element.get('nestedIn') self.nestedIn = None self.nestedList = [] self.type = element.get('type') self.definedType = element.get('definedType') self.isExecutable = (self.type in ('Function', 'If', 'Else', 'For', 'While', 'Do', 'Switch', 'Try', 'Catch', 'Unconditional', 'Lambda')) self.varlistId = [] self.varlist = [] def __repr__(self): attrs = ["Id", "className", "functionId", "bodyStartId", "bodyEndId", "nestedInId", "nestedIn", "type", "definedType", "isExecutable", "functions"] return "{}({})".format( "Scope", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.bodyStart = IdMap[self.bodyStartId] self.bodyEnd = IdMap[self.bodyEndId] self.nestedIn = IdMap[self.nestedInId] if self.nestedIn: self.nestedIn.nestedList.append(self) self.function = IdMap[self.functionId] for v in self.varlistId: value = IdMap.get(v) if value: self.varlist.append(value) class Function: """ Information about a function C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classFunction.html Attributes argument Argument list (dict of argument number and variable) token Token in function implementation tokenDef Token in function definition name type Constructor/CopyConstructor/MoveConstructor/OperatorEqual/Destructor/Function/Lambda/Unknown hasVirtualSpecifier Is this function is virtual isImplicitlyVirtual Is this function is virtual this in the base classes access Public/Protected/Private isInlineKeyword Is inline keyword used isStatic Is this function static isAttributeNoreturn overriddenFunction """ #symboldatabase.cpp/SymbolDatabase::printXml Id = None argument = None argumentId = None token = None tokenId = None tokenDef = None tokenDefId = None name = None type = None access = None isImplicitlyVirtual = None hasVirtualSpecifier = None isInlineKeyword = None isStatic = None isAttributeNoreturn = None overriddenFunction = None nestedIn = None def __init__(self, element, nestedIn): self.Id = element.get('id') self.tokenId = element.get('token') self.tokenDefId = element.get('tokenDef') self.name = element.get('name') self.type = element.get('type') self.hasVirtualSpecifier = element.get('hasVirtualSpecifier', 'false') == 'true' self.isImplicitlyVirtual = element.get('isImplicitlyVirtual', 'false') == 'true' self.access = element.get('access') self.isInlineKeyword = element.get('isInlineKeyword', 'false') == 'true' self.isStatic = element.get('isStatic', 'false') == 'true' self.isAttributeNoreturn = element.get('isAttributeNoreturn', 'false') == 'true' self.overriddenFunction = element.get('overriddenFunction', 'false') == 'true' self.nestedIn = nestedIn self.argument = {} self.argumentId = {} def __repr__(self): attrs = ["Id", "tokenId", "tokenDefId", "name", "type", "hasVirtualSpecifier", "isImplicitlyVirtual", "access", "isInlineKeyword", "isStatic", "isAttributeNoreturn", "overriddenFunction", "nestedIn", "argumentId"] return "{}({})".format( "Function", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): for argnr, argid in self.argumentId.items(): self.argument[argnr] = IdMap[argid] self.token = IdMap.get(self.tokenId, None) self.tokenDef = IdMap[self.tokenDefId] #todo add class Types: #symboldatabase.cpp/SymbolDatabase::printXml class Variable: """ Information about a variable C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classVariable.html Attributes: nameToken Name token in variable declaration typeStartToken Start token of variable declaration typeEndToken End token of variable declaration access Global/Local/Namespace/Public/Protected/Public/Throw/Argument/Unknown scope Variable scope constness Variable constness (same encoding as ValueType::constness) isArgument Is this variable a function argument? isGlobal Is this variable a global variable? isLocal Is this variable a local variable? isArray Is this variable an array? isClass Is this variable a class or struct? isConst Is this variable a const variable? isExtern Is this variable an extern variable? isPointer Is this variable a pointer isReference Is this variable a reference isStatic Is this variable static? isVolatile Is this variable volatile? """ #symboldatabase.cpp/SymbolDatabase::printXml Id = None nameTokenId = None nameToken = None typeStartTokenId = None typeStartToken = None typeEndTokenId = None typeEndToken = None access = None scopeId = None scope = None isArgument = False isArray = False isClass = False isConst = False isExtern = False isGlobal = False isLocal = False isPointer = False isReference = False isStatic = False isVolatile = False constness = 0 def __init__(self, element): self.Id = element.get('id') self.nameTokenId = element.get('nameToken') self.nameToken = None self.typeStartTokenId = element.get('typeStartToken') self.typeStartToken = None self.typeEndTokenId = element.get('typeEndToken') self.typeEndToken = None self.access = element.get('access') self.isArgument = (self.access and self.access == 'Argument') self.isGlobal = (self.access and self.access == 'Global') self.isLocal = (self.access and self.access == 'Local') self.scopeId = element.get('scope') self.scope = None self.constness = int(element.get('constness',0)) self.isArray = element.get('isArray') == 'true' self.isClass = element.get('isClass') == 'true' self.isConst = element.get('isConst') == 'true' self.isExtern = element.get('isExtern') == 'true' self.isPointer = element.get('isPointer') == 'true' self.isReference = element.get('isReference') == 'true' self.isStatic = element.get('isStatic') == 'true' self.isVolatile = element.get('isVolatile') == 'true' def __repr__(self): attrs = ["Id", "nameTokenId", "typeStartTokenId", "typeEndTokenId", "access", "scopeId", "isArgument", "isArray", "isClass", "isConst", "isGlobal", "isExtern", "isLocal", "isPointer", "isReference", "isStatic", "isVolatile", "constness"] return "{}({})".format( "Variable", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) def setId(self, IdMap): self.nameToken = IdMap[self.nameTokenId] self.typeStartToken = IdMap[self.typeStartTokenId] self.typeEndToken = IdMap[self.typeEndTokenId] self.scope = IdMap[self.scopeId] class Container: """ Container class -- information about containers Attributes: array-like-index-op true/false stdStringLike true/false """ #tokenizer.cpp/tokenizer::dump Id = None def __init__(self, element): self.Id = element.get('id') self.arrayLikeIndexOp = element.get('array-like-index-op') == 'true' self.stdStringLike = element.get('std-string-like') == 'true' class TypedefInfo: """ TypedefInfo class -- information about typedefs Attributes: name name of the typedef used 0/1 """ #tokenizer.cpp/tokenizer::dump name = None used = None file = None linenr = None column = None def __init__(self, element): self.name = element.get('name') _load_location(self, element) self.used = (element.get('used') == '1') class Value: """ Value class Attributes: intvalue integer value tokvalue token value floatvalue float value movedvalue uninit containerSize container size bufferSize buffer size lifetimeScope Local/Argument/SubFunction/ThisPointer/ThisValue lifetimeKind Object/SubObject/Lambda/Iterator/Address symbolicDelta condition condition where this Value comes from bound Upper/Lower/Point valueKind known/possible/impossible/inconclusive path 0/1/2/3/.. """ #token.cpp/token::printValueFlow intvalue = None tokvalue = None floatvalue = None containerSize = None condition = None valueKind = None def isKnown(self): return self.valueKind and self.valueKind == 'known' def isPossible(self): return self.valueKind and self.valueKind == 'possible' def isImpossible(self): return self.valueKind and self.valueKind == 'impossible' def isInconclusive(self): return self.valueKind and self.valueKind == 'inconclusive' def __init__(self, element): self.intvalue = element.get('intvalue') if self.intvalue: self.intvalue = int(self.intvalue) self._tokvalueId = element.get('tokvalue') self.floatvalue = element.get('floatvalue') self.movedvalue = element.get('movedvalue') self.uninit = element.get('uninit') self.bufferSize = element.get('buffer-size') self.containerSize = element.get('container-size') self.iteratorStart = element.get('iterator-start') self.iteratorEnd = element.get('iterator-end') self._lifetimeId = element.get('lifetime') self.lifetimeScope = element.get('lifetime-scope') self.lifetimeKind = element.get('lifetime-kind') self._symbolicId = element.get('symbolic') self.symbolicDelta = element.get('symbolic-delta') self.bound = element.get('bound') self.condition = element.get('condition-line') if self.condition: self.condition = int(self.condition) if element.get('known'): self.valueKind = 'known' elif element.get('possible'): self.valueKind = 'possible' elif element.get('impossible'): self.valueKind = 'impossible' elif element.get('inconclusive'): self.valueKind = 'inconclusive' self.path = element.get('path') def setId(self, IdMap): self.tokvalue = IdMap.get(self._tokvalueId) self.lifetime = IdMap.get(self._lifetimeId) self.symbolic = IdMap.get(self._symbolicId) def __repr__(self): attrs = ["intvalue", "tokvalue", "floatvalue", "movedvalue", "uninit", "bufferSize", "containerSize", "condition", "valueKind"] return "{}({})".format( "Value", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class ValueFlow: """ ValueFlow::Value class Each possible value has a ValueFlow::Value item. Each ValueFlow::Value either has a intvalue or tokvalue C++ class: https://cppcheck.sourceforge.io/devinfo/doxyoutput/classValueFlow_1_1Value.html Attributes: values Possible values """ Id = None values = None def __init__(self, element): self.Id = element.get('id') self.values = [] def __repr__(self): attrs = ["Id", "values"] return "{}({})".format( "ValueFlow", ", ".join(("{}={}".format(a, repr(getattr(self, a))) for a in attrs)) ) class Suppression: """ Suppression class This class contains a suppression entry to suppress a warning. Attributes errorId The id string of the error to suppress, can be a wildcard fileName The name of the file to suppress warnings for, can include wildcards lineNumber The number of the line to suppress warnings from, can be 0 to represent any line symbolName The name of the symbol to match warnings for, can include wildcards |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |