[
  {
    "path": ".gitignore",
    "content": "*~\n.*.sw[a-z]\n*.o\n*.so\na.out\n*.pyc\ntest.png\n\n# Generated during configuration:\nconfig-tests\n\n# Generated elsewhere in build:\nautogenerated*\ngcc-c-api/gcc-public-types.h\ngcc-c-api/gcc-semiprivate-types.h\ngcc-c-api/gcc-callgraph.h\ngcc-c-api/gcc-cfg.h\ngcc-c-api/gcc-constant.h\ngcc-c-api/gcc-declaration.h\ngcc-c-api/gcc-diagnostics.h\ngcc-c-api/gcc-function.h\ngcc-c-api/gcc-gimple.h\ngcc-c-api/gcc-location.h\ngcc-c-api/gcc-option.h\ngcc-c-api/gcc-rtl.h\ngcc-c-api/gcc-tree.h\ngcc-c-api/gcc-type.h\ngcc-c-api/gcc-variable.h\ngcc-with-python.1.gz\nprint-gcc-version\n\n# Generated by Sphinx\ndocs/_build\n\n# Logfiles generated during the selftest suite:\n*.c.cpychecker-log.txt\n*.*-refcount-errors.html\n*.*-refcount-errors.v2.html\n*.*-refcount-traces.html\ntests/plugin/dumpfiles/input.c.*t.test-pass\npygments_c.css\n"
  },
  {
    "path": ".travis.yml",
    "content": "matrix:\n  include:\n    - os: linux\n      addons:\n        apt:\n          sources:\n            - ubuntu-toolchain-r-test\n          packages:\n            - g++-4.8 gcc-4.8-plugin-dev\n      env:\n         - MATRIX_EVAL=\"CC=gcc-4.8 && CXX=g++-4.8\"\n\n    # works on Precise and Trusty\n    - os: linux\n      addons:\n        apt:\n          sources:\n            - ubuntu-toolchain-r-test\n          packages:\n            - g++-4.9 gcc-4.9-plugin-dev\n      env:\n         - MATRIX_EVAL=\"CC=gcc-4.9 && CXX=g++-4.9\"\n\n    # works on Precise and Trusty\n    - os: linux\n      addons:\n        apt:\n          sources:\n            - ubuntu-toolchain-r-test\n          packages:\n            - g++-5 gcc-5-plugin-dev\n      env:\n         - MATRIX_EVAL=\"CC=gcc-5 && CXX=g++-5\"\n\n    # works on Precise and Trusty\n    - os: linux\n      addons:\n        apt:\n          sources:\n            - ubuntu-toolchain-r-test\n          packages:\n            - g++-6 gcc-6-plugin-dev\n      env:\n        - MATRIX_EVAL=\"CC=gcc-6 && CXX=g++-6\"\n\n    # works on Precise and Trusty\n    - os: linux\n      addons:\n        apt:\n          sources:\n            - ubuntu-toolchain-r-test\n          packages:\n            - g++-7 gcc-7-plugin-dev\n      env:\n        - MATRIX_EVAL=\"CC=gcc-7 && CXX=g++-7\"\n\n    - os: linux\n      addons:\n        apt:\n          sources:\n            - ubuntu-toolchain-r-test\n          packages:\n            - g++-8 gcc-8-plugin-dev\n      env:\n        - MATRIX_EVAL=\"CC=gcc-8 && CXX=g++-8\"\n\n    - os: linux\n      addons:\n        apt:\n          sources:\n            - ubuntu-toolchain-r-test\n          packages:\n            - g++-9 gcc-9-plugin-dev\n      env:\n        - MATRIX_EVAL=\"CC=gcc-9 && CXX=g++-9\"\n\nlanguage: c\ncompiler:\n  - gcc\n\nbefore_install:\n  - eval \"${MATRIX_EVAL}\"\n  - sudo apt-get update -qq\n  - sudo apt-get install -qq python-six python-pygments graphviz python-lxml\n\nscript:\n- pwd=$(pwd -P)\n- mkdir build\n- cd build\n- make -f $pwd/Makefile srcdir=$pwd/\n"
  },
  {
    "path": "COPYING",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<http://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<http://www.gnu.org/philosophy/why-not-lgpl.html>.\n"
  },
  {
    "path": "LICENSES.txt",
    "content": "The C and Python code is licensed under the GPLv3 or later (see COPYING and the\nper-file license information).\n\nThere are copies of various JavaScript and CSS libraries embedded within the\nsource tree, which have their own licenses as follows:\n\n  libcpychecker_html/extlib/jquery-1.7.1.min.js:\n     jquery.org/license (MIT or GPLv2)\n\n  libcpychecker_html/extlib/prefixfree-1.0.4.min.js:\n     MIT license\n\n  libcpychecker_html/extlib/reset-20110126.css:\n     Public Domain\n\nThere are also various images within:\n   libcpychecke_/html/images\nThese were taken from:\n  http://code.google.com/p/fugue-icons-src/\nand are:\n  \"© 2012 Yusuke Kamiyamane. All rights reserved.\n  These icons are available under a Creative Commons Attribution 3.0\n  License. \"\n     http://creativecommons.org/licenses/by/3.0/\n\nThe test code contains historical examples of reference-count bugs:\n\n  * libcpychecker_html/test/example2\n      contains an embedded copy of part of an old version of pylibmc, which\n      is under a 3-clause BSD license\n"
  },
  {
    "path": "Makefile",
    "content": "#   Copyright 2011-2013, 2017 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011-2013, 2017 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nifneq ($(srcdir),)\nVPATH = $(srcdir)\nendif\nxmldir = $(srcdir)./gcc-c-api/\npwd = $(shell pwd -P)\n\n.PHONY: all clean debug dump_gimple plugin show-ssa tarball \\\n\ttest-suite testcpychecker testcpybuilder testdejagnu \\\n\tman\n\nPLUGIN_SOURCE_FILES= \\\n  gcc-python.c \\\n  gcc-python-attribute.c \\\n  gcc-python-callbacks.c \\\n  gcc-python-callgraph.c \\\n  gcc-python-cfg.c \\\n  gcc-python-closure.c \\\n  gcc-python-diagnostics.c \\\n  gcc-python-function.c \\\n  gcc-python-gimple.c \\\n  gcc-python-location.c \\\n  gcc-python-option.c \\\n  gcc-python-parameter.c \\\n  gcc-python-pass.c \\\n  gcc-python-pretty-printer.c \\\n  gcc-python-rtl.c \\\n  gcc-python-tree.c \\\n  gcc-python-variable.c \\\n  gcc-python-version.c \\\n  gcc-python-wrapper.c \\\n\nPLUGIN_GENERATED_SOURCE_FILES:= \\\n  autogenerated-callgraph.c \\\n  autogenerated-casts.c \\\n  autogenerated-cfg.c \\\n  autogenerated-option.c \\\n  autogenerated-function.c \\\n  autogenerated-gimple.c \\\n  autogenerated-location.c \\\n  autogenerated-parameter.c \\\n  autogenerated-pass.c \\\n  autogenerated-pretty-printer.c \\\n  autogenerated-rtl.c \\\n  autogenerated-tree.c \\\n  autogenerated-variable.c\n\nPLUGIN_OBJECT_SOURCE_FILES:= $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))\nPLUGIN_OBJECT_GENERATED_FILES:= $(patsubst %.c,%.o,$(PLUGIN_GENERATED_SOURCE_FILES))\nPLUGIN_OBJECT_FILES:= $(PLUGIN_OBJECT_SOURCE_FILES) $(PLUGIN_OBJECT_GENERATED_FILES)\nGCCPLUGINS_DIR:= $(shell $(CC) --print-file-name=plugin)\n\nGENERATOR_DEPS=cpybuilder.py wrapperbuilder.py print-gcc-version\n\n# The plugin supports both Python 2 and Python 3\n#\n# In theory we could have arbitrary combinations of python versions for each\n# of:\n#   - python version used when running scripts during the build (e.g. to\n#     generate code)\n#   - python version we compile and link the plugin against\n#   - when running the plugin with the cpychecker script, the python version\n#     that the code is being compiled against\n#\n# However, to keep things simple, let's assume for now that all of these are\n# the same version: we're building the plugin using the same version of Python\n# as we're linking against, and that the cpychecker will be testing that same\n# version of Python\n#\n# By default, build against \"python\", using \"python-config\" to query for\n# compilation options.  You can override this by passing other values for\n# PYTHON and PYTHON_CONFIG when invoking \"make\" (or by simply hacking up this\n# file): e.g.\n#    make  PYTHON=python3  PYTHON_CONFIG=python3-config  all\n\n# The python interpreter to use:\nPYTHON=python\n# The python-config executable to use:\nPYTHON_CONFIG=python-config\n\n#PYTHON=python3\n#PYTHON_CONFIG=python3-config\n\n#PYTHON=python-debug\n#PYTHON_CONFIG=python-debug-config\n\n#PYTHON=python3-debug\n#PYTHON_CONFIG=python3.3dm-config\n\nPYTHON_INCLUDES=$(shell $(PYTHON_CONFIG) --includes)\nPYTHON_LIBS=$(shell $(PYTHON) -c 'import sys;print(\"-lpython%d.%d\" % sys.version_info[:2])') $(shell $(PYTHON_CONFIG) --libs)\n\n# Support having multiple named plugins\n# e.g. \"python2.7\" \"python3.2mu\" \"python 3.2dmu\" etc:\nPLUGIN_NAME := python\nPLUGIN_DSO := $(PLUGIN_NAME).so\nPLUGIN_DIR := $(PLUGIN_NAME)\n\n# For now, gcc-c-api is part of this project\n# (Eventually it will be moved to its own project)\nLIBGCC_C_API_SO\t:= gcc-c-api/libgcc-c-api.so\n\nCPPFLAGS+= -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I. $(PYTHON_INCLUDES)\n# Allow user to pick optimization, choose whether warnings are fatal,\n# and choose debugging information level.\nCFLAGS?=-O2 -Werror -g\n# Force these settings\nCFLAGS+= -fPIC -fno-strict-aliasing -Wall\nLIBS+= $(PYTHON_LIBS)\nifneq \"$(PLUGIN_PYTHONPATH)\" \"\"\n  CPPFLAGS+= -DPLUGIN_PYTHONPATH='\"$(PLUGIN_PYTHONPATH)\"'\nendif\n\nall: autogenerated-config.h testcpybuilder testdejagnu test-suite testcpychecker\n\n# What still needs to be wrapped?\napi-report:\n\tgrep -nH -e \"\\.inner\" gcc-*.c *.h generate-*.py\n\nplugin: autogenerated-config.h $(PLUGIN_DSO)\n\n# When running the plugin from a working copy, use LD_LIBARY_PATH=gcc-c-api\n# so that the plugin can find its libgcc-c-api.so there\n#\nINVOCATION_ENV_VARS := PYTHONPATH=$(srcdir)./ CC_FOR_CPYCHECKER=$(CC) LD_LIBRARY_PATH=gcc-c-api:$(LD_LIBRARY_PATH) CC=$(CC)\n\n# When installing, both the plugin and libgcc-c-api.so will be installed to\n# $(GCCPLUGINS_DIR), so we give the plugin an RPATH of $(GCCPLUGINS_DIR)\n# so that it finds the libgcc-c-api.so there (to support the case of having\n# multiple GCCs installed)\n#\n$(PLUGIN_DSO): $(PLUGIN_OBJECT_FILES) $(LIBGCC_C_API_SO)\n\t$(CC) \\\n\t    $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \\\n\t    -shared \\\n\t    $(PLUGIN_OBJECT_FILES) \\\n\t    -o $@ \\\n\t    $(LIBS) \\\n\t    -lgcc-c-api -Lgcc-c-api -Wl,-rpath=$(GCCPLUGINS_DIR)\n\n$(pwd)/gcc-c-api:\n\tmkdir -p $@\n\n$(LIBGCC_C_API_SO): $(pwd)/gcc-c-api\n\tcd gcc-c-api && make $(if $(srcdir),-f $(srcdir)./gcc-c-api/Makefile) libgcc-c-api.so CC=$(CC) $(if $(srcdir),srcdir=$(srcdir)./gcc-c-api/)\n\n$(PLUGIN_OBJECT_GENERATED_FILES): CPPFLAGS+= $(if $(srcdir),-I$(srcdir))\n\n# This is the standard .c->.o recipe, but it needs to be stated\n# explicitly to support the case that $(srcdir) is not blank.\n$(PLUGIN_OBJECT_FILES): %.o: %.c autogenerated-config.h gcc-python.h $(LIBGCC_C_API_SO) autogenerated-EXTRA_CFLAGS.txt\n\t$(COMPILE.c) $(shell cat autogenerated-EXTRA_CFLAGS.txt) $(OUTPUT_OPTION) -I$(srcdir)./ -I$(srcdir)./gcc-c-api -I./gcc-c-api $<\n\nprint-gcc-version: print-gcc-version.c autogenerated-EXTRA_CFLAGS.txt\n\t$(CC) \\\n\t\t$(CPPFLAGS) $(CFLAGS) \\\n\t\t$(shell cat autogenerated-EXTRA_CFLAGS.txt) \\\n\t\t-o $@ \\\n\t\t$<\n\nclean:\n\t$(RM) *.so *.o gcc-c-api/*.o autogenerated*\n\t$(RM) -r docs/_build\n\t$(RM) -f gcc-with-$(PLUGIN_NAME).1 gcc-with-$(PLUGIN_NAME).1.gz\n\t$(RM) -f print-gcc-version\n\tcd gcc-c-api && make clean\n\tfind tests -name \"*.o\" -delete\n\nautogenerated-config.h: generate-config-h.py configbuilder.py\n\t$(PYTHON) $< -o $@ --gcc=\"$(CC)\" --plugindir=\"$(GCCPLUGINS_DIR)\"\n\nautogenerated-%.txt: %.txt.in\n\t$(CPP) $(CPPFLAGS) -x c-header $^ -o $@\n\n# autogenerated-EXTRA_CFLAGS.txt is a byproduct of making\n# autogenerated-config.h:\nautogenerated-EXTRA_CFLAGS.txt: autogenerated-config.h\n\n# autogenerated-casts.h is a byproduct of making autogenerated-casts.c\nautogenerated-casts.h: autogenerated-casts.c\n\n$(PLUGIN_GENERATED_SOURCE_FILES): autogenerated-%.c: generate-%-c.py $(GENERATOR_DEPS)\n\t$(PYTHON) $< > $@\n\nautogenerated-casts.c:  autogenerated-gimple-types.txt autogenerated-tree-types.txt autogenerated-rtl-types.txt generate-casts-c.py\n\tPYTHONPATH=$(srcdir)./gcc-c-api\t$(PYTHON) $(srcdir)generate-casts-c.py autogenerated-casts.c autogenerated-casts.h $(xmldir)\n\nautogenerated-gimple.c: autogenerated-gimple-types.txt autogenerated-tree-types.txt autogenerated-rtl-types.txt maketreetypes.py\nautogenerated-tree.c: autogenerated-tree-types.txt maketreetypes.py\nautogenerated-rtl.c: autogenerated-rtl-types.txt maketreetypes.py\nautogenerated-variable.c: autogenerated-gimple-types.txt maketreetypes.py\n\nbindir=/usr/bin\nmandir=/usr/share/man\n\nUpperPluginName = $(shell $(PYTHON) -c\"print('$(PLUGIN_NAME)'.upper())\")\n\ndocs/_build/man/gcc-with-python.1: docs/gcc-with-python.rst\n\tcd docs && $(MAKE) man\n\ngcc-with-$(PLUGIN_NAME).1: docs/_build/man/gcc-with-python.1\n\t# Fixup the generic manpage for this build:\n\tcp docs/_build/man/gcc-with-python.1 gcc-with-$(PLUGIN_NAME).1\n\tsed \\\n\t   -i \\\n\t   -e\"s|gcc-with-python|gcc-with-$(PLUGIN_NAME)|g\" \\\n\t   gcc-with-$(PLUGIN_NAME).1\n\tsed \\\n\t   -i \\\n\t   -e\"s|GCC-WITH-PYTHON|GCC-WITH-$(UpperPluginName)|g\" \\\n\t   gcc-with-$(PLUGIN_NAME).1\n\ngcc-with-$(PLUGIN_NAME).1.gz: gcc-with-$(PLUGIN_NAME).1\n\trm -f gcc-with-$(PLUGIN_NAME).1.gz\n\tgzip gcc-with-$(PLUGIN_NAME).1\n\nman: gcc-with-$(PLUGIN_NAME).1.gz\n\ninstall: $(PLUGIN_DSO) gcc-with-$(PLUGIN_NAME).1.gz\n\tmkdir -p $(DESTDIR)$(GCCPLUGINS_DIR)\n\n\tcd gcc-c-api && $(MAKE) install\n\n\tcp $(PLUGIN_DSO) $(DESTDIR)$(GCCPLUGINS_DIR)\n\n\tmkdir -p $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR)\n\tcp -a gccutils $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR)\n\tcp -a libcpychecker $(DESTDIR)$(GCCPLUGINS_DIR)/$(PLUGIN_DIR)\n\n\t# Create \"gcc-with-\" support script:\n\tmkdir -p $(DESTDIR)$(bindir)\n\tinstall -m 755 gcc-with-python $(DESTDIR)/$(bindir)/gcc-with-$(PLUGIN_NAME)\n\t# Fixup the reference to the plugin in that script, from being expressed as\n\t# a DSO filename with a path (for a working copy) to a name of an installed\n\t# plugin within GCC's search directory:\n\tsed \\\n\t    -i \\\n\t    -e\"s|-fplugin=[^ ]*|-fplugin=$(PLUGIN_NAME)|\" \\\n\t    $(DESTDIR)$(bindir)/gcc-with-$(PLUGIN_NAME)\n\n        # Fixup the plugin name within -fplugin-arg-PLUGIN_NAME-script to match the\n\t# name for this specific build:\n\tsed \\\n\t   -i \\\n\t   -e\"s|-fplugin-arg-python-script|-fplugin-arg-$(PLUGIN_NAME)-script|\" \\\n\t   $(DESTDIR)$(bindir)/gcc-with-$(PLUGIN_NAME)\n\n\tmkdir -p $(DESTDIR)$(mandir)/man1\n\tcp gcc-with-$(PLUGIN_NAME).1.gz $(DESTDIR)$(mandir)/man1\n\n\n# Hint for debugging: add -v to the gcc options \n# to get a command line for invoking individual subprocesses\n# Doing so seems to require that paths be absolute, rather than relative\n# to this directory\nTEST_CFLAGS= \\\n  -fplugin=$(CURDIR)/$(PLUGIN_DSO) \\\n  -fplugin-arg-python-script=test.py\n\n# A catch-all test for quick experimentation with the API:\ntest: plugin\n\t$(INVOCATION_ENV_VARS) $(CC) -v $(TEST_CFLAGS) $(CURDIR)/test.c\n\n# Selftest for the cpychecker.py code:\ntestcpychecker: plugin\n\t$(INVOCATION_ENV_VARS) $(PYTHON) $(srcdir)./testcpychecker.py -v\n\n# Selftest for the cpybuilder code:\ntestcpybuilder:\n\t$(PYTHON) $(srcdir)./testcpybuilder.py -v\n\n# Selftest for the dejagnu.py code:\ntestdejagnu:\n\t$(PYTHON) $(srcdir)./dejagnu.py -v\n\ndump_gimple:\n\t$(CC) -fdump-tree-gimple $(CURDIR)/test.c\n\ndebug: plugin\n\t$(INVOCATION_ENV_VARS) $(CC) -v $(TEST_CFLAGS) $(CURDIR)/test.c\n\n$(pwd)/gcc-with-cpychecker: gcc-with-cpychecker\n\tcp $< $@\n\n# A simple demo, to make it easy to demonstrate the cpychecker:\ndemo: demo.c plugin $(pwd)/gcc-with-cpychecker\n\t$(INVOCATION_ENV_VARS) ./gcc-with-cpychecker -c $(PYTHON_INCLUDES) $<\n\n# Run 'demo', and verify the output.\ntestdemo: DEMO_REF=$(shell \\\n\tif [ $$(./print-gcc-version) -ge 7000 ]; then \\\n\t\techo demo.expected.no-refcounts; \\\n\telse \\\n\t\techo demo.expected; \\\n\tfi)\ntestdemo: plugin print-gcc-version\n\t$(MAKE) -f $(srcdir)./Makefile demo > demo.out 2> demo.err\n\tegrep '^.*demo.c:( In function |[0-9][0-9]*:[0-9][0-9]*: warning:)' \\\n\t  demo.err \\\n\t  | sed 's/:[0-9][0-9]*: warning:/:: warning:/;s/ \\[enabled by default\\]//' \\\n\t  | sed \"s%$(srcdir)demo.c:%demo.c:%g\" \\\n\t  > demo.filtered\n\tdiff $(srcdir)./$(DEMO_REF) demo.filtered\n\trm demo.out demo.err demo.filtered\n\njson-examples: plugin\n\t$(INVOCATION_ENV_VARS) $(srcdir)./gcc-with-cpychecker -I/usr/include/python2.7 -c libcpychecker_html/test/example1/bug.c\n\ntest-suite: plugin print-gcc-version testdejagnu testdemo\n\t$(INVOCATION_ENV_VARS) $(PYTHON) $(srcdir)./run-test-suite.py $(if $(srcdir),--srcdir=$(srcdir))\n\nshow-ssa: plugin\n\t$(INVOCATION_ENV_VARS) $(srcdir)./gcc-with-python examples/show-ssa.py test.c\n\ndemo-show-lto-supergraph: plugin\n\t$(INVOCATION_ENV_VARS) $(srcdir)./gcc-with-python \\\n\t  examples/show-lto-supergraph.py \\\n\t  -flto \\\n\t  -flto-partition=none \\\n\t  tests/examples/lto/input-*.c\n\nhtml: docs/tables-of-passes.rst docs/passes.svg\n\tcd docs && $(MAKE) html\n\n# We commit this generated file to SCM to allow the docs to be built without\n# needing to build the plugin:\ndocs/tables-of-passes.rst: plugin generate-tables-of-passes-rst.py\n\t$(INVOCATION_ENV_VARS) $(srcdir)./gcc-with-python generate-tables-of-passes-rst.py test.c > $@\n\n# Likewise for this generated file:\ndocs/passes.svg: plugin generate-passes-svg.py\n\t$(INVOCATION_ENV_VARS) $(srcdir)./gcc-with-python generate-passes-svg.py test.c\n\ncheck-api:\n\txmllint --noout --relaxng $(srcdir)./gcc-c-api/api.rng $(srcdir)./gcc-c-api/*.xml\n\n# Utility target, to help me to make releases\n#   - creates a tag in git (but does not push it; see \"Notes to self on\n#     making a release\" below)\n#   - creates a tarball\n#\n# The following assumes that VERSION has been set e.g.\n#   $ make tarball VERSION=0.4\n\n$(HOME)/rpmbuild/SOURCES/%.tar.gz:\n\ttest -n \"$(VERSION)\"\n\t-git tag -d v$(VERSION)\n\tgit tag -a v$(VERSION) -m\"$(VERSION)\"\n\tgit archive --format=tar --prefix=$*/ v$(VERSION) | gzip > $*.tar.gz\n\tsha256sum $*.tar.gz\n\tcp $*.tar.gz $@\n\ntarball: $(HOME)/rpmbuild/SOURCES/gcc-python-plugin-$(VERSION).tar.gz\n\n# Notes to self on making a release\n# ---------------------------------\n#\n#  Before tagging:\n#\n#     * update the version/release in docs/conf.py\n#\n#     * update the version in gcc-python-plugin.spec\n#\n#     * add release notes to docs\n#\n#  Test the candidate tarball via a scratch SRPM build locally (this\n#  achieves test coverage against python 2 and 3, for both debug and\n#  optimized python, on one arch, against the locally-installed version of\n#  gcc):\n#\n#     $ make srpm VERSION=fixme\n#\n#     $ make rpm VERSION=fixme\n#\n#  Test the candidate tarball via a scratch SRPM build in Koji (this\n#  achieves test coverage against python 2 and 3, for both debug and\n#  optimized python, on both i686 and x86_64, against another version of\n#  gcc):\n#\n#     $ make koji VERSION=fixme\n#\n#  After successful testing of a candidate tarball:\n#\n#   * push the tag:\n#\n#         $ git push --tags\n#\n#   * upload it to https://fedorahosted.org/releases/g/c/gcc-python-plugin/\n#    via:\n#\n#        $ scp gcc-python-plugin-$(VERSION).tar.gz dmalcolm@fedorahosted.org:gcc-python-plugin\n#\n#  * add version to Trac: https://fedorahosted.org/gcc-python-plugin/admin/ticket/versions\n#\n#  * update release info at https://fedorahosted.org/gcc-python-plugin/wiki#Code\n#\n#  * send release announcement:\n#\n#      To: gcc@gcc.gnu.org, gcc-python-plugin@lists.fedorahosted.org, python-announce-list@python.org\n#      Subject: ANN: gcc-python-plugin $(VERSION)\n#      (etc)\n#\n#  * build it into Fedora\n\n# Utility target, for building test rpms:\nsrpm:\n\trpmbuild -bs gcc-python-plugin.spec\n\n# Perform a test rpm build locally:\nrpm:\n\trpmbuild -ba gcc-python-plugin.spec\n\n# Perform a test (scratch) build in Koji:\n# The following have been deleted from Koji:\n#   f16 was gcc 4.6\n#   f17 was gcc 4.7\n#   f19 was gcc 4.8\nkoji-gcc-5: srpm\n\tkoji build --scratch f23 ~/rpmbuild/SRPMS/gcc-python-plugin-$(VERSION)-1.fc20.src.rpm\n\nkoji-gcc-6: srpm\n\tkoji build --scratch f24 ~/rpmbuild/SRPMS/gcc-python-plugin-$(VERSION)-1.fc20.src.rpm\n\nkoji: koji-gcc-5 koji-gcc-6\n"
  },
  {
    "path": "README.rst",
    "content": "gcc-python\n==========\n\nThis is a plugin for GCC, which links against libpython, and (I hope) allows\nyou to invoke arbitrary Python scripts from inside the compiler.  The aim is to\nallow you to write GCC plugins in Python.\n\nThe plugin is Free Software, licensed under the GPLv3 (or later).\n\nIt's still at the \"experimental proof-of-concept stage\"; expect crashes and\ntracebacks (I'm new to insides of GCC, and I may have misunderstood things).\n\nIt's already possible to use this to add additional compiler errors/warnings,\ne.g. domain-specific checks, or static analysis.  One of my goals for this is\nto \"teach\" GCC about the common mistakes people make when writing extensions\nfor CPython, but it could be used e.g. to teach GCC about GTK's\nreference-counting semantics, or about locking in the Linux kernel, or about\nsignal-safety in APIs.\n\nOther ideas include visualizations of code structure.   Given a ``gcc.CFG``\ninstance, ``gccutils.render_to_dot(cfg)`` and ``gccutils.invoke_dot(cfg)`` will\nuse graphviz and eog to plot a handy visualization of a control flow graph,\nshowing the source code interleaved with GCC's ``GIMPLE`` internal\nrepresentation.\n\nThe documentation can be seen at:\n\n  http://gcc-python-plugin.readthedocs.io/en/latest/index.html\n\n\nRequirements\n------------\n\n* GCC: 4.6 or later (it uses APIs that weren't exposed to plugins in 4.5)\n\n  * tested with 4.8, 4.9, 5, 6, 7, and 8.\n\n* GCC plugin development package: usually available in distribution packages\n  such as ``gcc-N-plugin-dev`` or ``gcc-plugin-devel``.\n\n* Python: requires 2.7 or 3.2 or later\n\n* \"six\": The libcpychecker code uses the \"six_\" Python compatibility library to\n  smooth over Python 2 vs Python 3 differences, both at build-time and\n  run-time\n\n  .. _six: http://pypi.python.org/pypi/six/\n\n\nUsage\n-----\n\nI use::\n\n    make\n\nto build the plugin and run the tests\n\nYou can also use::\n\n   make demo\n\nto demonstrate the new compiler errors.\n\nDevelopment has been on x86_64 and I don't know to what extent it will be\ncompatible with other architectures.\n\nThere isn't an installer yet.  In theory you should be able to add these\narguments to the gcc invocation::\n\n    gcc -fplugin=python.so -fplugin-arg-python-script=PATH_TO_SCRIPT.py OTHER_ARGS\n\nand have it run your script as the plugin starts up.\n\nThe plugin automatically adds the absolute path to its own directory to the\nend of its `sys.path`, so that it can find support modules, such as gccutils.py\nand `libcpychecker`.\n\nThe exact API is still in flux; you can currently connect to events by\nregistering callbacks e.g. to be called for each function in the source at\ndifferent passes.\n\nIt exposes GCC's various types as Python objects, within a \"gcc\" module.  You\ncan see the API by running::\n\n    import gcc\n    help(gcc)\n\nfrom within a script.\n\n\nOverview of the code\n--------------------\n\nThis is currently three projects in one:\n\n``gcc-python-*``: the plugin for GCC.  The entrypoint (``init_plugin``) is in\n``gcc-python.c``.\n\n``libcpychecker`` and ``cpychecker.py``: a Python library (and a driver script),\nwritten for the plugin, in which I'm building new compiler warnings to\nhelp people find bugs in CPython extension code.\n\n``cpybuilder``: a handy module for programatically generating C source code for\nCPython extensions.  I use this both to generate parts of the GCC plugin, and\nalso in the selftests for the cpychecker script.  (I initially attempted to use\nCython for the former, but wrapping the \"tree\" type hierarchy required more\nprogramatic control)\n\nCoding style: Python and GCC each have their own coding style guide for C.\nI've chosen to follow Python's (PEP-7), as I prefer it (although my code is\nadmittedly a mess in places).\n\nYou'll find API documentation within the \"docs\" directory, written in the\nreStructuredText format (as is this file, in fact).  If you have Sphinx_\ninstalled, you can regenerate these docs using::\n\n   make html\n\nwithin the ``docs`` directory.  Sphinx is the ``python-sphinx`` package on a\nFedora/RHEL box.\n\n.. _Sphinx: http://sphinx.pocoo.org/\n\n\nMore detailed documentation can be seen within ``docs/getting-involved.rst``.\n\nEnjoy!\nDavid Malcolm <dmalcolm@redhat.com>\n"
  },
  {
    "path": "configbuilder.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport os\nimport shutil\nfrom subprocess import Popen, PIPE, check_output\nimport sys\n\ndef indent(prefix, text):\n    text = str(text)\n    return '\\n'.join([prefix + line\n                      for line in text.splitlines()])\n\nclass ConfigurationFailure(Exception):\n    pass\n\nclass CheckFor:\n    \"\"\"\n    Context manager for wrapping a feature test\n    The feature test should raise ConfigurationFailure to signify a failure\n    \"\"\"\n    def __init__(self, initmsg, mandatory, okmsg=None, failmsg='failed'):\n        self.initmsg = initmsg\n        self.mandatory = mandatory\n        self.okmsg = okmsg\n        self.failmsg = failmsg\n        self.result = None\n\n    # context manager hooks:\n    def __enter__(self):\n        sys.stdout.write('%s... ' % self.initmsg) # no newline\n        return self\n\n    def __exit__(self, exc_type, exc_val, exc_tb):\n        if exc_type:\n            # exception occurred:\n            self.result = False\n\n            # is it one of ours, signifiying the failure of a test?\n            if isinstance(exc_val, ConfigurationFailure):\n                # Write the failure message:\n                sys.stdout.write('%s\\n' % self.failmsg)\n\n                if self.mandatory:\n                    # Print diagnostic information:\n                    print(exc_val)\n\n                    # terminate the build\n                    sys.exit(1)\n                else:\n                    return True # swallow the exception\n            else:\n                # some kind of unexpected error; propagate it:\n                return False\n        else:\n            # Assume success:\n            self.result = True\n\n            # Write the success message:\n            if self.okmsg:\n                sys.stdout.write('%s\\n' % self.okmsg)\n\n    def succeeded(self):\n        # Did this test succeed?\n        return self.result\n\nclass Result:\n    pass\n\nclass OptionFlag(Result):\n    # the outcome of a feature test\n    def __init__(self, description, flag, defn):\n        self.description = description\n        self.flag = flag\n        self.defn = defn\n\n    def write_to(self, f):\n        f.write('/* %s */\\n' % self.description)\n        if self.flag:\n            f.write('#define %s\\n\\n' % self.defn)\n        else:\n            f.write('#undef %s\\n\\n' % self.defn)\n\nclass ConfigBuilder:\n    def __init__(self, argv):\n        import argparse\n        parser = argparse.ArgumentParser()\n        parser.add_argument('-o', '--output-file')\n        args = parser.parse_args(argv[1:])\n        #print(args)\n        self.filename = args.output_file\n\n        self.dirname = 'config-tests'\n        if os.path.exists(self.dirname):\n            shutil.rmtree(self.dirname)\n        os.mkdir(self.dirname)\n\n        self.testid = 0\n\n        self.results = []\n\n    def make_test_dir(self, test):\n        self.testid += 1\n        dirname = ('%05i-' % self.testid) + test.initmsg\n        dirname = '-'.join(dirname.split())\n        dirpath = os.path.join(self.dirname, dirname)\n        os.mkdir(dirpath)\n        return dirpath\n\n    def write_outcome(self):\n        sys.stdout.write('writing %s\\n' % self.filename)\n        with open(self.filename, 'w') as f:\n            f.write('/* autogenerated header file */\\n\\n')\n            for r in self.results:\n                r.write_to(f)\n\n    def compile(self, test, src, extraargs):\n        dirpath = self.make_test_dir(test)\n        srcpath = os.path.join(dirpath, 'feature-test.c')\n        with open(srcpath, 'w') as f:\n            f.write(src)\n        outpath = os.path.join(dirpath, 'feature-test.o')\n        args= [os.environ.get('CC', 'gcc'),\n               '-c', # don't run the linker (no main)\n               '-o', outpath]\n        args += extraargs\n        args += [srcpath]\n        p = Popen(args, stdout=PIPE, stderr=PIPE)\n        stdout, stderr = p.communicate()\n        c = p.wait()\n        if c != 0:\n            class CompilationError(ConfigurationFailure):\n                def __str__(self):\n                    result = 'Test compilation failed with exit code %i\\n' % c\n                    result += '  The command was:\\n'\n                    result += '    %s\\n' % ' '.join(args)\n                    result += '  The source was: (in %s)\\n' % srcpath\n                    result += indent('    ', src) + '\\n'\n                    result += '  The stderr was:\\n'\n                    result += indent('    ', stderr) + '\\n'\n                    return result\n            raise CompilationError()\n\n    def capture_shell_output(self, initmsg, cmd):\n        with CheckFor(initmsg,\n                      mandatory=True) as test:\n            out = check_output(cmd,\n                               shell=True) # input must be trusted\n            out = str(out.decode())\n        sys.stdout.write('%s\\n' % out.strip())\n        return out\n\n    def test_for_mandatory_c_header(self, header, extraargs):\n        with CheckFor('checking for %s' % header,\n                      okmsg='found',\n                      failmsg='not found',\n                      mandatory=True) as test:\n            self.compile(test,\n                         src='#include <%s>' % header,\n                         extraargs=extraargs)\n\n    def test_c_compilation(self, initmsg, src, extraargs, description, defn):\n        with CheckFor(initmsg,\n                      okmsg='yes',\n                      failmsg='no',\n                      mandatory=False) as test:\n            self.compile(test,\n                         src,\n                         extraargs)\n        self.results.append(OptionFlag(description,\n                                       test.succeeded(),\n                                       defn))\n\n"
  },
  {
    "path": "contributors.rst",
    "content": "Alexandre Lissy\nDavid Malcolm\nDavid Narvaez\nTom Tromey\n"
  },
  {
    "path": "cpybuilder.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom subprocess import Popen, PIPE\nimport re\n\n# For the purpose of the GCC plugin, it's OK to assume that we're compiling\n# with GCC itself, and thus we can use GCC extensions\nwith_gcc_extensions = True\n\ndef camel_case(txt):\n    return ''.join([word.title()\n                    for word in txt.split('_')])\n\ndef nullable_ptr(ptr):\n    if ptr:\n        return ptr\n    else:\n        return 'NULL'\n\ndef simple_unaryfunc(identifier, typename, c_expression):\n    \"\"\"Define a simple unaryfunc, using a specifc PyObject subclass\"\"\"\n    self.add_defn(\"static PyObject *\\n\" +\n                  \"%s(%s *self)\\n\" % (identifier, typename) +\n                  \"{\\n\" +\n                  \"    return %s;\\n\" % c_expression +\n                  \"}\\n\\n\")\n    return identifier\n\n\nclass NamedEntity:\n    \"\"\"A thing within C code that has an identifier\"\"\"\n    def __init__(self, identifier):\n        self.identifier = identifier\n\n    def c_ptr_field(self, name, cast=None):\n        if hasattr(self, name):\n            val = getattr(self, name)\n        else:\n            val = None\n        if cast:\n            caststr = '(%s)' % cast\n        else:\n            caststr = ''\n        if with_gcc_extensions:\n            # Designate the initializer fields:\n            return '    .%s = %s%s,\\n' % (name, caststr, nullable_ptr(val))\n        else:\n            return '    %s%s, /* %s */\\n' % (caststr, nullable_ptr(val), name)\n\n    def unaryfunc_field(self, name):\n        return self.c_ptr_field(name, 'unaryfunc')\n\n    def c_src_field(self, name):\n        assert hasattr(self, name)\n        val = getattr(self, name)\n        if with_gcc_extensions:\n            # Designate the initializer fields:\n            return '    .%s = %s,\\n' % (name, val)\n        else:\n            return '    %s, /* %s */\\n' % (val, name)\n\n    def c_src_field_value(self, name, val, cast=None):\n        if cast:\n            caststr = '(%s)' % cast\n        else:\n            caststr = ''\n        if with_gcc_extensions:\n            # Designate the initializer fields:\n            return '    .%s = %s%s,\\n' % (name, caststr, val)\n        else:\n            return '    %s%s, /* %s */\\n' % (caststr, val, name)\n\nclass PyGetSetDef:\n    def __init__(self, name, get, set, doc, closure=None):\n        self.name = name\n        self.get = get\n        self.set = set\n        self.doc = doc\n        self.closure = closure\n\n    def c_defn(self):\n        result =  '    {(char*)\"%s\",\\n' % self.name\n        result += '     (getter)%s,\\n' % nullable_ptr(self.get)\n        result += '     (setter)%s,\\n' % nullable_ptr(self.set)\n        result += '     (char*)\"%s\",\\n' % nullable_ptr(self.doc)\n        result += '     %s},\\n' % nullable_ptr(self.closure)\n        return result\n\nclass PyGetSetDefTable(NamedEntity):\n    def __init__(self, identifier, gsdefs, identifier_prefix=None, typename=None):\n        NamedEntity.__init__(self, identifier)\n        self.gsdefs = gsdefs\n        self.identifier_prefix = identifier_prefix\n        self.typename = typename\n\n    def c_defn(self):\n        result = 'static PyGetSetDef %s[] = {\\n' % self.identifier\n        for gsdef in self.gsdefs:\n            result += gsdef.c_defn()\n        result += '    {NULL}  /* Sentinel */\\n'\n        result += '};\\n'\n        return result\n\n    def add_gsdef(self, name, getter, setter, doc, closure=None):\n        self.gsdefs.append(PyGetSetDef(name, getter, setter, doc, closure=None))\n\n    def add_simple_getter(self, cu, name, c_expression, doc):\n        assert self.identifier_prefix\n        assert self.typename\n        identifier = self.identifier_prefix + '_get_' + name\n        cu.add_simple_getter(identifier, self.typename, c_expression)\n        self.add_gsdef(name, identifier, None, doc)\n\nMETH_VARARGS = 'METH_VARARGS'\n\nclass PyMethodDef:\n    def __init__(self, name, fn_name, args, docstring):\n        self.name = name\n        self.fn_name = fn_name\n        #assert args in ('METH_VARARGS', ) # FIXME\n        self.args = args        \n        self.docstring = docstring\n\n    def c_defn(self):\n        return ('    {(char*)\"%(name)s\",  %(fn_name)s, %(args)s,\\n'\n                '     (char*)\"%(docstring)s\"},\\n' % self.__dict__)\n\nclass PyMethodTable(NamedEntity):\n    def __init__(self, identifier, methods):\n        NamedEntity.__init__(self, identifier)\n        self.methods = methods\n\n    def c_defn(self):\n        result = 'static PyMethodDef %s[] = {\\n' % self.identifier\n        for method in self.methods:\n            result += method.c_defn()\n        result += '    {NULL, NULL, 0, NULL} /* Sentinel */\\n'\n        result += '};\\n'\n        return result\n\n    def add_method(self, name, fn_name, args, docstring):\n        self.methods.append(PyMethodDef(name, fn_name, args, docstring))\n\n# See http://docs.python.org/c-api/typeobj.html#number-structs\nclass PyNumberMethods(NamedEntity):\n    def __init__(self, identifier):\n        NamedEntity.__init__(self, identifier)\n\n    def c_defn(self):\n        result = 'static PyNumberMethods %s = {\\n' % self.identifier\n        result += self.c_ptr_field('nb_add')\n        result += self.c_ptr_field('nb_subtract')\n        result += self.c_ptr_field('nb_multiply')\n        result += '#if PY_MAJOR_VERSION < 3\\n'\n        result += self.c_ptr_field('nb_divide')\n        result += '#endif\\n'\n        result += self.c_ptr_field('nb_remainder')\n        result += self.c_ptr_field('nb_divmod')\n        result += self.c_ptr_field('nb_power')\n        result += self.unaryfunc_field('nb_negative')\n        result += self.unaryfunc_field('nb_positive')\n        result += self.unaryfunc_field('nb_absolute')\n        result += '#if PY_MAJOR_VERSION >= 3\\n'\n        result += self.c_ptr_field('nb_bool')\n        result += '#else\\n'\n        result += self.c_ptr_field('nb_nonzero')\n        result += '#endif\\n'\n        result += self.unaryfunc_field('nb_invert')\n        result += self.c_ptr_field('nb_lshift')\n        result += self.c_ptr_field('nb_rshift')\n        result += self.c_ptr_field('nb_and')\n        result += self.c_ptr_field('nb_xor')\n        result += self.c_ptr_field('nb_or')\n        result += '#if PY_MAJOR_VERSION < 3\\n'\n        result += self.c_ptr_field('nb_coerce')\n        result += '#endif\\n'\n        result += self.unaryfunc_field('nb_int')\n        result += '#if PY_MAJOR_VERSION >= 3\\n'\n        result += self.c_ptr_field('nb_reserved')\n        result += '#else\\n'\n        result += self.unaryfunc_field('nb_long')\n        result += '#endif\\n'\n        result += self.unaryfunc_field('nb_float')\n        result += '#if PY_MAJOR_VERSION < 3\\n'\n        result += self.unaryfunc_field('nb_oct')\n        result += self.unaryfunc_field('nb_hex')\n        result += '#endif\\n'\n        result += self.c_ptr_field('nb_inplace_add')\n        result += self.c_ptr_field('nb_inplace_subtract')\n        result += self.c_ptr_field('nb_inplace_multiply')\n        result += '#if PY_MAJOR_VERSION < 3\\n'\n        result += self.c_ptr_field('nb_inplace_divide')\n        result += '#endif\\n'\n        result += self.c_ptr_field('nb_inplace_remainder')\n        result += self.c_ptr_field('nb_inplace_power')\n        result += self.c_ptr_field('nb_inplace_lshift')\n        result += self.c_ptr_field('nb_inplace_rshift')\n        result += self.c_ptr_field('nb_inplace_and')\n        result += self.c_ptr_field('nb_inplace_xor')\n        result += self.c_ptr_field('nb_inplace_or')\n        result += self.c_ptr_field('nb_floor_divide')\n        result += self.c_ptr_field('nb_true_divide')\n        result += self.c_ptr_field('nb_inplace_floor_divide')\n        result += self.c_ptr_field('nb_inplace_true_divide')\n        result += self.unaryfunc_field('nb_index')\n        result += '};\\n'\n        return result\n\n    def add_method(self, name, fn_name, args, docstring):\n        self.methods.append(PyMethodDef(name, fn_name, args, docstring))\n\nclass PyTypeObject(NamedEntity):\n    def __init__(self, identifier, localname, tp_name, struct_name, **kwargs):\n        NamedEntity.__init__(self, identifier)\n        self.localname = localname\n        self.tp_name = tp_name\n        self.struct_name = struct_name\n        self.__dict__.update(kwargs)\n        if not hasattr(self, 'tp_new'):\n            self.tp_new = 'PyType_GenericNew'\n        if not hasattr(self, 'tp_flags'):\n            self.tp_flags = 'Py_TPFLAGS_DEFAULT'\n\n    def c_defn(self):\n        result = '\\n'\n        result += 'PyTypeObject %(identifier)s = {\\n' % self.__dict__\n        result += self.c_initializer()\n        result += '};\\n' % self.__dict__\n        result +='\\n'\n        return result\n\n    def c_initializer(self):\n        if hasattr(self, 'ob_type'):\n            ob_type_str = getattr(self, 'ob_type')\n        else:\n            ob_type_str = 'NULL'\n        result = '    PyVarObject_HEAD_INIT(%s, 0)\\n' % ob_type_str\n        result += '    \"%(tp_name)s\", /*tp_name*/\\n' % self.__dict__\n        result += '    sizeof(%(struct_name)s), /*tp_basicsize*/\\n' % self.__dict__\n        result += '    0, /*tp_itemsize*/\\n'\n        result += self.c_ptr_field('tp_dealloc')\n        result += '#if PY_VERSION_HEX >= 0x03080000\\n'\n        result += '    0, /*tp_vectorcall_offset*/\\n'\n        result += '#else\\n'\n        result += self.c_ptr_field('tp_print')\n        result += '#endif\\n'\n        result += self.c_ptr_field('tp_getattr')\n        result += self.c_ptr_field('tp_setattr')\n        result += '#if PY_MAJOR_VERSION < 3\\n' % self.__dict__\n        result += '    0, /*tp_compare*/\\n' % self.__dict__\n        result += '#else\\n' % self.__dict__\n        result += '    0, /*reserved*/\\n' % self.__dict__\n        result += '#endif\\n' % self.__dict__\n        result += self.c_ptr_field('tp_repr')\n        result += self.c_ptr_field('tp_as_number')\n        result += self.c_ptr_field('tp_as_sequence')\n        result += self.c_ptr_field('tp_as_mapping')\n        result += self.c_ptr_field('tp_hash')\n        result += self.c_ptr_field('tp_call')\n        result += self.c_ptr_field('tp_str')\n        result += self.c_ptr_field('tp_getattro')\n        result += self.c_ptr_field('tp_setattro')\n        result += self.c_ptr_field('tp_as_buffer')\n        result += self.c_src_field('tp_flags')\n        result += '    0, /*tp_doc*/\\n'\n        result += self.c_ptr_field('tp_traverse')\n        result += self.c_ptr_field('tp_clear')\n        result += self.c_ptr_field('tp_richcompare')\n        result += '    0, /* tp_weaklistoffset */\\n'\n        result += self.c_ptr_field('tp_iter')\n        result += self.c_ptr_field('tp_iternext')\n        result += self.c_ptr_field('tp_methods')\n        result += self.c_ptr_field('tp_members')\n        result += self.c_ptr_field('tp_getset')\n        result += self.c_ptr_field('tp_base', 'PyTypeObject*')\n        result += self.c_ptr_field('tp_dict')\n        result += self.c_ptr_field('tp_descr_get')\n        result += self.c_ptr_field('tp_descr_set')\n        result += '    0, /* tp_dictoffset */\\n'\n        result += self.c_ptr_field('tp_init', 'initproc')\n        result += self.c_ptr_field('tp_alloc')\n        result += self.c_ptr_field('tp_new')\n        result += self.c_ptr_field('tp_free')\n        result += self.c_ptr_field('tp_is_gc')\n        result += self.c_ptr_field('tp_bases')\n        result += self.c_ptr_field('tp_mro')\n        result += self.c_ptr_field('tp_cache')\n        result += self.c_ptr_field('tp_subclasses')\n        result += self.c_ptr_field('tp_weaklist')\n        result += self.c_ptr_field('tp_del')\n        result += '#if PY_VERSION_HEX >= 0x02060000\\n' % self.__dict__\n        result += '    0, /*tp_version_tag*/\\n' % self.__dict__\n        result += '#endif\\n' % self.__dict__\n        result += '\\n'\n        return result\n\n    def c_invoke_type_ready(self):\n        return ('    if (PyType_Ready((PyTypeObject*)&%(identifier)s) < 0)\\n'\n                '        goto error;\\n'\n                '\\n') % self.__dict__\n\n    def c_invoke_add_to_module(self):\n        return ('    Py_INCREF(&%(identifier)s);\\n'\n                '    PyModule_AddObject(m, \"%(localname)s\", (PyObject *)&%(identifier)s);\\n'\n                '\\n') % self.__dict__\n\nclass PyModule:\n    def __init__(self, modname, modmethods, moddoc):\n        self.modname = modname\n        self.moddoc = moddoc\n        assert (modmethods is None) or isinstance(modmethods, PyMethodTable)\n        self.modmethods = modmethods\n\n        if self.modmethods:\n            self.modmethods_as_ptr = self.modmethods.identifier\n        else:\n            self.modmethods_as_ptr = 'NULL'\n\n    def c_initfn_decl(self):\n        return (\"\"\"\n#if PY_MAJOR_VERSION < 3\nPyMODINIT_FUNC init%(modname)s(void);\n#else\nPyMODINIT_FUNC PyInit_%(modname)s(void);\n#endif\n\"\"\" % self.__dict__)\n\n    \n    def c_initfn_def_begin(self):\n        return (\"\"\"\n#if PY_MAJOR_VERSION < 3\nPyMODINIT_FUNC init%(modname)s(void)\n#else\nPyMODINIT_FUNC PyInit_%(modname)s(void)\n#endif\n{\n    PyObject *m = NULL;\n\"\"\" % self.__dict__)\n\n\n    def c_initfn_def_end(self):\n        return (\"\"\"\n    #if PY_MAJOR_VERSION < 3\n    return;\n    #else\n    return m;\n    #endif\n\nerror:\n    #if PY_MAJOR_VERSION < 3\n    return;\n    #else\n    Py_XDECREF(m);\n    return NULL;\n    #endif\n}\n\"\"\")\n\n\n    def c_py3k_moduledef(self):\n        return (\"\"\"\n#if PY_MAJOR_VERSION >= 3\nstatic PyModuleDef %(modname)smodule = {\n    PyModuleDef_HEAD_INIT,\n    \"%(modname)s\", /* m_name */\n    \"%(moddoc)s\", /* m_doc */\n    -1,   /* m_size */\n    %(modmethods_as_ptr)s, /* m_methods */\n    NULL, NULL, NULL, NULL\n};\n#endif\n\"\"\" % self.__dict__)\n\n        \n    def c_invoke_ctor(self):\n        return (\"\"\"\n    #if PY_MAJOR_VERSION < 3\n    m = Py_InitModule3(\"%(modname)s\", %(modmethods_as_ptr)s,\n                       \"%(moddoc)s\");\n    #else\n    m = PyModule_Create(&%(modname)smodule);\n    #endif\n    if (!m) {\n        goto error;\n    }\n\n\"\"\" % self.__dict__)\n\nclass CompilationUnit:\n    \"\"\"\n    A single C file\n    \"\"\"\n    def __init__(self):\n        self._includes = '#include <Python.h>\\n'\n\n        self._prototypes = ''\n        \n        self._definitions = ''\n\n    def add_include(self, path):\n        self._includes += '#include \"%s\"\\n' % path\n\n    def add_decl(self, text):\n        self._prototypes += text\n\n    def add_defn(self, text):\n        self._definitions += text\n\n    def as_str(self):\n        return ('/* Autogenerated by cpybuilder */\\n' +\n                self._includes +\n                self.make_header('Prototypes') +\n                self._prototypes + \n                self.make_header('Definitions') +\n                self._definitions)\n\n    def make_header(self, text):\n        return '\\n/**** %s ****/\\n\\n' % text\n\n    def add_simple_getter(self, identifier, typename, c_expression):\n        \"\"\"Define a simple getter, suitable for use by a PyGetSetDef\"\"\"\n        self.add_defn(\"static PyObject *\\n\" +                      \n                      \"%s(%s *self, void *closure)\\n\" % (identifier, typename) +\n                      \"{\\n\" +\n                      \"    return %s;\\n\" % c_expression + \n                      \"}\\n\\n\")\n        return identifier\n\n    def add_simple_setter(self, identifier, typename, attrname, c_typecheck_fn, c_assignment):\n        \"\"\"Define a simple setter, suitable for use by a PyGetSetDef\"\"\"\n        self.add_defn(\"static int\\n\" +\n                      \"%s(%s *self, PyObject *value, void *closure)\\n\" % (identifier, typename) +\n                      \"{\\n\" +\n                      \"    if (! %s(value)) {\\n\" % c_typecheck_fn +\n                      \"        PyErr_SetString(PyExc_TypeError,\\n\" +\n                      '                        \"%s must be an int\");\\n' % attrname +\n                      '        return -1;\\n'\n                      '    }\\n' +\n                      '    %s;\\n' % c_assignment +\n                      \"    return 0;\\n\"\n                      \"}\\n\\n\")\n        return identifier\n\n    def add_simple_int_setter(self, identifier, typename, attrname, c_assignment):\n        \"\"\"\n        Define a simple setter for an int-valued attribute, suitable for use\n        by a PyGetSetDef\n        \"\"\"\n        return self.add_simple_setter(identifier, typename, attrname,\n                                      'PyGccInt_Check',\n                                      c_assignment)\n\nclass SimpleModule:\n    \"\"\"\n    A C extension module built from a single C file\n    \"\"\"\n    def __init__(self):\n        self.cu = CompilationUnit()\n\n        self._modinit_preinit = ''\n        self._modinit_postinit = ''\n\n    def add_type_object(self, name, localname,\n                        tp_name, struct_name, **kwargs):\n        pytype = PyTypeObject(name, localname, tp_name, struct_name, **kwargs)\n        self.cu.add_defn(pytype.c_defn())\n        self._modinit_preinit += pytype.c_invoke_type_ready()\n        self._modinit_postinit += pytype.c_invoke_add_to_module()\n\n    def add_module_init(self, modname, modmethods, moddoc):\n        pymod = PyModule(modname, modmethods, moddoc)\n\n        self.cu.add_decl(pymod.c_initfn_decl())\n\n        self.cu.add_defn(pymod.c_py3k_moduledef())\n\n        self.cu.add_defn(pymod.c_initfn_def_begin())\n        self.cu.add_defn(self._modinit_preinit)\n        self.cu.add_defn(pymod.c_invoke_ctor())\n        self.cu.add_defn(self._modinit_postinit)\n        self.cu.add_defn(pymod.c_initfn_def_end())\n\nclass SimpleBuild:\n    def __init__(self, sm, builddir='.'):\n        self.sm\n\n    #def generate_c(self):\n    #    with open(sm.name\n\nclass CommandError(RuntimeError):\n    def __init__(self, out, err, p):\n        assert isinstance(out, str)\n        assert isinstance(err, str)\n        assert isinstance(p, Popen)\n\n        self.out = out\n        self.err = err\n        self.p = p\n\n    def __str__(self):\n        result = '\\n'\n        result += 'returncode: %r\\n' % self.p.returncode\n        result += '  %s\\n' % self._describe_activity()\n        result += 'Stdout:\\n'\n        result += self._indent(self.out)\n        result += '\\nStderr:\\n'\n        result += self._indent(self.err, 4)\n        result += self._extra_info()\n        return result\n\n    def _indent(self, txt, size=2):\n        return '\\n'.join([' '*size + line for line in txt.splitlines()])\n\n    def _extra_info(self):\n        return ''\n    \nclass PyRuntimeError(CommandError):\n    def __init__(self, runtime, cmd, out, err, p):\n        CommandError.__init__(self, out, err, p)\n        self.runtime = runtime\n        self.cmd = cmd\n\n    def _describe_activity(self):\n        return 'running: %s -c %r' % (self.runtime.executable , self.cmd)\n\nfrom collections import namedtuple\nclass PyVersionInfo(namedtuple('PyVersionInfo', 'major minor micro releaselevel serial')):\n    @classmethod\n    def from_text(cls, txt):\n        # e.g.:\n        #   sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)\n        m = re.match('sys\\.version_info\\(major=([0-9]+), minor=([0-9]+), micro=([0-9]+), releaselevel=\\'(.*)\\', serial=([0-9]+)\\)', txt)\n        return PyVersionInfo(major=int(m.group(1)),\n                             minor=int(m.group(2)),\n                             micro=int(m.group(3)),\n                             releaselevel=m.group(4),\n                             serial=int(m.group(5)))\n"
  },
  {
    "path": "cpychecker.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "dejagnu.py",
    "content": "#   Copyright 2017 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2017 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# A Python reimplementation of parts of DejaGnu\n\nimport re\nimport unittest\n\nclass Directive:\n    \"\"\"\n    A \"dg-*\" directive within an input file.\n    \"\"\"\n    def __init__(self, inputfile, linenum, name, args):\n        self.inputfile = inputfile\n        self.linenum = linenum\n        self.name = name\n        self.args = self.parse_args(args)\n        if len(self.args) == 4:\n            m = re.match('\\.(-?[0-9]+)', self.args[3])\n            offset = int(m.group(1))\n            self.linenum += offset\n\n    @staticmethod\n    def parse_args(args):\n        quoted_group = '\"([^\"]*)\"'\n        ws = '\\s+'\n        m = re.match(quoted_group + ws + quoted_group + ws + '{(.*)}' + ws + '(.+)', args)\n        if m:\n            return list(m.groups())\n\n        m = re.match(quoted_group + ws + quoted_group + ws + '{(.*)}', args)\n        if m:\n            return list(m.groups())\n\n        m = re.match(quoted_group + ws + quoted_group, args)\n        if m:\n            return list(m.groups())\n\n        m = re.match(quoted_group, args)\n        if m:\n            return list(m.groups())\n\n        m = re.match('(\\S+)', args)\n        if m:\n            return list(m.groups())\n\n        raise ValueError('unparseable directive args: %s' % args)\n\n    def __repr__(self):\n        return ('Directive(%r, %r, %r, %r)'\n                % (self.inputfile, self.linenum, self.name, self.args))\n\nclass ExpectedDiagnostic:\n    \"\"\"\n    A dg-warning or dg-error, after parsing\n    \"\"\"\n    def __init__(self, kind, pattern, directive):\n        self.kind = kind\n        self.pattern = pattern\n        self.directive = directive\n        m = re.match('^([0-9]+): (.*)', self.pattern)\n        linenum = directive.linenum\n        if m:\n            colnum_pattern = m.group(1)\n            self.pattern = m.group(2)\n        else:\n            colnum_pattern = '[0-9]+'\n        self.pattern = ('\\S+:%i:%s: %s: %s\\n'\n                        % (linenum, colnum_pattern, self.kind, self.pattern))\n\n    def __repr__(self):\n        return ('ExpectedDiagnostic(%r, %r, %r)'\n                % (self.kind, self.pattern, self.directive))\n\nclass ExpectedMultilineOutput:\n    def __init__(self, directive, start, end, lines):\n        self.directive = directive\n        self.start = start\n        self.end = end\n        self.lines = lines\n        self.pattern = ''.join([re.escape(line) + '\\n' for line in self.lines])\n\n    def __repr__(self):\n        return ('ExpectedMultilineOutput(%r, %r, %r, %r)'\n                % (self.directive, self.start, self.end, self.lines))\n\nclass Result:\n    \"\"\"\n    A result of a test: a PASS/FAIL, with a message, and an optional\n    directive that was being tested.\n    \"\"\"\n    def __init__(self, status, directive, message):\n        self.status = status\n        self.directive = directive\n        self.message = message\n\n    def __str__(self):\n        result = '%s: ' % self.status\n        if self.directive:\n            result += ('%s:%i: '\n                       % (self.directive.inputfile, self.directive.linenum))\n        if self.message:\n            result += self.message\n        return result\n\n    def __repr__(self):\n        return ('Result(%r, %r, %r)'\n                % (self.status, self.directive, self.message))\n\nclass DgContext:\n    \"\"\"\n    A Python reimplementation of DejaGnu\n    \"\"\"\n    def __init__(self, inputfiles, verbosity=0):\n        self.inputfiles = inputfiles\n        self.options = []\n        self.verbosity = 0\n        self.expected_diagnostics = []\n        self.results = []\n        self.echo_results = False\n        self._cur_multiline_output = None\n        self.multiline_ranges = []\n\n    def parse_directives(self, inputfile):\n        with open(inputfile, 'r') as f:\n            lines = f.read().splitlines()\n            for lineidx, line in enumerate(lines):\n                directive = self.parse_line(inputfile, lineidx + 1, line)\n                if directive:\n                    self.handle_directive(directive)\n\n    def parse_line(self, inputfile, linenum, line):\n        \"\"\"\n        Look for line content of the form: \"{ dg-FOO BAR }\"\n        \"\"\"\n        m = re.match(r'.*{ (dg-\\S+) (.+) }.*', line)\n        if m:\n            #print(m.groups())\n            return Directive(inputfile, linenum, m.group(1), m.group(2))\n        elif self._cur_multiline_output:\n            self._cur_multiline_output.lines.append(line)\n\n    def handle_directive(self, directive):\n        if 0:\n            print(directive)\n        if directive.name == 'dg-message':\n            self.expected_diagnostic('note', directive)\n        elif directive.name == 'dg-options':\n            self.options.append(directive.args[0])\n        elif directive.name == 'dg-do':\n            # For now, skip dg-do\n            pass\n        elif directive.name == 'dg-begin-multiline-output':\n            self.begin_multiline_output(directive)\n        elif directive.name == 'dg-end-multiline-output':\n            self.end_multiline_output(directive)\n        else:\n            self.on_fail(directive,\n                         'unrecognized directive: %s' % directive.name)\n\n    def expected_diagnostic(self, kind, directive):\n        message = directive.args[0]\n        ed = ExpectedDiagnostic(kind, message, directive)\n        self.expected_diagnostics.append(ed)\n\n    def begin_multiline_output(self, directive):\n        self._cur_multiline_output = directive\n        directive.lines = []\n\n    def end_multiline_output(self, directive):\n        start = self._cur_multiline_output.linenum + 1\n        end = directive.linenum - 1\n        lines = self._cur_multiline_output.lines\n        mr = ExpectedMultilineOutput(self._cur_multiline_output,\n                                     start, end, lines)\n        self.multiline_ranges.append(mr)\n        self._cur_multiline_output = None\n\n    def get_args(self):\n        return self.options\n\n    def check_result(self, stdout, stderr, exitcode):\n        if 0:\n            print(self.expected_diagnostics)\n        if stdout != '':\n            self.on_fail(None, 'non-empty stdout: %r' % stdout)\n\n        # Prune stderr:\n        if 0:\n            print('Before pruning:\\n%s' % stderr)\n        stderr = self.prune_stderr(stderr)\n        if 0:\n            print('After pruning:\\n%s' % stderr)\n        if stderr != '':\n            self.on_fail(None, 'unexpected output on stderr: %r' % stderr)\n\n        # Check exitcode\n        if exitcode != 0:\n            self.on_fail(None, 'nonzero exit code')\n\n        if 0:\n            print(self.results)\n\n    def prune_stderr(self, stderr):\n        # Prune lines like this:\n        #    tests/plugin/rich-location/input.c: In function 'test_1':\n        stderr = re.sub(\"(\\S+: In function '.+':)\\n\", '', stderr)\n        for d in self.expected_diagnostics:\n            stderr, count = re.subn(d.pattern, '', stderr, 1)\n            if count == 1:\n                self.on_pass(d.directive, d.directive.name)\n            else:\n                self.on_fail(d.directive, 'diagnostic not found')\n        for mr in self.multiline_ranges:\n            stderr, count = re.subn(mr.pattern, '', stderr, 1)\n            if count == 1:\n                self.on_pass(mr.directive, 'multiline range')\n            else:\n                self.on_fail(mr.directive, 'multiline range not found')\n        return stderr\n\n    def on_pass(self, directive, issue):\n        self.add_result(Result('PASS', directive, issue))\n\n    def on_fail(self, directive, issue):\n        self.add_result(Result('FAIL', directive, issue))\n\n    def add_result(self, result):\n        if self.echo_results:\n            print(str(result))\n        self.results.append(result)\n\n    def num_failures(self):\n        count = 0\n        for r in self.results:\n            if r.status == 'FAIL':\n                count += 1\n        return count\n\ndef uses_dg_directives(inputfiles):\n    for inputfile in inputfiles:\n        with open(inputfile, 'r') as f:\n            code = f.read()\n            if 'dg-do' in code:\n                return True\n\nclass Tests(unittest.TestCase):\n    def test_parse_line(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        d = ctxt.parse_line(INPUT_FILE, 42,\n                            'before /* { dg-something \"arg1\" \"arg2\" } */ after')\n        self.assertEqual(d.inputfile, INPUT_FILE)\n        self.assertEqual(d.linenum, 42)\n        self.assertEqual(d.name, 'dg-something')\n        self.assertEqual(d.args, ['arg1', 'arg2'])\n\n    def test_nonempty_stdout(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        ctxt.check_result('stray text', '', 0)\n        self.assertEqual(len(ctxt.results), 1)\n        self.assertEqual(ctxt.results[0].status, 'FAIL')\n        self.assertEqual(ctxt.results[0].message,\n                         \"non-empty stdout: 'stray text'\")\n        self.assertEqual(ctxt.num_failures(), 1)\n\n    def test_surplus_errors(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        ctxt.check_result('', 'stray text', 0)\n        self.assertEqual(len(ctxt.results), 1)\n        self.assertEqual(ctxt.results[0].status, 'FAIL')\n        self.assertEqual(ctxt.results[0].message,\n                         \"unexpected output on stderr: 'stray text'\")\n        self.assertEqual(ctxt.num_failures(), 1)\n\n    def test_dg_message_found(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        d = ctxt.parse_line(INPUT_FILE, 23,\n                            'before /* { dg-message \"17: hello world\" } */ after')\n        ctxt.handle_directive(d)\n        self.assertEqual(len(ctxt.expected_diagnostics), 1)\n        ed = ctxt.expected_diagnostics[0]\n        self.assertEqual(ed.kind, 'note')\n        self.assertEqual(ed.pattern, '\\\\S+:23:17: note: hello world\\n')\n\n        ctxt.check_result('', INPUT_FILE + ':23:17: note: hello world\\n', 0)\n        self.assertEqual(len(ctxt.results), 1)\n        self.assertEqual(ctxt.results[0].status, 'PASS')\n        self.assertEqual(ctxt.results[0].message, 'dg-message')\n        self.assertEqual(ctxt.num_failures(), 0)\n\n    def test_dg_message_not_found(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        d = ctxt.parse_line(INPUT_FILE, 23,\n                            'before /* { dg-message \"17: hello world\" } */ after')\n        ctxt.handle_directive(d)\n        self.assertEqual(len(ctxt.expected_diagnostics), 1)\n\n        # Incorrect line/column:\n        ctxt.check_result('', INPUT_FILE + ':24:18: note: hello world\\n', 0)\n        self.assertEqual(len(ctxt.results), 2)\n        self.assertEqual(ctxt.results[0].status, 'FAIL')\n        self.assertEqual(ctxt.results[0].message, 'diagnostic not found')\n        self.assertEqual(ctxt.results[1].status, 'FAIL')\n        self.assertEqual(ctxt.results[1].message,\n                         \"unexpected output on stderr: 'foo.c:24:18: note: hello world\\\\n'\")\n        self.assertEqual(ctxt.num_failures(), 2)\n\n    def test_directive_with_full_args(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        d = ctxt.parse_line(INPUT_FILE, 23,\n                            '/* { dg-message \"14: hello world\" \"title\" { target *-*-* } .-1 } */')\n        self.assertEqual(d.inputfile, INPUT_FILE)\n        self.assertEqual(d.linenum, 22)\n        self.assertEqual(d.name, 'dg-message')\n        self.assertEqual(d.args, ['14: hello world', 'title', ' target *-*-* ', '.-1'])\n\n        ctxt.handle_directive(d)\n\n        self.assertEqual(len(ctxt.expected_diagnostics), 1)\n        ed = ctxt.expected_diagnostics[0]\n        self.assertEqual(ed.kind, 'note')\n        self.assertEqual(ed.pattern, '\\\\S+:22:14: note: hello world\\n')\n\n        self.assertEqual(len(ctxt.expected_diagnostics), 1)\n\n        ctxt.check_result('', INPUT_FILE + ':22:14: note: hello world\\n', 0)\n        self.assertEqual(ctxt.num_failures(), 0)\n\n    def test_directive_with_full_args_2(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        d = ctxt.parse_line(INPUT_FILE, 23,\n                            '/* { dg-message \"14: hello world\" \"\" { target *-*-* } .-1 } */')\n        self.assertEqual(d.inputfile, INPUT_FILE)\n        self.assertEqual(d.linenum, 22)\n        self.assertEqual(d.name, 'dg-message')\n        self.assertEqual(d.args, ['14: hello world', '', ' target *-*-* ', '.-1'])\n\n        ctxt.handle_directive(d)\n\n        self.assertEqual(len(ctxt.expected_diagnostics), 1)\n        ed = ctxt.expected_diagnostics[0]\n        self.assertEqual(ed.kind, 'note')\n        self.assertEqual(ed.pattern, '\\\\S+:22:14: note: hello world\\n')\n\n        self.assertEqual(len(ctxt.expected_diagnostics), 1)\n\n        ctxt.check_result('', INPUT_FILE + ':22:14: note: hello world\\n', 0)\n        self.assertEqual(ctxt.num_failures(), 0)\n\n    def test_dg_options(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        d = ctxt.parse_line(INPUT_FILE, 23,\n                            '/* { dg-options \"-fdiagnostics-show-caret\" } */')\n        ctxt.handle_directive(d)\n        self.assertEqual(ctxt.options, ['-fdiagnostics-show-caret'])\n\n    def test_dg_do(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        d = ctxt.parse_line(INPUT_FILE, 23,\n                            '/* { dg-do compile } */')\n        ctxt.handle_directive(d)\n        self.assertEqual(d.args, ['compile'])\n\n    def test_multiline_ranges(self):\n        INPUT_FILE = 'foo.c'\n        ctxt = DgContext([INPUT_FILE])\n        lines = \"\"\"\n        /* { dg-begin-multiline-output \"\" }\n           { return foo + bar; }\n                    ~~~~^~~~~\n           { dg-end-multiline-output \"\" } */\n        \"\"\"\n        for lineidx, line in enumerate(lines.splitlines()):\n            directive = ctxt.parse_line(INPUT_FILE, lineidx + 1, line)\n            if directive:\n                ctxt.handle_directive(directive)\n\n        self.assertEqual(len(ctxt.multiline_ranges), 1)\n        mr = ctxt.multiline_ranges[0]\n        self.assertEqual(mr.start, 3)\n        self.assertEqual(mr.end, 4)\n        self.assertEqual(mr.lines,\n                         ['           { return foo + bar; }',\n                          '                    ~~~~^~~~~'])\n\n        stderr = ('           { return foo + bar; }\\n'\n                  + '                    ~~~~^~~~~\\n')\n        ctxt.check_result('', stderr, 0)\n        self.assertEqual(ctxt.num_failures(), 0)\n\nif __name__ == '__main__':\n    unittest.main()\n"
  },
  {
    "path": "demo.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Examples of mistakes made using the Python API */\n#include <Python.h>\n\nextern uint16_t htons(uint16_t hostshort);\n\n#if PY_MAJOR_VERSION >= 3\n#define PYINT_FROMLONG(l) (PyLong_FromLong(l))\n#else\n#define PYINT_FROMLONG(l) (PyInt_FromLong(l))\n#endif\n\nPyObject *\nsocket_htons(PyObject *self, PyObject *args)\n{\n    unsigned long x1, x2;\n\n    if (!PyArg_ParseTuple(args, \"i:htons\", &x1)) {\n        return NULL;\n    }\n    x2 = (int)htons((short)x1);\n    return PYINT_FROMLONG(x2);\n}\n\nPyObject *\nnot_enough_varargs(PyObject *self, PyObject *args)\n{\n   if (!PyArg_ParseTuple(args, \"i\")) {\n       return NULL;\n   }\n   Py_RETURN_NONE;\n}\n\nPyObject *\ntoo_many_varargs(PyObject *self, PyObject *args)\n{\n    int i, j;\n    if (!PyArg_ParseTuple(args, \"i\", &i, &j)) {\n\t return NULL;\n    }\n    Py_RETURN_NONE;\n}\n\nPyObject *\nkwargs_example(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    double x, y;\n    char *keywords[] = {\"x\", \"y\"};\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"(ff):kwargs_example\", keywords, &x, &y)) {\n\t return NULL;\n    }\n    Py_RETURN_NONE;\n}\n\n\nextern int convert_to_ssize(PyObject *, Py_ssize_t *);\n\nPyObject *\nbuggy_converter(PyObject *self, PyObject *args)\n{\n    int i;\n\n    if (!PyArg_ParseTuple(args, \"O&\", convert_to_ssize, &i)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\nPyObject *\nmake_a_list_of_random_ints_badly(PyObject *self,\n                                 PyObject *args)\n{\n    PyObject *list, *item;\n    long count, i;\n\n    if (!PyArg_ParseTuple(args, \"i\", &count)) {\n         return NULL;\n    }\n\n    list = PyList_New(0);\n\n    for (i = 0; i < count; i++) {\n        item = PyLong_FromLong(random());\n        PyList_Append(list, item);\n    }\n\n    return list;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "demo.expected",
    "content": "demo.c: In function ‘socket_htons’:\ndemo.c:36:: warning: Mismatching type in call to PyArg_ParseTuple with format code \"i:htons\"\ndemo.c: In function ‘not_enough_varargs’:\ndemo.c:46:: warning: Not enough arguments in call to PyArg_ParseTuple with format string \"i\"\ndemo.c: In function ‘too_many_varargs’:\ndemo.c:56:: warning: Too many arguments in call to PyArg_ParseTuple with format string \"i\"\ndemo.c: In function ‘kwargs_example’:\ndemo.c:68:: warning: Mismatching type in call to PyArg_ParseTupleAndKeywords with format code \"(ff):kwargs_example\"\ndemo.c:68:: warning: Mismatching type in call to PyArg_ParseTupleAndKeywords with format code \"(ff):kwargs_example\"\ndemo.c: In function ‘buggy_converter’:\ndemo.c:82:: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\"\ndemo.c: In function ‘make_a_list_of_random_ints_badly’:\ndemo.c:96:: warning: Mismatching type in call to PyArg_ParseTuple with format code \"i\"\ndemo.c:104:: warning: calling PyList_Append with NULL as argument 1 (list) at demo.c:104\n"
  },
  {
    "path": "demo.expected.no-refcounts",
    "content": "demo.c: In function ‘socket_htons’:\ndemo.c:36:: warning: Mismatching type in call to PyArg_ParseTuple with format code \"i:htons\"\ndemo.c: In function ‘not_enough_varargs’:\ndemo.c:46:: warning: Not enough arguments in call to PyArg_ParseTuple with format string \"i\"\ndemo.c: In function ‘too_many_varargs’:\ndemo.c:56:: warning: Too many arguments in call to PyArg_ParseTuple with format string \"i\"\ndemo.c: In function ‘kwargs_example’:\ndemo.c:68:: warning: Mismatching type in call to PyArg_ParseTupleAndKeywords with format code \"(ff):kwargs_example\"\ndemo.c:68:: warning: Mismatching type in call to PyArg_ParseTupleAndKeywords with format code \"(ff):kwargs_example\"\ndemo.c: In function ‘buggy_converter’:\ndemo.c:82:: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\"\ndemo.c: In function ‘make_a_list_of_random_ints_badly’:\ndemo.c:96:: warning: Mismatching type in call to PyArg_ParseTuple with format code \"i\"\n"
  },
  {
    "path": "docs/0.10.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. covers up to 9f38feba0c69add5a39b69faba528de955ff71a2\n\n0.10\n~~~~\n\nThanks to Buck Golemon, Daniele Varrazzo, David Narvaez, Eevee, Jason Mueller,\nKevin Pyle, Matt Rice and Tom Tromey for their contributions to this release.\n\nChanges to the GCC Python Plugin\n================================\n\n* The plugin can now be used with Python 3.3 (fixing Unicode issues and\n  dict-ordering assumptions).\n\n* The plugin now exposes inline assembler to Python scripts via\n  :py:class:`gcc.GimpleAsm`.\n\n* There is a new `gccutils.sorted_callgraph()` function to get the callgraph in\n  topologically-sorted order.\n\n* The test suite has been reworked to fix issues with checkouts on OS X\n  case-insensitive filesystems.\n\n* C++ support: support for locating the global namespace (aka \"::\"), for locating\n  declarations and child namespaces within a namespace, and aliases.\n\n* :py:class:`gcc.Declaration` now has an is_builtin attribute\n\n* Numerous improvements to the plugin's Makefile\n\n\nImprovements to :doc:`gcc-with-cpychecker </cpychecker>`\n========================================================\n\n* By default, the refcount checker is now only run on code that includes\n  <Python.h> (implemented by checking if the \"PyObject\" typedef exists).\n\n  This greatly speeds up compilation of large projects for which the Python\n  extension modules are only a small subset of the source tree.\n\n* Added some custom attributes for marking functions that set an exception,\n  either always, or when returning a negative value::\n\n    __attribute__((cpychecker_negative_result_sets_exception))\n    __attribute__((cpychecker_sets_exception))\n\n* Improve descriptions of ranges: rather than emitting descriptions with the rather\n  vague \"value\", such as::\n\n    when considering range: 1 <= value <= 0x7fffffff\n\n  instead try to embed a descriptive name for the value, such as::\n\n    when considering range: 1 <= n <= 0x7fffffff\n\n\nMass recompile of Fedora 17's Python extension code\n---------------------------------------------------\n\nI ran the reference-count checker on all of the C/C++ Python extension modules\nin Fedora 17 and `reported hundreds of genuine problems\n<http://fedoraproject.org/wiki/Features/StaticAnalysisOfPythonRefcounts>`_,\nmany of which have been fixed.\n\nIn the process of doing this I found and fixed many problems in the checker\nitself.  For example:\n\n  * the checker now understand's GCC's  `__builtin_expect`, fixing various\n    false reports about dereferencing NULL pointers when running the checker\n    on Cython-generated code in python-lxml-2.3\n\n  * added descriptions of part of SWIG and Cython's internal APIs to suppress\n    some false positives seen with SWIG and Cython-generated code.\n\n  * tweak the refcount rules to fix some false positives where the checker\n    erroneously considered the case of a deallocation by:\n\n    .. code-block:: c\n\n       Py_DECREF(obj);\n\n    where \"obj\" provably had other references not owned by the function being\n    analyzed, and thus for the case where obj->ob_refcnt > 1 the deallocation\n    could not happen.\n\nThe plugin also now has a triaging script which can examine all of the errors\nwithin a build and provide a report, showing all of them in prioritized\ncategories.\n\nThe source tree now contains helper scripts for conducting such a mass recompile.\n\nPyscopg support\n---------------\n\nDaniele Varrazzo used the checker extensively on\n`psycopg <http://initd.org/psycopg/>`_, the popular Python interface\nto `PostgreSQL <http://www.postgresql.org/>`_, and was able to find and fix\nnumerous subtle errors:\n\n  * https://fedorahosted.org/pipermail/gcc-python-plugin/2012-March/000229.html\n  * http://initd.org/psycopg/articles/2012/03/29/psycopg-245-released/\n\nExperimental new error visualization\n------------------------------------\n\nThe checker can now dump its internal representation in JSON form, via a new\n`--dump-json` option, and an experimental new renderer can generate HTML from\nthis.  An example can be seen here:\n\nhttp://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-19/example/example.html\n\nThis is still a work-in-progress\n\nC++ support\n-----------\n\nThe checker is now able to run on C++ code: support has been added for methods,\nreferences, \"this\", destructors, the :py:class:`gcc.GimpleNop` operation.\n\nCoverage of the CPython API\n---------------------------\n\nThe format code handling for Py_BuildValue was missing support for the\nfollowing codes:\n\n    * 'u' and 'u#'\n    * 'f' and 'd'\n    * 'D'\n    * 'c'\n\nIn addition, the handling for 's#' and 'z#' had a bug in which it erroneously\nexpected an int* or Py_ssize_t*, rather than just a int or Py_ssize_t.\n\nThis release fixes these issues, and gives full coverage of all valid\nformat codes for Py_BuildValue in Python 2.\n\nThis release adds heuristics for the behavior of the following CPython API\nentrypoints:\n\n   * PyCode_New\n   * PyCObject_FromVoidPtrAndDesc\n   * PyDict_Size\n   * PyErr_Clear\n   * PyEval_CallMethod\n   * Py_FatalError\n   * PyFile_SoftSpace, PyFile_WriteObject, and PyFile_WriteString\n   * PyFloat_AsDouble and PyFloat_FromDouble\n   * PyFrame_New\n   * Py_GetVersion\n   * PyImport_AddModule\n   * PyIter_Next\n   * PyNumber_Int, PyNumber_Remainder\n   * PyObject_CallObject, PyObject_GetAttr, PyObject_GetAttrString, PyObject_GetItem, PyObject_SetAttr, and PyObject_SetAttrString\n   * PyOS_snprintf\n   * PyString_InternFromString\n   * PySequence_Concat, PySequence_GetSlice, PySequence_SetItem, PySequence_Size\n   * PySys_GetObject\n   * PyTraceBack_Here\n   * PyTuple_GetItem\n   * PyUnicodeUCS4_DecodeUTF8\n   * PyWeakref_GetObject\n\nalong with various other bugfixes.\n"
  },
  {
    "path": "docs/0.11.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. this covers up to 9bfec18f7eebf9af2dde8b8db132cf97c7d9c17d\n\n0.11\n~~~~\n\nChanges to the GCC Python Plugin\n================================\n\nThe main change in this release is support for compiling the plugin with a\nC++ compiler.  Recent versions of GCC 4.7 are now built with C++ rather than\nC, meaning that plugins must also be built with C++ (since all of GCC's\ninternal symbols are name-mangled).  This release fixes the plugin's\nMakefile so that it autodetects whether the plugin needs to be built with a\nC or C++ compiler and (I hope) does the right thing automatically.  I've also\nmade the necessary changes to the C source code of the plugin so that it is\ncompilable as either language.\n\nThis should enable the plugin to now be usable with recent builds of gcc\n4.7.* (along with gcc 4.6).\n\nThe plugin doesn't yet support gcc 4.8 prereleases.\n\nOther fixes:\n\n  * there is now a unique :py:class:`gcc.Edge` wrapper for each underlying\n    edge in GCC's control flow graphs, rather than the old erroneous\n    behavior of having multiple identical duplicate wrappers.\n\n  * fixed missing documentation for :py:class:`gcc.SsaName`, and\n    :py:class:`gcc.Edge`'s `true_value` and `false_value` flags\n\n\nInternal improvements to :doc:`gcc-with-cpychecker </cpychecker>`\n=================================================================\n\nThe CPython static analysis code shipped with the plugin contains a detailed\ndescription of the behavior of the\n`CPython API <http://docs.python.org/c-api/>`_ (e.g. which arguments will\nlead to a segfault if NULL, and why; the possible outcomes of a call and\ntheir impact on reference-counts; etc).\n\nHowever, these descriptions were tightly bound to implementation details of\nthe checker.\n\nThis release introduces a new internal API to the analyzer for describing\nthe possible behaviors of CPython API entrypoints, in an attempt to decouple\nthese descriptions from the checker, and ports many of the descriptions to\nusing it.\n\nThese changes shouldn't be visible to users of the checker, but should make\nfuture maintenance much easier.\n"
  },
  {
    "path": "docs/0.12.rst",
    "content": ".. Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. this covers up to cfd1a892b8e47ea18b757611c83528b22d85f4ce\n\n0.12\n~~~~\n\nChanges to the GCC Python Plugin\n================================\n\nGCC 4.8 compatibility\n---------------------\n\nThis release of the plugin adds support for gcc 4.8 (along with continued\nsupport for gcc 4.7 and gcc 4.6).\n\n\ngcc-c-api\n---------\nThe source tree contains a new component: gcc-c-api.  This provides a\nwrapper library `libgcc-c-api.so` that hides much of the details of GCC's\ninternals (such as the binary layout of structures, and the differences\nbetween GCC 4.6 through 4.8).\n\nI plan for this to eventually be its own project, aiming at providing\na stable API and ABI for working with GCC, once it has proven itself in\nthe context of the python plugin.\n\nThe API provides an XML description of itself, which should greatly simplify\nthe job of generating bindings for accessing GCC internals from other\nlanguages.\n\n\nLink-Time Optimization support\n------------------------------\nThe plugin can now be used with GCC's Link-Time Optimization feature (LTO),\nallowing whole-program visualizations and analysis.\n\nFor example, you can rendering a whole-program \"supergraph\" of control flow\ngraphs using this invocation:\n\n.. code-block:: bash\n\n   $ ./gcc-with-python \\\n     examples/show-lto-supergraph.py \\\n     -flto \\\n     -flto-partition=none \\\n     tests/examples/lto/input-*.c\n\nwhich will render a bitmap of the supergraph like this:\n\n    .. figure:: sample-supergraph.png\n      :scale: 50 %\n      :alt: image of a supergraph\n\n\nAPI improvements\n----------------\nSane repr() implementations have been added to the following classes:\n:py:class:`gcc.CaseLabelExpr`\n:py:class:`gcc.GimpleLabel`\n:py:class:`gcc.BasicBlock`\n:py:class:`gcc.SsaName`\n:py:class:`gcc.ArrayRef`\n:py:class:`gcc.ComponentRef`\n:py:class:`gcc.PointerType`\n:py:class:`gcc.IntegerType`\n:py:class:`gcc.Location`\n\n\n:py:class:`gcc.Location` instances can now be compared and sorted.  They\nare ordered alphabetically by file, then by line number, then by column)\n\n\nOther fixes\n-----------\n\n* the Makefile has a \"make install\" target (at last)\n\n* prevent forkbomb when running with CC=gcc-with-cpychecker\n\n* fixed memory leak within :py:meth:`gcc.Gimple.walk_tree`\n\n* ensure that the result of :py:attr:`gcc.Cfg.basic_blocks`\n  can't contain any `None` items (which used to sometimes happen when\n  certain optimizations had occurred).\n\n* run-test-suite.py now has a --show option, giving more verbose\n  information on what the test suite is doing\n\n* fix hashing and equality for :py:class:`gcc.Function` and\n  :py:class:`gcc.Gimple`\n\n* fix :py:meth:`gcc.IntegerCst.__hash__` and ensure it compares sanely\n  against `int`\n\n* ensure that equivalent :py:class:`gcc.ComponentRef` objects have the\n  same hash and are equal\n\n* ensure there is a unique gcc.CallgraphEdge for each underlying edge, and\n  a unique gcc.Cfg for each underlying control flow graph\n\n* add a \"label\" attribute to gcc.GimpleLabel\n\n* add :py:data:`gcc.GCC_VERSION`\n\n\nInternal improvements to :doc:`gcc-with-cpychecker </cpychecker>`\n=================================================================\n\n* fix exception on pointer comparisons\n* fix exception on int-to-float casts\n* fix traceback when analyzing a callsite that discards the LHS when an Outcome.returns() a value\n* fix two different exceptions when casting an integer value to a pointer\n* add example of refcounting bugs to \"make demo\"\n* fix a traceback seen on bogus uses of Py_XDECREF()\n\n"
  },
  {
    "path": "docs/0.13.rst",
    "content": ".. Copyright 2014 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2014 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. this covers up to ef48966bc952d2af637e6a34e92846af2c2210bf\n\n0.13\n~~~~\n\nThe major features in this release are:\n\n  * gcc 4.9 compatibility\n\n  * a major revamping to the HTML output from gcc-with-cpychecker\n\nNew dependency: ``lxml``.   The new HTML output format uses lxml\ninternally.\n\n\nChanges to the GCC Python Plugin\n================================\n\nGCC 4.9 compatibility\n---------------------\n\nThis release of the plugin adds support for gcc 4.9 (along with continued\nsupport for gcc 4.6, 4.7 and gcc 4.8).\n\nBuilding against 4.9 requires a GCC 4.9 with the fix for\n`GCC bug 63410 <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63410>`_ applied.\n\nOther fixes\n-----------\n* fixed a build-time incompatibility with Python 3.3.0\n* various internal bug fixes:\n\n  * bug in garbage-collector integration (https://bugzilla.redhat.com/show_bug.cgi?id=864314)\n\n  * the test suite is now parallelized (using multiprocessing)\n\n* improvements to Makefile\n* improvements to documentation\n* add gcc.Location.in_system_header attribute\n\n\nImprovements to :doc:`gcc-with-cpychecker </cpychecker>`\n========================================================\n\nThe major improvement to :doc:`gcc-with-cpychecker </cpychecker>` is a big\nrevamp of the output.\n\nA new \"v2\" HTML report is available, written to ``SOURCE_NAME.v2.html``\ne.g. ``demo.c.v2.html``:\n\n.. figure:: new-html-error-report.png\n   :alt: screenshot of the new kind of HTML report\n\nThe new HTML report is easier to read in the presence of complicated\ncontrol flow.  It also include links to the API documentation for\ncalls made to the CPython API.\n\nFor both old-style and new-style reports, the wording of the messages has\nbeen clarified:\n\n  * Reference-count tracking messages now largely eliminate the\n    ``0 + N where N >=`` gobbledegook, since this was confusing to\n    everyone (including me).  Instead, error reports\n    talk about references as owned vs borrowed references e.g.\n\n    * \"refs: 1 owned\"\n\n    * \"refs: 0 owned 1 borrowed\"\n\n    resorting to ranges::\n\n      refs: 0 owned + B borrowed where 1 <= B <= 0x80000000\n\n    only where necessary.\n\n  * Reports now add ``memory leak:`` and ``future use-after-free:``\n    prefixes where appropriate, to better indicate the issue.\n\n  * Objects are referred to more in terms the user is likely to\n    understand e.g. ``*dictA`` rather than ``PyDictObject``.\n\nThe checker also reports better source locations in its messages\ne.g. in the presence of multiple ``return`` statements\n(https://fedorahosted.org/gcc-python-plugin/ticket/58).\n\n.. The v2 html output was first added in 0.10, but was \"experimental\", and\n   required hacking to access.\n\nOther improvements\n------------------\n* Add a new test script: `tests/examples/find-global-state`, showing\n  examples of finding global state in the code being compiled.\n* handle :c:func:`PySequence_DelItem`\n* fix bug in handling of :c:func:`PyRun_SimpleStringFlags`\n* fix issue with handling of :c:func:`PyArg_ParseTuple`\n  (https://fedorahosted.org/gcc-python-plugin/ticket/50)\n* although we don't model the internals of C++ exceptions, fix things so\n  we don't crash with a traceback in the absense of ``-fno-exceptions``\n  (https://fedorahosted.org/gcc-python-plugin/ticket/51)\n\n\nContributors\n============\nThanks to Buck Golemon, Denis Efremov, Philip Herron, and Tom Tromey for\ntheir contributions to this release.\n"
  },
  {
    "path": "docs/0.14.rst",
    "content": ".. Copyright 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n0.14\n~~~~\n\nThis releases adds support for gcc 5  (along with continued\nsupport for gcc 4.6, 4.7, 4.8 and 4.9).\n"
  },
  {
    "path": "docs/0.15.rst",
    "content": ".. Copyright 2016 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2016 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n0.15\n~~~~\n\nThis releases adds support for gcc 6  (along with continued\nsupport for gcc 4.6, 4.7, 4.8, 4.9 and 5).\n\nAdditionally, this release contains the following improvements\n(contributed by Tom Tromey; thanks Tom):\n\n    * document :py:data:`gcc.PLUGIN_FINISH_TYPE`\n\n    * document :py:class:`gcc.EnumeralType`; add 'values' attribute\n\n    * add unqualified_equivalent to gcc.Type subclasses\n\n    * preserve qualifiers when adding more qualifiers\n\n    * fix include for gcc 4.9.2\n\n    * handle variadic function types\n"
  },
  {
    "path": "docs/0.16.rst",
    "content": ".. Copyright 2018 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2018 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n0.16\n~~~~\n\nThis releases adds support for gcc 7 and gcc 8  (along with continued\nsupport for gcc 4.6, 4.7, 4.8, 4.9, 5 and 6).\n\nThe upstream location for the plugin has moved from fedorahosted.org\nto https://github.com/davidmalcolm/gcc-python-plugin\n\nAdditionally, this release contains the following improvements:\n\n* add :py:class:`gcc.RichLocation` for GCC 6 onwards\n\n* :py:class:`gcc.Location`\n\n  * add :py:attr:`~gcc.Location.caret`, :py:attr:`~gcc.Location.start`,\n    :py:attr:`~gcc.Location.finish` attributes for GCC 7 onwards\n\n  * add :py:meth:`gcc.Location.offset_column` method\n"
  },
  {
    "path": "docs/0.17.rst",
    "content": ".. Copyright 2019 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2019 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n0.17\n~~~~\n\nThis release adds support for gcc 9 (along with continued support for\ngcc 4.6, 4.7, 4.8, 4.9, 5, 6, 7, and 8).\n\nUnfortunately, the reference-count checker no longer works for gcc 7\nonwards, so it is disabled when embedded in those builds of gcc.\n\nAdditionally, this release contains the following improvements:\n\n* the plugin can now be built in a separate build directory from the\n  source directory (thanks to Tom de Vries)\n\n* gcc-with-cpychecker gained a :option:`--cpychecker-verbose` option\n"
  },
  {
    "path": "docs/0.7.rst",
    "content": "0.7\n~~~\n\nThis is a major update to the GCC Python plugin.\n\nThe main example script, cpychecker, has seen numerous improvements, and has\nnow detected many reference-counting bugs in real-world CPython extension code.\nThe usability and signal:noise ratio is greatly improved over previous releases.\n\nChanges to the GCC Python Plugin\n================================\n\nIt's now possible to create custom GCC attributes from Python, allowing you to\nadd custom high-level annotation to a C API, and to write scripts that will\nverify these properties.  It's also possible to inject preprocessor macros\nfrom Python.  Taken together, this allows code like this:\n\n   .. literalinclude:: ../tests/examples/attributes-with-macros/input.c\n      :lines: 22-45\n      :language: c\n\nOther improvements:\n\n   * gcc's debug dump facilities are now exposed via a Python API\n\n   * it's now possible to run Python commands in GCC (rather than scripts) using\n     -fplugin-arg-python-command\n\n   * improvements to the \"source location\" when reporting on an unhandled\n     Python exception.  Amongst other tweaks, it's now possible for a script to\n     override this, which the cpychecker uses, so that if it can't handle a\n     particular line of C code, the GCC error report gives that location before\n     reporting the Python traceback (making debugging much easier).\n\n   * \"switch\" statements are now properly wrapped at the Python level\n     (gcc.GimpleSwitch)\n\n   * C bitfields are now wrapped at the Python level\n\n   * gcc.Type instances now have a \"sizeof\" attribute, and an \"attributes\"\n     attribute.\n\n   * added a gcc.Gimple.walk_tree method, to make it easy to visit all nodes\n     relating to a statement\n\n   * added a new example: spell-checking all string literals in code\n\nImprovements to \"cpychecker\"\n============================\n\nThe \"libcpychecker\" Python code is a large example of using the plugin: it\nextends GCC with code that tries to detect various bugs in CPython extension\nmodules.\n\nThe cpychecker analyzes the paths that can be followed through a C function,\nand verifies various properties, including reference-count handling.\n\nAs of this release, the pass has found many reference-counting bugs in\nreal-world code.  You can see a list of the bugs that it has detected at:\n\nhttp://gcc-python-plugin.readthedocs.org/en/latest/success.html\n\nThe checker is now *almost* capable of fully handling the C code within the\ngcc python plugin itself.\n\nThe checker has also been reorganized to (I hope) make it easy to add checking\nfor other libraries and APIs.\n\nMajor rewrite of reference-count tracking\n-----------------------------------------\n\nI've rewritten the internals of how reference counts are tracked: the code now\nmakes a distinction betweeen all of the reference that can be analysed within a\nsingle function, versus all of the other references that may exist in the rest\nof the program.\n\nThis allows us to know for an object e.g. that the function doesn't directly\nown any references, but that the reference count is still > 0 (a \"borrowed\nreference\"), as compared to the case where the function owns a reference, but\nwe don't know of any in the rest of the program (this is typical when receiving\na \"new reference\" e.g. from a function call to a constructor).\n\nWithin the reference-count checker, we now look for memory locations that\nstore references to objects.   If those locations not on the stack, then the\nreferences they store are now assumed to legally count towards the ob_refcnt\nthat the function \"owns\".  This is needed in order to correctly handle e.g.\nthe PyList_SET_ITEM() macro, which directly writes to the list's ob_item field,\n\"stealing\" a reference: we can detect these references, and count them towards\nthe ob_refcnt value.\n\nThe checker can now detect types that look like PyObject subclasses at the C\nlevel (by looking at the top-most fields), and uses this information in various\nplaces.\n\nThe checker now exposes custom GCC attributes allowing you to mark APIs that\nhave non-standard reference-handling behavior:\n\n.. code-block:: c\n\n   PyObject *foo(void)\n     CPYCHECKER_RETURNS_BORROWED_REF;\n\n   extern void bar(int i, PyObject *obj, int j, PyObject *other)\n     CPYCHECKER_STEALS_REFERENCE_TO_ARG(2)\n     CPYCHECKER_STEALS_REFERENCE_TO_ARG(4);\n\nIt also exposes an attribute allowing you to the run-time and compile-time\ntype information for a Python extension class:\n    \n.. code-block:: c\n\n  /* Define some PyObject subclass, as both a struct and a typedef */\n  struct OurObjectStruct {\n      PyObject_HEAD\n      /* other fields */\n  };\n  typedef struct OurObjectStruct OurExtensionObject;\n\n  /*\n    Declare the PyTypeObject, using the custom attribute to associate it with\n    the typedef above:\n  */\n  extern PyTypeObject UserDefinedExtension_Type\n    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(\"OurExtensionObject\");\n\nFunction calls with NULL-pointer arguments\n------------------------------------------\nThe checker knows about various CPython API hooks that will crash on NULL\npointer arguments, and will emit warnings when it can determine a path through\nthe code that will lead to a definite call with a NULL value.\n\n\nDereferences of uninitialized pointers\n--------------------------------------\nThe checker will now complain about paths through a function for which it can\nprove that an uninitialized pointer will be dereferenced.\n\n\nError-reporting improvements\n----------------------------\n\nThe error-reporting machinery can generate HTML reports: see e.g.:\nhttp://readthedocs.org/docs/gcc-python-plugin/en/latest/cpychecker.html#reference-count-checking\nand http://dmalcolm.livejournal.com/6560.html\n\nThe checker can now annotate its HTML (and textual) reports with information\nshowing how some pertinent aspect of the program's state changes during a\nparticular path through a function.\n\nFor example, when reporting on reference-counting errors, the HTML report\nshowing the flow through the function will now display all changes to an object's\nob_refcnt, together with all changes to what the value ought to be (e.g. due to\npointers being stored to persistent memory locations):\n\n   .. figure:: sample-html-error-report.png\n      :alt: screenshot of the HTML report\n\nSimilarly, when reporting on exception-handling errors, it now displays the\n\"history\" of changes to the thread-local exception state.\n\nThere's also a debug mode which dumps _everything_ that changes within the\nreport, which is helpful for debugging the checker itself.\n\nThe error report will attempt to use the most representative name for a leaked\nobject, using a variable name or a C expression fragment as appropriate.\n\nThe checker will attempt to combine duplicate error reports, so that it will\nonly emit one error for all of the various traces of execution that exhibit a\nparticular reference-counting bug.\n\nFinally, when writing out an HTML report, the path to the HTML is now noted\nwithin gcc's regular stderr messages.\n\n\nSignal:noise ratio improvements\n-------------------------------\n\nTo suppress various false-positives that I commonly ran into on real code, the\nchecker now makes certain assumptions:\n  \n   * When encountering an unknown function that returns a PyObject*, the\n     checker assumes that it will either return a new reference to a sane\n     object (with a sane ob_type), or return NULL and set the thread-local\n     exception state.\n\n   * The checker assumes that a PyObject* argument to a function is non-NULL\n     and has a >0 refcount, and has a sane ob_type (e.g. with a sane refcount\n     and tp_dealloc)\n\n   * When dereferencing a pointer that it has no knowledge about (e.g. a\n     pointer field in a structure), the checker now assumes that it's\n     non-NULL, unless it knows that NULL is a definite possibility i.e. it\n     optimistically assumes that you know what you're doing (this could be\n     turned into a command-line option).  Note that for the cases where we\n     know that the pointer can _definitely_ be NULL, an error will still be\n     reported (e.g. when considering the various possible return values for a\n     function known to be able to return NULL).\n\nCoverage of the CPython API\n---------------------------\n\nI've gone through much of the CPython API, \"teaching\" the checker about the\nreference-count semantics of each API call (and which calls will crash if fed a\nNULL pointer).  This involves writing a simple fragment of Python code for\neach function, which describes the various different affects that the call can\nhave on the internal state within the callee.\n\nThis release adds support for calls to the following:\n   * _PyObject_New\n   * Py_{Initialize|Finalize}\n   * Py_InitModule4\n   * PyArg_ParseTuple[AndKeywords], and the PY_SSIZE_T_CLEAN variants (only\n     partial coverage so far: \"O\", \"O!\" should work though)\n   * PyArg_UnpackTuple\n   * PyBool_FromLong\n   * Py_BuildValue and the PY_SSIZE_T_CLEAN variant (only partial coverage so\n     far)\n   * PyDict_{GetItem,GetItemString,New,SetItem,SetItemString}\n   * PyErr_{Format,NoMemory,Occurred,Print,PrintEx,SetFromErrno[WithFilename],\n     SetObject,SetString}\n   * PyEval_InitThreads\n   * PyGILState_{Ensure,Release}\n   * PyImport_{AppendInittab,ImportModule}\n   * PyInt_{AsLong,FromLong}\n   * PyList_Append\n   * PyLong_{FromString,FromVoidPtr}\n   * PyMem_{Malloc,Free}\n   * PyModule_Add{IntConstant,Object,StringConstant}\n   * PyObject_{Call,CallMethod,HasAttrString,IsTrue,Repr,Str}\n   * PyRun_{SimpleFileExFlags,SimpleStringFlags}\n   * PySequence_GetItem\n   * PyString_{AsString,FromFormat,FromString,FromStringAndSize}\n   * PyStructSequence_{InitType,New}\n   * PySys_SetObject\n   * PyTuple_{New,SetItem,Size}\n   * PyType_{IsSubtype,Ready}\n\nI've been targetting those API entrypoints that I use myself in the plugin;\nthis is one area which is particularly amenable to patching, for anyone who\nwants to get involved.   I've also added a (disabled) hook that complains\nabout Python API entrypoints that weren't explicitly handled, to make it easy\nto find gaps in our coverage of the CPython API.\n\n\nOther user-visible improvments\n------------------------------\n\n   * There's now a \"gcc-with-cpychecker\" harness, to make it easier to invoke\n     GCC with the cpychecker code from e.g. Makefiles\n\n   * The checker now respects `__attribute((nonnull))` on function arguments\n     when detecting NULL pointers\n\n   * Handle functions that don't return (e.g. \"exit\")\n\n   * Number the unknown heap regions, to clarify things when there's more than\n     one\n\nInternal improvements\n---------------------\n\n  * The cpychecker now has some protection against combinatorial explosion\n    for functions that have very large numbers of possible routes through\n    them.  For such functions, the checker will emit a note on stderr and\n    not attempt to find reference-counting bugs in the function.\n\n  * The cpychecker is now done as a custom pass (rather than by wiring up a\n    callback associated with every pass)\n\n  * I've tuned the logging within the checker, eliminating some CPU/memory\n    consumption issues seen when analysing complicated C code.  In particular,\n    the log message arguments are now only expanded when logging is enabled\n    (previously this was happening all the time).\n\n  * Lots of other internal improvements and bug fixes (e.g. handling of arrays\n    vs pointers, static vs auto local variables, add missing handlers for\n    various kinds of C expression, lots of work on improving the readability of\n    error messages)\n"
  },
  {
    "path": "docs/0.8.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n0.8\n~~~\n\nThanks to David Narvaez and Tom Tromey for their code contributions to this\nrelease.\n\nChanges to the GCC Python Plugin\n================================\n\nInitial C++ support\n-------------------\nThis release adds the beginnings of C++ support: :py:class:`gcc.FunctionDecl`\ninstances now have a \"fullname\" attribute, along with \"is_public\",\n\"is_private\", \"is_protected\", \"is_static\" booleans.\n\nFor example, given this code:\n\n      .. code-block:: c++\n\n         namespace Example {\n             struct Coord {\n                 int x;\n                 int y;\n             };\n\n             class Widget {\n             public:\n                 void set_location(const struct Coord& coord);\n             };\n         };\n\n`set_location`'s fullname is::\n\n   'void Example::Widget::set_location(const Example::Coord&)'\n\nThis is only present when the plugin is invoked from the C++ frontend\n(`cc1plus`), gracefully handling the case when we're invoked from other\nlanguage frontends.\n\nSimilarly, :py:class:`gcc.MethodType` has gained an \"argument_types\" attribute.\n\nUnconditional warnings\n----------------------\nThe :py:func:`gcc.warning()` function in previous versions of the plugin required an\n\"option\" argument, such as ``gcc.Option('-Wformat')``\n\nIt's now possible to emit an unconditional warning, by supplying `None` for\nthis argument, which is now the default value::\n\n   gcc.warning(func.start, 'this is an unconditional warning')\n\n.. code-block:: bash\n\n   $ ./gcc-with-python script.py input.c\n   input.c:25:1: warning: this is an unconditional warning [enabled by default]\n\nwhich will be an error if `-Werror` is supplied as a command-line argument to gcc:\n\n.. code-block:: bash\n\n   $ ./gcc-with-python script.py -Werror input.c\n   input.c:25:1: error: this is an unconditional warning [-Werror]\n\nImprovements to :doc:`gcc-with-cpychecker </cpychecker>`\n========================================================\n\nThe :doc:`\"libcpychecker\" </cpychecker>` Python code is a large example of\nusing the plugin: it extends GCC with code that tries to detect various bugs\nin CPython extension modules.\n\nAs of this release, all of the errors emitted by the tool have been converted\nto warnings.  This should make `gcc-with-cpychecker` more usable as a drop-in\nreplacement for `gcc`: the first source file with a refcounting error should\nno longer terminate the build (unless the program uses ``-Werror``, of\ncourse).\n\nVerification of PyMethodDef tables\n----------------------------------\n\nThis release adds checking of tables of PyMethodDef initialization values, used\nby Python extension modules for binding C functions to Python methods.\n\nThe checker will verify that the signatures of the callbacks match the\nflags, and that the such tables are NULL terminated::\n\n   input.c:48:22: warning: flags do not match callback signature for 'test' within PyMethodDef table\n   input.c:48:22: note: expected ml_meth callback of type \"PyObject (fn)(someobject *, PyObject *)\" (2 arguments)\n   input.c:48:22: note: actual type of underlying callback: struct PyObject * <Tc58> (struct PyObject *, struct PyObject *, struct PyObject *) (3 arguments)\n   input.c:48:22: note: see http://docs.python.org/c-api/structures.html#PyMethodDef\n\nCoverage of the CPython API\n---------------------------\n\nWhen the checker warns about code that can erroneously pass ``NULL`` to\nvarious CPython API entrypoints which are known to implicitly dereference\nthose arguments, the checker will now add an explanatory note about why it\nis complaining.\n\nFor example::\n\n      input.c: In function 'test':\n      input.c:38:33: warning: calling PyString_AsString with NULL (gcc.VarDecl('repr_args')) as argument 1 at input.c:38\n      input.c:31:15: note: when PyObject_Repr() fails at:     repr_args = PyObject_Repr(args);\n      input.c:38:33: note: PyString_AsString() invokes Py_TYPE() on the pointer via the PyString_Check() macro, thus accessing (NULL)->ob_type\n      input.c:27:1: note: graphical error report for function 'test' written out to 'input.c.test-refcount-errors.html'\n\nThe checker will now verify the argument lists of invocations of\n`PyObject_CallFunctionObjArgs\n<http://docs.python.org/c-api/object.html#PyObject_CallFunctionObjArgs>`_ and\n`PyObject_CallMethodObjArgs\n<http://docs.python.org/c-api/object.html#PyObject_CallMethodObjArgs>`_,\nchecking that all of the arguments are of the correct type\n(PyObject* or subclasses), and that the list is NULL-terminated::\n\n  input.c: In function 'test':\n  input.c:33:5: warning: argument 2 had type char[12] * but was expecting a PyObject* (or subclass)\n  input.c:33:5: warning: arguments to PyObject_CallFunctionObjArgs were not NULL-terminated\n\nThis release also adds heuristics for the behavior of the following CPython API\nentrypoints:\n\n    * PyArg_Parse\n    * PyCObject_{As,From}VoidPtr\n    * PyCallable_Check\n    * PyCapsule_GetPointer\n    * PyErr_{NewException,SetNone,WarnEx}\n    * PyEval_CallObjectWithKeywords\n    * PyEval_{Save,Restore}Thread (and thus the Py_{BEGIN,END}_ALLOW_THREADS\n      macros)\n    * PyList_{GetItem,Size}\n    * PyLong_FromLongLong\n    * PyMapping_Size\n    * PyModule_GetDict\n    * PyObject_AsFileDescriptor\n    * PyObject_Call{Function,FunctionObjArgs,MethodObjArgs}\n    * PyObject_Generic{Get,Set}Attr\n    * PyString_Size\n    * PyTuple_Pack\n    * PyUnicode_AsUTF8String\n    * Py_AtExit\n\nBug fixes\n---------\n\n* gcc-with-cpychecker will now try harder on functions that are too\n  complicated to fully handle.  Previously, when a function was too\n  complicated for the reference-count tracker to fully analyze, it would give\n  up, performing no analysis.  The checker will now try to obtain at least\n  some subset of the list of all traces through the function, and analyze\n  those.  It will still note that the function was too complicated to fully\n  analyze.\n\n  Given that we do a depth-first traversal of the tree, and that \"success\"\n  transitions are typically visited before \"failure\" transitions, this means\n  that it should at least analyze the trace in which all functions calls\n  succeed, together with traces in which some of the later calls fail.\n\n* the reference-count checker now correctly handles \"static\" `PyObject*` local\n  variables: a `static PyObject *` local preserves its value from call to call,\n  and can thus permanently own a reference.\n\n  Fixes a false-positive seen in psycopg2-2.4.2\n  (`psycopg/psycopgmodule.c:psyco_GetDecimalType`)\n  where the refcount checker erroneously reported that a reference was leaked.\n\n* the checker for Py_BuildValue(\"O\") (and \"S\" and \"N\") was being too strict,\n  requiring a (PyObject*).  Although it's not explicitly documented, it's\n  clear that these can also accept pointers to any PyObject subclass.\n\n  Fixes a false positive seen when running gcc-with-cpychecker on\n  coverage-3.5.1b1.tar.gz, in which `coverage/tracer.c:Tracer_trace` passes a\n  PyFrameObject* as an argument to such a call.\n\n* the reference-count checker now correctly suppresses reports about \"leaks\"\n  for traces that call a function that never return (such as `abort()`).\n\n  Fixes a false positive seen in rpm-4.9.1.2 in a handler for fatal errors:\n  (in python/rpmts-py.c:die) where the checker erroneously reported that a\n  reference was leaked.\n\n* `tp_iternext` callbacks are allowed to return NULL without setting an\n  exception.  The reference-count checker will now notice if a function is\n  used in such a role, and suppress warnings about such behavior.\n\n* fixed various Python tracebacks (tickets\n  `#14 <https://fedorahosted.org/gcc-python-plugin/ticket/14>`_,\n  `#19 <https://fedorahosted.org/gcc-python-plugin/ticket/19>`_,\n  `#20 <https://fedorahosted.org/gcc-python-plugin/ticket/20>`_,\n  `#22 <https://fedorahosted.org/gcc-python-plugin/ticket/22>`_,\n  `#23 <https://fedorahosted.org/gcc-python-plugin/ticket/23>`_,\n  `#24 <https://fedorahosted.org/gcc-python-plugin/ticket/24>`_,\n  `#25 <https://fedorahosted.org/gcc-python-plugin/ticket/25>`_)\n\n* various other fixes\n\n\n"
  },
  {
    "path": "docs/0.9.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. covers up to 4642a564e03c9e2c8114bca206205ad9c8fbc308\n\n0.9\n~~~\n\nChanges to the GCC Python Plugin\n================================\n\nThe plugin now works with GCC 4.7 prereleases (ticket `#21 <https://fedorahosted.org/gcc-python-plugin/ticket/21>`_).\n\nThe plugin is now integrated with GCC's garbage collector: Python wrapper\nobjects keep their underlying GCC objects alive when GCC's garbage collector\nruns, preventing segfaults that could occur if the underlying objects were\nswept away from under us\n(ticket `#1 <https://fedorahosted.org/gcc-python-plugin/ticket/1>`_).\n\nIt's now possible to attach Python callbacks to more GCC events:\n:py:data:`gcc.PLUGIN_FINISH`, :py:data:`gcc.PLUGIN_GGC_START`,\n:py:data:`gcc.PLUGIN_GGC_MARKING`, :py:data:`gcc.PLUGIN_GGC_FINISH`,\n:py:data:`gcc.PLUGIN_FINISH_DECL` (gcc 4.7)\n\n:py:class:`gcc.ArrayType` has gained a \"range\" attribute, allowing scripts\nto detect out-of-bounds conditions in array-handling.\n\nA number of memory leaks were fixed: these were found by\n`running the plugin on itself\n<http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commitdiff;h=4642a564e03c9e2c8114bca206205ad9c8fbc308>`_.\n\nVarious documentation improvements\n(ticket `#6 <https://fedorahosted.org/gcc-python-plugin/ticket/6>`_,\nticket `#31 <https://fedorahosted.org/gcc-python-plugin/ticket/31>`_).\n\n\nImprovements to :doc:`gcc-with-cpychecker </cpychecker>`\n========================================================\n\nThe :doc:`gcc-with-cpychecker </cpychecker>` tool has received some deep\ninternal improvements in this release.\n\nThe logic for analyzing the outcome of comparisons has been rewritten for this\nrelease, fixing some significant bugs that could lead to the analyzer\nincorrectly deciding whether or not a block of code was reachable.\n\nSimilarly, the logic for detecting loops has been rewritten, elimininating a\nbug in which the checker would prematurely stop analyzing loops with\ncomplicated termination conditions, and not analyze the body of the loop.\n\nDoing so extended the reach of the checker, and enabled it to find the memory\nleaks referred to above.\n\nIn addition, the checker now emits more detailed information on the ranges of\npossible values it's considering when a comparison occurs against an unknown\nvalue::\n\n   input.c: In function 'test':\n   input.c:41:5: warning: comparison against uninitialized data (item) at    input.c:41 [enabled by default]\n   input.c:34:12: note: when PyList_New() succeeds at:     result = PyList_New(len);\n   input.c:35:8: note: taking False path at:     if (!result) {\n   input.c:39:12: note: reaching:     for (i = 0; i < len; i++) {\n   input.c:39:5: note: when considering range: 1 <= value <= 0x7fffffff at:     for (i = 0; i < len; i++) {\n   input.c:39:5: note: taking True path at:     for (i = 0; i < len; i++) {\n   input.c:41:5: note: reaching: \tif (!item) {\n\nThe checker should do a better job of identifying PyObject subclasses. \nPreviously it was treating any struct beginning with \"ob_refcnt\" and \"ob_type\"\nas a Python object (with some tweaks for python 3 and debug builds).  It now\nalso covers structs that begin with a field that's a PyObject (or subclass),\nsince these are likely to also be PyObject subclasses.\n\n\nUsage of deallocated memory\n---------------------------\nPreviously, the checker would warn about paths through a function that could\nreturn a pointer to deallocated memory, or which tried to read through such\na pointer.  With this release, the checker will now also warn about paths\nthrough a function in which a pointer to deallocated memory is passed to a\nfunction.\n\nFor example, given this buggy code:\n\n.. code-block:: c\n\n   extern void some_function(PyObject *);\n\n   void\n   test(PyObject *self, PyObject *args)\n   {\n       /* Create an object: */\n       PyObject *tmp = PyLong_FromLong(0x1000);\n\n       if (!tmp) {\n           return;\n       }\n\n       /*\n         Now decref the object.  Depending on what other references are owned\n         on the object, it can reach a refcount of zero, and thus be deallocated:\n       */\n       Py_DECREF(tmp);\n\n       /* BUG: the object being returned may have been deallocated */\n       some_function(tmp);\n   }\n\nthe checker will emit this warning::\n\n   input.c: In function 'test':\n   input.c:45: warning: passing pointer to deallocated memory as argument 1 of function at input.c:45: memory deallocated at input.c:42 [enabled by default]\n   input.c:32: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\n   input.c:34: note: taking False path at:     if (!tmp) {\n   input.c:42: note: reaching:     Py_DECREF(tmp);\n   input.c:42: note: when taking False path at:     Py_DECREF(tmp);\n   input.c:42: note: reaching:     Py_DECREF(tmp);\n   input.c:42: note: calling tp_dealloc on PyLongObject allocated at input.c:32 at:     Py_DECREF(tmp);\n   input.c:45: note: reaching:     foo(tmp);\n   input.c:30: note: graphical error report for function 'passing_dead_object_to_function' written out to 'input.c.test-refcount-errors.html'\n\n\nCoverage of the CPython API\n---------------------------\n\nThis release adds heuristics for the behavior of the following CPython API\nentrypoints:\n\n   * PyString_Concat\n   * PyString_ConcatAndDel\n\nalong with various other bugfixes and documentation improvements.\n\n..\n"
  },
  {
    "path": "docs/Makefile",
    "content": "# Makefile for Sphinx documentation\n#\n\n# You can set these variables from the command line.\nSPHINXOPTS    =\nSPHINXBUILD   = sphinx-build\nPAPER         =\nBUILDDIR      = _build\n\n# Internal variables.\nPAPEROPT_a4     = -D latex_paper_size=a4\nPAPEROPT_letter = -D latex_paper_size=letter\nALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .\n\n.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest\n\nhelp:\n\t@echo \"Please use \\`make <target>' where <target> is one of\"\n\t@echo \"  html       to make standalone HTML files\"\n\t@echo \"  dirhtml    to make HTML files named index.html in directories\"\n\t@echo \"  singlehtml to make a single large HTML file\"\n\t@echo \"  pickle     to make pickle files\"\n\t@echo \"  json       to make JSON files\"\n\t@echo \"  htmlhelp   to make HTML files and a HTML help project\"\n\t@echo \"  qthelp     to make HTML files and a qthelp project\"\n\t@echo \"  devhelp    to make HTML files and a Devhelp project\"\n\t@echo \"  epub       to make an epub\"\n\t@echo \"  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter\"\n\t@echo \"  latexpdf   to make LaTeX files and run them through pdflatex\"\n\t@echo \"  text       to make text files\"\n\t@echo \"  man        to make manual pages\"\n\t@echo \"  texinfo    to make a Texinfo document\"\n\t@echo \"  info       to make an info page\"\n\t@echo \"  changes    to make an overview of all changed/added/deprecated items\"\n\t@echo \"  linkcheck  to check all external links for integrity\"\n\t@echo \"  doctest    to run all doctests embedded in the documentation (if enabled)\"\n\nclean:\n\t-rm -rf $(BUILDDIR)/*\n\nhtml:\n\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/html.\"\n\ndirhtml:\n\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml\n\t@echo\n\t@echo \"Build finished. The HTML pages are in $(BUILDDIR)/dirhtml.\"\n\nsinglehtml:\n\t$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml\n\t@echo\n\t@echo \"Build finished. The HTML page is in $(BUILDDIR)/singlehtml.\"\n\npickle:\n\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle\n\t@echo\n\t@echo \"Build finished; now you can process the pickle files.\"\n\njson:\n\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json\n\t@echo\n\t@echo \"Build finished; now you can process the JSON files.\"\n\nhtmlhelp:\n\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp\n\t@echo\n\t@echo \"Build finished; now you can run HTML Help Workshop with the\" \\\n\t      \".hhp project file in $(BUILDDIR)/htmlhelp.\"\n\nqthelp:\n\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp\n\t@echo\n\t@echo \"Build finished; now you can run \"qcollectiongenerator\" with the\" \\\n\t      \".qhcp project file in $(BUILDDIR)/qthelp, like this:\"\n\t@echo \"# qcollectiongenerator $(BUILDDIR)/qthelp/gcc-python-plugin.qhcp\"\n\t@echo \"To view the help file:\"\n\t@echo \"# assistant -collectionFile $(BUILDDIR)/qthelp/gcc-python-plugin.qhc\"\n\ndevhelp:\n\t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp\n\t@echo\n\t@echo \"Build finished.\"\n\t@echo \"To view the help file:\"\n\t@echo \"# mkdir -p $$HOME/.local/share/devhelp/gcc-python-plugin\"\n\t@echo \"# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/gcc-python-plugin\"\n\t@echo \"# devhelp\"\n\nepub:\n\t$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub\n\t@echo\n\t@echo \"Build finished. The epub file is in $(BUILDDIR)/epub.\"\n\nlatex:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo\n\t@echo \"Build finished; the LaTeX files are in $(BUILDDIR)/latex.\"\n\t@echo \"Run \\`make' in that directory to run these through (pdf)latex\" \\\n\t      \"(use \\`make latexpdf' here to do that automatically).\"\n\nlatexpdf:\n\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex\n\t@echo \"Running LaTeX files through pdflatex...\"\n\tmake -C $(BUILDDIR)/latex all-pdf\n\t@echo \"pdflatex finished; the PDF files are in $(BUILDDIR)/latex.\"\n\ntext:\n\t$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text\n\t@echo\n\t@echo \"Build finished. The text files are in $(BUILDDIR)/text.\"\n\nman:\n\t$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man\n\t@echo\n\t@echo \"Build finished. The manual pages are in $(BUILDDIR)/man.\"\n\ntexinfo:\n\t$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo\n\t@echo\n\t@echo \"Build finished. The Texinfo pages are in $(BUILDDIR)/texinfo.\"\n\ninfo: texinfo\n\tcd $(BUILDDIR)/texinfo && $(MAKE) info\n\t@echo\n\t@echo \"Build finished. The info pages are in $(BUILDDIR)/texinfo.\"\n\nchanges:\n\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes\n\t@echo\n\t@echo \"The overview file is in $(BUILDDIR)/changes.\"\n\nlinkcheck:\n\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck\n\t@echo\n\t@echo \"Link check complete; look for any errors in the above output \" \\\n\t      \"or in $(BUILDDIR)/linkcheck/output.txt.\"\n\ndoctest:\n\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest\n\t@echo \"Testing of doctests in the sources finished, look at the \" \\\n\t      \"results in $(BUILDDIR)/doctest/output.txt.\"\n"
  },
  {
    "path": "docs/appendices.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nAppendices\n==========\n\nThe following contain tables of reference material that may be useful\nwhen writing scripts.\n\n.. toctree::\n\n   tables-of-passes.rst\n   operators.rst\n"
  },
  {
    "path": "docs/attributes.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nCreating custom GCC attributes\n==============================\n\nGNU C supports a non-standard `__attribute__(()) syntax\n<http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_ for marking\ndeclarations with additional information that may be of interest to the\noptimizer, and for checking the correctness of the code.\n\nThe GCC Python plugin allows you to create custom attributes, which may\nbe of use to your scripts: you can use this to annotate C code with additional\ninformation.  For example, you could create a custom attribute for functions\ndescribing the interaction of a function on mutex objects:\n\n.. code-block:: c\n\n    extern void some_function(void)\n      __attribute__((claims_mutex(\"io\")));\n\n    extern void some_other_function(void)\n      __attribute__((releases_mutex(\"io\")));\n\nand use this in a custom code-checker.\n\nCustom attributes can take string and integer parameters.  For example, the\nabove custom attributes take a single string parameter.  A custom attribute can\ntake more than one parameter, or none at all.\n\nTo create custom attributes from Python, you need to wire up a callback\nresponse to the :py:data:`gcc.PLUGIN_ATTRIBUTES` event:\n\n   .. literalinclude:: ../tests/examples/attributes/script.py\n    :lines: 39-40\n    :language: python\n\nThis callback should then call :py:func:`gcc.register_attribute` to associate\nthe name of the attribute with a Python callback to be called when the\nattribute is encountered in C code.\n\n.. py:function:: gcc.register_attribute(name, min_length, max_length, \\\n                                        decl_required, type_required, \\\n                                        function_type_required, \\\n                                        callable)\n\n   Registers a new GCC attribute with the given *name* , usable in C source\n   code via ``__attribute__(())``.\n\n   :param name: the name of the new attribute\n   :type name: str\n   :param min_length: the minimum number of arguments expected when the attribute is used\n   :type min_length: int\n   :param max_length: the maximum number of arguments expected when the\n      attribute is used (-1 for no maximum)\n   :type max_length: int\n   :param decl_required:\n   :type decl_required:\n   :param type_required:\n   :type type_required:\n   :param function_type_required:\n   :type function_type_required:\n   :param callable: the callback to be invoked when the attribute is seen\n   :type callable: a callable object, such as a function\n\nIn this example, we can simply print when the attribute is seen, to verify that\nthe callback mechanism is working:\n\n   .. literalinclude:: ../tests/examples/attributes/script.py\n    :lines: 22-36\n    :language: python\n\nPutting it all together, here is an example Python script for the plugin:\n\n   .. literalinclude:: ../tests/examples/attributes/script.py\n    :lines: 18-\n    :language: python\n\nCompiling this test C source file:\n\n   .. literalinclude:: ../tests/examples/attributes/input.c\n    :lines: 22-29\n    :language: c\n\nleads to this output from the script:\n\n   .. literalinclude:: ../tests/examples/attributes/stdout.txt\n    :language: bash\n\nUsing the preprocessor to guard attribute usage\n-----------------------------------------------\n\nUnfortunately, the above C code will only work when it is compiled with the\nPython script that adds the custom attributes.\n\nYou can avoid this by using :py:func:`gcc.define_macro()` to pre-define a\npreprocessor name (e.g. \"WITH_ATTRIBUTE_CLAIMS_MUTEX\") at the same time as when\nyou define the attribute:\n\n   .. literalinclude:: ../tests/examples/attributes-with-macros/script.py\n    :lines: 18-\n    :language: python\n\nThis way the user can write this C code instead, and have it work both with\nand without the Python script:\n\n   .. literalinclude:: ../tests/examples/attributes-with-macros/input.c\n    :lines: 22-45\n    :language: c\n\ngiving this output from the script:\n\n   .. literalinclude:: ../tests/examples/attributes-with-macros/stdout.txt\n    :language: bash\n"
  },
  {
    "path": "docs/basics.rst",
    "content": ".. Copyright 2011-2012, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2012, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. For notes on how to document Python in RST form, see e.g.:\n.. http://sphinx.pocoo.org/domains.html#the-python-domain\n\nRequirements\n============\n\nThe plugin has the following requirements:\n\n  * GCC: 4.6 or later (it uses APIs that weren't exposed to plugins in 4.5)\n\n  * Python: requires 2.7 or 3.2 or later\n\n  * \"six\": The libcpychecker code uses the \"six\" Python compatibility library to\n    smooth over Python 2 vs Python 3 differences, both at build-time and\n    run-time:\n\n       http://pypi.python.org/pypi/six/\n\n  * \"pygments\": The libcpychecker code uses the \"pygments\" Python\n    syntax-highlighting library when writing out error reports:\n\n       http://pygments.org/\n\n  * \"lxml\": The libcpychecker code uses the \"lxml\" internally when writing\n    out error reports.\n\n  * graphviz: many of the interesting examples use \"dot\" to draw diagrams\n    (e.g. control-flow graphs), so it's worth having graphviz installed.\n\nPrebuilt-packages\n=================\n\nVarious distributions ship with pre-built copies of the plugin.  If you're\nusing Fedora, you can install the plugin via RPM on Fedora 16 onwards using:\n\n.. code-block:: bash\n\n   yum install gcc-python2-plugin\n\nas root for the Python 2 build of the plugin, or:\n\n.. code-block:: bash\n\n   yum install gcc-python3-plugin\n\nfor the Python 3 build of the plugin.\n\nOn Gentoo, use `layman` to add the `dMaggot` overlay and `emerge` the\n`gcc-python-plugin` package. This will build the plugin for Python 2 and\nPython 3 should you have both of them installed in your system. A live\nebuild is also provided to install the plugin from git sources.\n\nBuilding the plugin from source\n===============================\n\nBuild-time dependencies\n-----------------------\nIf you plan to build the plugin from scratch, you'll need the build-time\ndependencies.\n\nOn a Fedora box you can install them by running the following as root:\n\n.. code-block:: bash\n\n   yum install gcc-plugin-devel python-devel python-six python-pygments graphviz\n\nfor building against Python 2, or:\n\n.. code-block:: bash\n\n   yum install gcc-plugin-devel python3-devel python3-six python3-pygments graphviz\n\nwhen building for Python 3.\n\nBuilding the code\n------------------\nYou can obtain the source code from git by using::\n\n   $ git clone git@github.com:davidmalcolm/gcc-python-plugin.git\n\nTo build the plugin, run:\n\n.. code-block:: bash\n\n   make plugin\n\nTo build the plugin and run the selftests, run:\n\n.. code-block:: bash\n\n   make\n\nYou can also use::\n\n   make demo\n\nto demonstrate the new compiler errors.\n\nBy default, the `Makefile` builds the plugin using the first ``python-config``\ntool found in `$PATH` (e.g. `/usr/bin/python-config`), which is typically the\nsystem copy of Python 2.  You can override this (e.g. to build against\nPython 3) by overriding the `PYTHON` and `PYTHON_CONFIG` Makefile variables\nwith:\n\n.. code-block:: bash\n\n   make PYTHON=python3 PYTHON_CONFIG=python3-config\n\nThere isn't a well-defined process yet for installing the plugin (though the\nrpm specfile in the source tree contains some work-in-progress towards this).\n\nSome notes on GCC plugins can be seen at http://gcc.gnu.org/wiki/plugins and\nhttp://gcc.gnu.org/onlinedocs/gccint/Plugins.html\n\n.. note:: Unfortunately, the layout of the header files for GCC plugin\n   development has changed somewhat between different GCC releases.  In\n   particular, older builds of GCC flattened the \"c-family\" directory in the\n   installed plugin headers.\n\n   This was fixed in this GCC commit:\n\n      http://gcc.gnu.org/viewcvs?view=revision&revision=176741\n\n   So if you're using an earlier build of GCC using the old layout you'll need\n   to apply the following patch (reversed with \"-R\") to the plugin's source\n   tree to get it to compile:\n\n   .. code-block:: bash\n\n      $ git show 215730cbec40a6fe482fabb7f1ecc3d747f1b5d2 | patch -p1 -R\n\n   If you have a way to make the plugin's source work with either layout,\n   please email the plugin's `mailing list\n   <https://fedorahosted.org/mailman/listinfo/gcc-python-plugin/>`_\n\nBasic usage of the plugin\n=========================\n\nOnce you've built the plugin, you can invoke a Python script like this:\n\n.. code-block:: bash\n\n  gcc -fplugin=./python.so -fplugin-arg-python-script=PATH_TO_SCRIPT.py OTHER_ARGS\n\nand have it run your script as the plugin starts up.\n\nAlternatively, you can run a one-shot Python command like this:\n\n.. code-block:: bash\n\n  gcc -fplugin=./python.so -fplugin-arg-python-command=\"python code\" OTHER_ARGS\n\nsuch as:\n\n.. code-block:: bash\n\n  gcc -fplugin=./python.so -fplugin-arg-python-command=\"import sys; print(sys.path)\" OTHER_ARGS\n\nThe plugin automatically adds the absolute path to its own directory to the\nend of its `sys.path`, so that it can find support modules, such as gccutils.py\nand `libcpychecker`.\n\nThere is also a helper script, `gcc-with-python`, which expects a python script\nas its first argument, then regular gcc arguments:\n\n.. code-block:: bash\n\n  ./gcc-with-python PATH_TO_SCRIPT.py other args follow\n\nFor example, this command will use graphviz to draw how GCC \"sees\" the\ninternals of each function in `test.c` (within its SSA representation):\n\n.. code-block:: bash\n\n  ./gcc-with-python examples/show-ssa.py test.c\n\n\nMost of the rest of this document describes the Python API visible for\nscripting.\n\nThe plugin GCC's various types as Python objects, within a \"gcc\" module.  You\ncan see the API by running the following within a script::\n\n    import gcc\n    help(gcc)\n\nTo make this easier, there's a script to do this for you:\n\n.. code-block:: bash\n\n  ./gcc-python-docs\n\nfrom where you can review the built-in documentation strings (this document\nmay be easier to follow though).\n\nThe exact API is still in flux: and may well change (this is an early version\nof the code; we may have to change things as GCC changes in future releases\nalso).\n\n\nDebugging your script\n---------------------\n\nYou can place a forced breakpoint in your script using this standard Python\none-liner::\n\n   import pdb; pdb.set_trace()\n\nIf Python reaches this location it will interrupt the compile and put you\nwithin the `pdb` interactive debugger, from where you can investigate.\n\nSee http://docs.python.org/library/pdb.html#debugger-commands for more\ninformation.\n\n\nIf an exception occurs during Python code, and isn't handled by a try/except\nbefore returning into the plugin, the plugin prints the traceback to stderr and\ntreats it as an error:\n\n.. code-block:: pytb\n\n  /home/david/test.c: In function ‘main’:\n  /home/david/test.c:28:1: error: Unhandled Python exception raised within callback\n  Traceback (most recent call last):\n    File \"test.py\", line 38, in my_pass_execution_callback\n      dot = gccutils.tree_to_dot(fun)\n  NameError: global name 'gccutils' is not defined\n\n(In this case, it was a missing `import` statement in the script)\n\nGCC reports errors at a particular location within the source code.  For an\nunhandled exception such as the one above, by default, the plugin reports\nthe error as occurring as the top of the current source function (or the last\nlocation within the current source file for passes and callbacks that aren't\nassociated with a function).\n\nYou can override this using gcc.set_location:\n\n.. py:function:: gcc.set_location(loc)\n\n   Temporarily overrides the error-reporting location, so that if an exception\n   occurs, it will use this `gcc.Location`, rather than the default.  This may\n   be of use when debugging tracebacks from scripts.  The location is reset\n   each time after returning from Python back to the plugin, after printing\n   any traceback.\n\n\nAccessing parameters\n--------------------\n\n.. py:data:: gcc.argument_dict\n\n   Exposes the arguments passed to the plugin as a dictionary.\n\n   For example, running:\n\n   .. code-block:: bash\n\n      gcc -fplugin=python.so \\\n          -fplugin-arg-python-script=test.py \\\n          -fplugin-arg-python-foo=bar\n\n   with `test.py` containing::\n\n      import gcc\n      print(gcc.argument_dict)\n\n   has output::\n\n      {'script': 'test.py', 'foo': 'bar'}\n\n.. py:data:: gcc.argument_tuple\n\n\n  Exposes the arguments passed to the plugin as a tuple of (key, value) pairs,\n  so you have ordering.  (Probably worth removing, and replacing\n  :py:data:`argument_dict` with an OrderedDict instead; what about\n  duplicate args though?)\n\nAdding new passes to the compiler\n---------------------------------\nYou can create new compiler passes by subclassing the appropriate\n:py:class:`gcc.Pass` subclass.  For example, here's how to wire up a new pass\nthat displays the control flow graph of each function:\n\n   .. literalinclude:: ../examples/show-gimple.py\n    :lines: 19-\n    :language: python\n\nFor more information, see :ref:`creating-new-passes`\n\nWiring up callbacks\n-------------------\n\nThe other way to write scripts is to register callback functions\nto be called when various events happen during compilation, such as using\n:py:data:`gcc.PLUGIN_PASS_EXECUTION` to piggyback off of an existing GCC pass.\n\n   .. literalinclude:: ../examples/show-passes.py\n    :lines: 19-\n    :language: python\n\nFor more information, see :ref:`callbacks`\n\nGlobal data access\n==================\n\n.. py:function:: gcc.get_variables()\n\n      Get all variables in this compilation unit as a list of\n      :py:class:`gcc.Variable`\n\n.. py:class:: gcc.Variable\n\n   Wrapper around GCC's `struct varpool_node`, representing a variable in\n   the code being compiled.\n\n   .. py:attribute:: decl\n\n      The declaration of this variable, as a :py:class:`gcc.Tree`\n\n.. py:function:: gccutils.get_variables_as_dict()\n\n      Get a dictionary of all variables, where the keys are the variable names\n      (as strings), and the values are instances of :py:class:`gcc.Variable`\n\n.. py:function:: gcc.maybe_get_identifier(str)\n\n      Get the :py:class:`gcc.IdentifierNode` with this name, if it exists,\n      otherwise None.  (However, after the front-end has run, the identifier\n      node may no longer point at anything useful to you; see\n      :py:func:`gccutils.get_global_typedef` for an example of working\n      around this)\n\n.. py:function:: gcc.get_translation_units()\n\n      Get a list of all :py:class:`gcc.TranslationUnitDecl` for the compilation\n      units within this invocation of GCC (that's \"source code files\" for the\n      layperson).\n\n      .. py:class:: gcc.TranslationUnitDecl\n\n         Subclass of :py:class:`gcc.Tree` representing a compilation unit\n\n\t    .. py:attribute:: block\n\n               The :py:class:`gcc.Block` representing global scope within this\n               source file.\n\n\t    .. py:attribute:: language\n\n\t       The source language of this translation unit, as a string\n\t       (e.g. \"GNU C\")\n\n.. py:function:: gcc.get_global_namespace()\n\n      C++ only: locate the :py:class:`gcc.NamespaceDecl` for the global\n      namespace (a.k.a. \"::\")\n\n.. py:function:: gccutils.get_global_typedef(name)\n\n      Given a string `name`, look for a C/C++ `typedef` in global scope with\n      that name, returning it as a :py:class:`gcc.TypeDecl`, or None if it\n      wasn't found\n\n.. py:function:: gccutils.get_global_vardecl_by_name(name)\n\n      Given a string `name`, look for a C/C++ variable in global scope with\n      that name, returning it as a :py:class:`gcc.VarDecl`, or None if it\n      wasn't found\n\n.. py:function:: gccutils.get_field_by_name(decl, name)\n\n      Given one of a :py:class:`gcc.RecordType`, :py:class:`gcc.UnionType`, or\n      :py:class:`gcc.QualUnionType`, along with a string `name`, look for a\n      field with that name within the given struct or union, returning it as a\n      :py:class:`gcc.FieldDecl`, or None if it wasn't found\n"
  },
  {
    "path": "docs/callbacks.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. _callbacks:\n\nWorking with callbacks\n======================\n\nOne way to work with GCC from the Python plugin is via callbacks. It's possible\nto register callback functions, which will be called when various events happen\nduring compilation.\n\nFor example, it's possible to piggyback off of an existing GCC pass by using\n:py:data:`gcc.PLUGIN_PASS_EXECUTION` to piggyback off of an existing GCC pass.\n\n.. py:function:: gcc.register_callback(event_id, function, [extraargs,] **kwargs)\n\n   Wire up a python function as a callback.  It will be called when the given\n   event occurs during compilation.  For some events, the callback will be\n   called just once; for other events, the callback is called once per\n   function within the source code being compiled.  In the latter case, the\n   plugin passes a :py:class:`gcc.Function` instance as a parameter to your\n   callback, so that you can work on it::\n\n     import gcc\n\n     def my_pass_execution_callback(*args, **kwargs):\n          print('my_pass_execution_callback was called: args=%r  kwargs=%r'\n\t        % (args, kwargs))\n\n     gcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                           my_pass_execution_callback)\n\n   The exact arguments passed to your callback vary: consult the documentation\n   for the particular event you are wiring up to (see below).\n\n   You can pass additional arguments when registering the callback - they will\n   be passed to the callback after any normal arguments.  This is denoted in the\n   descriptions of events below by `*extraargs`.\n\n   You can also supply keyword arguments: they will be passed on as keyword\n   arguments to the callback.  This is denoted in the description of events\n   below by `**kwargs`.\n\nThe various events are exposed as constants within the `gcc` module and\ndirectly wrap GCC's plugin mechanism.\n\nThe following GCC events are currently usable from the Python plugin via\n:py:func:`gcc.register_callback()`:\n\n===============================================  =========\nID                                               Meaning\n===============================================  =========\n:py:data:`gcc.PLUGIN_ATTRIBUTES`                 For :doc:`creating custom GCC attributes <attributes>`\n\n:py:data:`gcc.PLUGIN_PRE_GENERICIZE`             For working with the AST in the C and C++ frontends\n\n:py:data:`gcc.PLUGIN_PASS_EXECUTION`             Called before each pass is executed\n\n:py:data:`gcc.PLUGIN_FINISH_UNIT`                At the end of working with a translation unit (aka source file)\n\n:py:data:`gcc.PLUGIN_FINISH_TYPE`                After a type has been parsed\n\n:py:data:`gcc.PLUGIN_FINISH_DECL`                After a declaration has been parsed (GCC 4.7 or later)\n\n:py:data:`gcc.PLUGIN_FINISH`                     Called before GCC exits\n\n===============================================  =========\n\n.. py:data:: gcc.PLUGIN_ATTRIBUTES\n\n   Called when GCC is creating attributes for use with its non-standard\n   `__attribute__(()) syntax\n   <http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html>`_.\n\n   If you want to create custom GCC attributes, you should register a callback\n   on this event and call :py:func:`gcc.register_attribute()` from within that\n   callback, so that they are created at the same time as the GCC's built-in\n   attributes.\n\n   No arguments are passed to your callback other than those that you supply\n   yourself when registering it:\n\n      (`*extraargs`, `**kwargs`)\n\n   See :doc:`creating custom GCC attributes <attributes>` for examples and\n   more information.\n\n.. py:data:: gcc.PLUGIN_PASS_EXECUTION\n\n   Called when GCC is about to run one of its passes.\n\n   Arguments passed to the callback are:\n\n      (`ps`, `fun`, `*extraargs`, `**kwargs`)\n\n   where `ps` is a :py:class:`gcc.Pass` and `fun` is a :py:class:`gcc.Function`.\n   Your callback will typically be called many times: there are many passes,\n   and each can be invoked zero or more times per function (in the code being\n   compiled)\n\n   More precisely, some passes have a \"gate check\": the pass first checks a\n   condition, and only executes if the condition is true.\n\n   Any callback registered with `gcc.PLUGIN_PASS_EXECUTION` will get called\n   if this condition succeeds.\n\n   The actual work of the pass is done after the callbacks return.\n\n   In pseudocode::\n\n     if pass.has_gate_condition:\n         if !pass.test_gate_condition():\n\t    return\n     invoke_all_callbacks()\n     actually_do_the_pass()\n\n   For passes working on individual functions, all of the above is done\n   per-function.\n\n   To connect to a specific pass, you can simply add a conditional based on the\n   name of the pass::\n\n      import gcc\n\n      def my_callback(ps, fun):\n          if ps.name != '*warn_function_return':\n\t      # Not the pass we want\n\t      return\n\t  # Do something here\n\t  print(fun.decl.name)\n\n      gcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                            my_callback)\n\n\n.. py:data:: gcc.PLUGIN_PRE_GENERICIZE\n\n   Arguments passed to the callback are:\n\n      (`fndecl`, `*extraargs`, `**kwargs`)\n\n   where `fndecl` is a :py:class:`gcc.Tree` representing a function declaration\n   within the source code being compiled.\n\n.. py:data:: gcc.PLUGIN_FINISH_UNIT\n\n   Called when GCC has finished compiling a particular translation unit.\n\n   Arguments passed to the callback are:\n\n      (`*extraargs`, `**kwargs`)\n\n.. py:data:: gcc.PLUGIN_FINISH_DECL\n\n   .. note:: Only available in GCC 4.7 onwards.\n\n   Called when GCC has finished compiling a declaration (variables,\n   functions, parameters to functions, types, etc)\n\n   Arguments passed to the callback are:\n\n      (`decl`, `*extraargs`, `**kwargs`)\n\n   where `decl` is a :py:class:`gcc.Declaration`.\n\n.. py:data:: gcc.PLUGIN_FINISH_TYPE\n\n   Called when GCC has finished parsing a type.  Arguments to the\n   callback are:\n\n      (`type`, `*extraargs`, `**kwargs`)\n\n   where `type` is a :py:class:`gcc.Type`.\n\n.. py:data:: gcc.PLUGIN_FINISH\n\n   Called before GCC exits.\n\n   Arguments passed to the callback are:\n\n      (`*extraargs`, `**kwargs`)\n\nThe remaining GCC events aren't yet usable from the plugin; an attempt to\nregister a callback on them will lead to an exception being raised. Email\nthe `gcc-python-plugin's mailing list\n<https://fedorahosted.org/mailman/listinfo/gcc-python-plugin/>`_ if you're\ninterested in working with these):\n\n===============================================  =========\nID                                               Meaning\n===============================================  =========\n:py:data:`gcc.PLUGIN_PASS_MANAGER_SETUP`         To hook into pass manager\n:py:data:`gcc.PLUGIN_INFO`                       Information about the plugin\n:py:data:`gcc.PLUGIN_GGC_START`                  For interacting with GCC's garbage collector\n:py:data:`gcc.PLUGIN_GGC_MARKING`                (ditto)\n:py:data:`gcc.PLUGIN_GGC_END`                    (ditto)\n:py:data:`gcc.PLUGIN_REGISTER_GGC_ROOTS`         (ditto)\n:py:data:`gcc.PLUGIN_REGISTER_GGC_CACHES`        (ditto)\n:py:data:`gcc.PLUGIN_START_UNIT`                 Called before processing a translation unit (aka source file)\n:py:data:`gcc.PLUGIN_PRAGMAS`                    For registering pragmas\n:py:data:`gcc.PLUGIN_ALL_PASSES_START`           Called before the first pass of the :ref:`\"all other passes\" gcc.Pass catchall <all_passes>`\n:py:data:`gcc.PLUGIN_ALL_PASSES_END`             Called after last pass of the :ref:`\"all other passes\" gcc.Pass catchall <all_passes>`\n:py:data:`gcc.PLUGIN_ALL_IPA_PASSES_START`       Called before the first IPA pass\n:py:data:`gcc.PLUGIN_ALL_IPA_PASSES_END`         Called after last IPA pass\n:py:data:`gcc.PLUGIN_OVERRIDE_GATE`              Provides a way to disable a built-in pass\n:py:data:`gcc.PLUGIN_EARLY_GIMPLE_PASSES_START`\n:py:data:`gcc.PLUGIN_EARLY_GIMPLE_PASSES_END`\n:py:data:`gcc.PLUGIN_NEW_PASS`\n===============================================  =========\n\n.. Notes on the other callback events\n\n   .. py:data:: gcc.PLUGIN_PRAGMAS\n\n    gcc_data=0x0\n    Called from: c_common_init () at ../../gcc/c-family/c-opts.c:1052\n\n   .. py:data:: gcc.PLUGIN_START_UNIT\n\n    gcc_data=0x0\n    Called from: compile_file () at ../../gcc/toplev.c:573\n\n   .. py:data:: gcc.PLUGIN_PRE_GENERICIZE\n\n    gcc_data is:  tree fndecl;\n    Called from: finish_function () at ../../gcc/c-decl.c:8323\n\n   .. py:data:: gcc.PLUGIN_OVERRIDE_GATE\n\n    gcc_data::\n\n      &gate_status\n      bool gate_status;\n\n    Called from : execute_one_pass (pass=0x1011340) at ../../gcc/passes.c:1520\n\n   .. py:data:: gcc.PLUGIN_ALL_IPA_PASSES_START\n\n    gcc_data=0x0\n    Called from: ipa_passes () at ../../gcc/cgraphunit.c:1779\n\n   .. py:data:: gcc.PLUGIN_EARLY_GIMPLE_PASSES_START\n\n    gcc_data=0x0\n    Called from: execute_ipa_pass_list (pass=0x1011fa0) at ../../gcc/passes.c:1927\n\n   .. py:data:: gcc.PLUGIN_EARLY_GIMPLE_PASSES_END\n\n    gcc_data=0x0\n    Called from: execute_ipa_pass_list (pass=0x1011fa0) at ../../gcc/passes.c:1930\n\n   .. py:data:: gcc.PLUGIN_ALL_IPA_PASSES_END\n\n    gcc_data=0x0\n    Called from: ipa_passes () at ../../gcc/cgraphunit.c:1821\n\n   .. py:data:: gcc.PLUGIN_ALL_PASSES_START\n\n    gcc_data=0x0\n    Called from: tree_rest_of_compilation (fndecl=0x7ffff16b1f00) at ../../gcc/tree-optimize.c:420\n\n   .. py:data:: gcc.PLUGIN_ALL_PASSES_END\n\n    gcc_data=0x0\n    Called from: tree_rest_of_compilation (fndecl=0x7ffff16b1f00) at ../../gcc/tree-optimize.c:425\n\n   .. py:data:: gcc.PLUGIN_FINISH\n\n    gcc_data=0x0\n    Called from: toplev_main (argc=17, argv=0x7fffffffdfc8) at ../../gcc/toplev.c:1970\n\n   .. py:data:: gcc.PLUGIN_FINISH_TYPE\n\n    gcc_data=tree\n    Called from c_parser_declspecs (parser=0x7fffef559730, specs=0x15296d0, scspec_ok=1 '\\001', typespec_ok=1 '\\001', start_attr_ok=<optimized out>, la=cla_nonabstract_decl) at ../../gcc/c-parser.c:2111\n\n   .. py:data:: gcc.PLUGIN_PRAGMA\n\n    gcc_data=0x0\n    Called from: init_pragma at ../../gcc/c-family/c-pragma.c:1321\n    to  \"Allow plugins to register their own pragmas.\"\n"
  },
  {
    "path": "docs/callgraph.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nInterprocedural analysis (IPA)\n==============================\nGCC builds a \"call graph\", recording which functions call which other\nfunctions, and it uses this for various optimizations.\n\nIt is constructed by the `\"*build_cgraph_edges\"` pass.\n\nIn case it's of interest, it is available via the following Python API:\n\n.. py:function:: gcc.get_callgraph_nodes()\n\n   Get a list of all :py:class:`gcc.CallgraphNode` instances\n\n.. py:function:: gccutils.callgraph_to_dot()\n\n   Return the GraphViz source for a rendering of the current callgraph, as a\n   string.\n\n   Here's an example of such a rendering:\n\n   .. figure:: sample-callgraph.png\n      :alt: image of a call graph\n\n.. py:class:: gcc.CallgraphNode\n\n   .. py:attribute:: decl\n\n      The :py:class:`gcc.FunctionDecl` for this node within the callgraph\n\n   .. py:attribute:: callees\n\n      The function calls made by this function, as a list of :py:class:`gcc.CallgraphEdge` instances\n\n   .. py:attribute:: callers\n\n      The places that call this function, as a list of :py:class:`gcc.CallgraphEdge` instances\n\n   Internally, this wraps a `struct cgraph_node *`\n\n.. py:class:: gcc.CallgraphEdge\n\n   .. py:attribute:: caller\n\n      The function that makes this call, as a :py:class:`gcc.CallgraphNode`\n\n   .. py:attribute:: callee\n\n      The function that is called here, as a :py:class:`gcc.CallgraphNode`\n\n   .. py:attribute:: call_stmt\n\n      The :py:class:`gcc.GimpleCall` statememt for the function call\n\n   Internally, this wraps a `struct cgraph_edge *`\n"
  },
  {
    "path": "docs/cfg.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nWorking with functions and control flow graphs\n==============================================\n\nMany of the plugin events are called for each function within the source code\nbeing compiled.  Each time, the plugin passes a :py:class:`gcc.Function`\ninstance as a parameter to your callback, so that you can work on it.\n\nYou can get at the control flow graph of a :py:class:`gcc.Function` via its\n``cfg`` attribute.  This is an instance of :py:class:`gcc.Cfg`.\n\n.. py:class:: gcc.Function\n\n   Wrapper around one of GCC's ``struct function *``\n\n   .. py:attribute:: cfg\n\n      An instance of :py:class:`gcc.Cfg` for this function (or None during early\n      passes)\n\n   .. py:attribute:: decl\n\n      The declaration of this function, as a :py:class:`gcc.FunctionDecl`\n\n   .. py:attribute:: local_decls\n\n      List of :py:class:`gcc.VarDecl` for the function's local variables.  It\n      does not contain arguments; for those see the `arguments` property of\n      the function's `decl`.\n\n      Note that for locals with initializers, `initial` only seems to get set\n      on those `local_decls` that are static variables.  For other locals, it\n      appears that you have to go into the gimple representation to locate\n      assignments.\n\n   .. py:attribute:: start\n\n      The :py:class:`gcc.Location` of the beginning of the function\n\n   .. py:attribute:: end\n\n      The :py:class:`gcc.Location` of the end of the function\n\n   .. py:attribute:: funcdef_no\n\n      Integer: a sequence number for profiling, debugging, etc.\n\n.. py:class:: gcc.Cfg\n\n  A ``gcc.Cfg`` is a wrapper around GCC's `struct control_flow_graph`.\n\n  .. py:attribute:: basic_blocks\n\n     List of :py:class:`gcc.BasicBlock`, giving all of the basic blocks within\n     this CFG\n\n  .. py:attribute:: entry\n\n     Instance of :py:class:`gcc.BasicBlock`: the entrypoint for this CFG\n\n  .. py:attribute:: exit\n\n     Instance of :py:class:`gcc.BasicBlock`: the final one within this CFG\n\n  .. py:method:: get_block_for_label(labeldecl)\n\n     Given a :py:class:`gcc.LabelDecl`, get the corresponding\n     :py:class:`gcc.BasicBlock`\n\n  You can use ``gccutils.cfg_to_dot`` to render a gcc.Cfg as a graphviz\n  diagram.  It will render the diagram, showing each basic block, with\n  source code on the left-hand side, interleaved with the \"gimple\"\n  representation on the right-hand side.  Each block is labelled with its\n  index, and edges are labelled with appropriate flags.\n\n  For example, given this sample C code:\n\n    .. literalinclude:: ../test.c\n      :lines: 33-48\n      :language: c\n\n  then the following Python code::\n\n    dot = gccutils.cfg_to_dot(fun.cfg)\n    gccutils.invoke_dot(dot)\n\n  will render a CFG bitmap like this:\n\n    .. figure:: sample-gimple-cfg.png\n      :scale: 50 %\n      :alt: image of a control flow graph\n\n.. py:class:: gcc.BasicBlock\n\n  A ``gcc.BasicBlock`` is a wrapper around GCC's `basic_block` type.\n\n  .. py:attribute:: index\n\n     The index of the block (an int), as seen in the cfg_to_dot rendering.\n\n  .. py:attribute:: preds\n\n     The list of predecessor :py:class:`gcc.Edge` instances leading into this\n     block\n\n  .. py:attribute:: succs\n\n     The list of successor :py:class:`gcc.Edge` instances leading out of this\n     block\n\n  .. py:attribute:: phi_nodes\n\n     The list of :py:class:`gcc.GimplePhi` phoney functions at the top of this\n     block, if appropriate for this pass, or None\n\n  .. py:attribute:: gimple\n\n     The list of :py:class:`gcc.Gimple` instructions, if appropriate for this\n     pass, or None\n\n  .. py:attribute:: rtl\n\n     The list of :py:class:`gcc.Rtl` expressions, if appropriate for this\n     pass, or None\n\n\n.. py:class:: gcc.Edge\n\n  A wrapper around GCC's `edge` type.\n\n  .. py:attribute:: src\n\n     The source :py:class:`gcc.BasicBlock` of this edge\n\n  .. py:attribute:: dest\n\n     The destination :py:class:`gcc.BasicBlock` of this edge\n\n  .. py:attribute:: true_value\n\n     Boolean: `True` if this edge is taken when a :py:class:`gcc.GimpleCond`\n     conditional is true, `False` otherwise\n\n  .. py:attribute:: false_value\n\n     Boolean: `True` if this edge is taken when a :py:class:`gcc.GimpleCond`\n     conditional is false, `False` otherwise\n\n  .. py:attribute:: complex\n\n     Boolean: `True` if this edge is \"special\" e.g. due to\n     exception-handling, or some other kind of \"strange\" control flow transfer,\n     `False` otherwise\n\n  .. various other EDGE_ booleans, though it's not clear that they should be\n     documented\n"
  },
  {
    "path": "docs/conf.py",
    "content": "#   Copyright 2011, 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# -*- coding: utf-8 -*-\n#\n# gcc-python-plugin documentation build configuration file, created by\n# sphinx-quickstart on Wed Jun  1 15:53:48 2011.\n#\n# This file is execfile()d with the current directory set to its containing dir.\n#\n# Note that not all possible configuration values are present in this\n# autogenerated file.\n#\n# All configuration values have a default; values that are commented out\n# serve to show the default.\n\nimport sys, os\n\n# If extensions (or modules to document with autodoc) are in another directory,\n# add these directories to sys.path here. If the directory is relative to the\n# documentation root, use os.path.abspath to make it absolute, like shown here.\n#sys.path.insert(0, os.path.abspath('.'))\n\n# -- General configuration -----------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#needs_sphinx = '1.0'\n\n# Add any Sphinx extension module names here, as strings. They can be extensions\n# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.\nextensions = []\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = ['_templates']\n\n# The suffix of source filenames.\nsource_suffix = '.rst'\n\n# The encoding of source files.\n#source_encoding = 'utf-8-sig'\n\n# The master toctree document.\nmaster_doc = 'index'\n\n# General information about the project.\nproject = u'gcc-python-plugin'\ncopyright = u'2011-2019, David Malcolm'\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = '0.17'\n# The full version, including alpha/beta/rc tags.\nrelease = '0.17'\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#language = None\n\n# There are two options for replacing |today|: either, you set today to some\n# non-false value, then it is used:\n#today = ''\n# Else, today_fmt is used as the format for a strftime call.\n#today_fmt = '%B %d, %Y'\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\nexclude_patterns = ['_build']\n\n# The reST default role (used for this markup: `text`) to use for all documents.\n#default_role = None\n\n# If true, '()' will be appended to :func: etc. cross-reference text.\n#add_function_parentheses = True\n\n# If true, the current module name will be prepended to all description\n# unit titles (such as .. function::).\n#add_module_names = True\n\n# If true, sectionauthor and moduleauthor directives will be shown in the\n# output. They are ignored by default.\n#show_authors = False\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = 'sphinx'\n\n# A list of ignored prefixes for module index sorting.\n#modindex_common_prefix = []\n\n\n# -- Options for HTML output ---------------------------------------------------\n\n# The theme to use for HTML and HTML Help pages.  See the documentation for\n# a list of builtin themes.\nhtml_theme = 'default'\n\n# Theme options are theme-specific and customize the look and feel of a theme\n# further.  For a list of options available for each theme, see the\n# documentation.\n#html_theme_options = {}\n\n# Add any paths that contain custom themes here, relative to this directory.\n#html_theme_path = []\n\n# The name for this set of Sphinx documents.  If None, it defaults to\n# \"<project> v<release> documentation\".\n#html_title = None\n\n# A shorter title for the navigation bar.  Default is the same as html_title.\n#html_short_title = None\n\n# The name of an image file (relative to this directory) to place at the top\n# of the sidebar.\n#html_logo = None\n\n# The name of an image file (within the static path) to use as favicon of the\n# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32\n# pixels large.\n#html_favicon = None\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = ['_static']\n\n# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,\n# using the given strftime format.\n#html_last_updated_fmt = '%b %d, %Y'\n\n# If true, SmartyPants will be used to convert quotes and dashes to\n# typographically correct entities.\n#html_use_smartypants = True\n\n# Custom sidebar templates, maps document names to template names.\n#html_sidebars = {}\n\n# Additional templates that should be rendered to pages, maps page names to\n# template names.\n#html_additional_pages = {}\n\n# If false, no module index is generated.\n#html_domain_indices = True\n\n# If false, no index is generated.\n#html_use_index = True\n\n# If true, the index is split into individual pages for each letter.\n#html_split_index = False\n\n# If true, links to the reST sources are added to the pages.\n#html_show_sourcelink = True\n\n# If true, \"Created using Sphinx\" is shown in the HTML footer. Default is True.\n#html_show_sphinx = True\n\n# If true, \"(C) Copyright ...\" is shown in the HTML footer. Default is True.\n#html_show_copyright = True\n\n# If true, an OpenSearch description file will be output, and all pages will\n# contain a <link> tag referring to it.  The value of this option must be the\n# base URL from which the finished HTML is served.\n#html_use_opensearch = ''\n\n# This is the file name suffix for HTML files (e.g. \".xhtml\").\n#html_file_suffix = None\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = 'gcc-python-plugindoc'\n\n\n# -- Options for LaTeX output --------------------------------------------------\n\n# The paper size ('letter' or 'a4').\n#latex_paper_size = 'letter'\n\n# The font size ('10pt', '11pt' or '12pt').\n#latex_font_size = '10pt'\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title, author, documentclass [howto/manual]).\nlatex_documents = [\n  ('index', 'gcc-python-plugin.tex', u'gcc-python-plugin Documentation',\n   u'David Malcolm', 'manual'),\n]\n\n# The name of an image file (relative to this directory) to place at the top of\n# the title page.\n#latex_logo = None\n\n# For \"manual\" documents, if this is true, then toplevel headings are parts,\n# not chapters.\n#latex_use_parts = False\n\n# If true, show page references after internal links.\n#latex_show_pagerefs = False\n\n# If true, show URL addresses after external links.\n#latex_show_urls = False\n\n# Additional stuff for the LaTeX preamble.\n#latex_preamble = ''\n\n# Documents to append as an appendix to all manuals.\n#latex_appendices = []\n\n# If false, no module index is generated.\n#latex_domain_indices = True\n\n\n# -- Options for manual page output --------------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [\n    ('index', 'gcc-python-plugin', u'gcc-python-plugin Documentation',\n     [u'David Malcolm'], 1),\n    ('gcc-with-python', 'gcc-with-python', u'Run GCC whilst invoking a Python script',\n     [u'David Malcolm'], 1)\n]\n\n# -- Options for Texinfo output ------------------------------------------------\n\ntexinfo_documents = [\n    (master_doc, 'gcc-python-plugin', 'gcc-python-plugin Documentation',\n     'David Malcolm', 'gcc-python-plugin', 'gcc-python-plugin Documentation',\n     'Software development', False)\n]\n"
  },
  {
    "path": "docs/cpychecker.rst",
    "content": ".. Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. _cpychecker:\n\nUsage example: a static analysis tool for CPython extension code\n================================================================\n\n.. note:: This code is under heavy development, and still contains bugs.  It\n   is not unusual to see Python tracebacks when running the checker.  You\n   should verify what the checker reports before acting on it: it could be\n   wrong.\n\nAn example of using the plugin is a static analysis tool I'm working on which\nchecks the C source of CPython extension modules for common coding errors.\n\nThis was one of my main motivations for writing the GCC plugin, and I often\nneed to extend the plugin to support this use case.\n\nFor this reason, the checker is embedded within the gcc-python source tree\nitself for now:\n\n   * `gcc-with-cpychecker` is a harness script, which invokes GCC, adding\n     the arguments necessary to use the Python plugin, using the\n     `libcpychecker` Python code\n\n   * the `libcpychecker` subdirectory contains the code that does the actual\n     work\n\n   * various test cases (in the source tree, below `tests/cpychecker`)\n\ngcc-with-cpychecker\n-------------------\n`gcc-with-cpychecker` is a harness script, which invokes GCC, adding\nthe arguments necessary to use the Python plugin, using the\n`libcpychecker` Python code\n\nYou should be able to use the checker on arbitrary CPython extension\ncode by replacing \"gcc\" with \"gcc-with-cpychecker\" in your build with\nsomething like::\n\n   make CC=/path/to/built/plugin/gcc-with-cpychecker\n\nto override the Makefile variable `CC`.\n\nYou may need to supply an absolute path, especially if the \"make\" recursively\ninvokes \"make\" within subdirectories (thus having a different working\ndirectory).\n\nSimilarly, for projects that use `distutils\n<http://docs.python.org/library/distutils.html>`_, the code is typically built\nwith an invocation like this::\n\n   python setup.py build\n\nThis respects the environment variable `CC`, so typically you can replace the\nabove with something like this in order to add the additional checks::\n\n   CC=/path/to/built/plugin/gcc-with-cpychecker python setup.py build\n\nAdditional arguments for `gcc-with-cpychecker`\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n.. program:: gcc-with-cpychecker\n\n.. cmdoption:: --maxtrans <int>\n\n   Set the maximum number of transitions to consider within each function\n   before pruning the analysis tree.  You may need to increase this limit\n   for complicated functions.\n\n.. cmdoption:: --dump-json\n\n   Dump a JSON representation of any problems.  For example, given a function\n   `foo.c`, if any warnings or errors are found in function `bar`, a file\n   `foo.c.bar.json` will be written out in JSON form.\n\n\nReference-count checking\n------------------------\nThe checker attempts to analyze all possible paths through each function,\ntracking the various ``PyObject*`` objects encountered.\n\nFor each path through the function and ``PyObject*``, it determines what the\nreference count ought to be at the end of the function, issuing warnings for\nany that are incorrect.\n\nThe warnings are in two forms: the classic textual output to GCC's standard\nerror stream, together with an HTML report indicating the flow through the\nfunction, in graphical form.\n\nFor example, given this buggy C code:\n\n.. code-block:: c\n\n   PyObject *\n   test(PyObject *self, PyObject *args)\n   {\n       PyObject *list;\n       PyObject *item;\n       list = PyList_New(1);\n       if (!list)\n           return NULL;\n       item = PyLong_FromLong(42);\n       /* This error handling is incorrect: it's missing an\n          invocation of Py_DECREF(list): */\n       if (!item)\n           return NULL;\n       /* This steals a reference to item; item is not leaked when we get here: */\n       PyList_SetItem(list, 0, item);\n       return list;\n   }\n\nthe checker emits these messages to stderr::\n\n   input.c: In function 'test':\n   input.c:38:1: warning: ob_refcnt of '*list' is 1 too high [enabled by default]\n   input.c:38:1: note: was expecting final ob_refcnt to be N + 0 (for some unknown N)\n   input.c:38:1: note: but final ob_refcnt is N + 1\n   input.c:27:10: note: PyListObject allocated at:     list = PyList_New(1);\n   input.c:27:10: note: when PyList_New() succeeds at:     list = PyList_New(1);\n   input.c:27:10: note: ob_refcnt is now refs: 1 + N where N >= 0\n   input.c:28:8: note: taking False path at:     if (!list)\n   input.c:30:10: note: reaching:     item = PyLong_FromLong(42);\n   input.c:30:10: note: when PyLong_FromLong() fails at:     item = PyLong_FromLong(42);\n   input.c:33:8: note: taking True path at:     if (!item)\n   input.c:34:9: note: reaching:         return NULL;\n   input.c:38:1: note: returning\n   input.c:24:1: note: graphical error report for function 'test' written out to 'input.c.test-refcount-errors.html'\n\nalong with this HTML report (as referred to by the final line on stderr):\n\n   .. figure:: sample-html-error-report.png\n      :alt: screenshot of the HTML report\n\nThe HTML report is intended to be relatively self-contained, and thus easy to\nattach to bug tracking systems (it embeds its own CSS inline, and references\nthe JavaScript it uses via URLs to the web).\n\n.. note:: The arrow graphics in the HTML form of the report are added by using\n   the JSPlumb JavaScript library to generate HTML 5 <canvas> elements.  You\n   may need a relatively modern browser to see them.\n\n.. note:: The checker tracks reference counts in an abstract way, in two parts:\n   a part of the reference count that it knows about within the context of the\n   function, along with a second part: all of the other references held by the\n   rest of the program.\n\n   For example, in a call to PyInt_FromLong(0), it is assumed that if the call\n   succeeds, the object has a reference count of 1 + N, where N is some unknown\n   amount of other references held by the rest of the program.   The checker\n   knows that N >= 0.\n\n   If the object is then stored in an opaque container which is known to\n   increment the reference count, the checker can say that the reference count\n   is then 1 + (N+1).\n\n   If the function then decrements the reference count (to finish transferring\n   the reference to the opaque container), the checker now treats the object as\n   having a reference count of 0 + (N+1): it no longer owns any references on\n   the object, but the reference count is actually unchanged relative to the\n   original 1 + N amount.  It also knows, given that N >= 0 that the actual\n   reference count is >= 1, and thus the object won't (yet) be deallocated.\n\nAssumptions and configuration\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\nFor any function returning a ``PyObject*``, it assumes that the ``PyObject*``\nshould be either a new reference to an object, or NULL (with an exception set)\n- the function's caller should \"own\" a reference to that object.  For all\nother ``PyObject*``, it assumes that there should be no references owned by the\nfunction when the function terminates.\n\nIt will assume this behavior for any function (or call through a function\npointer) that returns a ``PyObject*``.\n\nIt is possible to override this behavior using custom compiler attributes as\nfollows:\n\nMarking functions that return borrowed references\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe checker provides a custom GCC attribute:\n\n.. code-block:: c\n\n   __attribute__((cpychecker_returns_borrowed_ref))\n\nwhich can be used to mark function declarations:\n\n.. code-block:: c\n\n  /* The checker automatically defines this preprocessor name when creating\n     the custom attribute: */\n  #if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)\n    #define CPYCHECKER_RETURNS_BORROWED_REF \\\n      __attribute__((cpychecker_returns_borrowed_ref))\n  #else\n    #define CPYCHECKER_RETURNS_BORROWED_REF\n  #endif\n\n  PyObject *foo(void)\n    CPYCHECKER_RETURNS_BORROWED_REF;\n\nGiven the above, the checker will assume that invocations of ``foo()`` are\nreturning a borrowed reference (or NULL), rather than a new reference.  It\nwill also check that this is that case when verifying the implementation of\n``foo()`` itself.\n\nMarking functions that steal references to their arguments\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nThe checker provides a custom GCC attribute:\n\n.. code-block:: c\n\n     __attribute__((cpychecker_steals_reference_to_arg(n)))\n\nwhich can be used to mark function declarations:\n\n.. code-block:: c\n\n  /* The checker automatically defines this preprocessor name when creating\n     the custom attribute: */\n  #if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)\n    #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \\\n     __attribute__((cpychecker_steals_reference_to_arg(n)))\n  #else\n   #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)\n  #endif\n\n  extern void foo(PyObject *obj)\n    CPYCHECKER_STEALS_REFERENCE_TO_ARG(1);\n\nGiven the above, the checker will assume that invocations of ``foo()`` steal\na reference to the first argument (``obj``).  It will also verify that this is\nthe case when analyzing the implementation of ``foo()`` itself.\n\nMore then one argument can be marked:\n\n.. code-block:: c\n\n  extern void bar(int i, PyObject *obj, int j, PyObject *other)\n    CPYCHECKER_STEALS_REFERENCE_TO_ARG(2)\n    CPYCHECKER_STEALS_REFERENCE_TO_ARG(4);\n\nThe argument indices are 1-based (the above example is thus referring to\n``obj`` and to ``other``).\n\nAll such arguments to the attribute should be ``PyObject*`` (or a pointer to a\nderived structure type).\n\nIt is assumed that such references are stolen for all possible outcomes of the\nfunction - if a function can either succeed or fail, the reference is stolen in\nboth possible worlds.\n\nError-handling checking\n-----------------------\nThe checker has knowledge of much of the CPython C API, and will generate\na trace tree containing many of the possible error paths.   It will issue\nwarnings for code that appears to not gracefully handle an error.\n\n(TODO: show example)\n\nAs noted above, it assumes that any function that returns a ``PyObject*`` can\nreturn can either NULL (setting an exception), or a new reference.  It knows\nabout much of the other parts of the CPython C API, including many other\nfunctions that can fail.\n\nThe checker will emit warnings for various events:\n\n  * if it detects a dereferencing of a ``NULL`` value\n\n  * if a ``NULL`` value is erroneously passed to various CPython API\n    entrypoints which are known to implicitly dereference those arguments\n    (which would lead to a segmentation fault if that code path were executed)::\n\n      input.c: In function 'test':\n      input.c:38:33: warning: calling PyString_AsString with NULL (gcc.VarDecl('repr_args')) as argument 1 at input.c:38\n      input.c:31:15: note: when PyObject_Repr() fails at:     repr_args = PyObject_Repr(args);\n      input.c:38:33: note: PyString_AsString() invokes Py_TYPE() on the pointer via the PyString_Check() macro, thus accessing (NULL)->ob_type\n      input.c:27:1: note: graphical error report for function 'test' written out to 'input.c.test-refcount-errors.html'\n\n  * if it detects that an uninitialized local variable has been used\n\n  * if it detects access to an object that has been deallocated, or such an\n    object being returned::\n\n       input.c: In function 'test':\n       input.c:43:1: warning: returning pointer to deallocated memory\n       input.c:29:15: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\n       input.c:31:8: note: taking False path at:     if (!tmp) {\n       input.c:39:5: note: reaching:     Py_DECREF(tmp);\n       input.c:39:5: note: when taking False path at:     Py_DECREF(tmp);\n       input.c:39:5: note: reaching:     Py_DECREF(tmp);\n       input.c:39:5: note: calling tp_dealloc on PyLongObject allocated at input.c:29 at:     Py_DECREF(tmp);\n       input.c:42:5: note: reaching:     return tmp;\n       input.c:43:1: note: returning\n       input.c:39:5: note: memory deallocated here\n       input.c:27:1: note: graphical error report for function 'returning_dead_object' written out to 'input.c.test.html'\n\nErrors in exception-handling\n----------------------------\nThe checker keeps track of the per-thread exception state.  It will issue a\nwarning about any paths through functions returning a ``PyObject*`` that return\nNULL for which the per-thread exception state has not been set::\n\n   input.c: In function 'test':\n   input.c:32:5: warning: returning (PyObject*)NULL without setting an exception\n\nThe checker does not emit the warning for cases where it is known that such\nbehavior is acceptable.  Currently this covers functions used as `tp_iternext\n<http://docs.python.org/c-api/typeobj.html#tp_iternext>`_ callbacks of a\n``PyTypeObject``.\n\nIf you have a helper function that always sets an exception, you can mark this\nproperty using a custom GCC attribute:\n\n.. code-block:: c\n\n    __attribute__((cpychecker_sets_exception))\n\nwhich can be used to mark function declarations.\n\n.. code-block:: c\n\n  /* The checker automatically defines this preprocessor name when creating\n     the custom attribute: */\n   #if defined(WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE)\n     #define CPYCHECKER_SETS_EXCEPTION \\\n        __attribute__((cpychecker_sets_exception))\n   #else\n     #define CPYCHECKER_SETS_EXCEPTION\n   #endif\n\n   extern void raise_error(const char *msg)\n     CPYCHECKER_SETS_EXCEPTION;\n\nGiven the above, the checker will know that an exception is set whenever a\ncall to `raise_error()` occurs.  It will also verify that `raise_error()`\nactually behaves this way when compiling the implementation of `raise_error`.\n\nThere is an analogous attribute for the case where a function returns a\nnegative value to signify an error, where the exception state is set whenever\na **negative** value is returned:\n\n.. code-block:: c\n\n    __attribute__((cpychecker_negative_result_sets_exception))\n\nwhich can be used to mark function declarations.\n\n.. code-block:: c\n\n  /* The checker automatically defines this preprocessor name when creating\n     the custom attribute: */\n   #if defined(WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE)\n     #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION \\\n        __attribute__((cpychecker_negative_result_sets_exception))\n   #else\n     #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION\n   #endif\n\n   extern int foo(void)\n     CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION;\n\nGiven the above, the checker will know that an exception is raised whenever a\ncall to `foo` returns a negative value.  It will also verify that `foo`\nactually behaves this way when compiling the implementation of `foo`.\n\nThe checker already knows about many of the functions within the CPython API\nwhich behave this way.\n\nFormat string checking\n----------------------\n\nThe checker will analyze some `Python APIs that take format strings\n<http://docs.python.org/c-api/arg.html>`_  and detect mismatches between the\nnumber and types of arguments that are passed in, as compared with those\ndescribed by the format string.\n\nIt currently verifies the arguments to the following API entrypoints:\n\n  * `PyArg_ParseTuple\n    <http://docs.python.org/c-api/arg.html#PyArg_ParseTuple>`_\n\n  * `PyArg_ParseTupleAndKeywords\n    <http://docs.python.org/c-api/arg.html#PyArg_ParseTupleAndKeywords>`_\n\n  * `PyArg_Parse\n    <http://docs.python.org/c-api/arg.html#PyArg_Parse>`_\n\n  * `Py_BuildValue\n    <http://docs.python.org/c-api/arg.html#Py_BuildValue>`_\n\n  * `PyObject_CallFunction\n    <http://docs.python.org/c-api/object.html#PyObject_CallFunction>`_\n\n  * `PyObject_CallMethod\n    <http://docs.python.org/c-api/object.html#PyObject_CallMethod>`_\n\nalong with the variants that occur if you define `PY_SSIZE_T_CLEAN` before\n`#include <Python.h>`.\n\nFor example, type mismatches between ``int`` vs ``long`` can lead to flaws\nwhen the code is compiled on big-endian 64-bit architectures, where\n``sizeof(int) != sizeof(long)`` and the in-memory layout of those types differs\nfrom what you might expect.\n\nThe checker will also issue a warning if the list of keyword arguments in a\ncall to PyArg_ParseTupleAndKeywords is not NULL-terminated.\n\n.. note:: All of the various \"#\" codes in these format strings are affected by\n   the presence of the macro `PY_SSIZE_T_CLEAN`. If the macro was defined\n   before including Python.h, the various lengths for these format codes are of\n   C type `Py_ssize_t` rather than `int`.\n\n   This behavior was clarified in the Python 3 version of the C API\n   documentation, though the Python 2 version of the API docs leave the matter\n   of which codes are affected somewhat ambiguous.\n\n   Nevertheless, the API *does* work this way in Python 2: all format codes\n   with a \"#\" do work this way.\n\n   Internally, the C preprocessor converts such function calls into invocations\n   of:\n\n      * `_PyArg_ParseTuple_SizeT`\n      * `_PyArg_ParseTupleAndKeywords_SizeT`\n\n   The checker handles this behavior correctly, by checking \"#\" codes in the\n   regular functions against `int` and those in the modified functions against\n   `Py_ssize_t`.\n\nAssociating PyTypeObject instances with compile-time types\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe \"O!\" format code to ``PyArg_ParseTuple`` takes a ``PyTypeObject`` followed\nby the address of an object.  This second argument can point to a\n``PyObject*``, but it can also point to a pointer to a derived class.\n\nFor example, CPython's own implementation contains code like this:\n\n.. code-block:: c\n\n  static PyObject *\n  unicodedata_decomposition(PyObject *self, PyObject *args)\n  {\n      PyUnicodeObject *v;\n\n      /* ...snip... */\n\n      if (!PyArg_ParseTuple(args, \"O!:decomposition\",\n                            &PyUnicode_Type, &v))\n\n      /* ...etc... */\n\nin which the input argument is written out into the ``PyUnicodeObject*``,\nprovided that it is indeed a unicode instance.\n\nWhen the cpychecker verifies the types in this format string it verifies that\nthe run-time type of the ``PyTypeObject`` matches the compile-time type\n(``PyUnicodeObject *``).   It is able to do this since it contains hard-coded\nassociations between these worlds for all of Python's built-in types: for the\nabove case, it \"knows\" that ``PyUnicode_Type`` is associated with\n``PyUnicodeObject``.\n\nIf you need to provide a similar association for an extension type, the checker\nprovides a custom GCC attribute:\n\n.. code-block:: c\n\n     __attribute__((cpychecker_type_object_for_typedef(typename)))\n\nwhich can be used to mark PyTypeObject instance, giving the name of the typedef\nthat PyObject instances of that type can be safely cast to.\n\n.. code-block:: c\n\n  /* The checker automatically defines this preprocessor name when creating\n     the custom attribute: */\n  #if defined(WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE)\n    #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(typename) \\\n       __attribute__((cpychecker_type_object_for_typedef(typename)))\n  #else\n    /* This handles the case where we're compiling with a \"vanilla\"\n       compiler that doesn't supply this attribute: */\n    #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(typename)\n  #endif\n\n  /* Define some PyObject subclass, as both a struct and a typedef */\n  struct OurObjectStruct {\n      PyObject_HEAD\n      /* other fields */\n  };\n  typedef struct OurObjectStruct OurExtensionObject;\n\n  /*\n    Declare the PyTypeObject, using the custom attribute to associate it with\n    the typedef above:\n  */\n  extern PyTypeObject UserDefinedExtension_Type\n    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(\"OurExtensionObject\");\n\nGiven the above, the checker will associate the given ``PyTypeObject`` with the\ngiven typedef.\n\n\nVerification of PyMethodDef tables\n----------------------------------\n\nThe checker will verify the types within tables of `PyMethodDef\n<http://docs.python.org/c-api/structures.html#PyMethodDef>`_ initializers: the\ncallbacks are typically cast to ``PyCFunction``, but the exact type needs to\ncorrespond to the flags given.  For example ``(METH_VARARGS | METH_KEYWORDS)``\nimplies a different function signature to the default, which the vanilla C\ncompiler has no way of verifying.\n\n.. code-block:: c\n\n   /*\n     BUG: there's a mismatch between the signature of the callback and\n     that implied by ml_flags below.\n    */\n   static PyObject *widget_display(PyObject *self, PyObject *args);\n\n   static PyMethodDef widget_methods[] = {\n       {\"display\",\n        (PyCFunction)widget_display,\n        (METH_VARARGS | METH_KEYWORDS), /* ml_flags */\n        NULL},\n\n       {NULL, NULL, 0, NULL} /* terminator */\n   };\n\nGiven the above, the checker will emit an error like this::\n\n   input.c:59:6: warning: flags do not match callback signature for 'widget_display' within PyMethodDef table\n   input.c:59:6: note: expected ml_meth callback of type \"PyObject (fn)(someobject *, PyObject *args, PyObject *kwargs)\" due to METH_KEYWORDS flag (3 arguments)\n   input.c:59:6: note: actual type of underlying callback: struct PyObject * <Tc53> (struct PyObject *, struct PyObject *) (2 arguments)\n   input.c:59:6: note: see http://docs.python.org/c-api/structures.html#PyMethodDef\n\nIt will also warn about tables of ``PyMethodDef`` initializers that are\nlacking a ``NULL`` sentinel value to terminate the iteration:\n\n.. code-block:: c\n\n   static PyMethodDef widget_methods[] = {\n       {\"display\",\n        (PyCFunction)widget_display,\n        0, /* ml_flags */\n        NULL},\n\n       /* BUG: this array is missing a NULL value to terminate\n          the list of methods, leading to a possible segfault\n          at run-time */\n   };\n\nGiven the above, the checker will emit this warning::\n\n  input.c:39:6: warning: missing NULL sentinel value at end of PyMethodDef table\n\nAdditional tests\n----------------\n\n* the checker will verify the argument lists of invocations of\n  `PyObject_CallFunctionObjArgs\n  <http://docs.python.org/c-api/object.html#PyObject_CallFunctionObjArgs>`_ and\n  `PyObject_CallMethodObjArgs\n  <http://docs.python.org/c-api/object.html#PyObject_CallMethodObjArgs>`_,\n  checking that all of the arguments are of the correct type\n  (PyObject* or subclasses), and that the list is NULL-terminated::\n\n     input.c: In function 'test':\n     input.c:33:5: warning: argument 2 had type char[12] * but was expecting a PyObject* (or subclass)\n     input.c:33:5: warning: arguments to PyObject_CallFunctionObjArgs were not NULL-terminated\n\nLimitations and caveats\n-----------------------\n\nCompiling with the checker is significantly slower than with \"vanilla\" gcc.\nI have been focussing on correctness and features, rather than optimization.\nI hope that it will be possible to greatly speed up the checker via\nahead-of-time compilation of the Python code (e.g. using Cython).\n\nThe checker does not yet fully implement all of C: expect to see Python\ntracebacks when it encounters less common parts of the language.  (We'll fix\nthose bugs as we come to them)\n\nThe checker has a rather simplistic way of tracking the flow through a\nfunction: it builds a tree of all possible traces of execution through a\nfunction.  This brings with it some shortcomings:\n\n  * In order to guarantee that the analysis terminates, the checker will only\n    track the first time through any loop, and stop analysing that trace for\n    subsequent iterations.  This appears to be good enough for detecting many\n    kinds of reference leaks, especially in simple wrapper code, but is clearly\n    suboptimal.\n\n  * In order to avoid combinatorial explosion, the checker will stop analyzing\n    a function once the trace tree gets sufficiently large.  When it reaches\n    this cutoff, a warning is issued::\n\n      input.c: In function 'add_module_objects':\n      input.c:31:1: note: this function is too complicated for the reference-count checker to analyze\n\n    To increase this limit, see the :option:`--maxtrans` option.\n\n  * The checker doesn't yet match up similar traces, and so a single bug that\n    affects multiple traces in the trace tree can lead to duplicate error\n    reports.\n\nOnly a subset of the CPython API has been modelled so far.  The functions\nknown to the checker are:\n\n`PyArg_Parse and _PyArg_Parse_SizeT <http://docs.python.org/c-api/arg.html#PyArg_Parse>`_,\n`PyArg_ParseTuple and _PyArg_ParseTuple_SizeT <http://docs.python.org/c-api/arg.html#PyArg_ParseTuple>`_,\n`PyArg_ParseTupleAndKeywords and _PyArg_ParseTupleAndKeywords_SizeT <http://docs.python.org/c-api/arg.html#PyArg_ParseTupleAndKeywords>`_,\n`PyArg_UnpackTuple <http://docs.python.org/c-api/arg.html#PyArg_UnpackTuple>`_,\n`Py_AtExit <http://docs.python.org/c-api/sys.html#Py_AtExit>`_,\n`PyBool_FromLong <http://docs.python.org/c-api/bool.html#PyBool_FromLong>`_,\n`Py_BuildValue and _Py_BuildValue_SizeT <http://docs.python.org/c-api/arg.html#Py_BuildValue>`_,\n`PyCallable_Check <http://docs.python.org/c-api/object.html#PyCallable_Check>`_,\n`PyCapsule_GetPointer <http://docs.python.org/c-api/capsule.html#PyCapsule_GetPointer>`_,\n`PyCObject_AsVoidPtr <http://docs.python.org/c-api/cobject.html#PyCObject_AsVoidPtr>`_,\n`PyCObject_FromVoidPtr <http://docs.python.org/c-api/cobject.html#PyCObject_FromVoidPtr>`_,\n`PyCObject_FromVoidPtrAndDesc <http://docs.python.org/c-api/cobject.html#PyCObject_FromVoidPtrAndDesc>`_,\n`PyCode_New <http://docs.python.org/c-api/code.html#PyCode_New>`_,\n`PyDict_GetItem <http://docs.python.org/c-api/dict.html#PyDict_GetItem>`_,\n`PyDict_GetItemString <http://docs.python.org/c-api/dict.html#PyDict_GetItemString>`_,\n`PyDict_New <http://docs.python.org/c-api/dict.html#PyDict_New>`_,\n`PyDict_SetItem <http://docs.python.org/c-api/dict.html#PyDict_SetItem>`_,\n`PyDict_SetItemString <http://docs.python.org/c-api/dict.html#PyDict_SetItemString>`_,\n`PyDict_Size <http://docs.python.org/c-api/dict.html#PyDict_Size>`_,\n`PyErr_Format <http://docs.python.org/c-api/exceptions.html#PyErr_Format>`_,\n`PyErr_NewException <http://docs.python.org/c-api/exceptions.html#PyErr_NewException>`_,\n`PyErr_NoMemory <http://docs.python.org/c-api/exceptions.html#PyErr_NoMemory>`_,\n`PyErr_Occurred <http://docs.python.org/c-api/exceptions.html#PyErr_Occurred>`_,\n`PyErr_Print <http://docs.python.org/c-api/exceptions.html#PyErr_Print>`_,\n`PyErr_PrintEx <http://docs.python.org/c-api/exceptions.html#PyErr_PrintEx>`_,\n`PyErr_SetFromErrno <http://docs.python.org/c-api/exceptions.html#PyErr_SetFromErrno>`_,\n`PyErr_SetFromErrnoWithFilename <http://docs.python.org/c-api/exceptions.html#PyErr_SetFromErrnoWithFilename>`_,\n`PyErr_SetNone <http://docs.python.org/c-api/exceptions.html#PyErr_SetNone>`_,\n`PyErr_SetObject <http://docs.python.org/c-api/exceptions.html#PyErr_SetObject>`_,\n`PyErr_SetString <http://docs.python.org/c-api/exceptions.html#PyErr_SetString>`_,\n`PyErr_WarnEx <http://docs.python.org/c-api/exceptions.html#PyErr_WarnEx>`_,\n`PyEval_CallMethod`,\n`PyEval_CallObjectWithKeywords`,\n`PyEval_InitThreads <http://docs.python.org/c-api/init.html#PyEval_InitThreads>`_,\n`PyEval_RestoreThread <http://docs.python.org/c-api/init.html#PyEval_RestoreThread>`_,\n`PyEval_SaveThread <http://docs.python.org/c-api/init.html#PyEval_SaveThread>`_,\n`Py_FatalError <http://docs.python.org/c-api/sys.html#Py_FatalError>`_,\n`PyFile_SoftSpace <http://docs.python.org/c-api/file.html#PyFile_SoftSpace>`_,\n`PyFile_WriteObject <http://docs.python.org/c-api/file.html#PyFile_WriteObject>`_,\n`PyFile_WriteString <http://docs.python.org/c-api/file.html#PyFile_WriteString>`_,\n`Py_Finalize <http://docs.python.org/c-api/init.html#Py_Finalize>`_,\n`PyFrame_New`,\n`Py_GetVersion <http://docs.python.org/c-api/init.html#Py_GetVersion>`_,\n`PyGILState_Ensure <http://docs.python.org/c-api/init.html#PyGILState_Ensure>`_,\n`PyGILState_Release <http://docs.python.org/c-api/init.html#PyGILState_Release>`_,\n`PyImport_AddModule <http://docs.python.org/c-api/import.html#PyImport_AddModule>`_,\n`PyImport_AppendInittab <http://docs.python.org/c-api/import.html#PyImport_AppendInittab>`_,\n`PyImport_ImportModule <http://docs.python.org/c-api/import.html#PyImport_ImportModule>`_,\n`Py_Initialize <http://docs.python.org/c-api/init.html#Py_Initialize>`_,\n`Py_InitModule4_64`,\n`PyInt_AsLong <http://docs.python.org/c-api/int.html#PyInt_AsLong>`_,\n`PyInt_FromLong <http://docs.python.org/c-api/int.html#PyInt_FromLong>`_,\n`PyList_Append <http://docs.python.org/c-api/list.html#PyList_Append>`_,\n`PyList_GetItem <http://docs.python.org/c-api/list.html#PyList_GetItem>`_,\n`PyList_New <http://docs.python.org/c-api/list.html#PyList_New>`_,\n`PyList_SetItem <http://docs.python.org/c-api/list.html#PyList_SetItem>`_,\n`PyList_Size <http://docs.python.org/c-api/list.html#PyList_Size>`_,\n`PyLong_FromLong <http://docs.python.org/c-api/long.html#PyLong_FromLong>`_,\n`PyLong_FromLongLong <http://docs.python.org/c-api/long.html#PyLong_FromLongLong>`_,\n`PyLong_FromString <http://docs.python.org/c-api/long.html#PyLong_FromString>`_,\n`PyLong_FromVoidPtr <http://docs.python.org/c-api/long.html#PyLong_FromVoidPtr>`_,\n`PyMapping_Size <http://docs.python.org/c-api/mapping.html#PyMapping_Size>`_,\n`PyMem_Free <http://docs.python.org/c-api/memory.html#PyMem_Free>`_,\n`PyMem_Malloc <http://docs.python.org/c-api/memory.html#PyMem_Malloc>`_,\n`PyModule_AddIntConstant <http://docs.python.org/c-api/module.html#PyModule_AddIntConstant>`_,\n`PyModule_AddObject <http://docs.python.org/c-api/module.html#PyModule_AddObject>`_,\n`PyModule_AddStringConstant <http://docs.python.org/c-api/module.html#PyModule_AddStringConstant>`_,_,\n`PyModule_GetDict <http://docs.python.org/c-api/module.html#PyModule_GetDict>`_,\n`PyNumber_Int <http://docs.python.org/c-api/number.html#PyNumber_Int>`_,\n`PyNumber_Remainer <http://docs.python.org/c-api/number.html#PyNumber_Remainder>`_,\n`PyObject_AsFileDescriptor <http://docs.python.org/c-api/object.html#PyObject_AsFileDescriptor>`_,\n`PyObject_Call <http://docs.python.org/c-api/object.html#PyObject_Call>`_,\n`PyObject_CallFunction and _PyObject_CallFunction_SizeT <http://docs.python.org/c-api/object.html#PyObject_CallFunction>`_,\n`PyObject_CallFunctionObjArgs <http://docs.python.org/c-api/object.html#PyObject_CallFunctionObjArgs>`_,\n`PyObject_CallMethod and _PyObject_CallMethod_SizeT <http://docs.python.org/c-api/object.html#PyObject_CallMethod>`_,\n`PyObject_CallMethodObjArgs <http://docs.python.org/c-api/object.html#PyObject_CallMethodObjArgs>`_,\n`PyObject_CallObject <http://docs.python.org/c-api/object.html#PyObject_CallObject>`_,\n`PyObject_GetAttr <http://docs.python.org/c-api/object.html#PyObject_GetAttr>`_,\n`PyObject_GetAttrString <http://docs.python.org/c-api/object.html#PyObject_GetAttrString>`_,\n`PyObject_GetItem <http://docs.python.org/c-api/object.html#PyObject_GetItem>`_,\n`PyObject_GenericGetAttr <http://docs.python.org/c-api/object.html#PyObject_GenericGetAttr>`_,\n`PyObject_GenericSetAttr <http://docs.python.org/c-api/object.html#PyObject_GenericSetAttr>`_,\n`PyObject_HasAttrString <http://docs.python.org/c-api/object.html#PyObject_HasAttrString>`_,\n`PyObject_IsTrue <http://docs.python.org/c-api/object.html#PyObject_IsTrue>`_,\n`_PyObject_New`,\n`PyObject_Repr <http://docs.python.org/c-api/object.html#PyObject_Repr>`_,\n`PyObject_SetAttr <http://docs.python.org/c-api/object.html#PyObject_SetAttr>`_,\n`PyObject_SetAttrString <http://docs.python.org/c-api/object.html#PyObject_SetAttrString>`_,\n`PyObject_Str <http://docs.python.org/c-api/object.html#PyObject_Str>`_,\n`PyOS_snprintf <http://docs.python.org/c-api/conversion.html#PyOS_snprintf>`_,\n`PyRun_SimpleFileExFlags <http://docs.python.org/c-api/veryhigh.html#PyRun_SimpleFileExFlags>`_,\n`PyRun_SimpleStringFlags <http://docs.python.org/c-api/veryhigh.html#PyRun_SimpleStringFlags>`_,\n`PySequence_Concat <http://docs.python.org/c-api/sequence.html#PySequence_Concat>`_,\n`PySequence_DelItem <http://docs.python.org/c-api/sequence.html#PySequence_DelItem>`_,\n`PySequence_GetItem <http://docs.python.org/c-api/sequence.html#PySequence_GetItem>`_,\n`PySequence_GetSlice <http://docs.python.org/c-api/sequence.html#PySequence_GetSlice>`_,\n`PySequence_SetItem <http://docs.python.org/c-api/sequence.html#PySequence_SetItem>`_,\n`PySequence_Size <http://docs.python.org/c-api/sequence.html#PySequence_Size>`_,\n`PyString_AsString <http://docs.python.org/c-api/string.html#PyString_AsString>`_,\n`PyString_Concat <http://docs.python.org/c-api/string.html#PyString_Concat>`_,\n`PyString_ConcatAndDel <http://docs.python.org/c-api/string.html#PyString_ConcatAndDel>`_,\n`PyString_FromFormat <http://docs.python.org/c-api/string.html#PyString_FromFormat>`_,\n`PyString_FromString <http://docs.python.org/c-api/string.html#PyString_FromString>`_,\n`PyString_FromStringAndSize <http://docs.python.org/c-api/string.html#PyString_FromStringAndSize>`_,\n`PyString_InternFromString <http://docs.python.org/c-api/string.html#PyString_InternFromString>`_,\n`PyString_Size <http://docs.python.org/c-api/string.html#PyString_Size>`_,\n`PyStructSequence_InitType`,\n`PyStructSequence_New`,\n`PySys_GetObject <http://docs.python.org/c-api/sys.html#PySys_GetObject>`_,\n`PySys_SetObject <http://docs.python.org/c-api/sys.html#PySys_SetObject>`_,\n`PyTraceBack_Here`,\n`PyTuple_GetItem <http://docs.python.org/c-api/tuple.html#PyTuple_GetItem>`_,\n`PyTuple_New <http://docs.python.org/c-api/tuple.html#PyTuple_New>`_,\n`PyTuple_Pack <http://docs.python.org/c-api/tuple.html#PyTuple_Pack>`_,\n`PyTuple_SetItem <http://docs.python.org/c-api/tuple.html#PyTuple_SetItem>`_,\n`PyTuple_Size <http://docs.python.org/c-api/tuple.html#PyTuple_Size>`_,\n`PyType_IsSubtype <http://docs.python.org/dev/c-api/type.html#PyType_IsSubtype>`_,\n`PyType_Ready <http://docs.python.org/dev/c-api/type.html#PyType_Ready>`_,\n`PyUnicodeUCS4_AsUTF8String <http://docs.python.org/c-api/unicode.html#PyUnicode_AsUTF8String>`_,\n`PyUnicodeUCS4_DecodeUTF8 <http://docs.python.org/c-api/unicode.html#PyUnicode_DecodeUTF8>`_,\n`PyWeakref_GetObject <http://docs.python.org/c-api/weakref.html#PyWeakref_GetObject>`_\n\nThe checker also has some knowledge about these SWIG-generated functions:\n`SWIG_Python_ErrorType`,\n`SWIG_Python_SetErrorMsg`\n\nand of this Cython-generated function:\n`__Pyx_GetStdout`\n\nIdeas for future tests\n----------------------\n\nHere's a list of some other C coding bugs I intend for the tool to detect:\n\n  * tp_traverse errors (which can mess up the garbage collector); missing it\n    altogether, or omitting fields\n\n  * errors in GIL-handling\n\n    * lock/release mismatches\n\n    * missed opportunities to release the GIL (e.g. compute-intensive\n      functions; functions that wait on IO/syscalls)\n\nIdeas for other tests are most welcome (patches even more so!)\n\nWe will probably need various fallbacks and suppression modes for turning off\nindividual tests (perhaps pragmas, perhaps compile-line flags, etc)\n\n\nReusing this code for other projects\n------------------------------------\nIt may be possible to reuse the analysis engine from cpychecker for other\nkinds of analysis - hopefully the python-specific parts are relatively\nself-contained.  Email the `gcc-python-plugin's mailing list\n<https://fedorahosted.org/mailman/listinfo/gcc-python-plugin/>`_ if you're\ninterested in adding verifiers for other kinds of code.\n\nCommon mistakes\n---------------\nHere are some common mistakes made using the CPython extension API, along with\nthe fixes.\n\nMissing `Py_INCREF()` on `Py_None`\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nThe following is typically incorrect: a method implementation is required to\nreturn a new reference, but this code isn't incrementing the reference count\non Py_None.\n\n.. code-block:: c\n\n    PyObject*\n    some_method(PyObject *self, PyObject *args)\n    {\n        [...snip...]\n\n        /* BUG: loses a reference to Py_None */\n        return Py_None;\n    }\n\nIf called enough, this could cause Py_None to be deallocated, crashing the\ninterpreter::\n\n    Fatal error: deallocating None\n\nThe `Py_RETURN_NONE <http://docs.python.org/c-api/none.html#Py_RETURN_NONE>`_\nmacro takes care of incrementing the reference count for you:\n\n.. code-block:: c\n\n    PyObject*\n    some_method(PyObject *self, PyObject *args)\n    {\n        [...snip...]\n\n        /* Fixed version of the above: */\n        Py_RETURN_NONE;\n    }\n\nReference leak in Py_BuildValue\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n`Py_BuildValue <http://docs.python.org/c-api/arg.html#Py_BuildValue>`_ with\n\"O\" adds a new reference on the object for use by the new tuple, hence the\nfollowing code leaks the reference already owned on the object:\n\n.. code-block:: c\n\n    /* BUG: reference leak: */\n    return Py_BuildValue(\"O\", some_object_we_own_a_ref_on);\n\n`Py_BuildValue <http://docs.python.org/c-api/arg.html#Py_BuildValue>`_ with\n\"N\" steals the reference (and copes with it being NULL by propagating the\nexception):\n\n.. code-block:: c\n\n    /* Fixed version of the above: */\n    return Py_BuildValue(\"N\", some_object_we_own_a_ref_on);\n\n\n.. TODO: other examples?\n\n   - constructing a list\n"
  },
  {
    "path": "docs/diagnostics.rst",
    "content": ".. Copyright 2011-2012, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2012, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nGenerating custom errors and warnings\n=====================================\n\n.. py:function:: gcc.warning(location, message, option=None)\n\n   Emits a compiler warning at the given :py:class:`gcc.Location`, potentially\n   controlled by a :py:class:`gcc.Option`.\n\n   If no option is supplied (or `None` is supplied), then the warning is an\n   unconditional one, always issued::\n\n      gcc.warning(func.start, 'this is an unconditional warning')\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python script.py input.c\n      input.c:25:1: warning: this is an unconditional warning [enabled by default]\n\n   and will be an error if `-Werror` is supplied as a command-line argument to\n   GCC:\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python script.py -Werror input.c\n      input.c:25:1: error: this is an unconditional warning [-Werror]\n\n   It's possible to associate the warning with a command-line option, so that\n   it is controlled by that option.\n\n   For example, given this Python code::\n\n      gcc.warning(func.start, 'Incorrect formatting', gcc.Option('-Wformat'))\n\n   if the given warning is enabled, a warning will be printed to stderr:\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python script.py input.c\n      input.c:25:1: warning: incorrect formatting [-Wformat]\n\n   If the given warning is being treated as an error (through the usage\n   of `-Werror`), then an error will be printed:\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python script.py -Werror input.c\n      input.c:25:1: error: incorrect formatting [-Werror=format]\n      cc1: all warnings being treated as errors\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python script.py -Werror=format input.c\n      input.c:25:1: error: incorrect formatting [-Werror=format]\n      cc1: some warnings being treated as errors\n\n   If the given warning is disabled, the warning will not be printed:\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python script.py -Wno-format input.c\n\n   .. note:: Due to the way GCC implements some options, it's not always\n      possible for the plugin to fully disable some warnings.  See\n      :py:attr:`gcc.Option.is_enabled` for more information.\n\n   The function returns a boolean, indicating whether or not anything was\n   actually printed.\n\n.. py:function:: gcc.error(location, message)\n\n   Emits a compiler error at the given :py:class:`gcc.Location`.\n\n   For example::\n\n      gcc.error(func.start, 'something bad was detected')\n\n   would lead to this error being printed to stderr:\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python script.py input.c\n     input.c:25:1: error: something bad was detected\n\n.. py:function:: gcc.permerror(loc, str)\n\n   This is a wrapper around GCC's `permerror` function.\n\n   Expects an instance of :py:class:`gcc.Location` (not None) and a string\n\n   Emit a \"permissive\" error at that location, intended for things that really\n   ought to be errors, but might be present in legacy code.\n\n   In theory it's suppressable using \"-fpermissive\" at the GCC command line\n   (which turns it into a warning), but this only seems to be legal for C++\n   source files.\n\n   Returns True if the warning was actually printed, False otherwise\n\n.. py:function:: gcc.inform(location, message)\n\n   This is a wrapper around GCC's `inform` function.\n\n   Expects an instance of :py:class:`gcc.Location` or\n   :py:class:`gcc.RichLocation`, (not None) and a string\n\n   Emit an informational message at that location.\n\n   For example::\n\n     gcc.inform(stmt.loc, 'this is where X was defined')\n\n   would lead to this informational message being printed to stderr:\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python script.py input.c\n     input.c:23:3: note: this is where X was defined\n"
  },
  {
    "path": "docs/examples.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nExample scripts\n===============\n\nThere are various sample scripts located in the `examples` subdirectory.\n\nOnce you've built the plugin (with `make`), you can run them via:\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python examples/NAME-OF-SCRIPT.py test.c\n\n`show-docs.py`\n--------------\n\n  A trivial script to make it easy to read the builtin documentation for the\n  gcc API:\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python examples/show-docs.py test.c\n\n  with this source:\n\n   .. literalinclude:: ../examples/show-docs.py\n    :lines: 17-\n    :language: python\n\n  giving output::\n\n     Help on built-in module gcc:\n\n     NAME\n         gcc\n\n     FILE\n         (built-in)\n\n     CLASSES\n         __builtin__.object\n             BasicBlock\n             Cfg\n             Edge\n             Function\n             Gimple\n     (truncated)\n\n`show-passes.py`\n----------------\n\nYou can see the passes being executed via:\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python examples/show-passes.py test.c\n\nThis is a simple script that registers a trivial callback:\n\n   .. literalinclude:: ../examples/show-passes.py\n    :lines: 17-\n    :language: python\n\nSample output, showing passes being called on two different functions (`main`\nand `helper_function`)::\n\n     (gcc.GimplePass(name='*warn_unused_result'), gcc.Function('main'))\n     (gcc.GimplePass(name='omplower'), gcc.Function('main'))\n     (gcc.GimplePass(name='lower'), gcc.Function('main'))\n     (gcc.GimplePass(name='eh'), gcc.Function('main'))\n     (gcc.GimplePass(name='cfg'), gcc.Function('main'))\n     (gcc.GimplePass(name='*warn_function_return'), gcc.Function('main'))\n     (gcc.GimplePass(name='*build_cgraph_edges'), gcc.Function('main'))\n     (gcc.GimplePass(name='*warn_unused_result'), gcc.Function('helper_function'))\n     (gcc.GimplePass(name='omplower'), gcc.Function('helper_function'))\n     (gcc.GimplePass(name='lower'), gcc.Function('helper_function'))\n     (gcc.GimplePass(name='eh'), gcc.Function('helper_function'))\n     (gcc.GimplePass(name='cfg'), gcc.Function('helper_function'))\n     [...truncated...]\n\n\n`show-gimple.py`\n----------------\n\nA simple script for viewing each function in the source file after it's been\nconverted to \"GIMPLE\" form, using GraphViz to visualize the control flow graph:\n\n   .. code-block:: bash\n\n      $ ./gcc-with-python examples/show-gimple.py test.c\n\nIt will generate a file `test.png` for each function, and opens it in an image\nviewer.\n\n   .. figure:: sample-gimple-cfg.png\n      :scale: 50 %\n      :alt: image of a control flow graph in GIMPLE form\n\nThe Python code for this is:\n\n   .. literalinclude:: ../examples/show-gimple.py\n    :lines: 19-\n    :language: python\n\n`show-ssa.py`\n-------------\n\nThis is similar to `show-gimple.py`, but shows each function after the GIMPLE\nhas been converted to Static Single Assignment form (\"SSA\"):\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python examples/show-ssa.py test.c\n\nAs before, it generates an image file for each function and opens it in a\nviewer.\n\n.. figure:: sample-gimple-ssa-cfg.png\n   :scale: 50 %\n   :alt: image of a control flow graph in GIMPLE SSA form\n\nThe Python code for this is:\n\n   .. literalinclude:: ../examples/show-ssa.py\n    :lines: 17-\n    :language: python\n\n`show-callgraph.py`\n-------------------\n\nThis simple script sends GCC's interprocedural analysis data through GraphViz.\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python examples/show-callgraph.py test.c\n\nIt generates an image file showing which functions call which other functions,\nand opens it in a viewer.\n\n.. figure:: sample-callgraph.png\n   :alt: image of a call graph\n\nThe Python code for this is:\n\n   .. literalinclude:: ../examples/show-callgraph.py\n    :lines: 18-\n    :language: python\n"
  },
  {
    "path": "docs/gcc-overview.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nOverview of GCC's internals\n===========================\n\n.. TODO: Subprocesses\n\n.. TODO: Passes\n\n.. TODO: could use a diagram  here showing all the passes\n\nTo add a new compiler warning to GCC, it's helpful to have a high-level\nunderstanding of how GCC works, so here's the 10,000 foot view of how GCC turns\nsource code into machine code.\n\nThe short version is that GCC applies a series of optimization passes to your\ncode, gradually converting it from a high-level representation into machine\ncode, via several different internal representations.\n\nEach programming language supported by GCC has a \"frontend\", which parses the\nsource files.\n\nFor the case of C and C++, the preprocessor manipulates the code first\nbefore the frontend sees it.  You can see the preprocessor output with the\n`-E` option.\n\nExactly what happens in each frontend varies by language: some language\nfrontends emit language-specific trees, and some convert to a\nlanguage-independent tree representation known as `GENERIC`.  In any case, we\neventually we reach a representation known as `GIMPLE`.  The GIMPLE\nrepresentation contains simplified operations, with temporary variables added as\nnecessary to avoid nested sub-expressions.\n\nFor example, given this C code:\n\n   .. literalinclude:: ../test.c\n     :lines: 33-48\n     :language: c\n\nwe can see a dump of a C-like representation of the GIMPLE form by passing\n`-fdump-tree-gimple` to the command-line:\n\n  .. code-block:: bash\n\n      $ gcc -fdump-tree-gimple test.c\n      $ cat test.c.004t.gimple\n\ngiving something like this:\n\n.. code-block:: c\n\n   main (int argc, char * * argv)\n   {\n     const char * restrict D.3258;\n     long unsigned int D.3259;\n     long unsigned int D.3260;\n     char * * D.3261;\n     char * D.3262;\n     const char * restrict D.3263;\n     int D.3264;\n     int i;\n\n     D.3258 = (const char * restrict) &\"argc: %i\\n\"[0];\n     printf (D.3258, argc);\n     i = 0;\n     goto <D.2050>;\n     <D.2049>:\n     D.3259 = (long unsigned int) i;\n     D.3260 = D.3259 * 8;\n     D.3261 = argv + D.3260;\n     D.3262 = *D.3261;\n     D.3263 = (const char * restrict) &\"argv[%i]: %s\\n\"[0];\n     printf (D.3263, D.3262);\n     i = i + 1;\n     <D.2050>:\n     if (i < argc) goto <D.2049>; else goto <D.2051>;\n     <D.2051>:\n     helper_function ();\n     D.3264 = 0;\n     return D.3264;\n   }\n\nIt's far easier to see the GIMPLE using:\n\n.. code-block:: bash\n\n  ./gcc-with-python examples/show-gimple.py test.c\n\nwhich generates bitmaps showing the \"control flow graph\" of the functions in\nthe file, with source on the left-hand side, and GIMPLE on the right-hand side:\n\n    .. figure:: sample-gimple-cfg.png\n      :scale: 50 %\n      :alt: image of a control flow graph in GIMPLE form\n\nEach function is divided into \"basic blocks\".  Each basic block consists of a\nstraight-line sequence of code with a single entrypoint and exit: all branching\nhappens between basic blocks, not within them.  The basic blocks form a\n\"control flow graph\" of basic blocks, linked together by edges.  Each block\ncan contain a list of :py:class:`gcc.Gimple` statements.\n\nYou can work with this representation from Python using :py:class:`gcc.Cfg`\n\nOnce the code is in GIMPLE form, GCC then attempts a series of optimizations on\nit.\n\nSome of these optimizations are listed here:\nhttp://gcc.gnu.org/onlinedocs/gccint/Tree-SSA-passes.html\n\nIf you're looking to add new compiler warnings, it's probably best to hook\nyour code into these early passes.\n\nThe GIMPLE representation actually has several forms:\n\n  * an initial \"high gimple\" form, potentially containing certain high-level\n    operations (e.g. control flow, exception handling)\n\n  * the lower level gimple forms, as each of these operations are rewritten\n    in lower-level terms (turning control flow from jumps into a CFG etc)\n\n  * the SSA form of GIMPLE.  In Static Single Assignment form, every variable\n    is assigned to at most once, with additional versions of variables added\n    to help track the impact of assignments on the data flowing through\n    a function.  See http://gcc.gnu.org/onlinedocs/gccint/SSA.html\n\nYou can tell what form a function is in by looking at the flags of the current\npass.  For example::\n\n   if ps.properties_provided & gcc.PROP_cfg:\n      # ...then this gcc.Function ought to have a gcc.Cfg:\n      do_something_with_cfg(fn.cfg)\n\n   if ps.properties_provided & gcc.PROP_ssa:\n      # ...then we have SSA data\n      do_something_with_ssa(fn)\n\nHere's our example function, after conversion to GIMPLE SSA:\n\n.. code-block:: bash\n\n  ./gcc-with-python examples/show-ssa.py test.c\n\n.. figure:: sample-gimple-ssa-cfg.png\n   :scale: 50 %\n   :alt: image of a control flow graph in GIMPLE SSA form\n\nYou can see that the local variable `i` has been split into three versions:\n\n   * `i_4`, assigned to in block 2\n   * `i_11`, assigned to at the end of block 3\n   * `i_1`, assigned to at the top of block 4.\n\nAs is normal with SSA, GCC inserts fake functions known as \"PHI\" at the start\nof basic blocks where needed in order to merge the multiple possible values of\na variable.  You can see one in our example at the top of the loop in block 4:\n\n.. code-block:: c\n\n   i_1 = PHI <i_4(2), i_11(3)>\n\nwhere i_1 either gets the value of i_4, or of i_11, depending on whether we\nreach here via block 2 (at the start of the iteration) or block 3 (continuing\nthe \"for\" loop).\n\nAfter these optimizations passes are done, GCC converts the GIMPLE SSA\nrepresentation into a lower-level representation known as Register Transfer\nLanguage (RTL).  This is probably too low-level to be of interest to those\nseeking to add new compiler warnings: at this point it's attempting to work\nwith the available opcodes and registers on the target CPU with the aim of\ngenerating efficient machine code.\n\nSee http://gcc.gnu.org/onlinedocs/gccint/RTL.html\n\nThe RTL form uses the same Control Flow Graph machinery as the GIMPLE\nrepresentation, but with RTL expressions within the basic blocks.\n\nOnce in RTL, GCC applies a series of further optimizations, before finally\ngenerating assembly language (which it submits to `as`, the GNU assembler):\nhttp://gcc.gnu.org/onlinedocs/gccint/RTL-passes.html\nYou can see the assembly language using the `-S` command line option.\n\n.. code-block:: bash\n\n  $ ./gcc -S test.c\n  $ cat test.s\n"
  },
  {
    "path": "docs/gcc-with-python.rst",
    "content": "Usage::\n\n   gcc-with-python PATH_TO_PYTHON_SCRIPT GCC PARAMETERS\n\n`gcc-with-python` is a helper script which invokes GCC, whilst loading the\nPython plugin for GCC, running the given python script.\n\nExample::\n\n   gcc-with-python show-ssa.py example.c\n"
  },
  {
    "path": "docs/getting-involved.rst",
    "content": ".. Copyright 2012, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nGetting Involved\n================\n\nThe plugin's web site is this GitHub repository:\n\n   https://github.com/davidmalcolm/gcc-python-plugin\n\nThe primary place for discussion of the plugin is the mailing list:\nhttps://fedorahosted.org/mailman/listinfo/gcc-python-plugin\n\nA pre-built version of the HTML documentation can be seen at:\n\nhttp://readthedocs.org/docs/gcc-python-plugin/en/latest/index.html\n\nThe project's mailing list is here: https://fedorahosted.org/mailman/listinfo/gcc-python-plugin\n\nIdeas for using the plugin\n--------------------------\n\nHere are some ideas for possible uses of the plugin.  Please email the\nplugin's mailing list if you get any of these working (or if you have other\nideas!).  Some guesses as to the usefulness and difficulty level are given in\nparentheses after some of the ideas.  Some of them might require new attributes,\nmethods and/or classes to be added to the plugin (to expose more of GCC\ninternals), but you can always ask on the mailing list if you need help.\n\n* extend the libcpychecker code to add checking for the standard C library.\n  For example, given this buggy C code:\n\n  .. code-block:: c\n\n    int foo() {\n         FILE *src, *dst;\n         src = fopen(\"source.txt\", \"r\");\n         if (!src) return -1;\n\n         dst = fopen(\"dest.txt\", \"w\");\n         if (!dst) return -1;  /* <<<< BUG: this error-handling leaks \"src\" */\n\n         /* etc, copy src to dst (or whatever) */\n    }\n\n  it would be great if the checker could emit a compile-time warning about\n  the buggy error-handling path above (or indeed any paths through\n  functions that leak `FILE*`, file descriptors, or other resources). The\n  way to do this (I think) is to add a new `Facet` subclass to\n  libcpychecker, analogous to the `CPython` facet subclass that already\n  exists (though the facet handling is probably rather messy right now).\n  (useful but difficult, and a lot of work)\n\n* extend the libcpychecker code to add checking for other libraries.  For\n  example:\n\n  * reference-count checking within `glib <http://developer.gnome.org/glib/>`_\n    and gobject\n\n  (useful for commonly-used C libraries but difficult, and a lot of work)\n\n* detection of C++ variables with non-trivial constructors that will need to be\n  run before `main` - globals and static locals (useful, ought to be fairly\n  easy)\n\n* finding unused parameters in definitions of non-virtual functions, so that\n  they can be removed - possibly removing further dead code.  Some care would\n  be needed for function pointers.  (useful, ought to be fairly easy)\n\n* detection of bad format strings (see e.g. https://lwn.net/Articles/478139/ )\n\n* compile gcc's own test suite with the cpychecker code, to reuse their\n  coverage of C and thus shake out more bugs in the checker (useful and easy)\n\n* a new `PyPy gc root finder <http://pypy.readthedocs.org/en/latest/config/translation.gcrootfinder.html>`_,\n  running inside GCC (useful for PyPy, but difficult)\n\n* reimplement `GCC-XML <http://www.gccxml.org/HTML/Index.html>`_ in Python\n  (probably fairly easy, but does anyone still use GCC-XML now that GCC\n  supports plugins?)\n\n* .gir generation for `GObject Introspection <http://live.gnome.org/GObjectIntrospection>`_\n  (unknown if the GNOME developers are actually interested in this though)\n\n* create an interface that lets you view the changing internal representation\n  of each function as it's modified by the various optimization pases: lets\n  you see which passes change a given function, and what the changes are\n  (might be useful as a teaching tool, and for understanding GCC)\n\n* add array bounds checking to C (to what extent can GCC already do this?)\n\n* `taint mode <http://perldoc.perl.org/perlsec.html#Taint-mode>`_ for GCC!\n  e.g. detect usage of data from network/from disk/etc; identify certain data\n  as untrusted, and track how it gets used; issue a warning (very useful, but\n  very difficult: how does untainting work? what about pointers and memory\n  regions?  is it just too low-level?)\n\n* implement something akin to PyPy's pygame-based viewer, for viewing control\n  flow graphs and tree structures: an OpenGL-based GUI giving a fast,\n  responsive UI for navigating the data - zooming, panning, search, etc.  (very\n  useful, and fairly easy)\n\n* `generation of pxd files for Cython\n  <http://comments.gmane.org/gmane.comp.python.cython.user/5970>`_\n  (useful for Cython, ought to be fairly easy)\n\n* reverse-engineering a .py or .pyx file from a .c file: turning legacy C\n  Python extension modules back into Python or Cython sources (useful but\n  difficult)\n\n\nTour of the C code\n------------------\nThe plugin's C code heavily uses Python's extension API, and so it's worth\nknowing this API if you're going to hack on this part of the project.  A good\ntutorial for this can be seen here:\n\n  http://docs.python.org/extending/index.html\n\nand detailed notes on it are here:\n\n  http://docs.python.org/c-api/index.html\n\nMost of the C \"glue\" for creating classes and registering their methods and\nattributes is autogenerated.  Simple C one-liners tend to appear in the\nautogenerated C files, whereas longer implementations are broken out into\na hand-written C file.\n\nAdding new methods and attributes to the classes requires editing the\nappropriate generate-\\*.py script to wire up the new entrypoint.  For\nvery simple attributes you can embed the C code directly there, but\nanything that's more than a one-liner should have its implementation in\nthe relevant C file.\n\nFor example, to add new methods to a :py:class:`gcc.Cfg` you'd edit:\n\n  * `generate-cfg-c.py` to add the new methods and attributes to the relevant\n    tables of callbacks\n\n  * `gcc-python-wrappers.h` to add declarations of the new C functions\n\n  * `gcc-python-cfg.c` to add the implementations of the new C functions\n\nPlease try to make the API \"Pythonic\".\n\nMy preference with getters is that if the implementation is a simple\nfield lookup, it should be an attribute (the \"getter\" is only implicit,\nexisting at the C level)::\n\n   print(bb.loopcount)\n\nwhereas if getting the result involves some work, it should be an\nexplicit method of the class (where the \"getter\" is explicit at the\nPython level)::\n\n   print(bb.get_loop_count())\n\n\nUsing the plugin to check itself\n--------------------------------\nGiven that the `cpychecker` code implements new error-checking for Python C\ncode, and that the underlying plugin is itself an example of such code, it's\npossible to build the plugin once, then compile it with itself (using\nCC=gcc-with-cpychecker as a Makefile variable::\n\n  $ make CC=/path/to/a/clean/build/of/the/plugin/gcc-with-cpychecker\n\nUnfortunately it doesn't quite compile itself cleanly right\nnow.\n\n.. TODO: add notes on the current known problems\n\n\nTest suite\n----------\nThere are three test suites:\n\n  * `testcpybuilder.py`: a minimal test suite which is used before the plugin\n    itself is built.  This verifies that the `cpybuilder` code works.\n\n  * `make test-suite` (aka `run-test-suite.py`): a test harness and suite\n    which was written for this project.  See the notes below on patches.\n\n  * `make testcpychecker` and `testcpychecker.py`: a suite based on Python's\n    `unittest` module\n\n\nDebugging the plugin's C code\n-----------------------------\n\nThe `gcc` binary is a harness that launches subprocesses, so it can be\nfiddly to debug.  Exactly what it launches depend on the inputs and\noptions. Typically, the subprocesses it launches are (in order):\n\n  * `cc1` or `cc1plus`: The C or C++ compiler, generating a .s assember\n    file.\n  * `as`: The assembler, converting a .s assembler file to a .o object\n    file.\n  * `collect2`: The linker, turning one or more .o files into an executable\n    (if you're going all the way to building an `a.out`-style executable).\n\nThe easiest way to debug the plugin is to add these parameters to the gcc\ncommand line (e.g. to the end)::\n\n   -wrapper gdb,--args\n\nNote the lack of space between the comma and the `--args`.\n\ne.g.::\n\n  ./gcc-with-python examples/show-docs.py test.c -wrapper gdb,--args\n\nThis will invoke each of the subprocesses in turn under gdb: e.g. `cc1`,\n`as` and `collect2`; the plugin runs with `cc1` (`cc1plus` for C++ code).\n\nFor example::\n\n  $ ./gcc-with-cpychecker -c -I/usr/include/python2.7 demo.c -wrapper gdb,--args\n\n  GNU gdb (GDB) Fedora 7.6.50.20130731-19.fc20\n  [...snip...]\n  Reading symbols from /usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1...Reading symbols from /usr/lib/debug/usr/libexec/gcc/x86_64-redhat-linux/4.8.2/cc1.debug...done.\n  done.\n  (gdb) run\n  [...etc...]\n\nAnother way to do it is to add \"-v\" to the gcc command line\n(verbose), so that it outputs the commands that it's running.  You can then use\nthis to launch::\n\n   $ gdb --args ACTUAL PROGRAM WITH ACTUAL ARGS\n\nto debug the subprocess that actually loads the Python plugin.\n\nFor example::\n\n  $ gcc -v -fplugin=$(pwd)/python.so -fplugin-arg-python-script=test.py test.c\n\non my machine emits this::\n\n   Using built-in specs.\n   COLLECT_GCC=gcc\n   COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.6.1/lto-wrapper\n   Target: x86_64-redhat-linux\n   Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux\n   Thread model: posix\n   gcc version 4.6.1 20110908 (Red Hat 4.6.1-9) (GCC) \n   COLLECT_GCC_OPTIONS='-v' '-fplugin=/home/david/coding/gcc-python/gcc-python/contributing/python.so' '-fplugin-arg-python-script=test.py' '-mtune=generic' '-march=x86-64'\n    /usr/libexec/gcc/x86_64-redhat-linux/4.6.1/cc1 -quiet -v -iplugindir=/usr/lib/gcc/x86_64-redhat-linux/4.6.1/plugin test.c -iplugindir=/usr/lib/gcc/x86_64-redhat-linux/4.6.1/plugin -quiet -dumpbase test.c -mtune=generic -march=x86-64 -auxbase test -version -fplugin=/home/david/coding/gcc-python/gcc-python/contributing/python.so -fplugin-arg-python-script=test.py -o /tmp/cc1Z3b95.s\n   (output of the script follows)\n\nThis allows us to see the line in which `cc1` is invoked: in the above\nexample, it's the final line before the output from the script::\n\n  /usr/libexec/gcc/x86_64-redhat-linux/4.6.1/cc1 -quiet -v -iplugindir=/usr/lib/gcc/x86_64-redhat-linux/4.6.1/plugin test.c -iplugindir=/usr/lib/gcc/x86_64-redhat-linux/4.6.1/plugin -quiet -dumpbase test.c -mtune=generic -march=x86-64 -auxbase test -version -fplugin=/home/david/coding/gcc-python/gcc-python/contributing/python.so -fplugin-arg-python-script=test.py -o /tmp/cc1Z3b95.s\n\nWe can then take this line and rerun this subprocess under gdb by adding\n`gdb --args` to the front like this::\n\n   $ gdb --args /usr/libexec/gcc/x86_64-redhat-linux/4.6.1/cc1 -quiet -v -iplugindir=/usr/lib/gcc/x86_64-redhat-linux/4.6.1/plugin test.c -iplugindir=/usr/lib/gcc/x86_64-redhat-linux/4.6.1/plugin -quiet -dumpbase test.c -mtune=generic -march=x86-64 -auxbase test -version -fplugin=/home/david/coding/gcc-python/gcc-python/contributing/python.so -fplugin-arg-python-script=test.py -o /tmp/cc1Z3b95.s\n\nThis approach to obtaining a debuggable process doesn't seem to work in the\npresence of `ccache`, in that it writes to a temporary directory with a name\nthat embeds the process ID each time, which then gets deleted.  I've worked\naround this by uninstalling ccache, but apparently setting::\n\n   CCACHE_DISABLE=1\n\nbefore invoking `gcc -v` ought to also work around this.\n\nI've also been running into this error from gdb::\n\n  [Thread debugging using libthread_db enabled]\n  Cannot find new threads: generic error\n\nApparently this happens when debugging a process that uses dlopen to load a\nlibrary that pulls in libpthread (as does gcc when loading in my plugin), and\na workaround is to link cc1 with -lpthread\n\nThe workaround I've been using (to avoid the need to build my own gcc) is to\nuse LD_PRELOAD, either like this::\n\n   LD_PRELOAD=libpthread.so.0 gdb --args ARGS GO HERE...\n\nor this::\n\n   (gdb) set environment LD_PRELOAD libpthread.so.0\n\n\nHandy tricks\n++++++++++++\n\nGiven a (PyGccTree*) named \"self\"::\n\n   (gdb) call debug_tree(self->t)\n\nwill use GCC's prettyprinter to dump the embedded (tree*) and its descendants\nto stderr; it can help to put a breakpoint on that function too, to explore the\ninsides of that type.\n\nPatches\n-------\nThe project doesn't have any copyright assignment requirement: you get\nto keep copyright in any contributions you make, though AIUI there's an\nimplicit licensing of such contributions under the GPLv3 or later, given\nthat any contribution is a derived work of the plugin, which is itself\nlicensed under the GPLv3 or later.   I'm not a lawyer, though.\n\nThe Python code within the project is intended to be usable with both Python 2\nand Python 3 without running 2to3: please stick to the common subset of the two\nlanguages.  For example, please write print statements using parentheses::\n\n   print(42)\n\nUnder Python 2 this is a `print` statement with a parenthesized number: (42)\nwhereas under Python 3 this is an invocation of the `print` function.\n\nPlease try to stick `PEP-8 <http://www.python.org/dev/peps/pep-0008/>`_ for\nPython code, and to `PEP-7 <http://www.python.org/dev/peps/pep-0007/>`_ for\nC code (rather than the GNU coding conventions).\n\nIn C code, I strongly prefer to use multiline blocks throughout, even where\nsingle statements are allowed (e.g. in an \"if\" statement)::\n\n   if (foo()) {\n       bar();\n   }\n\nas opposed to::\n\n   if (foo())\n       bar();\n\nsince this practice prevents introducing bugs when modifying such code, and the\nresulting \"diff\" is much cleaner.\n\nA good patch ought to add test cases for the new code that you write, and\ndocumentation.\n\nThe test cases should be grouped in appropriate subdirectories of \"tests\". \nEach new test case is a directory with an:\n\n  * `input.c` (or `input.cc` for C++)\n\n  * `script.py` exercising the relevant Python code\n\n  * `stdout.txt` containing the expected output from the script.\n\nFor more realistic examples of test code, put them below `tests/examples`;\nthese can be included by reference from the docs, so that we have\ndocumentation that's automatically verified by `run-test-suite.py`, and\nusers can use this to see the relationship between source-code constructs\nand the corresponding Python objects.\n\nMore information can be seen in `run-test-suite.py`\n\nBy default, `run-test-suite.py` will invoke all the tests.  You can pass it\na list of paths and it run all tests found in those paths and below.\n\nYou can generate the \"gold\" stdout.txt by hacking up this line in\nrun-test-suite.py::\n\n   out.check_for_diff(out.actual, err.actual, p, args, 'stdout', 0)\n\nso that the final 0 is a 1 (the \"writeback\" argument to `check_for_diff`).\nThere may need to be a non-empty stdout.txt file in the directory for\nthis to take effect though.\n\nUnfortunately, this approach over-specifies the selftests, making them\nrather \"brittle\".  Improvements to this approach would be welcome.\n\nTo directly see the GCC command line being invoked for each test, and to see\nthe resulting stdout and stderr, add `--show` to the arguments of\n`run-test-suite.py`.\n\nFor example::\n\n   $ python run-test-suite.py tests/plugin/diagnostics --show\n   tests/plugin/diagnostics: gcc -c -o tests/plugin/diagnostics/output.o -fplugin=/home/david/coding/gcc-python-plugin/python.so -fplugin-arg-python-script=tests/plugin/diagnostics/script.py -Wno-format tests/plugin/diagnostics/input.c\n   tests/plugin/diagnostics/input.c: In function 'main':\n   tests/plugin/diagnostics/input.c:23:1: error: this is an error (with positional args)\n   tests/plugin/diagnostics/input.c:23:1: error: this is an error (with keyword args)\n   tests/plugin/diagnostics/input.c:25:1: warning: this is a warning (with positional args) [-Wdiv-by-zero]\n   tests/plugin/diagnostics/input.c:25:1: warning: this is a warning (with keyword args) [-Wdiv-by-zero]\n   tests/plugin/diagnostics/input.c:23:1: error: a warning with some embedded format strings %s and %i\n   tests/plugin/diagnostics/input.c:25:1: warning: this is an unconditional warning [enabled by default]\n   tests/plugin/diagnostics/input.c:25:1: warning: this is another unconditional warning [enabled by default]\n   expected error was found: option must be either None, or of type gcc.Option\n   tests/plugin/diagnostics/input.c:23:1: note: This is the start of the function\n   tests/plugin/diagnostics/input.c:25:1: note: This is the end of the function\n   OK\n   1 success; 0 failures; 0 skipped\n\n\nDocumentation\n=============\nWe use Sphinx for documentation, which makes it easy\nto keep the documentation up-to-date.   For notes on how to document\nPython in the .rst form accepted by Sphinx, see e.g.:\n\n   http://sphinx.pocoo.org/domains.html#the-python-domain\n"
  },
  {
    "path": "docs/gimple.rst",
    "content": ".. Copyright 2011, 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nGimple statements\n=================\n\n.. py:class:: gcc.Gimple\n\n   A statement, in GCC's Gimple representation.\n\n   The __str__ method is implemented using GCC's own pretty-printer for gimple,\n   so e.g.::\n\n      str(stmt)\n\n   might return::\n\n      'D.3259 = (long unsigned int) i;'\n\n   .. py:attribute:: loc\n\n      Source code location of this statement, as a :py:class:`gcc.Location` (or None)\n\n   .. py:attribute:: block\n\n      The lexical block holding this statement, as a :py:class:`gcc.Tree`\n\n   .. py:attribute:: exprtype\n\n      The type of the main expression computed by this statement, as a\n      :py:class:`gcc.Tree` (which might be :py:class:`gcc.VoidType`)\n\n   .. py:attribute:: str_no_uid\n\n      A string representation of this statement, like str(), but without\n      including any internal UIDs.\n\n      This is intended for use in selftests that compare output against some\n      expected value, to avoid embedding values that change into the expected\n      output.\n\n      For example, given an assignment to a\n      temporary, the `str(stmt)` for the gcc.GimpleAssign might be::\n\n         'D.3259 = (long unsigned int) i;'\n\n      where the UID \"3259\" is liable to change from compile to compile, whereas\n      the `stmt.str_no_uid` has value::\n\n         'D.xxxx = (long unsigned int) i;'\n\n      which won't arbitrarily change each time.\n\n   .. py:method:: walk_tree(callback, *args, **kwargs)\n\n      Visit all :py:class:`gcc.Tree` nodes associated with this\n      statement, potentially more than once each.  This will visit both the\n      left-hand-side and right-hand-side operands of the statement (if any),\n      and recursively visit any of their child nodes.\n\n      For each node, the callback is invoked, supplying the node, and any\n      extra positional and keyword arguments passed to `walk_tree`::\n\n         callback(node, *args, **kwargs)\n\n      If the callback returns a true value, the traversal stops, and that\n      :py:class:`gcc.Tree` is the result of the call to `walk_tree`.\n      Otherwise, the traversal continues, and `walk_tree` eventually returns\n      `None`.\n\n.. Note that gimple.def contains useful summaries of what each gimple code\n   means\n\n:py:class:`gcc.Gimple` has various subclasses, each corresponding to the\none of the kinds of statement within GCC's internal representation.\n\nThe following subclasses have been wrapped for use from Python scripts:\n\n=======================================  ===================================\nSubclass                                 Meaning\n=======================================  ===================================\n:py:class:`gcc.GimpleAsm`                One or more inline assembly\n                                         statements\n\n:py:class:`gcc.GimpleAssign`             An assignment of an expression to\n                                         an l-value::\n\n                                            LHS = RHS1 EXPRCODE RHS2;\n\n:py:class:`gcc.GimpleCall`               A function call::\n\n                                            [ LHS = ] FN(ARG1, ..., ARGN);\n\n:py:class:`gcc.GimpleCond`               A conditional jump, of the form::\n\n                                             if (LHS EXPRCODE RHS) goto TRUE_LABEL else goto FALSE_LABEL;\n\n:py:class:`gcc.GimpleLabel`              A label statement (jump target)::\n\n                                             LABEL:\n\n:py:class:`gcc.GimpleNop`                The \"do nothing\" statement\n\n:py:class:`gcc.GimplePhi`                Used in the SSA passes::\n\n                                            LHS = PHI <ARG1, ..., ARGN>;\n\n:py:class:`gcc.GimpleReturn`             A \"return\" statement::\n\n                                            RETURN [RETVAL];\n\n:py:class:`gcc.GimpleSwitch`             A switch statement::\n\n                                            switch (INDEXVAR)\n                                            {\n                                              case LAB1: ...; break;\n                                              ...\n                                              case LABN: ...; break;\n                                              default: ...\n                                            }\n\n=======================================  ===================================\n\nThere are some additional subclasses that have not yet been fully wrapped by\nthe Python plugin (email the `gcc-python-plugin's mailing list\n<https://fedorahosted.org/mailman/listinfo/gcc-python-plugin/>`_ if you're\ninterested in working with these):\n\n=======================================  ===================================\nSubclass                                 Meaning\n=======================================  ===================================\n:py:class:`gcc.GimpleBind`               A lexical scope\n:py:class:`gcc.GimpleCatch`              An exception handler\n:py:class:`gcc.GimpleDebug`              A debug statement\n:py:class:`gcc.GimpleEhDispatch`         Used in exception-handling\n:py:class:`gcc.GimpleEhFilter`           Used in exception-handling\n:py:class:`gcc.GimpleEhMustNotThrow`     Used in exception-handling\n:py:class:`gcc.GimpleErrorMark`          A dummy statement used for handling internal errors\n:py:class:`gcc.GimpleGoto`               An unconditional jump\n:py:class:`gcc.GimpleOmpAtomicLoad`      Used for implementing OpenMP\n:py:class:`gcc.GimpleOmpAtomicStore`     (ditto)\n:py:class:`gcc.GimpleOmpContinue`        (ditto)\n:py:class:`gcc.GimpleOmpCritical`        (ditto)\n:py:class:`gcc.GimpleOmpFor`             (ditto)\n:py:class:`gcc.GimpleOmpMaster`          (ditto)\n:py:class:`gcc.GimpleOmpOrdered`         (ditto)\n:py:class:`gcc.GimpleOmpParallel`        (ditto)\n:py:class:`gcc.GimpleOmpReturn`          (ditto)\n:py:class:`gcc.GimpleOmpSection`         (ditto)\n:py:class:`gcc.GimpleOmpSections`        (ditto)\n:py:class:`gcc.GimpleOmpSectionsSwitch`  (ditto)\n:py:class:`gcc.GimpleOmpSingle`          (ditto)\n:py:class:`gcc.GimpleOmpTask`            (ditto)\n:py:class:`gcc.GimplePredict`            A hint for branch prediction\n:py:class:`gcc.GimpleResx`               Resumes execution after an exception\n:py:class:`gcc.GimpleTry`                A try/catch or try/finally statement\n:py:class:`gcc.GimpleWithCleanupExpr`    Internally used when generating GIMPLE\n=======================================  ===================================\n\n\n\n.. py:class:: gcc.GimpleAsm\n\n   Subclass of :py:class:`gcc.Gimple`: a fragment of `inline assembler code\n   <http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html>`_.\n\n   .. py:attribute:: string\n\n      The inline assembler code, as a `str`.\n\n   .. GIMPLE_ASM <STRING, I1, ..., IN, O1, ... OM, C1, ..., CP>\n   ..              STRING is the string containing the assembly statements.\n   ..              I1 ... IN are the N input operands.\n   ..              O1 ... OM are the M output operands.\n   ..              C1 ... CP are the P clobber operands.\n   ..              L1 ... LQ are the Q label operands.  */\n\n.. py:class:: gcc.GimpleAssign\n\n   Subclass of :py:class:`gcc.Gimple`: an assignment of an expression to an\n   l-value::\n\n      LHS = RHS1 EXPRCODE RHS2;\n\n   .. py:attribute:: lhs\n\n      Left-hand-side of the assignment, as a :py:class:`gcc.Tree`\n\n   .. py:attribute:: rhs\n\n      The operands on the right-hand-side of the expression, as a list of\n      :py:class:`gcc.Tree` instances (either of length 1 or length 2,\n      depending on the expression).\n\n   .. py:attribute:: exprcode\n\n      The kind of the expression, as an :py:class:`gcc.Tree` subclass (the type\n      itself, not an instance)\n\n.. py:class:: gcc.GimpleCall\n\n   Subclass of :py:class:`gcc.Gimple`: an invocation of a function, potentially\n   assigning the result to an l-value::\n\n      [ LHS = ] FN(ARG1, ..., ARGN);\n\n   .. py:attribute:: lhs\n\n      Left-hand-side of the assignment, as a :py:class:`gcc.Tree`, or `None`\n\n   .. py:attribute:: rhs\n\n      The operands on the right-hand-side of the expression, as a list of\n      :py:class:`gcc.Tree` instances\n\n   .. py:attribute:: fn\n\n      The function being called, as a :py:class:`gcc.Tree`\n\n   .. py:attribute:: fndecl\n\n      The  declaration of the function being called (if any), as a\n      :py:class:`gcc.Tree`\n\n   .. py:attribute:: args\n\n      The arguments for the call, as a list of :py:class:`gcc.Tree`\n\n   .. py:attribute:: noreturn\n\n      (boolean) Has this call been marked as not returning?  (e.g. a call to\n      `exit`)\n\n.. py:class:: gcc.GimpleReturn\n\n   Subclass of :py:class:`gcc.Gimple`: a \"return\" statement, signifying the end\n   of a :py:class:`gcc.BasicBlock`::\n\n       RETURN [RETVAL];\n\n   .. py:attribute:: retval\n\n   The return value, as a :py:class:`gcc.Tree`, or `None`.\n\n.. py:class:: gcc.GimpleCond\n\n   Subclass of :py:class:`gcc.Gimple`: a conditional jump, of the form::\n\n     if (LHS EXPRCODE RHS) goto TRUE_LABEL else goto FALSE_LABEL\n\n   .. py:attribute:: lhs\n\n      Left-hand-side of the comparison, as a :py:class:`gcc.Tree`\n\n   .. py:attribute:: exprcode\n\n      The comparison predicate, as a :py:class:`gcc.Comparison` subclass (the\n      type itself, not an instance).  For example, the gcc.GimpleCond statement\n      for this fragment of C code::\n\n         if (a == b)\n\n      would have stmt.exprcode == gcc.EqExpr\n\n   .. py:attribute:: rhs\n\n      The right-hand-side of the comparison, as a :py:class:`gcc.Tree`\n\n   .. py:attribute:: true_label\n\n      The :py:class:`gcc.LabelDecl` node used as the jump target for when the\n      comparison is true\n\n   .. py:attribute:: false_label\n\n      The :py:class:`gcc.LabelDecl` node used as the jump target for when the\n      comparison is false\n\n   Note that a C conditional of the form::\n\n     if (some_int) {suiteA} else {suiteB}\n\n   is implicitly expanded to::\n\n     if (some_int != 0) {suiteA} else {suiteB}\n\n   and this becomes a gcc.GimpleCond with `lhs` as the integer, `exprcode` as\n   `<type 'gcc.NeExpr'>`, and `rhs` as `gcc.IntegerCst(0)`.\n\n.. py:class:: gcc.GimplePhi\n\n   Subclass of :py:class:`gcc.Gimple` used in the SSA passes: a \"PHI\" or\n   \"phoney\" function, for merging the various possible values a variable can\n   have based on the edge that we entered this :py:class:`gcc.BasicBlock` on::\n\n      LHS = PHI <ARG1, ..., ARGN>;\n\n   .. py:attribute:: lhs\n\n      Left-hand-side of the assignment, as a :py:class:`gcc.SsaName`\n\n   .. py:attribute:: args\n\n      A list of (:py:class:`gcc.Tree`, :py:class:`gcc.Edge`) pairs representing\n      the possible (expr, edge) inputs.  Each `expr` is either a\n      :py:class:`gcc.SsaName` or a :py:class:`gcc.Constant`\n\n.. py:class:: gcc.GimpleSwitch\n\n   Subclass of :py:class:`gcc.Gimple`: a switch statement, signifying the end of a\n   :py:class:`gcc.BasicBlock`::\n\n      switch (INDEXVAR)\n      {\n        case LAB1: ...; break;\n        ...\n        case LABN: ...; break;\n        default: ...\n      }\n\n   .. py:attribute:: indexvar\n\n      The index variable used by the switch statement, as a :py:class:`gcc.Tree`\n\n   .. py:attribute:: labels\n\n      The labels of the switch statement, as a list of :py:class:`gcc.CaseLabelExpr`.\n\n      The initial label in the list is always the default.\n\n.. py:class:: gcc.GimpleLabel\n\n   Subclass of :py:class:`gcc.Gimple`, representing a \"label\" statement::\n\n   .. py:attribute:: labels\n\n      The underlying :py:class:`gcc.LabelDecl` node representing this jump\n      target\n\n.. py:class:: gcc.GimpleAssign\n\n   Subclass of :py:class:`gcc.Gimple`: an assignment of an expression to an\n   l-value::\n\n      LHS = RHS1 EXPRCODE RHS2;\n\n   .. py:attribute:: lhs\n\n      Left-hand-side of the assignment, as a :py:class:`gcc.Tree`\n\n   .. py:attribute:: rhs\n\n      The operands on the right-hand-side of the expression, as a list of\n      :py:class:`gcc.Tree` instances (either of length 1 or length 2,\n      depending on the expression).\n\n   .. py:attribute:: exprcode\n\n      The kind of the expression, as an :py:class:`gcc.Tree` subclass (the type\n      itself, not an instance)\n\n.. py:class:: gcc.GimpleNop\n\n   Subclass of :py:class:`gcc.Gimple`, representing a \"do-nothing\" statement\n   (a.k.a. \"no operation\").\n\n  .. Here's a dump of the class hierarchy, from help(gcc):\n  ..    Gimple\n  ..        GimpleAsm\n  ..        GimpleAssign\n  ..        GimpleBind\n  ..        GimpleCall\n  ..        GimpleCatch\n  ..        GimpleCond\n  ..        GimpleDebug\n  ..        GimpleEhDispatch\n  ..        GimpleEhFilter\n  ..        GimpleEhMustNotThrow\n  ..        GimpleErrorMark\n  ..        GimpleGoto\n  ..        GimpleLabel\n  ..        GimpleNop\n  ..        GimpleOmpAtomicLoad\n  ..        GimpleOmpAtomicStore\n  ..        GimpleOmpContinue\n  ..        GimpleOmpCritical\n  ..        GimpleOmpFor\n  ..        GimpleOmpMaster\n  ..        GimpleOmpOrdered\n  ..        GimpleOmpParallel\n  ..        GimpleOmpReturn\n  ..        GimpleOmpSection\n  ..        GimpleOmpSections\n  ..        GimpleOmpSectionsSwitch\n  ..        GimpleOmpSingle\n  ..        GimpleOmpTask\n  ..        GimplePhi\n  ..        GimplePredict\n  ..        GimpleResx\n  ..        GimpleReturn\n  ..        GimpleSwitch\n  ..        GimpleTry\n  ..        GimpleWithCleanupExpr\n"
  },
  {
    "path": "docs/index.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. gcc-python-plugin documentation master file, created by\n   sphinx-quickstart on Wed Jun  1 15:53:48 2011.\n   You can adapt this file completely to your liking, but it should at least\n   contain the root `toctree` directive.\n\nGCC Python plugin\n=================\n\nContents:\n\n.. toctree::\n   :maxdepth: 2\n\n   basics.rst\n   gcc-overview.rst\n   examples.rst\n   working-with-c.rst\n   locations.rst\n   diagnostics.rst\n   cfg.rst\n   tree.rst\n   gimple.rst\n   passes.rst\n   callbacks.rst\n   attributes.rst\n   cpychecker.rst\n   success.rst\n   getting-involved.rst\n   misc.rst\n   release-notes.rst\n   appendices.rst\n\nThis document describes the Python plugin I've written for GCC.  In theory the\nplugin allows you to write Python scripts that can run inside GCC as it\ncompiles code, exposing GCC's internal data structures as a collection of\nPython classes and functions.  The bulk of the document describes the Python API\nit exposes.\n\nHopefully this will be of use for writing domain-specific warnings, static\nanalysers, and the like, and for rapid prototyping of new GCC features.\n\nI've tried to stay close to GCC's internal representation, but using classes.\nI hope that the resulting API is pleasant to work with.\n\nThe plugin is a work-in-progress; the API may well change.\n\nBear in mind that writing this plugin has been the first time I have worked\nwith the insides of GCC.  I have only wrapped the types I have needed, and\nwithin them, I've only wrapped properties that seemed useful to me.  There may\nwell be plenty of interesting class and properties for instances that can be\nadded (patches most welcome!).  I may also have misunderstood how things work.\n\nMost of my development has been against Python 2 (2.7, actually), but I've tried\nto make the source code of the plugin buildable against both Python 2 and\nPython 3 (3.2), giving separate python2.so and python3.so plugins.  (I suspect\nthat it's only possible to use one or the other within a particular invocation\nof \"gcc\", due to awkward dynamic-linker symbol collisions between the two\nversions of Python).\n\nThe plugin is Free Software, licensed under the GPLv3 (or later).\n\n\nIndices and tables\n==================\n\n* :ref:`genindex`\n* :ref:`modindex`\n* :ref:`search`\n\n"
  },
  {
    "path": "docs/locations.rst",
    "content": ".. Copyright 2011-2012, 2017-2018 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2012, 2017-2018 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nLocations\n=========\n\n.. py:function:: gccutils.get_src_for_loc(loc)\n\n      Given a :py:class:`gcc.Location`, get the source line as a string\n      (without trailing whitespace or newlines)\n\n.. py:class:: gcc.Location\n\n   Wrapper around GCC's `location_t`, representing a location within the source\n   code.  Use :py:func:`gccutils.get_src_for_loc` to get at the line of actual\n   source code.\n\n   The output from __repr__ looks like this::\n\n      gcc.Location(file='./src/test.c', line=42)\n\n   The output from__str__  looks like this::\n\n      ./src/test.c:42\n\n   .. py:attribute:: file\n\n      (string) Name of the source file (or header file)\n\n   .. py:attribute:: line\n\n      (int) Line number within source file (starting at 1, not 0)\n\n   .. py:attribute:: column\n\n      (int) Column number within source file  (starting at 1, not 0)\n\n   .. py:attribute:: in_system_header\n\n      (bool) This attribute flags locations that are within a system header\n      file.  It may be of use when writing custom warnings, so that you\n      can filter out issues in system headers, leaving just those within\n      the user's code::\n\n         # Don't report on issues found in system headers:\n         if decl.location.in_system_header:\n             return\n\n   .. py:method:: offset_column(self, offset)\n\n      Generate a new :py:class:`gcc.Location` based on the caret location\n      of this location, offsetting the column by the given amount.\n\n   From GCC 6 onwards, these values can represent both a caret and a range,\n   e.g.::\n\n      a = (foo && bar)\n          ~~~~~^~~~~~~\n\n   .. py:method:: __init__(self, caret, start, finish)\n\n      Construct a location, using the caret location of caret as the\n      caret, and the start/finish of start and finish respectively::\n\n        compound_loc = gcc.Location(caret, start, finish)\n\n   .. py:attribute:: caret\n\n      (:py:class:`gcc.Location`) The caret location within this location.\n      In the above example, the caret is on the first '&' character.\n\n   .. py:attribute:: start\n\n      (:py:class:`gcc.Location`) The start location of this range.\n      In the above example, the start is on the opening parenthesis.\n\n   .. py:attribute:: finish\n\n      (:py:class:`gcc.Location`) The finish location of this range.\n      In the above example, the finish is on the closing parenthesis.\n\n.. py:class:: gcc.RichLocation\n\n   Wrapper around GCC's `rich_location`, representing one or more locations\n   within the source code, and zero or more fix-it hints.\n\n   .. note::\n\n      gcc.RichLocation is only available from GCC 6 onwards\n\n   .. method:: add_fixit_replace(self, new_content)\n\n      Add a fix-it hint, suggesting replacement of the content covered\n      by range 0 of the rich location with new_content.\n"
  },
  {
    "path": "docs/lto.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nWhole-program Analysis via Link-Time Optimization (LTO)\n=======================================================\nYou can enable GCC's \"link time optimization\" feature by passing `-flto`.\n\nWhen this is enabled, gcc adds extra sections to the compiled .o file\ncontaining the SSA-Gimple internal representation of every function, so that\nthis SSA representation is available at link-time.  This allows gcc to inline\nfunctions defined in one source file into functions defined in another\nsource file at link time.\n\nAlthough the feature is intended for optimization, we can also use it for\ncode analysis, and it's possible to run the Python plugin at link time.\n\nThis means we can do interprocedural analysis across multiple source files.\n\n.. warning:: Running a gcc plugin from inside link-time optimization is\n   rather novel, and you're more likely to run into bugs.  See e.g.\n   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54962\n\nAn invocation might look like this:\n\n.. code-block:: bash\n\n  gcc \\\n     -flto \\\n     -flto-partition=none \\\n     -v \\\n     -fplugin=PATH/TO/python.so \\\n     -fplugin-arg-python-script=PATH/TO/YOUR/SCRIPT.py \\\n     INPUT-1.c \\\n     INPUT-2.c \\\n     ...\n     INPUT-n.c\n\nLooking at the above options in turn:\n\n  * `-flto` enables link-time optimization\n\n  * `-flto-partition=none` : by default, gcc with LTO partitions the code\n    and generates summary information for each partition, then combines the\n    results of the summaries (known as \"WPA\" and \"LTRANS\" respectively).\n    This appears to be of use for optimization, but to get at the function\n    bodies, for static analysis, you should pass this option, which instead\n    gathers all the code into one process.\n\n  * `-v` means \"verbose\" and is useful for seeing all of the subprograms\n    that gcc invokes, along with their command line options.  Given the\n    above options, you should see invocations of `cc1` (the C compiler),\n    `collect2` (the linker) and `lto1` (the link-time optimizer).\n\nFor example,\n\n.. code-block:: bash\n\n   $ ./gcc-with-python \\\n     examples/show-lto-supergraph.py \\\n     -flto \\\n     -flto-partition=none \\\n     tests/examples/lto/input-*.c\n\nwill render a bitmap of the supergraph like this:\n\n    .. figure:: sample-supergraph.png\n      :scale: 50 %\n      :alt: image of a supergraph\n\n.. py:function:: gcc.is_lto()\n\n   :rtype: bool\n\n   Determine whether or not we're being invoked during link-time\n   optimization (i.e. from within the `lto1` program)\n\n   .. warning:: The underlying boolean is not set up until passes are being\n      invoked: it is always `False` during the initial invocation of the\n      Python script.\n\n"
  },
  {
    "path": "docs/misc.rst",
    "content": ".. Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nMiscellanea\n===========\n\nThe following odds and ends cover the more esoteric aspects of GCC, and are\ndocumented here for completeness.  They may or may not be useful when writing\nscripts.\n\n.. toctree::\n\n   callgraph.rst\n   lto.rst\n   options.rst\n   parameters.rst\n   preprocessor.rst\n   versions.rst\n   rtl.rst\n"
  },
  {
    "path": "docs/operators.rst",
    "content": ".. Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n:py:class:`gcc.Tree` operators by symbol\n----------------------------------------\n\n.. _get_symbols:\n\nThe following shows the symbol used for each expression subclass in debug\ndumps, as returned by the various `get_symbol()` class methods.\n\nThere are some duplicates (e.g. `-` is used for both :py:class:`gcc.MinusExpr`\nas an infix binary operator, and by :py:class:`gcc.NegateExpr` as a prefixed\nunary operator).\n\n.. include:: ../tests/plugin/expressions/get_symbol/stdout.txt\n"
  },
  {
    "path": "docs/options.rst",
    "content": "Inspecting GCC's command-line options\n=====================================\n\nGCC's command-line options are visible from Python scripts as instances of\n:py:class:`gcc.Option`.\n\n.. py:class:: gcc.Option\n\n   Wrapper around one of GCC's command-line options.\n\n   You can locate a specific option using its `text` attribute::\n\n      option = gcc.Option('-Wdiv-by-zero')\n\n   The plugin will raise a `ValueError` if the option is not recognized.\n\n   It does not appear to be possible to create new options from the plugin.\n\n   .. py:attribute:: text\n\n      (string) The text used at the command-line to affect this option\n      e.g. `-Werror`.\n\n   .. py:attribute:: help\n\n      (string) The help text for this option (e.g. \"Warn about uninitialized\n      automatic variables\")\n\n   .. py:attribute:: is_enabled\n\n      (bool) Is this option enabled?\n\n      .. note:: Unfortunately, for many options, the internal implementation\n         makes it difficult to extract this.  The plugin will raise a\n\t `NotImplementedError` exception when querying this attribute for such\n\t an option.\n\n\t Calling :py:meth:`gcc.warning` with such an option will lead to GCC's\n\t warning machinery treating the option as enabled and emitting a\n\t warning, regardless of whether or not the option was actually enabled.\n\n\t It appears that this must be fixed on an option-by-option basis within\n\t the plugin.\n\n   .. py:attribute:: is_driver\n\n      (bool) Is this a driver option?\n\n   .. py:attribute:: is_optimization\n\n      (bool) Does this option control an optimization?\n\n   .. py:attribute:: is_target\n\n      (bool) Is this a target-specific option?\n\n   .. py:attribute:: is_warning\n\n      (bool) Does this option control a warning message?\n\n   Internally, the class wraps GCC's `enum opt_code` (and thus a `struct cl_option`)\n\n\n.. py:function:: gcc.get_option_list()\n\n    Returns a list of all :py:class:`gcc.Option` instances.\n\n.. py:function:: gcc.get_option_dict()\n\n    Returns a dictionary, mapping from the option names to :py:class:`gcc.Option` instances\n\n"
  },
  {
    "path": "docs/parameters.rst",
    "content": "Working with GCC's tunable parameters\n=====================================\n\nGCC has numerous tunable parameters, which are integer values, tweakable at\nthe command-line by:\n\n.. code-block:: bash\n\n   --param <name>=<value>\n\nA detailed description of the current parameters (in GCC 4.6.0) can be seen at\nhttp://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Optimize-Options.html#Optimize-Options\n(search for \"--param\" on that page; there doesn't seem to be an anchor to the list)\n\nThe parameters are visible from Python scripts using the following API:\n\n.. py:function:: gcc.get_parameters()\n\n    Returns a dictionary, mapping from the option names to :py:class:`gcc.Parameter` instances\n\n.. py:class:: gcc.Parameter\n\n   .. py:attribute:: option\n\n      (string) The name used with the command-line --param switch to set this value\n\n   .. py:attribute:: current_value\n\n      (int/long)\n\n   .. py:attribute:: default_value\n\n      (int/long)\n\n   .. py:attribute:: min_value\n\n      (int/long) The minimum acceptable value\n\n   .. py:attribute:: max_value\n\n      (int/long) The maximum acceptable value, if greater than min_value\n\n   .. py:attribute:: help\n\n      (string) A short description of the option.\n\n"
  },
  {
    "path": "docs/passes.rst",
    "content": ".. Copyright 2011, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\n.. For notes on how to document Python in RST form, see e.g.:\n.. http://sphinx.pocoo.org/domains.html#the-python-domain\n\nOptimization passes\n===================\n\nWorking with existing passes\n----------------------------\nGCC organizes the optimization work it does as \"passes\", and these form trees:\npasses can have both successors and child passes.\n\nThere are actually five \"roots\" to this tree:\n\n   * The :py:class:`gcc.Pass` holding :ref:`all \"lowering\" passes <all_lowering_passes>`,\n     invoked per function within the callgraph, to turn high-level GIMPLE into\n     lower-level forms (this wraps `all_lowering_passes` within gcc/passes.c).\n\n   * The :py:class:`gcc.Pass` holding :ref:`all \"small IPA\" passes <all_small_ipa_passes>`,\n     working on the whole callgraph (IPA is \"Interprocedural Analysis\";\n     `all_small_ipa_passes` within gcc/passes.c)\n\n   * The :py:class:`gcc.Pass` holding :ref:`all regular IPA passes <all_regular_ipa_passes>`\n     (`all_regular_ipa_passes` within gcc/passes.c)\n\n   * The :py:class:`gcc.Pass` holding those :ref:`passes relating to link-time-optimization\n     <all_lto_gen_passes>` (`all_lto_gen_passes` within gcc/passes.c)\n\n   * The :ref:`\"all other passes\" gcc.Pass catchall <all_passes>`, holding the\n     majority of the passes.  These are called on each function within the call\n     graph (`all_passes`  within gcc/passes.c)\n\n.. classmethod:: gcc.Pass.get_roots()\n\n   Returns a 5-tuple of :py:class:`gcc.Pass` instances, giving the 5 top-level\n   passes within GCC's tree of passes, in the order described above.\n\n.. classmethod:: gcc.Pass.get_by_name(name)\n\n   Get the :py:class:`gcc.Pass` instance for the pass with the given name,\n   raising ValueError if it isn't found\n\n.. py:class:: gcc.Pass\n\n   This wraps one of GCC's `struct opt_pass *` instances.\n\n   Beware:  \"pass\" is a reserved word in Python, so use e.g. `ps` as a variable\n   name for an instance of :py:class:`gcc.Pass`\n\n   .. py:attribute:: name\n\n      The name of the pass, as a string\n\n   .. py:attribute:: sub\n\n      The first child pass of this pass (if any)\n\n   .. py:attribute:: next\n\n      The next sibling pass of this pass (if any)\n\n   .. py:attribute:: properties_required\n   .. py:attribute:: properties_provided\n   .. py:attribute:: properties_destroyed\n\n      Currently these are int bitfields, expressing the flow of data betweeen\n      the various passes.\n\n      They can be accessed using bitwise arithmetic::\n\n          if ps.properties_provided & gcc.PROP_cfg:\n\t       print(fn.cfg)\n\n      Here are the bitfield flags:\n\n         =========================   ============================================   =========================   =======================\n         Mask                        Meaning                                        Which pass sets this up?    Which pass clears this?\n         =========================   ============================================   =========================   =======================\n         gcc.PROP_gimple_any         Is the full GIMPLE grammar allowed?            (the frontend)              `\"expand\"`\n         gcc.PROP_gimple_lcf         Has control flow been lowered?                 `\"lower\"`                   `\"expand\"`\n         gcc.PROP_gimple_leh         Has exception-handling been lowered?           `\"eh\"`                      `\"expand\"`\n         gcc.PROP_cfg                Does the gcc.Function have a non-None \"cfg\"?   `\"cfg\"`                     `\"*free_cfg\"`\n         gcc.PROP_referenced_vars    Do we have data on which functions reference   `\"\\*referenced_vars\"`       (none)\n\t                             which variables? (Dataflow analysis, aka\n\t\t\t\t     DFA).  This flag was removed in GCC 4.8\n         gcc.PROP_ssa                Is the GIMPLE in SSA form?                     `\"ssa\"`                     `\"expand\"`\n         gcc.PROP_no_crit_edges      Have all critical edges within the CFG been    `\"crited\"`                  (none)\n                                     split?\n         gcc.PROP_rtl                Is the function now in RTL form? (rather       `\"expand\"`                  `\"*clean_state\"`\n\t                             than GIMPLE-SSA)\n         gcc.PROP_gimple_lomp        Have OpenMP directives been lowered into       `\"omplower\"`                `\"expand\"`\n\t                             explicit calls to the runtime library\n\t\t\t\t     (libgomp)\n         gcc.PROP_cfglayout          Are we reorganizing the CFG into a more        `\"into_cfglayout\"`          `\"outof_cfglayout\"`\n\t                             efficient order?\n         gcc.PROP_gimple_lcx         Have operations on complex numbers been        `\"cplxlower\"`               `\"cplxlower0\"`\n\t                             lowered to scalar operations?\n         =========================   ============================================   =========================   =======================\n\n   .. py:attribute:: static_pass_number\n\n      (int) The number of this pass, used as a fragment of the dump file name.\n      This is assigned automatically for custom passes.\n\n   .. py:attribute:: dump_enabled\n\n      (boolean) Is dumping enabled for this pass?  Set this attribute to `True`\n      to enable dumping.  Not available from GCC 4.8 onwards\n\nThere are four subclasses of :py:class:`gcc.Pass`:\n\n.. py:class:: gcc.GimplePass\n\n   Subclass of :py:class:`gcc.Pass`, signifying a pass called per-function on\n   the GIMPLE representation of that function.\n\n.. py:class:: gcc.RtlPass\n\n   Subclass of :py:class:`gcc.Pass`, signifying a pass called per-function on\n   the RTL representation of that function.\n\n.. py:class:: gcc.SimpleIpaPass\n\n   Subclass of :py:class:`gcc.Pass`, signifying a pass called once (not\n   per-function)\n\n.. py:class:: gcc.IpaPass\n\n   Subclass of :py:class:`gcc.Pass`, signifying a pass called once (not\n   per-function)\n\n.. _creating-new-passes:\n\nCreating new optimization passes\n--------------------------------\nYou can create new optimization passes.  This involves three steps:\n\n   * subclassing the appropriate :py:class:`gcc.Pass` subclass (e.g.\n     :py:class:`gcc.GimplePass`)\n\n   * creating an instance of your subclass\n\n   * registering the instance within the pass tree, relative to another pass\n\nHere's an example::\n\n   # Here's the (trivial) implementation of our new pass:\n   class MyPass(gcc.GimplePass):\n      # This is optional.\n      # If present, it should return a bool, specifying whether or not\n      # to execute this pass (and any child passes)\n      def gate(self, fun):\n          print('gate() called for %r' % fun)\n          return True\n\n      def execute(self, fun):\n          print('execute() called for %r' % fun)\n\n   # We now create an instance of the class:\n   my_pass = MyPass(name='my-pass')\n\n   # ...and wire it up, after the \"cfg\" pass:\n   my_pass.register_after('cfg')\n\nFor :py:class:`gcc.GimplePass` and :py:class:`gcc.RtlPass`, the signatures of\n`gate` and `execute` are:\n\n   .. method:: gate(self, fun)\n   .. method:: execute(self, fun)\n\nwhere fun is a :py:class:`gcc.Function`.\n\nFor :py:class:`gcc.SimpleIpaPass` and :py:class:`gcc.IpaPass`, the signature\nof `gate` and `execute` are:\n\n   .. method:: gate(self)\n   .. method:: execute(self)\n\n.. warning::\n\n   Unfortunately it doesn't appear to be possible to implement `gate()` for\n   `gcc.IpaPass` yet; for now, the `gate()` method on such passes will not be\n   called.  See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54959\n\nIf an unhandled exception is raised within `gate` or `execute`, it will lead\nto a GCC error:\n\n.. code-block:: pytb\n\n   /home/david/test.c:36:1: error: Unhandled Python exception raised calling 'execute' method\n   Traceback (most recent call last):\n     File \"script.py\", line 79, in execute\n      dot = gccutils.tree_to_dot(fun)\n   NameError: global name 'gccutils' is not defined\n\n.. method:: gcc.Pass.register_after(name [, instance_number=0 ])\n\n   Given the name of another pass, register this :py:class:`gcc.Pass` to occur\n   immediately after that other pass.\n\n   If the other pass occurs multiple times, the pass will be inserted at the\n   specified instance number, or at every instance, if supplied 0.\n\n   .. note::\n\n      The other pass must be of the same kind as this pass.  For example,\n      if it is a subclass of :py:class:`gcc.GimplePass`, then this pass must\n      also be a subclass of :py:class:`gcc.GimplePass`.\n\n      If they don't match, GCC won't be able to find the other pass, giving\n      an error like this::\n\n         cc1: fatal error: pass 'ssa' not found but is referenced by new pass 'my-ipa-pass'\n\n      where we attempted to register a :py:class:`gcc.IpaPass` subclass\n      relative to 'ssa', which is a :py:class:`gcc.GimplePass`\n\n.. method:: gcc.Pass.register_before(name [, instance_number=0 ])\n\n   As above, but this pass is registered immediately before the referenced\n   pass.\n\n.. method:: gcc.Pass.replace(name [, instance_number=0 ])\n\n   As above, but replace the given pass.  This method is included for\n   completeness; the result is unlikely to work well.\n\nDumping per-pass information\n----------------------------\nGCC has a logging framework which supports per-pass logging (\"dump files\").\n\nBy default, no logging is done; dumping must be explicitly enabled.\n\nDumping of passes can be enabled from the command-line in groups:\n\n   * `-fdump-tree-all` enables dumping for all :py:class:`gcc.GimplePass`\n     (both builtin, and custom ones from plugins)\n\n   * `-fdump-rtl-all` is similar, but for all :py:class:`gcc.RtlPass`\n\n   * `-fdump-ipa-all` as above, but for all :py:class:`gcc.IpaPass` and\n     :py:class:`gcc.SimpleIpaPass`\n\nFor more information, see\nhttp://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html\n\nIt's not possible to directly enable dumping for a custom pass from the\ncommand-line (it would require adding new GCC command-line options).  However,\nyour script *can* directly enable dumping for a custom pass by writing to the\n`dump_enabled` attribute (perhaps in response to the arguments passed to\nplugin, or a driver script).\n\nIf enabled for a pass, then a file is written to the same directory as the\noutput file, with a name based on the input file and the pass number.\n\nFor example, given a custom :py:class:`gcc.Pass` with name `'test-pass'`, then\nwhen `input.c` is compiled to `build/output.o`::\n\n   $ gcc -fdump-tree-all -o build/output.o src/input.c\n\nthen a dump file `input.c.225t.test-pass` will be written to the directory\n`build`.  In this case, `225` is the `static_pass_number` field, `\"t\"`\nsignifies a tree pass, with the pass name appearing as the suffix.\n\n.. py:function:: gcc.dump(obj)\n\n   Write str() of the argument to the current dump file.  No newlines or other\n   whitespace are added.\n\n   Note that dumping is disabled by default; in this case, the call will do\n   nothing.\n\n.. py:function:: gcc.get_dump_file_name()\n\n   Get the name of the current dump file.\n\n   If called from within a pass for which dumping is enabled, it will return\n   the filename in string form.\n\n   If dumping is disabled for this pass, it will return `None`.\n\nThe typical output of a dump file will contain::\n\n   ;; Function bar (bar)\n\n   (dumped information when handling function bar goes here)\n\n   ;; Function foo (foo)\n\n   (dumped information when handling function foo goes here)\n\nFor example::\n\n   class TestPass(gcc.GimplePass):\n       def execute(self, fun):\n           # Dumping of strings:\n           gcc.dump('hello world')\n\n           # Dumping of other objects:\n           gcc.dump(42)\n\n   ps = TestPass(name='test-pass')\n   ps.register_after('cfg')\n   ps.dump_enabled = True\n\nwould have a dump file like this::\n\n   ;; Function bar (bar)\n\n   hello world42\n   ;; Function foo (foo)\n\n   hello world42\n\nAlternatively, it can be simpler to create your own logging system, given that\none can simply open a file and write to it.\n\n.. py:function:: gcc.get_dump_base_name()\n\n   Get the base file path and name prefix for GCC's dump files.\n\n   You can use this when creating non-standard logfiles and other output.\n\n   For example, the libcpychecker code can write HTML reports on\n   reference-counting errors within a function, writing the output to a file\n   named::\n\n      filename = '%s.%s-refcount-errors.html' % (gcc.get_dump_base_name(),\n                                                 fun.decl.name)\n\n   given `fun`, a :py:class:`gcc.Function`.\n\n   By default, this is the name of the input file, but within the output\n   file's directory.  (It can be overridden using the `-dumpbase` command-line\n   option).\n"
  },
  {
    "path": "docs/preprocessor.rst",
    "content": "Working with the preprocessor\n=============================\n\nFor languages that support a preprocessor, it's possible to inject new\n\"built-in\" macros into the compilation from a Python script.\n\nThe motivation for this is to better support the creation of custom\nattributes, by creating preprocessor names that can be tested against.\n\n.. py:function:: gcc.define_macro(argument)\n\n   Defines a preprocessor macro with the given argument, which may be\n   of use for code that needs to test for the presence of your script.\n   The argument can either be a simple name, or a name with a\n   definition:\n\n   .. code-block:: python\n\n      gcc.define_macro(\"SOMETHING\")  # define as the empty string\n      gcc.define_macro(\"SOMETHING=72\")\n\n   This function can only be called from within specific event callbacks,\n   since it manipulates the state of the preprocessor for a given source\n   file.\n\n   For now, only call it in a handler for the event `gcc.PLUGIN_ATTRIBUTES`:\n\n   .. literalinclude:: ../tests/examples/attributes-with-macros/script.py\n    :lines: 18-\n    :language: python\n\n\n"
  },
  {
    "path": "docs/release-notes.rst",
    "content": ".. Copyright 2011-2018 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2018 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nRelease Notes\n=============\n\n.. toctree::\n   \n   0.17.rst\n   0.16.rst\n   0.15.rst\n   0.14.rst\n   0.13.rst\n   0.12.rst\n   0.11.rst\n   0.10.rst\n   0.9.rst\n   0.8.rst\n   0.7.rst\n"
  },
  {
    "path": "docs/rtl.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nRegister Transfer Language (RTL)\n================================\n\n.. py:class:: gcc.Rtl\n\n  A wrapper around GCC's `struct rtx_def` type: an expression within GCC's\n  Register Transfer Language\n\n  .. py:attribute:: loc\n\n     The :py:class:`gcc.Location` of this expression, or None\n\n  .. py:attribute:: operands\n\n     The operands of this expression, as a tuple.  The precise type of the\n     operands will vary by subclass.\n\nThere are numerous subclasses.  However, this part of the API is much less\npolished than the rest of the plugin.\n\n  .. Here's a dump of the class hierarchy, from help(gcc):\n  ..          Rtl\n  ..              RtxAutoinc\n  ..                  RtlPostDec\n  ..                  RtlPostInc\n  ..                  RtlPostModify\n  ..                  RtlPreDec\n  ..                  RtlPreInc\n  ..                  RtlPreModify\n  ..              RtxBinArith\n  ..                  RtlAshift\n  ..                  RtlAshiftrt\n  ..                  RtlCompare\n  ..                  RtlDiv\n  ..                  RtlLshiftrt\n  ..                  RtlMinus\n  ..                  RtlMod\n  ..                  RtlRotate\n  ..                  RtlRotatert\n  ..                  RtlSsAshift\n  ..                  RtlSsDiv\n  ..                  RtlSsMinus\n  ..                  RtlUdiv\n  ..                  RtlUmod\n  ..                  RtlUsAshift\n  ..                  RtlUsDiv\n  ..                  RtlUsMinus\n  ..                  RtlVecConcat\n  ..                  RtlVecSelect\n  ..              RtxBitfieldOps\n  ..                  RtlSignExtract\n  ..                  RtlZeroExtract\n  ..              RtxCommArith\n  ..                  RtlAnd\n  ..                  RtlIor\n  ..                  RtlMult\n  ..                  RtlPlus\n  ..                  RtlSmax\n  ..                  RtlSmin\n  ..                  RtlSsMult\n  ..                  RtlSsPlus\n  ..                  RtlUmax\n  ..                  RtlUmin\n  ..                  RtlUsMult\n  ..                  RtlUsPlus\n  ..                  RtlXor\n  ..              RtxCommCompare\n  ..                  RtlEq\n  ..                  RtlLtgt\n  ..                  RtlNe\n  ..                  RtlOrdered\n  ..                  RtlUneq\n  ..                  RtlUnordered\n  ..              RtxCompare\n  ..                  RtlGe\n  ..                  RtlGeu\n  ..                  RtlGt\n  ..                  RtlGtu\n  ..                  RtlLe\n  ..                  RtlLeu\n  ..                  RtlLt\n  ..                  RtlLtu\n  ..                  RtlUnge\n  ..                  RtlUngt\n  ..                  RtlUnle\n  ..                  RtlUnlt\n  ..              RtxConstObj\n  ..                  RtlConst\n  ..                  RtlConstDouble\n  ..                  RtlConstFixed\n  ..                  RtlConstInt\n  ..                  RtlConstVector\n  ..                  RtlHigh\n  ..                  RtlLabelRef\n  ..                  RtlSymbolRef\n  ..              RtxExtra\n  ..                  RtlAddrDiffVec\n  ..                  RtlAddrVec\n  ..                  RtlAsmInput\n  ..                  RtlAsmOperands\n  ..                  RtlBarrier\n  ..                  RtlCall\n  ..                  RtlClobber\n  ..                  RtlCodeLabel\n  ..                  RtlCondExec\n  ..                  RtlEhReturn\n  ..                  RtlExprList\n  ..                  RtlInsnList\n  ..                  RtlNote\n  ..                  RtlParallel\n  ..                  RtlPrefetch\n  ..                  RtlReturn\n  ..                  RtlSequence\n  ..                  RtlSet\n  ..                  RtlStrictLowPart\n  ..                  RtlSubreg\n  ..                  RtlTrapIf\n  ..                  RtlUnknown\n  ..                  RtlUnspec\n  ..                  RtlUnspecVolatile\n  ..                  RtlUse\n  ..                  RtlVarLocation\n  ..              RtxInsn\n  ..                  RtlCallInsn\n  ..                  RtlDebugInsn\n  ..                  RtlInsn\n  ..                  RtlJumpInsn\n  ..              RtxMatch\n  ..                  RtlAddress\n  ..              RtxObj\n  ..                  RtlCc0\n  ..                  RtlConcat\n  ..                  RtlConcatn\n  ..                  RtlConstString\n  ..                  RtlDebugExpr\n  ..                  RtlDebugImplicitPtr\n  ..                  RtlLoSum\n  ..                  RtlMem\n  ..                  RtlPc\n  ..                  RtlReg\n  ..                  RtlScratch\n  ..                  RtlValue\n  ..              RtxTernary\n  ..                  RtlFma\n  ..                  RtlIfThenElse\n  ..                  RtlVecMerge\n  ..              RtxUnary\n  ..                  RtlAbs\n  ..                  RtlBswap\n  ..                  RtlClz\n  ..                  RtlCtz\n  ..                  RtlFfs\n  ..                  RtlFix\n  ..                  RtlFloat\n  ..                  RtlFloatExtend\n  ..                  RtlFloatTruncate\n  ..                  RtlFractConvert\n  ..                  RtlNeg\n  ..                  RtlNot\n  ..                  RtlParity\n  ..                  RtlPopcount\n  ..                  RtlSatFract\n  ..                  RtlSignExtend\n  ..                  RtlSqrt\n  ..                  RtlSsAbs\n  ..                  RtlSsNeg\n  ..                  RtlSsTruncate\n  ..                  RtlTruncate\n  ..                  RtlUnsignedFix\n  ..                  RtlUnsignedFloat\n  ..                  RtlUnsignedFractConvert\n  ..                  RtlUnsignedSatFract\n  ..                  RtlUsNeg\n  ..                  RtlUsTruncate\n  ..                  RtlVecDuplicate\n  ..                  RtlZeroExtend\n"
  },
  {
    "path": "docs/success.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nSuccess Stories\n===============\n\nIf you use the gcc python plugin to improve your code, we'd love to hear about\nit.\n\nIf you want to share a success story here, please email the plugin's `mailing list\n<https://fedorahosted.org/mailman/listinfo/gcc-python-plugin/>`_.\n\nThe `GNU Debugger <http://sourceware.org/gdb/>`_\n------------------------------------------------\nBugs found in gdb by compiling it with the plugin's\n:ref:`gcc-with-cpychecker <cpychecker>` script:\n\n   * http://sourceware.org/bugzilla/show_bug.cgi?id=13308\n   * http://sourceware.org/bugzilla/show_bug.cgi?id=13309\n   * http://sourceware.org/bugzilla/show_bug.cgi?id=13310\n   * http://sourceware.org/bugzilla/show_bug.cgi?id=13316\n   * http://sourceware.org/ml/gdb-patches/2011-06/msg00376.html\n   * http://sourceware.org/ml/gdb-patches/2011-10/msg00391.html\n   * http://sourceware.org/bugzilla/show_bug.cgi?id=13331\n\nTom Tromey also wrote specialized Python scripts to use the GCC plugin to\nlocate bugs within GDB.\n\nOne of his scripts analyzes gdb's resource-management code, which found some\nresource leaks and a possible crasher:\n\n   * http://sourceware.org/ml/gdb-patches/2011-06/msg00408.html\n\nThe other generates a whole-program call-graph, annotated with information\non gdb's own exception-handling mechanism.  A script then finds places where\nthese exceptions were not properly integrated with gdb's embedded Python\nsupport:\n\n   * http://sourceware.org/ml/gdb/2011-11/msg00002.html\n   * http://sourceware.org/bugzilla/show_bug.cgi?id=13369\n\n\n`LibreOffice <http://www.libreoffice.org/>`_\n--------------------------------------------\nStephan Bergmann wrote a script to analyze LibreOffice's source code, detecting\na particular usage pattern of C++ method calls:\n\n   * https://fedorahosted.org/pipermail/gcc-python-plugin/2011-December/000136.html\n   * https://bugs.freedesktop.org/show_bug.cgi?id=43460\n\n`psycopg <http://initd.org/psycopg/>`_\n--------------------------------------\nDaniele Varrazzo used the plugin's :ref:`gcc-with-cpychecker <cpychecker>`\nscript on `psycopg <http://initd.org/psycopg/>`_, the popular Python interface\nto `PostgreSQL <http://www.postgresql.org/>`_, and was able to find and fix\nnumerous subtle errors:\n\n  * https://fedorahosted.org/pipermail/gcc-python-plugin/2012-March/000229.html\n  * http://initd.org/psycopg/articles/2012/03/29/psycopg-245-released/\n\npycups\n------\nBugs found in the `Python bindings for the CUPS API\n<http://cyberelk.net/tim/software/pycups/>`_ by compiling it with the\nplugin's :ref:`gcc-with-cpychecker <cpychecker>` script:\n\n  * https://fedorahosted.org/pycups/ticket/17\n\npython-krbV\n-----------\n\nBug found in the `Python bindings for the Kerberos 5 API\n<https://fedorahosted.org/python-krbV/>`_ by compiling it with the\nplugin's :ref:`gcc-with-cpychecker <cpychecker>` script:\n\n  * https://fedorahosted.org/python-krbV/ticket/1\n\nBugs found in itself\n--------------------\nBugs found and fixed in the gcc Python plugin itself, by running the the\nplugin's :ref:`gcc-with-cpychecker <cpychecker>` script when compiling another\ncopy:\n\n   * various reference counting errors:\n\n     * http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commitdiff;h=a9f48fac24a66c77007d99bf23f2eab188eb909e\n\n     * http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commitdiff;h=2922ad81c8e0ea954d462433ecc83d86d9ebab68\n\n     * http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commitdiff;h=4642a564e03c9e2c8114bca206205ad9c8fbc308>\n\n   * bad format string: https://fedorahosted.org/pipermail/gcc-python-plugin/2011-August/000065.html\n\n   * minor const-correctness error: http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=commitdiff;h=4fe4a83288e04be35a96d0bfec332197fb32c358\n"
  },
  {
    "path": "docs/tables-of-passes.rst",
    "content": ".. This file is autogenerated, using:\n   ./gcc-with-python generate-tables-of-passes-rst.py test.c\n\nAll of GCC's passes\n===================\n\n\nThis diagram shows the various GCC optimization passes, arranged vertically,\nshowing child passes via indentation.\n\nThe lifetime of the various properties that they maintain is shown, giving\nthe pass that initially creates the data (if any), the pass that destroys it\n(if any), and each pass that requires a particular property (based on the\nPROP_* flags).\n\n.. image:: passes.svg\n   :width: 550px\n   :height: 3302px\n   :scale: 50%\n\n\nThese tables contain the same information.  The diagram and tables were\nautogenerated, using GCC 4.6.0\n\n.. _all_lowering_passes:\n\nThe lowering passes\n-------------------\n\n   ======================  ===================  ===================  ====================\n   Pass Name               Required properties  Provided properties  Destroyed properties\n   ======================  ===================  ===================  ====================\n   \\*warn_unused_result    gimple_any\n   \\*diagnose_omp_blocks   gimple_any\n   mudflap1                gimple_any\n   omplower                gimple_any           gimple_lomp\n   lower                   gimple_any           gimple_lcf\n   ehopt                   gimple_lcf\n   eh                      gimple_lcf           gimple_leh\n   cfg                     gimple_leh           cfg\n   \\*warn_function_return  cfg\n   \\*build_cgraph_edges    cfg\n   ======================  ===================  ===================  ====================\n\n\n.. _all_small_ipa_passes:\n\nThe \"small IPA\" passes\n----------------------\n\n   ================================  =======================================  ===================  ====================\n   Pass Name                         Required properties                      Provided properties  Destroyed properties\n   ================================  =======================================  ===================  ====================\n   \\*free_lang_data                  gimple_any, gimple_lcf, gimple_leh, cfg\n   visibility\n   early_local_cleanups\n   > \\*free_cfg_annotations          cfg\n   > \\*init_datastructures           cfg\n   > ompexp                          gimple_any\n   > \\*referenced_vars               gimple_leh, cfg                          referenced_vars\n   > ssa                             cfg, referenced_vars                     ssa\n   > veclower                        cfg\n   > \\*early_warn_uninitialized      ssa\n   > \\*rebuild_cgraph_edges          cfg\n   > inline_param\n   > einline\n   > early_optimizations\n   > > \\*remove_cgraph_callee_edges\n   > > copyrename                    cfg, ssa\n   > > ccp                           cfg, ssa\n   > > forwprop                      cfg, ssa\n   > > ealias                        cfg, ssa\n   > > esra                          cfg, ssa\n   > > copyprop                      cfg, ssa\n   > > mergephi                      cfg, ssa\n   > > cddce                         cfg, ssa\n   > > eipa_sra\n   > > tailr                         cfg, ssa\n   > > switchconv                    cfg, ssa\n   > > ehcleanup                     gimple_lcf\n   > > profile                       cfg\n   > > local-pure-const\n   > > fnsplit                       cfg\n   > release_ssa                     ssa\n   > \\*rebuild_cgraph_edges          cfg\n   > inline_param\n   tree_profile_ipa\n   > feedback_fnsplit                cfg\n   increase_alignment\n   matrix-reorg\n   emutls                            cfg, ssa\n   ================================  =======================================  ===================  ====================\n\n\n.. _all_regular_ipa_passes:\n\nThe \"regular IPA\" passes\n------------------------\n\n   ================  =======================================  ===================  ====================\n   Pass Name         Required properties                      Provided properties  Destroyed properties\n   ================  =======================================  ===================  ====================\n   whole-program     gimple_any, gimple_lcf, gimple_leh, cfg\n   ipa-profile\n   cp\n   cdtor\n   inline\n   pure-const\n   static-var\n   type-escape-var\n   pta\n   ipa_struct_reorg\n   ================  =======================================  ===================  ====================\n\n\n.. _all_lto_gen_passes:\n\nPasses generating Link-Time Optimization data\n---------------------------------------------\n\n   ==============  =======================================  ===================  ====================\n   Pass Name       Required properties                      Provided properties  Destroyed properties\n   ==============  =======================================  ===================  ====================\n   lto_gimple_out  gimple_any, gimple_lcf, gimple_leh, cfg\n   lto_decls_out\n   ==============  =======================================  ===================  ====================\n\n\n.. _all_passes:\n\nThe \"all other passes\" catch-all\n--------------------------------\n\n   ==============================  =======================================  ===================  ====================================================\n   Pass Name                       Required properties                      Provided properties  Destroyed properties\n   ==============================  =======================================  ===================  ====================================================\n   ehdisp                          gimple_any, gimple_lcf, gimple_leh, cfg\n   \\*all_optimizations\n   > \\*remove_cgraph_callee_edges\n   > \\*strip_predict_hints         cfg\n   > copyrename                    cfg, ssa\n   > cunrolli                      cfg, ssa\n   > ccp                           cfg, ssa\n   > forwprop                      cfg, ssa\n   > cdce                          cfg, ssa\n   > alias                         cfg, ssa\n   > retslot                       ssa\n   > phiprop                       cfg, ssa\n   > fre                           cfg, ssa\n   > copyprop                      cfg, ssa\n   > mergephi                      cfg, ssa\n   > vrp                           ssa\n   > dce                           cfg, ssa\n   > cselim                        cfg, ssa\n   > ifcombine                     cfg, ssa\n   > phiopt                        cfg, ssa\n   > tailr                         cfg, ssa\n   > ch                            cfg, ssa\n   > stdarg                        cfg, ssa\n   > cplxlower                     ssa                                      gimple_lcx\n   > sra                           cfg, ssa\n   > copyrename                    cfg, ssa\n   > dom                           cfg, ssa\n   > phicprop                      cfg, ssa\n   > dse                           cfg, ssa\n   > reassoc                       cfg, ssa\n   > dce                           cfg, ssa\n   > forwprop                      cfg, ssa\n   > phiopt                        cfg, ssa\n   > objsz                         cfg, ssa\n   > ccp                           cfg, ssa\n   > copyprop                      cfg, ssa\n   > sincos                        ssa\n   > bswap                         ssa\n   > crited                        cfg                                      no_crit_edges\n   > pre                           cfg, ssa, no_crit_edges\n   > sink                          cfg, ssa, no_crit_edges\n   > loop                          cfg\n   > > loopinit                    cfg\n   > > lim                         cfg\n   > > copyprop                    cfg, ssa\n   > > dceloop                     cfg, ssa\n   > > unswitch                    cfg\n   > > sccp                        cfg, ssa\n   > > \\*record_bounds             cfg, ssa\n   > > ckdd                        cfg, ssa\n   > > ldist                       cfg, ssa\n   > > copyprop                    cfg, ssa\n   > > graphite0                   cfg, ssa\n   > > > graphite                  cfg, ssa\n   > > > lim                       cfg\n   > > > copyprop                  cfg, ssa\n   > > > dceloop                   cfg, ssa\n   > > ivcanon                     cfg, ssa\n   > > ifcvt                       cfg, ssa\n   > > vect                        cfg, ssa\n   > > > veclower2                 cfg\n   > > > dceloop                   cfg, ssa\n   > > pcom                        cfg\n   > > cunroll                     cfg, ssa\n   > > slp                         cfg, ssa\n   > > parloops                    cfg, ssa\n   > > aprefetch                   cfg, ssa\n   > > ivopts                      cfg, ssa\n   > > loopdone                    cfg\n   > recip                         ssa\n   > reassoc                       cfg, ssa\n   > vrp                           ssa\n   > dom                           cfg, ssa\n   > phicprop                      cfg, ssa\n   > cddce                         cfg, ssa\n   > tracer\n   > uninit                        ssa\n   > dse                           cfg, ssa\n   > forwprop                      cfg, ssa\n   > phiopt                        cfg, ssa\n   > fab                           cfg, ssa\n   > widening_mul                  ssa\n   > tailc                         cfg, ssa\n   > copyrename                    cfg, ssa\n   > uncprop                       cfg, ssa\n   > local-pure-const\n   cplxlower0                      cfg                                      gimple_lcx\n   ehcleanup                       gimple_lcf\n   resx                            gimple_lcf\n   nrv                             cfg, ssa\n   mudflap2                        gimple_leh, cfg, ssa\n   optimized                       cfg\n   \\*warn_function_noreturn        cfg\n   expand                          gimple_leh, cfg, ssa, gimple_lcx         rtl                  gimple_any, gimple_lcf, gimple_leh, ssa, gimple_lomp\n   \\*rest_of_compilation           rtl\n   > \\*init_function\n   > sibling\n   > rtl eh\n   > initvals\n   > unshare\n   > vregs\n   > into_cfglayout                                                         cfglayout\n   > jump\n   > subreg1\n   > dfinit\n   > cse1\n   > fwprop1\n   > cprop                         cfglayout\n   > rtl pre                       cfglayout\n   > hoist                         cfglayout\n   > cprop                         cfglayout\n   > store_motion                  cfglayout\n   > cse_local\n   > ce1\n   > reginfo\n   > loop2\n   > > loop2_init\n   > > loop2_invariant\n   > > loop2_unswitch\n   > > loop2_unroll\n   > > loop2_doloop\n   > > loop2_done\n   > web\n   > cprop                         cfglayout\n   > cse2\n   > dse1\n   > fwprop2\n   > auto_inc_dec\n   > init-regs\n   > ud dce\n   > combine                       cfglayout\n   > ce2\n   > bbpart                        cfglayout\n   > regmove\n   > outof_cfglayout                                                                             cfglayout\n   > split1\n   > subreg2\n   > no-opt dfinit\n   > \\*stack_ptr_mod\n   > mode_sw\n   > asmcons\n   > sms\n   > sched1\n   > ira\n   > \\*all-postreload              rtl\n   > > postreload\n   > > gcse2\n   > > split2\n   > > zee\n   > > cmpelim\n   > > btl1\n   > > pro_and_epilogue\n   > > dse2\n   > > csa\n   > > peephole2\n   > > ce3\n   > > rnreg\n   > > cprop_hardreg\n   > > rtl dce\n   > > bbro\n   > > btl2\n   > > \\*leaf_regs\n   > > split4\n   > > sched2\n   > > \\*stack_regs\n   > > > split3\n   > > > stack\n   > > alignments\n   > > compgotos\n   > > vartrack\n   > > \\*free_cfg                                                                                cfg\n   > > mach\n   > > barriers\n   > > dbr\n   > > split5\n   > > eh_ranges\n   > > shorten\n   > > nothrow\n   > > final\n   > dfinish\n   \\*clean_state                                                                                 rtl\n   ==============================  =======================================  ===================  ====================================================\n\n\n"
  },
  {
    "path": "docs/tree.rst",
    "content": ".. Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\ngcc.Tree and its subclasses\n===========================\n\nThe various language front-ends for GCC emit \"tree\" structures (which I believe\nare actually graphs), used throughout the rest of the internal representation of\nthe code passing through GCC.\n\n.. py:class:: gcc.Tree\n\n   A ``gcc.Tree`` is a wrapper around GCC's `tree` type\n\n   .. py:method:: debug()\n\n      Dump the tree to stderr, using GCC's own diagnostic routines\n\n   .. py:attribute:: type\n\n      Instance of :py:class:`gcc.Tree` giving the type of the node\n\n   .. py:attribute:: addr\n\n     (long) The address of the underlying GCC object in memory\n\n   The __str__ method is implemented using GCC's own pretty-printer for trees,\n   so e.g.::\n\n      str(t)\n\n   might return::\n\n      'int <T531> (int, char * *)'\n\n   for a `gcc.FunctionDecl`\n\n   .. py:attribute:: str_no_uid\n\n      A string representation of this object, like str(), but without\n      including any internal UIDs.\n\n      This is intended for use in selftests that compare output against some\n      expected value, to avoid embedding values that change into the expected\n      output.\n\n      For example, given the type declaration above, where `str(t)` might\n      return::\n\n         'int <T531> (int, char * *)'\n\n      where the UID \"531\" is liable to change from compile to compile, whereas\n      `t.str_no_uid` has value::\n\n         'int <Txxx> (int, char * *)'\n\n      which won't arbitrarily change each time.\n\nThere are numerous subclasses of :py:class:`gcc.Tree`, some with numerous\nsubclasses of their own.  Some important parts of the class hierarchy include:\n\n==================================   =======================================\nSubclass                             Meaning\n==================================   =======================================\n:py:class:`gcc.Binary`               A binary arithmetic expression, with\n                                     numerous subclasses\n:py:class:`gcc.Block`                A symbol-binding block\n:py:class:`gcc.Comparison`           A relational operators (with various\n                                     subclasses)\n:py:class:`gcc.Constant`             Subclasses for constants\n:py:class:`gcc.Constructor`          An aggregate value (e.g. in C, a\n                                     structure or array initializer)\n:py:class:`gcc.Declaration`          Subclasses relating to declarations\n                                     (variables, functions, etc)\n:py:class:`gcc.Expression`           Subclasses relating to expressions\n:py:class:`gcc.IdentifierNode`       A name\n:py:class:`gcc.Reference`            Subclasses for relating to reference to\n                                     storage (e.g. pointer values)\n:py:class:`gcc.SsaName`              A variable reference for SSA analysis\n:py:class:`gcc.Statement`            Subclasses for statement expressions,\n                                     which have side-effects\n:py:class:`gcc.Type`                 Subclasses for describing the types of\n                                     variables\n:py:class:`gcc.Unary`                Subclasses for unary arithmetic\n                                     expressions\n==================================   =======================================\n\n.. note::\n\n   Each subclass of :py:class:`gcc.Tree` is typically named\n   after either one of the `enum tree_code_class` or `enum tree_code` values,\n   with the names converted to Camel Case:\n\n   For example a :py:class:`gcc.Binary` is a wrapper around a `tree` of type\n   `tcc_binary`, and  a :py:class:`gcc.PlusExpr` is a wrapper around a `tree`\n   of type `PLUS_EXPR`.\n\n   As of this writing, only a small subset of the various fields of the different\n   subclasses have been wrapped yet, but it's generally easy to add new ones.  To\n   add new fields, I've found it easiest to look at `gcc/tree.h` and\n   `gcc/print-tree.c` within the GCC source tree and use the `print_node` function\n   to figure out what the valid fields are.  With that information, you should\n   then look at `generate-tree-c.py`, which is the code that generates the Python\n   wrapper classes (it's used when building the plugin to create\n   `autogenerated-tree.c`).  Ideally when exposing a field to Python you should\n   also add it to the API documentation, and add a test case.\n\n.. py:function:: gccutils.pformat(tree)\n\n   This function attempts to generate a debug dump of a :py:class:`gcc.Tree`\n   and all of its \"interesting\" attributes, recursively.  It's loosely modelled\n   on Python's `pprint` module and GCC's own `debug_tree` diagnostic routine\n   using indentation to try to show the structure.\n\n   It returns a string.\n\n   It differs from :py:meth:`gcc.Tree.debug()` in that it shows the Python\n   wrapper objects, rather than the underlying GCC data structures\n   themselves.  For example, it can't show attributes that haven't been\n   wrapped yet.\n\n   Objects that have already been reported within this call are abbreviated\n   to \"...\" to try to keep the output readable.\n\n   Example output::\n\n      <FunctionDecl\n        repr() = gcc.FunctionDecl('main')\n        superclasses = (<type 'gcc.Declaration'>, <type 'gcc.Tree'>)\n        .function = gcc.Function('main')\n        .location = /home/david/coding/gcc-python/test.c:15\n        .name = 'main'\n        .type = <FunctionType\n                  repr() = <gcc.FunctionType object at 0x2f62a60>\n                  str() = 'int <T531> (int, char * *)'\n                  superclasses = (<type 'gcc.Type'>, <type 'gcc.Tree'>)\n                  .name = None\n                  .type = <IntegerType\n                            repr() = <gcc.IntegerType object at 0x2f629d0>\n                            str() = 'int'\n                            superclasses = (<type 'gcc.Type'>, <type 'gcc.Tree'>)\n                            .const = False\n                            .name = <TypeDecl\n                                      repr() = gcc.TypeDecl('int')\n                                      superclasses = (<type 'gcc.Declaration'>, <type 'gcc.Tree'>)\n                                      .location = None\n                                      .name = 'int'\n                                      .pointer = <PointerType\n                                                   repr() = <gcc.PointerType object at 0x2f62b80>\n                                                   str() = ' *'\n                                                   superclasses = (<type 'gcc.Type'>, <type 'gcc.Tree'>)\n                                                   .dereference = ... (\"gcc.TypeDecl('int')\")\n                                                   .name = None\n                                                   .type = ... (\"gcc.TypeDecl('int')\")\n                                                 >\n                                      .type = ... ('<gcc.IntegerType object at 0x2f629d0>')\n                                    >\n                            .precision = 32\n                            .restrict = False\n                            .type = None\n                            .unsigned = False\n                            .volatile = False\n                          >\n                >\n      >\n\n.. py:function:: gccutils.pprint(tree)\n\n   Similar to :py:meth:`gccutils.pformat()`, but prints the output to stdout.\n\n   (should this be stderr instead? probably should take a stream as an arg, but\n   what should the default be?)\n\n\nBlocks\n------\n\n.. py:class:: gcc.Block\n\n   A symbol binding block, such as the global symbols within a compilation unit.\n\n   .. py:attribute:: vars\n\n      The list of :py:class:`gcc.Tree` for the declarations and labels in this\n      block\n\nDeclarations\n------------\n\n.. py:class:: gcc.Declaration\n\n   A subclass of :py:class:`gcc.Tree` indicating a declaration\n\n   Corresponds to the `tcc_declaration` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: name\n\n      (string) the name of this declaration\n\n\n   .. py:attribute:: location\n\n      The :py:class:`gcc.Location` for this declaration\n\n   .. py:attribute:: is_artificial\n\n      (bool) Is this declaration a compiler-generated entity, rather than\n      one provided by the user?\n\n      An example of such an \"artificial\" declaration occurs within the\n      arguments of C++ methods: the initial `this` argument is a\n      compiler-generated :py:class:`gcc.ParmDecl`.\n\n   .. py:attribute:: is_builtin\n\n      (bool) Is this declaration a compiler-builtin?\n\n.. py:class:: gcc.FieldDecl\n\n   A subclass of :py:class:`gcc.Declaration` indicating the declaration of a\n   field within a structure.\n\n   .. py:attribute:: name\n\n      (string) The name of this field\n\n\n.. py:class:: gcc.FunctionDecl\n\n   A subclass of :py:class:`gcc.Declaration` indicating the declaration of a\n   function.   Internally, this wraps a `(struct tree_function_decl *)`\n\n   .. py:attribute:: function\n\n      The :py:class:`gcc.Function` for this declaration\n\n   .. py:attribute:: arguments\n\n      List of :py:class:`gcc.ParmDecl` representing the arguments of this\n      function\n\n   .. py:attribute:: result\n\n      The :py:class:`gcc.ResultDecl` representing the return value of this\n      function\n\n   .. py:attribute:: fullname\n\n      .. note:: This attribute is only usable with C++ code.  Attempting to use\n         it from another language will lead to a `RuntimeError` exception.\n\n      (string) The \"full name\" of this function, including the scope, return\n      type and default arguments.\n\n      For example, given this code:\n\n      .. code-block:: c++\n\n         namespace Example {\n             struct Coord {\n                 int x;\n                 int y;\n             };\n\n             class Widget {\n             public:\n                 void set_location(const struct Coord& coord);\n             };\n         };\n\n      `set_location`'s fullname is::\n\n         'void Example::Widget::set_location(const Example::Coord&)'\n\n   .. py:attribute:: callgraph_node\n\n      The :py:class:`gcc.CallgraphNode` for this function declaration, or\n      `None`\n\n   .. py:attribute:: is_public\n\n      (bool) For C++: is this declaration \"public\"\n\n   .. py:attribute:: is_private\n\n      (bool) For C++: is this declaration \"private\"\n\n   .. py:attribute:: is_protected\n\n      (bool) For C++: is this declaration \"protected\"\n\n   .. py:attribute:: is_static\n\n      (bool) For C++: is this declaration \"static\"\n\n.. py:class:: gcc.ParmDecl\n\n   A subclass of :py:class:`gcc.Declaration` indicating the declaration of a\n   parameter to a function or method.\n\n.. py:class:: gcc.ResultDecl\n\n   A subclass of :py:class:`gcc.Declaration` declararing a dummy variable that\n   will hold the return value from a function.\n\n.. py:class:: gcc.VarDecl\n\n   A subclass of :py:class:`gcc.Declaration` indicating the declaration of a\n   variable (e.g. a global or a local).\n\n   .. py:attribute:: initial\n\n      The initial value for this variable as a :py:class:`gcc.Constructor`,\n      or None\n\n   .. py:attribute:: static\n\n      (boolean) Is this variable to be allocated with static storage?\n\n.. py:class:: gcc.NamespaceDecl\n\n   A subclass of :py:class:`gcc.Declaration` representing a C++ namespace\n\n   .. py:attribute:: alias_of\n\n      The :py:class:`gcc.NamespaceDecl` which this namespace is an alias of\n      or None if this namespace is not an alias.\n\n   .. py:attribute:: declarations\n\n      .. note:: This attribute is only usable with non-alias namespaces.\n                Accessing it on an alias will lead to a RuntimeError exception.\n\n      List of :py:class:`gcc.Declaration` objects in this namespace.\n      This attribute is only valid for non-aliases\n\n   .. py:attribute:: namespaces\n\n      .. note:: This attribute is only usable with non-alias namespaces.\n                Accessing it on an alias will lead to a RuntimeError exception.\n\n      List of :py:class:`gcc.NamespaceDecl` objects nested in this namespace.\n      This attribute is only valid for non-aliases\n\n   .. py:method:: lookup(name)\n\n      Locate the given name within the namespace, returning a\n      :py:class:`gcc.Tree` or `None`\n\n   .. py:method:: unalias()\n\n      Always returns a :py:class:`gcc.NamespaceDecl` object which is not an alias.\n      Returns self if this namespace is not an alias.\n\n\n  ..        Declaration\n  ..            ClassMethodDecl\n  ..            ConstDecl\n  ..            DebugExprDecl\n  ..            FieldDecl\n  ..            FunctionDecl\n  ..            ImportedDecl\n  ..            InstanceMethodDecl\n  ..            KeywordDecl\n  ..            LabelDecl\n  ..            NamespaceDecl\n  ..            ParmDecl\n  ..            PropertyDecl\n  ..            ResultDecl\n  ..            TemplateDecl\n  ..            TranslationUnitDecl\n  ..            TypeDecl\n  ..            UsingDecl\n  ..            VarDecl\n\n\nTypes\n-----\n\n.. py:class:: gcc.Type\n\n   A subclass of `gcc.Tree` indicating a type\n\n   Corresponds to the `tcc_type` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: name\n\n      The :py:class:`gcc.IdentifierNode` for the name of the type, or `None`.\n\n   .. py:attribute:: pointer\n\n      The :py:class:`gcc.PointerType` representing the `(this_type *)` type\n\n   .. py:attribute:: attributes\n\n      The user-defined attributes on this type (using GCC's `__attribute`\n      syntax), as a dictionary (mapping from attribute names to list of\n      values).  Typically this will be the empty dictionary.\n\n   .. py:attribute:: sizeof\n\n      `sizeof()` this type, as an `int`, or raising `TypeError` for those\n      types which don't have a well-defined size\n\n      .. note:: This attribute is not usable from within `lto1`; attempting\n         to use it there will lead to a `RuntimeError` exception.\n\nAdditional attributes for various :py:class:`gcc.Type` subclasses:\n\n   .. py:attribute:: const\n\n      (Boolean) Does this type have the `const` modifier?\n\n   .. py:attribute:: const_equivalent\n\n      The :py:class:`gcc.Type` for the `const` version of this type\n\n   .. py:attribute:: volatile\n\n      (Boolean) Does this type have the `volatile` modifier?\n\n   .. py:attribute:: volatile_equivalent\n\n      The :py:class:`gcc.Type` for the `volatile` version of this type\n\n   .. py:attribute:: restrict\n\n      (Boolean) Does this type have the `restrict` modifier?\n\n   .. py:attribute:: restrict_equivalent\n\n      The :py:class:`gcc.Type` for the `restrict` version of this type\n\n   .. py:attribute:: unqualified_equivalent\n\n      The :py:class:`gcc.Type` for the version of this type that does\n      not have any qualifiers.\n\n\n   The standard C types are accessible via class methods of :py:class:`gcc.Type`.\n   They are only created by GCC after plugins are loaded, and so they're\n   only visible during callbacks, not during the initial run of the code.\n   (yes, having them as class methods is slightly clumsy).\n\n   Each of the following returns a :py:class:`gcc.Type` instance representing\n   the given type (or None at startup before any passes, when the types don't\n   yet exist)\n\n      =============================  =====================\n      Class method                   C Type\n      =============================  =====================\n      gcc.Type.void()                `void`\n      gcc.Type.size_t()              `size_t`\n      gcc.Type.char()                `char`\n      gcc.Type.signed_char()         `signed char`\n      gcc.Type.unsigned_char()       `unsigned char`\n      gcc.Type.double()              `double`\n      gcc.Type.float()               `float`\n      gcc.Type.short()               `short`\n      gcc.Type.unsigned_short()      `unsigned short`\n      gcc.Type.int()                 `int`\n      gcc.Type.unsigned_int()        `unsigned int`\n      gcc.Type.long()                `long`\n      gcc.Type.unsigned_long()       `unsigned long`\n      gcc.Type.long_double()         `long double`\n      gcc.Type.long_long()           `long long`\n      gcc.Type.unsigned_long_long()  `unsigned long long`\n      gcc.Type.int128()              `int128`\n      gcc.Type.unsigned_int128()     `unsigned int128`\n      gcc.Type.uint32()              `uint32`\n      gcc.Type.uint64()              `uint64`\n      =============================  =====================\n\n.. py:class:: gcc.IntegerType\n\n   Subclass of :py:class:`gcc.Type`, adding a few properties:\n\n   .. py:attribute:: unsigned\n\n      (Boolean) True for 'unsigned', False for 'signed'\n\n   .. py:attribute:: precision\n\n      (int) The precision of this type in bits, as an int (e.g. 32)\n\n   .. py:attribute:: signed_equivalent\n\n      The gcc.IntegerType for the signed version of this type\n\n      .. note:: This attribute is not usable from within `lto1`; attempting\n         to use it there will lead to a `RuntimeError` exception.\n\n   .. py:attribute:: unsigned_equivalent\n\n      The gcc.IntegerType for the unsigned version of this type\n\n      .. note:: This attribute is not usable from within `lto1`; attempting\n         to use it there will lead to a `RuntimeError` exception.\n\n   .. py:attribute:: max_value\n\n      The maximum possible value for this type, as a\n      :py:class:`gcc.IntegerCst`\n\n   .. py:attribute:: min_value\n\n      The minimum possible value for this type, as a\n      :py:class:`gcc.IntegerCst`\n\n.. py:class:: gcc.FloatType\n\n   Subclass of :py:class:`gcc.Type` representing C's `float` and `double` types\n\n   .. py:attribute:: precision\n\n      (int) The precision of this type in bits (32 for `float`; 64 for\n      `double`)\n\n.. py:class:: gcc.PointerType\n\n   Subclass of :py:class:`gcc.Type` representing a pointer type, such as\n   an `int *`\n\n   .. py:attribute:: dereference\n\n      The :py:class:`gcc.Type` that this type points to.  In the above\n      example (`int *`), this would be the `int` type.\n\n.. py:class:: gcc.EnumeralType\n\n   Subclass of :py:class:`gcc.Type` representing an enumeral type.\n\n   .. py:attribute:: values\n\n      A list of tuple representing the constants defined in this\n      enumeration.  Each tuple consists of two elements; the first\n      being the name of the constant, a :py:class:`gcc.IdentifierNode`;\n      and the second being the value, a :py:class:`gcc.Constant`.\n\n.. py:class:: gcc.ArrayType\n\n   Subclass of :py:class:`gcc.Type` representing an array type.  For example,\n   in a C declaration such as::\n\n      char buf[16]\n\n   we have a :py:class:`gcc.VarDecl` for `buf`, and its type is an instance of\n   :py:class:`gcc.ArrayType`, representing `char [16]`.\n\n   .. py:attribute:: dereference\n\n      The :py:class:`gcc.Type` that this type points to.  In the above\n      example, this would be the `char` type.\n\n   .. py:attribute:: range\n\n      The :py:class:`gcc.Type` that represents the range of the\n      array's indices.  If the array has a known range, then this will\n      ordinarily be an :py:class:`gcc.IntegerType` whose `min_value`\n      and `max_value` are the (inclusive) bounds of the array.  If the\n      array does not have a known range, then this attribute will be\n      `None`.\n\n      That is, in the example above, `range.min_val` is `0`, and\n      `range.max_val` is `15`.\n\n      But, for a C declaration like::\n\n         extern char array[];\n\n      the type's `range` would be `None`.\n\n.. py:class:: gcc.VectorType\n\n   .. py:attribute:: dereference\n\n      The :py:class:`gcc.Type` that this type points to\n\n.. py:class:: gcc.FunctionType\n\n   Subclass of :py:class:`gcc.Type` representing the type of a given function\n   (or or a typedef to a function type, e.g. for callbacks).\n\n   See also :py:class:`gcc.FunctionType`\n\n   The `type` attribute holds the return type.\n\n   .. py:attribute:: is_variadic\n\n      True if this type represents a variadic function.  Note that for\n      a variadic function, the final `...` argument is not explicitly\n      represented in `argument_types`.\n\n   .. py:attribute:: argument_types\n\n      A tuple of :py:class:`gcc.Type` instances, representing the function's\n      argument types\n\n   .. py:function:: gccutils.get_nonnull_arguments(funtype)\n\n      This is a utility function for working with the `\"nonnull\"` custom\n      attribute on function types:\n\n      http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html\n\n      Return a `frozenset` of 0-based integers, giving the arguments for\n      which we can assume \"nonnull-ness\", handling the various cases of:\n\n          * the attribute isn't present (returning the empty frozenset)\n\n          * the attribute is present, without args (all pointer args are\n            non-NULL)\n\n          * the attribute is present, with a list of 1-based argument indices\n            (Note that the result is still 0-based)\n\n.. py:class:: gcc.MethodType\n\n   Subclass of :py:class:`gcc.Type` representing the type of a given method.\n   Similar to :py:class:`gcc.FunctionType`\n\n   The `type` attribute holds the return type.\n\n   .. py:attribute:: argument_types\n\n      A tuple of :py:class:`gcc.Type` instances, representing the function's\n      argument types\n\n.. py:class:: gcc.RecordType\n\n   A compound type, such as a C `struct`\n\n   .. py:attribute:: fields\n\n      The fields of this type, as a list of :py:class:`gcc.FieldDecl` instances\n\n   .. py:attribute:: methods\n\n      The methods of this type, as a list of :py:class:`gcc.MethodType` instances\n\n   You can look up C structures by looking within the top-level\n   :py:class:`gcc.Block` within the current translation unit.  For example,\n   given this sample C code:\n\n    .. literalinclude:: ../tests/examples/c/struct/input.c\n      :lines: 20-30\n      :language: c\n\n  then the following Python code:\n\n    .. literalinclude:: ../tests/examples/c/struct/script.py\n      :lines: 21-40\n\n  will generate this output:\n\n    .. literalinclude:: ../tests/examples/c/struct/stdout.txt\n\nConstants\n---------\n\n.. py:class:: gcc.Constant\n\n   Subclass of :py:class:`gcc.Tree` indicating a constant value.\n\n   Corresponds to the `tcc_constant` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: constant\n\n      The actual value of this constant, as the appropriate Python type:\n\n      ==============================  ===============\n      Subclass                        Python type\n      ==============================  ===============\n      .. py:class:: ComplexCst\n      .. py:class:: FixedCst\n      .. py:class:: IntegerCst        `int` or `long`\n      .. py:class:: PtrmemCst\n      .. py:class:: RealCst           `float`\n      .. py:class:: StringCst         `str`\n      .. py:class:: VectorCst\n      ==============================  ===============\n\n\nBinary Expressions\n------------------\n\n.. py:class:: gcc.Binary\n\n   Subclass of :py:class:`gcc.Tree` indicating a binary expression.\n\n   Corresponds to the `tcc_binary` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: location\n\n      The :py:class:`gcc.Location` for this binary expression\n\n   .. py:classmethod:: get_symbol()\n\n      Get the symbol used in debug dumps for this :py:class:`gcc.Binary`\n      subclass, if any, as a `str`.  A table showing these strings can be\n      seen :ref:`here <get_symbols>`.\n\n   Has subclasses for the various kinds of binary expression.  These\n   include:\n\n   .. These tables correspond to GCC's \"tree.def\"\n\n   Simple arithmetic:\n\n      ============================    ======================  ==============\n      Subclass                        C/C++ operators         enum tree_code\n      ============================    ======================  ==============\n      .. py:class:: gcc.PlusExpr      `+`                     PLUS_EXPR\n      .. py:class:: gcc.MinusExpr     `-`                     MINUS_EXPR\n      .. py:class:: gcc.MultExpr      `*`                     MULT_EXPR\n      ============================    ======================  ==============\n\n   Pointer addition:\n\n      =================================    =================  =================\n      Subclass                             C/C++ operators    enum tree_code\n      =================================    =================  =================\n      .. py:class:: gcc.PointerPlusExpr                       POINTER_PLUS_EXPR\n      =================================    =================  =================\n\n   Various division operations:\n\n      ==============================  ===============\n      Subclass                        C/C++ operators\n      ==============================  ===============\n      .. py:class:: gcc.TruncDivExr\n      .. py:class:: gcc.CeilDivExpr\n      .. py:class:: gcc.FloorDivExpr\n      .. py:class:: gcc.RoundDivExpr\n      ==============================  ===============\n\n   The remainder counterparts of the above division operators:\n\n      ==============================  ===============\n      Subclass                        C/C++ operators\n      ==============================  ===============\n      .. py:class:: gcc.TruncModExpr\n      .. py:class:: gcc.CeilModExpr\n      .. py:class:: gcc.FloorModExpr\n      .. py:class:: gcc.RoundModExpr\n      ==============================  ===============\n\n   Division for reals:\n\n      ===================================  ======================\n      Subclass                             C/C++ operators\n      ===================================  ======================\n      .. py:class:: gcc.RdivExpr\n      ===================================  ======================\n\n   Division that does not need rounding (e.g. for pointer subtraction in C):\n\n      ===================================  ======================\n      Subclass                             C/C++ operators\n      ===================================  ======================\n      .. py:class:: gcc.ExactDivExpr\n      ===================================  ======================\n\n   Max and min:\n\n      ===================================  ======================\n      Subclass                             C/C++ operators\n      ===================================  ======================\n      .. py:class:: gcc.MaxExpr\n      .. py:class:: gcc.MinExpr\n      ===================================  ======================\n\n    Shift and rotate operations:\n\n      ===================================  ======================\n      Subclass                             C/C++ operators\n      ===================================  ======================\n      .. py:class:: gcc.LrotateExpr\n      .. py:class:: gcc.LshiftExpr         `<<`, `<<=`\n      .. py:class:: gcc.RrotateExpr\n      .. py:class:: gcc.RshiftExpr         `>>`, `>>=`\n      ===================================  ======================\n\n   Bitwise binary expressions:\n\n      ===================================  =========================\n      Subclass                             C/C++ operators\n      ===================================  =========================\n      .. py:class:: gcc.BitAndExpr         `&`, `&=` (bitwise \"and\")\n      .. py:class:: gcc.BitIorExpr         `|`, `|=` (bitwise \"or\")\n      .. py:class:: gcc.BitXorExpr         `^`, `^=` (bitwise \"xor\")\n      ===================================  =========================\n\n  Other gcc.Binary subclasses:\n\n      ========================================  ==================================\n      Subclass                                  Usage\n      ========================================  ==================================\n      .. py:class:: gcc.CompareExpr\n      .. py:class:: gcc.CompareGExpr\n      .. py:class:: gcc.CompareLExpr\n      .. py:class:: gcc.ComplexExpr\n      .. py:class:: gcc.MinusNomodExpr\n      .. py:class:: gcc.PlusNomodExpr\n      .. py:class:: gcc.RangeExpr\n      .. py:class:: gcc.UrshiftExpr\n      .. py:class:: gcc.VecExtractevenExpr\n      .. py:class:: gcc.VecExtractoddExpr\n      .. py:class:: gcc.VecInterleavehighExpr\n      .. py:class:: gcc.VecInterleavelowExpr\n      .. py:class:: gcc.VecLshiftExpr\n      .. py:class:: gcc.VecPackFixTruncExpr\n      .. py:class:: gcc.VecPackSatExpr\n      .. py:class:: gcc.VecPackTruncExpr\n      .. py:class:: gcc.VecRshiftExpr\n      .. py:class:: gcc.WidenMultExpr\n      .. py:class:: gcc.WidenMultHiExpr\n      .. py:class:: gcc.WidenMultLoExpr\n      .. py:class:: gcc.WidenSumExpr\n      ========================================  ==================================\n \n\nUnary Expressions\n-----------------\n\n\n.. py:class:: gcc.Unary\n\n   Subclass of :py:class:`gcc.Tree` indicating a unary expression (i.e. taking a\n   single argument).\n\n   Corresponds to the `tcc_unary` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: operand\n\n      The operand of this operator, as a :py:class:`gcc.Tree`.\n\n   .. py:attribute:: location\n\n      The :py:class:`gcc.Location` for this unary expression\n\n   .. py:classmethod:: get_symbol()\n\n      Get the symbol used in debug dumps for this :py:class:`gcc.Unary`\n      subclass, if any, as a `str`.  A table showing these strings can be\n      seen :ref:`here <get_symbols>`.\n\n   Subclasses include:\n\n      ======================================  ==================================================\n      Subclass                                Meaning; C/C++ operators\n      ======================================  ==================================================\n      .. py:class:: gcc.AbsExpr               Absolute value\n      .. py:class:: gcc.AddrSpaceConvertExpr  Conversion of pointers between address spaces\n      .. py:class:: gcc.BitNotExpr            `~` (bitwise \"not\")\n      .. py:class:: gcc.CastExpr\n      .. py:class:: gcc.ConjExpr              For complex types: complex conjugate\n      .. py:class:: gcc.ConstCastExpr\n      .. py:class:: gcc.ConvertExpr\n      .. py:class:: gcc.DynamicCastExpr\n      .. py:class:: gcc.FixTruncExpr          Convert real to fixed-point, via truncation\n      .. py:class:: gcc.FixedConvertExpr\n      .. py:class:: gcc.FloatExpr             Convert integer to real\n      .. py:class:: gcc.NegateExpr            Unary negation\n      .. py:class:: gcc.NoexceptExpr\n      .. py:class:: gcc.NonLvalueExpr\n      .. py:class:: gcc.NopExpr\n      .. py:class:: gcc.ParenExpr\n      .. py:class:: gcc.ReducMaxExpr\n      .. py:class:: gcc.ReducMinExpr\n      .. py:class:: gcc.ReducPlusExpr\n      .. py:class:: gcc.ReinterpretCastExpr\n      .. py:class:: gcc.StaticCastExpr\n      .. py:class:: gcc.UnaryPlusExpr\n      ======================================  ==================================================\n\n\nComparisons\n------------\n\n.. py:class:: gcc.Comparison\n\n   Subclass of :py:class:`gcc.Tree` for comparison expressions\n\n   Corresponds to the `tcc_comparison` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: location\n\n      The :py:class:`gcc.Location` for this comparison\n\n   .. py:classmethod:: get_symbol()\n\n      Get the symbol used in debug dumps for this :py:class:`gcc.Comparison`\n      subclass, if any, as a `str`.  A table showing these strings can be\n      seen :ref:`here <get_symbols>`.\n\n   Subclasses include:\n\n      =====================================  ======================\n      Subclass                               C/C++ operators\n      =====================================  ======================\n      .. py:class:: EqExpr                   `==`\n      .. py:class:: GeExpr                   `>=`\n      .. py:class:: GtExpr                   `>`\n      .. py:class:: LeExpr                   `<=`\n      .. py:class:: LtExpr                   `<`\n      .. py:class:: LtgtExpr\n      .. py:class:: NeExpr                   `!=`\n      .. py:class:: OrderedExpr\n      .. py:class:: UneqExpr\n      .. py:class:: UngeExpr\n      .. py:class:: UngtExpr\n      .. py:class:: UnleExpr\n      .. py:class:: UnltExpr\n      .. py:class:: UnorderedExpr\n      =====================================  ======================\n\n\nReferences to storage\n---------------------\n\n.. py:class:: gcc.Reference\n\n   Subclass of :py:class:`gcc.Tree` for expressions involving a reference to\n   storage.\n\n   Corresponds to the `tcc_reference` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: location\n\n      The :py:class:`gcc.Location` for this storage reference\n\n   .. py:classmethod:: get_symbol()\n\n      Get the symbol used in debug dumps for this :py:class:`gcc.Reference`\n      subclass, if any, as a `str`.  A table showing these strings can be\n      seen :ref:`here <get_symbols>`.\n\n.. py:class:: gcc.ArrayRef\n\n   A subclass of :py:class:`gcc.Reference` for expressions involving an array\n   reference:\n\n   .. code-block:: c\n\n      unsigned char buffer[4096];\n      ...\n      /* The left-hand side of this gcc.GimpleAssign is a gcc.ArrayRef: */\n      buffer[42] = 0xff;\n\n   .. py:attribute:: array\n\n      The :py:class:`gcc.Tree` for the array within the reference\n      (`gcc.VarDecl('buffer')` in the example above)\n\n   .. py:attribute:: index\n\n      The :py:class:`gcc.Tree` for the index within the reference\n      (`gcc.IntegerCst(42)` in the example above)\n\n.. py:class:: gcc.ComponentRef\n\n   A subclass of :py:class:`gcc.Reference` for expressions involving a field\n   lookup.\n\n   This can mean either a direct field lookup, as in:\n\n   .. code-block:: c\n\n      struct mystruct s;\n      ...\n      s.idx = 42;\n\n   or dereferenced field lookup:\n\n   .. code-block:: c\n\n      struct mystruct *p;\n      ...\n      p->idx = 42;\n\n   .. py:attribute:: target\n\n      The :py:class:`gcc.Tree` for the container of the field (either `s` or\n      `*p` in the examples above)\n\n   .. py:attribute:: field\n\n      The :py:class:`gcc.FieldDecl` for the field within the target.\n\n.. py:class:: gcc.MemRef\n\n   A subclass of :py:class:`gcc.Reference` for expressions involving\n   dereferencing a pointer:\n\n   .. code-block:: c\n\n      int p, *q;\n      ...\n      p = *q;\n\n   .. py:attribute:: operand\n\n      The :py:class:`gcc.Tree` for the expression describing the target of the\n      pointer\n\nOther subclasses of :py:class:`gcc.Reference` include:\n\n      =====================================  ======================\n      Subclass                               C/C++ operators\n      =====================================  ======================\n      .. py:class:: ArrayRangeRef\n      .. py:class:: AttrAddrExpr\n      .. py:class:: BitFieldRef\n      .. py:class:: ImagpartExpr\n      .. py:class:: IndirectRef\n      .. py:class:: MemberRef\n      .. py:class:: OffsetRef\n      .. py:class:: RealpartExpr\n      .. py:class:: ScopeRef\n      .. py:class:: TargetMemRef\n      .. py:class:: UnconstrainedArrayRef\n      .. py:class:: ViewConvertExpr\n      =====================================  ======================\n\n\nOther expression subclasses\n---------------------------\n\n.. py:class:: gcc.Expression\n\n   Subclass of :py:class:`gcc.Tree` indicating an expression that doesn't fit\n   into the other categories.\n\n   Corresponds to the `tcc_expression` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n   .. py:attribute:: location\n\n      The :py:class:`gcc.Location` for this expression\n\n   .. py:classmethod:: get_symbol()\n\n      Get the symbol used in debug dumps for this :py:class:`gcc.Expression`\n      subclass, if any, as a `str`.  A table showing these strings can be\n      seen :ref:`here <get_symbols>`.\n\n   Subclasses include:\n\n      =====================================  ======================\n      Subclass                               C/C++ operators\n      =====================================  ======================\n      .. py:class:: gcc.AddrExpr\n      .. py:class:: gcc.AlignofExpr\n      .. py:class:: gcc.ArrowExpr\n      .. py:class:: gcc.AssertExpr\n      .. py:class:: gcc.AtEncodeExpr\n      .. py:class:: gcc.BindExpr\n      .. py:class:: gcc.CMaybeConstExpr\n      .. py:class:: gcc.ClassReferenceExpr\n      .. py:class:: gcc.CleanupPointExpr\n      .. py:class:: gcc.CompoundExpr\n      .. py:class:: gcc.CompoundLiteralExpr\n      .. py:class:: gcc.CondExpr\n      .. py:class:: gcc.CtorInitializer\n      .. py:class:: gcc.DlExpr\n      .. py:class:: gcc.DotProdExpr\n      .. py:class:: gcc.DotstarExpr\n      .. py:class:: gcc.EmptyClassExpr\n      .. py:class:: gcc.ExcessPrecisionExpr\n      .. py:class:: gcc.ExprPackExpansion\n      .. py:class:: gcc.ExprStmt\n      .. py:class:: gcc.FdescExpr\n      .. py:class:: gcc.FmaExpr\n      .. py:class:: gcc.InitExpr\n      .. py:class:: gcc.MessageSendExpr\n      .. py:class:: gcc.ModifyExpr\n      .. py:class:: gcc.ModopExpr\n      .. py:class:: gcc.MustNotThrowExpr\n      .. py:class:: gcc.NonDependentExpr\n      .. py:class:: gcc.NontypeArgumentPack\n      .. py:class:: gcc.NullExpr\n      .. py:class:: gcc.NwExpr\n      .. py:class:: gcc.ObjTypeRef\n      .. py:class:: gcc.OffsetofExpr\n      .. py:class:: gcc.PolynomialChrec\n      .. py:class:: gcc.PostdecrementExpr\n      .. py:class:: gcc.PostincrementExpr\n      .. py:class:: gcc.PredecrementExpr\n      .. py:class:: gcc.PredictExpr\n      .. py:class:: gcc.PreincrementExpr\n      .. py:class:: gcc.PropertyRef\n      .. py:class:: gcc.PseudoDtorExpr\n      .. py:class:: gcc.RealignLoad\n      .. py:class:: gcc.SaveExpr\n      .. py:class:: gcc.ScevKnown\n      .. py:class:: gcc.ScevNotKnown\n      .. py:class:: gcc.SizeofExpr\n      .. py:class:: gcc.StmtExpr\n      .. py:class:: gcc.TagDefn\n      .. py:class:: gcc.TargetExpr\n      .. py:class:: gcc.TemplateIdExpr\n      .. py:class:: gcc.ThrowExpr\n      .. py:class:: gcc.TruthAndExpr\n      .. py:class:: gcc.TruthAndifExpr\n      .. py:class:: gcc.TruthNotExpr\n      .. py:class:: gcc.TruthOrExpr\n      .. py:class:: gcc.TruthOrifExpr\n      .. py:class:: gcc.TruthXorExpr\n      .. py:class:: gcc.TypeExpr\n      .. py:class:: gcc.TypeidExpr\n      .. py:class:: gcc.VaArgExpr\n      .. py:class:: gcc.VecCondExpr\n      .. py:class:: gcc.VecDlExpr\n      .. py:class:: gcc.VecInitExpr\n      .. py:class:: gcc.VecNwExpr\n      .. py:class:: gcc.WidenMultMinusExpr\n      .. py:class:: gcc.WidenMultPlusExpr\n      .. py:class:: gcc.WithCleanupExpr\n      .. py:class:: gcc.WithSizeExpr\n      =====================================  ======================\n\nTODO\n\nStatements\n----------\n\n.. py:class:: gcc.Statement\n\n   A subclass of :py:class:`gcc.Tree` for statements\n\n   Corresponds to the `tcc_statement` value of `enum tree_code_class` within\n   GCC's own C sources.\n\n.. py:class:: gcc.CaseLabelExpr\n\n   A subclass of :py:class:`gcc.Statement` for the `case` and `default` labels\n   within a `switch` statement.\n\n   .. py:attribute:: low\n\n      * for single-valued case labels, the value, as a :py:class:`gcc.Tree`\n\n      * for range-valued case labels, the lower bound, as a :py:class:`gcc.Tree`\n\n      * `None` for the default label\n\n   .. py:attribute:: high\n\n      For range-valued case labels, the upper bound, as a :py:class:`gcc.Tree`.\n\n      `None` for single-valued case labels, and for the default label\n\n   .. py:attribute:: target\n\n      The target of the case label, as a :py:class:`gcc.LabelDecl`\n\nSSA Names\n---------\n\n.. py:class:: gcc.SsaName\n\n   A subclass of :py:class:`gcc.Tree` representing a variable references\n   during SSA analysis.  New SSA names are created every time a variable\n   is assigned a new value.\n\n   .. py:attribute:: var\n\n      The variable being referenced, as a :py:class:`gcc.VarDecl` or\n      :py:class:`gcc.ParmDecl`\n\n   .. py:attribute:: def_stmt\n\n      The :py:class:`gcc.Gimple` statement which defines this SSA name\n\n   .. py:attribute:: version\n\n      An `int` value giving the version number of this SSA name\n\n  .. Here's a dump of the class hierarchy, from help(gcc):\n  ..    Tree\n  ..        ArgumentPackSelect\n  ..        Baselink\n  ..        Binary\n  ..            BitAndExpr\n  ..            BitIorExpr\n  ..            BitXorExpr\n  ..            CeilDivExpr\n  ..            CeilModExpr\n  ..            CompareExpr\n  ..            CompareGExpr\n  ..            CompareLExpr\n  ..            ComplexExpr\n  ..            ExactDivExpr\n  ..            FloorDivExpr\n  ..            FloorModExpr\n  ..            LrotateExpr\n  ..            LshiftExpr\n  ..            MaxExpr\n  ..            MinExpr\n  ..            MinusExpr\n  ..            MinusNomodExpr\n  ..            MultExpr\n  ..            PlusExpr\n  ..            PlusNomodExpr\n  ..            PointerPlusExpr\n  ..            RangeExpr\n  ..            RdivExpr\n  ..            RoundDivExpr\n  ..            RoundModExpr\n  ..            RrotateExpr\n  ..            RshiftExpr\n  ..            TruncDivExpr\n  ..            TruncModExpr\n  ..            UrshiftExpr\n  ..            VecExtractevenExpr\n  ..            VecExtractoddExpr\n  ..            VecInterleavehighExpr\n  ..            VecInterleavelowExpr\n  ..            VecLshiftExpr\n  ..            VecPackFixTruncExpr\n  ..            VecPackSatExpr\n  ..            VecPackTruncExpr\n  ..            VecRshiftExpr\n  ..            WidenMultExpr\n  ..            WidenMultHiExpr\n  ..            WidenMultLoExpr\n  ..            WidenSumExpr\n  ..        Block\n  ..        Comparison\n  ..            EqExpr\n  ..            GeExpr\n  ..            GtExpr\n  ..            LeExpr\n  ..            LtExpr\n  ..            LtgtExpr\n  ..            NeExpr\n  ..            OrderedExpr\n  ..            UneqExpr\n  ..            UngeExpr\n  ..            UngtExpr\n  ..            UnleExpr\n  ..            UnltExpr\n  ..            UnorderedExpr\n  ..        Constant\n  ..            ComplexCst\n  ..            FixedCst\n  ..            IntegerCst\n  ..            PtrmemCst\n  ..            RealCst\n  ..            StringCst\n  ..            VectorCst\n  ..        Constructor\n  ..        Declaration\n  ..            ClassMethodDecl\n  ..            ConstDecl\n  ..            DebugExprDecl\n  ..            FieldDecl\n  ..            FunctionDecl\n  ..            ImportedDecl\n  ..            InstanceMethodDecl\n  ..            KeywordDecl\n  ..            LabelDecl\n  ..            NamespaceDecl\n  ..            ParmDecl\n  ..            PropertyDecl\n  ..            ResultDecl\n  ..            TemplateDecl\n  ..            TranslationUnitDecl\n  ..            TypeDecl\n  ..            UsingDecl\n  ..            VarDecl\n  ..        DefaultArg\n  ..        ErrorMark\n  ..        Expression\n  ..            AddrExpr\n  ..            AlignofExpr\n  ..            ArrowExpr\n  ..            AssertExpr\n  ..            AtEncodeExpr\n  ..            BindExpr\n  ..            CMaybeConstExpr\n  ..            ClassReferenceExpr\n  ..            CleanupPointExpr\n  ..            CompoundExpr\n  ..            CompoundLiteralExpr\n  ..            CondExpr\n  ..            CtorInitializer\n  ..            DlExpr\n  ..            DotProdExpr\n  ..            DotstarExpr\n  ..            EmptyClassExpr\n  ..            ExcessPrecisionExpr\n  ..            ExprPackExpansion\n  ..            ExprStmt\n  ..            FdescExpr\n  ..            FmaExpr\n  ..            InitExpr\n  ..            MessageSendExpr\n  ..            ModifyExpr\n  ..            ModopExpr\n  ..            MustNotThrowExpr\n  ..            NonDependentExpr\n  ..            NontypeArgumentPack\n  ..            NullExpr\n  ..            NwExpr\n  ..            ObjTypeRef\n  ..            OffsetofExpr\n  ..            PolynomialChrec\n  ..            PostdecrementExpr\n  ..            PostincrementExpr\n  ..            PredecrementExpr\n  ..            PredictExpr\n  ..            PreincrementExpr\n  ..            PropertyRef\n  ..            PseudoDtorExpr\n  ..            RealignLoad\n  ..            SaveExpr\n  ..            ScevKnown\n  ..            ScevNotKnown\n  ..            SizeofExpr\n  ..            StmtExpr\n  ..            TagDefn\n  ..            TargetExpr\n  ..            TemplateIdExpr\n  ..            ThrowExpr\n  ..            TruthAndExpr\n  ..            TruthAndifExpr\n  ..            TruthNotExpr\n  ..            TruthOrExpr\n  ..            TruthOrifExpr\n  ..            TruthXorExpr\n  ..            TypeExpr\n  ..            TypeidExpr\n  ..            VaArgExpr\n  ..            VecCondExpr\n  ..            VecDlExpr\n  ..            VecInitExpr\n  ..            VecNwExpr\n  ..            WidenMultMinusExpr\n  ..            WidenMultPlusExpr\n  ..            WithCleanupExpr\n  ..            WithSizeExpr\n  ..        IdentifierNode\n  ..        LambdaExpr\n  ..        OmpClause\n  ..        OptimizationNode\n  ..        Overload\n  ..        PlaceholderExpr\n  ..        Reference\n  ..            ArrayRangeRef\n  ..            ArrayRef\n  ..            AttrAddrExpr\n  ..            BitFieldRef\n  ..            ComponentRef\n  ..            ImagpartExpr\n  ..            IndirectRef\n  ..            MemRef\n  ..            MemberRef\n  ..            OffsetRef\n  ..            RealpartExpr\n  ..            ScopeRef\n  ..            TargetMemRef\n  ..            UnconstrainedArrayRef\n  ..            ViewConvertExpr\n  ..        SsaName\n  ..        Statement\n  ..            AsmExpr\n  ..            BreakStmt\n  ..            CaseLabelExpr\n  ..            CatchExpr\n  ..            CleanupStmt\n  ..            ContinueStmt\n  ..            DeclExpr\n  ..            DoStmt\n  ..            EhFilterExpr\n  ..            EhSpecBlock\n  ..            ExitExpr\n  ..            ExitStmt\n  ..            ForStmt\n  ..            GotoExpr\n  ..            Handler\n  ..            IfStmt\n  ..            LabelExpr\n  ..            LoopExpr\n  ..            LoopStmt\n  ..            OmpAtomic\n  ..            OmpCritical\n  ..            OmpFor\n  ..            OmpMaster\n  ..            OmpOrdered\n  ..            OmpParallel\n  ..            OmpSection\n  ..            OmpSections\n  ..            OmpSingle\n  ..            OmpTask\n  ..            RangeForStmt\n  ..            ReturnExpr\n  ..            StmtStmt\n  ..            SwitchExpr\n  ..            SwitchStmt\n  ..            TryBlock\n  ..            TryCatchExpr\n  ..            TryFinally\n  ..            UsingDirective\n  ..            WhileStmt\n  ..        StatementList\n  ..        StaticAssert\n  ..        TargetOptionNode\n  ..        TemplateInfo\n  ..        TemplateParmIndex\n  ..        TraitExpr\n  ..        TreeBinfo\n  ..        TreeList\n  ..        TreeVec\n  ..        Type\n  ..            ArrayType\n  ..            BooleanType\n  ..            BoundTemplateTemplateParm\n  ..            CategoryImplementationType\n  ..            CategoryInterfaceType\n  ..            ClassImplementationType\n  ..            ClassInterfaceType\n  ..            ComplexType\n  ..            DecltypeType\n  ..            EnumeralType\n  ..            FixedPointType\n  ..            FunctionType\n  ..            IntegerType\n  ..            LangType\n  ..            MethodType\n  ..            NullptrType\n  ..            OffsetType\n  ..            PointerType\n  ..            ProtocolInterfaceType\n  ..            QualUnionType\n  ..            RealType\n  ..            RecordType\n  ..            ReferenceType\n  ..            TemplateTemplateParm\n  ..            TemplateTypeParm\n  ..            TypeArgumentPack\n  ..            TypePackExpansion\n  ..            TypenameType\n  ..            TypeofType\n  ..            UnboundClassTemplate\n  ..            UnconstrainedArrayType\n  ..            UnionType\n  ..            VectorType\n  ..            VoidType\n  ..        Unary\n  ..            AbsExpr\n  ..            AddrSpaceConvertExpr\n  ..            BitNotExpr\n  ..            CastExpr\n  ..            ConjExpr\n  ..            ConstCastExpr\n  ..            ConvertExpr\n  ..            DynamicCastExpr\n  ..            FixTruncExpr\n  ..            FixedConvertExpr\n  ..            FloatExpr\n  ..            NegateExpr\n  ..            NoexceptExpr\n  ..            NonLvalueExpr\n  ..            NopExpr\n  ..            ParenExpr\n  ..            ReducMaxExpr\n  ..            ReducMinExpr\n  ..            ReducPlusExpr\n  ..            ReinterpretCastExpr\n  ..            StaticCastExpr\n  ..            UnaryPlusExpr\n  ..            VecUnpackFloatHiExpr\n  ..            VecUnpackFloatLoExpr\n  ..            VecUnpackHiExpr\n  ..            VecUnpackLoExpr\n  ..        VlExp\n  ..            AggrInitExpr\n  ..            CallExpr\n\n"
  },
  {
    "path": "docs/versions.rst",
    "content": ".. Copyright 2011, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nVersion handling\n================\n\n.. py:function:: gcc.get_gcc_version()\n\n   Get the gcc.Version for this version of GCC\n\n.. py:function:: gcc.get_plugin_gcc_version()\n\n   Get the gcc.Version that this plugin was compiled with\n\nTypically the above will be equal (the plugin-loading mechanism currently\nchecks for this, and won't load the plugin otherwise).\n\nOn my machine, running this currently gives::\n\n   gcc.Version(basever='4.6.0', datestamp='20110321', devphase='Red Hat 4.6.0-0.15', revision='', ...)\n\n\n.. py:class:: gcc.Version\n\n   Information on the version of GCC being run.  The various fields are\n   accessible by name and by index.\n\n   .. py:attribute:: basever\n\n      (string) On my machine, this has value::\n\n         '4.6.0'\n\n   .. py:attribute:: datestamp\n\n      (string) On my machine, this has value::\n\n         '20110321'\n\n   .. py:attribute:: devphase\n\n      (string) On my machine, this has value::\n\n          'Red Hat 4.6.0-0.15'\n\n   .. py:attribute:: revision\n\n      (string) On my machine, this is the empty string\n\n   .. py:attribute:: configuration_arguments\n\n      (string) On my machine, this has value::\n\n         '../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-java-awt=gtk --disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux'\n\n\n   Internally, this is a wrapper around a `struct plugin_gcc_version`\n\n.. py:data:: gcc.GCC_VERSION\n\n   (int) This corresponds to the value of GCC_VERSION within GCC's internal\n   code: (MAJOR * 1000) + MINOR:\n\n   ===========   ========================\n   GCC version   Value of gcc.GCC_VERSION\n   ===========   ========================\n   4.6           4006\n   4.7           4007\n   4.8           4008\n   4.9           4009\n   ===========   ========================\n"
  },
  {
    "path": "docs/working-with-c.rst",
    "content": ".. Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n\nWorking with C code\n===================\n\n\"Hello world\"\n-------------\n\nHere's a simple \"hello world\" C program:\n\n  .. literalinclude:: ../tests/examples/hello-world/input.c\n    :lines: 19-26\n    :language: c\n\nHere's a Python script that locates the function at one pass within the\ncompile  and prints various interesting things about it:\n\n  .. literalinclude:: ../tests/examples/hello-world/script.py\n    :lines: 19-\n    :language: python\n\nWe can run the script during the compile like this:\n\n   .. code-block:: bash\n\n     ./gcc-with-python script.py test.c\n\nHere's the expected output:\n\n  .. literalinclude:: ../tests/examples/hello-world/stdout.txt\n\nNotice how the call to `printf` has already been optimized into a call\nto `__builtin_puts`.\n\n\nSpell-checking string constants within source code\n--------------------------------------------------\n\nThis example add a spell-checker pass to GCC: all string constants are run through the \"enchant\" spelling-checker:\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python tests/examples/spelling-checker/script.py input.c\n\nThe Python code for this is:\n\n   .. literalinclude:: ../tests/examples/spelling-checker/script.py\n    :lines: 18-\n    :language: python\n\nGiven this sample C source file:\n\n  .. literalinclude:: ../tests/examples/spelling-checker/input.c\n    :lines: 19-29\n    :language: c\n\nthese warnings are emitted on stderr:\n\n  .. literalinclude:: ../tests/examples/spelling-checker/stderr.txt\n\n\nFinding global variables\n------------------------\nThis example adds a pass that warns about uses of global variables:\n\n   .. code-block:: bash\n\n     $ ./gcc-with-python \\\n         tests/examples/find-global-state/script.py \\\n         -c \\\n         tests/examples/find-global-state/input.c\n\nThe Python code for this is:\n\n   .. literalinclude:: ../tests/examples/find-global-state/script.py\n    :lines: 18-\n    :language: python\n\nGiven this sample C source file:\n\n  .. literalinclude:: ../tests/examples/find-global-state/input.c\n    :lines: 19-\n    :language: c\n\nthese warnings are emitted on stderr:\n\n  .. literalinclude:: ../tests/examples/find-global-state/stderr.txt\n"
  },
  {
    "path": "examples/show-callgraph.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Sample python script, to be run by our gcc plugin\n# Show the call graph (interprocedural analysis), using GraphViz\nimport gcc\nfrom gccutils import callgraph_to_dot, invoke_dot\n\n# In theory we could have done this with a custom gcc.Pass registered\n# directly after \"*build_cgraph_edges\".  However, we can only register\n# relative to passes of the same kind, and that pass is a\n# gcc.GimplePass, which is called per-function, and we want a one-time\n# pass instead.\n#\n# So we instead register a callback on the one-time pass that follows it\n\ndef on_pass_execution(p, fn):\n    if p.name == '*free_lang_data':\n        # The '*free_lang_data' pass is called once, rather than per-function,\n        # and occurs immediately after \"*build_cgraph_edges\", which is the\n        # pass that initially builds the callgraph\n        #\n        # So at this point we're likely to get a good view of the callgraph\n        # before further optimization passes manipulate it\n        dot = callgraph_to_dot()\n        invoke_dot(dot)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "examples/show-docs.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nhelp(gcc)\n"
  },
  {
    "path": "examples/show-gimple.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Sample python script, to be run by our gcc plugin\n# Show the GIMPLE form of each function, using GraphViz\nimport gcc\nfrom gccutils import get_src_for_loc, cfg_to_dot, invoke_dot\n\n# We'll implement this as a custom pass, to be called directly after the\n# builtin \"cfg\" pass, which generates the CFG:\n\nclass ShowGimple(gcc.GimplePass):\n    def execute(self, fun):\n        # (the CFG should be set up by this point, and the GIMPLE is not yet\n        # in SSA form)\n        if fun and fun.cfg:\n            dot = cfg_to_dot(fun.cfg, fun.decl.name)\n            # print dot\n            invoke_dot(dot, name=fun.decl.name)\n\nps = ShowGimple(name='show-gimple')\nps.register_after('cfg')\n"
  },
  {
    "path": "examples/show-lto-supergraph.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Sample python script, to be run by our gcc plugin\n# Show the \"supergraph\": the CFG of all functions, linked by\n# interproceduraledges:\nimport gcc\nfrom gccutils.graph.supergraph import Supergraph\nfrom gccutils import invoke_dot\n\n# We'll implement this as a custom pass, to be called directly before\n# 'whole-program'\n\nclass ShowSupergraph(gcc.IpaPass):\n    def execute(self):\n        # (the callgraph should be set up by this point)\n        if gcc.is_lto():\n            sg = Supergraph(split_phi_nodes=False,\n                            add_fake_entry_node=False)\n            dot = sg.to_dot('supergraph')\n            invoke_dot(dot)\n\nps = ShowSupergraph(name='show-supergraph')\nps.register_before('whole-program')\n"
  },
  {
    "path": "examples/show-passes.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Sample python script, to be run by our gcc plugin\n# Show all the passes that get executed\nimport gcc\n\ndef my_pass_execution_callback(*args, **kwargs):\n    (optpass, fun) = args\n    print(args)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      my_pass_execution_callback)\n"
  },
  {
    "path": "examples/show-ssa.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Sample python script, to be run by our gcc plugin\n# Show the SSA form of each function, using GraphViz\nimport gcc\nfrom gccutils import get_src_for_loc, cfg_to_dot, invoke_dot\n\n# A custom GCC pass, to be called directly after the builtin \"ssa\" pass, which\n# generates the Static Single Assignment form of the GIMPLE within the CFG:\nclass ShowSsa(gcc.GimplePass):\n    def execute(self, fun):\n        # (the SSA form of each function should have just been set up)\n        if fun and fun.cfg:\n            dot = cfg_to_dot(fun.cfg, fun.decl.name)\n            # print(dot)\n            invoke_dot(dot, name=fun.decl.name)\n\nps = ShowSsa(name='show-ssa')\nps.register_after('ssa')\n\n\n"
  },
  {
    "path": "gcc-c-api/Makefile",
    "content": "#   Copyright 2011, 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012, 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nifneq ($(srcdir),)\nVPATH = $(srcdir)\nendif\nxmldir = $(srcdir)./\n\n.PHONY: all clean check-api\n\nHANDWRITTEN_C_FILES = \\\n  gcc-callgraph.c \\\n  gcc-cfg.c \\\n  gcc-constant.c \\\n  gcc-declaration.c \\\n  gcc-diagnostics.c \\\n  gcc-function.c \\\n  gcc-gimple.c \\\n  gcc-location.c \\\n  gcc-option.c \\\n  gcc-rtl.c \\\n  gcc-tree.c \\\n  gcc-type.c \\\n  gcc-variable.c\n\nGENERATED_C_FILES = \\\n  autogenerated-casts.c\n\nOBJECT_FILES_FROM_HANDWRITTEN_C_FILES:= $(patsubst %.c,%.o,$(HANDWRITTEN_C_FILES))\nOBJECT_FILES_FROM_GENERATED_C_FILES:= $(patsubst %.c,%.o,$(GENERATED_C_FILES))\n\nOBJECT_FILES:= $(OBJECT_FILES_FROM_HANDWRITTEN_C_FILES) $(OBJECT_FILES_FROM_GENERATED_C_FILES)\n\nSOURCE_XML:= \\\n  callgraph.xml \\\n  cfg.xml \\\n  constant.xml \\\n  declaration.xml \\\n  diagnostics.xml \\\n  function.xml \\\n  gimple.xml \\\n  location.xml \\\n  option.xml \\\n  rtl.xml \\\n  tree.xml \\\n  type.xml \\\n  variable.xml\n\nGENERATED_HEADERS:= \\\n  gcc-public-types.h \\\n  gcc-semiprivate-types.h \\\n  gcc-callgraph.h \\\n  gcc-cfg.h \\\n  gcc-constant.h \\\n  gcc-declaration.h \\\n  gcc-function.h \\\n  gcc-gimple.h \\\n  gcc-location.h \\\n  gcc-option.h \\\n  gcc-rtl.h \\\n  gcc-tree.h \\\n  gcc-type.h \\\n  gcc-variable.h\n\nGCCPLUGINS_DIR:= $(shell $(CC) --print-file-name=plugin)\n\nLIBGCC_C_API_SO\t:= libgcc-c-api.so\n\nCPPFLAGS+= -I$(GCCPLUGINS_DIR)/include -I$(GCCPLUGINS_DIR)/include/c-family -I.\n# Allow user to pick optimization, choose whether warnings are fatal,\n# and choose debugging information level.\nCFLAGS?=-O2 -Werror -g\n# Force these settings\nCFLAGS+= -fPIC -fno-strict-aliasing -Wall\n\nall: $(LIBGCC_C_API_SO)\n\n$(LIBGCC_C_API_SO): $(OBJECT_FILES)\n\t$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -shared $^ -o $@ $(LIBS)\n\n# This is the standard .c->.o recipe, but it needs to be stated\n# explicitly to support the case that $(srcdir) is not blank.\n$(OBJECT_FILES): %.o: %.c $(GENERATED_HEADERS) ../autogenerated-EXTRA_CFLAGS.txt\n\t$(COMPILE.c) $(shell cat ../autogenerated-EXTRA_CFLAGS.txt) $(OUTPUT_OPTION) -I$(srcdir)./ $<\n\nautogenerated-casts.c: $(SOURCE_XML) xmltypes.py generate-casts-c.py\n\t$(PYTHON) $(srcdir)./generate-casts-c.py $@ $(xmldir)\n\nclean:\n\t$(RM) *.so *.o $(GENERATED_HEADERS)\n\ninstall: $(LIBGCC_C_API_SO)\n\tmkdir -p $(DESTDIR)$(GCCPLUGINS_DIR)\n\tcp libgcc-c-api.so $(DESTDIR)$(GCCPLUGINS_DIR)\n\n# The python interpreter to use:\nPYTHON=python\n\n$(GENERATED_HEADERS): $(SOURCE_XML) xml-to-h.py xmltypes.py\n\t$(PYTHON) $(srcdir)./xml-to-h.py $(xmldir)\n\ncheck-api:\n\txmllint --noout --relaxng api.rng *.xml\n"
  },
  {
    "path": "gcc-c-api/api.rng",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\nCopyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\nCopyright 2012, 2013 Red Hat, Inc.\n\nThis is free software: you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nGeneral Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program.  If not, see\n<http://www.gnu.org/licenses/>.\n-->\n<!--\nRelaxNG schema for the api format\n-->\n<grammar xmlns=\"http://relaxng.org/ns/structure/1.0\">\n  <start>\n    <element name=\"api\">\n      <attribute name=\"name\"> <text/> </attribute>\n      <element name=\"doc\">\n        <text/>\n      </element>\n\n      <zeroOrMore>\n        <element name=\"type\">\n          <attribute name=\"name\"> <text/> </attribute>\n          <optional>\n            <attribute name=\"base\"> <text/> </attribute>\n          </optional>\n          <optional>\n            <attribute name=\"inner\"> <text/> </attribute>\n          </optional>\n          <optional>\n            <attribute name=\"varname\"> <text/> </attribute>\n          </optional>\n\n          <optional>\n            <element name=\"doc\">\n              <text/>\n            </element>\n          </optional>\n\n          <!-- the attributes of this type -->\n          <zeroOrMore>\n            <ref name=\"attribute\"/>\n          </zeroOrMore>\n\n          <zeroOrMore>\n            <ref name=\"iterator\"/>\n          </zeroOrMore>\n        </element>\n      </zeroOrMore>\n\n      <!-- global attributes -->\n      <zeroOrMore>\n        <ref name=\"attribute\"/>\n      </zeroOrMore>\n\n      <!-- global iterators -->\n      <zeroOrMore>\n        <ref name=\"iterator\"/>\n      </zeroOrMore>\n\n      <!-- global functions -->\n      <zeroOrMore>\n        <ref name=\"function\"/>\n      </zeroOrMore>\n    </element>\n  </start>\n\n  <!-- <attribute> is shared by both <type> and by <api> -->\n  <define name=\"attribute\">\n    <element name=\"attribute\">\n      <attribute name=\"name\"> <text/> </attribute>\n      <attribute name=\"kind\"> <text/> </attribute>\n      <optional>\n        <attribute name=\"access\">\n          <choice>\n            <value type=\"string\">rw</value>\n            <value type=\"string\">r</value> <!-- default to readonly -->\n          </choice>\n        </attribute>\n      </optional>\n\n      <optional>\n        <element name=\"doc\">\n          <text/>\n        </element>\n      </optional>\n    </element>\n  </define>\n\n  <!-- <iterator> is shared by both <type> and by <api> -->\n  <define name=\"iterator\">\n    <element name=\"iterator\">\n      <attribute name=\"name\"> <text/> </attribute>\n      <attribute name=\"kind\"> <text/> </attribute>\n      <optional>\n        <element name=\"doc\">\n          <text/>\n        </element>\n      </optional>\n    </element>\n  </define>\n\n  <!-- <function> is shared by both <type> and by <api> -->\n  <define name=\"function\">\n    <element name=\"function\">\n      <attribute name=\"name\"> <text/> </attribute>\n      <attribute name=\"returntype\"> <text/> </attribute>\n      <zeroOrMore>\n        <element name=\"parameter\">\n          <attribute name=\"name\"> <text/> </attribute>\n          <attribute name=\"type\"> <text/> </attribute>\n        </element>\n      </zeroOrMore>\n      <optional>\n        <element name=\"doc\">\n          <text/>\n        </element>\n      </optional>\n    </element>\n  </define>\n\n</grammar>\n"
  },
  {
    "path": "gcc-c-api/callgraph.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"callgraph\">\n  <doc>Callgraphs</doc>\n\n  <type name=\"cgraph_node\" varname=\"node\" inner=\"struct cgraph_node *\">\n    <attribute name=\"decl\" kind=\"function_decl\">\n      <doc>The function declaration for this node within the callgraph</doc>\n    </attribute>\n    <iterator  name=\"callee\" kind=\"cgraph_edge\">\n      <doc>The function calls made by this function</doc>\n    </iterator>\n    <iterator  name=\"caller\" kind=\"cgraph_edge\">\n      <doc>The places that calls this function</doc>\n    </iterator>\n  </type>\n\n  <type name=\"cgraph_edge\" varname=\"edge\" inner=\"struct cgraph_edge *\">\n    <doc>An edge within the callgraph</doc>\n    <attribute name=\"caller\" kind=\"cgraph_node\">\n      <doc>The function that makes this call</doc>\n    </attribute>\n    <attribute name=\"callee\" kind=\"cgraph_node\">\n      <doc>The function that is called here</doc>\n    </attribute>\n    <attribute name=\"call_stmt\" kind=\"gimple_call\">\n      <doc>The gimple call statement representing the function call</doc>\n    </attribute>\n  </type>\n\n  <iterator name=\"cgraph_node\" kind=\"cgraph_node\">\n    <doc>All callgraph nodes, for the passes where these exist</doc>\n  </iterator>\n\n</api>"
  },
  {
    "path": "gcc-c-api/cfg.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"cfg\">\n  <doc>Control Flow Graphs</doc>\n\n  <type name=\"cfg\" varname=\"cfg\" inner=\"struct control_flow_graph *\">\n    <doc>A control flow graph</doc>\n    <attribute name=\"entry\" kind=\"cfg_block\">\n      <doc>Entrypoint for this CFG</doc>\n    </attribute>\n\n    <attribute name=\"exit\" kind=\"cfg_block\">\n      <doc>The final block within this CFG</doc>\n    </attribute>\n\n    <iterator name=\"block\" kind=\"cfg_block\"/>\n  </type>\n\n  <type name=\"cfg_block\" varname=\"block\" inner=\"basic_block\">\n    <attribute name=\"index\" kind=\"int\"/>\n    <iterator  name=\"pred_edge\" kind=\"cfg_edge\"/>\n    <iterator  name=\"succ_edge\" kind=\"cfg_edge\"/>\n    <iterator  name=\"gimple_phi\" kind=\"gimple_phi\"/>\n    <iterator  name=\"gimple\"     kind=\"gimple\"/>\n    <iterator  name=\"rtl_insn\"   kind=\"rtl_insn\"/>\n  </type>\n\n  <type name=\"cfg_edge\" varname=\"edge\" inner=\"edge\">\n    <attribute name=\"src\" kind=\"cfg_block\"/>\n    <attribute name=\"dest\" kind=\"cfg_block\"/>\n    <attribute name=\"is_true_value\" kind=\"bool\"/>\n    <attribute name=\"is_false_value\" kind=\"bool\"/>\n    <attribute name=\"is_loop_exit\" kind=\"bool\"/>\n    <attribute name=\"can_fallthru\" kind=\"bool\"/>\n    <attribute name=\"is_complex\" kind=\"bool\"/>\n    <attribute name=\"is_eh\" kind=\"bool\"/>\n  </type>\n\n</api>"
  },
  {
    "path": "gcc-c-api/constant.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"constant\">\n  <doc>Constant Expressions</doc>\n\n  <!-- constants -->\n  <type name=\"constant\" base=\"tree\">\n  </type>\n\n  <!-- \"cst\" vs \"constant\" -->\n  <type name=\"complex_constant\" base=\"constant\">\n  </type>\n  <type name=\"fixed_constant\" base=\"constant\">\n  </type>\n  <type name=\"integer_constant\" base=\"constant\">\n  </type>\n  <type name=\"ptrmem_constant\" base=\"constant\">\n  </type>\n  <type name=\"real_constant\" base=\"constant\">\n  </type>\n  <type name=\"string_constant\" base=\"constant\">\n    <attribute name=\"char_ptr\" kind=\"string\"/>\n  </type>\n  <type name=\"vector_constant\" base=\"constant\">\n  </type>\n</api>"
  },
  {
    "path": "gcc-c-api/declaration.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"declaration\">\n\n  <doc>Declarations</doc>\n\n  <type name=\"decl\" base=\"tree\">\n    <attribute name=\"location\" kind=\"location\"/>\n    <attribute name=\"is_artificial\" kind=\"bool\"/>\n    <attribute name=\"is_builtin\" kind=\"bool\"/>\n  </type>\n\n  <type name=\"class_method_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"const_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"debug_expr_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"field_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"function_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"imported_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"instance_method_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"keyword_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"label_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"namespace_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"parm_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"property_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"result_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"template_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"translation_unit_decl\" base=\"decl\">\n    <attribute name=\"block\" kind=\"block\"/>\n    <attribute name=\"language\" kind=\"string\"/>\n  </type>\n\n  <type name=\"type_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"using_decl\" base=\"decl\">\n  </type>\n\n  <type name=\"var_decl\" base=\"decl\">\n    <attribute name=\"initial\" kind=\"constructor\"/>\n    <attribute name=\"is_static\" kind=\"bool\"/>\n  </type>\n\n  <iterator name=\"translation_unit_decl\" kind=\"translation_unit_decl\"/>\n\n</api>"
  },
  {
    "path": "gcc-c-api/design.rst",
    "content": "Proposed GCC plugin C API\n-------------------------\n\nThis is an API for GCC plugins written in C.\n\nAll public functions are declared with GCC_PUBLIC_API, any private\nhelper functions are declared with GCC_PRIVATE_API\n\nDifferent plugins are likely to want different lifetime-management\npolicies for the wrapper objects: some plugins will want to\ngarbage-collect, others will want to reference-count, etc.\n\nHence all types are \"really\" just pointers, but are hidden somewhat to\nemphasize that you must collaborate with the GCC garbage collector.\n\nNaming convention:  a gcc_something is an interface to a GCC \"something\"\ne.g. gcc_gimple_phi is an interface to a GCC gimple phi node.  All types\nalso have a standard varname (e.g. \"edge\" for a gcc_cfg_edge).  All\nfunctions have a prefix relating to what they act on, e.g.:\n\n    GCC_PUBLIC_API (int)\n    gcc_cfg_block_get_index (gcc_cfg_block block);\n\nAll such interface types have a \"mark_in_use\" function, e.g.::\n\n    GCC_PUBLIC_API (void)\n    gcc_cfg_block_mark_in_use (gcc_cfg_block block);\n\nIf you're holding a pointer to one of these types, you *must* call this\nwhen GCC's garbage collector runs.\n\nGetters are named \"TYPEPREFIX_get_ATTR\" e.g. \"gcc_cfg_block_get_index\"\n\nIterators follow a common pattern.  Here's one that iterates over all basic\nblocks within a control flow graph::\n\n      GCC_PUBLIC_API (bool)\n      gcc_cfg_for_each_block (gcc_cfg cfg,\n                              bool (*cb) (gcc_cfg_block block, void *user_data),\n                              void *user_data);\n\nThe iteration terminates if the callback ever returns truth (allowing\nit also to be used for a linear search).  The overall return value is truth\nif any callback returned truth (implying there was an early exit), or false\nif every callback returned falsehood (implying every element was visited).\n\n\nC-based class hierarchy\n^^^^^^^^^^^^^^^^^^^^^^^\nThere is a \"class hierarchy\" to the types, but it is expressed in C.\n\nThere are explicit casting functions for every pair of types.  For example,\nthis function allows you to upcast a gcc_ssa_name to its parent class\ngcc_tree::\n\n  GCC_PUBLIC_API (gcc_tree)\n  gcc_ssa_name_as_gcc_tree (gcc_ssa_name node);\n\nand this function does the reverse, downcasting a gcc_tree to the more refined\nclass gcc_ssa_name::\n\n  GCC_PUBLIC_API (gcc_ssa_name)\n  gcc_tree_as_gcc_ssa_name (gcc_tree node);\n\n\nXML hooks\n^^^^^^^^^\nThe API is described in XML form, expressing the class hierarchy, along with\nwith the attributes that each class has.  This makes it easy to programatically\nmanipulate the API: every important platform can already handle XML.  The\nheader files for the API are generated from the XML description.  (This was\nuseful for generating all of the casting functions).\n\nThere is a RELAX-NG schema for the XML format.\n\n(I also tried JSON, but XML ended up being clearer).\n\nTODO: how to arrange for your code to be called when the GC runs?\n\nTODO: getting errors?\n"
  },
  {
    "path": "gcc-c-api/diagnostics.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"diagnostics\">\n\n  <doc>Diagnostics</doc>\n\n  <function name=\"inform\" returntype=\"void\">\n    <parameter name=\"location\" type=\"location\"/>\n    <parameter name=\"message\" type=\"string\"/>\n  </function>\n\n  <function name=\"error_at\" returntype=\"void\">\n    <parameter name=\"location\" type=\"location\"/>\n    <parameter name=\"message\" type=\"string\"/>\n  </function>\n\n  <function name=\"warning_at\" returntype=\"bool\">\n    <parameter name=\"location\" type=\"location\"/>\n    <parameter name=\"message\" type=\"string\"/>\n    <parameter name=\"option\" type=\"option\"/>\n  </function>\n\n  <function name=\"permerror\" returntype=\"bool\">\n    <parameter name=\"location\" type=\"location\"/>\n    <parameter name=\"message\" type=\"string\"/>\n  </function>\n\n</api>"
  },
  {
    "path": "gcc-c-api/function.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"function\">\n\n  <doc>Functions</doc>\n\n  <type name=\"function\" varname=\"func\" inner=\"struct function*\">\n    <attribute name=\"cfg\" kind=\"cfg\">\n      <doc>The control flow graph for this function (can be NULL in early\n      passes)</doc>\n    </attribute>\n    <attribute name=\"decl\" kind=\"function_decl\"/>\n    <attribute name=\"index\" kind=\"int\"/>\n    <attribute name=\"start\" kind=\"location\"/>\n    <attribute name=\"end\" kind=\"location\"/>\n  </type>\n\n  <attribute name=\"current_function\" kind=\"function\"/>\n\n</api>"
  },
  {
    "path": "gcc-c-api/gcc-callgraph.c",
    "content": "/*\n   Copyright 2012, 2013, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-callgraph.h\"\n#include \"tree.h\"\n#include \"cgraph.h\"\n#include \"ggc.h\"\n#include \"tree-ssa-alias.h\"\n#include \"basic-block.h\"\n#if (GCC_VERSION >= 4009)\n#include \"tree-ssa-alias.h\" /* needed by gimple.h in 4.9 */\n#include \"internal-fn.h\" /* needed by gimple.h in 4.9 */\n#include \"is-a.h\" /* needed by gimple.h in 4.9 */\n#include \"predict.h\" /* needed by gimple.h in 4.9 */\n#include \"gimple-expr.h\" /* needed by gimple.h in 4.9 */\n#endif\n#include \"gimple.h\"\n\n/***********************************************************\n   gcc_cgraph_node\n************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_cgraph_node)\ngcc_private_make_cgraph_node (struct cgraph_node *inner)\n{\n  struct gcc_cgraph_node result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_PUBLIC_API (void) gcc_cgraph_node_mark_in_use (gcc_cgraph_node node)\n{\n  /* As of gcc 4.9, a cgraph_node inherits from symtab node and uses that\n     struct's marking routine.\n  */\n#if (GCC_VERSION >= 4009)\n  gt_ggc_mx_symtab_node (node.inner);\n#else\n  gt_ggc_mx_cgraph_node (node.inner);\n#endif\n}\n\nGCC_PUBLIC_API (gcc_function_decl)\ngcc_cgraph_node_get_decl (gcc_cgraph_node node)\n{\n  /* gcc 4.8 eliminated the\n       tree decl;\n     field of cgraph_node in favor of\n       struct symtab_node_base symbol;\n\n     gcc 4.9 made cgraph_node inherit from symtab_node_base, renaming\n     the latter to symtab_node.\n  */\n  tree decl;\n\n#if (GCC_VERSION >= 4009)\n  /* Access decl field of parent class, symtab_node */\n  decl = node.inner->decl;\n#else\n#  if (GCC_VERSION >= 4008)\n  decl = node.inner->symbol.decl;\n#  else\n  decl = node.inner->decl;\n#  endif\n#endif\n\n  return gcc_private_make_function_decl (decl);\n}\n\nGCC_PUBLIC_API (bool)\ngcc_cgraph_node_for_each_callee (gcc_cgraph_node node,\n\t\t\t\t bool (*cb) (gcc_cgraph_edge edge,\n\t\t\t\t\t     void *user_data),\n\t\t\t\t void *user_data)\n{\n  struct cgraph_edge *edge;\n\n  for (edge = node.inner->callees; edge; edge = edge->next_callee)\n    {\n      if (cb (gcc_private_make_cgraph_edge (edge), user_data))\n\t{\n\t  return true;\n\t}\n    }\n  return false;\n}\n\nGCC_PUBLIC_API (bool)\ngcc_cgraph_node_for_each_caller (gcc_cgraph_node node,\n\t\t\t\t bool (*cb) (gcc_cgraph_edge edge,\n\t\t\t\t\t     void *user_data),\n\t\t\t\t void *user_data)\n{\n  struct cgraph_edge *edge;\n\n  for (edge = node.inner->callers; edge; edge = edge->next_caller)\n    {\n      if (cb (gcc_private_make_cgraph_edge (edge), user_data))\n\t{\n\t  return true;\n\t}\n    }\n  return false;\n}\n\n/***********************************************************\n   gcc_cgraph_edge\n************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_cgraph_edge)\ngcc_private_make_cgraph_edge (struct cgraph_edge *inner)\n{\n  struct gcc_cgraph_edge result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_PUBLIC_API (void) gcc_cgraph_edge_mark_in_use (gcc_cgraph_edge edge)\n{\n  gt_ggc_mx_cgraph_edge (edge.inner);\n}\n\nGCC_PUBLIC_API (gcc_cgraph_node)\ngcc_cgraph_edge_get_caller (gcc_cgraph_edge edge)\n{\n  return gcc_private_make_cgraph_node (edge.inner->caller);\n}\n\nGCC_PUBLIC_API (gcc_cgraph_node)\ngcc_cgraph_edge_get_callee (gcc_cgraph_edge edge)\n{\n  return gcc_private_make_cgraph_node (edge.inner->callee);\n}\n\nGCC_PUBLIC_API (gcc_gimple_call)\ngcc_cgraph_edge_get_call_stmt (gcc_cgraph_edge edge)\n{\n  return gcc_private_make_gimple_call (edge.inner->call_stmt);\n}\n\nGCC_PUBLIC_API (bool)\ngcc_for_each_cgraph_node (bool (*cb) (gcc_cgraph_node node, void *user_data),\n\t\t\t  void *user_data)\n{\n  struct cgraph_node *node;\n\n  /*\n    gcc 4.7 introduced FOR_EACH_DEFINED_FUNCTION\n    gcc 4.8 eliminated: extern GTY(()) struct cgraph_node *cgraph_nodes;\n    FIXME: does this only visit *defined* functions then?\n  */\n#if (GCC_VERSION >= 4008)\n  FOR_EACH_DEFINED_FUNCTION(node)\n#else\n  for (node = cgraph_nodes; node; node = node->next)\n#endif\n    {\n      if (cb (gcc_private_make_cgraph_node (node), user_data))\n\t{\n\t  return true;\n\t}\n    }\n  return false;\n}\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-cfg.c",
    "content": "/*\n   Copyright 2012, 2013, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-cfg.h\"\n\n#include \"tree.h\"\n#include \"function.h\"\n#include \"basic-block.h\"\n\n#if (GCC_VERSION >= 4009)\n#include \"tree-ssa-alias.h\" /* needed by gimple.h in 4.9 */\n#include \"internal-fn.h\" /* needed by gimple.h in 4.9 */\n#include \"is-a.h\" /* needed by gimple.h in 4.9 */\n#include \"predict.h\" /* needed by gimple.h in 4.9 */\n#include \"gimple-expr.h\" /* needed by gimple.h in 4.9 */\n#endif\n#include \"gimple.h\"\n\n/* gcc 4.9 moved gimple_stmt_iterator into this header */\n#if (GCC_VERSION >= 4009)\n#include \"gimple-iterator.h\"\n#endif\n\n/* gcc 10 removed this header */\n#if (GCC_VERSION < 10000)\n#include \"params.h\"\n#endif\n\n#include \"tree.h\"\n#include \"diagnostic.h\"\n#include \"cgraph.h\"\n#include \"opts.h\"\n#include \"rtl.h\"\n\n#include \"gcc-private-compat.h\"\n\n/***********************************************************\n   gcc_cfg\n************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_cfg)\ngcc_private_make_cfg (struct control_flow_graph *inner)\n{\n  struct gcc_cfg result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_cfg_mark_in_use (gcc_cfg cfg)\n{\n  gt_ggc_mx_control_flow_graph (cfg.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_cfg_block) gcc_cfg_get_entry (gcc_cfg cfg)\n{\n  return gcc_private_make_cfg_block (cfg.inner->x_entry_block_ptr);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_cfg_block) gcc_cfg_get_exit (gcc_cfg cfg)\n{\n  return gcc_private_make_cfg_block (cfg.inner->x_exit_block_ptr);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_cfg_for_each_block (gcc_cfg cfg,\n\t\t\tbool (*cb) (gcc_cfg_block block, void *user_data),\n\t\t\tvoid *user_data)\n{\n  int i;\n\n  for (i = 0; i < cfg.inner->x_n_basic_blocks; i++)\n    {\n      basic_block bb = GCC_COMPAT_VEC_INDEX (basic_block,\n                                             cfg.inner->x_basic_block_info,\n                                             i);\n      if (cb (gcc_private_make_cfg_block (bb), user_data))\n\t{\n\t  return true;\n\t}\n    }\n  return false;\n\n}\n\n/***********************************************************\n  gcc_cfg_block\n************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_cfg_block)\ngcc_private_make_cfg_block (basic_block inner)\n{\n  struct gcc_cfg_block result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (void)\ngcc_cfg_block_mark_in_use (gcc_cfg_block block)\n{\n  gt_ggc_mx_basic_block_def (block.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (int)\ngcc_cfg_block_get_index (gcc_cfg_block block)\n{\n  return block.inner->index;\n}\n\nstatic bool\nfor_each_edge (\n#if (GCC_VERSION >= 4008)\n               vec<edge, va_gc> *vec_edges,\n#else\n               VEC (edge, gc) * vec_edges,\n#endif\n\t       bool (*cb) (gcc_cfg_edge edge, void *user_data),\n\t       void *user_data)\n{\n  int i;\n  edge e;\n\n  GCC_COMPAT_FOR_EACH_VEC_ELT (edge, vec_edges, i, e)\n  {\n    if (cb (gcc_private_make_cfg_edge (e), user_data))\n      {\n\treturn true;\n      }\n  }\n\n  return false;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_cfg_block_for_each_pred_edge (gcc_cfg_block block,\n\t\t\t\t  bool (*cb) (gcc_cfg_edge edge,\n\t\t\t\t\t      void *user_data),\n\t\t\t\t  void *user_data)\n{\n  return for_each_edge (block.inner->preds, cb, user_data);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_cfg_block_for_each_succ_edge (gcc_cfg_block block,\n\t\t\t\t  bool (*cb) (gcc_cfg_edge edge,\n\t\t\t\t\t      void *user_data),\n\t\t\t\t  void *user_data)\n{\n  return for_each_edge (block.inner->succs, cb, user_data);\n}\n\n/* In GCC 4.7, struct basic_block_def had a\n     struct gimple_bb_info * gimple;\n   within its il union.\n\n   In GCC 4.8, this became:\n     struct gimple_bb_info gimple\n   i.e. it is no longer dereferenced\n*/\nstatic struct gimple_bb_info *\nchecked_get_gimple_info(gcc_cfg_block block)\n{\n  if (block.inner->flags & BB_RTL)\n    {\n      return NULL;\n    }\n\n#if (GCC_VERSION >= 4008)\n  return &block.inner->il.gimple;\n#else\n  return block.inner->il.gimple;\n#endif\n}\n\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_cfg_block_for_each_gimple_phi (gcc_cfg_block block,\n\t\t\t\t   bool (*cb) (gcc_gimple_phi phi,\n\t\t\t\t\t       void *user_data),\n\t\t\t\t   void *user_data)\n{\n  gimple_stmt_iterator gsi;\n  struct gimple_bb_info *info;\n\n  info = checked_get_gimple_info(block);\n\n  if (NULL == info)\n    {\n      return false;\n    }\n\n  for (gsi = gsi_start (info->phi_nodes);\n       !gsi_end_p (gsi); gsi_next (&gsi))\n    {\n\n      gimple_stmt_ptr stmt = gsi_stmt (gsi);\n      if (cb (gcc_private_make_gimple_phi (stmt), user_data))\n\t{\n\t  return true;\n\t}\n    }\n\n  return false;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_cfg_block_for_each_gimple (gcc_cfg_block block,\n\t\t\t       bool (*cb) (gcc_gimple stmt, void *user_data),\n\t\t\t       void *user_data)\n{\n  gimple_stmt_iterator gsi;\n  struct gimple_bb_info *info;\n\n  info = checked_get_gimple_info(block);\n\n  if (NULL == info)\n    {\n      return false;\n    }\n\n  for (gsi = gsi_start (info->seq);\n       !gsi_end_p (gsi); gsi_next (&gsi))\n    {\n\n      gimple_stmt_ptr stmt = gsi_stmt (gsi);\n      if (cb (gcc_private_make_gimple (stmt), user_data))\n\t{\n\t  return true;\n\t}\n    }\n\n  return false;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_cfg_block_for_each_rtl_insn (gcc_cfg_block block,\n\t\t\t\t bool (*cb) (gcc_rtl_insn insn,\n\t\t\t\t\t     void *user_data),\n\t\t\t\t void *user_data)\n{\n#if (GCC_VERSION >= 5000)\n  rtx_insn *insn;\n#else\n  rtx insn;\n#endif\n\n  if (!(block.inner->flags & BB_RTL))\n    {\n      return false;\n    }\n\n  FOR_BB_INSNS (block.inner, insn)\n  {\n    if (cb (gcc_private_make_rtl_insn (insn), user_data))\n      {\n\treturn true;\n      }\n  }\n\n  return false;\n}\n\n/***********************************************************\n   gcc_cfg_edge\n************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_cfg_edge)\ngcc_private_make_cfg_edge (edge inner)\n{\n  struct gcc_cfg_edge result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_cfg_edge_mark_in_use (gcc_cfg_edge edge)\n{\n  gt_ggc_mx_edge_def (edge.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_cfg_block)\ngcc_cfg_edge_get_src (gcc_cfg_edge edge)\n{\n  return gcc_private_make_cfg_block (edge.inner->src);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_cfg_block)\ngcc_cfg_edge_get_dest (gcc_cfg_edge edge)\n{\n  return gcc_private_make_cfg_block (edge.inner->dest);\n}\n\nGCC_PUBLIC_API (bool) gcc_cfg_edge_is_true_value (gcc_cfg_edge edge)\n{\n  return (edge.inner->flags & EDGE_TRUE_VALUE) == EDGE_TRUE_VALUE;\n}\n\nGCC_PUBLIC_API (bool) gcc_cfg_edge_is_false_value (gcc_cfg_edge edge)\n{\n  return (edge.inner->flags & EDGE_FALSE_VALUE) == EDGE_FALSE_VALUE;\n}\n\nGCC_PUBLIC_API(bool)\ngcc_cfg_edge_is_loop_exit(gcc_cfg_edge edge)\n{\n  return (edge.inner->flags & EDGE_LOOP_EXIT) == EDGE_LOOP_EXIT;\n}\n\nGCC_PUBLIC_API(bool)\ngcc_cfg_edge_get_can_fallthru(gcc_cfg_edge edge)\n{\n  return (edge.inner->flags & EDGE_CAN_FALLTHRU) == EDGE_CAN_FALLTHRU;\n}\n\nGCC_PUBLIC_API(bool)\ngcc_cfg_edge_is_complex(gcc_cfg_edge edge)\n{\n  return (edge.inner->flags & EDGE_COMPLEX);\n}\n\nGCC_PUBLIC_API(bool)\ngcc_cfg_edge_is_eh(gcc_cfg_edge edge)\n{\n  return (edge.inner->flags & EDGE_EH) == EDGE_EH;\n}\n\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-common.h",
    "content": "/*\n   Copyright 2012, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <gcc-plugin.h>\n\n/* see design.rst for notes */\n\n/* Compatibility macros */\n\n/* For declarations: */\n#define GCC_PUBLIC_API(RETURN_TYPE) extern RETURN_TYPE\n#define GCC_PRIVATE_API(RETURN_TYPE) extern RETURN_TYPE\n\n#if (GCC_VERSION >= 6000)\ntypedef gimple *gimple_stmt_ptr;\n#else\ntypedef gimple gimple_stmt_ptr;\n#endif\n\n#include \"gcc-public-types.h\"\n\n/* For internal use: */\n#define GCC_IMPLEMENT_PUBLIC_API(RETURN_TYPE) RETURN_TYPE\n#define GCC_IMPLEMENT_PRIVATE_API(RETURN_TYPE) RETURN_TYPE\n\n#if (GCC_VERSION >= 5000)\n#define AS_A_GASM(STMT) (as_a <gasm *> (STMT))\n#define AS_A_GCOND(STMT) (as_a <gcond *> (STMT))\n#define AS_A_GLABEL(STMT) (as_a <glabel *> (STMT))\n#define AS_A_GPHI(STMT) (as_a <gphi *> (STMT))\n#define AS_A_GSWITCH(STMT) (as_a <gswitch *> (STMT))\n#define AS_A_GRETURN(STMT) (as_a <greturn *> (STMT))\n#else\n#define AS_A_GASM(STMT) (STMT)\n#define AS_A_GCOND(STMT) (STMT)\n#define AS_A_GLABEL(STMT) (STMT)\n#define AS_A_GPHI(STMT) (STMT)\n#define AS_A_GSWITCH(STMT) (STMT)\n#define AS_A_GRETURN(STMT) (STMT)\n#endif\n"
  },
  {
    "path": "gcc-c-api/gcc-constant.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-common.h\"\n#include \"gcc-constant.h\"\n#include \"gcc-internal.h\"\n#include \"tree.h\"\n\n/* gcc_constant */\n/* gcc_integer_constant */\n\n/***************************************************************************\n gcc_string_constant\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(const char*)\ngcc_string_constant_get_char_ptr(gcc_string_constant node)\n{\n  return TREE_STRING_POINTER (node.inner);\n}\n\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-declaration.c",
    "content": "/*\n   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-common.h\"\n#include \"gcc-semiprivate-types.h\"\n#include \"gcc-declaration.h\"\n#include \"tree.h\"\n#include \"gcc-internal.h\"\n#include \"gcc-tree.h\"\n#include \"gcc-private-compat.h\"\n\n/***************************************************************************\n gcc_decl\n **************************************************************************/\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_location) gcc_decl_get_location (gcc_decl decl)\n{\n  return gcc_private_make_location (DECL_SOURCE_LOCATION (decl.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool) gcc_decl_is_artificial (gcc_decl decl)\n{\n  return DECL_ARTIFICIAL (decl.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API(bool) gcc_decl_is_builtin(gcc_decl decl)\n{\n  return DECL_IS_BUILTIN (decl.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree) gcc_decl_as_gcc_tree (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_class_method_decl)\ngcc_decl_as_gcc_class_method_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_const_decl)\ngcc_decl_as_gcc_const_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_debug_expr_decl)\ngcc_decl_as_gcc_debug_expr_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_field_decl)\ngcc_decl_as_gcc_field_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_function_decl)\ngcc_decl_as_gcc_function_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_imported_decl)\ngcc_decl_as_gcc_imported_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_instance_method_decl)\ngcc_decl_as_gcc_instance_method_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_keyword_decl)\ngcc_decl_as_gcc_keyword_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_label_decl)\ngcc_decl_as_gcc_label_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_namespace_decl)\ngcc_decl_as_gcc_namespace_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_parm_decl)\ngcc_decl_as_gcc_parm_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_property_decl)\ngcc_decl_as_gcc_property_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_result_decl)\ngcc_decl_as_gcc_result_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_template_decl)\ngcc_decl_as_gcc_template_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_translation_unit_decl)\ngcc_decl_as_gcc_translation_unit_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_type_decl)\ngcc_decl_as_gcc_type_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_using_decl)\ngcc_decl_as_gcc_using_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_var_decl)\ngcc_decl_as_gcc_var_decl (gcc_decl node);\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_function_decl)\ngcc_private_make_function_decl (tree inner)\n{\n  struct gcc_function_decl result;\n  result.inner = FUNCTION_DECL_CHECK (inner);\n  return result;\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_translation_unit_decl)\ngcc_private_make_translation_unit_decl (tree inner)\n{\n  struct gcc_translation_unit_decl result;\n  result.inner = TRANSLATION_UNIT_DECL_CHECK (inner);\n  return result;\n}\n\n\n/***************************************************************************\n gcc_class_method_decl\n **************************************************************************/\n/***************************************************************************\n gcc_const_decl\n **************************************************************************/\n/***************************************************************************\n gcc_debug_expr_decl\n **************************************************************************/\n/***************************************************************************\n gcc_field_decl\n **************************************************************************/\n/***************************************************************************\n gcc_function_decl\n **************************************************************************/\n/***************************************************************************\n gcc_imported_decl\n **************************************************************************/\n/***************************************************************************\n gcc_instance_method_decl\n **************************************************************************/\n/***************************************************************************\n gcc_keyword_decl\n **************************************************************************/\n/***************************************************************************\n gcc_label_decl\n **************************************************************************/\n/***************************************************************************\n gcc_namespace_decl\n **************************************************************************/\n/***************************************************************************\n gcc_parm_decl\n **************************************************************************/\n/***************************************************************************\n gcc_property_decl\n **************************************************************************/\n/***************************************************************************\n gcc_result_decl\n **************************************************************************/\n/***************************************************************************\n gcc_template_decl\n **************************************************************************/\n/***************************************************************************\n gcc_translation_unit_decl\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_block)\ngcc_translation_unit_decl_get_block (gcc_translation_unit_decl node)\n{\n  return gcc_private_make_block (DECL_INITIAL (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (const char *)\ngcc_translation_unit_decl_get_language (gcc_translation_unit_decl node)\n{\n  return TRANSLATION_UNIT_LANGUAGE (node.inner);\n}\n\n/***************************************************************************\n gcc_type_decl\n **************************************************************************/\n/***************************************************************************\n gcc_using_decl\n **************************************************************************/\n/***************************************************************************\n gcc_var_decl\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_constructor)\ngcc_var_decl_get_initial(gcc_var_decl node)\n{\n  return gcc_tree_as_gcc_constructor (gcc_private_make_tree (DECL_INITIAL (node.inner)));\n}\n\nGCC_IMPLEMENT_PUBLIC_API(bool)\ngcc_var_decl_is_static(gcc_var_decl node)\n{\n  return TREE_STATIC(node.inner);\n}\n\n/***************************************************************************\n Other things:\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_for_each_translation_unit_decl (bool (*cb)\n\t\t\t\t    (gcc_translation_unit_decl node,\n\t\t\t\t     void *user_data), void *user_data)\n{\n  int i;\n  tree t;\n\n  /*\n     all_translation_units was made globally visible in gcc revision 164331:\n     http://gcc.gnu.org/ml/gcc-cvs/2010-09/msg00625.html\n     http://gcc.gnu.org/viewcvs?view=revision&revision=164331\n   */\n  GCC_COMPAT_FOR_EACH_VEC_ELT (tree, all_translation_units, i, t)\n  {\n    if (cb (gcc_private_make_translation_unit_decl (t), user_data))\n      {\n\treturn true;\n      }\n  }\n  return false;\n}\n\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-diagnostics.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-diagnostics.h\"\n\n#include \"diagnostic.h\"\n\nGCC_IMPLEMENT_PUBLIC_API(void)\ngcc_inform(gcc_location location, const char* message)\n{\n  return inform(location.inner, \"%s\", message);\n}\n\nGCC_IMPLEMENT_PUBLIC_API(void)\ngcc_error_at(gcc_location location, const char* message)\n{\n  return error_at(location.inner, \"%s\", message);\n}\n\n#if 0\nGCC_IMPLEMENT_PUBLIC_API(bool)\ngcc_warning_at(gcc_location location, const char* message, gcc_option option)\n{\n  /* TODO (what about the no-option case?) */\n}\n#endif\n\nGCC_IMPLEMENT_PUBLIC_API(bool)\ngcc_permerror(gcc_location location, const char* message)\n{\n  return permerror(location.inner, \"%s\", message);\n}\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-function.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-common.h\"\n#include \"gcc-function.h\"\n\n/* TODO: rationalize these headers */\n#include \"tree.h\"\n\n/* gcc 10 removed this header */\n#if (GCC_VERSION < 10000)\n#include \"params.h\"\n#endif\n\n#include \"tree.h\"\n#include \"function.h\"\n#include \"diagnostic.h\"\n#include \"cgraph.h\"\n#include \"opts.h\"\n#include \"basic-block.h\"\n#include \"rtl.h\"\n#include \"ggc.h\"\n\n/* Declarations: functions */\n\n/* gcc_function */\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_function_mark_in_use (gcc_function func)\n{\n  gt_ggc_mx_function (func.inner);\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_function)\ngcc_private_make_function (struct function *inner)\n{\n  struct gcc_function result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_cfg) gcc_function_get_cfg (gcc_function func)\n{\n  return gcc_private_make_cfg (func.inner->cfg);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_function_decl)\ngcc_function_get_decl (gcc_function func)\n{\n  return gcc_private_make_function_decl (func.inner->decl);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (int) gcc_function_get_index (gcc_function func)\n{\n  return func.inner->funcdef_no;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_location)\ngcc_function_get_start (gcc_function func)\n{\n  return gcc_private_make_location (func.inner->function_start_locus);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_location)\ngcc_function_get_end (gcc_function func)\n{\n  return gcc_private_make_location (func.inner->function_end_locus);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_function) gcc_get_current_function (void)\n{\n  return gcc_private_make_function (cfun);\n}\n\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-gimple.c",
    "content": "/*\n   Copyright 2012, 2013, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-gimple.h\"\n#include \"gcc-tree.h\"\n#include \"gcc-internal.h\"\n\n#include \"tree.h\"\n#include \"function.h\"\n#include \"basic-block.h\"\n#if (GCC_VERSION >= 4009)\n//#include \"alias.h\" /* needed by tree-ssa-alias.h in 4.9 */\n#include \"tree-ssa-alias.h\" /* needed by gimple.h in 4.9 */\n#include \"internal-fn.h\" /* needed by gimple.h in 4.9 */\n#include \"is-a.h\" /* needed by gimple.h in 4.9 */\n#include \"predict.h\" /* needed by gimple.h in 4.9 */\n#include \"gimple-expr.h\" /* needed by gimple.h in 4.9 */\n#endif\n#include \"gimple.h\"\n\n#if 0\n\n/* gcc 10 removed this header */\n#if (GCC_VERSION < 10000)\n#include \"params.h\"\n#endif\n\n#include \"cp/name-lookup.h\"\t/* for global_namespace */\n#include \"tree.h\"\n#include \"diagnostic.h\"\n#include \"cgraph.h\"\n#include \"opts.h\"\n#include \"c-family/c-pragma.h\"\t/* for parse_in */\n#include \"rtl.h\"\n#endif\n\n#include <gcc-plugin.h>\n\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_gimple_mark_in_use (gcc_gimple stmt)\n{\n  /* Mark the underlying object (recursing into its fields): */\n\n  /* GCC 4.9 converted gimple to a class hierarchy */\n#if (GCC_VERSION >= 4009)\n\n  /* GCC 6 converted the base class from \"gimple_statement_base\" to\n     \"gimple\".  */\n# if (GCC_VERSION >= 6000)\n  gt_ggc_mx_gimple (stmt.inner);\n# else\n  gt_ggc_mx_gimple_statement_base (stmt.inner);\n# endif\n#else /* #if (GCC_VERSION >= 4009) */\n  gt_ggc_mx_gimple_statement_d (stmt.inner);\n#endif  /* #if (GCC_VERSION >= 4009) */\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_gimple_phi)\ngcc_private_make_gimple_phi (gimple_stmt_ptr inner)\n{\n  struct gcc_gimple_phi result;\n  GIMPLE_CHECK (inner, GIMPLE_PHI);\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_gimple_call)\ngcc_private_make_gimple_call (gimple_stmt_ptr inner)\n{\n  struct gcc_gimple_call result;\n  GIMPLE_CHECK (inner, GIMPLE_CALL);\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_gimple)\ngcc_private_make_gimple (gimple_stmt_ptr inner)\n{\n  struct gcc_gimple result;\n  result.inner = inner;\n  return result;\n}\n\n\n/***************************************************************************\n gcc_gimple\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API (gcc_location)\ngcc_gimple_get_location (gcc_gimple stmt)\n{\n  return gcc_private_make_location (gimple_location (stmt.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree) gcc_gimple_get_block (gcc_gimple stmt)\n{\n  return gcc_private_make_tree (gimple_block (stmt.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree) gcc_gimple_get_expr_type (gcc_gimple stmt)\n{\n  return gcc_private_make_tree (gimple_expr_type (stmt.inner));\n}\n\n/***************************************************************************\n gcc_gimple_asm\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API (const char *)\ngcc_gimple_asm_get_string (gcc_gimple_asm stmt)\n{\n  return gimple_asm_string (AS_A_GASM (stmt.inner));\n}\n\n/***************************************************************************\n gcc_gimple_assign\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_assign_get_lhs (gcc_gimple_assign stmt)\n{\n  return gcc_private_make_tree (gimple_assign_lhs (stmt.inner));\n}\n\n/***************************************************************************\n gcc_gimple_call\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_call_get_lhs (gcc_gimple_call stmt)\n{\n  return gcc_private_make_tree (gimple_call_lhs (stmt.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_call_get_fn (gcc_gimple_call stmt)\n{\n  return gcc_private_make_tree (gimple_call_fn (stmt.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_call_get_fndecl (gcc_gimple_call stmt)\n{\n  return gcc_private_make_tree (gimple_call_fndecl (stmt.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_gimple_call_is_noreturn (gcc_gimple_call stmt)\n{\n  return gimple_call_noreturn_p (stmt.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_gimple_call_for_each_arg (gcc_gimple_call stmt,\n\t\t\t      bool (*cb) (gcc_tree node, void *user_data),\n\t\t\t      void *user_data)\n{\n  int num_args = gimple_call_num_args (stmt.inner);\n  int i;\n\n  for (i = 0; i < num_args; i++)\n    {\n      if (cb (gcc_private_make_tree (gimple_call_arg (stmt.inner, i)),\n\t      user_data))\n\t{\n\t  return true;\n\t}\n    }\n  return false;\n}\n\n/***************************************************************************\n gcc_gimple_return\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_return_get_retval (gcc_gimple_return stmt)\n{\n  return gcc_private_make_tree\n            (gimple_return_retval (AS_A_GRETURN (stmt.inner)));\n}\n\n/***************************************************************************\n gcc_gimple_cond\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_cond_get_lhs (gcc_gimple_cond stmt)\n{\n  return gcc_private_make_tree (gimple_cond_lhs (stmt.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_cond_get_rhs (gcc_gimple_cond stmt)\n{\n  return gcc_private_make_tree (gimple_cond_rhs (stmt.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_cond_get_true_label (gcc_gimple_cond stmt)\n{\n  return gcc_private_make_tree (gimple_cond_true_label\n                                 (AS_A_GCOND (stmt.inner)));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_cond_get_false_label (gcc_gimple_cond stmt)\n{\n  return gcc_private_make_tree (gimple_cond_false_label\n                                 (AS_A_GCOND (stmt.inner)));\n}\n\n/***************************************************************************\n gcc_gimple_phi\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_phi_get_lhs (gcc_gimple_phi phi)\n{\n  return gcc_private_make_tree (gimple_phi_result (phi.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_phi_get_result (gcc_gimple_phi phi)\n{\n  return gcc_private_make_tree (gimple_phi_result (phi.inner));\n}\n\n/*\n  Iterator; terminates if the callback returns truth\n  (for linear search)\n*/\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_gimple_phi_for_each_exprs (gcc_gimple_phi phi,\n\t\t\t       bool (*cb) (gcc_tree node, void *user_data),\n\t\t\t       void *user_data);\n\n/*\n  Iterator; terminates if the callback returns truth\n  (for linear search)\n*/\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_gimple_phi_for_each_edges (gcc_gimple_phi phi,\n\t\t\t       bool (*cb) (gcc_cfg_edge edge,\n\t\t\t\t\t   void *user_data), void *user_data);\n\n/***************************************************************************\n gcc_gimple_switch\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_gimple_switch_get_indexvar (gcc_gimple_switch stmt)\n{\n  return gcc_private_make_tree (gimple_switch_index\n                                  (AS_A_GSWITCH (stmt.inner)));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_gimple_switch_for_each_label (gcc_gimple_switch stmt,\n\t\t\t\t  bool (*cb) (gcc_case_label_expr node,\n\t\t\t\t\t      void *user_data),\n\t\t\t\t  void *user_data)\n{\n  unsigned num_labels = gimple_switch_num_labels (AS_A_GSWITCH (stmt.inner));\n  unsigned i;\n\n  for (i = 0; i < num_labels; i++)\n    {\n      if (cb\n\t  (gcc_private_make_case_label_expr\n\t   (gimple_switch_label (AS_A_GSWITCH (stmt.inner), i)), user_data))\n\t{\n\t  return true;\n\t}\n    }\n  return false;\n}\n\n/***************************************************************************\n gcc_gimple_label\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_label_decl)\ngcc_gimple_label_get_label(gcc_gimple_label stmt)\n{\n  return gcc_tree_as_gcc_label_decl\n           (gcc_private_make_tree (gimple_label_label\n                                     (AS_A_GLABEL (stmt.inner))));\n}\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-internal.h",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#define IMPLEMENT_CAST(T_INPUT, T_OUTPUT)     \\\n  GCC_IMPLEMENT_PUBLIC_API(T_OUTPUT)          \\\n  T_INPUT ## _as_ ## T_OUTPUT(T_INPUT input)  \\\n  {                                           \\\n      T_OUTPUT output;                        \\\n      output.inner = input.inner;             \\\n      return output;                          \\\n  }\n"
  },
  {
    "path": "gcc-c-api/gcc-location.c",
    "content": "/*\n   Copyright 2012, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-location.h\"\n\n/***********************************************************\n   gcc_location\n************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_location)\ngcc_private_make_location (location_t inner)\n{\n  struct gcc_location result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_location_mark_in_use (gcc_location loc)\n{\n  /* empty */\n}\n\nGCC_IMPLEMENT_PUBLIC_API (const char *)\ngcc_location_get_filename (gcc_location loc)\n{\n  return LOCATION_FILE (loc.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (int) gcc_location_get_line (gcc_location loc)\n{\n  return LOCATION_LINE (loc.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (int) gcc_location_get_column (gcc_location loc)\n{\n  expanded_location exploc = expand_location (loc.inner);\n  return exploc.column;\n}\n\nGCC_PUBLIC_API (bool) gcc_location_is_unknown (gcc_location loc)\n{\n  return UNKNOWN_LOCATION == loc.inner;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool) gcc_location_get_in_system_header (gcc_location loc)\n{\n  return in_system_header_at (loc.inner);\n}\n\n/* get_pure_location and get_finish were added to gcc's input.h in\n   gcc's r238792 (aka f17776ffcba650feb512137e3e22a04f3f433c84).\n   get_start was added to gcc's input.h in gcc's r239831\n   (aka aca2a315073c72fb7c9ab1be779c290cc91f564c).\n   I believe that makes them available in gcc 7 onwards.  */\n\n#if (GCC_VERSION >= 7000)\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_location)\ngcc_location_get_caret (gcc_location loc)\n{\n  return gcc_private_make_location (get_pure_location (loc.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_location)\ngcc_location_get_start (gcc_location loc)\n{\n  return gcc_private_make_location (get_start (loc.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_location)\ngcc_location_get_finish (gcc_location loc)\n{\n  return gcc_private_make_location (get_finish (loc.inner));\n}\n\n#endif\n\n/* linemap_position_for_loc_and_offset was added in gcc's r217383\n   (aka 766928aa6ac2c846c2d098ef4ef9e220feb4dcab).\n   It's present in gcc 5.1. */\n\n#if (GCC_VERSION >= 5000)\n\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_location_offset_column (gcc_location loc, int offset)\n{\n  return gcc_private_make_location\n    (linemap_position_for_loc_and_offset (line_table, loc.inner,\n                                          offset));\n}\n\n#endif\n\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_set_input_location (gcc_location loc)\n{\n  input_location = loc.inner;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_location) gcc_get_input_location (void)\n{\n  return gcc_private_make_location (input_location);\n}\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-option.c",
    "content": "/*\n   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-option.h\"\n#include \"opts.h\"\n\n/*\n  Command-line options\n*/\n\n/* gcc_option */\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_option)\ngcc_private_make_option (enum opt_code inner)\n{\n  struct gcc_option result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (void)\ngcc_option_mark_in_use (gcc_option opt)\n{\n  /* empty */\n}\n\n\nGCC_IMPLEMENT_PUBLIC_API (const char*)\ngcc_option_get_text (gcc_option opt)\n{\n  return cl_options[opt.inner].opt_text;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_for_each_option (bool (*cb)(gcc_option opt, void *user_data),\n    void *user_data)\n{\n  unsigned int i;\n  for (i = 0; i < cl_options_count; i++)\n    {\n      gcc_option opt = gcc_private_make_option ((enum opt_code)i);\n      if (cb (opt, user_data) )\n        {\n          return true;\n        }\n    }\n  return false;\n}\n\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-private-compat.h",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n   Private header for the API, for handling compatibility between GCC\n   versions\n*/\n\n/*************************************************************************\n Vectors\n *************************************************************************/\n\n/* Getting the length of a vector, returning 0 if it is NULL: */\n#if (GCC_VERSION >= 4008)\n  #define GCC_COMPAT_VEC_LENGTH(KIND, V) \\\n    ( (V) ? ( (V)->length() ) : 0 )\n#else\n  #define GCC_COMPAT_VEC_LENGTH(KIND, V) \\\n    ( VEC_length(KIND, (V)) )\n#endif\n\n/* Looking up an element by index: */\n#if (GCC_VERSION >= 4008)\n  #define GCC_COMPAT_VEC_INDEX(KIND, V, IDX) \\\n    ( (*(V))[IDX] )\n#else\n  #define GCC_COMPAT_VEC_INDEX(KIND, V, IDX) \\\n    ( VEC_index(KIND, (V), (IDX) ) )\n#endif\n\n/* Iterating over every element in a vector, or not at all if it is\n   NULL: */\n#if (GCC_VERSION >= 4008)\n  #define GCC_COMPAT_FOR_EACH_VEC_ELT(KIND, V, IDX_VAR, ITEM_VAR) \\\n    if ( (V) != NULL ) \\\n      FOR_EACH_VEC_ELT ( (*V), (IDX_VAR), (ITEM_VAR) )\n#else\n  #define GCC_COMPAT_FOR_EACH_VEC_ELT(KIND, V, IDX_VAR, ITEM_VAR) \\\n    FOR_EACH_VEC_ELT(KIND, (V), (IDX_VAR), (ITEM_VAR) )\n#endif\n\n\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n\n"
  },
  {
    "path": "gcc-c-api/gcc-rtl.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-rtl.h\"\n\n#include <gcc-plugin.h>\n#include \"tm.h\"\n#include \"tree.h\"\n#include \"rtl.h\"\n#include \"ggc.h\"\n\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_rtl_insn_mark_in_use (gcc_rtl_insn insn)\n{\n  gt_ggc_mx_rtx_def (insn.inner);\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_rtl_insn)\ngcc_private_make_rtl_insn (struct rtx_def *inner)\n{\n  struct gcc_rtl_insn result;\n  result.inner = inner;\n  return result;\n}\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-tree.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-common.h\"\n#include \"gcc-tree.h\"\n#include \"ggc.h\"\n#include \"gcc-internal.h\"\n#include <assert.h>\n#include \"tree.h\"\n\n/*\n  Trees\n*/\n\n/* gcc_tree */\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_tree_mark_in_use (gcc_tree node)\n{\n  /* Mark the underlying object (recursing into its fields): */\n  gt_ggc_mx_tree_node (node.inner);\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_tree)\ngcc_private_make_tree (tree inner)\n{\n  struct gcc_tree result;\n  /* FIXME: type-checking */\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_block)\ngcc_private_make_block (tree inner)\n{\n  struct gcc_block result;\n  result.inner = BLOCK_CHECK (inner);\n  return result;\n}\n\n/* gcc_binary */\n  GCC_IMPLEMENT_PUBLIC_API (void) gcc_binary_mark_in_use (gcc_binary node);\n\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_binary_get_location(gcc_binary node)\n{\n  return gcc_private_make_location (EXPR_LOCATION (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_bitwise_and_expr)\ngcc_binary_as_gcc_bitwise_and_expr (gcc_binary node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_bitwise_ior_expr)\ngcc_binary_as_gcc_bitwise_ior_expr (gcc_binary node);\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_bitwise_xor_expr)\ngcc_binary_as_gcc_bitwise_xor_expr (gcc_binary node);\n\n\n/* gcc_bitwise_and_expr */\nGCC_IMPLEMENT_PUBLIC_API (void)\ngcc_bitwise_and_expr_mark_in_use (gcc_bitwise_and_expr node);\n\n/* gcc_bitwise_ior_expr */\nGCC_IMPLEMENT_PUBLIC_API (void)\ngcc_bitwise_ior_expr_mark_in_use (gcc_bitwise_ior_expr node);\n\n/* gcc_bitwise_xor_expr */\nGCC_IMPLEMENT_PUBLIC_API (void)\ngcc_bitwise_xor_expr_mark_in_use (gcc_bitwise_xor_expr node);\n\n/* gcc_block */\nGCC_IMPLEMENT_PUBLIC_API (void)\ngcc_block_mark_in_use (gcc_block node);\n\n/***************************************************************************\n gcc_comparison\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_comparison_get_location(gcc_comparison node)\n{\n  return gcc_private_make_location (EXPR_LOCATION (node.inner));\n}\n\n/***************************************************************************\n gcc_expression\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_expression_get_location(gcc_expression node)\n{\n  return gcc_private_make_location (EXPR_LOCATION (node.inner));\n}\n\n/***************************************************************************\n gcc_addr_expr\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_tree)\ngcc_addr_expr_get_operand(gcc_addr_expr node)\n{\n  return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));\n}\n\n/***************************************************************************\n gcc_reference\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_reference_get_location(gcc_reference node)\n{\n  return gcc_private_make_location (EXPR_LOCATION (node.inner));\n}\n\n/***************************************************************************\n gcc_array_ref\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_tree)\ngcc_array_ref_get_array(gcc_array_ref node)\n{\n  return gcc_private_make_tree(TREE_OPERAND(node.inner, 0));\n}\n\nGCC_IMPLEMENT_PUBLIC_API(gcc_tree)\ngcc_array_ref_get_index(gcc_array_ref node)\n{\n  return gcc_private_make_tree(TREE_OPERAND(node.inner, 1));\n}\n\n\n/***************************************************************************\n gcc_component_ref\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_tree)\ngcc_component_ref_get_target(gcc_component_ref node)\n{\n  return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));\n}\n\nGCC_IMPLEMENT_PUBLIC_API(gcc_tree)\ngcc_component_ref_get_field(gcc_component_ref node)\n{\n  return gcc_private_make_tree (TREE_OPERAND (node.inner, 1));\n}\n\n/***************************************************************************\n gcc_mem_ref\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_tree)\ngcc_mem_ref_get_operand(gcc_mem_ref node)\n{\n  return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));\n}\n\n/***************************************************************************\n gcc_ssa_name\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_tree) gcc_ssa_name_get_var (gcc_ssa_name node)\n{\n  return gcc_private_make_tree (SSA_NAME_VAR (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_gimple)\ngcc_ssa_name_get_def_stmt (gcc_ssa_name node)\n{\n  return gcc_private_make_gimple (SSA_NAME_DEF_STMT (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (int) gcc_ssa_name_get_version (gcc_ssa_name node)\n{\n  return SSA_NAME_VERSION (node.inner);\n}\n\n/***************************************************************************\n gcc_statement\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (void)\ngcc_statement_mark_in_use (gcc_statement node);\n\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_statement_get_location(gcc_statement node)\n{\n  return gcc_private_make_location (EXPR_LOCATION (node.inner));\n}\n\n/***************************************************************************\n gcc_case_label_expr\n **************************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_case_label_expr)\ngcc_private_make_case_label_expr (tree inner)\n{\n  struct gcc_case_label_expr result;\n  /* FIXME: type-checking */\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_case_label_expr_get_low (gcc_case_label_expr node)\n{\n  return gcc_private_make_tree (CASE_LOW (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree)\ngcc_case_label_expr_get_high (gcc_case_label_expr node)\n{\n  return gcc_private_make_tree (CASE_HIGH (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_label_decl)\ngcc_case_label_expr_get_target (gcc_case_label_expr node)\n{\n  return\n    gcc_tree_as_gcc_label_decl (gcc_private_make_tree\n\t\t\t\t(CASE_LABEL (node.inner)));\n}\n\n/***************************************************************************\n gcc_unary\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_unary_get_location(gcc_unary node)\n{\n  return gcc_private_make_location (EXPR_LOCATION (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API(gcc_tree)\ngcc_unary_get_operand(gcc_unary node)\n{\n  return gcc_private_make_tree (TREE_OPERAND (node.inner, 0));\n}\n\n/***************************************************************************\n gcc_vlexp\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_location)\ngcc_vlexp_get_location(gcc_vlexp node)\n{\n  return gcc_private_make_location (EXPR_LOCATION (node.inner));\n}\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-type.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-common.h\"\n#include \"gcc-type.h\"\n#include \"gcc-constant.h\"\n#include \"gcc-tree.h\"\n#include \"gcc-internal.h\"\n#include \"tree.h\"\n\n/*\n  Types\n*/\n\nGCC_IMPLEMENT_PRIVATE_API (gcc_type)\ngcc_private_make_type (tree inner)\n{\n  struct gcc_type result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PRIVATE_API (gcc_pointer_type)\ngcc_private_make_pointer_type (tree inner)\n{\n  struct gcc_pointer_type result;\n  result.inner = inner;\n  return result;\n}\n\n/***************************************************************************\n gcc_type\n **************************************************************************/\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree) gcc_type_get_name (gcc_type node)\n{\n  return gcc_private_make_tree (TYPE_NAME (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_pointer_type)\ngcc_type_get_pointer (gcc_type node)\n{\n  return gcc_private_make_pointer_type (build_pointer_type (node.inner));\n}\n\n/***************************************************************************\n gcc_array_type\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_type)\ngcc_array_type_get_dereference(gcc_array_type node)\n{\n  return gcc_private_make_type (TREE_TYPE (node.inner));\n}\n\n/***************************************************************************\n gcc_boolean_type\n **************************************************************************/\n/***************************************************************************\n gcc_bound_template_template_parm\n **************************************************************************/\n/***************************************************************************\n gcc_category_implementation_type\n **************************************************************************/\n/***************************************************************************\n gcc_category_interface_type\n **************************************************************************/\n/***************************************************************************\n gcc_class_implementation_type\n **************************************************************************/\n/***************************************************************************\n gcc_class_interface_type\n **************************************************************************/\n/***************************************************************************\n gcc_complex_type\n **************************************************************************/\n/***************************************************************************\n gcc_decl_type_type\n **************************************************************************/\n/***************************************************************************\n gcc_enumeral_type\n **************************************************************************/\n/***************************************************************************\n gcc_fixed_point_type\n **************************************************************************/\n\nGCC_IMPLEMENT_PUBLIC_API (int)\ngcc_fixed_point_type_get_precision (gcc_fixed_point_type node)\n{\n  return TYPE_PRECISION (node.inner);\n}\n\n/***************************************************************************\n gcc_function_type\n **************************************************************************/\n/***************************************************************************\n gcc_integer_type\n **************************************************************************/\n  GCC_IMPLEMENT_PUBLIC_API (gcc_integer_constant)\ngcc_integer_type_get_max_value (gcc_integer_type node)\n{\n  return gcc_private_make_integer_constant (TYPE_MAX_VALUE (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_integer_constant)\ngcc_integer_type_get_min_value (gcc_integer_type node)\n{\n  return gcc_private_make_integer_constant (TYPE_MIN_VALUE (node.inner));\n}\n\nGCC_IMPLEMENT_PUBLIC_API (int)\ngcc_integer_type_get_precision (gcc_integer_type node)\n{\n  return TYPE_PRECISION (node.inner);\n}\n\nGCC_IMPLEMENT_PUBLIC_API(bool)\ngcc_integer_type_is_unsigned(gcc_integer_type node)\n{\n  return TYPE_UNSIGNED (node.inner);\n}\n\n/* gcc_integer_type */\n  GCC_IMPLEMENT_PRIVATE_API (gcc_integer_constant)\ngcc_private_make_integer_constant (tree inner)\n{\n  gcc_integer_constant result;\n  result.inner = INTEGER_CST_CHECK (inner);\n  return result;\n}\n\n\n/***************************************************************************\n gcc_lang_type\n **************************************************************************/\n\n/***************************************************************************\n gcc_method_type\n **************************************************************************/\n/***************************************************************************\n gcc_null_ptr_type\n **************************************************************************/\n/***************************************************************************\n gcc_offset_type\n **************************************************************************/\n/***************************************************************************\n gcc_pointer_type\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_type)\ngcc_pointer_type_get_dereference(gcc_pointer_type node)\n{\n  return gcc_private_make_type (TREE_TYPE (node.inner));\n}\n\n/***************************************************************************\n gcc_protocol_interface_type\n **************************************************************************/\n/***************************************************************************\n gcc_qual_union_type\n **************************************************************************/\n/***************************************************************************\n gcc_real_type\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API (int)\ngcc_real_type_get_precision (gcc_real_type node)\n{\n  return TYPE_PRECISION (node.inner);\n}\n\n/***************************************************************************\n gcc_record_type\n **************************************************************************/\n/***************************************************************************\n gcc_reference_type\n **************************************************************************/\n/***************************************************************************\n gcc_template_template_parm\n **************************************************************************/\n/***************************************************************************\n gcc_template_type_parm\n **************************************************************************/\n/***************************************************************************\n gcc_type_argument_pack\n **************************************************************************/\n/***************************************************************************\n gcc_type_pack_expansion\n **************************************************************************/\n/***************************************************************************\n gcc_typename_type\n **************************************************************************/\n/***************************************************************************\n gcc_typeof_type\n **************************************************************************/\n/***************************************************************************\n gcc_unbound_class_template\n **************************************************************************/\n/***************************************************************************\n gcc_unconstrained_array_type\n **************************************************************************/\n/***************************************************************************\n gcc_union_type\n **************************************************************************/\n/***************************************************************************\n gcc_vector_type\n **************************************************************************/\nGCC_IMPLEMENT_PUBLIC_API(gcc_type)\ngcc_vector_type_get_dereference(gcc_vector_type node)\n{\n  return gcc_private_make_type (TREE_TYPE (node.inner));\n}\n\n/***************************************************************************\n gcc_void_type\n **************************************************************************/\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/gcc-variable.c",
    "content": "/*\n   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"gcc-variable.h\"\n#include \"ggc.h\"\n#include \"tree.h\"\n#include \"cgraph.h\"\t\t/* for varpool_nodes */\n\n/***********************************************************\n   gcc_variable\n************************************************************/\nGCC_IMPLEMENT_PRIVATE_API (struct gcc_variable)\ngcc_private_make_variable (struct varpool_node *inner)\n{\n  struct gcc_variable result;\n  result.inner = inner;\n  return result;\n}\n\nGCC_IMPLEMENT_PUBLIC_API (void) gcc_variable_mark_in_use (gcc_variable var)\n{\n  /* Mark the underlying object (recursing into its fields): */\n\n  /* In GCC 4.8, struct varpool_node became part of union symtab_node_def, and\n     In GCC 4.9, union symtab_node_def became class symtab_node.\n  */\n#if (GCC_VERSION >= 4009)\n  gt_ggc_mx_symtab_node (var.inner);\n#else\n#  if (GCC_VERSION >= 4008)\n  gt_ggc_mx_symtab_node_def (var.inner);\n#  else\n  gt_ggc_mx_varpool_node (var.inner);\n#  endif\n#endif\n}\n\nGCC_IMPLEMENT_PUBLIC_API (gcc_tree) gcc_variable_get_decl (gcc_variable var)\n{\n  /* gcc 4.8 eliminated the\n       tree decl;\n     field of varpool_node in favor of\n       struct symtab_node_base symbol;\n\n     gcc 4.9 made varpool_node be a derived class of symtab_node_base,\n     renaming it to symtab_node.\n  */\n  tree decl;\n\n#if (GCC_VERSION >= 4009)\n  /* Get from base class */\n  decl = var.inner->decl;\n#else\n#  if (GCC_VERSION >= 4008)\n  decl = var.inner->symbol.decl;\n#  else\n  decl = var.inner->decl;\n#  endif\n#endif\n\n  return gcc_private_make_tree (decl);\n}\n\nGCC_IMPLEMENT_PUBLIC_API (bool)\ngcc_for_each_variable (bool (*cb) (gcc_variable var, void *user_data),\n\t\t       void *user_data)\n{\n  struct varpool_node *n;\n\n#ifdef FOR_EACH_VARIABLE /* added in gcc 4.8 */\n  FOR_EACH_VARIABLE(n)\n#else\n  for (n = varpool_nodes; n; n = n->next)\n#endif\n    {\n      if (cb (gcc_private_make_variable (n), user_data))\n\t{\n\t  return true;\n\t}\n    }\n  return false;\n}\n\n\n/*\nLocal variables:\nc-basic-offset: 2\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-c-api/generate-casts-c.py",
    "content": "#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport glob\nimport sys\n\nfrom xmltypes import ApiRegistry, Api\n\nCOPYRIGHT_HEADER = '''\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n'''\n\ndef write_header(out):\n    out.write('/* This file is autogenerated: do not edit */\\n')\n    out.write('/*%s*/\\n' % COPYRIGHT_HEADER)\n    out.write('\\n')\n\ndef write_footer(out):\n    out.write('''\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n''')\n\ndef main(c_filename, xmldir):\n    registry = ApiRegistry()\n    for xmlfile in sorted(glob.glob(xmldir + '*.xml')):\n        api = Api(registry, xmlfile)\n\n    with open(c_filename, 'w') as c_out:\n        write_header(c_out)\n\n        c_out.write('#include \"gcc-common.h\"\\n')\n        c_out.write('#include \"gcc-tree.h\"\\n')\n        c_out.write('#include \"ggc.h\"\\n')\n        c_out.write('#include \"gcc-internal.h\"\\n')\n        c_out.write('#include <assert.h>\\n')\n        c_out.write('#include \"tree.h\"\\n')\n\n        # Ensure that we use the headers, so that the generated\n        # casts pick up on the 'extern \"C\"' and don't get name-mangled:\n        for api in registry.apis:\n            c_out.write('#include \"%s\"\\n' % api.get_header_filename())\n\n        for type_ in registry.iter_types():\n            for subclass in type_.get_subclasses(recursive=True):\n                c_out.write('IMPLEMENT_CAST(%s, %s)\\n'\n                            % (type_.get_c_name(),\n                               subclass.get_c_name()))\n                c_out.write('IMPLEMENT_CAST(%s, %s)\\n'\n                            % (subclass.get_c_name(),\n                               type_.get_c_name()))\n\n        write_footer(c_out)\n\nmain(c_filename=sys.argv[1],\n     xmldir=sys.argv[2])\n"
  },
  {
    "path": "gcc-c-api/gimple.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"gimple\">\n\n  <doc>GIMPLE statements</doc>\n\n  <type name=\"gimple\" varname=\"stmt\" inner=\"gimple_stmt_ptr\">\n    <attribute name=\"location\" kind=\"location\">\n      <doc>Source code location of this statement</doc>\n    </attribute>\n    <attribute name=\"block\" kind=\"tree\">\n      <doc>The lexical block holding this statement, as a gcc_tree</doc>\n    </attribute>\n    <attribute name=\"expr_type\" kind=\"tree\"> <!-- FIXME: as a type instead? -->\n      <doc>The type of the main expression computed by this statement, as a gcc_tree (which might be void_type.</doc>\n    </attribute>\n  </type>\n\n  <type name=\"gimple_asm\" base=\"gimple\">\n    <attribute name=\"string\" kind=\"string\">\n      <doc>The inline assembler as a string</doc>\n    </attribute>\n  </type>\n\n  <type name=\"gimple_assign\" base=\"gimple\">\n    <attribute name=\"lhs\" kind=\"tree\">\n      <doc>The left-hand-side of the assignment</doc>\n    </attribute>\n  </type>\n\n  <type name=\"gimple_call\" base=\"gimple\">\n    <attribute name=\"lhs\" kind=\"tree\">\n      <doc>The left-hand-side of the call</doc>\n    </attribute>\n    <attribute name=\"fn\" kind=\"tree\">\n      <doc>The function being called</doc>\n    </attribute>\n    <attribute name=\"fndecl\" kind=\"tree\">\n      <doc>The declaration of the function being called (if any)</doc>\n    </attribute>\n    <attribute name=\"is_noreturn\" kind=\"bool\">\n      <doc>Has this call been marked as never returning?</doc>\n    </attribute>\n    <iterator name=\"arg\" kind=\"tree\">\n      <doc>The arguments for the call</doc>\n    </iterator>\n  </type>\n\n  <type name=\"gimple_return\" base=\"gimple\">\n    <attribute name=\"retval\" kind=\"tree\">\n      <doc>The return value</doc>\n    </attribute>\n  </type>\n\n  <type name=\"gimple_cond\" base=\"gimple\">\n    <attribute name=\"lhs\" kind=\"tree\"/>\n    <attribute name=\"rhs\" kind=\"tree\"/>\n    <attribute name=\"true_label\" kind=\"tree\"/>\n    <attribute name=\"false_label\" kind=\"tree\"/>\n  </type>\n\n  <type name=\"gimple_phi\" varname=\"phi\" base=\"gimple\">\n    <attribute name=\"lhs\" kind=\"tree\">\n      <doc>The left-hand-side of the call</doc>\n    </attribute>\n\n    <attribute name=\"result\" kind=\"tree\">\n    </attribute>\n\n    <!-- In the python bindings we zip this pair of lists\n         into a list of pairs: -->\n    <iterator name=\"exprs\" kind=\"tree\">\n      <doc>The possible input expressions to the phi node</doc>\n    </iterator>\n    <iterator name=\"edges\" kind=\"cfg_edge\">\n      <doc>The possible edges leading to the phi node</doc>\n    </iterator>\n\n  </type>\n\n  <type name=\"gimple_switch\" base=\"gimple\">\n    <attribute name=\"indexvar\" kind=\"tree\">\n      <doc>The index variable used by the switch statement</doc>\n    </attribute>\n    <iterator name=\"label\" kind=\"case_label_expr\">\n      <doc>The labels of the switch statement.  The initial label in the list is always the default.</doc>\n    </iterator>\n  </type>\n\n  <type name=\"gimple_label\" base=\"gimple\">\n    <attribute name=\"label\" kind=\"label_decl\">\n      <doc>The underlying label_decl for this statement</doc>\n    </attribute>\n  </type>\n  \n</api>"
  },
  {
    "path": "gcc-c-api/location.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"location\">\n\n  <doc>Source code locations</doc>\n\n  <type name=\"location\" varname=\"loc\" inner=\"location_t\">\n    <attribute name=\"filename\" kind=\"string\">\n    </attribute>\n\n    <attribute name=\"line\" kind=\"int\">\n    </attribute>\n\n    <attribute name=\"column\" kind=\"int\">\n    </attribute>\n\n    <attribute name=\"is_unknown\" kind=\"bool\">\n    </attribute>\n\n    <attribute name=\"in_system_header\" kind=\"bool\">\n    </attribute>\n\n    <attribute name=\"caret\" kind=\"location\">\n    </attribute>\n    <attribute name=\"start\" kind=\"location\">\n    </attribute>\n    <attribute name=\"finish\" kind=\"location\">\n    </attribute>\n\n    <function name=\"offset_column\" returntype=\"location\">\n      <parameter name=\"offset\" type=\"int\"/>\n    </function>\n\n  </type>\n\n  <attribute name=\"input_location\" kind=\"location\" access=\"rw\">\n  </attribute>\n\n</api>"
  },
  {
    "path": "gcc-c-api/option.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"option\">\n\n  <doc>Command-line options</doc>\n\n  <type name=\"option\" varname=\"opt\" inner=\"enum opt_code\">\n    <attribute name=\"text\" kind=\"string\">\n      <doc>The text used at the command-line to affect this option e.g. -Werror.</doc>\n    </attribute>\n  </type>\n\n  <iterator name=\"option\" kind=\"option\">\n  </iterator>\n\n</api>"
  },
  {
    "path": "gcc-c-api/rtl.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"rtl\">\n\n  <doc>Register Transfer Language</doc>\n\n  <type name=\"rtl_insn\" varname=\"rtl\" inner=\"struct rtx_def *\">\n  </type>\n  \n</api>"
  },
  {
    "path": "gcc-c-api/tree.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"tree\">\n\n  <doc>Trees</doc>\n\n  <type name=\"tree\" varname=\"node\" inner=\"tree\">\n  </type>\n\n  <type name=\"binary\" base=\"tree\">\n     <attribute name=\"location\" kind=\"location\"/>\n   </type>\n\n  <type name=\"bitwise_and_expr\" base=\"binary\">\n  </type>\n  <type name=\"bitwise_ior_expr\" base=\"binary\">\n  </type>\n  <type name=\"bitwise_xor_expr\" base=\"binary\">\n  </type>\n<!--\n  ..            CeilDivExpr\n  ..            CeilModExpr\n  ..            CompareExpr\n  ..            CompareGExpr\n  ..            CompareLExpr\n  ..            ComplexExpr\n  ..            ExactDivExpr\n  ..            FloorDivExpr\n  ..            FloorModExpr\n  ..            LrotateExpr\n  ..            LshiftExpr\n  ..            MaxExpr\n  ..            MinExpr\n  ..            MinusExpr\n  ..            MinusNomodExpr\n  ..            MultExpr\n  ..            PlusExpr\n  ..            PlusNomodExpr\n  ..            PointerPlusExpr\n  ..            RangeExpr\n  ..            RdivExpr\n  ..            RoundDivExpr\n  ..            RoundModExpr\n  ..            RrotateExpr\n  ..            RshiftExpr\n  ..            TruncDivExpr\n  ..            TruncModExpr\n  ..            UrshiftExpr\n  ..            VecExtractevenExpr\n  ..            VecExtractoddExpr\n  ..            VecInterleavehighExpr\n  ..            VecInterleavelowExpr\n  ..            VecLshiftExpr\n  ..            VecPackFixTruncExpr\n  ..            VecPackSatExpr\n  ..            VecPackTruncExpr\n  ..            VecRshiftExpr\n  ..            WidenMultExpr\n  ..            WidenMultHiExpr\n  ..            WidenMultLoExpr\n  ..            WidenSumExpr\n-->\n  <type name=\"block\" base=\"tree\">\n  </type>\n\n  <type name=\"comparison\" base=\"tree\">\n    <attribute name=\"location\" kind=\"location\"/>\n  </type>\n  <!--\n  ..            EqExpr\n  ..            GeExpr\n  ..            GtExpr\n  ..            LeExpr\n  ..            LtExpr\n  ..            LtgtExpr\n  ..            NeExpr\n  ..            OrderedExpr\n  ..            UneqExpr\n  ..            UngeExpr\n  ..            UngtExpr\n  ..            UnleExpr\n  ..            UnltExpr\n  ..            UnorderedExpr\n  -->\n\n  <type name=\"constructor\" base=\"tree\">\n  </type>\n\n  <!--\n  ..        DefaultArg\n  ..        ErrorMark\n  -->\n\n  <type name=\"expression\" base=\"tree\">\n    <attribute name=\"location\" kind=\"location\"/>\n  </type>\n\n  <type name=\"addr_expr\" base=\"expression\">\n    <attribute name=\"operand\" kind=\"tree\"/>\n  </type>\n\n  <!--\n  ..            AlignofExpr\n  ..            ArrowExpr\n  ..            AssertExpr\n  ..            AtEncodeExpr\n  ..            BindExpr\n  ..            CMaybeConstExpr\n  ..            ClassReferenceExpr\n  ..            CleanupPointExpr\n  ..            CompoundExpr\n  ..            CompoundLiteralExpr\n  ..            CondExpr\n  ..            CtorInitializer\n  ..            DlExpr\n  ..            DotProdExpr\n  ..            DotstarExpr\n  ..            EmptyClassExpr\n  ..            ExcessPrecisionExpr\n  ..            ExprPackExpansion\n  ..            ExprStmt\n  ..            FdescExpr\n  ..            FmaExpr\n  ..            InitExpr\n  ..            MessageSendExpr\n  ..            ModifyExpr\n  ..            ModopExpr\n  ..            MustNotThrowExpr\n  ..            NonDependentExpr\n  ..            NontypeArgumentPack\n  ..            NullExpr\n  ..            NwExpr\n  ..            ObjTypeRef\n  ..            OffsetofExpr\n  ..            PolynomialChrec\n  ..            PostdecrementExpr\n  ..            PostincrementExpr\n  ..            PredecrementExpr\n  ..            PredictExpr\n  ..            PreincrementExpr\n  ..            PropertyRef\n  ..            PseudoDtorExpr\n  ..            RealignLoad\n  ..            SaveExpr\n  ..            ScevKnown\n  ..            ScevNotKnown\n  ..            SizeofExpr\n  ..            StmtExpr\n  ..            TagDefn\n  ..            TargetExpr\n  ..            TemplateIdExpr\n  ..            ThrowExpr\n  ..            TruthAndExpr\n  ..            TruthAndifExpr\n  ..            TruthNotExpr\n  ..            TruthOrExpr\n  ..            TruthOrifExpr\n  ..            TruthXorExpr\n  ..            TypeExpr\n  ..            TypeidExpr\n  ..            VaArgExpr\n  ..            VecCondExpr\n  ..            VecDlExpr\n  ..            VecInitExpr\n  ..            VecNwExpr\n  ..            WidenMultMinusExpr\n  ..            WidenMultPlusExpr\n  ..            WithCleanupExpr\n  ..            WithSizeExpr\n  ..        IdentifierNode\n  ..        LambdaExpr\n  ..        OmpClause\n  ..        OptimizationNode\n  ..        Overload\n  ..        PlaceholderExpr\n-->\n\n  <type name=\"reference\" base=\"tree\">\n    <attribute name=\"location\" kind=\"location\"/>\n  </type>\n\n<!-- Subclasses of \"reference\":\n  ..            ArrayRangeRef\n-->\n\n  <type name=\"array_ref\" base=\"reference\">\n    <attribute name=\"array\" kind=\"tree\"/>\n    <attribute name=\"index\" kind=\"tree\"/>\n  </type>\n  <!--\n  ..            AttrAddrExpr\n  ..            BitFieldRef\n  -->\n  <type name=\"component_ref\" base=\"reference\">\n    <attribute name=\"target\" kind=\"tree\"/>\n    <attribute name=\"field\" kind=\"tree\"/>\n  </type>\n  <!--\n  ..            ImagpartExpr\n  ..            IndirectRef\n  -->\n  <type name=\"mem_ref\" base=\"reference\">\n    <attribute name=\"operand\" kind=\"tree\"/>\n  </type>\n  <!--\n  ..            MemberRef\n  ..            OffsetRef\n  ..            RealpartExpr\n  ..            ScopeRef\n  ..            TargetMemRef\n  ..            UnconstrainedArrayRef\n  ..            ViewConvertExpr\n-->\n\n  <type name=\"ssa_name\" base=\"tree\">\n    <attribute name=\"var\" kind=\"tree\"/>\n    <attribute name=\"def_stmt\" kind=\"gimple\"/>\n    <attribute name=\"version\" kind=\"int\"/>\n  </type>\n\n  <type name=\"statement\" base=\"tree\">\n    <attribute name=\"location\" kind=\"location\"/>\n  </type>\n<!--\n  ..        Statement\n  ..            AsmExpr\n  ..            BreakStmt\n-->\n\n  <type name=\"case_label_expr\" base=\"statement\">\n    <attribute name=\"low\" kind=\"tree\"/>\n    <attribute name=\"high\" kind=\"tree\"/>\n    <attribute name=\"target\" kind=\"label_decl\"/>\n  </type>\n\n<!--\n  ..            CatchExpr\n  ..            CleanupStmt\n  ..            ContinueStmt\n  ..            DeclExpr\n  ..            DoStmt\n  ..            EhFilterExpr\n  ..            EhSpecBlock\n  ..            ExitExpr\n  ..            ExitStmt\n  ..            ForStmt\n  ..            GotoExpr\n  ..            Handler\n  ..            IfStmt\n  ..            LabelExpr\n  ..            LoopExpr\n  ..            LoopStmt\n  ..            OmpAtomic\n  ..            OmpCritical\n  ..            OmpFor\n  ..            OmpMaster\n  ..            OmpOrdered\n  ..            OmpParallel\n  ..            OmpSection\n  ..            OmpSections\n  ..            OmpSingle\n  ..            OmpTask\n  ..            RangeForStmt\n  ..            ReturnExpr\n  ..            StmtStmt\n  ..            SwitchExpr\n  ..            SwitchStmt\n  ..            TryBlock\n  ..            TryCatchExpr\n  ..            TryFinally\n  ..            UsingDirective\n  ..            WhileStmt\n  ..        StatementList\n  ..        StaticAssert\n  ..        TargetOptionNode\n  ..        TemplateInfo\n  ..        TemplateParmIndex\n  ..        TraitExpr\n  ..        TreeBinfo\n  ..        TreeList\n  ..        TreeVec\n-->\n\n  <type name=\"unary\" base=\"tree\">\n    <attribute name=\"location\" kind=\"location\"/>\n    <attribute name=\"operand\" kind=\"tree\"/>\n  </type>\n  <!--\n  ..            AbsExpr\n  ..            AddrSpaceConvertExpr\n  ..            BitNotExpr\n  ..            CastExpr\n  ..            ConjExpr\n  ..            ConstCastExpr\n  ..            ConvertExpr\n  ..            DynamicCastExpr\n  ..            FixTruncExpr\n  ..            FixedConvertExpr\n  ..            FloatExpr\n  ..            NegateExpr\n  ..            NoexceptExpr\n  ..            NonLvalueExpr\n  ..            NopExpr\n  ..            ParenExpr\n  ..            ReducMaxExpr\n  ..            ReducMinExpr\n  ..            ReducPlusExpr\n  ..            ReinterpretCastExpr\n  ..            StaticCastExpr\n  ..            UnaryPlusExpr\n  ..            VecUnpackFloatHiExpr\n  ..            VecUnpackFloatLoExpr\n  ..            VecUnpackHiExpr\n  ..            VecUnpackLoExpr\n-->\n  <type name=\"vlexp\" base=\"tree\">\n    <attribute name=\"location\" kind=\"location\"/>\n  </type>\n<!--\n  ..            AggrInitExpr\n  ..            CallExpr\n-->\n  \n</api>"
  },
  {
    "path": "gcc-c-api/type.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"type\">\n\n  <doc>Types</doc>\n\n  <type name=\"type\" base=\"tree\">\n    <attribute name=\"name\" kind=\"tree\"/>\n    <attribute name=\"pointer\" kind=\"pointer_type\"/>\n  </type>\n\n  <type name=\"array_type\" base=\"type\">\n    <attribute name=\"dereference\" kind=\"type\">\n      <doc>The type that this type points to</doc>\n    </attribute>\n  </type>\n\n  <type name=\"boolean_type\" base=\"type\">\n  </type>\n\n  <type name=\"bound_template_template_parm\" base=\"type\">\n  </type>\n\n  <type name=\"category_implementation_type\" base=\"type\">\n  </type>\n\n  <type name=\"category_interface_type\" base=\"type\">\n  </type>\n\n  <type name=\"class_implementation_type\" base=\"type\">\n  </type>\n\n  <type name=\"class_interface_type\" base=\"type\">\n  </type>\n\n  <type name=\"complex_type\" base=\"type\">\n  </type>\n\n  <type name=\"decl_type_type\" base=\"type\">\n  </type>\n\n  <type name=\"enumeral_type\" base=\"type\">\n  </type>\n\n  <type name=\"fixed_point_type\" base=\"type\">\n    <attribute name=\"precision\" kind=\"int\">\n      <doc>The precision of this type in bits (e.g. 32)</doc>\n    </attribute>\n  </type>\n\n  <type name=\"function_type\" base=\"type\">\n  </type>\n\n  <type name=\"integer_type\" base=\"type\">\n    <attribute name=\"max_value\" kind=\"integer_constant\"/>\n    <attribute name=\"min_value\" kind=\"integer_constant\"/>\n    <attribute name=\"precision\" kind=\"int\">\n      <doc>The precision of this type in bits (e.g. 32)</doc>\n    </attribute>\n    <attribute name=\"is_unsigned\" kind=\"bool\"/>\n\n  </type>\n\n  <type name=\"lang_type\" base=\"type\">\n  </type>\n\n  <type name=\"method_type\" base=\"type\">\n  </type>\n\n  <type name=\"null_ptr_type\" base=\"type\">\n  </type>\n\n  <type name=\"offset_type\" base=\"type\">\n  </type>\n\n  <type name=\"pointer_type\" base=\"type\">\n    <attribute name=\"dereference\" kind=\"type\">\n      <doc>The type that this type points to</doc>\n    </attribute>\n  </type>\n\n  <type name=\"protocol_interface_type\" base=\"type\">\n  </type>\n\n  <type name=\"qual_union_type\" base=\"type\">\n  </type>\n\n  <type name=\"real_type\" base=\"type\">\n    <attribute name=\"precision\" kind=\"int\">\n      <doc>The precision of this type in bits (e.g. 32)</doc>\n    </attribute>\n  </type>\n\n  <type name=\"record_type\" base=\"type\">\n  </type>\n\n  <type name=\"reference_type\" base=\"type\">\n  </type>\n\n  <type name=\"template_template_parm\" base=\"type\">\n  </type>\n\n  <type name=\"template_type_parm\" base=\"type\">\n  </type>\n\n  <type name=\"type_argument_pack\" base=\"type\">\n  </type>\n\n  <type name=\"type_pack_expansion\" base=\"type\">\n  </type>\n\n  <type name=\"typename_type\" base=\"type\">\n  </type>\n\n  <type name=\"typeof_type\" base=\"type\">\n  </type>\n\n  <type name=\"unbound_class_template\" base=\"type\">\n  </type>\n\n  <type name=\"unconstrained_array_type\" base=\"type\">\n  </type>\n\n  <type name=\"union_type\" base=\"type\">\n  </type>\n\n  <type name=\"vector_type\" base=\"type\">\n    <attribute name=\"dereference\" kind=\"type\">\n      <doc>The type that this type points to</doc>\n    </attribute>\n  </type>\n\n  <type name=\"void_type\" base=\"type\">\n  </type>\n\n</api>"
  },
  {
    "path": "gcc-c-api/variable.xml",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!--\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n-->\n<api name=\"variable\">\n\n  <doc>Variables</doc>\n\n  <type name=\"variable\" varname=\"var\" inner=\"struct varpool_node *\">\n    <attribute name=\"decl\" kind=\"tree\"> <!-- FIXME: can we make the kind be more specific? -->\n      <doc>the declaration of this variable</doc>\n    </attribute>\n  </type>\n\n  <iterator name=\"variable\" kind=\"variable\">\n  </iterator>\n</api>"
  },
  {
    "path": "gcc-c-api/xml-to-h.py",
    "content": "import glob\nimport sys\nfrom xmltypes import ApiRegistry, Api\n\nCOPYRIGHT_HEADER = '''\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n'''\n\ndef write_header(out):\n    out.write('/* This file is autogenerated: do not edit */\\n')\n    out.write('/*%s*/\\n' % COPYRIGHT_HEADER)\n    out.write('\\n')\n\ndef write_footer(out):\n    out.write('''\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n''')\n\nclass SourceWriter:\n    def __init__(self, out):\n        self.out = out\n        self._indent = 0\n\n    def indent(self):\n        self._indent += 1\n\n    def outdent(self):\n        self._indent -= 1\n\n    def writeln(self, line=None):\n        if line:\n            self.out.write('%s%s\\n' % ('  ' * self._indent, line))\n        else:\n            self.out.write('\\n')\n\n    def write_doc_comment(self, doc):\n        self.write_comment(doc.as_text())\n\n    def write_comment(self, doc):\n        self.writeln('/*')\n        self.indent()\n        for line in doc.splitlines():\n            self.writeln(line)\n        self.outdent()\n        self.writeln('*/')\n\n    def write_begin_extern_c(self):\n        self.writeln('#ifdef __cplusplus')\n        self.writeln('extern \"C\" {')\n        self.writeln('#endif')\n\n    def write_end_extern_c(self):\n        self.writeln('#ifdef __cplusplus')\n        self.writeln('}')\n        self.writeln('#endif')\n\ndef write_api(api, out):\n    writer = SourceWriter(out)\n    write_header(out)\n\n    if api.get_xml_name() == 'rtl':\n        out.write('''\n/* FIXME: rationalize these headers */\n#include \"gcc-common.h\"\n''')\n    else:\n        out.write('#include \"gcc-common.h\"\\n')\n    writer.writeln()\n\n    writer.write_begin_extern_c()\n\n    doc = api.get_doc()\n    if doc:\n        writer.write_doc_comment(doc)\n        writer.writeln()\n\n    for type_ in api.iter_types():\n        writer.writeln('/* %s */\\n' % type_.get_c_name())\n\n        doc = type_.get_doc()\n        if doc:\n            writer.write_doc_comment(doc)\n\n        # mark_in_use:\n        writer.writeln('GCC_PUBLIC_API(void)')\n        writer.writeln('%s_mark_in_use(%s %s);'\n                       % (type_.get_c_prefix(),\n                          type_.get_c_name(),\n                          type_.get_varname()))\n        writer.writeln()\n\n        # add getters for attributes:\n        for attr in type_.iter_attrs():\n            doc = attr.get_doc()\n            if doc:\n                writer.write_doc_comment(doc)\n            if attr.get_c_name().startswith('is_'):\n                # \"gcc_foo_is_some_boolean\", rather than\n                # \"gcc_foo_get_is_some_boolean\":\n                writer.writeln('GCC_PUBLIC_API(%s)' % attr.get_c_type())\n                writer.writeln('%s_%s(%s %s);'\n                               % (type_.get_c_prefix(),\n                                  attr.get_c_name(),\n                                  type_.get_c_name(),\n                                  type_.get_varname()))\n            else:\n                writer.writeln('GCC_PUBLIC_API(%s)' % attr.get_c_type())\n                writer.writeln('%s_get_%s(%s %s);'\n                               % (type_.get_c_prefix(),\n                                  attr.get_c_name(),\n                                  type_.get_c_name(),\n                                  type_.get_varname()))\n            writer.writeln()\n\n        # add iterators\n        for iter_ in type_.iter_iters():\n            itertype = iter_.get_type()\n            writer.write_comment('Iterator; terminates if the callback returns truth\\n'\n                                 '(for linear search)')\n            writer.writeln('GCC_PUBLIC_API(bool)')\n            writer.writeln('%s_for_each_%s(%s %s,'\n                           % (type_.get_c_prefix(),\n                              iter_.get_c_name(),\n                              type_.get_c_name(),\n                              type_.get_varname()))\n            writer.writeln('    bool (*cb)(%s %s, void *user_data),'\n                           % (itertype.get_c_name(),\n                              itertype.get_varname()))\n            writer.writeln('    void *user_data);')\n            writer.writeln()\n\n        # add functions:\n        for fun in type_.iter_functions():\n            doc = fun.get_doc()\n            if doc:\n                writer.write_doc_comment(doc)\n            writer.writeln('GCC_PUBLIC_API(%s)' % fun.get_c_return_type())\n            paramstrs = ['%s %s' % (type_.get_c_name(),\n                                    type_.get_varname())]\n            for param in fun.iter_params():\n                paramstrs.append('%s %s' % (param.get_c_type(),\n                                            param.get_xml_name()))\n            writer.writeln('%s_%s(%s);'\n                           % (type_.get_c_prefix(),\n                              fun.get_c_name(),\n                              ', '.join(paramstrs)))\n            writer.writeln()\n\n        # add upcasts\n        for base in type_.get_bases():\n            writer.writeln('GCC_PUBLIC_API(%s)'\n                           % base.get_c_name())\n            writer.writeln('%s_as_%s(%s %s);'\n                           % (type_.get_c_prefix(),\n                              base.get_c_name(),\n                              type_.get_c_name(),\n                              type_.get_varname()))\n            writer.writeln()\n\n        # add downcasts\n        for subclass in type_.get_subclasses(recursive=True):\n            writer.writeln('GCC_PUBLIC_API(%s)'\n                           % subclass.get_c_name())\n            writer.writeln('%s_as_%s(%s %s);'\n                           % (type_.get_c_prefix(),\n                              subclass.get_c_name(),\n                              type_.get_c_name(),\n                              type_.get_varname()))\n            writer.writeln()\n\n    # add getters for attributes:\n    for attr in api.iter_attrs():\n        doc = attr.get_doc()\n        if doc:\n            writer.write_doc_comment(doc, out)\n        if attr.is_readable():\n            writer.writeln('GCC_PUBLIC_API(%s)' % attr.get_c_type())\n            writer.writeln('gcc_get_%s(void);' % attr.get_c_name())\n        if attr.is_writable():\n            writer.writeln('GCC_PUBLIC_API(void)')\n            writer.writeln('gcc_set_%s(%s %s);'\n                           % (attr.get_c_name(),\n                              attr.get_c_type(),\n                              attr.get_varname()))\n        writer.writeln()\n\n    # add iterators\n    for iter_ in api.iter_iters():\n        itertype = iter_.get_type()\n        writer.write_comment('  Iterator; terminates if the callback returns truth\\n'\n                             '  (for linear search).')\n        writer.writeln('GCC_PUBLIC_API(bool)')\n        writer.writeln('gcc_for_each_%s(bool (*cb)(%s %s, void *user_data),'\n                  % (iter_.get_c_name(),\n                     itertype.get_c_name(),\n                     itertype.get_varname()))\n        writer.writeln('    void *user_data);')\n        writer.writeln()\n\n    # add functions\n    for fun in api.iter_functions():\n        writer.writeln('GCC_PUBLIC_API(%s)' % fun.get_c_return_type())\n        paramstrs = []\n        for param in fun.iter_params():\n            paramstrs.append('%s %s' % (param.get_c_type(),\n                                        param.get_xml_name()))\n        writer.writeln('gcc_%s(%s);'\n                       % (fun.get_c_name(),\n                          ', '.join(paramstrs)))\n\n    writer.write_end_extern_c()\n    write_footer(out)\n\ndef write_public_types(registry, out):\n    writer = SourceWriter(out)\n    write_header(out)\n    out.write('#ifndef INCLUDED__GCC_PUBLIC_TYPES_H\\n')\n    out.write('#define INCLUDED__GCC_PUBLIC_TYPES_H\\n')\n    out.write('\\n')\n    out.write('#include \"gcc-semiprivate-types.h\"\\n')\n    out.write('\\n')\n    writer.write_begin_extern_c()\n    for api in registry.apis:\n        out.write('/* Opaque types: %s */\\n' % api.get_doc().as_text())\n        for type_ in api.iter_types():\n            out.write('typedef struct %s %s;\\n'\n                      % (type_.get_c_name(), type_.get_c_name()))\n        out.write('\\n')\n\n    writer.write_end_extern_c()\n    out.write('#endif /* INCLUDED__GCC_PUBLIC_TYPES_H */\\n')\n    write_footer(out)\n\ndef write_semiprivate_types(registry, out):\n    writer = SourceWriter(out)\n    write_header(out)\n    out.write('#ifndef INCLUDED__GCC_SEMIPRIVATE_TYPES_H\\n')\n    out.write('#define INCLUDED__GCC_SEMIPRIVATE_TYPES_H\\n')\n\n    out.write('\\n')\n    out.write('#include \"input.h\" /* for location_t */\\n')\n    out.write('#include \"options.h\" /* for enum opt_code */\\n')\n    out.write('\\n')\n    writer.write_begin_extern_c()\n    out.write('/*\\n')\n    out.write('  These \"interface types\" should be treated like pointers, only that\\n')\n    out.write('  users are required to collaborate with the garbage-collector.\\n')\n    out.write('\\n')\n    out.write('  The internal details are exposed here so that the debugger is able to\\n')\n    out.write('  identify the real types.  Plugin developers should *not* rely on the\\n')\n    out.write('  internal implementation details.\\n')\n    out.write('\\n')\n    out.write('  By being structs, the compiler will be able to complain if plugin code\\n')\n    out.write('  directly pokes at a pointer.\\n')\n    out.write('*/\\n')\n\n    for api in registry.apis:\n        out.write('/* Semiprivate types: %s */\\n' % api.get_doc().as_text())\n        for type_ in api.iter_types():\n            out.write('struct %s {\\n' % type_.get_c_name())\n            out.write('  %s inner;\\n' % type_.get_inner_type())\n            out.write('};\\n')\n            out.write('\\n')\n            out.write('GCC_PRIVATE_API(struct %s)\\n' % type_.get_c_name())\n            out.write('gcc_private_make_%s(%s inner);\\n'\n                      % (type_.get_xml_name(),\n                         type_.get_inner_type()))\n            out.write('\\n')\n\n    writer.write_end_extern_c()\n    out.write('#endif /* INCLUDED__GCC_SEMIPRIVATE_TYPES_H */\\n')\n    write_footer(out)\n\nregistry = ApiRegistry()\nxmldir=sys.argv[1]\nfor xmlfile in sorted(glob.glob(xmldir + '*.xml')):\n    api = Api(registry, xmlfile)\nfor api in registry.apis:\n    with open(api.get_header_filename(), 'w') as f:\n        # write(api, sys.stdout)\n        write_api(api, f)\n    with open('gcc-public-types.h', 'w') as f:\n        write_public_types(registry, f)\n    with open('gcc-semiprivate-types.h', 'w') as f:\n        write_semiprivate_types(registry, f)\n"
  },
  {
    "path": "gcc-c-api/xmltypes.py",
    "content": "#   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012, 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n#\n# Autogenerate a header file from a .h description\nimport sys\nimport unittest\nimport xml.etree.ElementTree as ET\n\ndef get_c_type(xml_kind):\n    if xml_kind in ('int', 'bool'):\n        return xml_kind\n    if xml_kind == 'string':\n        return 'const char*'\n    if xml_kind == 'void':\n        return 'void'\n    return 'gcc_%s' % xml_kind\n\nclass TypeNotFound(Exception):\n    def __init__(self, xmlname):\n        self.xmlname = xmlname\n    def __str__(self):\n        return 'type named %r not found' % self.xmlname\n\nclass ApiRegistry:\n    def __init__(self):\n        self.apis = []\n\n    def load(self, filename):\n        api = Api(self, filename)\n\n    def iter_types(self):\n        for api in self.apis:\n            for type_ in api.iter_types():\n                yield type_\n\n    def lookup_type(self, xmlname):\n        for api in self.apis:\n            type_ = api.lookup_type(xmlname)\n            if type_:\n                return type_\n        raise TypeNotFound(xmlname)\n\nclass XmlWrapper:\n    def __init__(self, api, node):\n        self.api = api\n        self.node = node\n\n    def __eq__(self, other):\n        if not isinstance(other, XmlWrapper):\n            return False\n        return self.node == other.node\n\nclass HasDocsMixin:\n    def get_doc(self):\n        xml_doc = self.node.find('doc')\n        if xml_doc is not None:\n            return Doc(self.api, xml_doc)\n        else:\n            return None\n\nclass Type(XmlWrapper, HasDocsMixin):\n    def get_xml_name(self):\n        return self.node.get('name')\n\n    def get_c_name(self):\n        return 'gcc_%s' % self.get_xml_name()\n\n    def get_c_prefix(self):\n        return 'gcc_%s' % self.get_xml_name()\n\n    def get_base(self):\n        basename = self.node.get('base')\n        if basename:\n            return self.api.registry.lookup_type(basename)\n\n    def get_bases(self):\n        basename = self.node.get('base')\n        if basename:\n            base = self.api.registry.lookup_type(basename)\n            yield base\n            for base in base.get_bases():\n                yield base\n\n    def get_subclasses(self, recursive=False):\n        # brute force linear search for now:\n        for type_ in self.api.registry.iter_types():\n            base = type_.get_base()\n            if base == self:\n                yield type_\n                if recursive:\n                    for type_ in type_.get_subclasses(recursive):\n                        yield type_\n\n    def get_varname(self):\n        varname = self.node.get('varname')\n        if varname:\n            return varname\n        base = self.get_base()\n        return base.get_varname()\n\n    def get_inner_type(self):\n        inner = self.node.get('inner')\n        if inner:\n            return inner\n        base = self.get_base()\n        if base:\n            return base.get_inner_type()\n        else:\n            class NoInnerType(Exception):\n                def __init__(self, type_):\n                    self.type_ = type_\n                def __str__(self):\n                    return ('%s has no inheritable \"inner\" attribute'\n                            % self.type_.get_xml_name())\n            raise NoInnerType(self)\n\n    def iter_attrs(self):\n        for node in self.node.iter('attribute'):\n            yield Attribute(self.api, node)\n\n    def iter_iters(self):\n        for node in self.node.iter('iterator'):\n            yield Iterator(self.api, node)\n\n    def iter_functions(self):\n        for node in self.node.findall('function'):\n            yield Function(self, node)\n\nclass Attribute(XmlWrapper, HasDocsMixin):\n    def get_xml_name(self):\n        return self.node.get('name')\n\n    def get_c_name(self):\n        return self.get_xml_name()\n\n    def get_xml_kind(self):\n        return self.node.get('kind')\n\n    def get_c_type(self):\n        xml_kind = self.get_xml_kind()\n        return get_c_type(xml_kind)\n\n    def get_varname(self):\n        xml_kind = self.get_xml_kind()\n        if xml_kind == 'int':\n            return 'i'\n        if xml_kind == 'bool':\n            return 'flag'\n        if xml_kind == 'string':\n            return 'str'\n        return self.api.registry.lookup_type(xml_kind).get_varname()\n\n    def get_access(self):\n        access = self.node.get('access')\n        if access:\n            return access\n        else:\n            return 'r' # default to readonly\n\n    def is_writable(self):\n        access = self.get_access()\n        return 'w' in access\n\n    def is_readable(self):\n        access = self.get_access()\n        return 'r' in access\n\nclass Iterator(XmlWrapper, HasDocsMixin):\n    def get_xml_name(self):\n        return self.node.get('name')\n\n    def get_c_name(self):\n        return self.get_xml_name()\n\n    def get_type(self):\n        xmlkind = self.node.get('kind')\n        return self.api.registry.lookup_type(xmlkind)\n\nclass Function(XmlWrapper, HasDocsMixin):\n    def get_xml_name(self):\n        return self.node.get('name')\n\n    def get_c_name(self):\n        return self.get_xml_name()\n\n    def get_return_type(self):\n        xmlkind = self.node.get('returntype')\n        return xmlkind\n\n    def get_c_return_type(self):\n        xml_kind = self.get_return_type()\n        return get_c_type(xml_kind);\n\n    def iter_params(self):\n        for node in self.node.iter('parameter'):\n            yield Parameter(self.api, node)\n\nclass Parameter(XmlWrapper, HasDocsMixin):\n    def get_xml_name(self):\n        return self.node.get('name')\n\n    def get_xml_type(self):\n        return self.node.get('type')\n\n    def get_c_type(self):\n        xmltype = self.get_xml_type()\n        return get_c_type(xmltype)\n\nclass Doc(XmlWrapper):\n    def as_text(self):\n        return self.node.text\n    \nclass Api:\n    def __init__(self, registry, filename):\n        self.registry = registry\n        self.filename = filename\n        tree = ET.parse(filename)\n        self.registry.apis.append(self)\n        self.api = tree.getroot()\n\n    def get_xml_name(self):\n        return self.api.get('name')\n\n    def get_header_filename(self):\n        return 'gcc-%s.h' % self.get_xml_name()\n\n    def get_doc(self):\n        xml_doc = self.api.find('doc')\n        if xml_doc is not None:\n            return Doc(self, xml_doc)\n        else:\n            return None\n\n    def iter_types(self):\n        for node in self.api.iter('type'):\n            yield Type(self, node)\n\n    def lookup_type(self, xmlname):\n        for type_ in self.iter_types():\n            if xmlname == type_.get_xml_name():\n                return type_\n\n    def iter_attrs(self):\n        for node in self.api.findall('attribute'):\n            yield Attribute(self, node)\n\n    def iter_iters(self):\n        for node in self.api.findall('iterator'):\n            yield Iterator(self, node)\n\n    def iter_functions(self):\n        for node in self.api.findall('function'):\n            yield Function(self, node)\n\nclass Tests(unittest.TestCase):\n    def test_loading_all(self):\n        r = ApiRegistry()\n        for filename in ('cfg.xml', 'gimple.xml', 'rtl.xml'):\n            gimpleapi = r.load(filename)\n\n    def test_types(self):\n        r = ApiRegistry()\n        gimpleapi = r.load('gimple.xml')\n        gimple = r.lookup_type('gimple')\n        self.assertEqual(gimple.get_xml_name(), 'gimple')\n        self.assertEqual(gimple.get_c_name(), 'gcc_gimple')\n        self.assertEqual(gimple.get_varname(), 'stmt')\n\n    def test_subclassing(self):\n        r = ApiRegistry()\n        gimpleapi = r.load('gimple.xml')\n        gimple = r.lookup_type('gimple')\n        gimple_phi = r.lookup_type('gimple_phi')\n        self.assertEqual(gimple_phi.get_xml_name(), 'gimple_phi')\n        self.assertEqual(gimple.get_base(), None)\n        self.assertEqual(gimple_phi.get_base(), gimple)\n        self.assertIn(gimple_phi, gimple.get_subclasses()) # python 2.7\n\nif __name__ == '__main__':\n    unittest.main()\n"
  },
  {
    "path": "gcc-python-attribute.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n\n#include \"tree.h\"\n#include \"diagnostic.h\"\n#include \"plugin.h\"\n\n#if (GCC_VERSION >= 4009)\n/* GCC 4.9 moved debug_tree here: */\n#include \"print-tree.h\"\n#endif\n\n/*\n  Attribute handling\n*/\n/* Dictionary mapping string attribute names to callables */\nstatic PyObject *attribute_dict;\n\n/*\n  Helper function when a custom attribute is encountered, for generating\n  the arguments to the Python callback.\n\n  The args to the function call will be the node, plus the args of the\n  attribute:\n    (node, arg0, arg1, ...)\n*/\nPyObject *\nmake_args_for_attribute_callback(tree node, tree args)\n{\n    PyObject *list_args = NULL;\n    PyObject *py_args = NULL;\n    PyObject *py_node = NULL;\n    Py_ssize_t i;\n\n    /* Walk \"args\" (a tree_list), converting to a python list of wrappers */\n    list_args = PyGcc_TreeMakeListFromTreeList(args);\n    if (!list_args) {\n        goto error;\n    }\n\n    py_args = PyTuple_New(1 + PyList_Size(list_args));\n    if (!py_args) {\n        goto error;\n    }\n\n    py_node = PyGccTree_New(gcc_private_make_tree(node));\n    if (!py_node) {\n        goto error;\n    }\n    PyTuple_SET_ITEM(py_args, 0, py_node);\n\n    for (i = 0; i < PyList_Size(list_args); i++) {\n        PyObject *arg = PyList_GetItem(list_args, i);\n        Py_INCREF(arg);\n        PyTuple_SET_ITEM(py_args, i + 1, arg);\n    }\n    Py_DECREF(list_args);\n\n    return py_args;\n\n error:\n    Py_XDECREF(list_args);\n    Py_XDECREF(py_args);\n    Py_XDECREF(py_node);\n    return NULL;\n}\n\nstatic tree\nhandle_python_attribute(tree *node, tree name, tree args,\n                        int flags, bool *no_add_attrs)\n{\n    PyObject *callable;\n\n    /* Debug code: */\n    if (0) {\n        printf(\"handle_python_attribute called\\n\");\n        fprintf(stderr, \"node: \");\n        debug_tree(*node); /* the site of the attribute e.g. a var_decl */\n\n        fprintf(stderr, \"name: \");\n        debug_tree(name); /* an identifier_node e.g. \"custom_attribute_without_args\" */\n\n        fprintf(stderr, \"args: \");\n        debug_tree(args);  /* if present, a tree_list, e.g. of constants */\n        fprintf(stderr, \"flags: %i\\n\", flags);\n        fprintf(stderr, \"and here!\\n\");\n    }\n\n    /*\n      How do we get to the attribute?\n\n      This code:\n        const struct attribute_spec *spec = lookup_attribute_spec (name);\n      suggests that attributes must have unique names, so keep a dict mapping\n      strings to callables\n    */\n    assert(IDENTIFIER_NODE == TREE_CODE(name));\n    callable = PyDict_GetItemString(attribute_dict, IDENTIFIER_POINTER(name));\n    assert(callable);\n\n    {\n        PyGILState_STATE gstate;\n        PyObject *py_args = NULL;\n        PyObject *result = NULL;\n\n        gstate = PyGILState_Ensure();\n\n        /*\n           The args to the function call will be the node, plus the args of the\n           attribute:\n        */\n        py_args = make_args_for_attribute_callback(*node, args);\n        if (!py_args) {\n            goto cleanup;\n        }\n        result = PyObject_Call(callable, py_args, NULL);\n        if (!result) {\n            /* Treat an unhandled Python error as a compilation error: */\n            error(\"Unhandled Python exception raised within %s attribute handler\",\n                  IDENTIFIER_POINTER(name));\n            PyErr_PrintEx(1);\n        }\n\n        /* (the result is ignored) */\n\n    cleanup:\n        Py_XDECREF(py_args);\n        Py_XDECREF(result);\n\n        PyGILState_Release(gstate);\n    }\n\n    return NULL; // FIXME\n}\n\nPyObject*\nPyGcc_RegisterAttribute(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    const char *name;\n    int min_length;\n    int max_length;\n    int decl_required;\n    int type_required;\n    int function_type_required;\n    PyObject *callable;\n    struct attribute_spec *attr;\n\n    const char *keywords[] = {\"name\",\n                              \"min_length\",\n                              \"max_length\",\n                              \"decl_required\",\n                              \"type_required\",\n                              \"function_type_required\",\n                              \"callable\",\n                              NULL};\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"siiiiiO:register_attribute\", (char**)keywords,\n                                     &name,\n                                     &min_length,\n                                     &max_length,\n                                     &decl_required,\n                                     &type_required,\n                                     &function_type_required,\n                                     &callable)) {\n        return NULL;\n    }\n\n    /*\n      \"struct attribute_spec\" is declared in gcc/tree.h\n\n      register_attribute() is called by GCC for various attrs stored in\n      tables of global data e.g.:\n         const struct attribute_spec lto_attribute_table[]\n\n      Hence we must malloc the data, so that it persists for the rest of the\n      lifetime of the process\n\n      We get a \"handler\" callback, it gets passed the name of the attribute,\n      so maybe we can map names to callables.\n    */\n    attr = PyMem_New(struct attribute_spec, 1);\n    if (!attr) {\n        return PyErr_NoMemory();\n    }\n\n    /* Clear it first, for safety: */\n    memset(attr, 0, sizeof(struct attribute_spec));\n\n    /*\n       Populate \"attr\"\n\n       Annoyingly, all of the fields are marked as \"const\" within\n       struct attribute_spec, so we have to cast away the constness, leading\n       to the following deeply ugly code:\n    */\n    *(char**)&attr->name = PyGcc_strdup(name);\n    if (!attr->name) {\n        PyMem_Free(attr);\n        return PyErr_NoMemory();\n    }\n    *(int*)&attr->min_length = min_length;\n    *(int*)&attr->max_length = max_length;\n    *(bool*)&attr->decl_required = decl_required;\n    *(bool*)&attr->type_required = type_required;\n    *(bool*)&attr->function_type_required = function_type_required;\n    *(tree (**) (tree *node, tree name, tree args, int flags, bool *no_add_attrs))&attr->handler = handle_python_attribute;\n\n    /*\n       Associate the user-supplied callable with the given name, so that\n       handle_python_attribute knows which one to call:\n    */\n    if (!attribute_dict) {\n        attribute_dict = PyDict_New();\n        if (!attribute_dict) {\n            PyMem_Free((char*)attr->name);\n            PyMem_Free(attr);\n            return NULL;\n        }\n    }\n    assert(attribute_dict);\n\n    if (-1 == PyDict_SetItemString(attribute_dict, name, callable)) {\n        PyMem_Free((char*)attr->name);\n        PyMem_Free(attr);\n        return NULL;\n    }\n\n    /*\n       OK, call into GCC to register the attribute.\n\n       (register_attribute doesn't have a return value; failures appear\n       to be fatal)\n    */\n    register_attribute (attr);\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-callbacks.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n\n#include \"gcc-python-closure.h\"\n#include \"gcc-python-wrappers.h\"\n\n#include \"gcc-c-api/gcc-location.h\"\n\n/*\n  Notes on the passes\n\n  As of 2011-03-30, http://gcc.gnu.org/onlinedocs/gccint/Plugins.html doesn't\n  seem to document the type of the gcc_data passed to each callback.\n\n  For reference, with gcc-4.6.0-0.15.fc15.x86_64 the types seem to be as\n  follows:\n\n  PLUGIN_ATTRIBUTES:\n    gcc_data=0x0\n    Called from: init_attributes () at ../../gcc/attribs.c:187\n    However, it seems at this point to have initialized these:\n      static const struct attribute_spec *attribute_tables[4];\n      static htab_t attribute_hash;\n\n  PLUGIN_PRAGMAS:\n    gcc_data=0x0\n    Called from: c_common_init () at ../../gcc/c-family/c-opts.c:1052\n\n  PLUGIN_START_UNIT:\n    gcc_data=0x0\n    Called from: compile_file () at ../../gcc/toplev.c:573\n\n  PLUGIN_PRE_GENERICIZE\n    gcc_data is:  tree fndecl;\n    Called from: finish_function () at ../../gcc/c-decl.c:8323\n\n  PLUGIN_OVERRIDE_GATE\n    gcc_data:\n      &gate_status\n      bool gate_status;\n    Called from : execute_one_pass (pass=0x1011340) at ../../gcc/passes.c:1520\n\n  PLUGIN_PASS_EXECUTION\n    gcc_data: struct opt_pass *pass\n    Called from: execute_one_pass (pass=0x1011340) at ../../gcc/passes.c:1530\n\n  PLUGIN_ALL_IPA_PASSES_START\n    gcc_data=0x0\n    Called from: ipa_passes () at ../../gcc/cgraphunit.c:1779\n\n  PLUGIN_EARLY_GIMPLE_PASSES_START\n    gcc_data=0x0\n    Called from: execute_ipa_pass_list (pass=0x1011fa0) at ../../gcc/passes.c:1927\n\n  PLUGIN_EARLY_GIMPLE_PASSES_END\n    gcc_data=0x0\n    Called from: execute_ipa_pass_list (pass=0x1011fa0) at ../../gcc/passes.c:1930\n\n  PLUGIN_ALL_IPA_PASSES_END\n    gcc_data=0x0\n    Called from: ipa_passes () at ../../gcc/cgraphunit.c:1821\n\n  PLUGIN_ALL_PASSES_START\n    gcc_data=0x0\n    Called from: tree_rest_of_compilation (fndecl=0x7ffff16b1f00) at ../../gcc/tree-optimize.c:420\n\n  PLUGIN_ALL_PASSES_END\n    gcc_data=0x0\n    Called from: tree_rest_of_compilation (fndecl=0x7ffff16b1f00) at ../../gcc/tree-optimize.c:425\n\n  PLUGIN_FINISH_UNIT\n    gcc_data=0x0\n    Called from: compile_file () at ../../gcc/toplev.c:668\n\n  PLUGIN_FINISH_TYPE\n    gcc_data=tree\n    Called from c_parser_declspecs (parser=0x7fffef559730, specs=0x15296d0, scspec_ok=1 '\\001', typespec_ok=1 '\\001', start_attr_ok=<optimized out>, la=cla_nonabstract_decl) at ../../gcc/c-parser.c:2111\n\n  PLUGIN_PRAGMA\n    gcc_data=0x0\n    Called from: init_pragma at ../../gcc/c-family/c-pragma.c:1321\n    to  \"Allow plugins to register their own pragmas.\"\n*/\n\nstatic enum plugin_event current_event = (enum plugin_event)GCC_PYTHON_PLUGIN_BAD_EVENT;\n\nint PyGcc_IsWithinEvent(enum plugin_event *out_event)\n{\n    if (current_event != GCC_PYTHON_PLUGIN_BAD_EVENT) {\n        if (out_event) {\n            *out_event = current_event;\n        }\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n\nstatic void\nPyGcc_FinishInvokingCallback(PyGILState_STATE gstate,\n                                    int expect_wrapped_data, PyObject *wrapped_gcc_data,\n                                    void *user_data)\n    CPYCHECKER_STEALS_REFERENCE_TO_ARG(3) /* wrapped_gcc_data */ ;\n\nstatic void\nPyGcc_FinishInvokingCallback(PyGILState_STATE gstate,\n                                    int expect_wrapped_data, PyObject *wrapped_gcc_data,\n                                    void *user_data)\n{\n    struct callback_closure *closure = (struct callback_closure *)user_data;\n    PyObject *args = NULL;\n    PyObject *result = NULL;\n    gcc_location saved_loc = gcc_get_input_location();\n    enum plugin_event saved_event;\n\n    assert(closure);\n    /* We take ownership of wrapped_gcc_data.\n       For some callbacks types it will always be NULL; for others, it's only\n       NULL if an error has occurred: */\n    if (expect_wrapped_data && !wrapped_gcc_data) {\n        goto cleanup;\n    }\n\n    if (cfun) {\n        /* Temporarily override input_location to the top of the function: */\n        gcc_set_input_location(gcc_private_make_location(cfun->function_start_locus));\n    }\n\n    args = PyGcc_Closure_MakeArgs(closure, 1, wrapped_gcc_data);\n    if (!args) {\n        goto cleanup;\n    }\n\n    saved_event = current_event;\n    current_event = closure->event;\n\n    result = PyObject_Call(closure->callback, args, closure->kwargs);\n\n    current_event = saved_event;\n\n    if (!result) {\n        /* Treat an unhandled Python error as a compilation error: */\n        PyGcc_PrintException(\"Unhandled Python exception raised within callback\");\n    }\n\n    // FIXME: the result is ignored\n\ncleanup:\n    Py_XDECREF(wrapped_gcc_data);\n    Py_XDECREF(args);\n    Py_XDECREF(result);\n\n    /* We never cleanup \"closure\"; we don't know if we'll be called again */\n\n    PyGILState_Release(gstate);\n    gcc_set_input_location(saved_loc);\n}\n\n/*\n  C-level callbacks for each event ID follow, thunking into the registered\n  Python callable.\n\n  There's some repetition here, but it can be easier to debug if you have\n  separate breakpoint locations for each event ID.\n */\n\nstatic void\nPyGcc_CallbackFor_tree(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n    tree t = (tree)gcc_data;\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate, \n\t\t\t\t\t1, PyGccTree_New(gcc_private_make_tree(t)),\n\t\t\t\t\tuser_data);\n}\n\n\nstatic void\nPyGcc_CallbackFor_PLUGIN_ATTRIBUTES(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n\n    //printf(\"%s:%i:(%p, %p)\\n\", __FILE__, __LINE__, gcc_data, user_data);\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate,\n                                        0, NULL,\n                                        user_data);\n}\n\nstatic void\nPyGcc_CallbackFor_PLUGIN_PASS_EXECUTION(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n    struct opt_pass *pass = (struct opt_pass *)gcc_data;\n\n    //printf(\"%s:%i:(%p, %p)\\n\", __FILE__, __LINE__, gcc_data, user_data);\n    assert(pass);\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate, \n\t\t\t\t\t1, PyGccPass_New(pass),\n\t\t\t\t\tuser_data);\n}\n\nstatic void\nPyGcc_CallbackFor_FINISH(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n\n    /* PLUGIN_FINISH:\n       gcc_data=0x0\n       called from: toplev_main at ../../gcc/toplev.c:1970\n    */\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate,\n                                        0, NULL,\n                                        user_data);\n}\n\nstatic void\nPyGcc_CallbackFor_FINISH_UNIT(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate,\n\t\t\t\t\t0, NULL,\n\t\t\t\t\tuser_data);\n}\n\nstatic void\nPyGcc_CallbackFor_GGC_START(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate,\n\t\t\t\t\t0, NULL,\n\t\t\t\t\tuser_data);\n}\n\nstatic void\nPyGcc_CallbackFor_GGC_MARKING(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate,\n\t\t\t\t\t0, NULL,\n\t\t\t\t\tuser_data);\n}\n\nstatic void\nPyGcc_CallbackFor_GGC_END(void *gcc_data, void *user_data)\n{\n    PyGILState_STATE gstate;\n\n    gstate = PyGILState_Ensure();\n\n    PyGcc_FinishInvokingCallback(gstate,\n\t\t\t\t\t0, NULL,\n\t\t\t\t\tuser_data);\n}\n\n\nPyObject*\nPyGcc_RegisterCallback(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    int event;\n    PyObject *callback = NULL;\n    PyObject *extraargs = NULL;\n    struct callback_closure *closure;\n\n    if (!PyArg_ParseTuple(args, \"iO|O:register_callback\", &event, &callback, &extraargs)) {\n        return NULL;\n    }\n\n    //printf(\"%s:%i:PyGcc_RegisterCallback\\n\", __FILE__, __LINE__);\n\n    closure = PyGcc_Closure_NewForPluginEvent(callback, extraargs, kwargs,\n                                                      (enum plugin_event)event);\n    if (!closure) {\n        return PyErr_NoMemory();\n    }\n\n    switch ((enum plugin_event)event) {\n    case PLUGIN_ATTRIBUTES:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_PLUGIN_ATTRIBUTES,\n\t\t\t  closure);\n\tbreak;\n\n    case PLUGIN_PRE_GENERICIZE:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_tree,\n\t\t\t  closure);\n\tbreak;\n\t\n    case PLUGIN_PASS_EXECUTION:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_PLUGIN_PASS_EXECUTION,\n\t\t\t  closure);\n\tbreak;\n\n    case PLUGIN_FINISH:\n        register_callback(\"python\", // FIXME\n                          (enum plugin_event)event,\n                          PyGcc_CallbackFor_FINISH,\n                          closure);\n\tbreak;\n\n    case PLUGIN_FINISH_UNIT:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_FINISH_UNIT,\n\t\t\t  closure);\n\tbreak;\n\n    case PLUGIN_FINISH_TYPE:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_tree,\n\t\t\t  closure);\n\tbreak;\n\n    case PLUGIN_GGC_START:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_GGC_START,\n\t\t\t  closure);\n        break;\n    case PLUGIN_GGC_MARKING:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_GGC_MARKING,\n\t\t\t  closure);\n        break;\n    case PLUGIN_GGC_END:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n\t\t\t  PyGcc_CallbackFor_GGC_END,\n\t\t\t  closure);\n        break;\n\n    /* PLUGIN_FINISH_DECL was added in gcc 4.7 onwards: */\n#ifdef GCC_PYTHON_PLUGIN_CONFIG_has_PLUGIN_FINISH_DECL\n    case PLUGIN_FINISH_DECL:\n        register_callback(\"python\", // FIXME\n\t\t\t  (enum plugin_event)event,\n                          PyGcc_CallbackFor_tree,\n\t\t\t  closure);\n\tbreak;\n#endif /* GCC_PYTHON_PLUGIN_CONFIG_has_PLUGIN_FINISH_DECL */\n\n    default:\n        PyErr_Format(PyExc_ValueError, \"event type %i invalid (or not wired up yet)\", event);\n\treturn NULL;\n    }\n    \n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-callgraph.c",
    "content": "/*\n   Copyright 2011, 2012, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-c-api/gcc-callgraph.h\"\n\n/*\n  Wrapper for various types in gcc/cgraph.h\n    struct cgraph_edge *\n    struct cgraph_node *\n*/\n\nPyObject *\nPyGccCallgraphEdge_repr(struct PyGccCallgraphEdge * self)\n{\n    return PyGccString_FromFormat(\"%s()\",\n                                         Py_TYPE(self)->tp_name);\n}\n\nPyObject *\nPyGccCallgraphEdge_str(struct PyGccCallgraphEdge * self)\n{\n    return PyGccString_FromFormat(\"%s()\",\n                                         Py_TYPE(self)->tp_name);\n}\n\nPyObject *\nPyGccCallgraphNode_repr(struct PyGccCallgraphNode * self)\n{\n    return PyGccString_FromFormat(\"%s()\",\n                                         Py_TYPE(self)->tp_name);\n}\n\nPyObject *\nPyGccCallgraphNode_str(struct PyGccCallgraphNode * self)\n{\n    return PyGccString_FromFormat(\"%s()\",\n                                         Py_TYPE(self)->tp_name);\n}\n\nIMPL_APPENDER(add_cgraph_edge_to_list,\n              gcc_cgraph_edge,\n              PyGccCallgraphEdge_New)\n\nPyObject *\nPyGccCallgraphNode_get_callees(struct PyGccCallgraphNode * self)\n{\n    IMPL_LIST_MAKER(gcc_cgraph_node_for_each_callee,\n                    self->node,\n                    add_cgraph_edge_to_list)\n}\n\nPyObject *\nPyGccCallgraphNode_get_callers(struct PyGccCallgraphNode * self)\n{\n    IMPL_LIST_MAKER(gcc_cgraph_node_for_each_caller,\n                    self->node,\n                    add_cgraph_edge_to_list)\n}\n\nunion gcc_cgraph_edge_as_ptr {\n    gcc_cgraph_edge edge;\n    void *ptr;\n};\n\nPyObject *\nreal_make_cgraph_edge_wrapper(void *ptr)\n{\n    struct PyGccCallgraphEdge *obj = NULL;\n    union gcc_cgraph_edge_as_ptr u;\n    u.ptr = ptr;\n\n    obj = PyGccWrapper_New(struct PyGccCallgraphEdge,\n                           &PyGccCallgraphEdge_TypeObj);\n    if (!obj) {\n        goto error;\n    }\n\n    obj->edge = u.edge;\n\n    return (PyObject*)obj;\n\nerror:\n    return NULL;\n}\n\nstatic PyObject *cgraph_edge_wrapper_cache = NULL;\nPyObject *\nPyGccCallgraphEdge_New(gcc_cgraph_edge edge)\n{\n    union gcc_cgraph_edge_as_ptr u;\n    u.edge = edge;\n    return PyGcc_LazilyCreateWrapper(&cgraph_edge_wrapper_cache,\n                                     u.ptr,\n                                     real_make_cgraph_edge_wrapper);\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccCallgraphEdge(PyGccCallgraphEdge *wrapper)\n{\n    gcc_cgraph_edge_mark_in_use(wrapper->edge);\n}\n\n\nunion gcc_cgraph_node_as_ptr {\n    gcc_cgraph_node node;\n    void *ptr;\n};\n\nPyObject *\nreal_make_cgraph_node_wrapper(void *ptr)\n{\n    struct PyGccCallgraphNode *obj = NULL;\n    union gcc_cgraph_node_as_ptr u;\n    u.ptr = ptr;\n\n    obj = PyGccWrapper_New(struct PyGccCallgraphNode,\n                           &PyGccCallgraphNode_TypeObj);\n    if (!obj) {\n        goto error;\n    }\n\n    obj->node = u.node;\n\n    return (PyObject*)obj;\n\nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccCallgraphNode(PyGccCallgraphNode *wrapper)\n{\n    gcc_cgraph_node_mark_in_use(wrapper->node);\n}\n\n\nstatic PyObject *cgraph_node_wrapper_cache = NULL;\nPyObject *\nPyGccCallgraphNode_New(gcc_cgraph_node node)\n{\n    union gcc_cgraph_node_as_ptr u;\n    u.node = node;\n    return PyGcc_LazilyCreateWrapper(&cgraph_node_wrapper_cache,\n\t\t\t\t\t    u.ptr,\n\t\t\t\t\t    real_make_cgraph_node_wrapper);\n}\n\nIMPL_APPENDER(add_cgraph_node_to_list,\n              gcc_cgraph_node,\n              PyGccCallgraphNode_New)\n\nPyObject *\nPyGcc_get_callgraph_nodes(PyObject *self, PyObject *args)\n{\n    /* For debugging, see GCC's dump of things: */\n    if (0) {\n        fprintf(stderr, \"----------------BEGIN----------------\\n\");\n#if (GCC_VERSION >= 5000)\n        cgraph_node::dump_cgraph (stderr);\n#else\n        dump_cgraph (stderr);\n#endif\n        fprintf(stderr, \"---------------- END ----------------\\n\");\n    }\n\n    IMPL_GLOBAL_LIST_MAKER(gcc_for_each_cgraph_node,\n                           add_cgraph_node_to_list)\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-cfg.c",
    "content": "/*\n   Copyright 2011, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-c-api/gcc-cfg.h\"\n#include \"gcc-c-api/gcc-gimple.h\"\n\n#include \"gcc-c-api/gcc-private-compat.h\" /* for now */\n\n#if 1\n/* Ideally we wouldn't have these includes here: */\n#include \"basic-block.h\"\n#include \"rtl.h\"\n#endif\n\n/*\n  \"struct edge_def\" is declared in basic-block.h, c.f:\n      struct GTY(()) edge_def {\n           ... snip ...\n      }\n  and there are these typedefs to pointers defined in coretypes.h:\n      typedef struct edge_def *edge;\n      typedef const struct edge_def *const_edge;\n */\n\nunion cfg_edge_or_ptr {\n    gcc_cfg_edge edge;\n    void *ptr;\n};\n\nPyObject *\nreal_make_edge(void * ptr)\n{\n    union cfg_edge_or_ptr u;\n    u.ptr = ptr;\n    struct PyGccEdge *obj;\n\n    if (!u.edge.inner) {\n\tPy_RETURN_NONE;\n    }\n\n    obj = PyGccWrapper_New(struct PyGccEdge, &PyGccEdge_TypeObj);\n    if (!obj) {\n        goto error;\n    }\n\n    obj->e = u.edge;\n\n    return (PyObject*)obj;\n      \nerror:\n    return NULL;\n}\n\nstatic PyObject *edge_wrapper_cache = NULL;\n\nPyObject *\nPyGccEdge_New(gcc_cfg_edge e)\n{\n    union cfg_edge_or_ptr u;\n    u.edge = e;\n    return PyGcc_LazilyCreateWrapper(&edge_wrapper_cache,\n\t\t\t\t\t    u.ptr,\n\t\t\t\t\t    real_make_edge);\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccEdge(PyGccEdge *wrapper)\n{\n    /* Mark the underlying object (recursing into its fields): */\n    gcc_cfg_edge_mark_in_use(wrapper->e);\n}\n\nIMPL_APPENDER(add_edge_to_list,\n              gcc_cfg_edge,\n              PyGccEdge_New)\n\nPyObject *\nPyGccBasicBlock_repr(struct PyGccBasicBlock * self)\n{\n    return PyGccString_FromFormat(\"%s(index=%i)\",\n                                         Py_TYPE(self)->tp_name,\n                                         gcc_cfg_block_get_index(self->bb));\n}\n\nPyObject *\nPyGccBasicBlock_get_preds(PyGccBasicBlock *self, void *closure)\n{\n    IMPL_LIST_MAKER(gcc_cfg_block_for_each_pred_edge,\n                    self->bb,\n                    add_edge_to_list)\n}\n\nPyObject *\nPyGccBasicBlock_get_succs(PyGccBasicBlock *self, void *closure)\n{\n    IMPL_LIST_MAKER(gcc_cfg_block_for_each_succ_edge,\n                    self->bb,\n                    add_edge_to_list)\n}\n\nIMPL_APPENDER(append_gimple_to_list,\n              gcc_gimple,\n              PyGccGimple_New)\n\nPyObject *\nPyGccBasicBlock_get_gimple(PyGccBasicBlock *self, void *closure)\n{\n    assert(self);\n    assert(self->bb.inner);\n\n    IMPL_LIST_MAKER(gcc_cfg_block_for_each_gimple,\n                    self->bb,\n                    append_gimple_to_list)\n}\n\nstatic PyObject*\nPyGccGimple_New_phi(gcc_gimple_phi phi)\n{\n    return PyGccGimple_New(gcc_gimple_phi_as_gcc_gimple(phi));\n}\n\nIMPL_APPENDER(append_gimple_phi_to_list,\n              gcc_gimple_phi,\n              PyGccGimple_New_phi)\n\nPyObject *\nPyGccBasicBlock_get_phi_nodes(PyGccBasicBlock *self, void *closure)\n{\n    assert(self);\n    assert(self->bb.inner);\n\n    IMPL_LIST_MAKER(gcc_cfg_block_for_each_gimple_phi,\n                    self->bb,\n                    append_gimple_phi_to_list)\n}\n\nIMPL_APPENDER(append_rtl_to_list,\n              gcc_rtl_insn,\n              PyGccRtl_New)\n\nPyObject *\nPyGccBasicBlock_get_rtl(PyGccBasicBlock *self, void *closure)\n{\n    assert(self);\n    assert(self->bb.inner);\n\n    IMPL_LIST_MAKER(gcc_cfg_block_for_each_rtl_insn,\n                    self->bb,\n                    append_rtl_to_list)\n}\n\n\n/*\n  Force a 1-1 mapping between pointer values and wrapper objects\n */\nPyObject *\nPyGcc_LazilyCreateWrapper(PyObject **cache,\n\t\t\t\t void *ptr,\n\t\t\t\t PyObject *(*ctor)(void *ptr))\n{\n    PyObject *key = NULL;\n    PyObject *oldobj = NULL;\n    PyObject *newobj = NULL;\n\n    /* printf(\"PyGcc_LazilyCreateWrapper(&%p, %p, %p)\\n\", *cache, ptr, ctor); */\n\n    assert(cache);\n    /* ptr is allowed to be NULL */\n    assert(ctor);\n\n    /* The cache is lazily created: */\n    if (!*cache) {\n\t*cache = PyDict_New();\n\tif (!*cache) {\n\t    return NULL;\n\t}\n    }\n\n    key = PyLong_FromVoidPtr(ptr);\n    if (!key) {\n\treturn NULL;\n    }\n\n    oldobj = PyDict_GetItem(*cache, key);\n    if (oldobj) {\n\t/* The cache already contains an object wrapping \"ptr\": reuse t */\n\t/* printf(\"reusing %p for %p\\n\", oldobj, ptr); */\n\tPy_INCREF(oldobj); /* it was a borrowed ref */\n\tPy_DECREF(key);\n\treturn oldobj;\n    }\n\n    /* \n       Not in the cache: we don't yet have a wrapper object for this pointer\n    */\n       \n    assert(NULL != key); /* we own a ref */\n    assert(NULL == oldobj);\n    assert(NULL == newobj);\n\n    /* Construct a wrapper : */\n\n    newobj = (*ctor)(ptr);\n    if (!newobj) {\n\tPy_DECREF(key);\n\treturn NULL;\n    }\n\n    /* printf(\"created %p for %p\\n\", newobj, ptr); */\n\n    if (PyDict_SetItem(*cache, key, newobj)) {\n\tPy_DECREF(newobj);\n\tPy_DECREF(key);\n\treturn NULL;\n    }\n\n    Py_DECREF(key);\n    return newobj;\n}\n\nint\nPyGcc_insert_new_wrapper_into_cache(PyObject **cache,\n                                         void *ptr,\n                                         PyObject *obj)\n{\n    PyObject *key;\n    assert(cache);\n    assert(ptr);\n    assert(obj);\n\n    /* The cache is lazily created: */\n    if (!*cache) {\n\t*cache = PyDict_New();\n\tif (!*cache) {\n\t    return -1;\n\t}\n    }\n\n    key = PyLong_FromVoidPtr(ptr);\n    if (!key) {\n\treturn -1;\n    }\n\n    if (PyDict_SetItem(*cache, key, obj)) {\n\tPy_DECREF(key);\n\treturn -1;\n    }\n\n    Py_DECREF(key);\n    return 0;\n}\n\nunion cfg_block_or_ptr {\n    gcc_cfg_block block;\n    void *ptr;\n};\n\nstatic PyObject *\nreal_make_basic_block_wrapper(void *ptr)\n{\n    union cfg_block_or_ptr u;\n    struct PyGccBasicBlock *obj;\n\n    u.ptr = ptr;\n\n    if (!u.block.inner) {\n\tPy_RETURN_NONE;\n    }\n\n    obj = PyGccWrapper_New(struct PyGccBasicBlock, &PyGccBasicBlock_TypeObj);\n    if (!obj) {\n        goto error;\n    }\n\n#if 0\n    printf(\"bb: %p\\n\", bb);\n    printf(\"bb->flags: 0x%x\\n\", bb->flags);\n    printf(\"bb->flags & BB_RTL: %i\\n\", bb->flags & BB_RTL);\n    if (bb->flags & BB_RTL) {\n\tprintf(\"bb->il.rtl: %p\\n\", bb->il.rtl);\n    } else {\n\tprintf(\"bb->il.gimple: %p\\n\", bb->il.gimple);\n\tif (bb->il.gimple) {\n\t    /* \n\t       See http://gcc.gnu.org/onlinedocs/gccint/GIMPLE.html\n\t       and also gimple-pretty-print.c\n\n\t       coretypes.h has:\n\t           struct gimple_seq_d;\n\t\t   typedef struct gimple_seq_d *gimple_seq;\n\n\t       and gimple.h has:\n   \t           \"A double-linked sequence of gimple statements.\"\n\t\t   struct GTY ((chain_next (\"%h.next_free\"))) gimple_seq_d {\n                        ... snip ...\n\t\t   }\n               and:\n\t\t   struct gimple_seq_node_d;\n\t\t   typedef struct gimple_seq_node_d *gimple_seq_node;\n\t       and:\n\t           struct GTY((chain_next (\"%h.next\"), chain_prev (\"%h.prev\"))) gimple_seq_node_d {\n\t\t       gimple stmt;\n\t\t       struct gimple_seq_node_d *prev;\n\t\t       struct gimple_seq_node_d *next;\n\t\t   };\n\t       and coretypes.h has:\n\t           union gimple_statement_d;\n\t\t   typedef union gimple_statement_d *gimple;\n\t       and gimple.h has the \"union gimple_statement_d\", and another\n\t       set of codes for this\n\t    */\n\n\t    printf(\"bb->il.gimple->seq: %p\\n\", bb->il.gimple->seq);\n\t    printf(\"bb->il.gimple->phi_nodes: %p\\n\", bb->il.gimple->phi_nodes);\n\n\t    {\n\t\tgimple_stmt_iterator i;\n\t\t\n\t\tfor (i = gsi_start (bb->il.gimple->seq); !gsi_end_p (i); gsi_next (&i)) {\n\t\t    gimple stmt = gsi_stmt(i);\n\t\t    printf(\"  gimple: %p code: %s (%i) %s:%i num_ops=%i\\n\", \n\t\t\t   stmt,\n\t\t\t   gimple_code_name[gimple_code(stmt)],\n\t\t\t   gimple_code(stmt),\n\t\t\t   gimple_filename(stmt),\n\t\t\t   gimple_lineno(stmt),\n\t\t\t   gimple_num_ops(stmt));\n\t\t    //print_generic_stmt (stderr, stmt, 0);\n\t\t}\n\t    }\n\n\t}\n    }\n#endif\n\n    obj->bb = u.block;\n\n    return (PyObject*)obj;\n      \nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccBasicBlock(PyGccBasicBlock *wrapper)\n{\n    /* Mark the underlying object (recursing into its fields): */\n    gcc_cfg_block_mark_in_use(wrapper->bb);\n}\n\n\nstatic PyObject *basic_block_wrapper_cache = NULL;\nPyObject *\nPyGccBasicBlock_New(gcc_cfg_block bb)\n{\n    return PyGcc_LazilyCreateWrapper(&basic_block_wrapper_cache,\n\t\t\t\t\t    bb.inner,\n\t\t\t\t\t    real_make_basic_block_wrapper);\n}\n\nstatic bool\nadd_block_to_list(gcc_cfg_block bb, void *user_data)\n{\n    PyObject *result = (PyObject*)user_data;\n    PyObject *obj_var;\n    obj_var = PyGccBasicBlock_New(bb);\n    if (!obj_var) {\n        return true;\n    }\n\n    /* It appears that with optimization there can be occasional NULLs,\n       which get turned into None.  Skip them:\n    */\n    if (obj_var != Py_None) {\n        if (-1 == PyList_Append(result, obj_var)) {\n            Py_DECREF(obj_var);\n            return true;\n        }\n\n        /* Success: */\n    }\n    Py_DECREF(obj_var);\n    return false;\n}\n\nPyObject *\nPyGccCfg_get_basic_blocks(PyGccCfg *self, void *closure)\n{\n    IMPL_LIST_MAKER(gcc_cfg_for_each_block,\n                    self->cfg,\n                    add_block_to_list)\n}\n\nextern PyTypeObject PyGccLabelDecl_TypeObj;\n\nPyObject *\nPyGccCfg_get_block_for_label(PyObject *s, PyObject *args)\n{\n    struct PyGccCfg *self = (struct PyGccCfg *)s;\n    struct PyGccTree *label_decl;\n    int uid;\n    basic_block bb;\n\n    if (!PyArg_ParseTuple(args,\n                          \"O!:get_block_for_label\",\n                          &PyGccLabelDecl_TypeObj, &label_decl)) {\n        return NULL;\n    }\n\n    /* See also gcc/tree-cfg.c: label_to_block_fn */\n    uid = LABEL_DECL_UID(label_decl->t.inner);\n\n    if (uid < 0 ||\n        (\n         (\n#if (GCC_VERSION >= 4008)\n          vec_safe_length(self->cfg.inner->x_label_to_block_map)\n#else\n          VEC_length (basic_block, self->cfg.inner->x_label_to_block_map)\n#endif\n         )\n         <=\n         (unsigned int) uid)\n        ) {\n        return PyErr_Format(PyExc_ValueError,\n                            \"uid %i not found\", uid);\n    }\n\n    bb = GCC_COMPAT_VEC_INDEX(basic_block,\n                              self->cfg.inner->x_label_to_block_map,\n                              uid);\n\n    return PyGccBasicBlock_New(gcc_private_make_cfg_block(bb));\n}\n\nunion gcc_cfg_as_ptr {\n    gcc_cfg cfg;\n    void *ptr;\n};\n\nPyObject *\nreal_make_cfg_wrapper(void *ptr)\n{\n    struct PyGccCfg *obj;\n    union gcc_cfg_as_ptr u;\n    u.ptr = ptr;\n\n    if (!u.cfg.inner) {\n\tPy_RETURN_NONE;\n    }\n\n    obj = PyGccWrapper_New(struct PyGccCfg, &PyGccCfg_TypeObj);\n    if (!obj) {\n        goto error;\n    }\n\n    obj->cfg = u.cfg;\n\n    return (PyObject*)obj;\n      \nerror:\n    return NULL;\n}\n\nstatic PyObject *cfg_wrapper_cache = NULL;\nPyObject *\nPyGccCfg_New(gcc_cfg cfg)\n{\n    union gcc_cfg_as_ptr u;\n    u.cfg = cfg;\n    return PyGcc_LazilyCreateWrapper(&cfg_wrapper_cache,\n                                     u.ptr,\n                                     real_make_cfg_wrapper);\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccCfg(PyGccCfg *wrapper)\n{\n    /* Mark the underlying object (recursing into its fields): */\n    gcc_cfg_mark_in_use(wrapper->cfg);\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-closure.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include <gcc-plugin.h>\n\n#include \"gcc-python-closure.h\"\n#include \"gcc-python.h\"\n#include \"function.h\"\n\n#include \"gcc-c-api/gcc-function.h\"\n\nstruct callback_closure *\nPyGcc_closure_new_generic(PyObject *callback, PyObject *extraargs, PyObject *kwargs)\n{\n    struct callback_closure *closure;\n\n    assert(callback);\n    /* extraargs can be NULL\n       kwargs can also be NULL */\n\n    closure = PyMem_New(struct callback_closure, 1);\n    if (!closure) {\n        return NULL;\n    }\n    \n    closure->callback = callback;\n    Py_INCREF(callback);\n\n    // FIXME: we may want to pass in the event enum as well as the user-supplied extraargs\n\n    if (extraargs) {\n\t/* Hold a reference to the extraargs for when we register it with the\n\t   callback: */\n\tclosure->extraargs = extraargs;\n\tPy_INCREF(extraargs);\n    } else {\n\tclosure->extraargs = PyTuple_New(0);\n\tif (!closure->extraargs) {\n\t    return NULL;  // singleton, so can't happen, really\n\t}\n    }\n\n    closure->kwargs = kwargs;\n    if (kwargs) {\n\tPy_INCREF(kwargs);\n    }\n\n    closure->event = (enum plugin_event)GCC_PYTHON_PLUGIN_BAD_EVENT;\n\n    return closure;\n}\n\nstruct callback_closure *\nPyGcc_Closure_NewForPluginEvent(PyObject *callback, PyObject *extraargs, PyObject *kwargs,\n                                        enum plugin_event event)\n{\n    struct callback_closure *closure = PyGcc_closure_new_generic(callback, extraargs, kwargs);\n    if (closure) {\n        closure->event = event;\n    }\n    return closure;\n}\n\nPyObject *\nPyGcc_Closure_MakeArgs(struct callback_closure * closure, int add_cfun, PyObject *wrapped_gcc_data)\n{\n    PyObject *args = NULL;\n    PyObject *cfun_obj = NULL;\n    int i;\n\n    assert(closure);\n    /* wrapped_gcc_data can be NULL if there isn't one for this kind of callback */\n    assert(closure->extraargs);\n    assert(PyTuple_Check(closure->extraargs));\n    \n    if (wrapped_gcc_data) {\n \t/* \n\t   Equivalent to either:\n\t     args = (gcc_data, cfun, ) + extraargs\n           or:\n\t     args = (gcc_data, ) + extraargs\n\t */\n        args = PyTuple_New((add_cfun ? 2 : 1) + PyTuple_Size(closure->extraargs));\n\n\tif (!args) {\n\t    goto error;\n\t}\n\n        if (add_cfun) {\n            cfun_obj = PyGccFunction_New(gcc_get_current_function());\n            if (!cfun_obj) {\n                goto error;\n            }\n        }\n\n\tPyTuple_SetItem(args, 0, wrapped_gcc_data);\n        if (add_cfun) {\n            PyTuple_SetItem(args, 1, cfun_obj);\n        }\n\tPy_INCREF(wrapped_gcc_data);\n\tfor (i = 0; i < PyTuple_Size(closure->extraargs); i++) {\n\t    PyObject *item = PyTuple_GetItem(closure->extraargs, i);\n\t    PyTuple_SetItem(args, i + (add_cfun ? 2 : 1), item);\n\t    Py_INCREF(item);\n\t}\n\t\n\treturn args;\n\t\n    } else {\n\t/* Just reuse closure's extraargs tuple */\n\tPy_INCREF(closure->extraargs);\n\treturn closure->extraargs;\n    }\n\n error:\n    Py_XDECREF(args);\n    Py_XDECREF(cfun_obj);\n    return NULL;\n}\n\n\nvoid\nPyGcc_closure_free(struct callback_closure *closure)\n{\n    assert(closure);\n\n    Py_XDECREF(closure->callback);\n    Py_XDECREF(closure->extraargs);\n    Py_XDECREF(closure->kwargs);\n\n    PyMem_Free(closure);\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-closure.h",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#ifndef INCLUDED__GCC_PYTHON_CLOSURE_H\n#define INCLUDED__GCC_PYTHON_CLOSURE_H\n\nstruct callback_closure\n{\n    PyObject *callback;\n    PyObject *extraargs;\n    PyObject *kwargs;\n    enum plugin_event event;\n      /* or GCC_PYTHON_PLUGIN_BAD_EVENT if not an event */\n};\n\nstruct callback_closure *\nPyGcc_closure_new_generic(PyObject *callback,\n                               PyObject *extraargs,\n                               PyObject *kwargs);\n\nstruct callback_closure *\nPyGcc_Closure_NewForPluginEvent(PyObject *callback,\n                                        PyObject *extraargs,\n                                        PyObject *kwargs,\n                                        enum plugin_event event);\n\nPyObject *\nPyGcc_Closure_MakeArgs(struct callback_closure * closure,\n                             int add_cfun, PyObject *wrapped_gcc_data);\n\nvoid\nPyGcc_closure_free(struct callback_closure *closure);\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n\n#endif /* INCLUDED__GCC_PYTHON_CLOSURE_H */\n"
  },
  {
    "path": "gcc-python-compat.h",
    "content": "/*\n   Copyright 2011, 2012, 2014 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012, 2014 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#ifndef INCLUDED__GCC_PYTHON_COMPAT_H\n#define INCLUDED__GCC_PYTHON_COMPAT_H\n\n#include \"gimple.h\"\n#include \"tree.h\"\n\n#if GCC_VERSION < 8000\ntypedef int dump_flags_t;\n#endif\n\n/*\n  There are a few GCC symbols that don't seem to be exposed in the plugin\n  headers, but I wish were.\n\n  We manually repeated the necessary declarations here.\n\n  This is wrong, but at least it's all captured here in one place.  Hopefully\n  these will eventually become officially exposed to plugins, but for now its\n  all here.\n*/\n\n/*\n   This is declared in gcc/gimple-pretty-print.c, but not exposed in any of\n   the plugin headers AFAIK:\n*/\nextern void\ndump_gimple_stmt (pretty_printer *buffer, gimple gs, int spc, dump_flags_t flags);\n\n/*\n   This is declared in gcc/tree-pretty-print.c (around line 580); it was only\n   exposed to plugin headers (in tree-pretty-print.h) in GCC commit r203113\n   (aka 0d9585ca35b919263b973afb371f0eda04857159, 2013-10-02), as part of\n   GCC 4.9\n\n   The signature was changed by GCC 8 commit r248140 (aka\n   3f6e5ced7eb1cf5b3212b2391c5b70ec3dcaf136, 2017-05-17), which introduced\n   dump_flags_t.\n */\n#if GCC_VERSION < 4009\nextern int\ndump_generic_node (pretty_printer *buffer, tree node, int spc, dump_flags_t flags,\n\t\t   bool is_stmt);\n#endif\n\n/* Within gcc/gcc-internal.h, not exposed by plugin API */\nextern bool ggc_force_collect;\n\n/* From c-family/c-common.h */\n#if GCC_VERSION < 4008\nextern tree c_sizeof_or_alignof_type (location_t, tree, bool, int);\n#endif\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n\n#endif /* INCLUDED__GCC_PYTHON_COMPAT_H */\n"
  },
  {
    "path": "gcc-python-diagnostics.c",
    "content": "/*\n   Copyright 2011-2013, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n\n#include \"gcc-python-wrappers.h\"\n\n#include \"diagnostic.h\"\n#include \"gcc-c-api/gcc-diagnostics.h\"\n\n/*\n  I initially attempted to directly wrap gcc's:\n    diagnostic_report_diagnostic()\n  given that that seems to be the abstraction within gcc/diagnostic.h: all\n  instances of (struct diagnostic_info) within the gcc source tree seem to\n  be allocated on the stack, within functions exposed in gcc/diagnostic.h\n\n  However, diagnostic_report_diagnostic() ultimately calls into the\n  pretty-printing routines, trying to format varargs, which doesn't make much\n  sense for us: we have first-class string objects and string formatting at\n  the python level.\n\n  Thus we instead just wrap \"error_at\" and its analogs\n*/\n\nPyObject*\nPyGcc_permerror(PyObject *self, PyObject *args)\n{\n    PyGccLocation *loc_obj = NULL;\n    const char *msg = NULL;\n    PyObject *result_obj = NULL;\n    bool result_b;\n\n    if (!PyArg_ParseTuple(args,\n\t\t\t  \"O!\"\n\t\t\t  \"s\"\n\t\t\t  \":permerror\",\n\t\t\t  &PyGccLocation_TypeObj, &loc_obj,\n\t\t\t  &msg)) {\n        return NULL;\n    }\n\n    /* Invoke the GCC function: */\n    result_b = gcc_permerror(loc_obj->loc, msg);\n\n    result_obj = PyBool_FromLong(result_b);\n\n    return result_obj;\n}\n\nPyObject *\nPyGcc_error(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    PyGccLocation *loc_obj;\n    const char *msg;\n    const char *keywords[] = {\"location\",\n                              \"message\",\n                              NULL};\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"O!s:error\", (char**)keywords,\n                                     &PyGccLocation_TypeObj, &loc_obj,\n                                     &msg)) {\n        return NULL;\n    }\n\n    gcc_error_at(loc_obj->loc, msg);\n\n    Py_RETURN_NONE;\n}\n\nPyObject *\nPyGcc_warning(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    PyGccLocation *loc_obj;\n    const char *msg;\n    PyObject *opt_obj = &_Py_NoneStruct;\n    int opt_code;\n    const char *keywords[] = {\"location\",\n                              \"message\",\n                              \"option\",\n                              NULL};\n    bool was_reported;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"O!s|O:warning\", (char**)keywords,\n\n                                     /* code \"O!\": */\n                                     &PyGccLocation_TypeObj, &loc_obj,\n                                     /* code: \"s\": */\n                                     &msg,\n\n                                     /* optional args: */\n                                     /* code: \"O\": */\n                                     &opt_obj)) {\n        return NULL;\n    }\n\n    assert(opt_obj);\n\n    /* If a gcc.Option was given, extract the code: */\n    if (Py_TYPE(opt_obj) == (PyTypeObject*)&PyGccOption_TypeObj) {\n        opt_code = ((PyGccOption*)opt_obj)->opt.inner;\n\n        /* Ugly workaround; see this function: */\n        if (0 == PyGcc_option_is_enabled((enum opt_code)opt_code)) {\n            return PyBool_FromLong(0);\n        }\n\n    } else {\n        if (opt_obj == &_Py_NoneStruct) {\n            /* No gcc.Option given: an unconditionally enabled warning: */\n            opt_code = 0;\n        } else {\n            /* Some other object was given: */\n            return PyErr_Format(PyExc_TypeError,\n                                (\"option must be either None,\"\n                                 \" or of type gcc.Option\"));\n        }\n    }\n\n    was_reported = warning_at(loc_obj->loc.inner, opt_code, \"%s\", msg);\n\n    return PyBool_FromLong(was_reported);\n}\n\nPyObject *\nPyGcc_inform(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    const char *msg;\n    const char *keywords[] = {\"location\",\n                              \"message\",\n                              NULL};\n#if (GCC_VERSION >= 6000)\n    PyObject *obj;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"Os:inform\", (char**)keywords,\n                                     &obj, &msg)) {\n        return NULL;\n    }\n\n    /* Check for location vs rich_location.  */\n    if (Py_TYPE (obj) == (PyTypeObject *)&PyGccLocation_TypeObj) {\n        PyGccLocation *loc_obj = (PyGccLocation *)obj;\n        gcc_inform(loc_obj->loc, msg);\n        Py_RETURN_NONE;\n    } else if (Py_TYPE (obj) == (PyTypeObject *)&PyGccRichLocation_TypeObj) {\n        PyGccRichLocation *richloc_obj = (PyGccRichLocation *)obj;\n#if (GCC_VERSION >= 8000)\n        inform (&richloc_obj->richloc, \"%s\", msg);\n#else\n        inform_at_rich_loc (&richloc_obj->richloc, \"%s\", msg);\n#endif\n        Py_RETURN_NONE;\n    } else {\n        return PyErr_Format(PyExc_TypeError,\n                            (\"type of location must be either gcc.Location\"\n                             \" or gcc.RichLocation\"));\n    }\n#else\n    PyGccLocation *loc_obj;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"O!s:inform\", (char**)keywords,\n                                     &PyGccLocation_TypeObj, &loc_obj,\n                                     &msg)) {\n        return NULL;\n    }\n\n    gcc_inform(loc_obj->loc, msg);\n\n    Py_RETURN_NONE;\n#endif\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-docs",
    "content": "#!/bin/sh\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Invoke \"show-docs.py\", with a dummy source file\n./gcc-with-python examples/show-docs.py test.c\n\n"
  },
  {
    "path": "gcc-python-function.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n\n/*\n  \"struct function\" is declared in function.h, c.f.:\n      struct GTY(()) function {\n           ... snip ...\n      };\n*/\n\n#include \"function.h\"\n#include \"gcc-c-api/gcc-function.h\"\n\nPyObject *\nPyGccFunction_repr(struct PyGccFunction * self)\n{\n     const char *name = NULL;\n     PyObject *result = NULL;\n     tree decl;\n\n     assert(self->fun.inner);\n     decl = self->fun.inner->decl;\n     if (DECL_NAME(decl)) {\n         name = IDENTIFIER_POINTER (DECL_NAME(decl));\n     } else {\n         name = \"(unnamed)\";\n     }\n\n     if (!name) {\n         goto error;\n     }\n\n     result = PyGccString_FromFormat(\"gcc.Function('%s')\",\n                                            name);\n     return result;\nerror:\n     Py_XDECREF(result);\n     return NULL;\n}\n\nlong\nPyGccFunction_hash(struct PyGccFunction * self)\n{\n    return (long)self->fun.inner;\n}\n\nPyObject *\nPyGccFunction_richcompare(PyObject *o1, PyObject *o2, int op)\n{\n    struct PyGccFunction *functionobj1;\n    struct PyGccFunction *functionobj2;\n    int cond;\n    PyObject *result_obj;\n\n    if (!PyObject_TypeCheck(o1, (PyTypeObject*)&PyGccFunction_TypeObj)) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n    if (!PyObject_TypeCheck(o2, (PyTypeObject*)&PyGccFunction_TypeObj)) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n\n    functionobj1 = (struct PyGccFunction *)o1;\n    functionobj2 = (struct PyGccFunction *)o2;\n\n    switch (op) {\n    case Py_EQ:\n\tcond = (functionobj1->fun.inner == functionobj2->fun.inner);\n\tbreak;\n\n    case Py_NE:\n\tcond = (functionobj1->fun.inner != functionobj2->fun.inner);\n\tbreak;\n\n    default:\n        result_obj = Py_NotImplemented;\n        goto out;\n    }\n    result_obj = cond ? Py_True : Py_False;\n\n out:\n    Py_INCREF(result_obj);\n    return result_obj;\n}\n\nPyObject *\nPyGccFunction_New(gcc_function func)\n{\n    struct PyGccFunction *obj;\n\n    if (!func.inner) {\n\tPy_RETURN_NONE;\n    }\n\n#if 0\n    printf(\"PyGccFunction_New(%p)\\n\", fun);\n    \n    printf(\"struct eh_status *eh: %p\\n\", fun->eh);\n    printf(\"struct control_flow_graph *cfg: %p\\n\", fun->cfg);\n    printf(\"struct gimple_seq_d *gimple_body: %p\\n\", fun->gimple_body);\n    printf(\"struct gimple_df *gimple_df: %p\\n\", fun->gimple_df);\n    printf(\"struct loops *x_current_loops: %p\\n\", fun->x_current_loops);\n    printf(\"struct stack_usage *su: %p\\n\", fun->su);\n #if 0\n    printf(\"htab_t GTY((skip)) value_histogram\\n\");\n    printf(\"tree decl: %p;\\n\", fun->decl);\n    printf(\"tree static_chain_decl;\\n\");\n    printf(\"tree nonlocal_goto_save_area;\\n\");\n    printf(\"VEC(tree,gc) *local_decls: local_decls;\\n\");\n    printf(\"struct machine_function * GTY ((maybe_undef)) machine;\\n\");\n    printf(\"struct language_function * language;\\n\");\n    printf(\"htab_t GTY ((param_is (union tree_node))) used_types_hash;\\n\");\n    printf(\"int last_stmt_uid;\\n\");\n    printf(\"int funcdef_no;\\n\");\n    printf(\"location_t function_start_locus;\\n\");\n    printf(\"location_t function_end_locus;\\n\");\n    printf(\"unsigned int curr_properties;\\n\");\n    printf(\"unsigned int last_verified;\\n\");\n    printf(\"const char * GTY((skip)) cannot_be_copied_reason;\\n\");\n\n    printf(\"unsigned int va_list_gpr_size : 8;\\n\");\n    printf(\"unsigned int va_list_fpr_size : 8;\\n\");\n    printf(\"unsigned int calls_setjmp : 1;\\n\");\n    printf(\"unsigned int calls_alloca : 1;\\n\");\n    printf(\"unsigned int has_nonlocal_label : 1;\\n\");\n    printf(\"unsigned int cannot_be_copied_set : 1;\\n\");\n    printf(\"unsigned int stdarg : 1;\\n\");\n    printf(\"unsigned int dont_save_pending_sizes_p : 1;\\n\");\n    printf(\"unsigned int after_inlining : 1;\\n\");\n    printf(\"unsigned int always_inline_functions_inlined : 1;\\n\");\n    printf(\"unsigned int can_throw_non_call_exceptions : 1;\\n\");\n\n    printf(\"unsigned int returns_struct : 1;\\n\");\n    printf(\"unsigned int returns_pcc_struct : 1;\\n\");\n    printf(\"unsigned int after_tree_profile : 1;\\n\");\n    printf(\"unsigned int has_local_explicit_reg_vars : 1;\\n\");\n    printf(\"unsigned int is_thunk : 1;\\n\");\n #endif\n#endif\n\n    obj = PyGccWrapper_New(struct PyGccFunction, &PyGccFunction_TypeObj);\n    if (!obj) {\n        goto error;\n    }\n\n    obj->fun = func;\n\n    return (PyObject*)obj;\n      \nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccFunction(PyGccFunction *wrapper)\n{\n    /* Mark the underlying object (recursing into its fields): */\n    gcc_function_mark_in_use(wrapper->fun);\n}\n\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-gimple.c",
    "content": "/*\n   Copyright 2011-2013, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-python-compat.h\"\n#include \"gcc-python-closure.h\"\n#include \"gimple.h\"\n\n/* gimple_phi_arg_def etc were in tree-flow-inline.h prior to 4.9, when they\n   moved to gimple.h  */\n#if (GCC_VERSION < 4009)\n#include \"tree-flow.h\"\n#include \"tree-flow-inline.h\"\n#endif\n\n/*\n   Needed for pp_gimple_stmt_1 for gcc 4.8+;\n   this header didn't exist in gcc 4.6:\n */\n#if (GCC_VERSION >= 4008)\n#include \"gimple-pretty-print.h\"\n#endif\n\n#include \"gcc-c-api/gcc-gimple.h\"\n\n/* GCC 4.9 moved struct walk_stmt_info into the new header gimple-walk.h,\n   which in turn needs the new header gimple-iterator.h: */\n#if (GCC_VERSION >= 4009)\n#include \"gimple-iterator.h\"\n#include \"gimple-walk.h\"\n#endif\n\ngcc_gimple_asm\nPyGccGimple_as_gcc_gimple_asm(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_asm(self->stmt);\n}\n\ngcc_gimple_assign\nPyGccGimple_as_gcc_gimple_assign(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_assign(self->stmt);\n}\n\ngcc_gimple_call\nPyGccGimple_as_gcc_gimple_call(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_call(self->stmt);\n}\n\ngcc_gimple_return\nPyGccGimple_as_gcc_gimple_return(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_return(self->stmt);\n}\n\ngcc_gimple_cond\nPyGccGimple_as_gcc_gimple_cond(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_cond(self->stmt);\n}\n\ngcc_gimple_phi\nPyGccGimple_as_gcc_gimple_phi(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_phi(self->stmt);\n}\n\ngcc_gimple_switch\nPyGccGimple_as_gcc_gimple_switch(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_switch(self->stmt);\n}\n\ngcc_gimple_label\nPyGccGimple_as_gcc_gimple_label(struct PyGccGimple *self)\n{\n    return gcc_gimple_as_gcc_gimple_label(self->stmt);\n}\n\nstatic PyObject *\ndo_pretty_print(struct PyGccGimple * self, int spc, dump_flags_t flags)\n{\n    PyObject *ppobj = PyGccPrettyPrinter_New();\n    PyObject *result = NULL;\n    if (!ppobj) {\n\treturn NULL;\n    }\n\n    /*\n      gcc 4.8 renamed \"dump_gimple_stmt\" to \"pp_gimple_stmt_1\"\n      (in r191884).  Declaration is in gimple-pretty-print.h\n    */\n#if (GCC_VERSION >= 4008)\n    pp_gimple_stmt_1(PyGccPrettyPrinter_as_pp(ppobj),\n                     self->stmt.inner,\n                     spc, flags);\n#else\n    dump_gimple_stmt(PyGccPrettyPrinter_as_pp(ppobj),\n                     self->stmt.inner,\n                     spc, flags);\n#endif\n\n    result = PyGccPrettyPrinter_as_string(ppobj);\n    if (!result) {\n\tgoto error;\n    }\n    \n    Py_XDECREF(ppobj);\n    return result;\n    \n error:\n    Py_XDECREF(ppobj);\n    return NULL;\n}\n\nPyObject *\nPyGccGimple_repr(struct PyGccGimple * self)\n{\n    return PyGccString_FromFormat(\"%s()\", Py_TYPE(self)->tp_name);\n}\n\nPyObject *\nPyGccGimple_str(struct PyGccGimple * self)\n{\n    return do_pretty_print(self, 0, (dump_flags_t)0);\n}\n\nlong\nPyGccGimple_hash(struct PyGccGimple * self)\n{\n    return (long)self->stmt.inner;\n}\n\nPyObject *\nPyGccGimple_richcompare(PyObject *o1, PyObject *o2, int op)\n{\n    struct PyGccGimple *gimpleobj1;\n    struct PyGccGimple *gimpleobj2;\n    int cond;\n    PyObject *result_obj;\n\n    if (!PyObject_TypeCheck(o1, (PyTypeObject*)&PyGccGimple_TypeObj)) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n    if (!PyObject_TypeCheck(o2, (PyTypeObject*)&PyGccGimple_TypeObj)) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n\n    gimpleobj1 = (struct PyGccGimple *)o1;\n    gimpleobj2 = (struct PyGccGimple *)o2;\n\n    switch (op) {\n    case Py_EQ:\n\tcond = (gimpleobj1->stmt.inner == gimpleobj2->stmt.inner);\n\tbreak;\n\n    case Py_NE:\n\tcond = (gimpleobj1->stmt.inner != gimpleobj2->stmt.inner);\n\tbreak;\n\n    default:\n        result_obj = Py_NotImplemented;\n        goto out;\n    }\n    result_obj = cond ? Py_True : Py_False;\n\n out:\n    Py_INCREF(result_obj);\n    return result_obj;\n}\n\nstatic tree\ngimple_walk_tree_callback(tree *tree_ptr, int *walk_subtrees, void *data)\n{\n    struct walk_stmt_info *wi = (struct walk_stmt_info*)data;\n    struct callback_closure *closure = (struct callback_closure *)wi->info;\n    PyObject *tree_obj = NULL;\n    PyObject *args = NULL;\n    PyObject *result = NULL;\n\n    assert(closure);\n    assert(*tree_ptr);\n    tree_obj = PyGccTree_New(gcc_private_make_tree(*tree_ptr));\n    if (!tree_obj) {\n        goto error;\n    }\n\n    args = PyGcc_Closure_MakeArgs(closure, 0, tree_obj);\n    if (!args) {\n        goto error;\n    }\n\n    /* Invoke the python callback: */\n    result = PyObject_Call(closure->callback, args, closure->kwargs);\n    if (!result) {\n        goto error;\n    }\n\n    Py_DECREF(tree_obj);\n    Py_DECREF(args);\n\n    if (PyObject_IsTrue(result)) {\n        Py_DECREF(result);\n        return *tree_ptr;\n    } else {\n        Py_DECREF(result);\n        return NULL;\n    }\n\n error:\n    /* On an exception, terminate the traversal: */\n    *walk_subtrees = 0;\n    Py_XDECREF(tree_obj);\n    Py_XDECREF(args);\n    Py_XDECREF(result);\n    return NULL;\n}\n\nPyObject *\nPyGccGimple_walk_tree(struct PyGccGimple * self, PyObject *args, PyObject *kwargs)\n{\n    PyObject *callback;\n    PyObject *extraargs = NULL;\n    struct callback_closure *closure;\n    tree result;\n    struct walk_stmt_info wi;\n\n    callback = PyTuple_GetItem(args, 0);\n    extraargs = PyTuple_GetSlice(args, 1, PyTuple_Size(args));\n\n    closure = PyGcc_closure_new_generic(callback, extraargs, kwargs);\n    if (!closure) {\n        Py_DECREF(callback);\n        Py_DECREF(extraargs);\n        return NULL;\n    }\n\n    memset(&wi, 0, sizeof(wi));\n    wi.info = closure;\n\n    result = walk_gimple_op (self->stmt.inner,\n                             gimple_walk_tree_callback,\n                             &wi);\n\n    PyGcc_closure_free(closure);\n\n    /* Propagate exceptions: */\n    if (PyErr_Occurred()) {\n        return NULL;\n    }\n\n    return PyGccTree_New(gcc_private_make_tree(result));\n}\n\nPyObject *\nPyGccGimple_get_rhs(struct PyGccGimple *self, void *closure)\n{\n    PyObject * result = NULL;\n    unsigned int i;\n\n    assert(gimple_has_ops(self->stmt.inner));\n\n    assert(gimple_num_ops(self->stmt.inner) > 0);\n    result = PyList_New(gimple_num_ops (self->stmt.inner) - 1);\n    if (!result) {\n\tgoto error;\n    }\n    \n    for (i = 1 ; i < gimple_num_ops(self->stmt.inner); i++) {\n\ttree t = gimple_op(self->stmt.inner, i);\n\tPyObject *obj = PyGccTree_New(gcc_private_make_tree(t));\n\tif (!obj) {\n\t    goto error;\n\t}\n\tPyList_SetItem(result, i-1, obj);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\nPyObject *\nPyGccGimple_get_str_no_uid(struct PyGccGimple *self, void *closure)\n{\n    return do_pretty_print(self, 0, TDF_NOUID);\n}\n\nIMPL_APPENDER(add_tree_to_list,\n              gcc_tree,\n              PyGccTree_New)\n\nPyObject *\nPyGccGimpleCall_get_args(struct PyGccGimple *self, void *closure)\n{\n    IMPL_LIST_MAKER(gcc_gimple_call_for_each_arg,\n                    PyGccGimple_as_gcc_gimple_call(self),\n                    add_tree_to_list)\n}\n\nPyObject *\nPyGccGimpleLabel_repr(PyObject *self)\n{\n    PyObject *label_repr = NULL;\n    PyObject *result = NULL;\n\n    label_repr = PyGcc_GetReprOfAttribute(self, \"label\");\n    if (!label_repr) {\n        goto cleanup;\n    }\n\n    result = PyGccString_FromFormat(\"%s(label=%s)\",\n                                           Py_TYPE(self)->tp_name,\n                                           PyGccString_AsString(label_repr));\n\n cleanup:\n    Py_XDECREF(label_repr);\n\n    return result;\n}\n\n\nPyObject *\nPyGccGimplePhi_get_args(struct PyGccGimple *self, void *closure)\n{\n    /* See e.g. gimple-pretty-print.c:dump_gimple_phi */\n    PyObject * result = NULL;\n    int num_args = gimple_phi_num_args (self->stmt.inner);\n    int i;\n\n    result = PyList_New(num_args);\n    if (!result) {\n        goto error;\n    }\n\n    for (i = 0 ; i < num_args; i++) {\n        tree arg_def = gimple_phi_arg_def(self->stmt.inner, i);\n        edge arg_edge = gimple_phi_arg_edge(AS_A_GPHI(self->stmt.inner), i);\n        /* fwiw, there's also gimple_phi_arg_has_location and gimple_phi_arg_location */\n        PyObject *tuple_obj;\n        tuple_obj = Py_BuildValue(\"O&O&\",\n                                  PyGccTree_New, arg_def,\n                                  PyGccEdge_New, arg_edge);\n        if (!tuple_obj) {\n            goto error;\n        }\n        PyList_SET_ITEM(result, i, tuple_obj);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\nIMPL_APPENDER(add_case_label_expr_to_list,\n              gcc_case_label_expr,\n              PyGccCaseLabelExpr_New)\n\nPyObject *\nPyGccGimpleSwitch_get_labels(struct PyGccGimple *self, void *closure)\n{\n    IMPL_LIST_MAKER(gcc_gimple_switch_for_each_label,\n                    PyGccGimple_as_gcc_gimple_switch(self),\n                    add_case_label_expr_to_list)\n}\n\n\n/*\n   Ensure we have a unique PyGccGimple per gimple address (by maintaining a dict):\n*/\nstatic PyObject *gimple_wrapper_cache = NULL;\n\nunion gcc_gimple_or_ptr {\n    gcc_gimple stmt;\n    void *ptr;\n};\n\nstatic PyObject *\nreal_make_gimple_wrapper(void *ptr)\n{\n    union gcc_gimple_or_ptr u;\n    u.ptr = ptr;\n    struct PyGccGimple *gimple_obj = NULL;\n    PyGccWrapperTypeObject* tp;\n  \n    tp = PyGcc_autogenerated_gimple_type_for_stmt(u.stmt);\n    assert(tp);\n    //printf(\"tp:%p\\n\", tp);\n  \n    gimple_obj = PyGccWrapper_New(struct PyGccGimple, tp);\n    if (!gimple_obj) {\n        goto error;\n    }\n\n    gimple_obj->stmt = u.stmt;\n\n    return (PyObject*)gimple_obj;\n      \nerror:\n    return NULL;\n}\n\nPyObject*\nPyGccGimple_New(gcc_gimple stmt)\n{\n    union gcc_gimple_or_ptr u;\n    u.stmt = stmt;\n    return PyGcc_LazilyCreateWrapper(&gimple_wrapper_cache,\n\t\t\t\t\t    u.ptr,\n\t\t\t\t\t    real_make_gimple_wrapper);\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccGimple(PyGccGimple *wrapper)\n{\n    gcc_gimple_mark_in_use(wrapper->stmt);\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-location.c",
    "content": "/*\n   Copyright 2011-2013, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-c-api/gcc-location.h\"\n\n/*\n  Wrapper for GCC's \"location_t\"\n\n  GCC's input.h has: \n    typedef source_location location_t;\n\n  GCC's line-map.h has:\n      A logical line/column number, i.e. an \"index\" into a line_map:\n          typedef unsigned int source_location;\n*/\n\n#if (GCC_VERSION >= 7000)\n\nint\nPyGccLocation_init(PyGccLocation *self, PyObject *args, PyObject *kwargs)\n{\n    const char *keywords[] = {\"caret\", \"start\", \"finish\",\n                              NULL};\n    PyGccLocation *caret_obj;\n    PyGccLocation *start_obj;\n    PyGccLocation *finish_obj;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"O!O!O!\", (char**)keywords,\n                                     &PyGccLocation_TypeObj, &caret_obj,\n                                     &PyGccLocation_TypeObj, &start_obj,\n                                     &PyGccLocation_TypeObj, &finish_obj)) {\n        return -1;\n    }\n\n    self->loc\n        = gcc_private_make_location (make_location (caret_obj->loc.inner,\n                                                    start_obj->loc.inner,\n                                                    finish_obj->loc.inner));\n\n    return 0;\n}\n\n#endif\n\nPyObject *\nPyGccLocation_repr(struct PyGccLocation * self)\n{\n     return PyGccString_FromFormat(\"gcc.Location(file='%s', line=%i)\",\n                                   gcc_location_get_filename(self->loc),\n                                   gcc_location_get_line(self->loc));\n}\n\nPyObject *\nPyGccLocation_str(struct PyGccLocation * self)\n{\n     return PyGccString_FromFormat(\"%s:%i\",\n                                   gcc_location_get_filename(self->loc),\n                                   gcc_location_get_line(self->loc));\n}\n\nPyObject *\nPyGccLocation_richcompare(PyObject *o1, PyObject *o2, int op)\n{\n    struct PyGccLocation *locobj1;\n    struct PyGccLocation *locobj2;\n    int cond;\n    PyObject *result_obj;\n    const char *file1;\n    const char *file2;\n\n    if (Py_TYPE(o1) != (PyTypeObject*)&PyGccLocation_TypeObj) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n\n    if (Py_TYPE(o2) != (PyTypeObject*)&PyGccLocation_TypeObj) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n\n    locobj1 = (struct PyGccLocation *)o1;\n    locobj2 = (struct PyGccLocation *)o2;\n\n    /* First compare by filename, then by line, then by column */\n    file1 = gcc_location_get_filename(locobj1->loc);\n    file2 = gcc_location_get_filename(locobj2->loc);\n\n    if (file1 != file2) {\n        /* Compare by file: */\n        switch (op) {\n        case Py_LT:\n        case Py_LE:\n            /* we merge the LT and LE cases since we've already\n               established that the values are not equal */\n            cond = (strcmp(file1, file2) < 0);\n            break;\n        case Py_GT:\n        case Py_GE:\n            cond = (strcmp(file1, file2) > 0);\n            break;\n        case Py_EQ:\n            cond = 0;\n            break;\n        case Py_NE:\n            cond = 1;\n            break;\n        default:\n            result_obj = Py_NotImplemented;\n            goto out;\n        }\n    } else {\n        /* File equality; compare by line: */\n        int line1 = gcc_location_get_line(locobj1->loc);\n        int line2 = gcc_location_get_line(locobj2->loc);\n\n        if (line1 != line2) {\n            switch (op) {\n            case Py_LT:\n            case Py_LE:\n                cond = (line1 < line2);\n                break;\n            case Py_GT:\n            case Py_GE:\n                cond = (line1 > line2);\n                break;\n            case Py_EQ:\n                cond = 0;\n                break;\n            case Py_NE:\n                cond = 1;\n                break;\n            default:\n                result_obj = Py_NotImplemented;\n                goto out;\n            }\n        } else {\n            /* File and line equality; compare by column: */\n            int col1 = gcc_location_get_column(locobj1->loc);\n            int col2 = gcc_location_get_column(locobj2->loc);\n\n            switch (op) {\n            case Py_LT:\n            case Py_LE:\n                cond = (col1 < col2);\n                break;\n            case Py_GT:\n            case Py_GE:\n                cond = (col1 > col2);\n                break;\n            case Py_EQ:\n                cond = (col1 == col2);\n                break;\n            case Py_NE:\n                cond = (col1 != col2);\n                break;\n            default:\n                result_obj = Py_NotImplemented;\n                goto out;\n            }\n        }\n    }\n\n    result_obj = cond ? Py_True : Py_False;\n\n out:\n    Py_INCREF(result_obj);\n    return result_obj;\n}\n\nlong\nPyGccLocation_hash(struct PyGccLocation * self)\n{\n    return self->loc.inner;\n}\n\n#if (GCC_VERSION >= 5000)\n\nPyObject *\nPyGccLocation_offset_column(PyGccLocation *self, PyObject *args)\n{\n    int offset;\n\n    if (!PyArg_ParseTuple(args, \"i\", &offset)) {\n        return NULL;\n    }\n\n    return PyGccLocation_New(gcc_location_offset_column(self->loc, offset));\n}\n\n#endif /* #if (GCC_VERSION >= 5000) */\n\nPyObject *\nPyGccLocation_New(gcc_location loc)\n{\n    struct PyGccLocation *location_obj = NULL;\n\n    if (gcc_location_is_unknown(loc)) {\n\tPy_RETURN_NONE;\n    }\n  \n    location_obj = PyGccWrapper_New(struct PyGccLocation,\n                                    &PyGccLocation_TypeObj);\n    if (!location_obj) {\n        goto error;\n    }\n\n    location_obj->loc = loc;\n\n    return (PyObject*)location_obj;\n      \nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccLocation(PyGccLocation *wrapper)\n{\n    /* empty */\n}\n\n\n/* rich_location. */\n\n#if (GCC_VERSION >= 6000)\n\nPyObject *\nPyGccRichLocation_add_fixit_replace(PyGccRichLocation *self, PyObject *args,\n                                    PyObject *kwargs)\n{\n    const char *keywords[] = {\"new_content\",\n                              NULL};\n    const char *new_content;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"s\", (char**)keywords,\n                                     &new_content)) {\n        return NULL;\n    }\n\n    self->richloc.add_fixit_replace (get_range_from_loc (line_table,\n                                                         self->richloc.get_loc (0)),\n                                     new_content);\n\n    Py_RETURN_NONE;\n}\n\nint\nPyGccRichLocation_init(PyGccRichLocation *self, PyObject *args,\n                       PyObject *kwargs)\n{\n    const char *keywords[] = {\"location\",\n                              NULL};\n    PyGccLocation *loc_obj;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"O!\", (char**)keywords,\n                                     &PyGccLocation_TypeObj, &loc_obj)) {\n        return -1;\n    }\n    // FIXME: also need a manual dtor call\n    new (&self->richloc) rich_location (line_table, loc_obj->loc.inner);\n    return 0;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccRichLocation(PyGccRichLocation *wrapper)\n{\n    /* empty */\n}\n\n#endif /* #if (GCC_VERSION >= 6000) */\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-option.c",
    "content": "/*\n   Copyright 2011, 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"c-common.h\" /* for warn_format */\n#include \"diagnostic.h\"\n\n\n/*\n  Wrapper for GCC's opts.h\n\n  opts.h declares:\n    extern const struct cl_option cl_options[];\n    extern const unsigned int cl_options_count;\n  which suggests that this table is fixed in place and thus not resizable.\n  (The definition is in the autogenerated DIR/gcc/options.c)\n\n  We specifically wrap:\n    enum opt_code\n  and use this to get at the associated \"struct cl_option\" within the\n  \"cl_options\" table.\n*/\n\nint\nPyGccOption_init(PyGccOption * self, PyObject *args, PyObject *kwargs)\n{\n    const char *text;\n    static const char *kwlist[] = {\"text\", NULL};\n    unsigned int i;\n\n    /*\n      We need to call _track manually as we're not using PyGccWrapper_New():\n    */\n    PyGccWrapper_Track(&self->head);\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"s\", (char**)kwlist,\n                                      &text)) {\n        return -1;\n    }\n\n    /* Search for text within cl_options */\n    for (i = 0; i < cl_options_count; i++) {\n        if (0 == strcmp(cl_options[i].opt_text, text)) {\n            self->opt = gcc_private_make_option((enum opt_code)i);\n            return 0; /* success */\n        }\n    }\n\n    /* Not found: */\n    PyErr_Format(PyExc_ValueError,\n                 \"Could not find command line argument with text '%s'\",\n                 text);\n    return -1;\n}\n\nPyObject *\nPyGccOption_repr(PyGccOption * self)\n{\n    return PyGccString_FromFormat(\"gcc.Option('%s')\",\n                                         PyGcc_option_to_cl_option(self)->opt_text);\n}\n\n/*\n  In GCC 4.6 and 4.7, \"warn_format\" is a global, declared in\n  c-family/c-common.h\n\n  In GCC 4.8, it became a macro in options.h to:\n      #define warn_format global_options.x_warn_format\n*/\n\n#if (GCC_VERSION < 4008)\n/*\n  Weakly import warn_format; it's not available in lto1\n  (during link-time optimization)\n*/\n__typeof__ (warn_format) warn_format __attribute__ ((weak));\n#endif\n\nint PyGcc_option_is_enabled(enum opt_code opt_code)\n{\n    /* Returns 1 if option OPT_IDX is enabled in OPTS, 0 if it is disabled,\n       or -1 if it isn't a simple on-off switch.  */\n#if (GCC_VERSION < 10000)\n    int i = option_enabled (opt_code, global_dc->option_state);\n#else\n    /* Starting with GCC 10, options can be distinguished by language. */\n    /* TODO Expose the lang_mask to the user. */\n    int i = option_enabled (opt_code, CL_LANG_ALL, global_dc->option_state);\n#endif\n\n    if (i == 1) {\n        return 1;\n    }\n    if (i == 0) {\n        return 0;\n    }\n\n    /* -1: we don't know */\n    /*\n      Ugly workaround to allow disabling warnings.\n\n      For many options, it doesn't seem to be possible to disable them\n      directly.\n\n      Specifically a cl_option with o.flag_var_offset == -1 will return NULL\n      from option_flag_var()\n\n      For these options, option_enabled() will return -1 signifying that \"it\n      isn't a simple on-off switch\".\n\n      diagnostic_report_diagnostic() uses\n         if (!option_enabled(...))\n            return false\n      to suppress disabled warnings.\n\n      However, -1 is true for the purpose of this test.\n\n      For GCC's own uses of the options, they are typically guarded by an\n      additional test.  For example, \"-Wformat\" sets \"warn_format\", and this\n      guards the formatting tests.\n     */\n    switch (opt_code) {\n    default:\n        /*  We don't know: */\n        return -1;\n\n#if (GCC_VERSION >= 4008)\n    case OPT_Wformat_:\n#else\n    case OPT_Wformat:\n#endif\n        return warn_format;\n    }\n}\n\nPyObject *\nPyGccOption_is_enabled(PyGccOption * self, void *closure)\n{\n    int i = PyGcc_option_is_enabled(self->opt.inner);\n\n    if (i == 1) {\n        return PyBool_FromLong(1);\n    }\n    if (i == 0) {\n        return PyBool_FromLong(0);\n    }\n\n    PyErr_Format(PyExc_NotImplementedError,\n                 \"The plugin does not know how to determine if gcc.Format('%s') is implemented\",\n                 PyGcc_option_to_cl_option(self)->opt_text);\n    return NULL;\n}\n\nconst struct cl_option*\nPyGcc_option_to_cl_option(PyGccOption * self)\n{\n    assert(self);\n    assert(self->opt.inner >= 0);\n    assert(self->opt.inner < cl_options_count);\n\n    return &cl_options[self->opt.inner];\n}\n\nPyObject *\nPyGccOption_New(gcc_option opt)\n{\n    struct PyGccOption *opt_obj = NULL;\n\n    opt_obj = PyGccWrapper_New(struct PyGccOption, &PyGccOption_TypeObj);\n    if (!opt_obj) {\n        goto error;\n    }\n\n    opt_obj->opt = opt;\n\n    return (PyObject*)opt_obj;\n\nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccOption(PyGccOption *wrapper)\n{\n    /* empty */\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-parameter.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n\n/* gcc 10 removed params.h */\n#if (GCC_VERSION < 10000)\n\n/*\n  Wrapper for GCC's params.h.\n  We specifically wrap \"compiler_param\" (a typedef to an enum)\n  and use this to get at the associated \"param_info\" struct\n*/\nPyObject *\nPyGccParameter_New(compiler_param param_num)\n{\n    struct PyGccParameter *param_obj = NULL;\n\n    param_obj = PyGccWrapper_New(struct PyGccParameter, &PyGccParameter_TypeObj);\n    if (!param_obj) {\n        goto error;\n    }\n\n    param_obj->param_num = param_num;\n\n    return (PyObject*)param_obj;\n\nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccParameter(PyGccParameter *wrapper)\n{\n    /* empty */\n}\n\n#endif\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-pass.c",
    "content": "/*\n   Copyright 2011-2013, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"diagnostic.h\"\n#include \"gcc-c-api/gcc-function.h\"\n#include \"gcc-c-api/gcc-location.h\"\n#if (GCC_VERSION >= 4009)\n#include \"context.h\"\n#include \"pass_manager.h\"\n#endif\n\n/*\n  Wrapper for GCC's (opt_pass *)\n*/\n\n/*\n   Ensure we have a unique PyGccPass per pass address (by maintaining a dict)\n\n   For passes defined in Python, this dictionary maps from\n   long (struct opt_pass *) to the gcc.Pass wrapper object for that pass\n\n   The references on the right-hand-side keep these wrappers alive\n*/\nstatic PyObject *pass_wrapper_cache = NULL;\n\nstatic bool impl_gate(function *fun)\n{\n    PyObject *pass_obj;\n    PyObject *cfun_obj = NULL;\n    PyObject* result_obj;\n    int result;\n    gcc_location saved_loc = gcc_get_input_location();\n\n    /*\n       It appears that current_pass is not set by when gcc (4.7 at least) when\n       it invokes gate for an IPA_PASS within execute_ipa_summary_passes\n       (in gcc/passes.c), so we don't have a way of figuring out which pass\n       we were called on.\n\n       Reported as http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54959\n    */\n    if (NULL == current_pass) {\n        return true;\n    }\n\n    assert(current_pass);\n    pass_obj = PyGccPass_New(current_pass);\n    assert(pass_obj); /* we own a ref at this point */\n\n    if (!PyObject_HasAttrString(pass_obj, \"gate\")) {\n        /* No \"gate\" method?  Always execute this pass: */\n        Py_DECREF(pass_obj);\n        return true;\n    }\n\n    /* Supply the function, if any */\n    if (fun) {\n        assert (fun == cfun);\n        gcc_function cf = gcc_get_current_function();\n\n        /* Temporarily override input_location to the top of the function: */\n        gcc_set_input_location(gcc_function_get_start(cf));\n        cfun_obj = PyGccFunction_New(cf);\n        if (!cfun_obj) {\n            PyGcc_PrintException(\"Unhandled Python exception raised calling 'gate' method\");\n            Py_DECREF(pass_obj);\n            gcc_set_input_location(saved_loc);\n            return false;\n        }\n        result_obj = PyObject_CallMethod(pass_obj, (char*)\"gate\", (char*)\"O\",\n                                         cfun_obj, NULL);\n    } else {\n        result_obj = PyObject_CallMethod(pass_obj, (char*)\"gate\", NULL);\n    }\n\n    Py_XDECREF(cfun_obj);\n    Py_DECREF(pass_obj);\n\n    if (!result_obj) {\n        PyGcc_PrintException(\"Unhandled Python exception raised calling 'gate' method\");\n        gcc_set_input_location(saved_loc);\n        return false;\n    }\n\n    result = PyObject_IsTrue(result_obj);\n    Py_DECREF(result_obj);\n    gcc_set_input_location(saved_loc);\n    return result;\n}\n\nstatic unsigned int impl_execute(function *fun)\n{\n    PyObject *pass_obj;\n    PyObject *cfun_obj = NULL;\n    PyObject* result_obj;\n    gcc_location saved_loc = gcc_get_input_location();\n\n    assert(current_pass);\n    pass_obj = PyGccPass_New(current_pass);\n    assert(pass_obj); /* we own a ref at this point */\n\n    if (fun) {\n        assert (fun == cfun);\n        gcc_function cf = gcc_get_current_function();\n\n        /* Temporarily override input_location to the top of the function: */\n        gcc_set_input_location(gcc_function_get_start(cf));\n        cfun_obj = PyGccFunction_New(cf);\n        if (!cfun_obj) {\n            PyGcc_PrintException(\"Unhandled Python exception raised calling 'execute' method\");\n            Py_DECREF(pass_obj);\n            gcc_set_input_location(saved_loc);\n            return false;\n        }\n        result_obj = PyObject_CallMethod(pass_obj, (char*)\"execute\",\n                                         (char*)\"O\", cfun_obj, NULL);\n    } else {\n        result_obj = PyObject_CallMethod(pass_obj, (char*)\"execute\", NULL);\n    }\n\n    Py_XDECREF(cfun_obj);\n    Py_DECREF(pass_obj);\n\n    if (!result_obj) {\n        PyGcc_PrintException(\"Unhandled Python exception raised calling 'execute' method\");\n        gcc_set_input_location(saved_loc);\n        return 0;\n    }\n\n    if (result_obj == Py_None) {\n        Py_DECREF(result_obj);\n        gcc_set_input_location(saved_loc);\n        return 0;\n    }\n\n#if PY_MAJOR_VERSION < 3\n    if (PyInt_Check(result_obj)) {\n        long result = PyInt_AS_LONG(result_obj);\n        Py_DECREF(result_obj);\n        gcc_set_input_location(saved_loc);\n        return result;\n    }\n#endif\n\n    if (PyLong_Check(result_obj)) {\n        long result = PyLong_AsLong(result_obj);\n        Py_DECREF(result_obj);\n        gcc_set_input_location(saved_loc);\n        return result;\n    }\n\n    PyErr_Format(PyExc_TypeError,\n                 \"execute returned a non-integer\"   \\\n                 \"(type %.200s)\",\n                 Py_TYPE(result_obj)->tp_name);\n    Py_DECREF(result_obj);\n    PyGcc_PrintException(\"Unhandled Python exception raised calling 'execute' method\");\n    gcc_set_input_location(saved_loc);\n    return 0;\n}\n\n#if (GCC_VERSION >= 4009)\n/*\n  GCC 4.9 converted passes to a C++ class hierarchy, with methods for gate\n  and execute.\n*/\n\n#if (GCC_VERSION >= 5000)\n/* GCC 5 added a \"fun\" param to the \"gate\" and \"execute\" vfuncs of\n   pass opt_pass.  */\n# define PASS_DECLARE_GATE_AND_EXECUTE                                  \\\n    bool gate (function *fun) { return impl_gate(fun); }                \\\n    unsigned int execute (function *fun) { return impl_execute(fun); }\n#else\n/* ...whereas in GCC 4.9 they took no params, with cfun being implied.  */\n# define PASS_DECLARE_GATE_AND_EXECUTE                            \\\n    bool gate () { return impl_gate(cfun); }                      \\\n    unsigned int execute () { return impl_execute(cfun); }\n#endif /* #if (GCC_VERSION >= 5000) */\n\nclass PyGccGimplePass : public gimple_opt_pass\n{\npublic:\n PyGccGimplePass(const pass_data& data, gcc::context *ctxt) :\n    gimple_opt_pass(data, ctxt)\n {\n }\n\n  PASS_DECLARE_GATE_AND_EXECUTE\n  opt_pass *clone() {return this; }\n};\n\nclass PyGccRtlPass : public rtl_opt_pass\n{\npublic:\n  PyGccRtlPass (const pass_data& data, gcc::context *ctxt)\n    : rtl_opt_pass (data, ctxt)\n  {\n  }\n\n  PASS_DECLARE_GATE_AND_EXECUTE\n  opt_pass *clone() {return this; }\n};\n\nclass PyGccIpaPass : public ipa_opt_pass_d\n{\npublic:\n  PyGccIpaPass(const pass_data& data, gcc::context *ctxt)\n      : ipa_opt_pass_d (data, ctxt,\n                        NULL, /* void (*generate_summary) (void), */\n                        NULL, /* void (*write_summary) (void), */\n                        NULL, /* void (*read_summary) (void), */\n                        NULL, /* void (*write_optimization_summary) (void), */\n                        NULL, /* void (*read_optimization_summary) (void), */\n                        NULL, /* void (*stmt_fixup) (struct cgraph_node *, gimple *), */\n                        0, /* unsigned int function_transform_todo_flags_start, */\n                        NULL, /* unsigned int (*function_transform) (struct cgraph_node *), */\n                        NULL) /* void (*variable_transform) (struct varpool_node *)) */\n  {\n  }\n\n  PASS_DECLARE_GATE_AND_EXECUTE\n  opt_pass *clone() {return this; }\n};\n\nclass PyGccSimpleIpaPass : public simple_ipa_opt_pass\n{\npublic:\n  PyGccSimpleIpaPass(const pass_data& data, gcc::context *ctxt)\n    : simple_ipa_opt_pass(data, ctxt)\n  {\n  }\n\n  PASS_DECLARE_GATE_AND_EXECUTE\n  opt_pass *clone() {return this; }\n};\n\n#else /* #if (GCC_VERSION >= 4009) */\n/*\n  Before GCC 4.9, passes were implemented using callback functions.\n*/\nstatic bool gate_cb(void)\n{\n    return impl_gate(cfun);\n}\n\nstatic unsigned int execute_cb(void)\n{\n    return impl_execute(cfun);\n}\n#endif /* #else clause of if (GCC_VERSION >= 4009) */\n\nstatic int\ndo_pass_init(PyObject *s, PyObject *args, PyObject *kwargs,\n             enum opt_pass_type pass_type,\n             size_t sizeof_pass)\n{\n    struct PyGccPass *self = (struct PyGccPass *)s;\n    const char *name;\n    const char *keywords[] = {\"name\",\n                              NULL};\n    struct opt_pass *pass;\n\n    /*\n      We need to call _track manually as we're not using PyGccWrapper_New():\n    */\n    PyGccWrapper_Track(&self->head);\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"s:gcc.Pass.__init__\", (char**)keywords,\n                                     &name)) {\n        return -1;\n    }\n\n#if (GCC_VERSION >= 4009)\n    pass_data pass_data;\n    memset(&pass_data, 0, sizeof(pass_data));\n    pass_data.type = pass_type;\n    pass_data.name = PyGcc_strdup(name);\n#if (GCC_VERSION < 5000)\n    pass_data.has_gate = true;\n    pass_data.has_execute = true;\n#endif\n    switch (pass_type) {\n      case GIMPLE_PASS:\n          pass = new PyGccGimplePass (pass_data, g);\n          break;\n      case RTL_PASS:\n          pass = new PyGccRtlPass (pass_data, g);\n          break;\n      case SIMPLE_IPA_PASS:\n          pass = new PyGccSimpleIpaPass (pass_data, g);\n          break;\n      case IPA_PASS:\n          pass = new PyGccIpaPass (pass_data, g);\n          break;\n      default:\n          gcc_unreachable();\n    }\n#else /* #if (GCC_VERSION >= 4009) */\n    pass = (struct opt_pass*)PyMem_Malloc(sizeof_pass);\n    if (!pass) {\n        return -1;\n    }\n    memset(pass, 0, sizeof_pass);\n    pass->type = pass_type;\n\n    pass->name = PyGcc_strdup(name);\n    /* does the name need to be unique?\n       mapping from opt_pass ptr to callable?\n       (the ID (as a long) is unique)\n    */\n    if (!pass->name) {\n        PyMem_Free(pass);\n        return -1;\n    }\n\n    pass->gate = gate_cb;\n    pass->execute = execute_cb;\n#endif /* ending the #else clause of #if (GCC_VERSION >= 4009) */\n\n    if (PyGcc_insert_new_wrapper_into_cache(&pass_wrapper_cache,\n                                                 pass,\n                                                 s)) {\n        return -1;\n    }\n\n    self->pass = pass;\n    return 0; // FIXME\n}\n\nint\nPyGccGimplePass_init(PyObject *self, PyObject *args, PyObject *kwds)\n{\n    return do_pass_init(self, args, kwds,\n                        GIMPLE_PASS,\n                        sizeof(struct gimple_opt_pass));\n}\n\nint\nPyGccRtlPass_init(PyObject *self, PyObject *args, PyObject *kwds)\n{\n    return do_pass_init(self, args, kwds,\n                        RTL_PASS,\n                        sizeof(struct rtl_opt_pass));\n}\n\nint\nPyGccSimpleIpaPass_init(PyObject *self, PyObject *args, PyObject *kwds)\n{\n    return do_pass_init(self, args, kwds,\n                        SIMPLE_IPA_PASS,\n                        sizeof(struct simple_ipa_opt_pass));\n}\n\nint\nPyGccIpaPass_init(PyObject *self, PyObject *args, PyObject *kwds)\n{\n    return do_pass_init(self, args, kwds,\n                        IPA_PASS,\n                        sizeof(struct ipa_opt_pass_d));\n}\n\n\n\nPyObject *\nPyGccPass_repr(struct PyGccPass *self)\n{\n     return PyGccString_FromFormat(\"%s(name='%s')\",\n                                          Py_TYPE(self)->tp_name,\n                                          self->pass->name);\n}\n\n#if (GCC_VERSION >= 4009)\nstatic struct dump_file_info *\nget_dump_file_info(int phase)\n{\n    gcc::dump_manager *dumps = g->get_dumps ();\n    return dumps->get_dump_file_info (phase);\n}\n#endif\n\n/* In GCC 4.8, dump_enabled_p changed from acting on one pass to the\n   current phase (as of r192773), and dump_phase_enabled_p() was added (as\n   of r192692).\n\n   Unfortunately, dump_phase_enabled_p() is static within gcc/dumpfile.c,\n   so we use a copy of the 2 lines of relevant code:\n*/\nstatic bool\nis_dump_enabled(struct opt_pass *pass)\n{\n#if (GCC_VERSION >= 4008)\n    struct dump_file_info *dfi = get_dump_file_info(pass->static_pass_number);\n    return dfi->pstate || dfi->alt_state;\n#else\n    return dump_enabled_p(pass->static_pass_number);\n#endif\n}\n\nPyObject *\nPyGccPass_get_dump_enabled(struct PyGccPass *self, void *closure)\n{\n    return PyBool_FromLong(is_dump_enabled(self->pass));\n}\n\n/* In GCC 4.8, this field became \"pstate\" */\n#if (GCC_VERSION >= 4008)\n  #define DFI_STATE(dfi) (dfi)->pstate\n#else\n  #define DFI_STATE(dfi) (dfi)->state\n#endif\n\nint\nPyGccPass_set_dump_enabled(struct PyGccPass *self, PyObject *value, void *closure)\n{\n    struct dump_file_info *dfi = get_dump_file_info (self->pass->static_pass_number);\n    assert(dfi);\n\n    int newbool = PyObject_IsTrue(value);\n    if (newbool == -1) {\n        return -1;\n    }\n\n    if (DFI_STATE (dfi) == 0) {\n        /* Dumping was disabled: */\n        if (newbool) {\n            /* Enabling: */\n            DFI_STATE (dfi) = -1;\n            return 0;\n        } else {\n            /* No change: */\n            return 0;\n        }\n    } else {\n        if (DFI_STATE (dfi) < 0) {\n            /* Dumping was enabled but has not yet started */\n            if (newbool) {\n                /* No change: */\n                return 0;\n            } else {\n                /* Disabling: */\n                DFI_STATE (dfi) = 0;\n                return 0;\n            }\n        } else {\n            assert(DFI_STATE (dfi) > 0);\n            /* Dumping was enabled and has already started */\n            if (newbool) {\n                /* No change: */\n                return 0;\n            } else {\n                /* Can't disable after it's started: */\n                PyErr_SetString(PyExc_RuntimeError,\n                                \"Can't disable dumping: already started\");\n                return -1;\n            }\n        }\n    }\n}\n\n/* In GCC 4.9, passes moved from being globals to fields of the\n   pass_manager.  */\n#if (GCC_VERSION >= 4009)\n#define GET_PASS_LIST(PASS_NAME) (g->get_passes()->PASS_NAME)\n#else\n#define GET_PASS_LIST(PASS_NAME) (PASS_NAME)\n#endif\n\n\nPyObject *\nPyGccPass_get_roots(PyObject *cls, PyObject *noargs)\n{\n    /*\n      There are 5 \"roots\" for the pass tree; see gcc/passes.c\n    */\n    PyObject *result;\n    PyObject *passobj;\n\n    result = PyTuple_New(5);\n    if (!result) {\n        goto error;\n    }\n\n#define SET_PASS(IDX, PASS_NAME) \\\n    passobj = PyGccPass_New(GET_PASS_LIST(PASS_NAME)); \\\n    if (!passobj) goto error;                  \\\n    PyTuple_SET_ITEM(result, IDX, passobj);    \\\n    (void)0;\n\n    SET_PASS(0, all_lowering_passes);\n    SET_PASS(1, all_small_ipa_passes);\n    SET_PASS(2, all_regular_ipa_passes);\n    /* all_late_ipa_passes appeared in r175336 */\n    /* r204984 eliminated all_lto_gen_passes */\n#if (GCC_VERSION >= 4009)\n    SET_PASS(3, all_late_ipa_passes);\n#else\n    SET_PASS(3, all_lto_gen_passes);\n#endif\n    SET_PASS(4, all_passes);\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n\n}\n\nstatic struct opt_pass *\nfind_pass_by_name(const char *name, struct opt_pass *pass_list)\n{\n    struct opt_pass *pass;\n\n    for (pass = pass_list; pass; pass = pass->next)\n    {\n        if (pass->name && !strcmp (name, pass->name)) {\n            /* Found: */\n            return pass;\n        }\n\n        if (pass->sub) {\n            /* Recurse: */\n            struct opt_pass *result = find_pass_by_name(name, pass->sub);\n            if (result) {\n                return result;\n            }\n        }\n    }\n\n    /* Not found: */\n    return NULL;\n}\n\n\nPyObject *\nPyGccPass_get_by_name(PyObject *cls, PyObject *args, PyObject *kwargs)\n{\n    const char *name;\n    const char *keywords[] = {\"name\",\n                              NULL};\n    struct opt_pass *result;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"s:get_by_name\", (char**)keywords,\n                                     &name)) {\n        return NULL;\n    }\n\n#define SEARCH_WITHIN_LIST(PASS_LIST) \\\n    result = find_pass_by_name(name, (GET_PASS_LIST(PASS_LIST))); \\\n    if (result) {                                    \\\n        return PyGccPass_New(result); \\\n    }\n\n    SEARCH_WITHIN_LIST(all_lowering_passes);\n    SEARCH_WITHIN_LIST(all_small_ipa_passes);\n    SEARCH_WITHIN_LIST(all_regular_ipa_passes);\n    /* all_late_ipa_passes appeared in r175336 */\n    /* r204984 eliminated all_lto_gen_passes */\n#if (GCC_VERSION >= 4009)\n    SEARCH_WITHIN_LIST(all_late_ipa_passes);\n#else\n    SEARCH_WITHIN_LIST(all_lto_gen_passes);\n#endif\n    SEARCH_WITHIN_LIST(all_passes);\n\n    /* Not found: */\n    PyErr_Format(PyExc_ValueError, \"pass named '%s' not found\", name);\n    return NULL;\n}\n\nstatic PyObject *\nimpl_register(struct PyGccPass *self, PyObject *args, PyObject *kwargs,\n              enum pass_positioning_ops pos_op, const char *arg_format)\n{\n    struct register_pass_info rpi;\n    const char *keywords[] = {\"name\",\n                              \"instance_number\",\n                              NULL};\n\n    rpi.pass = self->pass;\n    rpi.pos_op = pos_op;\n    rpi.ref_pass_instance_number = 0;\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     arg_format, (char**)keywords,\n                                     &rpi.reference_pass_name,\n                                     &rpi.ref_pass_instance_number)) {\n        return NULL;\n    }\n\n    /* (Failures lead to a fatal error) */\n    register_pass (&rpi);\n\n    Py_RETURN_NONE;\n}\n\nPyObject *\nPyGccPass_register_before(struct PyGccPass *self, PyObject *args, PyObject *kwargs)\n{\n    return impl_register(self, args, kwargs,\n                         PASS_POS_INSERT_BEFORE,\n                         \"s|i:register_before\");\n}\n\nPyObject *\nPyGccPass_register_after(struct PyGccPass *self, PyObject *args, PyObject *kwargs)\n{\n    return impl_register(self, args, kwargs,\n                         PASS_POS_INSERT_AFTER,\n                         \"s|i:register_after\");\n}\n\nPyObject *\nPyGccPass_replace(struct PyGccPass *self, PyObject *args, PyObject *kwargs)\n{\n    return impl_register(self, args, kwargs,\n                         PASS_POS_REPLACE,\n                         \"s|i:replace\");\n}\n\nstatic PyGccWrapperTypeObject *\nget_type_for_pass_type(enum opt_pass_type pt)\n{\n    switch (pt) {\n    default: assert(0);\n\n    case GIMPLE_PASS:\n\treturn &PyGccGimplePass_TypeObj;\n\n    case RTL_PASS:\n\treturn &PyGccRtlPass_TypeObj;\n\n    case SIMPLE_IPA_PASS:\n\treturn &PyGccSimpleIpaPass_TypeObj;\n\n    case IPA_PASS:\n\treturn &PyGccIpaPass_TypeObj;\n    }\n};\n\n\nstatic PyObject *\nreal_make_pass_wrapper(void *p)\n{\n    struct opt_pass *pass = (struct opt_pass *)p;\n    PyGccWrapperTypeObject *type_obj;\n    struct PyGccPass *pass_obj = NULL;\n\n    if (NULL == pass) {\n\tPy_RETURN_NONE;\n    }\n\n    type_obj = get_type_for_pass_type(pass->type);\n\n    pass_obj = PyGccWrapper_New(struct PyGccPass, type_obj);\n    if (!pass_obj) {\n        goto error;\n    }\n\n    pass_obj->pass = pass;\n    /* FIXME: do we need to do something for the GCC GC? */\n\n    return (PyObject*)pass_obj;\n      \nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccPass(PyGccPass *wrapper)\n{\n    /*\n      This function is empty: struct opt_pass does not have a GTY()\n      and any (struct opt_pass*) is either statically-allocated, or\n      allocated by us within do_pass_init using PyMem_Malloc\n    */\n}\n\nPyObject *\nPyGccPass_New(struct opt_pass *pass)\n{\n    return PyGcc_LazilyCreateWrapper(&pass_wrapper_cache,\n\t\t\t\t\t    pass,\n\t\t\t\t\t    real_make_pass_wrapper);\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-plugin.spec",
    "content": "Name:           gcc-python-plugin\nVersion:        0.17\nRelease:        1%{?dist}\nSummary:        GCC plugin that embeds Python\n\nGroup:          Development/Languages\nLicense:        GPLv3+\nURL:            https://fedorahosted.org/gcc-python-plugin/\nSource0:        https://fedorahosted.org/releases/g/c/gcc-python-plugin/gcc-python-plugin-%{version}.tar.gz\nBuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)\n\nBuildRequires:  gcc-plugin-devel\n\n# gcc 4.6.1's plugin/include/double-int.h includes \"gmp.h\", but on Fedora,\n# gmp-devel isn't yet listed in the requirements of gcc-plugin-devel\n# For now, explicitly require it:\nBuildRequires:  gmp-devel\n# Filed as https://bugzilla.redhat.com/show_bug.cgi?id=725569\n\n\n# Various python runtimes to build the plugin against:\nBuildRequires:  python-devel\nBuildRequires:  python-debug\nBuildRequires:  python3-devel\nBuildRequires:  python3-debug\n\n# \"six\" is used at buildtime:\nBuildRequires:  python-six\nBuildRequires:  python3-six\n\n# sphinx is used for building documentation:\nBuildRequires:  python-sphinx\n\n# pygments is used when running the selftests:\nBuildRequires: python-pygments\nBuildRequires: python3-pygments\n\n# lxml is used when running the selftests:\nBuildRequires: python-lxml\nBuildRequires: python3-lxml\n\n%global gcc_plugins_dir %(gcc --print-file-name=plugin)\n\n%description\nPlugins for embedding various versions of Python within GCC\n\n%package -n gcc-python-plugin-c-api\nSummary: Shared library to make it easier to write GCC plugins\nGroup:   Development/Languages\n\n%description -n gcc-python-plugin-c-api\nShared library to make it easier to write GCC plugins\n\n%package -n gcc-python2-plugin\nSummary: GCC plugin embedding Python 2\nGroup:   Development/Languages\nRequires: python-six\nRequires: python-pygments\nRequires: python-lxml\nRequires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}\n\n%description  -n gcc-python2-plugin\nGCC plugin embedding Python 2\n\n%package -n gcc-python3-plugin\nSummary: GCC plugin embedding Python 3\nGroup:   Development/Languages\nRequires: python3-six\nRequires: python3-pygments\nRequires: python3-lxml\nRequires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}\n\n%description  -n gcc-python3-plugin\nGCC plugin embedding Python 3\n\n%package -n gcc-python2-debug-plugin\nSummary: GCC plugin embedding Python 2 debug build\nGroup:   Development/Languages\nRequires: python-six\nRequires: python-pygments\nRequires: python-lxml\nRequires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}\n\n%description  -n gcc-python2-debug-plugin\nGCC plugin embedding debug build of Python 2\n\n%package -n gcc-python3-debug-plugin\nSummary: GCC plugin embedding Python 3 debug build\nGroup:   Development/Languages\nRequires: python3-six\nRequires: python3-pygments\nRequires: python3-lxml\nRequires: gcc-python-plugin-c-api%{?_isa} = %{version}-%{release}\n\n%description  -n gcc-python3-debug-plugin\nGCC plugin embedding debug build of Python 3\n\n%package docs\nSummary: API documentation for the GCC Python plugin\nGroup:   Development/Languages\n\n%description docs\nThis package contains API documentation for the GCC Python plugin\n\n\n\n%prep\n%setup -q\n\n# We will be building the plugin 4 times, each time against a different\n# Python runtime\n#\n# The plugin doesn't yet cleanly support srcdir != builddir, so for now\n# make 4 separate copies of the source, once for each build\n\nPrepPlugin() {\n    PluginName=$1\n\n    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName\n\n    rm -rf $BuildDir\n    cp -a . $BuildDir\n}\n\nPrepPlugin \\\n  python2\n\nPrepPlugin \\\n  python2_debug\n\nPrepPlugin \\\n  python3\n\nPrepPlugin \\\n  python3_debug\n\n\n%build\n\nBuildPlugin() {\n    PythonExe=$1\n    PythonConfig=$2\n    PluginDso=$3\n    PluginName=$4\n\n    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName\n\n    pushd $BuildDir\n    make \\\n       %{?_smp_mflags} \\\n       PLUGIN_NAME=$PluginName \\\n       PLUGIN_DSO=$PluginDso \\\n       PYTHON=$PythonExe \\\n       PYTHON_CONFIG=$PythonConfig \\\n       PLUGIN_PYTHONPATH=%{gcc_plugins_dir}/$PluginName \\\n       plugin print-gcc-version\n    popd\n}\n\nBuildPlugin \\\n  python \\\n  python-config \\\n  python2.so \\\n  python2\n\nBuildPlugin \\\n  python-debug \\\n  python-debug-config \\\n  python2_debug.so \\\n  python2_debug\n\nBuildPlugin \\\n  python3 \\\n  python3-config \\\n  python3.so \\\n  python3\n\nBuildPlugin \\\n  python3-debug \\\n  /usr/bin/python3.?dm-config \\\n  python3_debug.so \\\n  python3_debug\n\n# Documentation:\ncd docs\nmake html\n# Avoid having a hidden file in the payload:\nrm _build/html/.buildinfo\n\nmake man\n\n%install\nrm -rf $RPM_BUILD_ROOT\n\nmkdir -p $RPM_BUILD_ROOT/%{gcc_plugins_dir}\nmkdir -p $RPM_BUILD_ROOT/%{_bindir}\nmkdir -p $RPM_BUILD_ROOT/%{_mandir}/man1\n\nInstallPlugin() {\n    PythonExe=$1\n    PythonConfig=$2\n    PluginDso=$3\n    PluginName=$4\n\n    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName\n\n    pushd $BuildDir\n    make install \\\n        DESTDIR=$RPM_BUILD_ROOT \\\n        PLUGIN_NAME=$PluginName \\\n        PLUGIN_DSO=$PluginDso\n    popd\n\n    # (doing the above actually installs each build's copy of libgccapi.so,\n    # all to the same location, but they should all be identical, so that's\n    # OK)\n}\n\nInstallPlugin \\\n  python \\\n  python-config \\\n  python2.so \\\n  python2\n\nInstallPlugin \\\n  python-debug \\\n  python-debug-config \\\n  python2_debug.so \\\n  python2_debug\n\nInstallPlugin \\\n  python3 \\\n  python3-config \\\n  python3.so \\\n  python3\n\nInstallPlugin \\\n  python3-debug \\\n  python3.4dm-config \\\n  python3_debug.so \\\n  python3_debug\n\n\n%clean\nrm -rf $RPM_BUILD_ROOT\n\n%check\n\nCheckPlugin() {\n    PythonExe=$1\n    PythonConfig=$2\n    PluginDso=$3\n    PluginName=$4\n    SelftestArgs=$5\n\n    BuildDir=../gcc-python-plugin-%{version}-building-for-$PluginName\n\n    pushd $BuildDir\n\n    # Run the selftests:\n    LD_LIBRARY_PATH=gcc-c-api \\\n    PLUGIN_NAME=$PluginName \\\n        $PythonExe run-test-suite.py $SelftestArgs\n\n    LD_LIBRARY_PATH=gcc-c-api \\\n    PLUGIN_NAME=$PluginName \\\n        $PythonExe testcpychecker.py -v\n\n    popd\n}\n\n# Selftest for python2 (optimized) build\n# All tests ought to pass:\nCheckPlugin \\\n  python \\\n  python-config \\\n  python2.so \\\n  python2 \\\n  %{nil}\n\n# Selftest for python2-debug build:\n# Disable the cpychecker tests for now: somewhat ironically, the extra\n# instrumentation in the debug build breaks the selftests for the refcount\n# tracker.  (specifically, handling of _Py_RefTotal):\n#\n#   Failed tests:\n#     tests/cpychecker/refcounts/correct_py_none\n#     tests/cpychecker/refcounts/correct_decref\n#     tests/cpychecker/refcounts/use_after_dealloc\n#     tests/cpychecker/refcounts/returning_dead_object\n#     tests/cpychecker/refcounts/too_many_increfs\n#     tests/cpychecker/refcounts/loop_n_times\n#\nCheckPlugin \\\n  python-debug \\\n  python-debug-config \\\n  python2_debug.so \\\n  python2_debug \\\n  \"-x tests/cpychecker\"\n\n# Selftest for python3 (optimized) build:\n# Disable the cpychecker tests for now:\n#   Failed tests:\n#     tests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U\n#     tests/cpychecker/PyArg_ParseTuple/correct_codes_S_and_U\n#     tests/cpychecker/refcounts/correct_decref\n#     tests/cpychecker/refcounts/fold_conditional\n#     tests/cpychecker/refcounts/use_after_dealloc\n#     tests/cpychecker/refcounts/missing_decref\n#     tests/cpychecker/refcounts/returning_dead_object\n#     tests/cpychecker/refcounts/too_many_increfs\n#     tests/cpychecker/refcounts/loop_n_times\n#\nCheckPlugin \\\n  python3 \\\n  python3-config \\\n  python3.so \\\n  python3 \\\n  \"-x tests/cpychecker\"\n\n# Selftest for python3-debug build:\n#   (shares the issues of the above)\nCheckPlugin \\\n  python3-debug \\\n  python3.4dm-config \\\n  python3_debug.so \\\n  python3_debug \\\n  \"-x tests/cpychecker\"\n\n%files -n gcc-python-plugin-c-api\n%{gcc_plugins_dir}/libgcc-c-api.so\n\n%files -n gcc-python2-plugin\n%defattr(-,root,root,-)\n%doc COPYING README.rst\n%{_bindir}/gcc-with-python2\n%{gcc_plugins_dir}/python2.so\n%{gcc_plugins_dir}/python2\n%doc %{_mandir}/man1/gcc-with-python2.1.gz\n\n%files -n gcc-python3-plugin\n%defattr(-,root,root,-)\n%doc COPYING README.rst\n%{_bindir}/gcc-with-python3\n%{gcc_plugins_dir}/python3.so\n%{gcc_plugins_dir}/python3\n%doc %{_mandir}/man1/gcc-with-python3.1.gz\n\n%files -n gcc-python2-debug-plugin\n%defattr(-,root,root,-)\n%doc COPYING README.rst\n%{_bindir}/gcc-with-python2_debug\n%{gcc_plugins_dir}/python2_debug.so\n%{gcc_plugins_dir}/python2_debug\n%doc %{_mandir}/man1/gcc-with-python2_debug.1.gz\n\n%files -n gcc-python3-debug-plugin\n%defattr(-,root,root,-)\n%doc COPYING README.rst\n%{_bindir}/gcc-with-python3_debug\n%{gcc_plugins_dir}/python3_debug.so\n%{gcc_plugins_dir}/python3_debug\n%doc %{_mandir}/man1/gcc-with-python3_debug.1.gz\n\n%files docs\n%defattr(-,root,root,-)\n%doc COPYING\n%doc docs/_build/html\n# Example scripts:\n%doc examples\n\n%changelog\n* Mon Feb  6 2012 David Malcolm <dmalcolm@redhat.com> - 0.9-1\n- 0.9\n\n* Tue Jan 10 2012 David Malcolm <dmalcolm@redhat.com> - 0.8-1\n- 0.8\n\n* Tue Aug  2 2011 David Malcolm <dmalcolm@redhat.com> - 0.6-1\n- 0.6\n\n* Wed Jul 27 2011 David Malcolm <dmalcolm@redhat.com> - 0.5-1\n- 0.5\n- examples are now in an \"examples\" subdirectory\n\n* Tue Jul 26 2011 David Malcolm <dmalcolm@redhat.com> - 0.4-1\n- 0.4\n- add requirement on pygments\n- run the upstream test suites during %%check\n\n* Mon Jul 25 2011 David Malcolm <dmalcolm@redhat.com> - 0.3-1\n- add requirements on python-six and python3-six\n- add %%check section (empty for now)\n- set PYTHON and PLUGIN_PYTHONPATH during each build; install support files\ninto build-specific directories below the gcc plugin dir\n- add helper gcc-with-python scripts, with man pages\n- package the license\n- add example scripts\n- add explicit BR on gmp-devel (rhbz#725569)\n\n* Tue May 24 2011 David Malcolm <dmalcolm@redhat.com> - 0.1-1\n- initial packaging\n"
  },
  {
    "path": "gcc-python-pretty-printer.c",
    "content": "/*\n   Copyright 2011, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#if (GCC_VERSION >= 4009)\n/* Needed for placement new */\n#include <new>\n#endif\n\nPyObject*\nPyGccPrettyPrinter_New(void)\n{\n    struct PyGccPrettyPrinter *obj;\n\n    obj = PyObject_New(struct PyGccPrettyPrinter, &PyGccPrettyPrinter_TypeObj);\n    if (!obj) {\n\treturn NULL;\n    }\n    \n    //printf(\"PyGccPrettyPrinter_New\\n\");\n\n    /* Gross hack for getting at a FILE* ; rewrite using fopencookie? */\n    obj->buf[0] = '\\0';\n    obj->file_ptr = fmemopen(obj->buf, sizeof(obj->buf), \"w\");\n\n#if (GCC_VERSION >= 4009)\n    /* GCC 4.9 eliminated pp_construct in favor of a C++ ctor.\n       Use placement new to run it on obj->pp.  */\n    new ((void*)&obj->pp)\n        pretty_printer(\n# if (GCC_VERSION < 8003)\n                       /* GCC 9 eliminated the \"prefix\" param.  */\n                       NULL,\n# endif\n                       0);\n#else\n    pp_construct(&obj->pp, /* prefix */NULL, /* line-width */0);\n#endif\n    pp_needs_newline(&obj->pp) = false;\n    pp_translate_identifiers(&obj->pp) = false;\n\n    /* Connect the pp to the (FILE*): */\n    obj->pp.buffer->stream = obj->file_ptr;\n\n    //printf(\"PyGccPrettyPrinter_New returning: %p\\n\", obj);\n    \n    return (PyObject*)obj;\n}\n\npretty_printer*\nPyGccPrettyPrinter_as_pp(PyObject *obj)\n{\n    struct PyGccPrettyPrinter *ppobj;\n\n    /* FIXME: */\n    assert(Py_TYPE(obj) == &PyGccPrettyPrinter_TypeObj);\n    ppobj = (struct PyGccPrettyPrinter *)obj;\n\n    return &ppobj->pp;\n}\n\nPyObject*\nPyGccPrettyPrinter_as_string(PyObject *obj)\n{\n    struct PyGccPrettyPrinter *ppobj;\n    int len;\n\n    /* FIXME: */\n    assert(Py_TYPE(obj) == &PyGccPrettyPrinter_TypeObj);\n    ppobj = (struct PyGccPrettyPrinter *)obj;\n\n    /* Flush the pp first.  This forcibly adds a trailing newline: */\n    pp_flush(&ppobj->pp);\n\n    /* Convert to a python string, leaving off the trailing newline: */\n    len = strlen(ppobj->buf);\n    assert(len > 0);\n    if ('\\n' == ppobj->buf[len - 1]) {\n\treturn PyGccString_FromString_and_size(ppobj->buf,\n\t\t\t\t\t\t      len - 1);\n    } else {\n\treturn PyGccString_FromString(ppobj->buf);\n    }\n}\n\nvoid\nPyGccPrettyPrinter_dealloc(PyObject *obj)\n{\n    struct PyGccPrettyPrinter *ppobj;\n\n    /* FIXME: */\n    assert(Py_TYPE(obj) == &PyGccPrettyPrinter_TypeObj);\n    ppobj = (struct PyGccPrettyPrinter *)obj;\n\n    /* Close the (FILE*), if open: */\n    if (ppobj->file_ptr) {\n\tfclose(ppobj->file_ptr);\n\tppobj->file_ptr = NULL;\n    }\n\n    Py_TYPE(obj)->tp_free(obj);\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-rtl.c",
    "content": "/*\n   Copyright 2011-2013, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-python-compat.h\"\n#include \"rtl.h\"\n#include \"gcc-c-api/gcc-rtl.h\"\n\n#if (GCC_VERSION < 5000)\nPyObject *\nPyGccRtl_get_location(struct PyGccRtl *self, void *closure)\n{\n    /* In gcc 4.8, INSN_LOCATOR was replaced by INSN_LOCATION (in r191494) */\n#if (GCC_VERSION >= 4008)\n    return PyGccLocation_New(gcc_private_make_location(INSN_LOCATION(self->insn.inner)));\n#else\n    int locator = INSN_LOCATOR (self->insn.inner);\n    if (locator && insn_file (self->insn.inner)) {\n        return PyGccLocation_New(gcc_private_make_location(locator_location(locator)));\n    }\n    Py_RETURN_NONE;\n#endif\n}\n#endif\n\nPyObject *\nget_operand_as_object(const_rtx in_rtx, int idx, char fmt)\n{\n    const char *str;\n\n    /* The operand types are described in gcc/rtl.c */\n    switch (fmt) {\n\n    case 'T': /* pointer to a string, with special meaning */\n        str = XTMPL (in_rtx, idx);\n        goto string;\n\n    case 'S': /* optional pointer to a string */\n    case 's': /* a pointer to a string */\n        str = XSTR (in_rtx, idx);\n    string:\n        return PyGccStringOrNone(str);\n\n    case '0': /* unused, or used in a phase-dependent manner */\n        Py_RETURN_NONE; /* for now */\n\n    case 'e': /* pointer to an rtl expression */\n        /* Nested expression: */\n        return PyGccRtl_New(\n                   gcc_private_make_rtl_insn(XEXP (in_rtx, idx)));\n\n    case 'E':\n    case 'V':\n        /* Nested list of expressions */\n        {\n            PyObject *list = PyList_New(XVECLEN (in_rtx, idx));\n            int j;\n            if (!list) {\n                return NULL;\n            }\n            for (j = 0; j < XVECLEN (in_rtx, idx); j++) {\n                PyObject *item = PyGccRtl_New(\n                                     gcc_private_make_rtl_insn(XVECEXP (in_rtx, idx, j)));\n                if (!item) {\n                    Py_DECREF(list);\n                    return NULL;\n                }\n                if (-1 == PyList_Append(list, item)) {\n                    Py_DECREF(item);\n                    Py_DECREF(list);\n                    return NULL;\n                }\n                Py_DECREF(item);\n            }\n            return list;\n        }\n\n    case 'w':\n        return PyGccInt_FromLong(XWINT (in_rtx, idx));\n\n    case 'i':\n        return PyGccInt_FromLong(XINT (in_rtx, idx));\n\n    case 'n':\n        /* Return NOTE_INSN names rather than integer codes.  */\n        return PyGccStringOrNone(GET_NOTE_INSN_NAME (XINT (in_rtx, idx)));\n\n    case 'u': /* a pointer to another insn */\n        Py_RETURN_NONE; /* for now */\n\n    case 't':\n        return PyGccTree_New(gcc_private_make_tree(XTREE (in_rtx, idx)));\n\n    case '*':\n        Py_RETURN_NONE; /* for now */\n\n    case 'B':\n        return PyGccBasicBlock_New(\n            gcc_private_make_cfg_block(XBBDEF (in_rtx, idx)));\n\n    default:\n        gcc_unreachable ();\n    }\n}\n\nPyObject *\nPyGccRtl_get_operands(struct PyGccRtl *self, void *closure)\n{\n    const int length = GET_RTX_LENGTH (GET_CODE (self->insn.inner));\n    PyObject *result;\n    int i;\n    const char *format_ptr;\n\n    result = PyTuple_New(length);\n    if (!result) {\n        return NULL;\n    }\n\n    format_ptr = GET_RTX_FORMAT (GET_CODE (self->insn.inner));\n    for (i = 0; i < length; i++) {\n        PyObject *item = get_operand_as_object(self->insn.inner, i, *format_ptr++);\n        if (!item) {\n            Py_DECREF(result);\n            return NULL;\n        }\n        PyTuple_SET_ITEM(result, i, item);\n    }\n\n    return result;\n}\n\nPyObject *\nPyGccRtl_repr(struct PyGccRtl * self)\n{\n    return PyGccString_FromFormat(\"%s()\",\n                                         Py_TYPE(self)->tp_name);\n}\n\nPyObject *\nPyGccRtl_str(struct PyGccRtl * self)\n{\n    /*\n      We use print_rtl_single() which takes a FILE*, so\n      we need an fmemopen buffer to write to:\n    */\n    char buf[2048]; /* FIXME */\n    FILE *f;\n\n    buf[0] = '\\0';\n    f = fmemopen(buf, sizeof(buf), \"w\");\n    if (!f) {\n        return PyErr_SetFromErrno(PyExc_IOError);\n    }\n\n    print_rtl_single (f, self->insn.inner);\n\n    fclose(f);\n\n    return PyGccString_FromString(buf);\n}\n\nPyObject*\nPyGccRtl_New(gcc_rtl_insn insn)\n{\n    struct PyGccRtl *rtl_obj = NULL;\n    PyGccWrapperTypeObject* tp;\n\n    if (!insn.inner) {\n        Py_RETURN_NONE;\n    }\n\n    tp = PyGcc_autogenerated_rtl_type_for_stmt(insn);\n    assert(tp);\n\n    rtl_obj = PyGccWrapper_New(struct PyGccRtl, tp);\n    if (!rtl_obj) {\n        goto error;\n    }\n    rtl_obj->insn = insn;\n\n    return (PyObject*)rtl_obj;\n\nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccRtl(PyGccRtl *wrapper)\n{\n    /* Mark the underlying object (recursing into its fields): */\n    gcc_rtl_insn_mark_in_use(wrapper->insn);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-tree.c",
    "content": "/*\n   Copyright 2011-2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-python-compat.h\"\n#include \"cp/cp-tree.h\"\n#include \"gimple.h\"\n\n#include \"cp/cp-tree.h\" /* for TFF_* for use by PyGccFunctionDecl_get_fullname */\n\n/* for op_symbol_code */\n/* Moved to tree-pretty-print.h in gcc 4.9: */\n#if (GCC_VERSION >= 4009)\n#include \"tree-pretty-print.h\"\n#else\n#include \"tree-flow.h\"\n#endif\n\n/* \"maybe_get_identifier\" was moved from tree.h to stringpool.h in 4.9 */\n#if (GCC_VERSION >= 4009)\n#include \"stringpool.h\" /* for maybe_get_identifier */\n#endif\n\n#include \"gcc-c-api/gcc-tree.h\"\n#include \"gcc-c-api/gcc-type.h\"\n#include \"gcc-c-api/gcc-private-compat.h\" /* for now */\n\nextern PyGccWrapperTypeObject PyGccIntegerCst_TypeObj;\n\n__typeof__ (lang_check_failed) lang_check_failed __attribute__ ((weak));\n\n\n/*\n  Unfortunately, decl_as_string() is only available from the C++\n  frontend: cc1plus (it's defined in gcc/cp/error.c).\n\n  See http://gcc.gnu.org/ml/gcc/2011-11/msg00504.html\n\n  Hence we redeclare the symbol as weak, and then check its definition\n  against 0 before using it.\n*/\n\n__typeof__ (decl_as_string) decl_as_string __attribute__ ((weak));\n\n/* Similar for namespace_binding, though gcc 8's r247654 (aka\n   f906dcc33dd818b71e16c88cef38f33c161070db) replaced it with\n   get_namespace_value and reversed the order of the params\n   and r247745 (aka 9d79db401edbb9665cde47ddea2702671c89e548)\n   renamed it from get_namespace_value to get_namespace_binding.  */\n#if (GCC_VERSION >= 8000)\n__typeof__ (get_namespace_binding) get_namespace_binding __attribute__ ((weak));\n#else\n__typeof__ (namespace_binding) namespace_binding __attribute__ ((weak));\n#endif\n\n/* And for cp_namespace_decls: */\n__typeof__ (cp_namespace_decls) cp_namespace_decls __attribute__ ((weak));\n\nstatic PyObject *\nraise_cplusplus_only(const char *what)\n{\n    return PyErr_Format(PyExc_RuntimeError,\n                        \"%s is only available when compiling C++ code\",\n                        what);\n}\n\nstatic PyObject *\nraise_not_during_lto(const char *what)\n{\n    return PyErr_Format(PyExc_RuntimeError,\n                        \"%s is not available during link-time optimization\",\n                        what);\n}\n\n//#include \"rtl.h\"\n/*\n  \"struct rtx_def\" is declarted within rtl.h, c.f:\n    struct GTY((chain_next (\"RTX_NEXT (&%h)\"),\n\t    chain_prev (\"RTX_PREV (&%h)\"), variable_size)) rtx_def {\n           ... snip ...\n    }\n    \n  and seems to be the fundamental instruction type\n    \n  Seems to use RTX_NEXT() and RTX_PREV()\n*/\n\n/*\n    Code for various tree types\n */\nstatic PyObject *\ndo_pretty_print(struct PyGccTree * self, int spc, dump_flags_t flags)\n{\n    PyObject *ppobj = PyGccPrettyPrinter_New();\n    PyObject *result = NULL;\n    if (!ppobj) {\n\treturn NULL;\n    }\n\n    dump_generic_node (PyGccPrettyPrinter_as_pp(ppobj),\n\t\t       self->t.inner, spc, flags, 0);\n    result = PyGccPrettyPrinter_as_string(ppobj);\n    if (!result) {\n\tgoto error;\n    }\n    \n    Py_XDECREF(ppobj);\n    return result;\n    \n error:\n    Py_XDECREF(ppobj);\n    return NULL;\n}\n\nPyObject *\nPyGccBlock_New(gcc_block t)\n{\n    return PyGccTree_New(gcc_block_as_gcc_tree(t));\n}\n\nPyObject *\nPyGccPointerType_New(gcc_pointer_type t)\n{\n    return PyGccTree_New(gcc_pointer_type_as_gcc_tree(t));\n}\n\nPyObject *\nPyGccPointerType_repr(struct PyGccTree * self)\n{\n    PyObject *repr_name = NULL;\n    PyObject *result = NULL;\n\n    repr_name = PyGcc_GetReprOfAttribute((PyObject*)self, \"dereference\");\n    if (!repr_name) {\n        goto error;\n    }\n\n    result = PyGccString_FromFormat(\"%s(dereference=%s)\",\n                                    Py_TYPE(self)->tp_name,\n                                    PyGccString_AsString(repr_name));\n\n error:\n    Py_XDECREF(repr_name);\n\n    return result;\n}\n\n\nPyObject *\nPyGccCaseLabelExpr_New(gcc_case_label_expr t)\n{\n    return PyGccTree_New(gcc_case_label_expr_as_gcc_tree(t));\n}\n\nPyObject *\nPyGccTree_str(struct PyGccTree * self)\n{\n    return do_pretty_print(self, 0, (dump_flags_t)0);\n}\n\nlong\nPyGccTree_hash(struct PyGccTree * self)\n{\n    if (Py_TYPE(self) == (PyTypeObject*)&PyGccComponentRef_TypeObj) {\n        return (long)TREE_OPERAND(self->t.inner, 0) ^ (long)TREE_OPERAND(self->t.inner, 1);\n    }\n\n    if (Py_TYPE(self) == (PyTypeObject*)&PyGccIntegerCst_TypeObj) {\n        /* Ensure that hash(cst) == hash(int(cst)) */\n        PyObject *constant = PyGccIntegerConstant_get_constant(self, NULL);\n        long result;\n        if (!constant) {\n            return -1;\n        }\n        result = PyObject_Hash(constant);\n        Py_DECREF(constant);\n        return result;\n    }\n\n    /* Use the ptr as the hash value: */\n    return (long)self->t.inner;\n}\n\n\nPyObject *\nPyGccTree_richcompare(PyObject *o1, PyObject *o2, int op)\n{\n    struct PyGccTree *treeobj1;\n    struct PyGccTree *treeobj2;\n    int cond;\n    PyObject *result_obj;\n\n    /* Specialcases: */\n    if (Py_TYPE(o1) == (PyTypeObject*)&PyGccIntegerCst_TypeObj) {\n        o1 = PyGccIntegerConstant_get_constant((struct PyGccTree *)o1, NULL);\n        if (!o1) { return NULL; }\n        result_obj = PyObject_RichCompare(o1, o2, op);\n        Py_DECREF(o1);\n        return result_obj;\n    }\n    if (Py_TYPE(o2) == (PyTypeObject*)&PyGccIntegerCst_TypeObj) {\n        o2 = PyGccIntegerConstant_get_constant((struct PyGccTree *)o2, NULL);\n        if (!o2) { return NULL; }\n        result_obj = PyObject_RichCompare(o1, o2, op);\n        Py_DECREF(o2);\n        return result_obj;\n    }\n\n    if (!PyObject_TypeCheck(o1, (PyTypeObject*)&PyGccTree_TypeObj)) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n    if (!PyObject_TypeCheck(o2, (PyTypeObject*)&PyGccTree_TypeObj)) {\n\tresult_obj = Py_NotImplemented;\n\tgoto out;\n    }\n\n    treeobj1 = (struct PyGccTree *)o1;\n    treeobj2 = (struct PyGccTree *)o2;\n\n    if (Py_TYPE(o1) == (PyTypeObject*)&PyGccComponentRef_TypeObj) {\n        if (Py_TYPE(o2) == (PyTypeObject*)&PyGccComponentRef_TypeObj) {\n            switch (op) {\n            case Py_EQ:\n                cond = ((TREE_OPERAND(treeobj1->t.inner, 0) == TREE_OPERAND(treeobj2->t.inner, 0)) &&\n                        (TREE_OPERAND(treeobj1->t.inner, 1) == TREE_OPERAND(treeobj2->t.inner, 1)));\n                break;\n\n            case Py_NE:\n                cond = !((TREE_OPERAND(treeobj1->t.inner, 0) == TREE_OPERAND(treeobj2->t.inner, 0)) &&\n                         (TREE_OPERAND(treeobj1->t.inner, 1) == TREE_OPERAND(treeobj2->t.inner, 1)));\n                break;\n\n            default:\n                result_obj = Py_NotImplemented;\n                goto out;\n            }\n            result_obj = cond ? Py_True : Py_False;\n            goto out;\n        }\n    }\n\n    switch (op) {\n    case Py_EQ:\n\tcond = (treeobj1->t.inner == treeobj2->t.inner);\n\tbreak;\n\n    case Py_NE:\n\tcond = (treeobj1->t.inner != treeobj2->t.inner);\n\tbreak;\n\n    default:\n        result_obj = Py_NotImplemented;\n        goto out;\n    }\n    result_obj = cond ? Py_True : Py_False;\n\n out:\n    Py_INCREF(result_obj);\n    return result_obj;\n}\n\nPyObject *\nPyGccTree_get_str_no_uid(struct PyGccTree *self, void *closure)\n{\n    return do_pretty_print(self, 0, TDF_NOUID);\n}\n\nPyObject *\nPyGccTree_get_symbol(PyObject *cls, PyObject *args)\n{\n    enum tree_code code;\n\n    if (-1 == PyGcc_tree_type_object_as_tree_code(cls, &code)) {\n        PyErr_SetString(PyExc_TypeError,\n                        \"no symbol associated with this type\");\n        return NULL;\n    }\n\n    return PyGccString_FromString(op_symbol_code(code));\n}\n\nPyObject *\nPyGccDeclaration_repr(struct PyGccTree * self)\n{\n    PyObject *name = NULL;\n    PyObject *result = NULL;\n\n    if (DECL_NAME(self->t.inner)) {\n\tname = PyGccDeclaration_get_name(self, NULL);\n\tif (!name) {\n\t    goto error;\n\t}\n\n        result = PyGccString_FromFormat(\"%s('%s')\",\n                                               Py_TYPE(self)->tp_name,\n                                               PyGccString_AsString(name));\n\tPy_DECREF(name);\n    } else {\n        result = PyGccString_FromFormat(\"%s(%u)\",\n\t\t\t\t     Py_TYPE(self)->tp_name,\n\t\t\t\t     DECL_UID (self->t.inner));\n    }\n\n    return result;\nerror:\n    Py_XDECREF(name);\n    Py_XDECREF(result);\n    return NULL;\n}\n\nPyObject *\nPyGccFunctionDecl_get_fullname(struct PyGccTree *self, void *closure)\n{\n    const char *str;\n\n    if (NULL == decl_as_string) {\n        return raise_cplusplus_only(\"attribute 'fullname'\");\n    }\n\n    str = decl_as_string(self->t.inner,\n                         TFF_DECL_SPECIFIERS\n                         |TFF_RETURN_TYPE\n                         |TFF_FUNCTION_DEFAULT_ARGUMENTS\n                         |TFF_EXCEPTION_SPECIFICATION);\n    return PyGccString_FromString(str);\n}\n\nPyObject *\nPyGccFunctionDecl_get_callgraph_node(struct PyGccTree *self, void *closure)\n{\n    /* cgraph_get_node became cgraph_node::get in 5.0 */\n    struct cgraph_node *node;\n#if (GCC_VERSION >= 5000)\n    node = cgraph_node::get(self->t.inner);\n#else\n    node = cgraph_get_node(self->t.inner);\n#endif\n    return PyGccCallgraphNode_New(gcc_private_make_cgraph_node(node));\n}\n\nPyObject *\nPyGccArrayRef_repr(PyObject *self)\n{\n    PyObject *array_repr = NULL;\n    PyObject *index_repr = NULL;\n    PyObject *result = NULL;\n\n    array_repr = PyGcc_GetReprOfAttribute(self, \"array\");\n    if (!array_repr) {\n        goto error;\n    }\n    index_repr =PyGcc_GetReprOfAttribute(self, \"index\");\n    if (!index_repr) {\n        goto error;\n    }\n\n    result = PyGccString_FromFormat(\"%s(array=%s, index=%s)\",\n                                           Py_TYPE(self)->tp_name,\n                                           PyGccString_AsString(array_repr),\n                                           PyGccString_AsString(index_repr));\n\n error:\n    Py_XDECREF(array_repr);\n    Py_XDECREF(index_repr);\n\n    return result;\n}\n\nPyObject *\nPyGccComponentRef_repr(PyObject *self)\n{\n    PyObject *target_repr = NULL;\n    PyObject *field_repr = NULL;\n    PyObject *result = NULL;\n\n    target_repr = PyGcc_GetReprOfAttribute(self, \"target\");\n    if (!target_repr) {\n        goto error;\n    }\n    field_repr = PyGcc_GetReprOfAttribute(self, \"field\");\n    if (!field_repr) {\n        goto error;\n    }\n\n    result = PyGccString_FromFormat(\"%s(target=%s, field=%s)\",\n                                           Py_TYPE(self)->tp_name,\n                                           PyGccString_AsString(target_repr),\n                                           PyGccString_AsString(field_repr));\n\n error:\n    Py_XDECREF(target_repr);\n    Py_XDECREF(field_repr);\n\n    return result;\n}\n\nPyObject *\nPyGccIdentifierNode_repr(struct PyGccTree * self)\n{\n    if (IDENTIFIER_POINTER(self->t.inner)) {\n        return PyGccString_FromFormat(\"%s(name='%s')\",\n                                             Py_TYPE(self)->tp_name,\n                                             IDENTIFIER_POINTER(self->t.inner));\n    } else {\n        return PyGccString_FromFormat(\"%s(name=None)\",\n                                             Py_TYPE(self)->tp_name);\n    }\n}\n\nPyObject *\nPyGccType_get_attributes(struct PyGccTree *self, void *closure)\n{\n    /* gcc/tree.h defines TYPE_ATTRIBUTES(NODE) as:\n       \"A TREE_LIST of IDENTIFIER nodes of the attributes that apply\n       to this type\"\n\n       Looking at:\n          typedef int (example3)(const char *, const char *, const char *)\n              __attribute__((nonnull(1)))\n              __attribute__((nonnull(3)));\n       (which is erroneous), we get this for TYPE_ATTRIBUTES:\n         gcc.TreeList(purpose=gcc.IdentifierNode(name='nonnull'),\n                      value=gcc.TreeList(purpose=None,\n                                         value=gcc.IntegerCst(3),\n                                         chain=None),\n                      chain=gcc.TreeList(purpose=gcc.IdentifierNode(name='nonnull'),\n                                         value=gcc.TreeList(purpose=None,\n                                                            value=gcc.IntegerCst(1),\n                                                            chain=None),\n                                         chain=None)\n                      )\n    */\n    tree attr;\n    PyObject *result = PyDict_New();\n    if (!result) {\n        return NULL;\n    }\n    for (attr = TYPE_ATTRIBUTES(self->t.inner); attr; attr = TREE_CHAIN(attr)) {\n        const char *attrname = IDENTIFIER_POINTER(TREE_PURPOSE(attr));\n        PyObject *values;\n        values = PyGcc_TreeMakeListFromTreeList(TREE_VALUE(attr));\n        if (!values) {\n            goto error;\n        }\n\n        if (-1 == PyDict_SetItemString(result, attrname, values)) {\n            Py_DECREF(values);\n            goto error;\n        }\n        Py_DECREF(values);\n    }\n\n    return result;\n\n error:\n    Py_DECREF(result);\n    return NULL;\n}\n\n/*\n  Weakly import c_sizeof_or_alignof_type; it's not available in lto1\n  (link-time optimization)\n*/\n__typeof__ (c_sizeof_or_alignof_type) c_sizeof_or_alignof_type __attribute__ ((weak));\n\nPyObject *\nPyGccType_get_sizeof(struct PyGccTree *self, void *closure)\n{\n    if (NULL == c_sizeof_or_alignof_type) {\n        return raise_not_during_lto(\"Type.sizeof\");\n    }\n\n    /*\n      c_sizeof_or_alignof_type wants a location; we use a fake one\n    */\n    tree t_sizeof = c_sizeof_or_alignof_type(input_location, self->t.inner, true,\n#if (GCC_VERSION >= 4009)\n                                             false,\n#endif\n                                             0);\n    PyObject *str;\n\n    /* This gives us either an INTEGER_CST or the dummy error type: */\n    if (INTEGER_CST == TREE_CODE(t_sizeof)) {\n        return PyGcc_int_from_int_cst (t_sizeof);\n    }\n\n    /* Error handling: */\n    str = PyGccTree_str(self);\n    if (str) {\n        PyErr_Format(PyExc_TypeError,\n                     \"type \\\"%s\\\" does not have a \\\"sizeof\\\"\",\n                     PyGccString_AsString(str));\n        Py_DECREF(str);\n    } else {\n        PyErr_Format(PyExc_TypeError,\n                     \"type does not have a \\\"sizeof\\\"\");\n    }\n    return NULL;\n}\n\n__typeof__ (c_common_signed_type) c_common_signed_type __attribute__ ((weak));\n\nPyObject *\nPyGccIntegerType_get_signed_equivalent(struct PyGccTree * self, void *closure)\n{\n    if (NULL == c_common_signed_type)\n        return raise_not_during_lto(\"gcc.IntegerType.signed_equivalent\");\n\n    return PyGccTree_New(gcc_private_make_tree(c_common_signed_type(self->t.inner)));\n}\n\n__typeof__ (c_common_unsigned_type) c_common_unsigned_type __attribute__ ((weak));\n\nPyObject *\nPyGccIntegerType_get_unsigned_equivalent(struct PyGccTree * self, void *closure)\n{\n    if (NULL == c_common_unsigned_type)\n        return raise_not_during_lto(\"gcc.IntegerType.unsigned_equivalent\");\n\n    return PyGccTree_New(gcc_private_make_tree(c_common_unsigned_type(self->t.inner)));\n}\n\nPyObject *\nPyGccIntegerType_repr(struct PyGccTree * self)\n{\n    PyObject *repr_name = NULL;\n    PyObject *result = NULL;\n\n    repr_name = PyGcc_GetReprOfAttribute((PyObject*)self, \"name\");\n    if (!repr_name) {\n        goto error;\n    }\n\n    result = PyGccString_FromFormat(\"%s(name=%s)\",\n                                    Py_TYPE(self)->tp_name,\n                                    PyGccString_AsString(repr_name));\n\n error:\n    Py_XDECREF(repr_name);\n\n    return result;\n}\n\nPyObject *\nPyGccFunction_TypeObj_get_argument_types(struct PyGccTree * self, void *closure)\n{\n    PyObject *result;\n    PyObject *item;\n    int i, size;\n    tree iter;\n    tree head = TYPE_ARG_TYPES(self->t.inner);\n\n    /* Get length of chain */\n    for (size = 0, iter = head;\n         iter && iter != error_mark_node && iter != void_list_node;\n         iter = TREE_CHAIN(iter), size++) {\n        /* empty */\n    }\n\n    /* \"size\" should now be the length of the chain */\n\n    result = PyTuple_New(size);\n    if (!result) {\n        return NULL;\n    }\n\n    for (i = 0, iter = head; i < size; iter = TREE_CHAIN(iter), i++) {\n\titem = PyGccTree_New(gcc_private_make_tree(TREE_VALUE(iter)));\n\tif (!item) {\n\t    goto error;\n\t}\n        if (0 != PyTuple_SetItem(result, i, item)) {\n            Py_DECREF(item);\n            goto error;\n        }\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\nPyObject *\nPyGccFunction_TypeObj_is_variadic(struct PyGccTree * self, void *closure)\n{\n    tree iter;\n    tree head = TYPE_ARG_TYPES(self->t.inner);\n\n    /* Get length of chain */\n    for (iter = head;\n         iter && iter != error_mark_node && iter != void_list_node;\n         iter = TREE_CHAIN(iter)) {\n        /* empty */\n    }\n\n    if (iter == void_list_node)\n        Py_RETURN_FALSE;\n    Py_RETURN_TRUE;\n}\n\nPyObject *\nPyGccMethodType_get_argument_types(struct PyGccTree * self,void *closure)\n{\n    return PyGccFunction_TypeObj_get_argument_types(self, closure);\n}\n\nPyObject *\nPyGccMethodType_is_variadic(struct PyGccTree * self,void *closure)\n{\n    return PyGccFunction_TypeObj_is_variadic(self, closure);\n}\n\nPyObject *\nPyGccConstructor_get_elements(PyObject *self, void *closure)\n{\n    struct PyGccTree * self_as_tree;\n    PyObject *result = NULL;\n    tree node;\n    unsigned HOST_WIDE_INT cnt;\n    tree index, value;\n\n    self_as_tree = (struct PyGccTree *)self; /* FIXME */\n    node = self_as_tree->t.inner;\n\n    result = PyList_New(GCC_COMPAT_VEC_LENGTH(constructor_elt,\n                                              CONSTRUCTOR_ELTS (node)));\n    if (!result) {\n\tgoto error;\n    }\n\n    FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (node),\n\t\t\t      cnt, index, value) {\n\tPyObject *obj_index = NULL;\n\tPyObject *obj_value = NULL;\n\tPyObject *obj_pair = NULL;\n\tobj_index = PyGccTree_New(gcc_private_make_tree(index));\n\tif (!obj_index) {\n\t    goto error;\n\t}\n\tobj_value = PyGccTree_New(gcc_private_make_tree(value));\n\tif (!obj_value) {\n\t    Py_DECREF(obj_index);\n\t    goto error;\n\t}\n\tobj_pair = PyTuple_Pack(2, obj_index, obj_value);\n\tif (!obj_pair) {\n\t    Py_DECREF(obj_value);\n\t    Py_DECREF(obj_index);\n\t    goto error;\n\t}\n        Py_DECREF(obj_value);\n        Py_DECREF(obj_index);\n\n\tif (-1 == PyList_SetItem(result, cnt, obj_pair)) {\n\t    Py_DECREF(obj_pair);\n\t    goto error;\n\t}\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n#if (GCC_VERSION >= 5000)\n\nstatic void\nprint_integer_cst_to_buf(tree int_cst, char *buf, tree type)\n{\n    /*\n      GCC 8 commit r253595 (aka e3d0f65c14ffd7a63455dc1aa9d0405d25b327e4,\n      2017-10-10) introduces and requires the use of wi::to_wide on\n      INTEGER_CST.\n    */\n#if (GCC_VERSION >= 8000)\n    print_dec(wi::to_wide(int_cst), buf, TYPE_SIGN (type));\n#else\n    print_dec(int_cst, buf, TYPE_SIGN (type));\n#endif\n}\n\n#endif /* #if (GCC_VERSION >= 5000) */\n\nPyObject *\nPyGcc_int_from_int_cst(tree int_cst)\n{\n    tree type = TREE_TYPE(int_cst);\n#if (GCC_VERSION >= 5000)\n    char buf[WIDE_INT_PRINT_BUFFER_SIZE];\n    print_integer_cst_to_buf (int_cst, buf, type);\n    return PyGcc_int_from_decimal_string_buffer(buf);\n#else\n    return PyGcc_int_from_double_int(TREE_INT_CST(int_cst),\n                                     TYPE_UNSIGNED(type));\n#endif\n}\n\nPyObject *\nPyGccIntegerConstant_get_constant(struct PyGccTree * self, void *closure)\n{\n    return PyGcc_int_from_int_cst(self->t.inner);\n}\n\nPyObject *\nPyGccIntegerConstant_repr(struct PyGccTree * self)\n{\n    tree type = TREE_TYPE(self->t.inner);\n#if (GCC_VERSION >= 5000)\n    char buf[WIDE_INT_PRINT_BUFFER_SIZE];\n    print_integer_cst_to_buf (self->t.inner, buf, type);\n#else\n    char buf[512];\n    PyGcc_DoubleIntAsText(TREE_INT_CST(self->t.inner),\n                                  TYPE_UNSIGNED(type),\n                                  buf, sizeof(buf));\n#endif\n    return PyGccString_FromFormat(\"%s(%s)\",\n                                         Py_TYPE(self)->tp_name,\n                                         buf);\n}\n\nPyObject *\nPyGccRealCst_get_constant(struct PyGccTree * self, void *closure)\n{\n    /* \"cheat\" and go through the string representation: */\n    REAL_VALUE_TYPE *d;\n    char buf[60];\n    PyObject *str;\n    PyObject *result;\n\n    d = TREE_REAL_CST_PTR(self->t.inner);\n    real_to_decimal (buf, d, sizeof (buf), 0, 1);\n\n    str = PyGccString_FromString(buf);\n    if (!str) {\n        return NULL;\n    }\n\n    /*\n      PyFloat_FromString API dropped its redundant second argument\n      in Python 3\n     */\n#if PY_MAJOR_VERSION == 3\n    result = PyFloat_FromString(str);\n#else\n    result = PyFloat_FromString(str, NULL);\n#endif\n\n    Py_DECREF(str);\n    return result;\n}\n\nPyObject *\nPyGccRealCst_repr(struct PyGccTree * self)\n{\n    REAL_VALUE_TYPE *d;\n    char buf[60];\n\n    d = TREE_REAL_CST_PTR(self->t.inner);\n    real_to_decimal (buf, d, sizeof (buf), 0, 1);\n    return PyGccString_FromFormat(\"%s(%s)\",\n                                         Py_TYPE(self)->tp_name,\n                                         buf);\n}\n\nPyObject *\nPyGccStringConstant_repr(struct PyGccTree * self)\n{\n    PyObject *str_obj;\n    PyObject *result = NULL;\n\n    str_obj = PyGccStringOrNone(TREE_STRING_POINTER(self->t.inner));\n    if (!str_obj) {\n        return NULL;\n    }\n#if PY_MAJOR_VERSION >= 3\n    result = PyGccString_FromFormat(\"%s(%R)\",\n                                           Py_TYPE(self)->tp_name,\n                                           str_obj);\n#else\n    {\n        PyObject *str_repr;\n        str_repr = PyObject_Repr(str_obj);\n        if (!str_repr) {\n            Py_DECREF(str_obj);\n            return NULL;\n        }\n        result = PyGccString_FromFormat(\"%s(%s)\",\n                                               Py_TYPE(self)->tp_name,\n                                               PyString_AsString(str_repr));\n        Py_DECREF(str_repr);\n    }\n#endif\n    Py_DECREF(str_obj);\n    return result;\n}\n\nPyObject *\nPyGccTypeDecl_get_pointer(struct PyGccTree *self, void *closure)\n{\n    tree decl_type = TREE_TYPE(self->t.inner);\n    if (!decl_type) {\n        PyErr_SetString(PyExc_ValueError, \"gcc.TypeDecl has no associated type\");\n        return NULL;\n    }\n    return PyGccTree_New(gcc_private_make_tree(build_pointer_type(decl_type)));\n}\n\nPyObject *\nPyGccTypeDecl_get_original_type(struct PyGccTree *self, void *closure)\n{\n    tree decl_type = TREE_TYPE(self->t.inner);\n    if (!decl_type) {\n        PyErr_SetString(PyExc_ValueError, \"gcc.TypeDecl has no associated type\");\n        return NULL;\n    }\n    return PyGccTree_New(gcc_private_make_tree(DECL_ORIGINAL_TYPE(TYPE_NAME(decl_type))));\n}\n\nPyObject *\nPyGccSsaName_repr(struct PyGccTree * self)\n{\n    int version;\n    PyObject *repr_var = NULL;\n    PyObject *result = NULL;\n\n    version = gcc_ssa_name_get_version(gcc_tree_as_gcc_ssa_name(self->t));\n    repr_var = PyGcc_GetReprOfAttribute((PyObject*)self, \"var\");\n    if (!repr_var) {\n        goto error;\n    }\n\n    result = PyGccString_FromFormat(\"%s(var=%s, version=%i)\",\n                                           Py_TYPE(self)->tp_name,\n                                           PyGccString_AsString(repr_var),\n                                           version);\n\n error:\n    Py_XDECREF(repr_var);\n\n    return result;\n}\n\nPyObject *\nPyGccTreeList_repr(struct PyGccTree * self)\n{\n    PyObject *purpose = NULL;\n    PyObject *value = NULL;\n    PyObject *chain = NULL;\n    PyObject *repr_purpose = NULL;\n    PyObject *repr_value = NULL;\n    PyObject *repr_chain = NULL;\n    PyObject *result = NULL;\n\n    purpose = PyGccTree_New(gcc_private_make_tree(TREE_PURPOSE(self->t.inner)));\n    if (!purpose) {\n        goto error;\n    }\n    value = PyGccTree_New(gcc_private_make_tree(TREE_VALUE(self->t.inner)));\n    if (!value) {\n        goto error;\n    }\n    chain = PyGccTree_New(gcc_private_make_tree(TREE_CHAIN(self->t.inner)));\n    if (!chain) {\n        goto error;\n    }\n\n    repr_purpose = PyObject_Repr(purpose);\n    if (!repr_purpose) {\n        goto error;\n    }\n    repr_value = PyObject_Repr(value);\n    if (!repr_value) {\n        goto error;\n    }\n    repr_chain = PyObject_Repr(chain);\n    if (!repr_chain) {\n        goto error;\n    }\n\n    result = PyGccString_FromFormat(\"%s(purpose=%s, value=%s, chain=%s)\",\n                                           Py_TYPE(self)->tp_name,\n                                           PyGccString_AsString(repr_purpose),\n                                           PyGccString_AsString(repr_value),\n                                           PyGccString_AsString(repr_chain));\n error:\n    Py_XDECREF(purpose);\n    Py_XDECREF(value);\n    Py_XDECREF(chain);\n    Py_XDECREF(repr_purpose);\n    Py_XDECREF(repr_value);\n    Py_XDECREF(repr_chain);\n\n    return result;\n}\n\nPyObject *\nPyGccCaseLabelExpr_repr(PyObject * self)\n{\n    PyObject *low_repr = NULL;\n    PyObject *high_repr = NULL;\n    PyObject *target_repr = NULL;\n    PyObject *result = NULL;\n\n    low_repr = PyGcc_GetReprOfAttribute(self, \"low\");\n    if (!low_repr) {\n        goto cleanup;\n    }\n    high_repr = PyGcc_GetReprOfAttribute(self, \"high\");\n    if (!high_repr) {\n        goto cleanup;\n    }\n    target_repr = PyGcc_GetReprOfAttribute(self, \"target\");\n    if (!target_repr) {\n        goto cleanup;\n    }\n\n    result = PyGccString_FromFormat(\"%s(low=%s, high=%s, target=%s)\",\n                                           Py_TYPE(self)->tp_name,\n                                           PyGccString_AsString(low_repr),\n                                           PyGccString_AsString(high_repr),\n                                           PyGccString_AsString(target_repr));\n\n cleanup:\n    Py_XDECREF(low_repr);\n    Py_XDECREF(high_repr);\n    Py_XDECREF(target_repr);\n    return result;\n}\n\nPyObject *\nPyGccNamespaceDecl_lookup(struct PyGccTree * self, PyObject *args, PyObject *kwargs)\n{\n    tree t_result;\n    tree t_name;\n\n    const char *name;\n    const char *keywords[] = {\"name\",\n                              NULL};\n\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"s:lookup\", (char**)keywords,\n                                     &name)) {\n        return NULL;\n    }\n\n#if (GCC_VERSION >= 8000)\n    if (NULL == get_namespace_binding) {\n#else\n    if (NULL == namespace_binding) {\n#endif\n        return raise_cplusplus_only(\"gcc.NamespaceDecl.lookup\");\n    }\n\n    t_name = get_identifier(name);\n\n#if (GCC_VERSION >= 8000)\n    t_result = get_namespace_binding(self->t.inner, t_name);\n#else\n    t_result = namespace_binding(t_name, self->t.inner);\n#endif\n\n    return PyGccTree_New(gcc_private_make_tree(t_result));\n}\n\nPyObject *\nPyGccNamespaceDecl_unalias(struct PyGccTree * self, PyObject *args, PyObject *kwargs)\n{\n  tree t = self->t.inner;\n\n  if (NULL == DECL_NAMESPACE_ALIAS(t)) {\n    Py_INCREF(self);\n    return (PyObject *)self;\n  }\n\n  while (DECL_NAMESPACE_ALIAS(t)) {\n    t = DECL_NAMESPACE_ALIAS(t);\n  }\n\n  return PyGccTree_New(gcc_private_make_tree(t));\n}\n\nstatic PyObject *\nraise_namespace_alias(const char *what)\n{\n    return PyErr_Format(PyExc_RuntimeError,\n                        \"%s is not valid for an alias\",\n                        what);\n}\n\nPyObject *\nPyGccNamespaceDecl_declarations(tree t)\n{\n  if (NULL == cp_namespace_decls)\n    return raise_cplusplus_only(\"gcc.NamespaceDecl.declarations\");\n\n  /* throw if we are an alias,\n     if we unalias it, it may return a list containing itself.  */\n  if (DECL_NAMESPACE_ALIAS(t))\n    return raise_namespace_alias(\"gcc.NamespaceDecl.declarations\");\n\n  return PyGcc_TreeListFromChain(cp_namespace_decls(t));\n}\n\n#if (GCC_VERSION >= 8000)\n\nstatic int is_namespace (tree decl, void *)\n{\n    return (TREE_CODE (decl) == NAMESPACE_DECL\n            && !DECL_NAMESPACE_ALIAS (decl));\n}\n\n#endif /* #if (GCC_VERSION >= 8000) */\n\nPyObject *\nPyGccNamespaceDecl_namespaces(tree t)\n{\n  /* We don't actually call cp_namespace_decls, but we only actually call\n     c++ specific macros, not sure what happens.  */\n  if (NULL == cp_namespace_decls)\n    return raise_cplusplus_only(\"gcc.NamespaceDecl.namespaces\");\n\n  /* throw if we are an alias,\n     if we unalias it, it may return a list containing itself.  */\n  if (DECL_NAMESPACE_ALIAS(t))\n    return raise_namespace_alias(\"gcc.NamespaceDecl.namespaces\");\n\n  /* GCC 8's r248821 (aka f7564df45462679c3b0b82f2942f5fb50b640113)\n     eliminated the \"namespaces\" field from cp_binding_level.  */\n\n#if (GCC_VERSION >= 8000)\n  return PyGcc_TreeListFromChainWithFilter(NAMESPACE_LEVEL(t)->names,\n                                           is_namespace, NULL);\n#else\n  return PyGcc_TreeListFromChain(NAMESPACE_LEVEL(t)->namespaces);\n#endif\n}\n\n/* Accessing the fields and methods of compound types.\n   GCC 8's r250413 (aka ab87ee8f509c0b600102195704105d4d98ec59d9)\n   eliminated TYPE_METHODS, instead putting both fields and methods\n   on the TYPE_FIELDS chain, using DECL_DECLARES_FUNCTION_P to\n   distinguish them.  */\n\n#if (GCC_VERSION >= 8000)\n\nstatic int is_field (tree t, void *)\n{\n    return !DECL_DECLARES_FUNCTION_P (t);\n}\n\nstatic int is_method (tree t, void *)\n{\n    return DECL_DECLARES_FUNCTION_P (t);\n}\n\n#endif /* #if (GCC_VERSION >= 8000) */\n\nPyObject *\nPyGcc_GetFields(struct PyGccTree *self)\n{\n#if (GCC_VERSION >= 8000)\n    return PyGcc_TreeListFromChainWithFilter(TYPE_FIELDS(self->t.inner),\n                                             is_field, NULL);\n#else\n    return PyGcc_TreeListFromChain(TYPE_FIELDS(self->t.inner));\n#endif\n}\n\nPyObject *\nPyGcc_GetMethods(struct PyGccTree *self)\n{\n#if (GCC_VERSION >= 8000)\n    return PyGcc_TreeListFromChainWithFilter(TYPE_FIELDS(self->t.inner),\n                                             is_method, NULL);\n#else\n    return PyGcc_TreeListFromChain(TYPE_METHODS(self->t.inner));\n#endif\n}\n\n/* \n   GCC's debug_tree is implemented in:\n     gcc/print-tree.c\n   e.g. in:\n     /usr/src/debug/gcc-4.6.0-20110321/gcc/print-tree.c\n   and appears to be a good place to look when figuring out how the tree data\n   works.\n\n   dump_generic_node is defined around line 580 of tree-pretty-print.c\n*/\n\nunion tree_or_ptr {\n    gcc_tree tree;\n    void *ptr;\n};\n\nstatic PyObject *\nreal_make_tree_wrapper(void *ptr)\n{\n\n    struct PyGccTree *tree_obj = NULL;\n    PyGccWrapperTypeObject* tp;\n    union tree_or_ptr u;\n    u.ptr = ptr;\n\n    if (NULL == ptr) {\n\tPy_RETURN_NONE;\n    }\n  \n    tp = PyGcc_autogenerated_tree_type_for_tree(u.tree, 1);\n    assert(tp);\n    \n    tree_obj = PyGccWrapper_New(struct PyGccTree, tp);\n    if (!tree_obj) {\n        goto error;\n    }\n\n    tree_obj->t = u.tree;\n\n    return (PyObject*)tree_obj;\n      \nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccTree(PyGccTree *wrapper)\n{\n    gcc_tree_mark_in_use(wrapper->t);\n}\n\n/*\n   Ensure we have a unique PyGccTree per tree address (by maintaining a dict)\n   (what about lifetimes?)\n*/\nstatic PyObject *tree_wrapper_cache = NULL;\n\nPyObject *\nPyGccTree_New(gcc_tree t)\n{\n    union tree_or_ptr u;\n    u.tree = t;\n    return PyGcc_LazilyCreateWrapper(&tree_wrapper_cache,\n\t\t\t\t\t    u.ptr,\n\t\t\t\t\t    real_make_tree_wrapper);\n}\n\nPyObject *\nPyGccTree_NewUnique(gcc_tree t)\n{\n    union tree_or_ptr u;\n    u.tree = t;\n    return real_make_tree_wrapper(u.ptr);\n}\n\n/* Walk the chain of a tree, building a python list of wrapper gcc.Tree\n   instances */\nPyObject *\nPyGcc_TreeListFromChain(tree t)\n{\n    PyObject *result = NULL;\n    \n    result = PyList_New(0);\n    if (!result) {\n\tgoto error;\n    }\n\n    while (t) {\n\tPyObject *item;\n\titem = PyGccTree_New(gcc_private_make_tree(t));\n\tif (!item) {\n\t    goto error;\n\t}\n\tif (-1 == PyList_Append(result, item)) {\n            Py_DECREF(item);\n\t    goto error;\n\t}\n        Py_DECREF(item);\n\tt = TREE_CHAIN(t);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/* As above, but only add nodes for which \"filter\" returns true.  */\nPyObject *\nPyGcc_TreeListFromChainWithFilter(tree t,\n                                  int (*filter) (tree, void *),\n                                  void *user_data)\n{\n    PyObject *result = NULL;\n\n    result = PyList_New(0);\n    if (!result) {\n\tgoto error;\n    }\n\n    while (t) {\n        if (filter (t, user_data)) {\n            PyObject *item;\n\n            item = PyGccTree_New(gcc_private_make_tree(t));\n            if (!item) {\n                goto error;\n            }\n            if (-1 == PyList_Append(result, item)) {\n                Py_DECREF(item);\n                goto error;\n            }\n            Py_DECREF(item);\n        }\n\n        t = TREE_CHAIN(t);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/*\n  As above, but expect nodes of the form:\n     tree_list  ---> value\n         +--chain--> tree_list ---> value\n                         +--chain--> tree_list ---> value\n                                         +---chain--> NULL\n  Extract a list of objects for the values\n */\nPyObject *\nPyGcc_TreeMakeListFromTreeList(tree t)\n{\n    PyObject *result = NULL;\n\n    result = PyList_New(0);\n    if (!result) {\n       goto error;\n    }\n\n    while (t) {\n       PyObject *item;\n       item = PyGccTree_New(gcc_private_make_tree(TREE_VALUE(t)));\n       if (!item) {\n           goto error;\n       }\n       if (-1 == PyList_Append(result, item)) {\n           Py_DECREF(item);\n           goto error;\n       }\n       Py_DECREF(item);\n       t = TREE_CHAIN(t);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/*\n  As above, but expect nodes of the form:\n     tree_list  ---> (purpose, value)\n         +--chain--> tree_list ---> (purpose, value)\n                         +--chain--> tree_list ---> (purpose, value)\n                                         +---chain--> NULL\n  Extract a list of objects for the values\n */\nPyObject *\nPyGcc_TreeMakeListOfPairsFromTreeListChain(tree t)\n{\n    PyObject *result = NULL;\n\n    result = PyList_New(0);\n    if (!result) {\n       goto error;\n    }\n\n    while (t) {\n       PyObject *purpose;\n       PyObject *value;\n       PyObject *pair;\n       purpose = PyGccTree_New(gcc_private_make_tree(TREE_PURPOSE(t)));\n       if (!purpose) {\n           goto error;\n       }\n       value = PyGccTree_New(gcc_private_make_tree(TREE_VALUE(t)));\n       if (!value) {\n           Py_DECREF(purpose);\n           goto error;\n       }\n       pair = Py_BuildValue(\"OO\", purpose, value);\n       Py_DECREF(purpose);\n       Py_DECREF(value);\n       if (!pair) {\n           goto error;\n       }\n       if (-1 == PyList_Append(result, pair)) {\n           Py_DECREF(pair);\n           goto error;\n       }\n       Py_DECREF(pair);\n       t = TREE_CHAIN(t);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\nPyObject *\nVEC_tree_as_PyList(\n#if (GCC_VERSION >= 4008)\n    vec<tree, va_gc> *vec_nodes\n#else\n    VEC(tree,gc) *vec_nodes\n#endif\n)\n{\n    PyObject *result = NULL;\n    int i;\n    tree t;\n\n    result = PyList_New(GCC_COMPAT_VEC_LENGTH(tree, vec_nodes));\n    if (!result) {\n\tgoto error;\n    }\n\n    GCC_COMPAT_FOR_EACH_VEC_ELT(tree, vec_nodes, i, t) {\n\tPyObject *item;\n\titem = PyGccTree_New(gcc_private_make_tree(t));\n\tif (!item) {\n\t    goto error;\n\t}\n\tPyList_SetItem(result, i, item);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-variable.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-c-api/gcc-variable.h\"\n\nPyObject *\nPyGccVariable_New(gcc_variable var)\n{\n    struct PyGccVariable *var_obj = NULL;\n\n    if (NULL == var.inner) {\n\tPy_RETURN_NONE;\n    }\n  \n    var_obj = PyGccWrapper_New(struct PyGccVariable, &PyGccVariable_TypeObj);\n    if (!var_obj) {\n        goto error;\n    }\n\n    var_obj->var = var;\n\n    return (PyObject*)var_obj;\n      \nerror:\n    return NULL;\n}\n\nvoid\nPyGcc_WrtpMarkForPyGccVariable(PyGccVariable *wrapper)\n{\n    /* Mark the underlying object (recursing into its fields): */\n    gcc_variable_mark_in_use(wrapper->var);\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-version.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include <structseq.h>\n#include \"gcc-python.h\"\n#include \"plugin-version.h\"\n\n/* Version handling: */\n\nstatic struct plugin_gcc_version *actual_gcc_version;\n\n/* Define a gcc.Version type, as a structseq */\nstatic struct PyStructSequence_Field gcc_version_fields[] = {\n    {(char*)\"basever\", NULL},\n    {(char*)\"datestamp\", NULL},\n    {(char*)\"devphase\", NULL},\n    {(char*)\"revision\", NULL},\n    {(char*)\"configuration_arguments\", NULL},\n    {0}\n};\n\nstatic struct PyStructSequence_Desc gcc_version_desc = {\n    (char*)\"gcc.Version\", /* name */\n    NULL, /* doc */\n    gcc_version_fields,\n    5\n};\n\nPyTypeObject GccVersion_TypeObj;\n\nvoid\nPyGcc_version_init(struct plugin_gcc_version *version)\n{\n    actual_gcc_version = version;\n    PyStructSequence_InitType(&GccVersion_TypeObj, &gcc_version_desc);\n}\n\n\nstatic PyObject *\ngcc_version_to_object(struct plugin_gcc_version *version)\n{\n    PyObject *obj = PyStructSequence_New(&GccVersion_TypeObj);\n    if (!obj) {\n        return NULL;\n    }\n\n#define SET_ITEM(IDX, FIELD) \\\n    PyStructSequence_SET_ITEM(obj, (IDX), PyGccStringOrNone(version->FIELD));\n\n    SET_ITEM(0, basever);\n    SET_ITEM(1, datestamp);\n    SET_ITEM(2, devphase);\n    SET_ITEM(3, revision);\n    SET_ITEM(4, configuration_arguments);\n\n#undef SET_ITEM\n\n    return obj;\n}\n\nPyObject *\nPyGcc_get_plugin_gcc_version(PyObject *self, PyObject *args)\n{\n    /*\n       \"gcc_version\" is compiled in to the plugin, as part of\n       plugin-version.h:\n    */\n    return gcc_version_to_object(&gcc_version);\n}\n\nPyObject *\nPyGcc_get_gcc_version(PyObject *self, PyObject *args)\n{\n    /*\n       \"actual_gcc_version\" is passed in when the plugin is initialized\n    */\n    return gcc_version_to_object(actual_gcc_version);\n}\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-wrapper.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Low-level wrapper support, with integration with GCC's garbage\n  collector (aka \"GGC\")\n\n  High-level overview\n  ===================\n\n  We keep track of all \"live\" wrapper objects, and each one knows how\n  to mark the object it wraps; we register a hook into GCC\"s GC so that\n  when it starts marking, we iterate through all our live wrapper objects,\n  marking the underlying GCC objects.\n\n\n  Implementation details\n  ======================\n\n  All of our wrapper types are subclasses of PyGccWrapper, which adds\n  a doubly-linked list to the top of the objects, so that we can track\n  all live wrapper objects.  This list is updated via their PyTypeObject's\n  tp_alloc and tp_dealloc.\n\n  Each has a PyTypeObject that's actually a PyGccWrapperTypeObject, which adds\n  a \"wrtp_mark\" hook to a PyTypeObject, so that it can participate in\n  GCC's garbage collector.  It actually has to add it to PyHeapTypeObject,\n  given that that's the (larger) in-memory layout of a user-defined type.\n\n  In order to correctly inherit this wrtp_mark slot, we need to override the\n  creation of any user-defined subclases of these PyTypeObjects, adding the\n  \"inherit the wrtp_mark callback\" logic.  We do this by setting the ob_type\n  of our PyGccWrapperTypeObject to be PyGccWrapperMeta_TypeObj, which supplies\n  a custom tp_new hook: analogous to setting a __metaclass__:\n\n     http://docs.python.org/reference/datamodel.html#customizing-class-creation\n\n  Thus, given e.g.\n\n      class MyPass(gcc.GimplePass):\n           ...etc...\n      p = MyPass('mypass')\n\n  p is a PyGccPass\n     ob_type == address on heap of user-defined type (\"MyPass\")\n\n  \"MyPass\" is this heap-allocated PyGccWrapperTypeObject:\n     ob_type == &PyGccWrapperMetaType\n     tp_base == &PyGccGimplePassType (the parent class: \"gcc.GimplePass\")\n     wrtp_mark == PyGcc_WrtpMarkForPyGccPass (inherited from tp_base via\n                  PyGccWrapperMetaType.tp_new)\n\n  PyGccGimplePassType is a statically-allocated PyGccWrapperTypeObject (in\n  autogenerated-pass.c):\n     ob_type == &PyGccWrapperMetaType\n     tp_base == &PyGccPass_TypeObj (the parent class: \"gcc.Pass\")\n     wrtp_mark == PyGcc_WrtpMarkForPyGccPass (\"manually\" set up by\n                  generate-pass-c.py)\n\n  PyGccPass_TypeObj is a statically-allocated PyGccWrapperTypeObject (in\n  autogenerated-pass.c):\n     ob_type == &PyGccWrapperMetaType\n     tp_base == NULL, but becomes &PyBaseObject_Type aka \"object\"\n     wrtp_mark == PyGcc_WrtpMarkForPyGccPass (\"manually\" set up by\n                  generate-pass-c.py)\n\n  PyGccWrapperMetaType is the statically-allocated metaclass for the above\n  type objects (\"gcc.WrapperMeta\")\n\n  (as it happens, gcc.Pass wraps an object that doesn't participate in the\n  GCC garbage collector, so this is somewhat redundant.  However, it should\n  matter when creating user-defined subclasses of types that *do* wrap a\n  GC-managed object)\n\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n#include \"gcc-python-wrappers.h\"\n#include \"gcc-python-compat.h\"\n\nstatic void\nforce_gcc_gc(void);\n\n/* Debugging, for use by selftest routine */\nstatic int debug_PyGcc_wrapper = 0;\n\n/*\n  This is the overriden tp_new in our metatype: when we create new subtypes,\n  it copies up our added slots:\n*/\nstatic PyObject*\nPyGcc_wrapper_meta_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds)\n{\n    PyGccWrapperTypeObject* new_type;\n    PyGccWrapperTypeObject* base_type;\n\n    /* Use PyType_Type's tp_new to do most of the work: */\n    new_type = (PyGccWrapperTypeObject*)PyType_Type.tp_new(type, args, kwds);\n    if (!new_type) {\n        return NULL;\n    }\n\n    /* Verify that the metaclass is sane, and that the created type object\n       will thus be large enough for our extra information: */\n    assert(Py_TYPE(new_type)->tp_basicsize >= (int)sizeof(PyGccWrapperTypeObject));\n\n    base_type = (PyGccWrapperTypeObject*)((PyTypeObject*)new_type)->tp_base;\n    assert(base_type);\n\n    /* Inherit wrtp_mark: */\n    assert(base_type->wrtp_mark);\n    new_type->wrtp_mark = base_type->wrtp_mark;\n\n    return (PyObject*)new_type;\n}\n\nPyTypeObject PyGccWrapperMeta_TypeObj  = {\n    PyVarObject_HEAD_INIT(&PyType_Type, 0)\n    \"gcc.WrapperMeta\", /*tp_name*/\n    sizeof(PyGccWrapperTypeObject), /*tp_basicsize*/\n    0, /*tp_itemsize*/\n    NULL, /* tp_dealloc */\n#if PY_VERSION_HEX >= 0x03080000\n    0, /*tp_vectorcall_offset*/\n#else\n    NULL, /* tp_print */\n#endif\n    NULL, /* tp_getattr */\n    NULL, /* tp_setattr */\n#if PY_MAJOR_VERSION < 3\n    0, /*tp_compare*/\n#else\n    0, /*reserved*/\n#endif\n    NULL, /* tp_repr */\n    NULL, /* tp_as_number */\n    NULL, /* tp_as_sequence */\n    NULL, /* tp_as_mapping */\n    NULL, /* tp_hash */\n    NULL, /* tp_call */\n    NULL, /* tp_str */\n    NULL, /* tp_getattro */\n    NULL, /* tp_setattro */\n    NULL, /* tp_as_buffer */\n    Py_TPFLAGS_DEFAULT, /* tp_flags */\n    0, /*tp_doc*/\n    NULL, /* tp_traverse */\n    NULL, /* tp_clear */\n    NULL, /* tp_richcompare */\n    0, /* tp_weaklistoffset */\n    NULL, /* tp_iter */\n    NULL, /* tp_iternext */\n    NULL, /* tp_methods */\n    NULL, /* tp_members */\n    NULL, /* tp_getset */\n    &PyType_Type, /* tp_base */\n    NULL, /* tp_dict */\n    NULL, /* tp_descr_get */\n    NULL, /* tp_descr_set */\n    0, /* tp_dictoffset */\n    NULL, /* tp_init */\n    NULL, /* tp_alloc */\n    PyGcc_wrapper_meta_tp_new, /* tp_new */\n    NULL, /* tp_free */\n    NULL, /* tp_is_gc */\n    NULL, /* tp_bases */\n    NULL, /* tp_mro */\n    NULL, /* tp_cache */\n    NULL, /* tp_subclasses */\n    NULL, /* tp_weaklist */\n    NULL, /* tp_del */\n#if PY_VERSION_HEX >= 0x02060000\n    0, /*tp_version_tag*/\n#endif\n};\n\n/* Maintain a circular linked list of PyGccWrapper instances: */\nstatic struct PyGccWrapper sentinel = {\n    PyObject_HEAD_INIT(NULL)\n    &sentinel,\n    &sentinel,\n};\n\nPyGccWrapper *\n_PyGccWrapper_New(PyGccWrapperTypeObject *typeobj)\n{\n    PyGccWrapper *obj;\n    assert(typeobj);\n\n    obj = PyObject_New(PyGccWrapper,\n                       (PyTypeObject*)typeobj);\n    if (!obj) {\n        return NULL;\n    }\n\n    /* Add to list of live PyGccWrapper objects: */\n    PyGccWrapper_Track(obj);\n\n    return obj;\n}\n\nextern void\nPyGccWrapper_Track(struct PyGccWrapper *obj)\n{\n    assert(obj);\n    assert(sentinel.wr_next);\n    assert(sentinel.wr_prev);\n    /* obj is uninitialized, apart from ob_type and ob_refcnt */\n\n    if (debug_PyGcc_wrapper) {\n        printf(\"  PyGccWrapper_Track: %s\\n\",\n               Py_TYPE(obj)->tp_name);\n    }\n\n    /*\n      obj's type must use correct delloc, so that obj removes itself from the\n      list.  obj->ob_type->tp_dealloc should be either\n      PyGccWrapper_Dealloc or subtype_dealloc\n     */\n\n    /* Add to end of list, immediately before sentinel: */\n    assert(sentinel.wr_prev->wr_next == &sentinel);\n    sentinel.wr_prev->wr_next = obj;\n    obj->wr_prev = sentinel.wr_prev;\n    obj->wr_next = &sentinel;\n    sentinel.wr_prev = obj;\n\n    assert(obj->wr_prev);\n    assert(obj->wr_next);\n}\n\nvoid\nPyGcc_wrapper_untrack(struct PyGccWrapper *obj)\n{\n    if (debug_PyGcc_wrapper) {\n        printf(\"    PyGcc_wrapper_untrack: %s\\n\", Py_TYPE(obj)->tp_name);\n    }\n\n    assert(obj);\n    assert(Py_REFCNT(obj) == 0);\n\n    /*\n      Remove from the linked list if it's within it\n\n      (If the object constructor fails, then we have only a\n      partially-constructed object, which might not have been\n      added to the linked list yet)\n    */\n    if (obj->wr_prev) {\n        assert(sentinel.wr_next);\n        assert(sentinel.wr_prev);\n        assert(obj->wr_next);\n\n        /* Remove from linked list: */\n        obj->wr_prev->wr_next = obj->wr_next;\n        obj->wr_next->wr_prev = obj->wr_prev;\n        obj->wr_prev = NULL;\n        obj->wr_next = NULL;\n    }\n}\n\nvoid\nPyGccWrapper_Dealloc(PyObject *obj)\n{\n    assert(obj);\n    assert(Py_REFCNT(obj) == 0);\n    if (debug_PyGcc_wrapper) {\n        printf(\"  PyGccWrapper_Dealloc: %s\\n\",\n               Py_TYPE(obj)->tp_name);\n    }\n    PyGcc_wrapper_untrack((struct PyGccWrapper*)obj);\n    Py_TYPE(obj)->tp_free(obj);\n}\n\nstatic void\nmy_walker(void *arg ATTRIBUTE_UNUSED)\n{\n    /*\n      Callback for use by GCC's garbage collector when marking\n\n      Walk all the PyGccWrapper objects here and if they reference\n      GCC GC objects, mark the underlying GCC objects so that they\n      don't get swept\n    */\n    struct PyGccWrapper *iter;\n\n    if (debug_PyGcc_wrapper) {\n        printf(\"  walking the live PyGccWrapper objects\\n\");\n    }\n    for (iter = sentinel.wr_next; iter != &sentinel; iter = iter->wr_next) {\n        wrtp_marker wrtp_mark;\n        if (debug_PyGcc_wrapper) {\n            printf(\"    marking inner object for: \");\n            PyObject_Print((PyObject*)iter, stdout, 0);\n            printf(\"\\n\");\n        }\n        wrtp_mark = ((PyGccWrapperTypeObject*)Py_TYPE(iter))->wrtp_mark;\n        assert(wrtp_mark);\n        wrtp_mark(iter);\n    }\n    if (debug_PyGcc_wrapper) {\n        printf(\"  finished walking the live PyGccWrapper objects\\n\");\n    }\n}\n\nstatic struct ggc_root_tab myroottab[] = {\n    { (char*)\"\", 1, 1, my_walker, NULL },\n    { NULL, }\n};\n\nvoid\nPyGcc_wrapper_init(void)\n{\n    /* Register our GC root-walking callback: */\n    ggc_register_root_tab(myroottab);\n\n    PyType_Ready(&PyGccWrapperMeta_TypeObj);\n}\n\nstatic void\nforce_gcc_gc(void)\n{\n    bool stored = ggc_force_collect;\n\n    ggc_force_collect = true;\n    ggc_collect();\n    ggc_force_collect = stored;\n}\n\nPyObject *\nPyGcc__force_garbage_collection(PyObject *self, PyObject *args)\n{\n    force_gcc_gc();\n    Py_RETURN_NONE;\n}\n\n#define MY_ASSERT(condition) \\\n    if (!(condition)) { \\\n         PyErr_SetString(PyExc_AssertionError, #condition); \\\n         return NULL; \\\n    }\n\nPyObject *\nPyGcc__gc_selftest(PyObject *self, PyObject *args)\n{\n    tree tree_intcst;\n    PyObject *wrapper_intcst;\n\n    tree tree_str;\n    PyObject *wrapper_str;\n\n    printf(\"gcc._gc_selftest() starting\\n\");\n\n    /* Enable verbose logging: */\n    debug_PyGcc_wrapper = 1;\n\n    /*\n      Approach: construct various GCC objects here, unreferenced by anything.\n      Wrap them in Python objects, then force the GCC GC, then verify that the\n      underlying objects were marked, and weren't collected.\n\n      See http://gcc.gnu.org/onlinedocs/gccint/Type-Information.html for some\n      notes on GCC's garbage collector.\n    */\n\n    printf(\"creating test GCC objects\\n\");\n\n    /* We're called from PLUGIN_FINISH, so integer_types[] should be ready: */\n    tree_intcst = build_int_cst(integer_types[itk_int], 42);\n    wrapper_intcst = PyGccTree_NewUnique(gcc_private_make_tree(tree_intcst));\n    MY_ASSERT(wrapper_intcst);\n\n    #define MY_TEST_STRING \"I am only referenced via a python wrapper\"\n    tree_str = build_string(strlen(MY_TEST_STRING), MY_TEST_STRING);\n\n    /* We should now have a newly-allocated tree node; it should not\n       have been marked yet by the GC: */\n    MY_ASSERT(tree_str);\n    //MY_ASSERT(!ggc_marked_p(str)); // this fails, why? why is it being marked?\n\n    /* Wrap it with a Python object: */\n    wrapper_str = PyGccTree_NewUnique(gcc_private_make_tree(tree_str));\n    MY_ASSERT(wrapper_str);\n\n    /* Force a garbage collection: */\n    printf(\"forcing a garbage collection:\\n\");\n    force_gcc_gc();\n    printf(\"completed the forced garbage collection\\n\");\n\n    /*\n      Verify that the various wrapped objects were marked (via the Python\n      wrapper).\n      If it was not marked, then we're accessing freed memory,\n      and this will likely fail with an Internal Compiler Error\n     */\n    printf(\"verifying that the underlying GCC objects were marked\\n\");\n    MY_ASSERT(ggc_marked_p(tree_intcst));\n    MY_ASSERT(ggc_marked_p(tree_str));\n    printf(\"all of the underlying GCC objects were indeed marked\\n\");\n\n    /* Clean up the wrapper objects: */\n    printf(\"invoking DECREF on Python wrapper objects\\n\");\n    Py_DECREF(wrapper_intcst);\n    Py_DECREF(wrapper_str);\n\n    /* FIXME: need to do this for all of our types (base classes, at least) */\n\n    printf(\"gcc._gc_selftest() complete\\n\");\n\n    /* Turn off verbose logging: */\n    debug_PyGcc_wrapper = 0;\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python-wrappers.h",
    "content": "/*\n   Copyright 2011-2013, 2015, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2015, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#ifndef INCLUDED__WRAPPERS_H\n#define INCLUDED__WRAPPERS_H\n\n#include \"gcc-python.h\"\n#include \"tree-pass.h\"\n#include \"opts.h\"\n#include \"cgraph.h\"\n\n/*\n  Create a callback for use in a gcc for_each iterator to make wrapper\n  objects for the underlying gcc objects being iterated, and append the\n  wrapper objects to a Python list\n*/\n#define IMPL_APPENDER(FNNAME, KIND, MAKE_WRAPPER) \\\n  static bool FNNAME(KIND var, void *user_data)    \\\n  {                                                \\\n      PyObject *result = (PyObject*)user_data;     \\\n      PyObject *obj_var;                           \\\n      obj_var = MAKE_WRAPPER(var);                 \\\n      if (!obj_var) {                              \\\n          return true;                             \\\n      }                                            \\\n      if (-1 == PyList_Append(result, obj_var)) {  \\\n          Py_DECREF(obj_var);                      \\\n          return true;                             \\\n      }                                            \\\n      /* Success: */                               \\\n      Py_DECREF(obj_var);                          \\\n      return false;                                \\\n  }\n\n/*\n  Create the body of a function that builds a list by calling a for_each\n  ITERATOR, passing in the APPENDER callback to convert the iterated items\n  into Python wrapper objects\n */\n#define IMPL_LIST_MAKER(ITERATOR, ARG, APPENDER) \\\n    PyObject *result;                            \\\n    result = PyList_New(0);                      \\\n    if (!result) {                               \\\n        return NULL;                             \\\n    }                                            \\\n    if (ITERATOR((ARG), APPENDER, result)) {     \\\n        Py_DECREF(result);                       \\\n        return NULL;                             \\\n    }                                            \\\n    return result;\n\n/*\nAs per IMPL_LIST_MAKER, but for a global iterator that takes no ARG\n */\n#define IMPL_GLOBAL_LIST_MAKER(ITERATOR, APPENDER) \\\n    PyObject *result;                 \\\n    result = PyList_New(0);           \\\n    if (!result) {                    \\\n        return NULL;                  \\\n    }                                 \\\n    if (ITERATOR(APPENDER, result)) { \\\n        Py_DECREF(result);            \\\n        return NULL;                  \\\n    }                                 \\\n    return result;\n\nPyMODINIT_FUNC initoptpass(void);\n\n/* gcc-python-attribute.c: */\nPyObject*\nPyGcc_RegisterAttribute(PyObject *self, PyObject *args, PyObject *kwargs);\n\n/* gcc-python-callbacks.c: */\nint PyGcc_IsWithinEvent(enum plugin_event *out_event);\n\nPyObject*\nPyGcc_RegisterCallback(PyObject *self, PyObject *args, PyObject *kwargs);\n\n/* gcc-python-callgraph.c: */\nPyObject *\nPyGccCallgraphEdge_repr(struct PyGccCallgraphEdge * self);\n\nPyObject *\nPyGccCallgraphEdge_str(struct PyGccCallgraphEdge * self);\n\nPyObject *\nPyGccCallgraphNode_repr(struct PyGccCallgraphNode * self);\n\nPyObject *\nPyGccCallgraphNode_str(struct PyGccCallgraphNode * self);\n\nextern PyObject *\nPyGccCallgraphNode_get_callers(struct PyGccCallgraphNode * self);\n\nextern PyObject *\nPyGccCallgraphNode_get_callees(struct PyGccCallgraphNode * self);\n\nPyObject *\nPyGcc_get_callgraph_nodes(PyObject *self, PyObject *args);\n\n/* gcc-python-diagnostics.c: */\nPyObject*\nPyGcc_permerror(PyObject *self, PyObject *args);\n\nPyObject *\nPyGcc_error(PyObject *self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGcc_warning(PyObject *self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGcc_inform(PyObject *self, PyObject *args, PyObject *kwargs);\n\n/* gcc-python-pass.c: */\nextern PyObject *\nPyGccPass_New(struct opt_pass *pass);\n\n/* gcc-python-location.c: */\nint\nPyGccLocation_init(PyGccLocation *self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccLocation_repr(struct PyGccLocation * self);\n\nPyObject *\nPyGccLocation_str(struct PyGccLocation * self);\n\nPyObject *\nPyGccLocation_richcompare(PyObject *o1, PyObject *o2, int op);\n\nlong\nPyGccLocation_hash(struct PyGccLocation * self);\n\nPyObject *\nPyGccLocation_offset_column(PyGccLocation *self, PyObject *args);\n\n#if (GCC_VERSION >= 6000)\n\nPyObject *\nPyGccRichLocation_add_fixit_replace(PyGccRichLocation *self, PyObject *args,\n                                    PyObject *kwargs);\n\nint\nPyGccRichLocation_init(PyGccRichLocation *self, PyObject *args,\n                       PyObject *kwargs);\n\n#endif\n\n/* gcc-python-cfg.c: */\nPyObject *\nPyGccBasicBlock_repr(struct PyGccBasicBlock * self);\n\nPyObject *\nPyGccBasicBlock_get_preds(PyGccBasicBlock *self, void *closure);\n\nPyObject *\nPyGccBasicBlock_get_succs(PyGccBasicBlock *self, void *closure);\n\nPyObject *\nPyGccBasicBlock_get_gimple(PyGccBasicBlock *self, void *closure);\n\nPyObject *\nPyGccBasicBlock_get_phi_nodes(PyGccBasicBlock *self, void *closure);\n\nPyObject *\nPyGccBasicBlock_get_rtl(PyGccBasicBlock *self, void *closure);\n\nPyObject *\nPyGccCfg_get_basic_blocks(PyGccCfg *self, void *closure);\n\nPyObject *\nPyGccCfg_get_block_for_label(PyObject *self, PyObject *args);\n\n/* autogenerated-tree.c: */\n\n/* return -1 if there isn't an enum tree_code associated with this type */\nint\nPyGcc_tree_type_object_as_tree_code(PyObject *cls,\n                                         enum tree_code *out);\n\n/* gcc-python-tree.c: */\n/* FIXME: autogenerate these: */\nextern gcc_decl\nPyGccTree_as_gcc_decl(struct PyGccTree * self);\n\nextern gcc_type\nPyGccTree_as_gcc_type(struct PyGccTree * self);\n\nextern gcc_fixed_point_type\nPyGccTree_as_gcc_fixed_point_type(struct PyGccTree * self);\n\nextern gcc_integer_type\nPyGccTree_as_gcc_integer_type(struct PyGccTree * self);\n\nextern gcc_real_type\nPyGccTree_as_gcc_real_type(struct PyGccTree * self);\n\nextern gcc_translation_unit_decl\nPyGccTree_as_gcc_translation_unit_decl(struct PyGccTree * self);\n\nextern gcc_ssa_name\nPyGccTree_as_gcc_ssa_name(struct PyGccTree * self);\n\nextern gcc_case_label_expr\nPyGccTree_as_gcc_case_label_expr(struct PyGccTree * self);\n\nextern PyObject *\nPyGccBlock_New(gcc_block t);\n\nextern PyObject *\nPyGccPointerType_New(gcc_pointer_type t);\n\nPyObject *\nPyGccPointerType_repr(struct PyGccTree * self);\n\nextern PyObject *\nPyGccCaseLabelExpr_New(gcc_case_label_expr t);\n\nPyObject *\nPyGccTree_str(struct PyGccTree * self);\n\nlong\nPyGccTree_hash(struct PyGccTree * self);\n\nPyObject *\nPyGccTree_richcompare(PyObject *o1, PyObject *o2, int op);\n\nPyObject *\nPyGccTree_get_str_no_uid(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccTree_get_symbol(PyObject *cls, PyObject *args);\n\nPyObject *\nPyGccFunction_repr(struct PyGccFunction * self);\n\nlong\nPyGccFunction_hash(struct PyGccFunction * self);\n\nPyObject *\nPyGccFunction_richcompare(PyObject *o1, PyObject *o2, int op);\n\nPyObject *\nPyGccArrayRef_repr(PyObject *self);\n\nPyObject *\nPyGccComponentRef_repr(PyObject *self);\n\nPyObject *\nPyGccDeclaration_get_name(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccDeclaration_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccFunctionDecl_get_fullname(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccFunctionDecl_get_callgraph_node(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccIdentifierNode_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccType_get_attributes(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccType_get_sizeof(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccFunction_TypeObj_get_argument_types(struct PyGccTree * self,void *closure);\n\nPyObject *\nPyGccFunction_TypeObj_is_variadic(struct PyGccTree * self, void *closure);\n\nPyObject *\nPyGccConstructor_get_elements(PyObject *self, void *closure);\n\nPyObject *\nPyGccIntegerConstant_get_constant(struct PyGccTree * self, void *closure);\n\nPyObject *\nPyGccIntegerConstant_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccRealCst_get_constant(struct PyGccTree * self, void *closure);\n\nPyObject *\nPyGccRealCst_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccIntegerType_get_signed_equivalent(struct PyGccTree * self, void *closure);\n\nPyObject *\nPyGccIntegerType_get_unsigned_equivalent(struct PyGccTree * self, void *closure);\n\nPyObject *\nPyGccIntegerType_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccMethodType_get_argument_types(struct PyGccTree * self,void *closure);\n\nPyObject *\nPyGccMethodType_is_variadic(struct PyGccTree * self,void *closure);\n\nPyObject *\nPyGccStringConstant_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccTypeDecl_get_pointer(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccTypeDecl_get_original_type(struct PyGccTree *self, void *closure);\n\nPyObject *\nPyGccSsaName_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccTreeList_repr(struct PyGccTree * self);\n\nPyObject *\nPyGccCaseLabelExpr_repr(PyObject *self);\n\nPyObject *\nPyGccNamespaceDecl_lookup(struct PyGccTree * self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccNamespaceDecl_unalias(struct PyGccTree * self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccNamespaceDecl_declarations(tree t);\n\nPyObject *\nPyGccNamespaceDecl_namespaces(tree t);\n\nPyObject *\nPyGcc_GetFields(struct PyGccTree *self);\n\nPyObject *\nPyGcc_GetMethods(struct PyGccTree *self);\n\n/* gcc-python-gimple.c: */\nextern gcc_gimple_asm\nPyGccGimple_as_gcc_gimple_asm(struct PyGccGimple *self);\n\nextern gcc_gimple_assign\nPyGccGimple_as_gcc_gimple_assign(struct PyGccGimple *self);\n\nextern gcc_gimple_call\nPyGccGimple_as_gcc_gimple_call(struct PyGccGimple *self);\n\nextern gcc_gimple_return\nPyGccGimple_as_gcc_gimple_return(struct PyGccGimple *self);\n\nextern gcc_gimple_cond\nPyGccGimple_as_gcc_gimple_cond(struct PyGccGimple *self);\n\nextern gcc_gimple_phi\nPyGccGimple_as_gcc_gimple_phi(struct PyGccGimple *self);\n\nextern gcc_gimple_switch\nPyGccGimple_as_gcc_gimple_switch(struct PyGccGimple *self);\n\nextern gcc_gimple_label\nPyGccGimple_as_gcc_gimple_label(struct PyGccGimple *self);\n\nPyObject *\nPyGccGimple_repr(struct PyGccGimple * self);\n\nPyObject *\nPyGccGimple_str(struct PyGccGimple * self);\n\nlong\nPyGccGimple_hash(struct PyGccGimple * self);\n\nPyObject *\nPyGccGimple_richcompare(PyObject *o1, PyObject *o2, int op);\n\nPyObject *\nPyGccGimple_walk_tree(struct PyGccGimple * self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccGimple_get_rhs(struct PyGccGimple *self, void *closure);\n\nPyObject *\nPyGccGimple_get_str_no_uid(struct PyGccGimple *self, void *closure);\n\nPyObject *\nPyGccGimpleCall_get_args(struct PyGccGimple *self, void *closure);\n\nPyObject *\nPyGccGimpleLabel_repr(PyObject * self);\n\nPyObject *\nPyGccGimplePhi_get_args(struct PyGccGimple *self, void *closure);\n\nPyObject *\nPyGccGimpleSwitch_get_labels(struct PyGccGimple *self, void *closure);\n\n/* gcc-python-option.c: */\nint PyGcc_option_is_enabled(enum opt_code opt_code);\n\nconst struct cl_option*\nPyGcc_option_to_cl_option(PyGccOption * self);\n\nint\nPyGccOption_init(PyGccOption * self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccOption_repr(PyGccOption * self);\n\nPyObject *\nPyGccOption_is_enabled(PyGccOption * self, void *closure);\n\n/* gcc-python-pass.c: */\nint\nPyGccGimplePass_init(PyObject *self, PyObject *args, PyObject *kwds);\n\nint\nPyGccRtlPass_init(PyObject *self, PyObject *args, PyObject *kwds);\n\nint\nPyGccSimpleIpaPass_init(PyObject *self, PyObject *args, PyObject *kwds);\n\nint\nPyGccIpaPass_init(PyObject *self, PyObject *args, PyObject *kwds);\n\nPyObject *\nPyGccPass_repr(struct PyGccPass * self);\n\nPyObject *\nPyGccPass_get_dump_enabled(struct PyGccPass *self, void *closure);\n\nint\nPyGccPass_set_dump_enabled(struct PyGccPass *self, PyObject *value, void *closure);\n\nPyObject *\nPyGccPass_get_roots(PyObject *cls, PyObject *noargs);\n\nPyObject *\nPyGccPass_get_by_name(PyObject *cls, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccPass_register_before(struct PyGccPass *self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccPass_register_after(struct PyGccPass *self, PyObject *args, PyObject *kwargs);\n\nPyObject *\nPyGccPass_replace(struct PyGccPass *self, PyObject *args, PyObject *kwargs);\n\n\n/* gcc-python-pretty-printer.c: */\n#include \"pretty-print.h\"\nstruct PyGccPrettyPrinter {\n    PyObject_HEAD\n    pretty_printer pp;\n    FILE *file_ptr;\n    char buf[1024]; /* FIXME */\n};\n\nextern PyTypeObject PyGccPrettyPrinter_TypeObj;\n\nPyObject*\nPyGccPrettyPrinter_New(void);\n\npretty_printer*\nPyGccPrettyPrinter_as_pp(PyObject *obj);\n\nPyObject*\nPyGccPrettyPrinter_as_string(PyObject *obj);\n\nvoid\nPyGccPrettyPrinter_dealloc(PyObject *obj);\n\n/* gcc-python-rtl.c: */\n#if (GCC_VERSION < 5000)\nPyObject *\nPyGccRtl_get_location(struct PyGccRtl *self, void *closure);\n#endif\n\nPyObject *\nPyGccRtl_get_operands(struct PyGccRtl *self, void *closure);\n\nPyObject *\nPyGccRtl_repr(struct PyGccRtl * self);\n\nPyObject *\nPyGccRtl_str(struct PyGccRtl * self);\n\nPyObject *\nPyGcc_TreeListFromChain(tree t);\n\nPyObject *\nPyGcc_TreeListFromChainWithFilter(tree t,\n                                  int (*filter) (tree, void *),\n                                  void *user_data);\n\nPyObject *\nPyGcc_TreeMakeListFromTreeList(tree t);\n\nPyObject *\nPyGcc_TreeMakeListOfPairsFromTreeListChain(tree t);\n\n/* gcc-python-version.c: */\nvoid\nPyGcc_version_init(struct plugin_gcc_version *version);\n\nPyObject *\nPyGcc_get_plugin_gcc_version(PyObject *self, PyObject *args);\n\nPyObject *\nPyGcc_get_gcc_version(PyObject *self, PyObject *args);\n\n/* gcc-python-wrappers.c: */\nvoid\nPyGcc_wrapper_init(void);\n\nPyObject *\nPyGcc__force_garbage_collection(PyObject *self, PyObject *args);\n\nPyObject *\nPyGcc__gc_selftest(PyObject *self, PyObject *args);\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n\n#endif /* INCLUDED__WRAPPERS_H */\n"
  },
  {
    "path": "gcc-python.c",
    "content": "/*\n   Copyright 2011-2013, 2015 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2015 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n#include \"gcc-python.h\"\n\n#include \"gcc-python-closure.h\"\n#include \"gcc-python-wrappers.h\"\n\n#include \"gcc-c-api/gcc-location.h\"\n#include \"gcc-c-api/gcc-variable.h\"\n#include \"gcc-c-api/gcc-declaration.h\"\n#include \"gcc-c-api/gcc-diagnostics.h\"\n#include \"gcc-c-api/gcc-option.h\"\n\nint plugin_is_GPL_compatible;\n\n#include \"plugin-version.h\"\n\n#if 1\n/* Ideally we wouldn't have these includes here: */\n#if (GCC_VERSION >= 6000)\n#include \"cp/cp-tree.h\" /* for cp_expr */\n#endif\n#include \"cp/name-lookup.h\" /* for global_namespace */\n#include \"tree.h\"\n#include \"function.h\"\n#include \"cgraph.h\"\n//#include \"opts.h\"\n\n/* \"maybe_get_identifier\" was moved from tree.h to stringpool.h in 4.9 */\n#if (GCC_VERSION >= 4009)\n#include \"stringpool.h\"\n#endif\n\n/*\n * Use an unqualified name here and rely on dual search paths to let the\n * compiler find it.  This deals with c-pragma.h moving to a\n * subdirectory in newer versions of gcc.\n */\n#include \"c-pragma.h\" /* for parse_in */\n#endif\n\n#if 0\n#define LOG(msg) \\\n    (void)fprintf(stderr, \"%s:%i:%s\\n\", __FILE__, __LINE__, (msg))\n#else\n#define LOG(msg) ((void)0);\n#endif\n\n\n#define GCC_PYTHON_TRACE_ALL_EVENTS 0\n#if GCC_PYTHON_TRACE_ALL_EVENTS\nstatic const char* event_name[] = {\n#define DEFEVENT(NAME) \\\n  #NAME, \n# include \"plugin.def\"\n# undef DEFEVENT\n};\n\nstatic void\ntrace_callback(enum plugin_event event, void *gcc_data, void *user_data)\n{\n    fprintf(stderr,\n\t    \"%s:%i:trace_callback(%s, %p, %p)\\n\",\n\t    __FILE__, __LINE__, event_name[event], gcc_data, user_data);\n    fprintf(stderr, \"  cfun:%p\\n\", cfun);\n}\n\n#define DEFEVENT(NAME) \\\nstatic void trace_callback_for_##NAME(void *gcc_data, void *user_data) \\\n{ \\\n     trace_callback(NAME, gcc_data, user_data); \\\n}\n# include \"plugin.def\"\n# undef DEFEVENT\n#endif /* GCC_PYTHON_TRACE_ALL_EVENTS */\n\n/*\n  Weakly import parse_in; it will be non-NULL in the C and C++ frontend,\n  but it's not available lto1 (link-time optimization)\n*/\n__typeof__ (parse_in) parse_in __attribute__ ((weak));\n\nstatic PyObject*\nPyGcc_define_macro(PyObject *self,\n                        PyObject *args, PyObject *kwargs)\n{\n    const char *macro;\n    const char *keywords[] = {\"macro\",\n                        NULL};\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"s:define_preprocessor_name\", (char**)keywords,\n                                     &macro)) {\n        return NULL;\n    }\n\n    if (0) {\n        fprintf(stderr, \"gcc.define_macro(\\\"%s\\\")\\n\", macro);\n    }\n\n    if (!parse_in) {\n        return PyErr_Format(PyExc_ValueError,\n                            \"gcc.define_macro(\\\"%s\\\") called without a compilation unit\",\n                            macro);\n    }\n\n    if (!PyGcc_IsWithinEvent(NULL)) {\n        return PyErr_Format(PyExc_ValueError,\n                            \"gcc.define_macro(\\\"%s\\\") called from outside an event callback\",\n                            macro);\n    }\n\n    cpp_define (parse_in, macro);\n\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\nPyGcc_set_location(PyObject *self, PyObject *args)\n{\n    PyGccLocation *loc_obj;\n    if (!PyArg_ParseTuple(args,\n                          \"O!:set_location\",\n                          &PyGccLocation_TypeObj, &loc_obj)) {\n        return NULL;\n    }\n\n    gcc_set_input_location(loc_obj->loc);\n\n    Py_RETURN_NONE;\n}\n\nstatic bool add_option_to_list(gcc_option opt, void *user_data)\n{\n    PyObject *result = (PyObject*)user_data;\n    PyObject *obj_opt;\n\n    obj_opt = PyGccOption_New(opt);\n    if (!obj_opt) {\n        return true;\n    }\n    if (-1 == PyList_Append(result, obj_opt)) {\n        Py_DECREF(obj_opt);\n        return true;\n    }\n    /* Success: */\n    Py_DECREF(obj_opt);\n    return false;\n}\n\nstatic PyObject *\nPyGcc_get_option_list(PyObject *self, PyObject *args)\n{\n    PyObject *result;\n\n    result = PyList_New(0);\n    if (!result) {\n        return NULL;\n    }\n\n    if (gcc_for_each_option(add_option_to_list, result)) {\n        Py_DECREF(result);\n        return NULL;\n    }\n\n    /* Success: */\n    return result;\n}\n\nstatic bool add_option_to_dict(gcc_option opt, void *user_data)\n{\n    PyObject *dict = (PyObject*)user_data;\n    PyObject *opt_obj;\n\n    opt_obj = PyGccOption_New(opt);\n    if (!opt_obj) {\n        return true;\n    }\n\n    if (-1 == PyDict_SetItemString(dict,\n                                   gcc_option_get_text(opt),\n                                   opt_obj)) {\n        Py_DECREF(opt_obj);\n        return true;\n    }\n\n    Py_DECREF(opt_obj);\n    return false;\n}\n\nstatic PyObject *\nPyGcc_get_option_dict(PyObject *self, PyObject *args)\n{\n    PyObject *dict;\n\n    dict = PyDict_New();\n    if (!dict) {\n        return NULL;\n    }\n\n    if (gcc_for_each_option(add_option_to_dict, dict)) {\n        Py_DECREF(dict);\n        return NULL;\n    }\n\n    /* Success: */\n    return dict;\n}\n\n/* Function has been removed from GCC 10. */\n#if (GCC_VERSION < 10000)\nstatic PyObject *\nPyGcc_get_parameters(PyObject *self, PyObject *args)\n{\n    PyObject *dict;\n    size_t i;\n\n    dict = PyDict_New();\n    if (!dict) {\n\tgoto error;\n    }\n\n    for (i = 0; i < get_num_compiler_params(); i++) {\n        PyObject *param_obj = PyGccParameter_New((compiler_param)i);\n        if (!param_obj) {\n\t    goto error;\n        }\n        if (-1 == PyDict_SetItemString(dict,\n                                       compiler_params[i].option,\n                                       param_obj)) {\n\t    Py_DECREF(param_obj);\n\t    goto error;\n\t}\n        Py_DECREF(param_obj);\n    }\n\n    return dict;\n\n error:\n    Py_XDECREF(dict);\n    return NULL;\n}\n#endif\n\nIMPL_APPENDER(add_var_to_list,\n              gcc_variable,\n              PyGccVariable_New)\n\nstatic PyObject *\nPyGcc_get_variables(PyObject *self, PyObject *args)\n{\n    IMPL_GLOBAL_LIST_MAKER(gcc_for_each_variable,\n                           add_var_to_list)\n}\n\nstatic PyObject *\nPyGcc_maybe_get_identifier(PyObject *self, PyObject *args)\n{\n    const char *str;\n    tree t;\n\n    if (!PyArg_ParseTuple(args,\n\t\t\t  \"s:maybe_get_identifier\",\n\t\t\t  &str)) {\n\treturn NULL;\n    }\n\n    t = maybe_get_identifier(str);\n    return PyGccTree_New(gcc_private_make_tree(t));\n}\n\nstatic PyObject *PyGcc_make_translation_unit_decl(gcc_translation_unit_decl decl)\n{\n    gcc_tree tree = gcc_translation_unit_decl_as_gcc_tree(decl);\n    return PyGccTree_New(tree);\n}\n\nIMPL_APPENDER(add_translation_unit_decl_to_list,\n              gcc_translation_unit_decl,\n              PyGcc_make_translation_unit_decl)\n\nstatic PyObject *\nPyGcc_get_translation_units(PyObject *self, PyObject *args)\n{\n    IMPL_GLOBAL_LIST_MAKER(gcc_for_each_translation_unit_decl,\n                           add_translation_unit_decl_to_list)\n}\n\n\n/* Weakly import global_namespace; it will be non-NULL for the C++ frontend.\n\n   GCC 8's r247599 (aka c99e91fe8d1191b348cbc1659fbfbac2fc07e154)\n   converted it from:\n      extern GTY(()) tree global_namespace;\n   to:\n      #define global_namespace               cp_global_trees[CPTI_GLOBAL]\n   so we have to access cp_global_trees instead.  */\n\n#if (GCC_VERSION >= 8000)\n__typeof__ (cp_global_trees) cp_global_trees __attribute__ ((weak));\n#else\n__typeof__ (global_namespace) global_namespace __attribute__ ((weak));\n#endif /* #if (GCC_VERSION >= 8000) */\n\n\nstatic PyObject *\nPyGcc_get_global_namespace(PyObject *self, PyObject *args)\n{\n    /* (global_namespace will be NULL outside the C++ frontend, giving a\n       result of None) */\n    return PyGccTree_New(gcc_private_make_tree(global_namespace));\n}\n\n/* Dump files */\n\nstatic PyObject *\nPyGcc_dump(PyObject *self, PyObject *arg)\n{\n    PyObject *str_obj;\n    /*\n       gcc/output.h: declares:\n           extern FILE *dump_file;\n       This is NULL when not defined.\n    */\n    if (!dump_file) {\n        /* The most common case; make it fast */\n        Py_RETURN_NONE;\n    }\n\n    str_obj = PyObject_Str(arg);\n    if (!str_obj) {\n        return NULL;\n    }\n\n    /* FIXME: encoding issues */\n    /* FIXME: GIL */\n    if (!fwrite(PyGccString_AsString(str_obj),\n                strlen(PyGccString_AsString(str_obj)),\n                1,\n                dump_file)) {\n        Py_DECREF(str_obj);\n        return PyErr_SetFromErrnoWithFilename(PyExc_IOError, dump_file_name);\n    }\n\n    Py_DECREF(str_obj);\n\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\nPyGcc_get_dump_file_name(PyObject *self, PyObject *noargs)\n{\n    /* gcc/tree-pass.h declares:\n        extern const char *dump_file_name;\n    */\n    return PyGccStringOrNone(dump_file_name);\n}\n\nstatic PyObject *\nPyGcc_get_dump_base_name(PyObject *self, PyObject *noargs)\n{\n    /*\n      The generated gcc/options.h has:\n          #ifdef GENERATOR_FILE\n          extern const char *dump_base_name;\n          #else\n            const char *x_dump_base_name;\n          #define dump_base_name global_options.x_dump_base_name\n          #endif\n    */\n    return PyGccStringOrNone(dump_base_name);\n}\n\nstatic PyObject *\nPyGcc_get_is_lto(PyObject *self, PyObject *noargs)\n{\n    /*\n      The generated gcc/options.h has:\n          #ifdef GENERATOR_FILE\n          extern bool in_lto_p;\n          #else\n            bool x_in_lto_p;\n          #define in_lto_p global_options.x_in_lto_p\n          #endif\n    */\n    return PyBool_FromLong(in_lto_p);\n}\n\nstatic PyMethodDef GccMethods[] = {\n    {\"register_attribute\",\n     (PyCFunction)PyGcc_RegisterAttribute,\n     (METH_VARARGS | METH_KEYWORDS),\n     \"Register an attribute.\"},\n\n    {\"register_callback\",\n     (PyCFunction)PyGcc_RegisterCallback,\n     (METH_VARARGS | METH_KEYWORDS),\n     \"Register a callback, to be called when various GCC events occur.\"},\n\n    {\"define_macro\",\n     (PyCFunction)PyGcc_define_macro,\n     (METH_VARARGS | METH_KEYWORDS),\n     \"Pre-define a named value in the preprocessor.\"},\n\n    /* Diagnostics: */\n    {\"permerror\", PyGcc_permerror, METH_VARARGS,\n     NULL},\n    {\"error\",\n     (PyCFunction)PyGcc_error,\n     (METH_VARARGS | METH_KEYWORDS),\n     (\"Report an error\\n\"\n      \"FIXME\\n\")},\n    {\"warning\",\n     (PyCFunction)PyGcc_warning,\n     (METH_VARARGS | METH_KEYWORDS),\n     (\"Report a warning\\n\"\n      \"FIXME\\n\")},\n    {\"inform\",\n     (PyCFunction)PyGcc_inform,\n     (METH_VARARGS | METH_KEYWORDS),\n     (\"Report an information message\\n\"\n      \"FIXME\\n\")},\n    {\"set_location\",\n     (PyCFunction)PyGcc_set_location,\n     METH_VARARGS,\n     (\"Temporarily set the default location for error reports\\n\")},\n\n    /* Options: */\n    {\"get_option_list\",\n     PyGcc_get_option_list,\n     METH_NOARGS,\n     \"Get all command-line options, as a list of gcc.Option instances\"},\n\n    {\"get_option_dict\",\n     PyGcc_get_option_dict,\n     METH_NOARGS,\n     (\"Get all command-line options, as a dict from command-line text strings \"\n      \"to gcc.Option instances\")},\n\n/* Function has been removed from GCC 10. */\n#if (GCC_VERSION < 10000)\n    {\"get_parameters\", PyGcc_get_parameters, METH_NOARGS,\n     \"Get all tunable GCC parameters.  Returns a dictionary, mapping from\"\n     \"option name -> gcc.Parameter instance\"},\n#endif\n\n    {\"get_variables\", PyGcc_get_variables, METH_NOARGS,\n     \"Get all variables in this compilation unit as a list of gcc.Variable\"},\n\n    {\"maybe_get_identifier\", PyGcc_maybe_get_identifier, METH_VARARGS,\n     \"Get the gcc.IdentifierNode with this name, if it exists, otherwise None\"},\n\n    {\"get_translation_units\", PyGcc_get_translation_units, METH_NOARGS,\n     \"Get a list of all gcc.TranslationUnitDecl\"},\n\n    {\"get_global_namespace\", PyGcc_get_global_namespace, METH_NOARGS,\n     \"C++: get the global namespace (aka '::') as a gcc.NamespaceDecl\"},\n\n    /* Version handling: */\n    {\"get_plugin_gcc_version\", PyGcc_get_plugin_gcc_version, METH_NOARGS,\n     \"Get the gcc.Version that this plugin was compiled with\"},\n\n    {\"get_gcc_version\", PyGcc_get_gcc_version, METH_NOARGS,\n     \"Get the gcc.Version for this version of GCC\"},\n\n    {\"get_callgraph_nodes\", PyGcc_get_callgraph_nodes, METH_VARARGS,\n     \"Get a list of all gcc.CallgraphNode instances\"},\n\n    /* Dump files */\n    {\"dump\", PyGcc_dump, METH_O,\n     \"Dump str() of the argument to the current dump file (or silently discard it when no dump file is open)\"},\n\n    {\"get_dump_file_name\", PyGcc_get_dump_file_name, METH_NOARGS,\n     \"Get the name of the current dump file (or None)\"},\n\n    {\"get_dump_base_name\", PyGcc_get_dump_base_name, METH_NOARGS,\n     \"Get the base name used when writing dump files\"},\n\n    {\"is_lto\", PyGcc_get_is_lto, METH_NOARGS,\n     \"Determine whether or not we're being invoked during link-time optimization\"},\n\n    /* Garbage collection */\n    {\"_force_garbage_collection\", PyGcc__force_garbage_collection, METH_NOARGS,\n     \"Forcibly trigger a single run of GCC's garbage collector\"},\n\n    {\"_gc_selftest\", PyGcc__gc_selftest, METH_NOARGS,\n     \"Run a garbage-collection selftest\"},\n\n    /* Sentinel: */\n    {NULL, NULL, 0, NULL}\n};\n\nstatic struct \n{\n    PyObject *module;\n    PyObject *argument_dict;\n    PyObject *argument_tuple;\n} PyGcc_globals;\n\n#if PY_MAJOR_VERSION == 3\nstatic struct PyModuleDef module_def = {\n    PyModuleDef_HEAD_INIT,\n    \"gcc\",   /* name of module */\n    NULL,\n    -1,\n    GccMethods\n};\n#endif\n\nPyMODINIT_FUNC PyInit_gcc(void)\n{\n#if PY_MAJOR_VERSION == 3\n    PyObject *m;\n    m = PyModule_Create(&module_def);\n#else\n    Py_InitModule(\"gcc\", GccMethods);\n#endif\n\n#if PY_MAJOR_VERSION == 3\n    return m;\n#endif\n}\n\nstatic int\nPyGcc_init_gcc_module(struct plugin_name_args *plugin_info)\n{\n    int i;\n\n    if (!PyGcc_globals.module) {\n        return 0;\n    }\n\n    /* Set up int constants for each of the enum plugin_event values: */\n    #define DEFEVENT(NAME) \\\n       PyModule_AddIntMacro(PyGcc_globals.module, NAME);\n    # include \"plugin.def\"\n    # undef DEFEVENT\n\n    PyGcc_globals.argument_dict = PyDict_New();\n    if (!PyGcc_globals.argument_dict) {\n        return 0;\n    }\n\n    PyGcc_globals.argument_tuple = PyTuple_New(plugin_info->argc);\n    if (!PyGcc_globals.argument_tuple) {\n        return 0;\n    }\n\n    /* PySys_SetArgvEx(plugin_info->argc, plugin_info->argv, 0); */\n    for (i=0; i<plugin_info->argc; i++) {\n\tstruct plugin_argument *arg = &plugin_info->argv[i];\n        PyObject *key;\n        PyObject *value;\n\tPyObject *pair;\n      \n\tkey = PyGccString_FromString(arg->key);\n\tif (arg->value) {\n            value = PyGccString_FromString(plugin_info->argv[i].value);\n\t} else {\n  \t    value = Py_None;\n\t}\n        PyDict_SetItem(PyGcc_globals.argument_dict, key, value);\n\t// FIXME: ref counts?\n\n\tpair = Py_BuildValue(\"(s, s)\", arg->key, arg->value);\n\tif (!pair) {\n  \t    return 1;\n\t}\n        PyTuple_SetItem(PyGcc_globals.argument_tuple, i, pair);\n\n    }\n    PyModule_AddObject(PyGcc_globals.module, \"argument_dict\", PyGcc_globals.argument_dict);\n    PyModule_AddObject(PyGcc_globals.module, \"argument_tuple\", PyGcc_globals.argument_tuple);\n\n    /* Pass properties: */\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_any);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_lcf);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_leh);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_cfg);\n#if (GCC_VERSION >= 4008)\n    /* PROP_referenced_vars went away in GCC 4.8 (in r190067) */\n#else\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_referenced_vars);\n#endif\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_ssa);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_no_crit_edges);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_rtl);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_lomp);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_cfglayout);\n    PyModule_AddIntMacro(PyGcc_globals.module, PROP_gimple_lcx);\n\n    PyModule_AddIntMacro(PyGcc_globals.module, GCC_VERSION);\n\n    /* Success: */\n    return 1;\n}\n\nstatic void PyGcc_run_any_command(void)\n{\n    PyObject* command_obj; /* borrowed ref */\n    int result;\n    const char *command_str;\n\n    command_obj = PyDict_GetItemString(PyGcc_globals.argument_dict, \"command\");\n    if (!command_obj) {\n        return;\n    }\n\n    command_str = PyGccString_AsString(command_obj);\n\n    if (0) {\n        fprintf(stderr, \"Running: %s\\n\", command_str);\n    }\n\n    result = PyRun_SimpleString(command_str);\n    if (-1 == result) {\n        /* Error running the python command */\n        Py_Finalize();\n        exit(1);\n    }\n}\n\nstatic void PyGcc_run_any_script(void)\n{\n    PyObject* script_name;\n    FILE *fp;\n    int result;\n  \n    script_name = PyDict_GetItemString(PyGcc_globals.argument_dict, \"script\");\n    if (!script_name) {\n        return;\n    }\n\n    fp = fopen(PyGccString_AsString(script_name), \"r\");\n    if (!fp) {\n        fprintf(stderr,\n\t\t\"Unable to read python script: %s\\n\",\n                PyGccString_AsString(script_name));\n\texit(1);\n    }\n    result = PyRun_SimpleFile(fp, PyGccString_AsString(script_name));\n    fclose(fp);\n    if (-1 == result) {\n        /* Error running the python script */\n        Py_Finalize();\n        exit(1);\n    }\n}\n\nint\nsetup_sys(struct plugin_name_args *plugin_info)\n{\n    /*\n\n     * Sets up \"sys.plugin_full_name\" as plugin_info->full_name.  This is the\n     path to the plugin (as specified with -fplugin=)\n\n     * Sets up \"sys.plugin_base_name\" as plugin_info->base_name.  This is the\n     short name, of the plugin (filename without .so suffix)\n\n     * Add the directory containing the plugin to \"sys.path\", so that it can\n     find modules relative to itself without needing PYTHONPATH to be set up.\n     (sys.path has already been initialized by the call to Py_Initialize)\n\n     * If PLUGIN_PYTHONPATH is defined, add it to \"sys.path\"\n\n    */\n    int result = 0; /* failure */\n    PyObject *full_name = NULL;\n    PyObject *base_name = NULL;\n    const char *program =\n      \"import sys;\\n\"\n      \"import os;\\n\"\n      \"sys.path.append(os.path.abspath(os.path.dirname(sys.plugin_full_name)))\\n\";\n\n    /* Setup \"sys.plugin_full_name\" */\n    full_name = PyGccString_FromString(plugin_info->full_name);\n    if (!full_name) {\n        goto error;\n    }\n    if (-1 == PySys_SetObject((char*)\"plugin_full_name\", full_name)) {\n        goto error;\n    }\n\n    /* Setup \"sys.plugin_base_name\" */\n    base_name = PyGccString_FromString(plugin_info->base_name);\n    if (!base_name) {\n        goto error;\n    }\n    if (-1 == PySys_SetObject((char*)\"plugin_base_name\", base_name)) {\n        goto error;\n    }\n\n    /* Add the plugin's path to sys.path */\n    if (-1 == PyRun_SimpleString(program)) {\n        goto error;\n    }\n\n#ifdef PLUGIN_PYTHONPATH\n    {\n        /*\n           Support having multiple builds of the plugin installed independently\n           of each other, by supporting each having a directory for support\n           files e.g. gccutils, libcpychecker, etc\n\n           We do this by seeing if PLUGIN_PYTHONPATH was defined in the\n           compile, and if so, adding it to sys.path:\n        */\n        const char *program2 =\n            \"import sys;\\n\"\n            \"import os;\\n\"\n            \"sys.path.append('\" PLUGIN_PYTHONPATH \"')\\n\";\n\n        if (-1 == PyRun_SimpleString(program2)) {\n            goto error;\n        }\n    }\n#endif\n\n    /* Success: */\n    result = 1;\n\n error:\n    Py_XDECREF(full_name);\n    Py_XDECREF(base_name);\n    return result;\n}\n\n/*\n  Wired up to PLUGIN_FINISH, this callback handles finalization for the plugin:\n*/\nvoid\non_plugin_finish(void *gcc_data, void *user_data)\n{\n    /*\n       Clean up the python runtime.\n\n       For python 3, this flushes buffering of sys.stdout and sys.stderr\n    */\n    Py_Finalize();\n}\n\nextern int\nplugin_init (struct plugin_name_args *plugin_info,\n             struct plugin_gcc_version *version) __attribute__((nonnull));\n\nint\nplugin_init (struct plugin_name_args *plugin_info,\n             struct plugin_gcc_version *version)\n{\n    LOG(\"plugin_init started\");\n\n    if (!plugin_default_version_check (version, &gcc_version)) {\n        return 1;\n    }\n\n#if PY_MAJOR_VERSION >= 3\n    /*\n      Python 3 added internal buffering to sys.stdout and sys.stderr, but this\n      leads to unpredictable interleavings of messages from gcc, such as from calling\n      gcc.warning() vs those from python scripts, such as from print() and\n      sys.stdout.write()\n\n      Suppress the buffering, to better support mixed gcc/python output:\n    */\n    Py_UnbufferedStdioFlag = 1;\n#endif\n\n    PyImport_AppendInittab(\"gcc\", PyInit_gcc);\n\n    LOG(\"calling Py_Initialize...\");\n\n    Py_Initialize();\n\n    LOG(\"Py_Initialize finished\");\n\n    PyGcc_globals.module = PyImport_ImportModule(\"gcc\");\n\n    PyEval_InitThreads();\n  \n    if (!PyGcc_init_gcc_module(plugin_info)) {\n        return 1;\n    }\n\n    if (!setup_sys(plugin_info)) {\n        return 1;\n    }\n\n    /* Init other modules */\n    PyGcc_wrapper_init();\n\n    /* FIXME: properly integrate them within the module hierarchy */\n\n    PyGcc_version_init(version);\n\n    autogenerated_callgraph_init_types();  /* FIXME: error checking! */\n    autogenerated_cfg_init_types();  /* FIXME: error checking! */\n    autogenerated_function_init_types();  /* FIXME: error checking! */\n    autogenerated_gimple_init_types();  /* FIXME: error checking! */\n    autogenerated_location_init_types();  /* FIXME: error checking! */\n    autogenerated_option_init_types();  /* FIXME: error checking! */\n#if (GCC_VERSION < 10000)\n    autogenerated_parameter_init_types();  /* FIXME: error checking! */\n#endif\n    autogenerated_pass_init_types();  /* FIXME: error checking! */\n    autogenerated_pretty_printer_init_types();  /* FIXME: error checking! */\n    autogenerated_rtl_init_types(); /* FIXME: error checking! */\n    autogenerated_tree_init_types(); /* FIXME: error checking! */\n    autogenerated_variable_init_types(); /* FIXME: error checking! */\n\n\n\n    autogenerated_callgraph_add_types(PyGcc_globals.module);\n    autogenerated_cfg_add_types(PyGcc_globals.module);\n    autogenerated_function_add_types(PyGcc_globals.module);\n    autogenerated_gimple_add_types(PyGcc_globals.module);\n    autogenerated_location_add_types(PyGcc_globals.module);\n    autogenerated_option_add_types(PyGcc_globals.module);\n#if (GCC_VERSION < 10000)\n    autogenerated_parameter_add_types(PyGcc_globals.module);\n#endif\n    autogenerated_pass_add_types(PyGcc_globals.module);\n    autogenerated_pretty_printer_add_types(PyGcc_globals.module);\n    autogenerated_rtl_add_types(PyGcc_globals.module);\n    autogenerated_tree_add_types(PyGcc_globals.module);\n    autogenerated_variable_add_types(PyGcc_globals.module);\n\n\n    /* Register at-exit finalization for the plugin: */\n    register_callback(plugin_info->base_name, PLUGIN_FINISH,\n                      on_plugin_finish, NULL);\n\n    PyGcc_run_any_command();\n    PyGcc_run_any_script();\n\n    //printf(\"%s:%i:got here\\n\", __FILE__, __LINE__);\n\n#if GCC_PYTHON_TRACE_ALL_EVENTS\n#define DEFEVENT(NAME) \\\n    if (NAME != PLUGIN_PASS_MANAGER_SETUP &&         \\\n        NAME != PLUGIN_INFO &&                       \\\n\tNAME != PLUGIN_REGISTER_GGC_ROOTS &&         \\\n\tNAME != PLUGIN_REGISTER_GGC_CACHES) {        \\\n    register_callback(plugin_info->base_name, NAME,  \\\n\t\t      trace_callback_for_##NAME, NULL); \\\n    }\n# include \"plugin.def\"\n# undef DEFEVENT\n#endif /* GCC_PYTHON_TRACE_ALL_EVENTS */\n\n    LOG(\"init_plugin finished\");\n\n    return 0;\n}\n\nPyObject *\nPyGccStringOrNone(const char *str_or_null)\n{\n    if (str_or_null) {\n\treturn PyGccString_FromString(str_or_null);\n    } else {\n\tPy_RETURN_NONE;\n    }\n}\n\nPyObject *\nPyGcc_int_from_decimal_string_buffer(const char *buf)\n{\n    PyObject *long_obj;\n#if PY_MAJOR_VERSION < 3\n    long long_val;\n    int overflow;\n#endif\n    long_obj = PyLong_FromString((char *)buf, NULL, 10);\n    if (!long_obj) {\n        return NULL;\n    }\n#if PY_MAJOR_VERSION >= 3\n    return long_obj;\n#else\n    long_val = PyLong_AsLongAndOverflow(long_obj, &overflow);\n    if (overflow) {\n        /* Doesn't fit in a PyIntObject; use the PyLongObject: */\n        return long_obj;\n    } else {\n        /* Fits in a PyIntObject: use that */\n        PyObject *int_obj = PyInt_FromLong(long_val);\n        if (!int_obj) {\n            return long_obj;\n        }\n        Py_DECREF(long_obj);\n        return int_obj;\n    }\n#endif\n}\n\n#if (GCC_VERSION < 5000)\n/*\n  \"double_int\" is declared in gcc/double-int.h as a pair of HOST_WIDE_INT.\n  These in turn are defined in gcc/hwint.h as a #define to one of \"long\",\n  \"long long\", or \"__int64\".\n\n  It appears that they can be interpreted as either \"unsigned\" or \"signed\"\n\n  How to convert this to other types?\n  We \"cheat\", and take it through the decimal representation, then convert\n  from decimal.  This is probably slow, but is (I hope) at least correct.\n*/\nvoid\nPyGcc_DoubleIntAsText(double_int di, bool is_unsigned,\n                              char *out, int bufsize)\n{\n    FILE *f;\n    assert(out);\n    assert(bufsize > 256); /* FIXME */\n\n    out[0] = '\\0';\n    f = fmemopen(out, bufsize, \"w\");\n    dump_double_int (f, di, is_unsigned);\n    fclose(f);\n}\n\nPyObject *\nPyGcc_int_from_double_int(double_int di, bool is_unsigned)\n{\n    char buf[512]; /* FIXME */\n    PyGcc_DoubleIntAsText(di, is_unsigned, buf, sizeof(buf));\n    return PyGcc_int_from_decimal_string_buffer(buf);\n}\n\n#endif /* #if (GCC_VERSION < 5000) */\n\n/*\n   GCC's headers \"poison\" strdup to make it unavailable, so we provide our own.\n\n   The buffer is allocated using PyMem_Malloc\n*/\nchar *\nPyGcc_strdup(const char *str)\n{\n    char *result;\n    char *dst;\n\n    result = (char*)PyMem_Malloc(strlen(str) + 1);\n\n    if (!result) {\n        return NULL;\n    }\n\n    dst = result;\n    while (*str) {\n        *(dst++) = *(str++);\n    }\n    *dst = '\\0';\n\n    return result;\n}\n\nvoid PyGcc_PrintException(const char *msg)\n{\n    /* Handler for Python exceptions */\n    assert(msg);\n\n    /*\n       Emit a gcc error, using GCC's \"input_location\"\n\n       Typically, by the time our code is running, that's generally just the\n       end of the source file.\n\n       The value is saved and restored whenever calling into Python code, and\n       within passes is initialized to the top of the function; it can be\n       temporarily overridden using gcc.set_location()\n    */\n    gcc_error_at(gcc_get_input_location(), msg);\n\n    /* Print the traceback: */\n    PyErr_PrintEx(1);\n}\n\nPyObject *\nPyGcc_GetReprOfAttribute(PyObject *obj, const char *attrname)\n{\n    PyObject *attr_obj;\n    PyObject *attr_repr;\n\n    attr_obj = PyObject_GetAttrString(obj, attrname);\n    if (!attr_obj) {\n        return NULL;\n    }\n    attr_repr = PyObject_Repr(attr_obj);\n    if (!attr_repr) {\n        Py_DECREF(attr_obj);\n        return NULL;\n    }\n\n    return attr_repr;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "gcc-python.h",
    "content": "/*\n   Copyright 2011-2013, 2015, 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011-2013, 2015, 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#ifndef INCLUDED__GCC_PYTHON_H\n#define INCLUDED__GCC_PYTHON_H\n\n#include <gcc-plugin.h>\n#include \"autogenerated-config.h\"\n#if 1\n#include \"tree.h\"\n\n#if (GCC_VERSION >= 4009)\n#include \"basic-block.h\" /* needed by gimple.h in 4.9 */\n#include \"function.h\" /* needed by gimple.h in 4.9 */\n#include \"tree-ssa-alias.h\" /* needed by gimple.h in 4.9 */\n#include \"internal-fn.h\" /* needed by gimple.h in 4.9 */\n#include \"is-a.h\" /* needed by gimple.h in 4.9 */\n#include \"predict.h\" /* needed by gimple.h in 4.9 */\n#include \"gimple-expr.h\" /* needed by gimple.h in 4.9 */\n#endif\n#include \"gimple.h\"\n\n\n/* gcc 10 removed this header */\n#if (GCC_VERSION < 10000)\n#include \"params.h\"\n#endif\n\n#endif\n#include \"gcc-c-api/gcc-cfg.h\"\n\n/* GCC doesn't seem to give us an ID for \"invalid event\", so invent one: */\n#define GCC_PYTHON_PLUGIN_BAD_EVENT (0xffff)\n\n/*\n  Define some macros to allow us to use cpychecker's custom attributes when\n  compiling the plugin using itself (gcc-with-cpychecker), but also to turn\n  them off when compiling with vanilla gcc (and other compilers).\n*/\n#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)\n  #define CPYCHECKER_RETURNS_BORROWED_REF \\\n    __attribute__((cpychecker_returns_borrowed_ref))\n#else\n  #define CPYCHECKER_RETURNS_BORROWED_REF\n#endif\n\n#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \\\n    __attribute__((cpychecker_steals_reference_to_arg(n)))\n#else\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)\n#endif\n\n#if defined(WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE)\n  #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(typename) \\\n     __attribute__((cpychecker_type_object_for_typedef(typename)))\n#else\n  #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(typename)\n#endif\n\n/*\n  PyObject shared header for wrapping GCC objects, for integration\n  with GCC's garbage collector (so that things we wrap don't get collected\n  from under us)\n*/\ntypedef struct PyGccWrapper\n{\n     PyObject_HEAD\n\n     /*\n       Keep track of a linked list of all live wrapper objects,\n       so that we can mark the wrapped objects for GCC's garbage\n       collector:\n     */\n     struct PyGccWrapper *wr_prev;\n     struct PyGccWrapper *wr_next;\n} PyGccWrapper;\n\n/*\n  PyTypeObject subclass for PyGccWrapper, adding a GC-marking callback:\n */\ntypedef void (*wrtp_marker) (PyGccWrapper *wrapper);\n\ntypedef struct PyGccWrapperTypeObject\n{\n    PyHeapTypeObject wrtp_base;\n\n    /* Callback for marking the wrapped objects when GCC's garbage\n       collector runs: */\n    wrtp_marker wrtp_mark;\n\n} PyGccWrapperTypeObject;\n\n/* gcc-python-wrapper.c */\n\n/*\n  Allocate a new PyGccWrapper of the given type, setting up:\n    - ob_refcnt\n    - ob_type\n  and calling PyGccWrapper_Track() on it:\n*/\n#define PyGccWrapper_New(ARG_structname, ARG_typeobj) \\\n    ( (ARG_structname*) _PyGccWrapper_New(ARG_typeobj) )\n\nextern PyGccWrapper *\n_PyGccWrapper_New(PyGccWrapperTypeObject *typeobj);\n\nextern void\nPyGccWrapper_Track(PyGccWrapper *obj);\n\nextern void\nPyGccWrapper_Dealloc(PyObject *obj);\n\nextern PyTypeObject PyGccWrapperMeta_TypeObj;\n/*\n  Macro DECLARE_SIMPLE_WRAPPER():\n    ARG_structname:\n      the struct tag for the resulting python wrapper class,\n      e.g. \"PyGccPass\"\n\n    ARG_typeobj:\n      the singleton PyTypeObject for the resulting python wrapper class\n      e.g. \"PyGccPass_TypeObj\"\n\n    ARG_typename:\n      a C identifier to use when referring to instances of the underlying\n      type e.g. \"pass\"\n\n    ARG_wrappedtype:\n      the GCC type being wrapped e.g. \"struct opt_pass *\"\n\n    ARG_fieldname:\n      the name of the field within the CPython struct, containing the pointer\n      to the GCC data\n */\n#define DECLARE_SIMPLE_WRAPPER(ARG_structname, ARG_typeobj, ARG_typename, ARG_wrappedtype, ARG_fieldname) \\\n  struct ARG_structname {           \\\n     struct PyGccWrapper head;      \\\n     ARG_wrappedtype ARG_fieldname; \\\n  };                                \\\n                                    \\\n  typedef struct ARG_structname ARG_structname;                          \\\n                                                                         \\\n  extern PyObject *                                                      \\\n  ARG_structname##_New(ARG_wrappedtype ARG_fieldname); \\\n                                                                         \\\n  extern PyObject *                                                      \\\n  ARG_structname##_NewUnique(ARG_wrappedtype ARG_fieldname); \\\n                                                                         \\\n  extern PyGccWrapperTypeObject ARG_typeobj                              \\\n    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(#ARG_structname);                 \\\n                                                                         \\\n  extern void                                                            \\\n  PyGcc_WrtpMarkFor##ARG_structname(ARG_structname *wrapper);               \\\n  /* end of macro */\n\nDECLARE_SIMPLE_WRAPPER(PyGccCallgraphEdge,\n\t\t       PyGccCallgraphEdge_TypeObj,\n\t\t       cgraph_edge,\n                       gcc_cgraph_edge, edge)\n\nDECLARE_SIMPLE_WRAPPER(PyGccCallgraphNode,\n\t\t       PyGccCallgraphNode_TypeObj,\n\t\t       cgraph_node,\n                       gcc_cgraph_node, node)\n\nDECLARE_SIMPLE_WRAPPER(PyGccPass,\n\t\t       PyGccPass_TypeObj,\n\t\t       pass,\n\t\t       struct opt_pass *, pass)\n\nDECLARE_SIMPLE_WRAPPER(PyGccLocation, \n\t\t       PyGccLocation_TypeObj,\n\t\t       location,\n\t\t       gcc_location, loc)\n\n/* class rich_location was added to libcpp in gcc 6.  */\n\n#if (GCC_VERSION >= 6000)\n\nDECLARE_SIMPLE_WRAPPER(PyGccRichLocation,\n\t\t       PyGccRichLocation_TypeObj,\n\t\t       rich_location,\n\t\t       rich_location, richloc)\n\n#endif\n\nDECLARE_SIMPLE_WRAPPER(PyGccGimple, \n\t\t       PyGccGimple_TypeObj,\n\t\t       gimple,\n\t\t       gcc_gimple, stmt);\n\nDECLARE_SIMPLE_WRAPPER(PyGccEdge,\n\t\t       PyGccEdge_TypeObj,\n\t\t       edge,\n\t\t       gcc_cfg_edge, e)\n\nDECLARE_SIMPLE_WRAPPER(PyGccBasicBlock, \n\t\t       PyGccBasicBlock_TypeObj,\n\t\t       basic_block,\n\t\t       gcc_cfg_block, bb)\n\nDECLARE_SIMPLE_WRAPPER(PyGccCfg, \n\t\t       PyGccCfg_TypeObj,\n\t\t       cfg,\n                       gcc_cfg, cfg)\n\nDECLARE_SIMPLE_WRAPPER(PyGccFunction, \n\t\t       PyGccFunction_TypeObj,\n\t\t       function,\n\t\t       gcc_function, fun)\n\nDECLARE_SIMPLE_WRAPPER(PyGccOption,\n\t\t       PyGccOption_TypeObj,\n                       option,\n                       gcc_option, opt)\n\n/* gcc 10 removed params.h */\n#if (GCC_VERSION < 10000)\nDECLARE_SIMPLE_WRAPPER(PyGccParameter,\n\t\t       PyGccParameter_TypeObj,\n                       param_num,\n\t\t       compiler_param, param_num)\n#endif\n\nDECLARE_SIMPLE_WRAPPER(PyGccRtl,\n                       PyGccRtl_TypeObj,\n#if (GCC_VERSION >= 5000)\n                       rtl_insn *,\n#else\n                       rtl,\n#endif\n                       gcc_rtl_insn, insn)\n\nDECLARE_SIMPLE_WRAPPER(PyGccTree,\n\t\t       PyGccTree_TypeObj,\n                       tree,\n\t\t       gcc_tree, t)\n\nDECLARE_SIMPLE_WRAPPER(PyGccVariable,\n\t\t       PyGccVariable_TypeObj,\n\t\t       variable,\n\t\t       gcc_variable, var)\n\n/* autogenerated-callgraph.c */\nint autogenerated_callgraph_init_types(void);\nvoid autogenerated_callgraph_add_types(PyObject *m);\n\n/* autogenerated-cfg.c */\nint autogenerated_cfg_init_types(void);\nvoid autogenerated_cfg_add_types(PyObject *m);\n\n/* autogenerated-function.c */\nint autogenerated_function_init_types(void);\nvoid autogenerated_function_add_types(PyObject *m);\n\n/* autogenerated-gimple.c */\nint autogenerated_gimple_init_types(void);\nvoid autogenerated_gimple_add_types(PyObject *m);\nPyGccWrapperTypeObject*\nPyGcc_autogenerated_gimple_type_for_stmt(gcc_gimple stmt);\n\n/* autogenerated-location.c */\nint autogenerated_location_init_types(void);\nvoid autogenerated_location_add_types(PyObject *m);\n\n/* autogenerated-option.c */\nint autogenerated_option_init_types(void);\nvoid autogenerated_option_add_types(PyObject *m);\n\n/* GCC 10 removed params.h */\n#if (GCC_VERSION < 10000)\n/* autogenerated-parameter.c */\nint autogenerated_parameter_init_types(void);\nvoid autogenerated_parameter_add_types(PyObject *m);\n#endif\n\n/* autogenerated-pass.c */\nint autogenerated_pass_init_types(void);\nvoid autogenerated_pass_add_types(PyObject *m);\nextern PyGccWrapperTypeObject PyGccGimplePass_TypeObj;\nextern PyGccWrapperTypeObject PyGccRtlPass_TypeObj;\nextern PyGccWrapperTypeObject PyGccSimpleIpaPass_TypeObj;\nextern PyGccWrapperTypeObject PyGccIpaPass_TypeObj;\n\n/* autogenerated-pretty-printer.c */\nint autogenerated_pretty_printer_init_types(void);\nvoid autogenerated_pretty_printer_add_types(PyObject *m);\n\n\n/* autogenerated-rtl.c */\nint autogenerated_rtl_init_types(void);\nvoid autogenerated_rtl_add_types(PyObject *m);\nPyGccWrapperTypeObject *\nPyGcc_autogenerated_rtl_type_for_stmt(gcc_rtl_insn insn);\n\n\n/* autogenerated-tree.c */\nint autogenerated_tree_init_types(void);\nvoid autogenerated_tree_add_types(PyObject *m);\n\nPyGccWrapperTypeObject*\nPyGcc_autogenerated_tree_type_for_tree(gcc_tree t, int borrow_ref);\n\nPyGccWrapperTypeObject*\nPyGcc_autogenerated_tree_type_for_tree_code(enum tree_code code, int borrow_ref);\n\nextern PyGccWrapperTypeObject PyGccComponentRef_TypeObj;\n\n/* autogenerated-variable.c */\nint autogenerated_variable_init_types(void);\nvoid autogenerated_variable_add_types(PyObject *m);\n\n\nPyObject *\nPyGccStringOrNone(const char *str_or_null);\n\n#if (GCC_VERSION >= 4008)\nPyObject *\nVEC_tree_as_PyList(vec<tree, va_gc> *vec_nodes);\n#else\nPyObject *\nVEC_tree_as_PyList(VEC(tree,gc) *vec_nodes);\n#endif\n\nPyObject *\nPyGcc_int_from_int_cst(tree int_cst);\n\nPyObject *\nPyGcc_int_from_decimal_string_buffer(const char *buf);\n\nvoid\nPyGcc_DoubleIntAsText(double_int di, bool is_unsigned,\n                              char *out, int bufsize)  __attribute__((nonnull));\n\n#if (GCC_VERSION >= 5000)\nPyObject *\nPyGcc_int_from_wide_int();\n#else\nPyObject *\nPyGcc_int_from_double_int(double_int di, bool is_unsigned);\n#endif\n\nPyObject *\nPyGcc_LazilyCreateWrapper(PyObject **cache,\n\t\t\t\t void *ptr,\n\t\t\t\t PyObject *(*ctor)(void *ptr));\nint\nPyGcc_insert_new_wrapper_into_cache(PyObject **cache,\n                                         void *ptr,\n                                         PyObject *obj);\n\n\n/* gcc-python.c */\nint PyGcc_IsWithinEvent(enum plugin_event *out_event);\n\nchar * PyGcc_strdup(const char *str) __attribute__((nonnull));\n\nvoid PyGcc_PrintException(const char *msg);\n\n/*\n  Shorthand for:  repr(getattr(obj, attrname))\n*/\nPyObject *\nPyGcc_GetReprOfAttribute(PyObject *obj, const char *attrname);\n\n/* Python 2 vs Python 3 compat: */\n#if PY_MAJOR_VERSION == 3\n/* Python 3: use PyUnicode for \"str\" and PyLong for \"int\": */\n#define PyGccString_FromFormat PyUnicode_FromFormat\n#define PyGccString_FromString PyUnicode_FromString\n#define PyGccString_FromString_and_size PyUnicode_FromStringAndSize\n#define PyGccString_AsString _PyUnicode_AsString\n#define PyGccInt_FromLong PyLong_FromLong\n#define PyGccInt_Check PyLong_Check\n#define PyGccInt_AsLong PyLong_AsLong\n#else\n/* Python 2: use PyString for \"str\" and PyInt for \"int\": */\n#define PyGccString_FromFormat PyString_FromFormat\n#define PyGccString_FromString PyString_FromString\n#define PyGccString_FromString_and_size PyString_FromStringAndSize\n#define PyGccString_AsString PyString_AsString\n#define PyGccInt_FromLong PyInt_FromLong\n#define PyGccInt_Check PyInt_Check\n#define PyGccInt_AsLong PyInt_AsLong\n#endif\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n\n#endif /* INCLUDED__GCC_PYTHON_H */\n"
  },
  {
    "path": "gcc-with-cpychecker",
    "content": "#!/usr/bin/env python\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Harness for invoking GCC with the cpychecker Python code within the python\n# plugin, whilst dealing with some options\n# (This code runs under the regular Python interpreter, not within gcc)\n\nimport argparse\nimport os\nimport subprocess\nimport sys\n\nabspath = os.path.abspath(os.path.dirname(sys.argv[0]))\n\n# By default, look for the plugin relative to this harness.  This is intended\n# to make it easier during development, so that we can make other projects with\n#     CC=../../../gcc-python-plugin/gcc-with-cpychecker\n# and similar.\n#\n# When installed, this should be fixed up.\nPLUGIN = os.path.join(abspath, 'python.so')\n\n# Similarly, set the location to search for libgcc-c-api.so:\nLD_LIBRARY_PATH = os.path.join(abspath, 'gcc-c-api')\nif 'LD_LIBRARY_PATH' in os.environ:\n    LD_LIBRARY_PATH = '%s:%s' % (LD_LIBRARY_PATH, os.environ['LD_LIBRARY_PATH'])\n\n# Create arg parser:\nparser = argparse.ArgumentParser(usage='%(prog)s [options] gcc-options')\nDEFAULT_MAXTRANS=256\nparser.add_argument('--maxtrans',\n                    type=int,\n                    default=DEFAULT_MAXTRANS,\n                    help='Set the maximum number of transitions to consider before pruning the analysis tree (default: %i)' % DEFAULT_MAXTRANS)\n\nparser.add_argument('--dump-json',\n                    action='store_true',\n                    default=False,\n                    help=('Dump a JSON representation of any problems.  For'\n                          ' example, given a function \"foo.c\", if any warnings'\n                          ' or errors are found in function \"bar\", a file'\n                          ' \"foo.c.bar.json\" will be written out in JSON'\n                          ' form'))\n\nparser.add_argument('--cpychecker-verbose',\n                    action='store_true',\n                    default=False,\n                    help=('Output extra information'))\n\n# Only consume args we understand, leaving the rest for gcc:\nns, other_args = parser.parse_known_args()\nif 0:\n    print(ns)\n    print(other_args)\n\n# Enable the refcount-checker when running via this script\n#\n# We would use the regular keyword argument syntax:\n#   verify_refcounting=True\n# but unfortunately gcc's option parser seems to not be able to cope with '='\n# within an option's value.  So we do it using dictionary syntax instead:\ndictstr = '\"verify_refcounting\":True'\ndictstr += ', \"verbose\":%i' % (ns.cpychecker_verbose)\ndictstr += ', \"maxtrans\":%i' % ns.maxtrans\ndictstr += ', \"dump_json\":%i' % ns.dump_json\ncmd = 'from libcpychecker import main; main(**{%s})' % dictstr\n\n# Do not use CC in the environment, to avoid forkbombing when setting\n# CC=gcc-with-cpychecker.  Instead, use CC_FOR_CPYCHECKER.\nif 'CC_FOR_CPYCHECKER' in os.environ:\n    gcc = os.environ['CC_FOR_CPYCHECKER']\nelse:\n    gcc = 'gcc'\n\nargs = [gcc,\n        ('-fplugin=%s' % PLUGIN),\n        ('-fplugin-arg-python-command=%s' % cmd)]\nargs += other_args # (the args we didn't consume)\n\n# Beware of quoting: if the command is quoted within the Popen call, then\n# Python interprets it as a string literal, and does nothing.\n#\n# But if invoking from a shell, you need quotes aroung the command\n#\n# To add to the fun, \"gcc -v\" emits it in unquoted form,\n# which will need quotes added\n\nenv = os.environ.copy()\nenv['LD_LIBRARY_PATH'] = LD_LIBRARY_PATH\n\nif 0:\n    print(' '.join(args))\np = subprocess.Popen(args, env=env)\n\ntry:\n    r = p.wait()\nexcept KeyboardInterrupt:\n    r = 1\nsys.exit(r)\n"
  },
  {
    "path": "gcc-with-python",
    "content": "#!/bin/sh\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n${CC:-gcc} -fplugin=$(pwd)/python.so -fplugin-arg-python-script=$@\n"
  },
  {
    "path": "gccutils/__init__.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\ndef sorted_dict_repr(d):\n    return '{' + ', '.join(['%r: %r' % (k, d[k])\n                            for k in sorted(d.keys())]) + '}'\n\ndef get_src_for_loc(loc):\n    # Given a gcc.Location, get the source line as a string\n    import linecache\n    return linecache.getline(loc.file, loc.line).rstrip()\n\ndef get_field_by_name(typeobj, name):\n    check_isinstance(typeobj,\n                     (gcc.RecordType, gcc.UnionType, gcc.QualUnionType))\n    for field in typeobj.fields:\n        if field.name == name:\n            return field\n\ndef get_global_typedef(name):\n    # Look up a typedef in global scope by name, returning a gcc.TypeDecl,\n    # or None if not found\n    for u in gcc.get_translation_units():\n        if u.language.startswith('GNU C++'):\n            gns = gcc.get_global_namespace()\n            return gns.lookup(name)\n        if u.block:\n            for v in u.block.vars:\n                if isinstance(v, gcc.TypeDecl):\n                    if v.name == name:\n                        return v\n\ndef get_variables_as_dict():\n    result = {}\n    for var in gcc.get_variables():\n        result[var.decl.name] = var\n    return result\n\ndef get_global_vardecl_by_name(name):\n    # Look up a variable in global scope by name, returning a gcc.VarDecl,\n    # or None if not found\n    for u in gcc.get_translation_units():\n        if u.language == 'GNU C++':\n            gns = gcc.get_global_namespace()\n            return gns.lookup(name)\n        for v in u.block.vars:\n            if isinstance(v, gcc.VarDecl):\n                if v.name == name:\n                    return v\n\ndef get_nonnull_arguments(funtype):\n    \"\"\"\n    'nonnull' is an attribute on the fun.decl.type\n\n    http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html\n\n    It can either have no arguments (all pointer args are non-NULL), or\n    be a list of integers.  These integers are 1-based.\n\n    Return a frozenset of 0-based integers, giving the arguments for which we\n    can assume the \"nonnull\" property.\n\n    (Note the 0-based vs 1-based differences)\n\n    Compare with gcc/tree-vrp.c: nonnull_arg_p\n    \"\"\"\n    check_isinstance(funtype, (gcc.FunctionType, gcc.MethodType))\n    if 'nonnull' in funtype.attributes:\n        result = []\n        nonnull = funtype.attributes['nonnull']\n        if nonnull == []:\n            # All pointer args are nonnull:\n            for idx, parm in enumerate(funtype.argument_types):\n                if isinstance(parm, gcc.PointerType):\n                    result.append(idx)\n        else:\n            # Only the listed args are nonnull:\n            for val in nonnull:\n                check_isinstance(val, gcc.IntegerCst)\n                result.append(val.constant - 1)\n        return frozenset(result)\n    else:\n        # No \"nonnull\" attribute was given:\n        return frozenset()\n\ndef invoke_dot(dot, name='test'):\n    from subprocess import Popen, PIPE\n\n    if 1:\n        fmt = 'png'\n    else:\n        # SVG generation seems to work, but am seeing some text-width issues\n        # with rendering of the SVG  by eog and firefox on this machine (though\n        # not chromium).\n        #\n        # Looks like X coordinates allocated by graphviz don't contain quite\n        # enough space for the <text> elements.\n        #\n        # Presumably a font selection/font metrics issue\n        fmt = 'svg'\n    filename = '%s.%s' % (name, fmt)\n    p = Popen(['dot', '-T%s' % fmt, '-o', filename],\n              stdin=PIPE)\n    p.communicate(dot.encode('ascii'))\n\n    p = Popen(['xdg-open', filename])\n    p.communicate()\n\ndef pprint(obj):\n    pp = TextualPrettyPrinter()\n    pp.pprint(obj)\n\ndef pformat(obj):\n    pp = TextualPrettyPrinter()\n    return pp.pformat(obj)\n\n\nclass PrettyPrinter(object):\n    def __init__(self):\n        self.show_addr = False\n\n    def attr_to_str(self, name, value):\n        if name == 'addr':\n            return hex(value)\n        if isinstance(value, str):\n            return repr(value)\n        return str(value)\n\n    def iter_tree_attrs(self, obj):\n        # Iterate through the interesting attributes of the object:\n        for name in dir(obj):\n            # Ignore private and \"magic\" attributes:\n            if name.startswith('_'):\n                continue\n            value = getattr(obj, name)\n            # Ignore methods:\n            if hasattr(value, '__call__'):\n                continue\n            if not self.show_addr:\n                if name == 'addr':\n                    continue\n            # Don't follow infinite chains, e.g.\n            # ptr to ptr to ... of a type:\n            if isinstance(obj, gcc.Type):\n                if (name == 'pointer' or\n                    name.endswith('equivalent')):\n                    continue\n\n            #print 'attr %r    obj.%s: %r' % (name, name, value)\n            yield (name, value)\n\n\nclass TextualPrettyPrinter(PrettyPrinter):\n    \"\"\"Convert objects to nice textual dumps, loosely based on Python's pprint\n    module\"\"\"\n    def __init__(self):\n        super(TextualPrettyPrinter, self).__init__()\n        self.maxdepth = 5\n\n    def pprint(self, obj):\n        import sys\n        sys.stdout.write(self.pformat(obj))\n\n    def make_indent(self, indent):\n        return indent * ' '\n\n    def pformat(self, obj):\n        return self._recursive_format_obj(obj, set(), 0)\n\n    def indent(self, prefix, txt):\n        return '\\n'.join([prefix + line for line in txt.splitlines()])\n\n    def _recursive_format_obj(self, obj, visited, depth):\n        def str_for_kv(key, value):\n            return '  %s = %s\\n' % (key, value)\n\n        check_isinstance(obj, gcc.Tree)\n        visited.add(obj.addr)\n\n        result = '<%s\\n' % obj.__class__.__name__\n        r = repr(obj)\n        s = str(obj)\n        result += str_for_kv('repr()', r)\n        if s != r:\n            result += str_for_kv('str()', '%r' % s)\n\n        # Show MRO, stripping off this type from front and \"object\" from end:\n        superclasses = obj.__class__.__mro__[1:-1]\n        result += str_for_kv('superclasses',\n                             superclasses)\n        for name, value in self.iter_tree_attrs(obj):\n            if depth < self.maxdepth:\n                if isinstance(value, gcc.Tree):\n                    if value.addr in visited:\n                        result += str_for_kv('.%s' % name,\n                                             '... (%s)' % self.attr_to_str(name, repr(value)))\n                    else:\n                        # Recurse\n                        formatted_value = self._recursive_format_obj(value,\n                                              visited, depth + 1)\n                        indented_value = self.indent(' ' * (len(name) + 6),\n                                                     formatted_value)\n                        result += str_for_kv('.%s' % name,\n                                             indented_value.lstrip())\n                    continue\n            # Otherwise: just print short version of the attribute:\n            result += str_for_kv('.%s' % name,\n                                 self.attr_to_str(name, value))\n\n        result += '>\\n'\n        return result\n\nclass DotPrettyPrinter(PrettyPrinter):\n    # Base class for various kinds of data visualizations that use graphviz\n    # (aka \".dot\" source files)\n    def to_html(self, text):\n        html_escape_table = {\n            \"&\": \"&amp;\",\n            '\"': \"&quot;\",\n            \"'\": \"&apos;\",\n            \">\": \"&gt;\",\n            \"<\": \"&lt;\",\n            \n            # 'dot' doesn't seem to like these:\n            '{': '&#123;',\n            '}': '&#125;',\n\n            ']': '&#93;',\n          }\n        return \"\".join(html_escape_table.get(c,c) for c in str(text))\n\n    def _dot_td(self, text, align=\"left\", colspan=1, escape=1, bgcolor=None,\n                port=None):\n        if escape:\n            text = self.to_html(text)\n        attribs = 'align=\"%s\" colspan=\"%i\"' % (align, colspan)\n        if bgcolor:\n            attribs += ' bgcolor=\"%s\"' % bgcolor\n        if port:\n            attribs += ' port=\"%s\"' % port\n        return ('<td %s>%s</td>'\n                % (attribs, text))\n\n    def _dot_tr(self, td_text):\n        return ('<tr>%s</tr>\\n' % self._dot_td(td_text))\n\ntry:\n    from pygments.formatter import Formatter\n    from pygments.token import Token\n    from pygments.styles import get_style_by_name\n\n    class GraphvizHtmlFormatter(Formatter, DotPrettyPrinter):\n        \"\"\"\n        A pygments Formatter to turn source code fragments into graphviz's\n        pseudo-HTML format.\n        \"\"\"\n        def __init__(self, style):\n            Formatter.__init__(self)\n            self.style = style\n\n        def style_for_token(self, token):\n            # Return a (hexcolor, isbold) pair, where hexcolor could be None\n\n            # Lookup up pygments' color for this token type:\n            col = self.style.styles[token]\n\n            isbold = False\n\n            # Extract a pure hex color specifier of the form that graphviz can\n            # deal with\n            if col:\n                if col.startswith('bold '):\n                    isbold = True\n                    col = col[5:]\n            return (col, isbold)\n\n        def format_unencoded(self, tokensource, outfile):\n            from pprint import pprint\n            for t, piece in tokensource:\n                # graphviz seems to choke on font elements with no inner text:\n                if piece == '':\n                    continue\n\n                # pygments seems to add this:\n                if piece == '\\n':\n                    continue\n\n                # avoid croaking on '\\n':\n                if t == Token.Literal.String.Escape:\n                    continue\n\n                color, isbold = self.style_for_token(t)\n                if 0:\n                    print ('(color, isbold): (%r, %r)' % (color, isbold))\n\n                if isbold:\n                    outfile.write('<b>')\n\n                # Avoid empty color=\"\" values:\n                if color:\n                    outfile.write('<font color=\"%s\">' % color\n                                  + self.to_html(piece)\n                                  + '</font>')\n                else:\n                    outfile.write(self.to_html(piece))\n\n                if isbold:\n                    outfile.write('</b>')\n\n    from pygments import highlight\n    from pygments.lexers import CLexer\n    from pygments.formatters import HtmlFormatter\n\n    def code_to_graphviz_html(code):\n        style = get_style_by_name('default')\n        return highlight(code,\n                         CLexer(), # FIXME\n                         GraphvizHtmlFormatter(style))\n\n    using_pygments = True\nexcept ImportError:\n    using_pygments = False\n\nclass CfgPrettyPrinter(DotPrettyPrinter):\n    # Generate graphviz source for this gcc.Cfg instance, as a string\n    def __init__(self, cfg, name=None):\n        self.cfg = cfg\n        if name:\n            self.name = name\n\n    def block_id(self, b):\n        if b is self.cfg.entry:\n            return 'entry'\n        if b is self.cfg.exit:\n            return 'exit'\n        return 'block%i' % id(b)\n\n    def block_to_dot_label(self, bb):\n        # FIXME: font setting appears to work on my machine, but I invented\n        # the attribute value; it may be exercising a failure path\n        result = '<font face=\"monospace\"><table cellborder=\"0\" border=\"0\" cellspacing=\"0\">\\n'\n        result += '<tr> <td>BLOCK %i</td> <td></td> </tr>\\n' % bb.index\n        curloc = None\n        if isinstance(bb.phi_nodes, list):\n            for stmtidx, phi in enumerate(bb.phi_nodes):\n                result += '<tr><td></td>' + self.stmt_to_html(phi, stmtidx) + '</tr>\\n'\n        if isinstance(bb.gimple, list) and bb.gimple != []:\n            for stmtidx, stmt in enumerate(bb.gimple):\n                if curloc != stmt.loc:\n                    curloc = stmt.loc\n                    if curloc is not None:\n                        code = get_src_for_loc(stmt.loc).rstrip()\n                        pseudohtml = self.code_to_html(code)\n                        # print('pseudohtml: %r' % pseudohtml)\n                        result += ('<tr><td align=\"left\">'\n                                   + self.to_html('%4i ' % stmt.loc.line)\n                                   + pseudohtml\n                                   + '<br/>'\n                                   + (' ' * (5 + stmt.loc.column-1)) + '^'\n                                   + '</td></tr>')\n                    \n                result += '<tr><td></td>' + self.stmt_to_html(stmt, stmtidx) + '</tr>\\n'\n        else:\n            # (prevent graphviz syntax error for empty blocks):\n            result += self._dot_tr(self.block_id(bb))\n        result += '</table></font>\\n'\n        return result\n\n    def code_to_html(self, code):\n        if using_pygments:\n            return code_to_graphviz_html(code)\n        else:\n            return self.to_html(code)\n\n    def stmt_to_html(self, stmt, stmtidx):\n        text = str(stmt).strip()\n        text = self.code_to_html(text)\n        bgcolor = None\n\n        # Work towards visualization of CPython refcounting rules.\n        # For now, paint assignments to (PyObject*) vars and to ob_refcnt\n        # fields, to highlight the areas needing tracking:\n        # print 'stmt: %s' % stmt\n        if 0: # hasattr(stmt, 'lhs'):\n            # print 'stmt.lhs: %s' % stmt.lhs\n            # print 'stmt.lhs: %r' % stmt.lhs\n            if stmt.lhs:\n                # print 'stmt.lhs.type: %s' % stmt.lhs.type\n\n                # Color assignments to (PyObject *) in red:\n                if str(stmt.lhs.type) == 'struct PyObject *':\n                    bgcolor = 'red'\n\n                # Color assignments to PTR->ob_refcnt in blue:\n                if isinstance(stmt.lhs, gcc.ComponentRef):\n                    # print(dir(stmt.lhs))\n                    # print 'stmt.lhs.target: %s' % stmt.lhs.target\n                    # print 'stmt.lhs.target.type: %s' % stmt.lhs.target.type\n                    # (presumably we need to filter these to structs that are\n                    # PyObject, or subclasses)\n                    # print 'stmt.lhs.field: %s' % stmt.lhs.field\n                    if stmt.lhs.field.name == 'ob_refcnt':\n                        bgcolor = 'blue'\n\n        return self._dot_td(text, escape=0, bgcolor=bgcolor, port='stmt%i' % stmtidx)\n\n    def edge_to_dot(self, e):\n        if e.true_value:\n            attrliststr = '[label = true]'\n        elif e.false_value:\n            attrliststr = '[label = false]'\n        elif e.loop_exit:\n            attrliststr = '[label = loop_exit]'\n        elif e.can_fallthru:\n            attrliststr = '[label = fallthru]'\n        else:\n            attrliststr = ''\n        return ('   %s -> %s %s;\\n'\n                % (self.block_id(e.src), self.block_id(e.dest), attrliststr))\n\n    def extra_items(self):\n        # Hook for expansion\n        return ''\n\n    def to_dot(self):\n        if hasattr(self, 'name'):\n            name = self.name\n        else:\n            name = 'G'\n        result = 'digraph %s {\\n' % name\n        result += ' subgraph cluster_cfg {\\n'\n        #result += '  label=\"CFG\";\\n'\n        result += '  node [shape=box];\\n'\n        for block in self.cfg.basic_blocks:\n\n            result += ('  %s [label=<%s>];\\n'\n                       % (self.block_id(block), self.block_to_dot_label(block)))\n\n            for edge in block.succs:\n                result += self.edge_to_dot(edge)\n            # FIXME: this will have duplicates:\n            #for edge in block.preds:\n            #    result += edge_to_dot(edge)\n        result += ' }\\n'\n\n        # Potentially add extra material:\n        result += self.extra_items()\n        result += '}\\n'\n        return result\n\nclass TreePrettyPrinter(DotPrettyPrinter):\n    # Generate a graphviz visualization of this gcc.Tree and the graphs of\n    # nodes it references, as a string\n    def __init__(self, root):\n        print('root: %s' % root)\n        check_isinstance(root, gcc.Tree)\n        self.root = root\n        self.show_addr = False\n        self.maxdepth = 6 # for now\n\n    def tr_for_kv(self, key, value):\n        return ('<tr> %s %s</tr>\\n'\n                % (self._dot_td(key),\n                   self._dot_td(value)))\n\n    def label_for_tree(self, obj):\n        result = '<table cellborder=\"0\" border=\"0\" cellspacing=\"0\">\\n'\n        r = repr(obj)\n        s = str(obj)\n        result += self.tr_for_kv('repr()', r)\n        if s != r:\n            result += self.tr_for_kv('str()', '%r' % s)\n\n        # Show MRO, stripping off this type from front and \"object\" from end:\n        superclasses = obj.__class__.__mro__[1:-1]\n        result += self.tr_for_kv('superclasses',\n                                 superclasses)\n\n        for name, value in self.iter_tree_attrs(obj):\n            result += ('<tr> %s %s </tr>\\n'\n                       % (self._dot_td(name),\n                          self._dot_td(self.attr_to_str(name, value))))\n        result += '</table>\\n'\n        return result\n\n    def tree_id(self, obj):\n        return 'id%s' % id(obj)\n\n    def tree_to_dot(self, obj):\n        check_isinstance(obj, gcc.Tree)\n        return ('  %s [label=<%s>];\\n'\n                % (self.tree_id(obj), self.label_for_tree(obj)))\n\n    def recursive_tree_to_dot(self, obj, visited, depth):\n        print('recursive_tree_to_dot(%r, %r)' % (obj, visited))\n        check_isinstance(obj, gcc.Tree)\n        result = self.tree_to_dot(obj)\n        visited.add(obj.addr)\n        if depth < self.maxdepth:\n            for name, value in self.iter_tree_attrs(obj):\n                if isinstance(value, gcc.Tree):\n                    if value.addr not in visited:\n                        # Recurse\n                        result += self.recursive_tree_to_dot(value,\n                                                             visited, depth + 1)\n                    # Add edge:\n                    result += ('   %s -> %s [label = %s];\\n'\n                               % (self.tree_id(obj),\n                                  self.tree_id(value),\n                                  name))\n        return result\n\n    def to_dot(self):\n        self.root.debug()\n        result = 'digraph G {\\n'\n        result += '  node [shape=record];\\n'\n        result += self.recursive_tree_to_dot(self.root, set(), 0)\n        result += '}\\n'\n        return result\n\ndef cfg_to_dot(cfg, name = None):\n    pp = CfgPrettyPrinter(cfg, name)\n    return pp.to_dot()\n\n\ndef tree_to_dot(tree):\n    pp = TreePrettyPrinter(tree)\n    return pp.to_dot()\n\nclass Table(object):\n    '''A table of text/numbers that knows how to print itself'''\n    def __init__(self, columnheadings=None, rows=[], sepchar='-'):\n        self.numcolumns = len(columnheadings)\n        self.columnheadings = columnheadings\n        self.rows = []\n        self._colsep = '  '\n        self._sepchar = sepchar\n\n    def add_row(self, row):\n        assert len(row) == self.numcolumns\n        self.rows.append(row)\n\n    def write(self, out):\n        colwidths = self._calc_col_widths()\n\n        self._write_separator(out, colwidths)\n\n        self._write_row(out, colwidths, self.columnheadings)\n\n        self._write_separator(out, colwidths)\n\n        for row in self.rows:\n            self._write_row(out, colwidths, row)\n\n        self._write_separator(out, colwidths)\n\n    def _calc_col_widths(self):\n        result = []\n        for colIndex in range(self.numcolumns):\n            result.append(self._calc_col_width(colIndex))\n        return result\n\n    def _calc_col_width(self, idx):\n        cells = [str(row[idx]) for row in self.rows]\n        heading = self.columnheadings[idx]\n        return max([len(c) for c in (cells + [heading])])\n\n    def _write_row(self, out, colwidths, values):\n        for i, (value, width) in enumerate(zip(values, colwidths)):\n            if i > 0:\n                out.write(self._colsep)\n            formatString = \"%%-%ds\" % width # to generate e.g. \"%-20s\"\n            out.write(formatString % value)\n        out.write('\\n')\n\n    def _write_separator(self, out, colwidths):\n        for i, width in enumerate(colwidths):\n            if i > 0:\n                out.write(self._colsep)\n            out.write(self._sepchar * width)\n        out.write('\\n')\n\nclass CallgraphPrettyPrinter(DotPrettyPrinter):\n    def node_id(self, cgn):\n        return 'cgn%i' % id(cgn)\n\n    def node_to_dot_label(self, cgn):\n        return str(cgn.decl.name)\n\n    def edge_to_dot(self, e):\n        attrliststr = ''\n        return ('   %s -> %s %s;\\n'\n                % (self.node_id(e.caller),\n                   self.node_id(e.callee),\n                   attrliststr))\n\n    def to_dot(self):\n        result = 'digraph Callgraph {\\n'\n        #result += ' subgraph cluster_callgraph {\\n'\n        result += '  node [shape=box];\\n'\n        for cgn in gcc.get_callgraph_nodes():\n            result += ('  %s [label=<%s>];\\n'\n                       % (self.node_id(cgn), self.node_to_dot_label(cgn)))\n            for edge in cgn.callers:\n                result += self.edge_to_dot(edge)\n        #result += ' }\\n'\n        result += '}\\n'\n        return result\n\ndef callgraph_to_dot():\n    pp = CallgraphPrettyPrinter()\n    return pp.to_dot()\n\ndef check_isinstance(obj, types):\n    \"\"\"\n    Like:\n       assert isinstance(obj, types)\n    but with better error messages\n    \"\"\"\n    if not isinstance(obj, types):\n        raise TypeError('%s / %r is not an instance of %s' % (obj, obj, types))\n\ndef sorted_callgraph():\n    \"\"\"\n    Return the callgraph, in topologically-sorted order\n    \"\"\"\n    return topological_sort(gcc.get_callgraph_nodes(),\n                            get_srcs=lambda n: [edge.caller\n                                                for edge in n.callers\n                                                # Strip out recursive calls:\n                                                if edge.caller != n],\n                            get_dsts=lambda n: [edge.callee\n                                                for edge in n.callees\n                                                # Strip out recursive calls:\n                                                if edge.callee != n])\n\ndef topological_sort(nodes, get_srcs, get_dsts):\n    \"\"\"\n    Topological sort in O(n), based on depth-first traversal\n    \"\"\"\n    result = []\n    visited = set()\n    debug = False\n    def visit(n):\n        if n not in visited:\n            if debug:\n                print('first visit to %s' % n.decl)\n            visited.add(n)\n            for m in get_srcs(n):\n                visit(m)\n            if debug:\n                print('adding to result: %s' % n.decl)\n            result.append(n)\n        else:\n            if debug:\n                print('already visited %s' % n.decl)\n\n    for n in nodes:\n        if not get_dsts(n):\n            visit(n)\n\n    return result\n\n"
  },
  {
    "path": "gccutils/dot.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\ndef to_html(text):\n    html_escape_table = {\n        \"&\": \"&amp;\",\n        '\"': \"&quot;\",\n        \"'\": \"&apos;\",\n        \">\": \"&gt;\",\n        \"<\": \"&lt;\",\n\n        # 'dot' doesn't seem to like these:\n        '{': '&#123;',\n        '}': '&#125;',\n\n        ']': '&#93;',\n      }\n    return \"\".join(html_escape_table.get(c,c) for c in str(text))\n\n\n# An easy way to construct graphviz' pseudo-html:\nclass Node:\n    def to_html(self):\n        raise NotImplementedError()\n\nclass Element(Node):\n    def __init__(self, children=None, **kwargs):\n        if children is None:\n            children = []\n        else:\n            assert isinstance(children, list)\n        self.children = children\n        self.attrs = kwargs\n\n    def to_html(self):\n        if self.attrs:\n            attrstr = ''.join(' %s=\"%s\"' % (attr, value)\n                              for attr, value in self.attrs.items())\n        else:\n            attrstr = ''\n        result = '<%s%s>' % (self.name, attrstr)\n        for child in self.children:\n            result += child.to_html()\n        result += '</%s>' % self.name\n        return result\n\n    def add_child(self, child):\n        self.children.append(child)\n        return child\n\nclass Table(Element):\n    def to_html(self):\n        result = ('<table cellborder=\"%i\" border=\"%i\" cellspacing=\"0\">\\n'\n                  % (self.attrs.get('cellborder', 0),\n                     self.attrs.get('border', 0)))\n        for row in self.children:\n            result += row.to_html()\n        result += '</table>'\n        return result\n\nclass Tr(Element):\n    name = 'tr'\n\nclass Td(Element):\n    name = 'td'\n\nclass Text(Node):\n    def __init__(self, text):\n        self.text = text\n\n    def to_html(self):\n        return to_html(self.text)\n\nclass Br(Element):\n    def to_html(self):\n        return '<br/>'\n\nclass Font(Element):\n    name = 'font'\n"
  },
  {
    "path": "gccutils/graph/__init__.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom gccutils.dot import to_html\n\n############################################################################\n# Generic directed graphs\n############################################################################\nclass Graph(object):\n    __slots__ = ('nodes', 'edges')\n\n    def __init__(self):\n        self.nodes = set()\n        self.edges = set()\n\n    def add_node(self, node):\n        self.nodes.add(node)\n        return node\n\n    def add_edge(self, srcnode, dstnode, *args, **kwargs):\n        assert isinstance(srcnode, Node)\n        assert isinstance(dstnode, Node)\n        e = self._make_edge(srcnode, dstnode, *args, **kwargs)\n        self.edges.add(e)\n        srcnode.succs.add(e)\n        dstnode.preds.add(e)\n        return e\n\n    def _make_edge(self, srcnode, dstnode):\n        return Edge(srcnode, dstnode)\n\n    def remove_node(self, node):\n        if node not in self.nodes:\n            return 0\n        self.nodes.remove(node)\n        victims = 1\n        for edge in list(node.succs):\n            victims += self.remove_edge(edge)\n        for edge in list(node.preds):\n            victims += self.remove_edge(edge)\n        return victims\n\n    def remove_edge(self, edge):\n        if edge not in self.edges:\n            return 0\n        self.edges.remove(edge)\n        edge.srcnode.succs.remove(edge)\n        edge.dstnode.preds.remove(edge)\n        victims = 0\n        if not edge.dstnode.preds:\n            # We removed last inedge: recurse\n            if edge.dstnode in self.nodes:\n                victims += self.remove_node(edge.dstnode)\n        return victims\n\n    def to_dot(self, name, ctxt=None):\n        result = 'digraph %s {\\n' % name\n        result += '  node [shape=box];\\n'\n        result += self._nodes_to_dot(ctxt)\n        result += self._edges_to_dot(ctxt)\n        result += '}\\n'\n        return result\n\n    def _nodes_to_dot(self, ctxt):\n        # A subgraph path is a tuple of Subgraph instances\n\n        from pprint import pprint\n\n        # 1st pass: get the subgraph path for every node\n        # This is a dict from subgraph path to set of nodes:\n        subgraph_paths = {}\n        for node in self.nodes:\n            subgraph_path = node.get_subgraph_path(ctxt)\n            assert isinstance(subgraph_path, tuple)\n            if 0:\n                print('node: %s' % node)\n                print('subgraph_path: %s' % (subgraph_path, ))\n            if subgraph_path in subgraph_paths:\n                subgraph_paths[subgraph_path].add(node)\n            else:\n                subgraph_paths[subgraph_path] = set([node])\n\n        if 0:\n            print('subgraph_paths:')\n            pprint(subgraph_paths)\n\n        # 2nd pass: construct a tree of subgraphs:\n        # dict from subgraph path (parent) to set of subgraph paths\n        # (immediate children):\n        child_paths = {}\n        # sort the paths, so that they are in order of increasing\n        # length:\n        for path in sorted(subgraph_paths.keys()):\n            if path:\n                for i in range(len(path) + 1):\n                    subpath = path[0:i]\n                    if 0:\n                        print('subpath: %s' % (subpath, ))\n                    if subpath:\n                        parent = subpath[0:-1]\n                        if parent in child_paths:\n                            child_paths[parent].add(subpath)\n                        else:\n                            child_paths[parent] = set([subpath])\n        if 0:\n            print('child_paths:')\n            pprint(child_paths)\n\n        # 3rd pass: recursively render the subgraph paths:\n        def render_subgraph_path(subgraph_path, indent):\n            def _indent():\n                return ' ' * indent\n            result = ''\n            if subgraph_path:\n                result += ('%ssubgraph cluster_%s {\\n'\n                           % (_indent(), subgraph_path[-1].id))\n                indent += 2\n                result += ('%slabel = \"%s\";\\n'\n                           % (_indent(), subgraph_path[-1].label))\n\n            for node in subgraph_paths.get(subgraph_path, set()):\n                result += ('%s%s [label=<%s>];\\n'\n                           % (_indent(),\n                              node.to_dot_id(),\n                              node.to_dot_label(ctxt)))\n            # Recurse:\n            for child_path in child_paths.get(subgraph_path, set()):\n                result += render_subgraph_path(child_path, indent)\n\n            if subgraph_path:\n                indent -= 2\n                result += '%s}\\n' % _indent()\n            return result\n\n        return render_subgraph_path( (), 2)\n\n    def _edges_to_dot(self, ctxt):\n        result = ''\n        for edge in self.edges:\n            result += ('    %s -> %s [label=<%s>%s];\\n'\n                       % (edge.srcnode.to_dot_id(),\n                          edge.dstnode.to_dot_id(),\n                          edge.to_dot_label(ctxt),\n                          edge.to_dot_attrs(ctxt)))\n        return result\n\n    def topologically_sorted_nodes(self):\n        from gccutils import topological_sort\n        def get_srcs(node):\n            for pred in node.preds:\n                yield pred.srcnode\n        def get_dsts(node):\n            for succ in node.succs:\n                yield succ.dstnode\n        return topological_sort(self.nodes,\n                                get_srcs,\n                                get_dsts)\n\n    def get_shortest_path(self, srcnode, dstnode):\n        '''\n        Locate the shortest path from the srcnode to the dstnode\n        Return a list of Edge instances, or None if no such path exists\n        '''\n        # Dijkstra's algorithm\n        # A dict giving for each node the length of the shortest known path\n        # from srcnode to this node:\n        distance = {}\n\n        # A dict giving for each node the previous node within that shortest\n        # path:\n        inedge = {}\n\n        INFINITY = 0x80000000\n        for node in self.nodes:\n            distance[node] = INFINITY\n            inedge[node] = None\n        distance[srcnode] = 0\n\n        # We use a heapq to keep the nodes sorted by distance\n        # The items in the heapq are lists of the form:\n        #    [distance_to_node, node, is_live)\n        # The first entry in the list ensures that the heapq is sorted\n        # into the order needed for Dijkstra's algorithm\n        #\n        # Since we can't change the priority of items within a heapq,\n        # whenever we need to update the distance we mark the existing\n        # item as dead (setting the is_live boolean to False), and add a\n        # new entry with the correct value; we ignore dead items during\n        # the iteration\n        #\n        # This gets the time taken for a simple 10000 node graph down to\n        # ~3 seconds, compared to minutes/hours.\n        from heapq import heapify, heappop, heappush\n        item_for_node = {}\n        for node in self.nodes:\n            item_for_node[node] = [distance[node], node, True]\n\n        worklist = list(item_for_node.values())\n        heapify(worklist)\n        while worklist:\n            def get_next():\n                while 1:\n                    if not worklist:\n                        return None\n                    disttonode, node, islive = heappop(worklist)\n                    if islive:\n                        return node\n            node = get_next()\n            if node is None:\n                # disjoint\n                break\n            if node == dstnode:\n                # We've found the target node; build a path of the edges to\n                # follow to get here:\n                path = []\n                while inedge[node]:\n                    path = [inedge[node]] + path\n                    node = inedge[node].srcnode\n                return path\n            if distance[node] == INFINITY:\n                # disjoint\n                break\n            for edge in node.succs:\n                alt = distance[node] + 1\n                if alt < distance[edge.dstnode]:\n                    distance[edge.dstnode] = alt\n                    # Changing the distance of edge.dstnode requires us to\n                    # update the heapq:\n                    # Mark the existing item as dead:\n                    item_for_node[edge.dstnode][2] = False\n                    # Create a new itemwith the new distance:\n                    newitem = [alt, edge.dstnode, True]\n                    item_for_node[edge.dstnode] = newitem\n                    heappush(worklist, newitem)\n                    inedge[edge.dstnode] = edge\n        return None\n\n\nclass Node(object):\n    __slots__ = ('preds', 'succs')\n\n    def __init__(self):\n        self.preds = set()\n        self.succs = set()\n\n    def to_dot_id(self):\n        return '%s' % id(self)\n\n    def to_dot_label(self, ctxt):\n        if hasattr(ctxt, 'node_to_dot_html'):\n            htmlnode = ctxt.node_to_dot_html(self)\n        else:\n            htmlnode = self.to_dot_html(ctxt)\n        if htmlnode:\n            return htmlnode.to_html()\n        else:\n            return to_html(str(self))\n\n    def to_dot_html(self, ctxt):\n        # Optionally, build a tree of gccutils.dot.Node\n        return None\n\n    def get_subgraph_path(self, ctxt):\n        # Optionally, allow nodes to be partitioned into a tree of subgraphs\n        # Return a tuple of Subgraph instances\n        return ()\n\n    def __lt__(self, other):\n        return id(self) < id(other)\n\nclass Edge(object):\n    __slots__ = ('srcnode', 'dstnode')\n\n    def __init__(self, srcnode, dstnode):\n        self.srcnode = srcnode\n        self.dstnode = dstnode\n\n    def __repr__(self):\n        return '%s(srcnode=%r, dstnode=%r)' % (self.__class__.__name__, self.srcnode, self.dstnode)\n\n    def __str__(self):\n        return '%s -> %s' % (self.srcnode, self.dstnode)\n\n    def to_dot_label(self, ctxt):\n        return ''\n\n    def to_dot_attrs(self, ctxt):\n        return ''\n\nclass Subgraph(object):\n    __slots__ = ('id', 'label')\n\n    def __init__(self, id_, label):\n        self.id = ''\n        for ch in id_:\n            if ch.isalnum():\n                self.id += ch\n            else:\n                self.id += '_'\n        self.label = label\n\n    def __eq__(self, other):\n        if self.id == other.id:\n            if self.label == other.label:\n                return True\n\n    def __hash__(self):\n        return hash(self.id) ^ hash(self.label)\n\n    def __str__(self):\n        return '(%r, %r)' % (self.id, self.label)\n\n    def __repr__(self):\n        return 'Subgraph(%r, %r)' % (self.id, self.label)\n\n    def __lt__(self, other):\n        return self.id < other.id\n"
  },
  {
    "path": "gccutils/graph/ivpgraph.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom gccutils.graph import Graph, Node, Edge, Subgraph\nfrom gccutils.graph.supergraph import Supergraph, CallToStart, \\\n    ExitToReturnSite, CallNode\n\n############################################################################\n# Enhancement to a Supergraph to approximate the Interprocedural Valid Paths\n# (IVP), in which each node is extended to contain a callstring suffix\n# (i.e. the top N callnodes on the stack), thus modelling call/return\n# behavior.\n# Analogous to inlining\n############################################################################\n\nclass Callstring:\n    \"\"\"\n    A callstring-suffix\n    \"\"\"\n    __slots__ = ('callnodes', )\n\n    def __init__(self, callnodes):\n        self.callnodes = callnodes\n\n    def __str__(self):\n        def callnode_to_str(callnode):\n            #return str(callnode)\n            return '%s:%s' % (callnode.function.decl.name, callnode.stmt.loc.line)\n        return '[%s]' % ' <| '.join(callnode_to_str(callnode)\n                                    for callnode in self.callnodes)\n\n    def __repr__(self):\n        return 'Callstring(%r)' % str(self)\n\n    def __eq__(self, other):\n        return self.callnodes == other.callnodes\n\n    def __hash__(self):\n        return hash(self.callnodes)\n\n    def to_dot_id(self):\n        return '_'.join([str(id(callnode))\n                         for callnode in self.callnodes])\n\nclass IvpGraph(Graph):\n    __slots__ = ('sg', 'maxlength', 'ivpnodes', '_entrynodes')\n\n    def __init__(self, sg, maxlength):\n        Graph.__init__(self)\n        self.sg = sg\n        self.maxlength = maxlength\n\n        # Dict mapping from (callstring, supernode) to IvpNode\n        self.ivpnodes = {}\n\n        self._entrynodes = set()\n\n        # 1st pass: walk from the entrypoints, calling functions,\n        # building nodes, and calling edges.\n        # We will fill in the return edges later:\n        # set of (ivpnode, inneredge) pairs deferred for later processsing:\n        _pending_return_edges = set()\n\n        def _add_node_for_key(key):\n            callstring, supernode = key\n            newnode = IvpNode(callstring, supernode)\n            self.add_node(newnode)\n            self.ivpnodes[key] = newnode\n            return newnode\n\n        # The \"worklist\" is a set of IvpNodes that we need to add\n        # edges for.  Doing so may lead to more IvpNodes being\n        # created.\n        worklist = set()\n        for supernode in sg.get_entry_nodes():\n            key = (Callstring(tuple()), supernode)\n            node = _add_node_for_key(key)\n            worklist.add(node)\n            self._entrynodes.add(node)\n\n        while worklist:\n            ivpnode = worklist.pop()\n            if 0:\n                print('ivpnode: %s' % ivpnode)\n                print('ivpnode: %r' % ivpnode)\n\n            for inneredge in ivpnode.innernode.succs:\n                if 0:\n                    print('  inneredge: %s' % inneredge)\n                    print('  inneredge: %r' % inneredge)\n                callstring = ivpnode.callstring\n\n                def get_callstring():\n                    if isinstance(inneredge, CallToStart):\n                        # interprocedural call: push onto stack:\n                        callnode = inneredge.srcnode\n                        assert len(callstring.callnodes) <= maxlength\n                        if len(callstring.callnodes) == maxlength:\n                            # Truncate, losing the bottom of the stack:\n                            oldstack = list(callstring.callnodes[1:])\n                        else:\n                            oldstack = list(callstring.callnodes)\n                        return Callstring(tuple(oldstack + [callnode]))\n\n                    elif isinstance(inneredge, ExitToReturnSite):\n                        # interprocedural return: pop from stack\n                        if not callstring.callnodes:\n                            return None\n\n                        # Ensure that we're returning to the correct place\n                        # according to the top of the stack:\n                        callnode = callstring.callnodes[-1]\n                        if inneredge.dstnode == callnode.returnnode:\n                            # add to the pending list\n                            _pending_return_edges.add( (ivpnode, inneredge) )\n\n                        return None\n                    else:\n                        # same stack depth:\n                        return ivpnode.callstring\n\n                newcallstring = get_callstring()\n                if newcallstring:\n                    key = (newcallstring, inneredge.dstnode)\n                    if key not in self.ivpnodes:\n                        dstnode = _add_node_for_key(key)\n                        worklist.add( dstnode )\n                    else:\n                        dstnode = self.ivpnodes[key]\n                    self.add_edge(ivpnode, dstnode, inneredge)\n\n            # FIXME: in case we don't terminate, this is useful for debugging why:\n            #if len(self.nodes) > 100:\n            #    return\n\n        # 2nd pass: now gather all valid callstrings:\n        self.all_callstrings = set()\n        for node in self.nodes:\n            self.all_callstrings.add(node.callstring)\n\n        if 0:\n            print('self.all_callstrings: %s' % self.all_callstrings)\n\n        # 3rd pass: go back and add the return edges (using the set of valid\n        # callstrings to expand possible-truncated stacks):\n        for srcivpnode, inneredge in _pending_return_edges:\n            callstring = srcivpnode.callstring\n\n            # We have a return edge, valid in the sense\n            # that the dstnode is the call at the top of the stack\n            #\n            # What state should the stack end up in?\n            def iter_valid_pops(callstring):\n                # We could be at the top of an untruncated stack, in which\n                # case we simply lose the top element:\n                candidate = Callstring(callstring.callnodes[:-1])\n                if candidate in self.all_callstrings:\n                    yield candidate\n\n                # Alternatively, the stack could be truncated, in which\n                # case we need to generate all possible new elements for the\n                # prefix part of the truncated stack\n                if len(callstring.callnodes) == maxlength:\n                    suffix = callstring.callnodes[0:-1]\n                    for candidate in self.all_callstrings:\n                        if candidate.callnodes[1:] == suffix:\n                            yield candidate\n\n            valid_pops = set(iter_valid_pops(callstring))\n            for newcallstring in valid_pops:\n                key = (newcallstring, inneredge.dstnode)\n                dstivpnode = self.ivpnodes[key]\n                self.add_edge(srcivpnode, dstivpnode, inneredge)\n\n        # (done)\n\n    def _make_edge(self, srcnode, dstnode, edge):\n        return IvpEdge(srcnode, dstnode, edge)\n\n    def get_functions(self):\n        for fun in self.sg.get_functions():\n            yield fun\n\n    def get_entry_nodes(self):\n        for node in self._entrynodes:\n            yield node\n\nclass IvpNode(Node):\n    __slots__ = ('callstring', 'innernode', )\n\n    def __init__(self, callstring, innernode):\n        Node.__init__(self)\n        self.callstring = callstring\n        self.innernode = innernode\n\n    def to_dot_html(self, ctxt):\n        from gccutils.dot import Table, Tr, Td, Text, Br, Font\n\n        table = Table()\n        tr = table.add_child(Tr())\n        td = tr.add_child(Td(align='left'))\n        td.add_child(Text('%s' % (self.callstring))) #.to_dot_id())))\n        tr = table.add_child(Tr())\n        td = tr.add_child(Td(align='left'))\n        td.add_child(self.innernode.to_dot_html(ctxt))\n\n        return table\n\n    def __str__(self):\n        return '%s: %s' % (self.callstring, self.innernode)\n\n    def __repr__(self):\n        return 'IvpNode(%r, %r)' % (self.callstring, self.innernode)\n\n    @property\n    def supergraphnode(self):\n        return self.innernode\n\n    @property\n    def stmt(self):\n        return self.innernode.stmt\n\n    @property\n    def function(self):\n        return self.innernode.function\n\n    def get_gcc_loc(self):\n        return self.innernode.get_gcc_loc()\n\n    def get_subgraph_path(self, ctxt):\n        innerpath = self.innernode.get_subgraph_path(ctxt)\n        if innerpath:\n            sg_file, sg_func = innerpath\n            return (sg_file,\n                    Subgraph('callstring_%s_function_%s'\n                             % (self.callstring, self.function),\n                             '%s : %s()' % (self.callstring,\n                                            self.function.decl.name)))\n        return ()\n\nclass IvpEdge(Edge):\n    __slots__ = ('inneredge', )\n\n    def __init__(self, srcnode, dstnode, inneredge):\n        Edge.__init__(self, srcnode, dstnode)\n        self.inneredge = inneredge\n\n    def to_dot_label(self, ctxt):\n        return self.inneredge.to_dot_label(ctxt)\n\n    def to_dot_attrs(self, ctxt):\n        return self.inneredge.to_dot_attrs(ctxt)\n\n    @property\n    def true_value(self):\n        return self.inneredge.true_value\n\n    @property\n    def false_value(self):\n        return self.inneredge.false_value\n\n    @property\n    def stmtedge(self):\n        return self.inneredge.stmtedge\n"
  },
  {
    "path": "gccutils/graph/query.py",
    "content": "#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Queries on graphs, with composable filters\n#   Query(graph).filters\n\nimport gcc\n\nfrom gccutils.graph.supergraph import ReturnNode\n\n__all__ = ['Query']\n\nclass BaseQuery:\n    def first(self):\n        results = list(self)\n        if len(results) < 1:\n            raise ValueError('no nodes found satisfying: %s' % self)\n        return results[0]\n\n    def one(self):\n        results = list(self)\n        if len(results) > 1:\n            raise ValueError('more than one node found satisfying: %s' % self)\n        if len(results) < 1:\n            raise ValueError('no nodes found satisfying: %s' % self)\n        return results[0]\n\n    #######################################################################\n    # Filters\n    #######################################################################\n\n    def get_calls_of(self, funcname):\n        class GetCallsOf(CompoundQuery):\n            def __init__(self, innerquery, funcname):\n                CompoundQuery.__init__(self, innerquery)\n                self.funcname = funcname\n            def __iter__(self):\n                for node in self.innerquery:\n                    # For an interprocedural call, we want the CallNode, not the\n                    # ReturnNode.\n                    # For a call to an external function, the GimpleCall will be\n                    # within a regular SupergraphNode:\n                    if not isinstance(node, ReturnNode):\n                        stmt = node.stmt\n                        if isinstance(stmt, gcc.GimpleCall):\n                            if isinstance(stmt.fn, gcc.AddrExpr):\n                                if isinstance(stmt.fn.operand, gcc.FunctionDecl):\n                                    if stmt.fn.operand.name == funcname:\n                                        yield node\n            def __repr__(self):\n                return ('GetCallsOf(%r, funcname=%r)'\n                        % (self.innerquery, self.funcname))\n            def __str__(self):\n                return '%s that are calls of %s()' % (self.innerquery, self.funcname)\n\n        return GetCallsOf(self, funcname)\n\n    def assigning_to(self, varname):\n        class AssigningTo(CompoundQuery):\n            def __init__(self, innerquery, varname):\n                CompoundQuery.__init__(self, innerquery)\n                self.varname = varname\n            def __iter__(self):\n                for node in self.innerquery:\n                    stmt = node.stmt\n                    if stmt.lhs.var.name == self.varname:\n                        yield node\n            def __repr__(self):\n                return ('AssigningTo(%r, varname=%r)'\n                        % (self.innerquery, self.varname))\n            def __str__(self):\n                return '%s in which the LHS is assigned to a variable named %s' % (self.innerquery, self.varname)\n        return AssigningTo(self, varname)\n\n    def assigning_constant(self, constant):\n        class AssigningConstant(CompoundQuery):\n            def __init__(self, innerquery, constant):\n                CompoundQuery.__init__(self, innerquery)\n                self.constant = constant\n            def __iter__(self):\n                for node in self.innerquery:\n                    stmt = node.stmt\n                    if isinstance(stmt, gcc.GimpleAssign):\n                        if stmt.exprcode == gcc.IntegerCst:\n                            if stmt.rhs[0] == self.constant:\n                                yield node\n            def __repr__(self):\n                return ('AssigningConstant(%r, constant=%r)'\n                        % (self.innerquery, self.constant))\n            def __str__(self):\n                return '%s in which an assignment of the value %s is made' % (self.innerquery, self.constant)\n        return AssigningConstant(self, constant)\n\n    def within(self, funcname):\n        class Within(CompoundQuery):\n            def __init__(self, innerquery, funcname):\n                CompoundQuery.__init__(self, innerquery)\n                self.funcname = funcname\n            def __iter__(self):\n                for node in self.innerquery:\n                    if node.function:\n                        if node.function.decl.name == self.funcname:\n                            yield node\n            def __repr__(self):\n                return ('Within(%r, funcname=%r)'\n                        % (self.innerquery, self.funcname))\n            def __str__(self):\n                return '%s within %s' % (self.innerquery, self.funcname)\n        return Within(self, funcname)\n\nclass CompoundQuery(BaseQuery):\n    def __init__(self, innerquery):\n        self.innerquery = innerquery\n\nclass Query(BaseQuery):\n    def __init__(self, graph):\n        self.graph = graph\n\n    def __iter__(self):\n        for node in self.graph.nodes:\n            yield node\n\n    def __repr__(self):\n        return 'Query()'\n\n    def __str__(self):\n        return 'nodes'\n\n"
  },
  {
    "path": "gccutils/graph/stmtgraph.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\nfrom gccutils.graph import Graph, Node, Edge\n\n############################################################################\n# A CFG, but with individual statements for nodes, rather than lumping them\n# together within basic blocks\n# It also has \"empty\" nodes i.e. those with no statements, to handle\n# the empty BBs in the original CFG (entry and exit)\n############################################################################\nclass StmtGraph(Graph):\n    __slots__ = ('fun',\n                 'entry', 'exit',\n                 'entry_of_bb',\n                 'exit_of_bb',\n                 'node_for_stmt',\n                 '__lastnode',\n                 'supernode_for_stmtnode')\n\n    def __init__(self, fun, split_phi_nodes, omit_complex_edges=False):\n        \"\"\"\n        fun : the underlying gcc.Function\n\n        split_phi_nodes:\n\n           if true, split phi nodes so that there is one copy of each phi\n           node per edge as a SplitPhiNode instance, allowing client code\n           to walk the StmtGraph without having to track which edge we came\n           from\n\n           if false, create a StmtNode per phi node at the top of the BB\n\n        \"\"\"\n        Graph.__init__(self)\n        self.fun = fun\n        self.entry = None\n        self.exit = None\n        # Mappings from gcc.BasicBlock to StmtNode so that we can wire up\n        # the edges for the gcc.Edge:\n        self.entry_of_bb = {}\n        self.exit_of_bb = {}\n        self.node_for_stmt = {}\n\n        basic_blocks = fun.cfg.basic_blocks\n\n        # 1st pass: create nodes and edges within BBs:\n        for bb in basic_blocks:\n            self.__lastnode = None\n\n            def add_stmt(stmt):\n                nextnode = self.add_node(StmtNode(fun, bb, stmt))\n                self.node_for_stmt[stmt] = nextnode\n                if self.__lastnode:\n                    self.add_edge(self.__lastnode, nextnode, None)\n                else:\n                    self.entry_of_bb[bb] = nextnode\n                self.__lastnode = nextnode\n\n            if bb.phi_nodes and not split_phi_nodes:\n                # If we're not splitting the phi nodes, add them to the top\n                # of each BB:\n                for stmt in bb.phi_nodes:\n                    add_stmt(stmt)\n                self.exit_of_bb[bb] = self.__lastnode\n            if bb.gimple:\n                for stmt in bb.gimple:\n                    add_stmt(stmt)\n                self.exit_of_bb[bb] = self.__lastnode\n\n            if self.__lastnode is None:\n                # We have a BB with neither statements nor phis\n                # Create a single node for this BB:\n                if bb == fun.cfg.entry:\n                    cls = EntryNode\n                elif bb == fun.cfg.exit:\n                    cls = ExitNode\n                else:\n                    # gcc appears to create empty BBs for functions\n                    # returning void that contain multiple \"return;\"\n                    # statements:\n                    cls = StmtNode\n                node = self.add_node(cls(fun, bb, None))\n                self.entry_of_bb[bb] = node\n                self.exit_of_bb[bb] = node\n                if bb == fun.cfg.entry:\n                    self.entry = node\n                elif bb == fun.cfg.exit:\n                    self.exit = node\n\n            assert self.entry_of_bb[bb] is not None\n            assert self.exit_of_bb[bb] is not None\n\n        # 2nd pass: wire up the cross-BB edges:\n        for bb in basic_blocks:\n            for edge in bb.succs:\n\n                # If requested, omit \"complex\" edges e.g. due to\n                # exception-handling:\n                if omit_complex_edges:\n                    if edge.complex:\n                        continue\n\n                last_node = self.exit_of_bb[bb]\n                if split_phi_nodes:\n                    # add SplitPhiNode instances at the end of each edge\n                    # as a copy of each phi node, specialized for this edge\n                    if edge.dest.phi_nodes:\n                        for stmt in edge.dest.phi_nodes:\n                            split_phi = self.add_node(SplitPhiNode(fun, stmt, edge))\n                            self.add_edge(last_node,\n                                          split_phi,\n                                          edge)\n                            last_node = split_phi\n\n                # After optimization, the CFG sometimes contains edges that\n                # point to blocks that are no longer within fun.cfg.basic_blocks\n                # Skip them:\n                if edge.dest not in basic_blocks:\n                    continue\n\n                self.add_edge(last_node,\n                              self.entry_of_bb[edge.dest],\n                              edge)\n\n        # 3rd pass: set up caselabelexprs for edges within switch statements\n        # There doesn't seem to be any direct association between edges in a\n        # CFG and the switch labels; store this information so that it's\n        # trivial to go from an edge to the set of case labels that might be\n        # being followed:\n        for stmt in self.node_for_stmt:\n            if isinstance(stmt, gcc.GimpleSwitch):\n                labels = stmt.labels\n                node = self.node_for_stmt[stmt]\n                for edge in node.succs:\n                    caselabelexprs = set()\n                    for label in labels:\n                        dststmtnode_of_labeldecl = self.get_node_for_labeldecl(label.target)\n                        if dststmtnode_of_labeldecl == edge.dstnode:\n                            caselabelexprs.add(label)\n                    edge.caselabelexprs = frozenset(caselabelexprs)\n\n    def _make_edge(self, srcnode, dstnode, edge):\n        return StmtEdge(srcnode, dstnode, edge, len(self.edges))\n\n    def get_entry_nodes(self):\n        return [self.entry]\n\n    def get_node_for_labeldecl(self, labeldecl):\n        assert isinstance(labeldecl, gcc.LabelDecl)\n        bb = self.fun.cfg.get_block_for_label(labeldecl)\n        return self.entry_of_bb[bb]\n\nclass StmtNode(Node):\n    __slots__ = ('fun', 'bb', 'stmt')\n\n    def __init__(self, fun, bb, stmt):\n        Node.__init__(self)\n        self.fun = fun\n        self.bb = bb\n        self.stmt = stmt # can be None for empty BBs\n\n    def __str__(self):\n        return str(self.stmt)\n\n    def __repr__(self):\n        return 'StmtNode(%r)' % self.stmt\n\n    def __hash__(self):\n        return hash(self.stmt)\n\n    def get_stmt(self):\n        return self.stmt\n\n    def get_gcc_loc(self):\n        if self.stmt:\n            return self.stmt.loc\n        else:\n            return None\n\n    def to_dot_html(self, ctxt):\n        from gccutils.dot import Table, Tr, Td, Text, Br, Font\n        from gccutils import get_src_for_loc\n\n        loc = self.get_gcc_loc()\n        if loc:\n            table = Table()\n            code = get_src_for_loc(loc).rstrip()\n            tr = table.add_child(Tr())\n            td = tr.add_child(Td(align='left'))\n            td.add_child(Text('%4i %s' % (self.stmt.loc.line, code)))\n            td.add_child(Br())\n            td.add_child(Text(' ' * (5 + self.stmt.loc.column-1) + '^'))\n            td.add_child(Br())\n            td.add_child(Text(str(self)))\n            return table\n            # return Font([table], face=\"monospace\")\n        else:\n            return Text(str(self))\n\n    def __eq__(self, other):\n        return self.stmt == other.stmt\n\nclass EntryNode(StmtNode):\n    __slots__ = ()\n\n    def to_dot_html(self, ctxt):\n        from gccutils.dot import Table, Tr, Td, Text\n\n        funtype = self.fun.decl.type\n        args = ','.join(['%s %s' % (arg.type, arg.name)\n                         for arg in self.fun.decl.arguments])\n        signature = '%s %s(%s)' % (funtype.type, self.fun.decl.name, args)\n\n        table = Table([\n            Tr([\n                Td([\n                    Text('ENTRY %s' % signature)\n                    ])\n                ])\n            ])\n        for var in self.fun.local_decls:\n            table.add_child(Tr([\n                        Td([\n                                Text('%s %s;' % (var.type, var))\n                                ])\n                        ]))\n        return table\n\n    def __str__(self):\n        return 'ENTRY %s' % self.fun.decl.name\n\n    def __repr__(self):\n        return 'EntryNode(%r)' % self.fun.decl.name\n\nclass ExitNode(StmtNode):\n    __slots__ = ()\n\n    def __str__(self):\n        return 'EXIT %s' % self.fun.decl.name\n\n    def __repr__(self):\n        return 'ExitNode(%r)' % self.fun.decl.name\n\n    @property\n    def returnnode(self):\n        \"\"\"\n        Get the gcc.GimpleReturn statement associated with this function exit\n        \"\"\"\n        if len(self.preds) == 1:\n            node = list(self.preds)[0].srcnode\n            assert isinstance(node.stmt, gcc.GimpleReturn)\n            return node\n\n    @property\n    def returnval(self):\n        \"\"\"\n        Get the gcc.Tree for the return value, or None\n        \"\"\"\n        returnnode = self.returnnode\n        if returnnode:\n            assert isinstance(returnnode.stmt, gcc.GimpleReturn)\n            return returnnode.stmt.retval\n\nclass SplitPhiNode(StmtNode):\n    __slots__ = ('inneredge', 'rhs')\n\n    def __init__(self, fun, stmt, inneredge):\n        StmtNode.__init__(self, fun, None, stmt)\n        self.inneredge = inneredge\n\n        # Lookup the RHS for this edge:\n        assert isinstance(stmt, gcc.GimplePhi)\n        assert isinstance(inneredge, gcc.Edge)\n        self.rhs = None\n        for arg, edge in stmt.args:\n            if edge == inneredge:\n                self.rhs = arg\n                break\n        if self.rhs is None:\n            raise UnknownEdge()\n\n    def __str__(self):\n        return '%s = %s (via %s)' % (self.stmt.lhs, self.rhs, self.stmt)\n\n    def __repr__(self):\n        return 'SplitPhiNode(%r, %r)' % (self.stmt, self.inneredge)\n\n    def __eq__(self, other):\n        return isinstance(other, SplitPhiNode) and self.inneredge == other.inneredge\n\nclass StmtEdge(Edge):\n    __slots__ = ('cfgedge', 'sortidx', 'caselabelexprs')\n\n    def __init__(self, srcnode, dstnode, cfgedge, sortidx):\n        Edge.__init__(self, srcnode, dstnode)\n        self.cfgedge = cfgedge # will be None within a BB\n        self.sortidx = sortidx\n\n        # For use in handling switch statements:\n        # the set of gcc.CaseLabelExpr for this edge\n        self.caselabelexprs = frozenset()\n\n\n    def to_dot_label(self, ctx):\n        return str(self.sortidx)\n        if self.cfgedge:\n            if self.cfgedge.true_value:\n                return 'true'\n            elif self.cfgedge.false_value:\n                return 'false'\n\n        # Edges within a switch statement:\n        if self.caselabelexprs:\n            def cle_to_str(cle):\n                if cle.low is not None:\n                    if cle.high is not None:\n                        return '%s ... %s' % (cle.low, cle.high)\n                    else:\n                        return str(cle.low)\n                else:\n                    return 'default'\n            return '{%s}' % ', '.join([cle_to_str(cle)\n                                       for cle in self.caselabelexprs])\n\n        return ''\n\n    @property\n    def true_value(self):\n        if self.cfgedge:\n            return self.cfgedge.true_value\n\n    @property\n    def false_value(self):\n        if self.cfgedge:\n            return self.cfgedge.false_value\n\n    def __cmp__(self, other):\n        return cmp(self.sortidx, other.sortidx)\n\n"
  },
  {
    "path": "gccutils/graph/supergraph.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom gccutils.graph import Graph, Node, Edge, Subgraph\nfrom gccutils.graph.stmtgraph import StmtGraph\n\n############################################################################\n# Supergraph of all CFGs, built from each functions' StmtGraph.\n# A graph in which the nodes wrap StmtNode\n############################################################################\nclass Supergraph(Graph):\n    __slots__ = ('supernode_for_stmtnode',\n                 'stmtg_for_fun',\n                 'fake_entry_node')\n\n    def __init__(self, split_phi_nodes, add_fake_entry_node):\n        Graph.__init__(self)\n        self.supernode_for_stmtnode = {}\n        # 1st pass: locate interprocedural instances of gcc.GimpleCall\n        # i.e. where both caller and callee are within the supergraph\n        # (perhaps the same function)\n        ipcalls = set()\n        from gcc import get_callgraph_nodes\n        for node in get_callgraph_nodes():\n            fun = node.decl.function\n            if fun:\n                for edge in node.callees:\n                    if edge.callee.decl.function:\n                        ipcalls.add(edge.call_stmt)\n\n        # 2nd pass: construct a StmtGraph for each function in the callgraph\n        # and add nodes and edges to \"self\" wrapping the nodes and edges\n        # within each StmtGraph:\n        self.stmtg_for_fun = {}\n        for node in get_callgraph_nodes():\n            fun = node.decl.function\n            if fun:\n                stmtg = StmtGraph(fun, split_phi_nodes)\n                self.stmtg_for_fun[fun] = stmtg\n                # Clone the stmtg nodes and edges into the Supergraph:\n                stmtg.supernode_for_stmtnode = {}\n                for node in stmtg.nodes:\n                    if node.stmt in ipcalls:\n                        # These nodes will have two supernodes, a CallNode\n                        # and a ReturnNode:\n                        callnode = self.add_node(CallNode(node, stmtg))\n                        returnnode = self.add_node(ReturnNode(node, stmtg))\n                        callnode.returnnode = returnnode\n                        returnnode.callnode = callnode\n                        stmtg.supernode_for_stmtnode[node] = (callnode, returnnode)\n                        self.add_edge(\n                            callnode, returnnode,\n                            CallToReturnSiteEdge, None)\n                    else:\n                        stmtg.supernode_for_stmtnode[node] = \\\n                            self.add_node(SupergraphNode(node, stmtg))\n                for edge in stmtg.edges:\n                    if edge.srcnode.stmt in ipcalls:\n                        # Begin the superedge from the ReturnNode:\n                        srcsupernode = stmtg.supernode_for_stmtnode[edge.srcnode][1]\n                    else:\n                        srcsupernode = stmtg.supernode_for_stmtnode[edge.srcnode]\n                    if edge.dstnode.stmt in ipcalls:\n                        # End the superedge at the CallNode:\n                        dstsupernode = stmtg.supernode_for_stmtnode[edge.dstnode][0]\n                    else:\n                        dstsupernode = stmtg.supernode_for_stmtnode[edge.dstnode]\n                    superedge = self.add_edge(srcsupernode, dstsupernode,\n                                              SupergraphEdge, edge)\n\n        # 3rd pass: add the interprocedural edges (call and return):\n        for node in get_callgraph_nodes():\n            fun = node.decl.function\n            if fun:\n                for edge in node.callees:\n                    if edge.callee.decl.function:\n                        calling_stmtg = self.stmtg_for_fun[fun]\n                        called_stmtg = self.stmtg_for_fun[edge.callee.decl.function]\n\n                        calling_stmtnode = calling_stmtg.node_for_stmt[edge.call_stmt]\n                        assert calling_stmtnode\n\n                        entry_stmtnode = called_stmtg.entry\n                        assert entry_stmtnode\n\n                        exit_stmtnode = called_stmtg.exit\n                        assert exit_stmtnode\n\n                        superedge_call = self.add_edge(\n                            calling_stmtg.supernode_for_stmtnode[calling_stmtnode][0],\n                            called_stmtg.supernode_for_stmtnode[entry_stmtnode],\n                            CallToStart,\n                            None)\n                        superedge_return = self.add_edge(\n                            called_stmtg.supernode_for_stmtnode[exit_stmtnode],\n                            calling_stmtg.supernode_for_stmtnode[calling_stmtnode][1],\n                            ExitToReturnSite,\n                            None)\n                        superedge_return.calling_stmtnode = calling_stmtnode\n\n        # 4th pass: create fake entry node:\n        if not add_fake_entry_node:\n            self.fake_entry_node = None\n            return\n\n        self.fake_entry_node = self.add_node(FakeEntryNode(None, None))\n        \"\"\"\n\t/* At file scope, the presence of a `static' or `register' storage\n\t   class specifier, or the absence of all storage class specifiers\n\t   makes this declaration a definition (perhaps tentative).  Also,\n\t   the absence of `static' makes it public.  */\n\tif (current_scope == file_scope)\n\t  {\n\t    TREE_PUBLIC (decl) = storage_class != csc_static;\n\t    TREE_STATIC (decl) = !extern_ref;\n\t  }\n          \"\"\"\n        # For now, assume all non-static functions are possible entrypoints:\n        for fun in self.stmtg_for_fun:\n            # Only for non-static functions:\n            if fun.decl.is_public:\n                stmtg = self.stmtg_for_fun[fun]\n                self.add_edge(self.fake_entry_node,\n                              stmtg.supernode_for_stmtnode[stmtg.entry],\n                              FakeEntryEdge,\n                              None)\n\n    def add_node(self, supernode):\n        Graph.add_node(self, supernode)\n        # Keep track of mapping from stmtnode -> supernode\n        self.supernode_for_stmtnode[supernode.innernode] = supernode\n        return supernode\n\n    def _make_edge(self, srcnode, dstnode, cls, edge):\n        return cls(srcnode, dstnode, edge)\n\n    def get_entry_nodes(self):\n        if self.fake_entry_node:\n            yield self.fake_entry_node\n\n    def get_functions(self):\n        for fun in self.stmtg_for_fun:\n            yield fun\n\nclass SupergraphNode(Node):\n    \"\"\"\n    A node in the supergraph, wrapping a StmtNode\n    \"\"\"\n    __slots__ = ('innernode', 'stmtg')\n\n    def __init__(self, innernode, stmtg):\n        Node.__init__(self)\n        self.innernode = innernode\n        self.stmtg = stmtg\n\n    def to_dot_html(self, ctxt):\n        return self.innernode.to_dot_html(ctxt)\n\n    def __str__(self):\n        return str(self.innernode)\n\n    def __repr__(self):\n        return 'SupergraphNode(%r)' % self.innernode\n\n    @property\n    def supergraphnode(self):\n        return self\n\n    @property\n    def stmtnode(self):\n        return self.innernode\n\n    @property\n    def stmt(self):\n        if self.innernode:\n            return self.innernode.get_stmt()\n\n    def get_stmt(self):\n        if self.innernode:\n            return self.innernode.get_stmt()\n\n    def get_gcc_loc(self):\n        if self.innernode:\n            return self.innernode.get_gcc_loc()\n\n    def get_subgraph_path(self, ctxt):\n        if self.stmtg:\n            func = self.stmtg.fun\n            filename = func.start.file\n            funcname = func.decl.name\n            return (Subgraph(filename, filename),\n                    Subgraph(funcname, funcname), )\n        return ()\n\n    @property\n    def function(self):\n        \"\"\"\n        Get the gcc.Function for this node\n        \"\"\"\n        if self.stmtg:\n            return self.stmtg.fun\n\nclass CallNode(SupergraphNode):\n    \"\"\"\n    A first node for a gcc.GimpleCall, representing the invocation of the\n    function.\n    It has the same stmt (the gcc.GimpleCall) as the ReturnNode\n    \"\"\"\n    __slots__ = ('returnnode', # the corresponding ReturnNode\n                 )\n\nclass ReturnNode(SupergraphNode):\n    \"\"\"\n    A second node for a gcc.GimpleCall, representing the assignment of the\n    return value from the completed call into the LHS.\n    It has the same stmt (the gcc.GimpleCall) as the CallNode\n    \"\"\"\n    __slots__ = ('callnode', # the corresponding CallNode\n                 )\n\nclass FakeEntryNode(SupergraphNode):\n    \"\"\"\n    Fake entry node which links to all externally-visible entry nodes, so\n    that a supergraph can have a unique entrypoint.\n\n    It represents \"the outside world\" when analyzing the supergraph of a\n    shared library.\n    \"\"\"\n    __slots__ = ()\n\n    def __str__(self):\n        return 'ALL ENTRYPOINTS'\n\n    def __repr__(self):\n        return 'FakeEntryNode'\n\n    def to_dot_html(self, ctxt):\n        from gccutils.dot import Text\n        return Text('ALL ENTRYPOINTS')\n\nclass SupergraphEdge(Edge):\n    \"\"\"\n    An edge in the supergraph, wrapping a StmtEdge,\n    or None for the intraprocedual edges for function call/return\n    \"\"\"\n    __slots__ = ('inneredge', )\n\n    def __init__(self, srcnode, dstnode, inneredge):\n        Edge.__init__(self, srcnode, dstnode)\n        self.inneredge = inneredge\n\n    def to_dot_label(self, ctxt):\n        if self.inneredge:\n            return self.inneredge.to_dot_label(ctxt)\n\n    @property\n    def true_value(self):\n        if self.inneredge:\n            return self.inneredge.true_value\n\n    @property\n    def false_value(self):\n        if self.inneredge:\n            return self.inneredge.false_value\n\n    @property\n    def stmtedge(self):\n        return self.inneredge\n\nclass CallToReturnSiteEdge(SupergraphEdge):\n    \"\"\"\n    The intraprocedural edge for a function call, from\n    the gcc.GimpleCall to the next statement\n    \"\"\"\n    __slots__ = ()\n\n    def to_dot_label(self, ctxt):\n        return 'within function'\n\n    def to_dot_attrs(self, ctxt):\n        return ' penwidth=2'\n\nclass CallToStart(SupergraphEdge):\n    \"\"\"\n    The interprocedural edge for the start of a function call: from\n    the gcc.GimpleCall to the entry node of the callee\n    \"\"\"\n    __slots__ = ()\n\n    def to_dot_label(self, ctxt):\n        return 'call of %s' % self.dstnode.function.decl.name\n\n    def to_dot_attrs(self, ctxt):\n        #return ' constraint=false, style=dotted'\n        return ' style=dotted'\n\nclass ExitToReturnSite(SupergraphEdge):\n    \"\"\"\n    The interprocedural edge for the end of a function call: from\n    the exit node of the callee to the successor node of the\n    gcc.GimpleCall within the caller\n    \"\"\"\n    __slots__ = ('calling_stmtnode', )\n\n    def to_dot_label(self, ctxt):\n        return 'return to %s' % self.dstnode.function.decl.name\n\n    def to_dot_attrs(self, ctxt):\n        #return ' constraint=false, style=dotted'\n        return ' style=dotted'\n\nclass FakeEntryEdge(SupergraphEdge):\n    \"\"\"\n    Fake edge from the FakeEntryNode to one of the entrypoints.\n\n    This represents a call \"from outside\" the scope of the supergraph\n    (e.g. for analyzing a library)\n    \"\"\"\n    __slots__ = ()\n\n    def to_dot_label(self, ctxt):\n        return 'external call'\n"
  },
  {
    "path": "gccutils/selftests.py",
    "content": "#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Helper functions for writing selftests\n#\n# Sometimes it's hard to use the stdlib's unittest module, given that in\n# the plugin we're typically effectively being run as a callback from gcc\n# (either literally, or as a gcc.Pass)\n\ndef assertEqual(lhs, rhs):\n    if lhs != rhs:\n        raise ValueError('non-equal values: %r != %r' % (lhs, rhs))\n\ndef assertEndsWith(s, suffix):\n    if not s.endswith(suffix):\n        raise ValueError('%r does not end with %r' % (s, suffix))\n"
  },
  {
    "path": "generate-callgraph-c.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"gcc-c-api/gcc-callgraph.h\")\ncu.add_include(\"gcc-c-api/gcc-gimple.h\")\ncu.add_include(\"gcc-c-api/gcc-tree.h\")\ncu.add_include(\"gcc-c-api/gcc-declaration.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_callgraph_edge():\n    #\n    # Generate the gcc.CallgraphEdge class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccCallgraphEdge_getset_table', [],\n                                   identifier_prefix='PyGccCallgraphEdge',\n                                   typename='PyGccCallgraphEdge')\n    getsettable.add_simple_getter(cu,\n                                  'caller',\n                                  'PyGccCallgraphNode_New(gcc_cgraph_edge_get_caller(self->edge))',\n                                  'The function that makes this call, as a gcc.CallgraphNode')\n    getsettable.add_simple_getter(cu,\n                                  'callee',\n                                  'PyGccCallgraphNode_New(gcc_cgraph_edge_get_callee(self->edge))',\n                                  'The function that is called here, as a gcc.CallgraphNode')\n    getsettable.add_simple_getter(cu,\n                                  'call_stmt',\n                                  'PyGccGimple_New(gcc_gimple_call_as_gcc_gimple(gcc_cgraph_edge_get_call_stmt(self->edge)))',\n                                  'The gcc.GimpleCall statememt for the function call')\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccCallgraphEdge_TypeObj',\n                          localname = 'CallgraphEdge',\n                          tp_name = 'gcc.CallgraphEdge',\n                          struct_name = 'PyGccCallgraphEdge',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = getsettable.identifier,\n                          tp_repr = '(reprfunc)PyGccCallgraphEdge_repr',\n                          tp_str = '(reprfunc)PyGccCallgraphEdge_str',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_callgraph_edge()\n\ndef generate_callgraph_node():\n    #\n    # Generate the gcc.CallgraphNode class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccCallgraphNode_getset_table', [],\n                                   identifier_prefix='PyGccCallgraphNode',\n                                   typename='PyGccCallgraphNode')\n    # FIXME: add getters\n    getsettable.add_simple_getter(cu,\n                                  'decl',\n                                  'PyGccTree_New(gcc_function_decl_as_gcc_tree(gcc_cgraph_node_get_decl(self->node)))',\n                                  'The gcc.FunctionDecl for this node')\n    getsettable.add_gsdef('callees',\n                          'PyGccCallgraphNode_get_callees',\n                          None,\n                          'The function calls made by this function, as a list of gcc.CallgraphEdge')\n    getsettable.add_gsdef('callers',\n                          'PyGccCallgraphNode_get_callers',\n                          None,\n                          'The places that call this function, as a list of gcc.CallgraphEdge')\n    cu.add_defn(getsettable.c_defn())\n\n    # see gcc/cgraph.c: dump_cgraph_node (FILE *f, struct cgraph_node *node)\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccCallgraphNode_TypeObj',\n                          localname = 'CallgraphNode',\n                          tp_name = 'gcc.CallgraphNode',\n                          struct_name = 'PyGccCallgraphNode',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = getsettable.identifier,\n                          tp_repr = '(reprfunc)PyGccCallgraphNode_repr',\n                          tp_str = '(reprfunc)PyGccCallgraphNode_str',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_callgraph_node()\n\ncu.add_defn(\"\"\"\nint autogenerated_callgraph_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_callgraph_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-casts-c.py",
    "content": "#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport glob\n\nimport sys\nsys.path.append('gcc-c-api')\nfrom xmltypes import ApiRegistry, Api\n\nCOPYRIGHT_HEADER = '''\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n'''\n\ndef write_header(out):\n    out.write('/* This file is autogenerated: do not edit */\\n')\n    out.write('/*%s*/\\n' % COPYRIGHT_HEADER)\n    out.write('\\n')\n\ndef write_footer(out):\n    out.write('''\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n''')\n\ndef write_c(registry, c_out):\n    write_header(c_out)\n\n    c_out.write('#include <Python.h>\\n')\n    c_out.write('#include \"gcc-python.h\"\\n')\n    c_out.write('#include \"gcc-python-wrappers.h\"\\n')\n    c_out.write('#include \"gcc-python-compat.h\"\\n')\n    c_out.write('#include \"cp/cp-tree.h\"\\n')\n    c_out.write('#include \"gimple.h\"\\n')\n\n    c_out.write('#include \"cp/cp-tree.h\" /* for TFF_* for use by PyGccFunctionDecl_get_fullname */\\n')\n\n    c_out.write('/* op_symbol_code moved to tree-pretty-print.h in gcc 4.9\\n')\n    c_out.write('   but tree-pretty-print.h is only available from 4.7 onwards.  */\\n')\n    c_out.write('#if (GCC_VERSION >= 4009)\\n')\n    c_out.write('#include \"tree-pretty-print.h\"\\n')\n    c_out.write('#endif\\n')\n\n    c_out.write('#include \"gcc-c-api/gcc-tree.h\"\\n')\n    c_out.write('#include \"gcc-c-api/gcc-type.h\"\\n')\n\n    c_out.write('#include \"autogenerated-casts.h\"\\n\\n\\n')\n\n    tree_type = registry.lookup_type('tree')\n    for subclass in tree_type.get_subclasses(recursive=True):\n        c_out.write('%s\\n'\n                    'PyGccTree_as_%s(struct PyGccTree * self)\\n'\n                    '{\\n'\n                    '    return gcc_tree_as_%s(self->t);\\n'\n                    '}\\n\\n'\n                    % (subclass.get_c_name(),\n                       subclass.get_c_name(),\n                       subclass.get_c_name()))\n    write_footer(c_out)\n\ndef write_h(registry, h_out):\n    write_header(h_out)\n\n    h_out.write('#include <gcc-c-api/gcc-tree.h>\\n')\n\n    tree_type = registry.lookup_type('tree')\n    for subclass in tree_type.get_subclasses(recursive=True):\n        h_out.write('extern %s\\n'\n                    'PyGccTree_as_%s(struct PyGccTree * self);\\n\\n'\n                    % (subclass.get_c_name(), subclass.get_c_name()))\n    write_footer(h_out)\n\ndef main(c_filename, h_filename, xmldir):\n    registry = ApiRegistry()\n    for xmlfile in sorted(glob.glob(xmldir + '*.xml')):\n        api = Api(registry, xmlfile)\n\n    with open(c_filename, 'w') as c_out:\n        write_c(registry, c_out)\n\n    with open(h_filename, 'w') as h_out:\n        write_h(registry, h_out)\n\n\nmain(c_filename=sys.argv[1],\n     h_filename=sys.argv[2],\n     xmldir=sys.argv[3])\n"
  },
  {
    "path": "generate-cfg-c.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include('gcc-c-api/gcc-cfg.h')\n#cu.add_include(\"basic-block.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_edge():\n    #\n    # Generate the gcc.Edge class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccEdge_getset_table',\n                                   [PyGetSetDef('src',\n                                                cu.add_simple_getter('PyGccEdge_get_src',\n                                                                     'PyGccEdge',\n                                                                     'PyGccBasicBlock_New(gcc_cfg_edge_get_src(self->e))'),\n                                                None,\n                                                'The source gcc.BasicBlock of this edge'),\n                                    PyGetSetDef('dest',\n                                                cu.add_simple_getter('PyGccEdge_get_dest',\n                                                                     'PyGccEdge',\n                                                                     'PyGccBasicBlock_New(gcc_cfg_edge_get_dest(self->e))'),\n                                                None,\n                                                'The destination gcc.BasicBlock of this edge')],\n                                   identifier_prefix = 'PyGccEdge',\n                                   typename = 'PyGccEdge')\n\n    # We only expose the subset of the flags exposed by gcc-c-api\n    for attrname, flaggetter in [('true_value', 'is_true_value'),\n                                 ('false_value', 'is_false_value'),\n                                 ('loop_exit', 'is_loop_exit'),\n                                 ('can_fallthru', 'get_can_fallthru'),\n                                 ('complex', 'is_complex'),\n                                 ('eh', 'is_eh'),\n                                 ]:\n        getsettable.add_simple_getter(cu,\n                                      attrname,\n                                      'PyBool_FromLong(gcc_cfg_edge_%s(self->e))' % flaggetter,\n                                      None)\n\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccEdge_TypeObj',\n                          localname = 'Edge',\n                          tp_name = 'gcc.Edge',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccEdge',\n                          tp_new = 'PyType_GenericNew',\n                          #tp_repr = '(reprfunc)PyGccEdge_repr',\n                          #tp_str = '(reprfunc)PyGccEdge_repr',\n                          tp_getset = getsettable.identifier,\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_edge()\n\ndef generate_basic_block():\n    #\n    # Generate the gcc.BasicBlock class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccBasicBlock_getset_table',\n                                   [PyGetSetDef('preds',\n                                                'PyGccBasicBlock_get_preds',\n                                                None,\n                                                'The list of predecessor gcc.Edge instances leading into this block'),\n                                    PyGetSetDef('succs',\n                                                'PyGccBasicBlock_get_succs',\n                                                None,\n                                                'The list of successor gcc.Edge instances leading out of this block'),\n                                    PyGetSetDef('gimple',\n                                                'PyGccBasicBlock_get_gimple',\n                                                None,\n                                                'The list of gcc.Gimple instructions, if appropriate for this pass, or None'),\n                                    PyGetSetDef('phi_nodes',\n                                                'PyGccBasicBlock_get_phi_nodes',\n                                                None,\n                                                'The list of gcc.GimplePhi phoney functions, if appropriate for this pass, or None'),\n                                    PyGetSetDef('rtl',\n                                                'PyGccBasicBlock_get_rtl',\n                                                None,\n                                                'The list of gcc.Rtl instructions, if appropriate for this pass, or None'),\n                                    ],\n                                   identifier_prefix='PyGccBasicBlock',\n                                   typename='PyGccBasicBlock')\n    getsettable.add_simple_getter(cu,\n                                  'index',\n                                  'PyGccInt_FromLong(gcc_cfg_block_get_index(self->bb))',\n                                  None)\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccBasicBlock_TypeObj',\n                          localname = 'BasicBlock',\n                          tp_name = 'gcc.BasicBlock',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccBasicBlock',\n                          tp_new = 'PyType_GenericNew',\n                          tp_repr = '(reprfunc)PyGccBasicBlock_repr',\n                          #tp_str = '(reprfunc)PyGccBasicBlock_repr',\n                          tp_getset = getsettable.identifier,\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_basic_block()\n\ndef generate_cfg():\n    #\n    # Generate the gcc.Cfg class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccCfg_getset_table',\n                                   [PyGetSetDef('basic_blocks',\n                                                'PyGccCfg_get_basic_blocks',\n                                                None,\n                                                'The list of gcc.BasicBlock instances in this graph'),\n                                    PyGetSetDef('entry',\n                                                cu.add_simple_getter('PyGccCfg_get_entry',\n                                                                     'PyGccCfg',\n                                                                     'PyGccBasicBlock_New(gcc_cfg_get_entry(self->cfg))'),\n                                                None,\n                                                'The initial gcc.BasicBlock in this graph'),\n                                    PyGetSetDef('exit', \n                                                cu.add_simple_getter('PyGccCfg_get_exit',\n                                                                     'PyGccCfg',\n                                                                     'PyGccBasicBlock_New(gcc_cfg_get_exit(self->cfg))'),\n                                                None,\n                                                'The final gcc.BasicBlock in this graph'),\n                                    ])\n    cu.add_defn(getsettable.c_defn())\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccCfg_TypeObj',\n                          localname = 'Cfg',\n                          tp_name = 'gcc.Cfg',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccCfg',\n                          tp_new = 'PyType_GenericNew',\n                          #tp_repr = '(reprfunc)PyGccCfg_repr',\n                          #tp_str = '(reprfunc)PyGccCfg_repr',\n                          tp_getset = getsettable.identifier,\n                          )\n    methods = PyMethodTable('PyGccCfg_methods', [])\n    methods.add_method('get_block_for_label',\n                       'PyGccCfg_get_block_for_label',\n                       'METH_VARARGS',\n                       \"Given a gcc.LabelDecl, get the corresponding gcc.BasicBlock\")\n    cu.add_defn(methods.c_defn())\n    pytype.tp_methods = methods.identifier\n\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_cfg()\n\ncu.add_defn(\"\"\"\nint autogenerated_cfg_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_cfg_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-config-h.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport os\nimport sys\n\nfrom configbuilder import ConfigBuilder, CheckFor\n\nclass GccPythonPluginConfigBuilder(ConfigBuilder):\n    def __init__(self, argv):\n        import argparse\n        parser = argparse.ArgumentParser()\n        parser.add_argument('--gcc')\n        parser.add_argument('--plugindir')\n        args, argv = parser.parse_known_args(argv)\n        ConfigBuilder.__init__(self, argv)\n        self.gcc = args.gcc\n        self.plugindir = args.plugindir\n        self.extra_compilation_args = []\n\n    def main(self):\n        prefix = 'GCC_PYTHON_PLUGIN_CONFIG_'\n        if self.plugindir:\n            plugindir = self.plugindir\n        else:\n            plugindir = self.capture_shell_output('locating plugin directory for %s' % self.gcc,\n                                            '%s --print-file-name=plugin' % self.gcc).strip()\n        extraargs = ['-I%s' % os.path.join(plugindir, 'include')]\n\n        self.test_whether_built_with_cplusplus()\n        extraargs += self.extra_compilation_args\n\n        # In GCC 4.9 onwards, this header file uses C++ syntax, so we\n        # must already have determined C vs C++ at this point\n        self.test_for_mandatory_c_header('gcc-plugin.h', extraargs)\n\n        self.test_c_compilation(initmsg='checking whether plugin.def defines PLUGIN_FINISH_DECL',\n                              src='''\n#include <gcc-plugin.h>\n\nint i[PLUGIN_FINISH_DECL];\n''',\n                              extraargs=extraargs,\n                              description='Does plugin.def define PLUGIN_FINISH_DECL?',\n                              defn=prefix+'has_PLUGIN_FINISH_DECL')\n        self.test_rtti()\n        self.write_outcome()\n        self.write_EXTRA_CFLAGS()\n\n    def test_whether_built_with_cplusplus(self):\n        \"\"\"\n        Determine if the GCC was built with C++ or C\n        \"\"\"\n        # According to http://gcc.gnu.org/ml/gcc/2012-03/msg00411.html\n        # we should look in $(gcc -print-file-name=plugin)/include/auto-host.h\n        # where we'll see either:\n        #\n        # Old 4.6, built with C:\n        #   /* Define if building with C++. */\n        #   #ifndef USED_FOR_TARGET\n        #   /* #undef ENABLE_BUILD_WITH_CXX */\n        #   #endif\n        #\n        # New 4.7, built with C++:\n        #   /* Define if building with C++. */\n        #   #ifndef USED_FOR_TARGET\n        #   #define ENABLE_BUILD_WITH_CXX 1\n        #   #endif\n        #\n        # 4.8, built with C++ doesn't have this (always built with C++)\n        with CheckFor('Checking whether %s was built with C or C++' % self.gcc,\n                      True) as check:\n            def with_cplusplus():\n                check.okmsg = 'C++'\n                self.extra_compilation_args += ['-x', 'c++']\n            def with_c():\n                check.okmsg = 'C'\n            auto_host_h = os.path.join(self.plugindir, 'include', 'auto-host.h')\n            with open(auto_host_h, 'r') as f:\n                content = f.read()\n            if '/* #undef ENABLE_BUILD_WITH_CXX */' in content:\n                with_c()\n            elif '#define ENABLE_BUILD_WITH_CXX 1' in content:\n                with_cplusplus()\n            else:\n                # Not found, assume C++:\n                with_cplusplus()\n\n    def test_rtti(self):\n        # Only need to do this check for C++ compilation\n        if 'c++' in self.extra_compilation_args:\n            with CheckFor('checking whether passes are C++ classes', True) as check:\n                tree_pass_h = os.path.join(self.plugindir, 'include', 'tree-pass.h')\n                with open(tree_pass_h, 'r') as f:\n                    content = f.read()\n                if 'class opt_pass' in content:\n                    # Passes are C++ classes (GCC 4.9 onwards); we need\n                    # -fno-rtti\n                    self.extra_compilation_args += ['-fno-rtti']\n                    check.okmsg = 'yes'\n                else:\n                    check.okmsg = 'no'\n\n    def write_EXTRA_CFLAGS(self):\n        filename = 'autogenerated-EXTRA_CFLAGS.txt'\n        sys.stdout.write('writing %s\\n' % filename)\n        with open(filename, 'w') as f:\n            f.write(' '.join(self.extra_compilation_args))\n\nch = GccPythonPluginConfigBuilder(sys.argv)\nch.main()\n\n"
  },
  {
    "path": "generate-function-c.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"function.h\")\ncu.add_include(\"gcc-c-api/gcc-function.h\")\ncu.add_include(\"gcc-c-api/gcc-declaration.h\")\ncu.add_include(\"gcc-c-api/gcc-tree.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_function():\n    #\n    # Generate the gcc.Function class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n    cu.add_defn(\"\\n\"\n                \"static PyObject *\\n\"\n                \"PyGccFunction_get_cfg(struct PyGccFunction *self, void *closure)\\n\"\n                \"{\\n\"\n                \"    return PyGccCfg_New(gcc_function_get_cfg(self->fun));\\n\"\n                \"}\\n\"\n                \"\\n\")\n    getsettable = PyGetSetDefTable('PyGccFunction_getset_table',\n                                   [PyGetSetDef('cfg', 'PyGccFunction_get_cfg', None,\n                                                'Instance of gcc.Cfg for this function (or None for early passes)'),\n                                    ],\n                                   identifier_prefix='PyGccFunction',\n                                   typename='PyGccFunction')\n    getsettable.add_simple_getter(cu,\n                                  'decl', \n                                  'PyGccTree_New(gcc_function_decl_as_gcc_tree(gcc_function_get_decl(self->fun)))',\n                                  'The declaration of this function, as a gcc.FunctionDecl instance')\n    getsettable.add_simple_getter(cu,\n                                  'local_decls',\n                                  'VEC_tree_as_PyList(self->fun.inner->local_decls)',\n                                  \"List of gcc.VarDecl for the function's local variables\")\n    getsettable.add_simple_getter(cu,\n                                  'funcdef_no',\n                                  'PyGccInt_FromLong(gcc_function_get_index(self->fun))',\n                                  'Function sequence number for profiling, debugging, etc.')\n    getsettable.add_simple_getter(cu,\n                                  'start',\n                                  'PyGccLocation_New(gcc_function_get_start(self->fun))',\n                                  'Location of the start of the function')\n    getsettable.add_simple_getter(cu,\n                                  'end',\n                                  'PyGccLocation_New(gcc_function_get_end(self->fun))',\n                                  'Location of the end of the function')\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccFunction_TypeObj',\n                          localname = 'Function',\n                          tp_name = 'gcc.Function',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccFunction',\n                          tp_new = 'PyType_GenericNew',\n                          tp_repr = '(reprfunc)PyGccFunction_repr',\n                          tp_str = '(reprfunc)PyGccFunction_repr',\n                          tp_hash = '(hashfunc)PyGccFunction_hash',\n                          tp_richcompare = 'PyGccFunction_richcompare',\n                          tp_getset = getsettable.identifier,\n                                    )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_function()\n\ncu.add_defn(\"\"\"\nint autogenerated_function_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_function_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-gimple-c.py",
    "content": "#   Copyright 2011, 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012, 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom maketreetypes import iter_gimple_types, iter_gimple_struct_types\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"gimple.h\")\ncu.add_include(\"gcc-c-api/gcc-gimple.h\")\ncu.add_include(\"gcc-c-api/gcc-declaration.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ngimple_struct_types = list(iter_gimple_struct_types())\ngimple_types = list(iter_gimple_types())\n\n# gimple.h declares a family of struct gimple_statement_* which internally express an inheritance hierarchy, via enum enum gimple_statement_structure_enum (see gsstruct.def).\n# FIXME there's also enum gimple_code, which is used to look up into this hierarchy\n#\n# From reading gimple.h, the struct hierarchy is:\n#\n# gimple_statement_base (GSS_BASE)\n#   gimple_statement_with_ops_base\n#      gimple_statement_with_ops (GSS_WITH_OPS)\n#      gimple_statement_with_memory_ops_base (GSS_WITH_MEM_OPS_BASE)\n#         gimple_statement_with_memory_ops (GSS_WITH_MEM_OPS)\n#         gimple_statement_call (GSS_CALL)\n#         gimple_statement_asm (GSS_ASM)\n#   gimple_statement_omp (GSS_OMP)\n#     gimple_statement_omp_critical (GSS_OMP_CRITICAL)\n#     gimple_statement_omp_for (GSS_OMP_FOR)\n#     gimple_statement_omp_parallel (GSS_OMP_PARALLEL)\n#       gimple_statement_omp_task (GSS_OMP_TASK)\n#     gimple_statement_omp_sections (GSS_OMP_SECTIONS)\n#     gimple_statement_omp_single (GSS_OMP_SINGLE)\n#   gimple_statement_bind (GSS_BIND)\n#   gimple_statement_catch (GSS_CATCH)\n#   gimple_statement_eh_filter (GSS_EH_FILTER)\n#   gimple_statement_eh_mnt (GSS_EH_MNT)\n#   gimple_statement_phi (GSS_PHI)\n#   gimple_statement_eh_ctrl (GSS_EH_CTRL)\n#   gimple_statement_try (GSS_TRY)\n#   gimple_statement_wce (GSS_WCE)\n#   gimple_statement_omp_continue (GSS_OMP_CONTINUE)   (does not inherit from gimple_statement_omp)\n#   gimple_statement_omp_atomic_load (GSS_OMP_ATOMIC_LOAD  (likewise)\n#   gimple_statement_omp_atomic_store (GSS_OMP_ATOMIC_STORE)  (ditto)\n\n# The inheritance hierarchy of struct gimple_statement_*,\n#  expressed as (structname, parentstructname) pairs:\nstruct_hier = (('gimple_statement_base', None),\n               ('gimple_statement_with_ops_base', 'simple_statement_base'),\n               ('gimple_statement_with_ops', 'gimple_statement_with_ops_base'),\n               ('gimple_statement_with_memory_ops_base', 'gimple_statement_with_ops_base opbase'),\n               ('gimple_statement_with_memory_ops', 'gimple_statement_with_memory_ops_base membase'),\n               ('gimple_statement_call', 'gimple_statement_with_memory_ops_base membase'),\n               ('gimple_statement_omp', 'gimple_statement_base'),\n               ('gimple_statement_bind', 'gimple_statement_base'),\n               ('gimple_statement_catch', 'gimple_statement_base'),\n               ('gimple_statement_eh_filter', 'gimple_statement_base'),\n               ('gimple_statement_eh_mnt', 'gimple_statement_base'),\n               ('gimple_statement_phi', 'gimple_statement_base'),\n               ('gimple_statement_eh_ct', 'gimple_statement_base'),\n               ('gimple_statement_try', 'gimple_statement_base'),\n               ('gimple_statement_wce', 'gimple_statement_base'),\n               ('gimple_statement_asm', 'gimple_statement_with_memory_ops_base'),\n               ('gimple_statement_omp_critical', 'gimple_statement_omp'),\n               ('gimple_statement_omp_for', 'gimple_statement_omp'),\n               ('gimple_statement_omp_parallel', 'gimple_statement_omp'),\n               ('gimple_statement_omp_task', 'gimple_statement_omp_parallel'),\n               ('gimple_statement_omp_sections', 'gimple_statement_omp'),\n               ('gimple_statement_omp_continue', 'gimple_statement_base'),\n               ('gimple_statement_omp_single', 'gimple_statement_omp'),\n               ('gimple_statement_omp_atomic_load', 'gimple_statement_base'),\n               ('gimple_statement_omp_atomic_store', 'gimple_statement_base'))\n\n# Interleaving with the material from gimple.def:\n# gimple_statement_base (GSS_BASE)\n#   GIMPLE_ERROR_MARK, \"gimple_error_mark\", GSS_BASE\n#   GIMPLE_NOP, \"gimple_nop\", GSS_BASE\n#   GIMPLE_OMP_RETURN, \"gimple_omp_return\", GSS_BASE\n#   GIMPLE_OMP_SECTIONS_SWITCH, \"gimple_omp_sections_switch\", GSS_BASE\n#   GIMPLE_PREDICT, \"gimple_predict\", GSS_BASE\n#   gimple_statement_with_ops_base\n#      gimple_statement_with_ops (GSS_WITH_OPS)\n#        GIMPLE_COND, \"gimple_cond\", GSS_WITH_OPS\n#        GIMPLE_DEBUG, \"gimple_debug\", GSS_WITH_OPS\n#        GIMPLE_GOTO, \"gimple_goto\", GSS_WITH_OPS\n#        GIMPLE_LABEL, \"gimple_label\", GSS_WITH_OPS\n#        GIMPLE_SWITCH, \"gimple_switch\", GSS_WITH_OPS\n#      gimple_statement_with_memory_ops_base (GSS_WITH_MEM_OPS_BASE)\n#         gimple_statement_with_memory_ops (GSS_WITH_MEM_OPS)\n#           GIMPLE_ASSIGN, \"gimple_assign\", GSS_WITH_MEM_OPS\n#           GIMPLE_RETURN, \"gimple_return\", GSS_WITH_MEM_OPS\n#         gimple_statement_call (GSS_CALL)\n#           GIMPLE_CALL, \"gimple_call\", GSS_CALL\n#         gimple_statement_asm (GSS_ASM)\n#            GIMPLE_ASM, \"gimple_asm\", GSS_ASM\n#   gimple_statement_omp (GSS_OMP)\n#     GIMPLE_OMP_MASTER, \"gimple_omp_master\", GSS_OMP\n#     GIMPLE_OMP_ORDERED, \"gimple_omp_ordered\", GSS_OMP\n#     GIMPLE_OMP_SECTION, \"gimple_omp_section\", GSS_OMP\n#     gimple_statement_omp_critical (GSS_OMP_CRITICAL)\n#       GIMPLE_OMP_CRITICAL, \"gimple_omp_critical\", GSS_OMP_CRITICAL\n#     gimple_statement_omp_for (GSS_OMP_FOR)\n#        GIMPLE_OMP_FOR, \"gimple_omp_for\", GSS_OMP_FOR\n#     gimple_statement_omp_parallel (GSS_OMP_PARALLEL)\n#       GIMPLE_OMP_PARALLEL, \"gimple_omp_parallel\", GSS_OMP_PARALLEL\n#       gimple_statement_omp_task (GSS_OMP_TASK)\n#       GIMPLE_OMP_TASK, \"gimple_omp_task\", GSS_OMP_TASK\n#     gimple_statement_omp_sections (GSS_OMP_SECTIONS)\n#       GIMPLE_OMP_SECTIONS, \"gimple_omp_sections\", GSS_OMP_SECTIONS\n#     gimple_statement_omp_single (GSS_OMP_SINGLE)\n#       GIMPLE_OMP_SINGLE, \"gimple_omp_single\", GSS_OMP_SINGLE\n#   gimple_statement_bind (GSS_BIND)\n#     GIMPLE_BIND, \"gimple_bind\", GSS_BIND\n#   gimple_statement_catch (GSS_CATCH)\n#     GIMPLE_CATCH, \"gimple_catch\", GSS_CATCH\n#   gimple_statement_eh_filter (GSS_EH_FILTER)\n#      GIMPLE_EH_FILTER, \"gimple_eh_filter\", GSS_EH_FILTER\n#   gimple_statement_eh_mnt (GSS_EH_MNT)\n#      GIMPLE_EH_MUST_NOT_THROW, \"gimple_eh_must_not_throw\", GSS_EH_MNT\n#   gimple_statement_phi (GSS_PHI)\n#      GIMPLE_PHI, \"gimple_phi\", GSS_PHI\n#   gimple_statement_eh_ctrl (GSS_EH_CTRL)\n#      GIMPLE_RESX, \"gimple_resx\", GSS_EH_CTRL\n#      GIMPLE_EH_DISPATCH, \"gimple_eh_dispatch\", GSS_EH_CTRL\n#   gimple_statement_try (GSS_TRY)\n#     GIMPLE_TRY, \"gimple_try\", GSS_TRY\n#   gimple_statement_wce (GSS_WCE)\n#     GIMPLE_WITH_CLEANUP_EXPR, \"gimple_with_cleanup_expr\", GSS_WCE\n#   gimple_statement_omp_continue (GSS_OMP_CONTINUE)   (does not inherit from gimple_statement_omp)\n#     GIMPLE_OMP_CONTINUE, \"gimple_omp_continue\", GSS_OMP_CONTINUE\n#   gimple_statement_omp_atomic_load (GSS_OMP_ATOMIC_LOAD  (likewise)\n#     GIMPLE_OMP_ATOMIC_LOAD, \"gimple_omp_atomic_load\", GSS_OMP_ATOMIC_LOAD\n#   gimple_statement_omp_atomic_store (GSS_OMP_ATOMIC_STORE)  (ditto)\n#     GIMPLE_OMP_ATOMIC_STORE, \"gimple_omp_atomic_store\", GSS_OMP_ATOMIC_STORE\n\n\ndef generate_gimple_struct_subclasses():\n    global modinit_preinit\n    global modinit_postinit\n    \n    for gt in gimple_struct_types:\n    #print gimple_types\n        cc = gt.camel_cased_string()\n        pytype = PyGccWrapperTypeObject(identifier = 'PyGccGimpleStructType%s_TypeObj' % cc,\n                              localname = 'GimpleStructType' + cc,\n                              tp_name = 'gcc.GimpleStructType%s' % cc,\n                              tp_dealloc = 'PyGccWrapper_Dealloc',\n                              struct_name = 'PyGccGimple',\n                              tp_new = 'PyType_GenericNew',\n                              tp_base = '&PyGccGimple_TypeObj',\n                              #tp_getset = getsettable.identifier,\n                              #tp_repr = '(reprfunc)PyGccGimple_repr',\n                              #tp_str = '(reprfunc)PyGccGimple_str',\n                              )\n        cu.add_defn(pytype.c_defn())\n        modinit_preinit += pytype.c_invoke_type_ready()\n        modinit_postinit += pytype.c_invoke_add_to_module()\n\n#generate_gimple_struct_subclasses()\n\n# See gcc/gimple-pretty-print.c (e.g. /usr/src/debug/gcc-4.6.0-20110321/gcc/gimple-pretty-print.c )\n# for hints on the innards of gimple, in particular, see dump_gimple_stmt\n\ndef generate_gimple():\n    #\n    # Generate the gcc.Gimple class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccGimple_get_location(struct PyGccGimple *self, void *closure)\n{\n    return PyGccLocation_New(gcc_gimple_get_location(self->stmt));\n}\n\nstatic PyObject *\nPyGccGimple_get_block(struct PyGccGimple *self, void *closure)\n{\n    return PyGccTree_New(gcc_gimple_get_block(self->stmt));\n}\n\"\"\")\n\n    getsettable = PyGetSetDefTable('PyGccGimple_getset_table',\n                                   [PyGetSetDef('loc', 'PyGccGimple_get_location', None, 'Source code location of this statement, as a gcc.Location'),\n                                    PyGetSetDef('block', 'PyGccGimple_get_block', None, 'The lexical block holding this statement, as a gcc.Tree'),\n                                    PyGetSetDef('exprtype',\n                                                cu.add_simple_getter('PyGccGimple_get_exprtype',\n                                                                     'PyGccGimple',\n                                                                     'PyGccTree_New(gcc_gimple_get_expr_type(self->stmt))'),\n                                                None,\n                                                'The type of the main expression computed by this statement, as a gcc.Tree (which might be gcc.Void_TypeObj)'),\n                                    PyGetSetDef('str_no_uid',\n                                                'PyGccGimple_get_str_no_uid',\n                                                None,\n                                                'A string representation of this statement, like str(), but without including any internal UID'),\n                                    ])\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccGimple_TypeObj',\n                          localname = 'Gimple',\n                          tp_name = 'gcc.Gimple',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccGimple',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = getsettable.identifier,\n                          tp_repr = '(reprfunc)PyGccGimple_repr',\n                          tp_str = '(reprfunc)PyGccGimple_str',\n                          tp_hash = '(hashfunc)PyGccGimple_hash',\n                          tp_richcompare = 'PyGccGimple_richcompare',\n                          tp_flags = 'Py_TPFLAGS_BASETYPE',\n                          )\n    methods = PyMethodTable('PyGccGimple_methods', [])\n    methods.add_method('walk_tree',\n                       '(PyCFunction)PyGccGimple_walk_tree',\n                       'METH_VARARGS | METH_KEYWORDS',\n                       \"Visit all gcc.Tree nodes associated with this statement\")\n    cu.add_defn(methods.c_defn())\n    pytype.tp_methods = methods.identifier\n\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_gimple()\n\ndef generate_gimple_subclasses():\n    global modinit_preinit\n    global modinit_postinit\n    \n    exprcode_getter = PyGetSetDef('exprcode',\n                                  cu.add_simple_getter('PyGccGimple_get_exprcode',\n                                                       'PyGccGimple',\n                                                       '(PyObject*)PyGcc_autogenerated_tree_type_for_tree_code(gimple_expr_code(self->stmt.inner), 0)'),\n                                  None,\n                                  'The kind of the expression, as an gcc.Tree subclass (the type itself, not an instance)')\n\n    rhs_getter = PyGetSetDef('rhs',\n                             'PyGccGimple_get_rhs',\n                             None,\n                             'The operands on the right-hand-side of the expression, as a list of gcc.Tree instances')\n\n    def make_getset_Asm():\n        getsettable = PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                       [exprcode_getter],\n                                       'PyGccGimpleAsm',\n                                       'PyGccGimple')\n        getsettable.add_simple_getter(cu,\n                                      'string',\n                                      'PyGccString_FromString(gcc_gimple_asm_get_string(PyGccGimple_as_gcc_gimple_asm(self)))',\n                                      'The inline assembler as a string')\n        return getsettable\n\n    def make_getset_Assign():\n        return PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                [PyGetSetDef('lhs',\n                                             cu.add_simple_getter('PyGccGimpleAssign_get_lhs',\n                                                                  'PyGccGimple',\n                                                                  'PyGccTree_New(gcc_gimple_assign_get_lhs(PyGccGimple_as_gcc_gimple_assign(self)))'),\n                                             None,\n                                             'Left-hand-side of the assignment, as a gcc.Tree'),\n                                 exprcode_getter,\n                                 rhs_getter,\n                                 ])\n    def make_getset_Call():\n        return PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                [PyGetSetDef('lhs',\n                                             cu.add_simple_getter('PyGccGimpleCall_get_lhs',\n                                                                  'PyGccGimple',\n                                                                  'PyGccTree_New(gcc_gimple_call_get_lhs(PyGccGimple_as_gcc_gimple_call(self)))'),\n                                             None,\n                                             'Left-hand-side of the call, as a gcc.Tree'),\n                                 rhs_getter,\n                                 PyGetSetDef('fn',\n                                             cu.add_simple_getter('PyGccGimpleCall_get_fn',\n                                                                  'PyGccGimple',\n                                                                  'PyGccTree_New(gcc_gimple_call_get_fn(PyGccGimple_as_gcc_gimple_call(self)))'),\n                                             None,\n                                             'The function being called, as a gcc.Tree'),\n                                 PyGetSetDef('fndecl',\n                                             cu.add_simple_getter('PyGccGimpleCall_get_fndecl',\n                                                                  'PyGccGimple',\n                                                                  'PyGccTree_New(gcc_gimple_call_get_fndecl(PyGccGimple_as_gcc_gimple_call(self)))'),\n                                             None,\n                                             'The declaration of the function being called (if any), as a gcc.Tree'),\n                                 exprcode_getter,\n                                 PyGetSetDef('args',\n                                             'PyGccGimpleCall_get_args',\n                                             None,\n                                             'The arguments for the call, as a list of gcc.Tree'),\n                                 PyGetSetDef('noreturn',\n                                             cu.add_simple_getter('PyGccGimpleCall_get_noreturn',\n                                                                  'PyGccGimple',\n                                                                  'PyBool_FromLong(gcc_gimple_call_is_noreturn(PyGccGimple_as_gcc_gimple_call(self)))'),\n\n                                             None,\n                                             'Has this call been marked as not returning, as a boolean'),\n                                 ],\n                                )\n    def make_getset_Return():\n        return PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                [PyGetSetDef('retval',\n                                             cu.add_simple_getter('PyGccGimpleReturn_get_retval',\n                                                                  'PyGccGimple',\n                                                                  'PyGccTree_New(gcc_gimple_return_get_retval(PyGccGimple_as_gcc_gimple_return(self)))'),\n                                             None,\n                                             'The return value, as a gcc.Tree'),\n                                 ])\n\n\n    def make_getset_Cond():\n        getsettable = PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                       [exprcode_getter],\n                                       'PyGccGimpleCond',\n                                       'PyGccGimple')\n        getsettable.add_simple_getter(cu,\n                                      'lhs',\n                                      'PyGccTree_New(gcc_gimple_cond_get_lhs(PyGccGimple_as_gcc_gimple_cond(self)))',\n                                      None)\n        getsettable.add_simple_getter(cu,\n                                      'rhs',\n                                      'PyGccTree_New(gcc_gimple_cond_get_rhs(PyGccGimple_as_gcc_gimple_cond(self)))',\n                                      None)\n        getsettable.add_simple_getter(cu,\n                                      'true_label',\n                                      'PyGccTree_New(gcc_gimple_cond_get_true_label(PyGccGimple_as_gcc_gimple_cond(self)))',\n                                      None)\n        getsettable.add_simple_getter(cu,\n                                      'false_label',\n                                      'PyGccTree_New(gcc_gimple_cond_get_false_label(PyGccGimple_as_gcc_gimple_cond(self)))',\n                                      None)\n        return getsettable\n\n    def make_getset_Phi():\n        getsettable = PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                       [exprcode_getter],\n                                       'PyGccGimplePhi',\n                                       'PyGccGimple')\n        getsettable.add_simple_getter(cu,\n                                      'lhs',\n                                      'PyGccTree_New(gcc_gimple_phi_get_result(PyGccGimple_as_gcc_gimple_phi(self)))',\n                                      None)\n        getsettable.add_gsdef('args',\n                              'PyGccGimplePhi_get_args',\n                              None,\n                              'Get a list of (gcc.Tree, gcc.Edge) pairs representing the possible (expr, edge) inputs') # FIXME: should we instead have a dict here?\n        return getsettable\n\n    def make_getset_Switch():\n        getsettable = PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                       [exprcode_getter],\n                                       'PyGccGimpleSwitch',\n                                       'PyGccGimple')\n        getsettable.add_simple_getter(cu,\n                                      'indexvar',\n                                      'PyGccTree_New(gcc_gimple_switch_get_indexvar(PyGccGimple_as_gcc_gimple_switch(self)))',\n                                      'Get the index variable used by the switch statement, as a gcc.Tree')\n        getsettable.add_gsdef('labels',\n                              'PyGccGimpleSwitch_get_labels',\n                              None,\n                              'Get a list of labels, as a list of gcc.CaseLabelExpr   The initial label in the list is always the default.')\n        return getsettable\n\n    def make_getset_Label():\n        getsettable = PyGetSetDefTable('gcc_%s_getset_table' % cc,\n                                       [exprcode_getter],\n                                       'PyGccGimpleLabel',\n                                       'PyGccGimple')\n        getsettable.add_simple_getter(cu,\n                                      'label',\n                                      'PyGccTree_New(gcc_label_decl_as_gcc_tree(gcc_gimple_label_get_label(PyGccGimple_as_gcc_gimple_label(self))))',\n                                      'Get the underlying gcc.LabelDecl for this statement')\n        return getsettable\n\n    for gt in gimple_types:\n        cc = gt.camel_cased_string()\n\n        tp_repr = None\n        getsettable = None\n        if cc == 'GimpleAsm':\n            getsettable = make_getset_Asm()\n        elif cc == 'GimpleAssign':\n            getsettable = make_getset_Assign()\n        elif cc == 'GimpleCall':\n            getsettable = make_getset_Call()\n        elif cc == 'GimpleCond':\n            getsettable = make_getset_Cond()\n        elif cc == 'GimpleReturn':\n            getsettable = make_getset_Return()\n        elif cc == 'GimplePhi':\n            getsettable = make_getset_Phi()\n        elif cc == 'GimpleSwitch':\n            getsettable = make_getset_Switch()\n        elif cc == 'GimpleLabel':\n            getsettable = make_getset_Label()\n            tp_repr = '(reprfunc)PyGccGimpleLabel_repr'\n\n        if getsettable:\n            cu.add_defn(getsettable.c_defn())\n\n            \n        pytype = PyGccWrapperTypeObject(identifier = 'PyGcc%s_TypeObj' % cc,\n                              localname = cc,\n                              tp_name = 'gcc.%s' % cc,\n                              tp_dealloc = 'PyGccWrapper_Dealloc',\n                              struct_name = 'PyGccGimple',\n                              tp_new = 'PyType_GenericNew',\n                              tp_base = '&PyGccGimple_TypeObj',\n                              tp_getset = getsettable.identifier if getsettable else None,\n                              tp_repr = tp_repr,\n                              #tp_str = '(reprfunc)PyGccGimple_str',\n                              )\n        cu.add_defn(pytype.c_defn())\n        modinit_preinit += pytype.c_invoke_type_ready()\n        modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_gimple_subclasses()\n\ndef generate_gimple_code_map():\n    cu.add_defn('\\n/* Map from GCC gimple codes to PyTypeObject* */\\n')\n    cu.add_defn('PyGccWrapperTypeObject *pytype_for_gimple_code[] = {\\n')\n    for gt in gimple_types:\n        cc = gt.camel_cased_string()\n        cu.add_defn('    &PyGcc%s_TypeObj, /* %s */\\n' % (cc, gt.gimple_symbol))\n    cu.add_defn('};\\n\\n')\n\n    cu.add_defn(\"\"\"\nPyGccWrapperTypeObject*\nPyGcc_autogenerated_gimple_type_for_stmt(gcc_gimple stmt)\n{\n    enum gimple_code code = gimple_code(stmt.inner);\n\n    /* printf(\"code:%i\\\\n\", code); */\n    assert(code >= 0);\n    assert(code < LAST_AND_UNUSED_GIMPLE_CODE);\n    return pytype_for_gimple_code[code];\n}\n\"\"\")\n\ngenerate_gimple_code_map()\n\n\ncu.add_defn(\"\"\"\nint autogenerated_gimple_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_gimple_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\nprint(cu.as_str())\n\n"
  },
  {
    "path": "generate-location-c.py",
    "content": "#   Copyright 2011-2014, 2017 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011-2014, 2017 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom testcpychecker import get_gcc_version\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"gcc-c-api/gcc-location.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_location():\n    #\n    # Generate the gcc.Location class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccLocation_get_file(struct PyGccLocation *self, void *closure)\n{\n    const char *filename = gcc_location_get_filename(self->loc);\n    if (!filename) {\n      Py_RETURN_NONE;\n    }\n    return PyGccString_FromString(filename);\n}\n\"\"\")\n\n    cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccLocation_get_line(struct PyGccLocation *self, void *closure)\n{\n    return PyGccInt_FromLong(gcc_location_get_line(self->loc));\n}\n\"\"\")\n\n    cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccLocation_get_column(struct PyGccLocation *self, void *closure)\n{\n    return PyGccInt_FromLong(gcc_location_get_column(self->loc));\n}\n\"\"\")\n    if get_gcc_version() >= 7000:\n        cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccLocation_get_caret(struct PyGccLocation *self, void *closure)\n{\n    return PyGccLocation_New(gcc_location_get_caret(self->loc));\n}\n\"\"\")\n        cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccLocation_get_start(struct PyGccLocation *self, void *closure)\n{\n    return PyGccLocation_New(gcc_location_get_start(self->loc));\n}\n\"\"\")\n        cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccLocation_get_finish(struct PyGccLocation *self, void *closure)\n{\n    return PyGccLocation_New(gcc_location_get_finish(self->loc));\n}\n\"\"\")\n\n    getsettable = PyGetSetDefTable('PyGccLocation_getset_table',\n                                   [PyGetSetDef('file', 'PyGccLocation_get_file', None, 'Name of the source file'),\n                                    PyGetSetDef('line', 'PyGccLocation_get_line', None, 'Line number within source file'),\n                                    PyGetSetDef('column', 'PyGccLocation_get_column', None, 'Column number within source file'),\n                                    ],\n                                   identifier_prefix='PyGccLocation',\n                                   typename='PyGccLocation')\n    if get_gcc_version() >= 7000:\n        getsettable.gsdefs += [PyGetSetDef('caret', 'PyGccLocation_get_caret', None, 'Location of caret'),\n                               PyGetSetDef('start', 'PyGccLocation_get_start', None, 'Starting location of range'),\n                               PyGetSetDef('finish', 'PyGccLocation_get_finish', None, 'End location of range')]\n    getsettable.add_simple_getter(cu,\n                                  'in_system_header',\n                                  'PyBool_FromLong(gcc_location_get_in_system_header(self->loc))',\n                                  'Boolean: is this location within a system header?')\n    cu.add_defn(getsettable.c_defn())\n\n    methods = PyMethodTable('PyGccLocation_methods', [])\n    if get_gcc_version() >= 5000:\n        methods.add_method('offset_column',\n                           '(PyCFunction)PyGccLocation_offset_column',\n                           'METH_VARARGS',\n                           \"\")\n    cu.add_defn(methods.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccLocation_TypeObj',\n                          localname = 'Location',\n                          tp_name = 'gcc.Location',\n                          struct_name = 'PyGccLocation',\n                          tp_new = 'PyType_GenericNew',\n                          tp_init = '(initproc)PyGccLocation_init' if get_gcc_version() >= 7000 else None,\n                          tp_getset = getsettable.identifier,\n                          tp_hash = '(hashfunc)PyGccLocation_hash',\n                          tp_repr = '(reprfunc)PyGccLocation_repr',\n                          tp_str = '(reprfunc)PyGccLocation_str',\n                          tp_methods = methods.identifier,\n                          tp_richcompare = 'PyGccLocation_richcompare',\n                          tp_dealloc = 'PyGccWrapper_Dealloc')\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ndef generate_rich_location():\n    #\n    # Generate the gcc.RichLocation class:\n    #\n\n    # class rich_location was added to libcpp in gcc 6.\n    GCC_VERSION = get_gcc_version()\n    if GCC_VERSION < 6000:\n        return\n\n    global modinit_preinit\n    global modinit_postinit\n\n    methods = PyMethodTable('PyGccRichLocation_methods', [])\n    methods.add_method('add_fixit_replace',\n                       '(PyCFunction)PyGccRichLocation_add_fixit_replace',\n                       'METH_VARARGS | METH_KEYWORDS',\n                       \"FIXME\")\n    cu.add_defn(methods.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccRichLocation_TypeObj',\n                          localname = 'RichLocation',\n                          tp_name = 'gcc.RichLocation',\n                          struct_name = 'PyGccRichLocation',\n                          tp_new = 'PyType_GenericNew',\n                          tp_init = '(initproc)PyGccRichLocation_init',\n                          #tp_getset = getsettable.identifier,\n                          #tp_hash = '(hashfunc)PyGccRichLocation_hash',\n                          #tp_repr = '(reprfunc)PyGccRichLocation_repr',\n                          #tp_str = '(reprfunc)PyGccRichLocation_str',\n                          tp_methods = methods.identifier,\n                          #tp_richcompare = 'PyGccRichLocation_richcompare',\n                          tp_dealloc = 'PyGccWrapper_Dealloc')\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_location()\ngenerate_rich_location()\n\ncu.add_defn(\"\"\"\nint autogenerated_location_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_location_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-option-c.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"diagnostic.h\")\n\n# FIXME: need to participate in the GC, to ensure ownership of the underlying\n# diag object\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_option():\n    #\n    # Generate the gcc.Option class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccOption_getset_table', [],\n                                   identifier_prefix='PyGccOption',\n                                   typename='PyGccOption')\n    def add_simple_getter(name, c_expression, doc):\n        getsettable.add_simple_getter(cu, name, c_expression, doc)\n\n    add_simple_getter('text',\n      'PyGccStringOrNone(PyGcc_option_to_cl_option(self)->opt_text)',\n      '(string) The command-line text used to set this option')\n    add_simple_getter('help',\n      'PyGccStringOrNone(PyGcc_option_to_cl_option(self)->help)',\n      '(string) The help text shown for this option')\n\n    for flag, helptext in (\n        ('CL_WARNING', '(bool) Does this option control a warning message?'),\n        ('CL_OPTIMIZATION', '(bool) Does this option control an optimization?'),\n        ('CL_DRIVER', '(bool) Is this a driver option?'),\n        ('CL_TARGET', '(bool) Is this a target-specific option?'),\n      ):\n        add_simple_getter('is_%s' % flag[3:].lower(),\n                          'PyBool_FromLong(PyGcc_option_to_cl_option(self)->flags & %s)' % flag,\n                          helptext)\n\n    getsettable.add_gsdef('is_enabled',\n                          'PyGccOption_is_enabled',\n                          None,\n                          'True/False for whether or not this option is enabled, raising a '\n                          'NotImplementedError for options for which the plugin cannot tell')\n\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccOption_TypeObj',\n                          localname = 'Option',\n                          tp_name = 'gcc.Option',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccOption',\n                          tp_init = 'PyGccOption_init',\n                          tp_getset = getsettable.identifier,\n                          tp_repr = '(reprfunc)PyGccOption_repr',\n                          #tp_str = '(reprfunc)PyGccOption_str',\n                          #tp_richcompare = 'PyGccOption_richcompare'\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_option()\n\ncu.add_defn(\"\"\"\nint autogenerated_option_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_option_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-parameter-c.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\nimport os, subprocess, sys\n\nif not os.path.exists(\"./print-gcc-version\"):\n    sys.stderr.write(\"Build make target 'print-gcc-version' before running this script.\")\n    sys.exit(1)\n\ngcc_version = int(subprocess.check_output(\"./print-gcc-version\"))\n\nif gcc_version >= 10000:\n    print(\"/* GCC10 has removed params.h; no need for this wrapper. */\")\n    sys.exit(0)\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"params.h\")\n\ncu._prototypes += '''\n#define PARAM_INFO(self) (compiler_params[(self)->param_num])\n'''\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\n# GCC's params.h defines\n#   typedef struct param_info param_info\n# and they're listed in params.def\n\ndef generate_param():\n    #\n    # Generate the gcc.Parameter class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccParameter_getset_table', [],\n                                   identifier_prefix='PyGccParameter',\n                                   typename='PyGccParameter')\n    def add_simple_getter(name, c_expression, doc):\n        getsettable.add_simple_getter(cu, name, c_expression, doc)\n    add_simple_getter('option',\n                      'PyGccStringOrNone(PARAM_INFO(self).option)',\n                      \"(string) The name used with the `--param <name>=<value>' switch to set this value\")\n    add_simple_getter('default_value',\n                      'PyGccInt_FromLong(PARAM_INFO(self).default_value)',\n                      \"(int/long)\")\n    add_simple_getter('min_value',\n                      'PyGccInt_FromLong(PARAM_INFO(self).min_value)',\n                      \"(int/long) The minimum acceptable value\")\n    add_simple_getter('max_value',\n                      'PyGccInt_FromLong(PARAM_INFO(self).max_value)',\n                      \"(int/long) The maximum acceptable value, if greater than min_value\")\n    add_simple_getter('help',\n                      'PyGccStringOrNone(PARAM_INFO(self).help)',\n                      \"(string) A short description of the option.\")\n\n    # \"current_value\":\n    getter = cu.add_simple_getter('PyGccParameter_get_current_value',\n                                  'PyGccParameter',\n                                  'PyGccInt_FromLong(PARAM_VALUE(self->param_num))')\n    setter = cu.add_simple_int_setter('PyGccParameter_set_current_value',\n                                      'PyGccParameter',\n                                      'current_value',\n                                      'global_options.x_param_values[self->param_num] = PyGccInt_AsLong(value)') #FIXME\n    getsettable.add_gsdef('current_value',\n                          getter, setter,\n                          \"(int/long)\")\n\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccParameter_TypeObj',\n                          localname = 'Parameter',\n                          tp_name = 'gcc.Parameter',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccParameter',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = getsettable.identifier,\n                          #tp_repr = '(reprfunc)PyGccParameter_repr',\n                          #tp_str = '(reprfunc)PyGccParameter_str',\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_param()\n\ncu.add_defn(\"\"\"\nint autogenerated_parameter_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_parameter_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\nprint(cu.as_str())\n\n"
  },
  {
    "path": "generate-pass-c.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"tree-pass.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\n# See GCC's tree-pass.h\n\ndef generate_pass():\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccPass_getset_table', [],\n                                   identifier_prefix='PyGccPass',\n                                   typename='PyGccPass')\n    getsettable.add_simple_getter(cu,\n                                  'name',\n                                  'PyGccString_FromString(self->pass->name)',\n                                  'Name of the pass')\n    getsettable.add_simple_getter(cu,\n                                  'next',\n                                  'PyGccPass_New(self->pass->next)',\n                                  'The next gcc.Pass after this one, or None')\n    getsettable.add_simple_getter(cu,\n                                  'sub',\n                                  'PyGccPass_New(self->pass->sub)',\n                                  \"The first sub-pass (gated by this pass' predicate, if any)\")\n\n    for field in ('properties_required', 'properties_provided', 'properties_destroyed'):\n        getsettable.add_simple_getter(cu,\n                                      field,\n                                      'PyGccInt_FromLong(self->pass->%s)' % field,\n                                      None)\n    getsettable.add_simple_getter(cu,\n                                  'static_pass_number',\n                                  'PyGccInt_FromLong(self->pass->static_pass_number)',\n                                  'Number of this pass, used as a fragment of the dump file name')\n    getsettable.add_gsdef('dump_enabled',\n                          'PyGccPass_get_dump_enabled',\n                          'PyGccPass_set_dump_enabled',\n                          '(boolean) Is dumping enabled for this pass?')\n    cu.add_defn(getsettable.c_defn())\n\n    methods = PyMethodTable('PyGccPass_methods', [])\n    methods.add_method('get_roots',\n                       'PyGccPass_get_roots',\n                       'METH_CLASS | METH_VARARGS',\n                       \"Get a tuple of gcc.Pass instances, the roots of the compilation pass tree\")\n    methods.add_method('get_by_name',\n                       '(PyCFunction)PyGccPass_get_by_name',\n                       'METH_CLASS | METH_VARARGS | METH_KEYWORDS',\n                       \"Get the gcc.Pass instance for the pass with the given name, raising ValueError if it isn't found\")\n    methods.add_method('register_after',\n                       '(PyCFunction)PyGccPass_register_after',\n                       'METH_VARARGS | METH_KEYWORDS',\n                       \"Given the name of another pass, register this gcc.Pass to occur immediately after that other pass\")\n    methods.add_method('register_before',\n                       '(PyCFunction)PyGccPass_register_before',\n                       'METH_VARARGS | METH_KEYWORDS',\n                       \"Given the name of another pass, register this gcc.Pass to occur immediately before that other pass\")\n    methods.add_method('replace',\n                       '(PyCFunction)PyGccPass_replace',\n                       'METH_VARARGS | METH_KEYWORDS',\n                       \"Given the name of another pass, replace that pass with this gcc.Pass\")\n\n    cu.add_defn(methods.c_defn())\n    \n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccPass_TypeObj',\n                          localname = 'Pass',\n                          tp_name = 'gcc.Pass',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccPass',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = getsettable.identifier,\n                          tp_repr = '(reprfunc)PyGccPass_repr',\n                          tp_str = '(reprfunc)PyGccPass_repr',\n                          tp_methods = methods.identifier,\n                          tp_flags = '(Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE)',\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_pass()\n\ndef generate_pass_subclasses():\n    global modinit_preinit\n    global modinit_postinit\n\n    for opt_pass_type in ('GIMPLE_PASS', 'RTL_PASS',\n                          'SIMPLE_IPA_PASS', 'IPA_PASS'):\n        cc = camel_case(opt_pass_type)\n        pytype = PyGccWrapperTypeObject(identifier = 'PyGcc%s_TypeObj' % cc,\n                              localname = cc,\n                              tp_name = 'gcc.%s' % cc,\n                              tp_dealloc = 'PyGccWrapper_Dealloc',\n                              struct_name = 'PyGccPass',\n                              tp_new = 'PyType_GenericNew',\n                              tp_init = 'PyGcc%s_init' % cc,\n                              tp_base = '&PyGccPass_TypeObj',\n                              tp_flags = '(Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE)'\n                              )\n        cu.add_defn(pytype.c_defn())\n        modinit_preinit += pytype.c_invoke_type_ready()\n        modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_pass_subclasses()\n\ncu.add_defn(\"\"\"\nint autogenerated_pass_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_pass_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-passes-svg.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nimport math\n\nHEADING_HEIGHT = 20\nTREE_X_INDENT = 24\nPASS_HEIGHT = 12\nPASS_LEADING = 4\nPHASE_SPACING = 50\n\npropdata = [\n    ('PROP_gimple_any', (1, 0, 0)),\n    ('PROP_gimple_lcf', (0, 1, 0)),\n    ('PROP_gimple_leh', (0, 0, 1)),\n    ('PROP_cfg', (0, 1, 1)),\n    ('PROP_referenced_vars', (1, 1, 0)),\n    ('PROP_ssa', (0.5, 0.5, 1)),\n    ('PROP_no_crit_edges', (0, 0, 0)),\n    ('PROP_rtl', (0.5, 0.5, 0.5)),\n    ('PROP_gimple_lomp', (0.75, 1, 0)),\n    ('PROP_cfglayout', (0, 1, 0.75)),\n    ('PROP_gimple_lcx', (0.25, 0.25, 0.25)),\n]\n\n# PROP_referenced_vars went away in GCC 4.8 (in r190067)\nif not hasattr(gcc, 'PROP_referenced_vars'):\n    propdata = [(flag, color) for (flag, color) in propdata\n                if flag != 'PROP_referenced_vars']\n\ndef show_text_x_centered(ctx, text, x, y):\n    ctx.set_source_rgb(0, 0, 0)\n    te = ctx.text_extents(text)\n    ctx.move_to(x - te[2]/2, y)\n    ctx.show_text(text)\n\ndef show_text_y_centered(ctx, text, x, y):\n    ctx.set_source_rgb(0, 0, 0)\n    te = ctx.text_extents(text)\n    ctx.move_to(x, y + te[3]/2)\n    ctx.show_text(text)\n\nclass Property:\n    def __init__(self, flagname, color, x):\n        assert flagname.startswith('PROP_')\n        self.name = flagname[5:]\n        self.color = color\n        self.flag = getattr(gcc, flagname)\n        self.provided_by = None\n        self.destroyed_by = None\n        self.x = x\n\n    def render(self, ctx):\n        # Draw a line showing the lifetime of the property:\n        if self.provided_by:\n            start_y = self.provided_by.y\n        else:\n            start_y = 0\n\n        if self.destroyed_by:\n            end_y = self.destroyed_by.y\n        else:\n            end_y = 4000\n\n        ctx.set_source_rgb(*self.color)\n        ctx.move_to(self.x, start_y)\n        ctx.line_to(self.x, end_y)\n        ctx.stroke()\n\n        # Draw termini:\n        if self.provided_by:\n            # ctx.arc(self.x, self.provided_by.y, 10, 0, 2 * math.pi)\n            ctx.set_source_rgb(*self.color)\n            ctx.move_to(self.x - 5, start_y)\n            ctx.line_to(self.x + 5, start_y)\n            ctx.stroke()\n            show_text_x_centered(ctx, self.name, self.x, start_y - 5)\n        else:\n            show_text_x_centered(ctx, self.name, self.x, PASS_HEIGHT)\n\n        if self.destroyed_by:\n            # ctx.arc(self.x, self.destroyed_by.y, 10, 0, 2 * math.pi)\n            ctx.set_source_rgb(*self.color)\n            ctx.move_to(self.x - 5, end_y)\n            ctx.line_to(self.x + 5, end_y)\n            ctx.stroke()\n\nproperties = [Property(propname, col, 250 + (i*20))\n              for i, (propname, col) in enumerate(propdata)]\n\nclass PassInfo:\n    def __init__(self, d, ps, parent):\n        self.d = d\n        self.ps = ps\n\n        for prop in properties:\n            if self.ps.properties_provided & prop.flag:\n                prop.provided_by = self\n\n            if self.ps.properties_destroyed & prop.flag:\n                prop.destroyed_by = self\n\n    def render(self, ctx):\n        show_text_y_centered(ctx, self.ps.name, self.x, self.y)\n\n        for i, prop in enumerate(properties):\n            if self.ps.properties_required & prop.flag:\n                ctx.set_source_rgb(*prop.color)\n                ctx.move_to(prop.x, self.y)\n                ctx.line_to(prop.x - 5, self.y)\n                ctx.stroke()\n\n\n\nclass Phase:\n    def __init__(self, rootname, base_y):\n        self.passinfo = {} # gcc.Pass ->PassInfo\n        self.rootname = rootname\n        self.base_y = base_y\n        self.height = base_y + HEADING_HEIGHT + PASS_LEADING\n\n    def add_pass(self, ps, parent):\n        # print ps.name\n        pi = PassInfo(self, ps, parent)\n        if parent:\n            ppi = self.passinfo[parent]\n            pi.x = ppi.x + TREE_X_INDENT\n        else:\n            pi.x = 0\n        pi.y = self.height\n        if self.passinfo == {}:\n            self.height += PASS_LEADING + PASS_HEIGHT\n        else:\n            self.height += PASS_HEIGHT\n        self.passinfo[ps] = pi\n\n        if ps.sub:\n            self.add_pass(ps.sub, ps)\n        if ps.next:\n            self.add_pass(ps.next, parent)\n\n    def render(self, ctx):\n        ctx.move_to(0, self.base_y)\n        ctx.set_source_rgb(0, 0, 0)\n        ctx.set_font_size(HEADING_HEIGHT)\n        ctx.show_text(self.rootname)\n\n        ctx.set_font_size(PASS_HEIGHT)\n        for k in self.passinfo:\n            pi = self.passinfo[k]\n            pi.render(ctx)\n\nphases = {}\nbase_y = HEADING_HEIGHT\nfor i, (rootname, reflabel, ps) in enumerate(\n    zip(('The lowering passes',\n         'The \"small IPA\" passes',\n         'The \"regular IPA\" passes',\n         'Passes generating Link-Time Optimization data',\n         'The \"all other passes\" catch-all'),\n        ('all_lowering_passes',\n         'all_small_ipa_passes',\n         'all_regular_ipa_passes',\n         'all_lto_gen_passes',\n         'all_passes'),\n        gcc.Pass.get_roots())):\n    # print rootname, reflabel, ps\n    phases[i] = Phase(rootname, base_y)\n    phases[i].add_pass(ps, None)\n    base_y = phases[i].height + PHASE_SPACING\n\nimport cairo\nsurf = cairo.SVGSurface('docs/passes.svg', 550, base_y)\nctx = cairo.Context(surf)\n\n# Fill with white:\nctx.set_source_rgb(1, 1, 1)\nctx.paint()\n\nfor prop in properties:\n    prop.render(ctx)\n\nfor i in range(5):\n    phases[i].render(ctx)\n\nsurf.finish()\n"
  },
  {
    "path": "generate-pretty-printer-c.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_pretty_printer():\n    global modinit_preinit\n    global modinit_postinit\n    \n    pytype = PyTypeObject(identifier = 'PyGccPrettyPrinter_TypeObj',\n                          localname = 'PrettyPrinter',\n                          tp_name = 'gcc.PrettyPrinter',\n                          struct_name = 'struct PyGccPrettyPrinter',\n                          tp_new = 'PyType_GenericNew',\n                          tp_dealloc = 'PyGccPrettyPrinter_dealloc',\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n    \ngenerate_pretty_printer()\n\ncu.add_defn(\"\"\"\nint autogenerated_pretty_printer_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_pretty_printer_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-rtl-c.py",
    "content": "#   Copyright 2011-2012, 2015 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011-2012, 2015 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom maketreetypes import iter_rtl_expr_types #, iter_rtl_struct_types\n\nfrom cpybuilder import *\nfrom testcpychecker import get_gcc_version\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\nGCC_VERSION = get_gcc_version()\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"rtl.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\n#rtl_struct_types = list(iter_rtl_struct_types())\nrtl_expr_types = list(iter_rtl_expr_types())\n#print rtl_types\n\n# Should be a three-level hierarchy:\n#\n# - Rtl base class\n#   - intermediate subclasses, one per enum rtx_class\n#     - concrete subclasses, one per enum rtx_code\n\ndef generate_rtl_base_class():\n    #\n    # Generate the gcc.Rtl class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n    '''\n    cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccRtl_get_block(struct PyGccRtl *self, void *closure)\n{\n    return PyGccTree_New(rtl_block(self->stmt));\n}\n\"\"\")\n    '''\n    getsettable = PyGetSetDefTable('PyGccRtl_getset_table', [])\n    if GCC_VERSION < 5000:\n        getsettable.add_gsdef('loc',\n                              'PyGccRtl_get_location',\n                              None,\n                              'Source code location of this instruction, as a gcc.Location')\n    getsettable.add_gsdef('operands',\n                          'PyGccRtl_get_operands',\n                          None,\n                          'Operands of this expression, as a tuple')\n    cu.add_defn(getsettable.c_defn())\n\n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccRtl_TypeObj',\n                          localname = 'Rtl',\n                          tp_name = 'gcc.Rtl',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccRtl',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = getsettable.identifier,\n                          tp_repr = '(reprfunc)PyGccRtl_repr',\n                          tp_str = '(reprfunc)PyGccRtl_str',\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_rtl_base_class()\n\n# enum rtx_class from gcc/rtl.h (as seen in 4.6.0):\nenum_rtx_class = ('RTX_COMPARE',\n                  'RTX_COMM_COMPARE',\n                  'RTX_BIN_ARITH',\n                  'RTX_COMM_ARITH',\n                  'RTX_UNARY',\n                  'RTX_EXTRA',\n                  'RTX_MATCH',\n                  'RTX_INSN',\n                  'RTX_OBJ',\n                  'RTX_CONST_OBJ',\n                  'RTX_TERNARY',\n                  'RTX_BITFIELD_OPS',\n                  'RTX_AUTOINC')\n\ndef generate_intermediate_rtx_class_subclasses():\n    global modinit_preinit\n    global modinit_postinit\n\n    for rtx_class in enum_rtx_class:\n        cc = camel_case(rtx_class)\n        pytype = PyGccWrapperTypeObject(identifier = 'PyGccRtlClassType%s_TypeObj' % cc,\n                              localname = 'RtlClassType' + cc,\n                              tp_name = 'gcc.%s' % cc,\n                              struct_name = 'PyGccRtl',\n                              tp_new = 'PyType_GenericNew',\n                              tp_base = '&PyGccRtl_TypeObj',\n                              #tp_getset = getsettable.identifier,\n                              #tp_repr = '(reprfunc)PyGccRtl_repr',\n                              #tp_str = '(reprfunc)PyGccRtl_str',\n                              )\n        cu.add_defn(pytype.c_defn())\n        modinit_preinit += pytype.c_invoke_type_ready()\n        modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_intermediate_rtx_class_subclasses()\n\n\ndef generate_concrete_rtx_code_subclasses():\n    global modinit_preinit\n    global modinit_postinit\n\n    for expr_type in rtl_expr_types:\n\n        cc = expr_type.camel_cased_string()\n\n        getsettable = None\n        if getsettable:\n            cu.add_defn(getsettable.c_defn())\n\n        pytype = PyGccWrapperTypeObject(identifier = 'PyGcc%s_TypeObj' % cc,\n                              localname = cc,\n                              tp_name = 'gcc.%s' % cc,\n                              struct_name = 'PyGccRtl',\n                              tp_new = 'PyType_GenericNew',\n                              tp_base = ('&PyGccRtlClassType%s_TypeObj'\n                                         % camel_case(expr_type.CLASS)),\n                              tp_getset = getsettable.identifier if getsettable else None,\n                              tp_repr = '(reprfunc)PyGccRtl_repr',\n                              tp_str = '(reprfunc)PyGccRtl_str',\n                              )\n        cu.add_defn(pytype.c_defn())\n        modinit_preinit += pytype.c_invoke_type_ready()\n        modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_concrete_rtx_code_subclasses()\n\ndef generate_rtl_code_map():\n    cu.add_defn('\\n/* Map from GCC rtl codes to PyGccWrapperTypeObject* */\\n')\n    cu.add_defn('PyGccWrapperTypeObject *pytype_for_rtx_code[] = {\\n')\n    for expr_type in rtl_expr_types:\n        cc = expr_type.camel_cased_string()\n        cu.add_defn('    &PyGcc%s_TypeObj, /* %s */\\n' % (cc, expr_type.ENUM))\n    cu.add_defn('};\\n\\n')\n\n    cu.add_defn(\"\"\"\nPyGccWrapperTypeObject*\nPyGcc_autogenerated_rtl_type_for_stmt(gcc_rtl_insn insn)\n{\n    enum rtx_code code = insn.inner->code;\n\n    /* printf(\"code:%i\\\\n\", code); */\n    assert(code >= 0);\n    assert(code < LAST_AND_UNUSED_RTX_CODE);\n    return pytype_for_rtx_code[code];\n}\n\"\"\")\n\ngenerate_rtl_code_map()\n\ncu.add_defn(\"\"\"\nint autogenerated_rtl_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_rtl_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\nprint(cu.as_str())\n\n"
  },
  {
    "path": "generate-tables-of-passes-rst.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# We use this script to regenerate docs/tables-of-passes.rst\nimport gcc\nimport sys\nimport six\n\nfrom gccutils import Table\n\npass_prop_flags = ['PROP_gimple_any', 'PROP_gimple_lcf', 'PROP_gimple_leh',\n                   'PROP_cfg', 'PROP_referenced_vars', 'PROP_ssa',\n                   'PROP_no_crit_edges', 'PROP_rtl', 'PROP_gimple_lomp',\n                   'PROP_cfglayout', 'PROP_gimple_lcx']\n# PROP_referenced_vars went away in GCC 4.8 (in r190067)\nif not hasattr(gcc, 'PROP_referenced_vars'):\n    pass_prop_flags.remove('PROP_referenced_vars')\n\ndef pass_properties_to_str(bitfield):\n    result = []\n\n    for attrname in pass_prop_flags:\n        flag = getattr(gcc, attrname)\n        if bitfield & flag:\n            result.append(attrname[5:]) # drop the 'PROP_'\n    return ', '.join(result)\n\np_to_s = pass_properties_to_str\n\ndef foo(t, ps, indent):\n    name = ps.name.replace('*', '\\\\*')\n    t.add_row(('%s%s' % (six.u('> ') * indent, name),\n               p_to_s(ps.properties_required),\n               p_to_s(ps.properties_provided),\n               p_to_s(ps.properties_destroyed)))\n    if ps.sub:\n        foo(t, ps.sub, indent + 1)\n    if ps.next:\n        foo(t, ps.next, indent)\n\nprint('.. This file is autogenerated, using:')\nprint('   ./gcc-with-python generate-tables-of-passes-rst.py test.c')\nprint\nprint(\"All of GCC's passes\")\nprint(\"===================\")\nprint\nprint('''\nThis diagram shows the various GCC optimization passes, arranged vertically,\nshowing child passes via indentation.\n\nThe lifetime of the various properties that they maintain is shown, giving\nthe pass that initially creates the data (if any), the pass that destroys it\n(if any), and each pass that requires a particular property (based on the\nPROP_* flags).\n\n.. image:: passes.svg\n   :width: 550px\n   :height: 3302px\n   :scale: 50%\n''')\nprint(\"\"\"\nThese tables contain the same information.  The diagram and tables were\nautogenerated, using GCC %s\"\"\" % gcc.get_gcc_version().basever)\nprint\nfor rootname, reflabel, ps in zip(('The lowering passes',\n                                   'The \"small IPA\" passes',\n                                   'The \"regular IPA\" passes',\n                                   'Passes generating Link-Time Optimization data',\n                                   'The \"all other passes\" catch-all'),\n                                  ('all_lowering_passes',\n                                   'all_small_ipa_passes',\n                                   'all_regular_ipa_passes',\n                                   'all_lto_gen_passes',\n                                   'all_passes'),\n                                  gcc.Pass.get_roots()):\n    print('.. _%s:' % reflabel)\n    print\n    print(rootname)\n    print('-' * len(rootname))\n    print\n\n    t = Table(['Pass Name', 'Required properties', 'Provided properties', 'Destroyed properties'],\n              sepchar='=')\n    foo(t, ps, 0)\n    s = six.StringIO()\n    t.write(s)\n    for line in s.getvalue().splitlines():\n        print('   ' + line.rstrip())\n    print('\\n')\n"
  },
  {
    "path": "generate-tree-c.py",
    "content": "#   Copyright 2011-2013, 2015 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011-2013, 2015 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom maketreetypes import iter_tree_types\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\nfrom testcpychecker import get_gcc_version\n\ntree_types = list(iter_tree_types())\n# FIXME: truncate the list, for ease of development:\n#tree_types = list(iter_tree_types())[:3]\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"tree.h\")\ncu.add_include(\"function.h\")\ncu.add_include(\"basic-block.h\")\ncu.add_include(\"cp/cp-tree.h\")\ncu.add_include(\"c-family/c-common.h\")\ncu.add_include(\"gcc-c-api/gcc-tree.h\")\ncu.add_include(\"gcc-c-api/gcc-constant.h\")\ncu.add_include(\"gcc-c-api/gcc-declaration.h\")\ncu.add_include(\"gcc-c-api/gcc-type.h\")\ncu.add_include(\"cp/name-lookup.h\")\ncu.add_include(\"autogenerated-casts.h\")\n\nGCC_VERSION = get_gcc_version()\nif GCC_VERSION >= 4009:\n    # GCC 4.9 moved debug_tree here:\n    cu.add_include(\"print-tree.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_tree():\n    #\n    # Generate the gcc.Tree class:\n    #\n    global modinit_preinit\n    global modinit_postinit\n    \n    cu.add_defn(\"\"\"\nstatic PyObject *\nPyGccTree_get_type(struct PyGccTree *self, void *closure)\n{\n    return PyGccTree_New(gcc_private_make_tree(TREE_TYPE(self->t.inner)));\n}\n\nstatic PyObject *\nPyGccTree_get_addr(struct PyGccTree *self, void *closure)\n{\n    return PyLong_FromVoidPtr(self->t.inner);\n}\n\n\"\"\")\n\n    getsettable = PyGetSetDefTable('PyGccTree_getset_table',\n                                   [PyGetSetDef('type', 'PyGccTree_get_type', None,\n                                                'Instance of gcc.Tree giving the type of the node'),\n                                    PyGetSetDef('addr', 'PyGccTree_get_addr', None,\n                                                'The address of the underlying GCC object in memory'),\n                                    PyGetSetDef('str_no_uid', 'PyGccTree_get_str_no_uid', None,\n                                                'A string representation of this object, like str(), but without including any internal UID')],\n                                   identifier_prefix='PyGccTree',\n                                   typename='PyGccTree')\n\n    cu.add_defn(getsettable.c_defn())\n    \n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccTree_TypeObj',\n                          localname = 'Tree',\n                          tp_name = 'gcc.Tree',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccTree',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = 'PyGccTree_getset_table',\n                          tp_hash = '(hashfunc)PyGccTree_hash',\n                          tp_str = '(reprfunc)PyGccTree_str',\n                          tp_richcompare = 'PyGccTree_richcompare')\n    methods = PyMethodTable('PyGccTree_methods', [])\n    methods.add_method('debug',\n                       'PyGccTree_debug',\n                       'METH_VARARGS',\n                       \"Dump the tree to stderr\")\n    cu.add_defn(\"\"\"\nPyObject*\nPyGccTree_debug(PyObject *self, PyObject *args)\n{\n    PyGccTree *tree_obj;\n    /* FIXME: type checking */\n    tree_obj = (PyGccTree *)self;\n    debug_tree(tree_obj->t.inner);\n    Py_RETURN_NONE;\n}\n\"\"\")\n    cu.add_defn(methods.c_defn())\n    pytype.tp_methods = methods.identifier\n\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n    \ngenerate_tree()\n\ntype_for_code_class = {\n    'tcc_exceptional' : 'PyGccTree_TypeObj',\n    'tcc_constant' : 'PyGccConstant_TypeObj',\n    'tcc_type' : 'PyGccType_TypeObj',\n    'tcc_declaration' : 'PyGccDeclaration_TypeObj',\n    'tcc_reference' : 'PyGccReference_TypeObj',\n    'tcc_comparison' : 'PyGccComparison_TypeObj',\n    'tcc_unary' : 'PyGccUnary_TypeObj',\n    'tcc_binary' : 'PyGccBinary_TypeObj',\n    'tcc_statement' : 'PyGccStatement_TypeObj',\n    'tcc_vl_exp' : 'PyGccVlExp_TypeObj',\n    'tcc_expression' : 'PyGccExpression_TypeObj',\n}\n\ndef generate_intermediate_tree_classes():\n    # Generate a \"middle layer\" of gcc.Tree subclasses, corresponding to most of the\n    # values of\n    #    enum_tree_code_class\n    # from GCC's tree.h\n    global modinit_preinit\n    global modinit_postinit\n\n    \n    for code_type in type_for_code_class.values():\n        # We've already built the base class:\n        if code_type == 'PyGccTree_TypeObj':\n            continue\n\n        # Strip off the \"PyGcc\" prefix and \"_TypeObj\" suffix:\n        localname = code_type[5:-8]\n\n        getsettable = PyGetSetDefTable('gcc_%s_getset_table' % localname, [])\n\n        methods = PyMethodTable('gcc_%s_methods' % localname, [])\n\n        pytype = PyGccWrapperTypeObject(identifier = code_type,\n                              localname = localname,\n                              tp_name = 'gcc.%s' % localname,\n                              struct_name = 'PyGccTree',\n                              tp_new = 'PyType_GenericNew',\n                              tp_base = '&PyGccTree_TypeObj',\n                              tp_getset = getsettable.identifier,\n                              tp_methods = methods.identifier)\n\n        def add_simple_getter(name, c_expression, doc):\n            getsettable.add_gsdef(name,\n                                  cu.add_simple_getter('PyGcc%s_get_%s' % (localname, name),\n                                                       'PyGccTree',\n                                                       c_expression),\n                                  None,\n                                  doc)\n\n        if localname == 'Declaration':\n            cu.add_defn(\"\"\"\nPyObject *\nPyGccDeclaration_get_name(struct PyGccTree *self, void *closure)\n{\n    if (DECL_NAME(self->t.inner)) {\n        return PyGccString_FromString(IDENTIFIER_POINTER (DECL_NAME (self->t.inner)));\n    }\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\nPyGccDeclaration_get_location(struct PyGccTree *self, void *closure)\n{\n    return PyGccLocation_New(gcc_decl_get_location(PyGccTree_as_gcc_decl(self)));\n}\n\"\"\")\n\n            getsettable.add_gsdef('name',\n                                  'PyGccDeclaration_get_name',\n                                  None,\n                                  'The name of this declaration (string)')\n            getsettable.add_gsdef('location',\n                                  'PyGccDeclaration_get_location',\n                                  None,\n                                  'The gcc.Location for this declaration')\n            add_simple_getter('is_artificial',\n                              'PyBool_FromLong(gcc_decl_is_artificial(PyGccTree_as_gcc_decl(self)))',\n                              \"Is this a compiler-generated entity?\")\n            add_simple_getter('is_builtin',\n                              'PyBool_FromLong(gcc_decl_is_builtin(PyGccTree_as_gcc_decl(self)))',\n                              \"Is this declaration built in by the compiler?\")\n            pytype.tp_repr = '(reprfunc)PyGccDeclaration_repr'\n\n        if localname == 'Type':\n            add_simple_getter('name',\n                              'PyGccTree_New(gcc_type_get_name(PyGccTree_as_gcc_type(self)))',\n                              \"The name of the type as a gcc.Tree, or None\")\n            add_simple_getter('pointer',\n                              'PyGccPointerType_New(gcc_type_get_pointer(PyGccTree_as_gcc_type(self)))',\n                              \"The gcc.PointerType representing '(this_type *)'\")\n            getsettable.add_gsdef('attributes',\n                                  'PyGccType_get_attributes',\n                                  None,\n                                  'The user-defined attributes on this type')\n            getsettable.add_gsdef('sizeof',\n                                  'PyGccType_get_sizeof',\n                                  None,\n                                  'sizeof() this type, as a gcc.IntegerCst')\n\n            def add_type(c_expr_for_node, typename):\n                # Expose the given global type node within the gcc.Tree API\n                #\n                # The table is populated by tree.c:build_common_builtin_nodes\n                # but unfortunately this seems to be called after our plugin is\n                # initialized.\n                #\n                # Hence we add them as properties, so that they can be looked up on\n                # demand, rather than trying to look them up once when the module\n                # is set up\n                cu.add_defn(\"\"\"\nPyObject*\n%s(PyObject *cls, PyObject *args)\n{\n    return PyGccTree_New(gcc_private_make_tree(%s));\n}\n\"\"\"                         % ('PyGccType_get_%s' % typename, c_expr_for_node))\n                if typename == 'size_t':\n                    desc = typename\n                else:\n                    desc = typename.replace('_', ' ')\n                methods.add_method('%s' % typename,\n                                   'PyGccType_get_%s' % typename,\n                                   'METH_CLASS|METH_NOARGS',\n                                   \"The builtin type '%s' as a gcc.Type (or None at startup before any compilation passes)\" % desc)\n\n            # Add the standard C integer types as properties.\n            #\n            # Tree nodes for the standard C integer types are defined in tree.h by\n            #    extern GTY(()) tree integer_types[itk_none];\n            # with macros to look into it of this form:\n            #       #define unsigned_type_node    integer_types[itk_unsigned_int]\n            #\n            std_types = ['itk_char', 'itk_signed_char', 'itk_unsigned_char',\n                         'itk_short', 'itk_unsigned_short',\n                         'itk_int', 'itk_unsigned_int',\n                         'itk_long', 'itk_unsigned_long',\n                         'itk_long_long', 'itk_unsigned_long_long']\n            if GCC_VERSION < 5000:\n                # int128 seems to have gone away in\n                # 9f75f0266e3611513f196c898088e2712a71eaf4, discussed at\n                # https://gcc.gnu.org/ml/gcc-patches/2014-08/msg01396.html\n                std_types += ['itk_int128', 'itk_unsigned_int128']\n            for std_type in std_types:\n                # strip off the \"itk_\" prefix\n                assert std_type.startswith('itk_')\n                stddef = std_type[4:]\n                #add_simple_getter(stddef,\n                #                  'PyGccTree_New(gcc_private_make_tree(integer_types[%s]))' % std_type,\n                #                  \"The builtin type '%s' as a gcc.Type (or None at startup before any compilation passes)\" % stddef.replace('_', ' '))\n                add_type('integer_types[%s]' % std_type, stddef)\n\n            # Similarly,\n            #   extern GTY(()) tree global_trees[TI_MAX];\n            # holds various nodes, including many with a _TYPE suffix.\n            # Here are some of them:\n            for ti in ('TI_UINT32_TYPE', 'TI_UINT64_TYPE',\n                       'TI_FLOAT_TYPE', 'TI_DOUBLE_TYPE',\n                       'TI_LONG_DOUBLE_TYPE', 'TI_VOID_TYPE', 'TI_SIZE_TYPE'):\n                # strip off the \"TI_\" prefix and \"_TYPE\" suffix:\n                assert ti.startswith('TI_')\n                assert ti.endswith('_TYPE')\n\n                if ti == 'TI_SIZE_TYPE':\n                    name = 'size_t'\n                else:\n                    name = ti[3:-5].lower()\n                add_type('global_trees[%s]' % ti, name)\n\n        if localname == 'Unary':\n            add_simple_getter('operand',\n                              'PyGccTree_New(gcc_unary_get_operand(PyGccTree_as_gcc_unary(self)))',\n                              'The operand of this expression, as a gcc.Tree')\n\n        # Corresponds to this gcc/tree.h macro:\n        #   #define IS_EXPR_CODE_CLASS(CLASS)\\\n        #       ((CLASS) >= tcc_reference && (CLASS) <= tcc_expression)\n        if localname in ('Reference', 'Comparison', 'Unary', 'Binary',\n                         'Statement' 'VlExp', 'Expression'):\n            add_simple_getter('location',\n                              ('PyGccLocation_New(gcc_%s_get_location(PyGccTree_as_gcc_%s(self)))'\n                               % (localname.lower(),\n                                  localname.lower())),\n                              \"The source location of this expression\")\n\n            methods.add_method('get_symbol',\n                               'PyGccTree_get_symbol', # they all share the implementation\n                               'METH_CLASS|METH_NOARGS',\n                               \"FIXME\")\n\n        cu.add_defn(methods.c_defn())\n        cu.add_defn(getsettable.c_defn())            \n        cu.add_defn(pytype.c_defn())\n        modinit_preinit += pytype.c_invoke_type_ready()\n        modinit_postinit += pytype.c_invoke_add_to_module()\n\ngenerate_intermediate_tree_classes()\n\n\ndef generate_tree_code_classes():\n    # Generate all of the concrete gcc.Tree subclasses based on the:\n    #    enum tree_code\n    # as subclasses of the above layer:\n    global modinit_preinit\n    global modinit_postinit\n    \n    for tree_type in tree_types:\n        base_type = type_for_code_class[tree_type.TYPE]\n\n        cc = tree_type.camel_cased_string()\n\n        getsettable =  PyGetSetDefTable('gcc_%s_getset_table' % cc, [],\n                                        identifier_prefix='gcc_%s' % cc,\n                                        typename='PyGccTree')\n\n        tp_as_number = None\n        tp_repr = None\n        tp_str = None\n\n        methods = PyMethodTable('gcc_%s_methods' % cc, [])\n\n        def get_getter_identifier(name):\n            return 'PyGcc%s_get_%s' % (cc, name)\n\n        def add_simple_getter(name, c_expression, doc):\n            getsettable.add_gsdef(name,\n                                  cu.add_simple_getter(get_getter_identifier(name),\n                                                       'PyGccTree',\n                                                       c_expression),\n                                  None,\n                                  doc)\n\n        def add_complex_getter(name, doc):\n            getsettable.add_gsdef(name,\n                                  get_getter_identifier(name),\n                                  None,\n                                  doc)\n\n        if cc == 'AddrExpr':\n            add_simple_getter('operand',\n                              'PyGccTree_New(gcc_addr_expr_get_operand(PyGccTree_as_gcc_addr_expr(self)))',\n                              'The operand of this expression, as a gcc.Tree')\n\n        if cc == 'StringCst':\n            add_simple_getter('constant',\n                              'PyGccString_FromString(gcc_string_constant_get_char_ptr(PyGccTree_as_gcc_string_constant(self)))',\n                              'The actual value of this constant, as a str')\n            tp_repr = '(reprfunc)PyGccStringConstant_repr'\n\n        if cc == 'IntegerCst':\n            getsettable.add_gsdef('constant',\n                                  'PyGccIntegerConstant_get_constant',\n                                  None,\n                                  'The actual value of this constant, as an int/long')\n            number_methods = PyNumberMethods('PyGccIntegerConstant_number_methods')\n            tp_as_number = number_methods.identifier\n            number_methods.nb_int = 'PyGccIntegerConstant_get_constant'\n            cu.add_defn(number_methods.c_defn())\n            tp_repr = '(reprfunc)PyGccIntegerConstant_repr'\n\n        if cc == 'RealCst':\n            getsettable.add_gsdef('constant',\n                                  'PyGccRealCst_get_constant',\n                                  None,\n                                  'The actual value of this constant, as a float')\n            tp_repr = '(reprfunc)PyGccRealCst_repr'\n\n        # TYPE_QUALS for various foo_TYPE classes:\n        if tree_type.SYM in ('VOID_TYPE', 'INTEGER_TYPE', 'REAL_TYPE', \n                             'FIXED_POINT_TYPE', 'COMPLEX_TYPE', 'VECTOR_TYPE',\n                             'ENUMERAL_TYPE', 'BOOLEAN_TYPE'):\n            for qual in ('const', 'volatile', 'restrict'):\n                add_simple_getter(qual,\n                                  'PyBool_FromLong(TYPE_QUALS(self->t.inner) & TYPE_QUAL_%s)' % qual.upper(),\n                                  \"Boolean: does this type have the '%s' modifier?\" % qual)\n                add_simple_getter('%s_equivalent' % qual,\n                                  'PyGccTree_New(gcc_private_make_tree(build_qualified_type(self->t.inner, TYPE_QUALS(self->t.inner) | TYPE_QUAL_%s)))' % qual.upper(),\n                                  'The gcc.Type for the %s version of this type' % qual)\n            add_simple_getter('unqualified_equivalent',\n                              'PyGccTree_New(gcc_private_make_tree(build_qualified_type(self->t.inner, 0)))',\n                                  'The gcc.Type for the unqualified version of this type')\n        if tree_type.SYM == 'RECORD_TYPE':\n            add_simple_getter('const',\n                              'PyBool_FromLong(TYPE_READONLY(self->t.inner))',\n                              \"Boolean: does this type have the 'const' modifier?\")\n\n        if tree_type.SYM == 'INTEGER_TYPE':\n            add_simple_getter('unsigned',\n                              'PyBool_FromLong(gcc_integer_type_is_unsigned(PyGccTree_as_gcc_integer_type(self)))',\n                              \"Boolean: True for 'unsigned', False for 'signed'\")\n            add_complex_getter('signed_equivalent',\n                              'The gcc.IntegerType for the signed version of this type')\n            add_complex_getter('unsigned_equivalent',\n                              'The gcc.IntegerType for the unsigned version of this type')\n            add_simple_getter('max_value',\n                              'PyGccTree_New(gcc_integer_constant_as_gcc_tree(gcc_integer_type_get_max_value(PyGccTree_as_gcc_integer_type(self))))',\n                              'The maximum possible value for this type, as a gcc.IntegerCst')\n            add_simple_getter('min_value',\n                              'PyGccTree_New(gcc_integer_constant_as_gcc_tree(gcc_integer_type_get_min_value(PyGccTree_as_gcc_integer_type(self))))',\n                              'The minimum possible value for this type, as a gcc.IntegerCst')\n            tp_repr = '(reprfunc)PyGccIntegerType_repr'\n\n        if tree_type.SYM in ('INTEGER_TYPE', 'REAL_TYPE', 'FIXED_POINT_TYPE'):\n            prefix = 'gcc_%s' % tree_type.SYM.lower()\n            add_simple_getter('precision',\n                              'PyGccInt_FromLong(%s_get_precision(PyGccTree_as_%s(self)))' % (prefix, prefix),\n                              'The precision of this type in bits, as an int (e.g. 32)')\n\n        if tree_type.SYM in ('POINTER_TYPE', 'ARRAY_TYPE', 'VECTOR_TYPE'):\n            prefix = 'gcc_%s' % tree_type.SYM.lower()\n            add_simple_getter('dereference',\n                              ('PyGccTree_New(gcc_type_as_gcc_tree(%s_get_dereference(PyGccTree_as_%s(self))))'\n                               % (prefix, prefix)),\n                              \"The gcc.Type that this type points to'\")\n\n        if tree_type.SYM == 'POINTER_TYPE':\n            tp_repr = '(reprfunc)PyGccPointerType_repr'\n\n        if tree_type.SYM == 'ARRAY_TYPE':\n            add_simple_getter('range',\n                              'PyGccTree_New(gcc_private_make_tree(TYPE_DOMAIN(self->t.inner)))',\n                              \"The gcc.Type that is the range of this array type\")\n\n        if tree_type.SYM == 'ARRAY_REF':\n            add_simple_getter('array',\n                              'PyGccTree_New(gcc_array_ref_get_array(PyGccTree_as_gcc_array_ref(self)))',\n                              \"The gcc.Tree for the array being referenced'\")\n            add_simple_getter('index',\n                              'PyGccTree_New(gcc_array_ref_get_index(PyGccTree_as_gcc_array_ref(self)))',\n                              \"The gcc.Tree for index being referenced'\")\n            tp_repr = '(reprfunc)PyGccArrayRef_repr'\n\n        if tree_type.SYM == 'COMPONENT_REF':\n            add_simple_getter('target',\n                              'PyGccTree_New(gcc_component_ref_get_target(PyGccTree_as_gcc_component_ref(self)))',\n                              \"The gcc.Tree that for the container of the field'\")\n            add_simple_getter('field',\n                              'PyGccTree_New(gcc_component_ref_get_field(PyGccTree_as_gcc_component_ref(self)))',\n                              \"The gcc.FieldDecl for the field within the target'\")\n            tp_repr = '(reprfunc)PyGccComponentRef_repr'\n\n        if tree_type.SYM == 'MEM_REF':\n            add_simple_getter('operand',\n                              'PyGccTree_New(gcc_mem_ref_get_operand(PyGccTree_as_gcc_mem_ref(self)))',\n                              \"The gcc.Tree that for the pointer expression'\")\n\n        if tree_type.SYM == 'BIT_FIELD_REF':\n            add_simple_getter('operand',\n                              'PyGccTree_New(gcc_private_make_tree(TREE_OPERAND(self->t.inner, 0)))',\n                              \"The gcc.Tree for the structure or union expression\")\n            add_simple_getter('num_bits',\n                              'PyGccTree_New(gcc_private_make_tree(TREE_OPERAND(self->t.inner, 1)))',\n                              \"The number of bits being referenced, as a gcc.IntegerCst\")\n            add_simple_getter('position',\n                              'PyGccTree_New(gcc_private_make_tree(TREE_OPERAND(self->t.inner, 2)))',\n                              \"The position of the first referenced bit, as a gcc.IntegerCst\")\n\n        if tree_type.SYM in ('RECORD_TYPE', 'UNION_TYPE', 'QUAL_UNION_TYPE'):\n            add_simple_getter('fields',\n                              'PyGcc_GetFields(self)',\n                              \"The fields of this type\")\n            add_simple_getter('methods',\n                              'PyGcc_GetMethods(self)',\n                              \"The methods of this type\")\n\n        if tree_type.SYM == 'ENUMERAL_TYPE':\n            add_simple_getter('values',\n                              'PyGcc_TreeMakeListOfPairsFromTreeListChain(TYPE_VALUES(self->t.inner))',\n                              \"The values of this type\")\n\n        if tree_type.SYM == 'IDENTIFIER_NODE':\n            add_simple_getter('name',\n                              'PyGccStringOrNone(IDENTIFIER_POINTER(self->t.inner))',\n                              \"The name of this gcc.IdentifierNode, as a string\")\n            tp_repr = '(reprfunc)PyGccIdentifierNode_repr'\n\n        if tree_type.SYM == 'VAR_DECL':\n            add_simple_getter('initial',\n                              'PyGccTree_New(gcc_constructor_as_gcc_tree(gcc_var_decl_get_initial(PyGccTree_as_gcc_var_decl(self))))',\n                              \"The initial value for this variable as a gcc.Constructor, or None\")\n            add_simple_getter('static',\n                              'PyBool_FromLong(gcc_var_decl_is_static(PyGccTree_as_gcc_var_decl(self)))',\n                              \"Boolean: is this variable to be allocated with static storage\")\n\n        if tree_type.SYM == 'CONSTRUCTOR':\n            add_complex_getter('elements',\n                              \"The elements of this constructor, as a list of (index, gcc.Tree) pairs\")\n\n        if tree_type.SYM == 'TRANSLATION_UNIT_DECL':\n            add_simple_getter('block',\n                              'PyGccBlock_New(gcc_translation_unit_decl_get_block(PyGccTree_as_gcc_translation_unit_decl(self)))',\n                               \"The gcc.Block for this namespace\")\n            add_simple_getter('language',\n                              'PyGccString_FromString(gcc_translation_unit_decl_get_language(PyGccTree_as_gcc_translation_unit_decl(self)))',\n                               \"The source language of this translation unit, as a string\")\n\n        if tree_type.SYM == 'BLOCK':\n            add_simple_getter('vars',\n                              'PyGcc_TreeListFromChain(BLOCK_VARS(self->t.inner))',\n                               \"The list of gcc.Tree for the declarations and labels in this block\")\n\n        if tree_type.SYM == 'NAMESPACE_DECL':\n            add_simple_getter('alias_of',\n                              'PyGccTree_New(gcc_private_make_tree(DECL_NAMESPACE_ALIAS(self->t.inner)))',\n                              \"None if not an alias, otherwise the gcc.NamespaceDecl we alias\")\n            add_simple_getter('declarations',\n                              'PyGccNamespaceDecl_declarations(self->t.inner)',\n                              'The list of gcc.Declarations within this namespace')\n            add_simple_getter('namespaces',\n                              'PyGccNamespaceDecl_namespaces(self->t.inner)',\n                              'The list of gcc.NamespaceDecl objects and gcc.TypeDecl of Unions nested in this namespace')\n            methods.add_method('lookup',\n                               '(PyCFunction)PyGccNamespaceDecl_lookup',\n                               'METH_VARARGS|METH_KEYWORDS',\n                               \"Look up the given string within this namespace\")\n            methods.add_method('unalias',\n                               '(PyCFunction)PyGccNamespaceDecl_unalias',\n                               'METH_VARARGS|METH_KEYWORDS',\n                               \"A gcc.NamespaceDecl of this namespace that is not an alias\")\n\n        if tree_type.SYM == 'TYPE_DECL':\n            getsettable.add_gsdef('pointer',\n                                  'PyGccTypeDecl_get_pointer',\n                                  None,\n                                  \"The gcc.PointerType representing '(this_type *)'\")\n            getsettable.add_gsdef('original_type',\n                                  'PyGccTypeDecl_get_original_type',\n                                  None,\n                                  \"The gcc.Type from which this type was typedef'd from.'\")\n\n        if tree_type.SYM == 'FUNCTION_TYPE':\n            getsettable.add_gsdef('argument_types',\n                                  'PyGccFunction_TypeObj_get_argument_types',\n                                  None,\n                                  \"A tuple of gcc.Type instances, representing the argument types of this function type\")\n            getsettable.add_gsdef('is_variadic',\n                                  'PyGccFunction_TypeObj_is_variadic',\n                                  None,\n                                  \"Boolean: is this function variadic\")\n\n        if tree_type.SYM == 'METHOD_TYPE':\n            getsettable.add_gsdef('argument_types',\n                                  'PyGccMethodType_get_argument_types',\n                                  None,\n                                  \"A tuple of gcc.Type instances, representing the argument types of this method type\")\n            getsettable.add_gsdef('is_variadic',\n                                  'PyGccMethodType_is_variadic',\n                                  None,\n                                  \"Boolean: is this method variadic\")\n\n        if tree_type.SYM == 'FUNCTION_DECL':\n            getsettable.add_gsdef('fullname',\n                                  'PyGccFunctionDecl_get_fullname',\n                                  None,\n                                  'C++ only: the full name of this function declaration')\n            add_simple_getter('function',\n                              'PyGccFunction_New(gcc_private_make_function(DECL_STRUCT_FUNCTION(self->t.inner)))',\n                              'The gcc.Function (or None) for this declaration')\n            add_simple_getter('arguments',\n                              'PyGcc_TreeListFromChain(DECL_ARGUMENTS(self->t.inner))',\n                              'List of gcc.ParmDecl')\n            add_simple_getter('result',\n                              'PyGccTree_New(gcc_private_make_tree(DECL_RESULT_FLD(self->t.inner)))',\n                              'The gcc.ResultDecl for the return value')\n            getsettable.add_gsdef('callgraph_node',\n                                  'PyGccFunctionDecl_get_callgraph_node',\n                                  None,\n                                  'The gcc.CallgraphNode for this function declaration, or None')\n\n            for attr in ('public', 'private', 'protected', 'static'):\n                getsettable.add_simple_getter(cu,\n                                              'is_%s' % attr,\n                                              'PyBool_FromLong(TREE_%s(self->t.inner))' % attr.upper(),\n                                              None)\n\n        if tree_type.SYM == 'SSA_NAME':\n            # c.f. \"struct GTY(()) tree_ssa_name\":\n            add_simple_getter('var',\n                              'PyGccTree_New(gcc_ssa_name_get_var(PyGccTree_as_gcc_ssa_name(self)))',\n                              \"The variable being referenced'\")\n            add_simple_getter('def_stmt',\n                              'PyGccGimple_New(gcc_ssa_name_get_def_stmt(PyGccTree_as_gcc_ssa_name(self)))',\n                              \"The gcc.Gimple statement which defines this SSA name'\")\n            add_simple_getter('version',\n                              'PyGccInt_FromLong(gcc_ssa_name_get_version(PyGccTree_as_gcc_ssa_name(self)))',\n                              \"The SSA version number of this SSA name'\")\n            tp_repr = '(reprfunc)PyGccSsaName_repr'\n\n\n        if tree_type.SYM == 'TREE_LIST':\n            # c.f. \"struct GTY(()) tree_list\":\n            tp_repr = '(reprfunc)PyGccTreeList_repr'\n\n        if tree_type.SYM == 'CASE_LABEL_EXPR':\n            add_simple_getter('low',\n                              'PyGccTree_New(gcc_case_label_expr_get_low(PyGccTree_as_gcc_case_label_expr(self)))',\n                              \"The low value of the case label, as a gcc.Tree (or None for the default)\")\n            add_simple_getter('high',\n                              'PyGccTree_New(gcc_case_label_expr_get_high(PyGccTree_as_gcc_case_label_expr(self)))',\n                              \"The high value of the case label, if any, as a gcc.Tree (None for the default and for single-valued case labels)\")\n            add_simple_getter('target',\n                              'PyGccTree_New(gcc_label_decl_as_gcc_tree(gcc_case_label_expr_get_target(PyGccTree_as_gcc_case_label_expr(self))))',\n                              \"The target of the case label, as a gcc.LabelDecl\")\n            tp_repr = '(reprfunc)PyGccCaseLabelExpr_repr'\n\n        cu.add_defn(getsettable.c_defn())\n        cu.add_defn(methods.c_defn())\n        pytype = PyGccWrapperTypeObject(identifier = 'PyGcc%s_TypeObj' % cc,\n                              localname = cc,\n                              tp_name = 'gcc.%s' % cc,\n                              struct_name = 'PyGccTree',\n                              tp_new = 'PyType_GenericNew',\n                              tp_base = '&%s' % base_type,\n                              tp_getset = getsettable.identifier,\n                              tp_str = tp_str,\n                              tp_repr = tp_repr,\n                              tp_methods = methods.identifier,\n                              )\n        if tp_as_number:\n            pytype.tp_as_number = '&%s' % tp_as_number\n        cu.add_defn(pytype.c_defn())\n        modinit_preinit += pytype.c_invoke_type_ready()\n        modinit_postinit += pytype.c_invoke_add_to_module()\n        \n\n    cu.add_defn('\\n/* Map from GCC tree codes to PyGccWrapperTypeObject* */\\n')\n    cu.add_defn('PyGccWrapperTypeObject *pytype_for_tree_code[] = {\\n')\n    for tree_type in tree_types:\n        cu.add_defn('    &PyGcc%s_TypeObj, /* %s */\\n' % (tree_type.camel_cased_string(), tree_type.SYM))\n    cu.add_defn('};\\n\\n')\n\n    cu.add_defn('\\n/* Map from PyGccWrapperTypeObject* to GCC tree codes*/\\n')\n    cu.add_defn('int \\n')\n    cu.add_defn('PyGcc_tree_type_object_as_tree_code(PyObject *cls, enum tree_code *out)\\n')\n    cu.add_defn('{\\n')\n    for tree_type in tree_types:\n        cu.add_defn('    if (cls == (PyObject*)&PyGcc%s_TypeObj) {\\n'\n                    '        *out = %s; return 0;\\n'\n                    '    }\\n'\n                    % (tree_type.camel_cased_string(),\n                       tree_type.SYM))\n    cu.add_defn('    return -1;\\n')\n    cu.add_defn('}\\n')\n\n    cu.add_defn(\"\"\"\nPyGccWrapperTypeObject*\nPyGcc_autogenerated_tree_type_for_tree_code(enum tree_code code, int borrow_ref)\n{\n    PyGccWrapperTypeObject *result;\n\n    assert(code >= 0);\n    assert(code < MAX_TREE_CODES);\n\n    result = pytype_for_tree_code[code];\n\n    if (!borrow_ref) {\n        Py_INCREF(result);\n    }\n    return result;\n}\n\nPyGccWrapperTypeObject*\nPyGcc_autogenerated_tree_type_for_tree(gcc_tree t, int borrow_ref)\n{\n    enum tree_code code = TREE_CODE(t.inner);\n    /* printf(\"code:%i\\\\n\", code); */\n    return PyGcc_autogenerated_tree_type_for_tree_code(code, borrow_ref);\n}\n\"\"\")\n\n\ngenerate_tree_code_classes()\n\ncu.add_defn(\"\"\"\nint autogenerated_tree_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_tree_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\n\n\nprint(cu.as_str())\n"
  },
  {
    "path": "generate-variable-c.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom cpybuilder import *\nfrom wrapperbuilder import PyGccWrapperTypeObject\n\ncu = CompilationUnit()\ncu.add_include('gcc-python.h')\ncu.add_include('gcc-python-wrappers.h')\ncu.add_include('gcc-plugin.h')\ncu.add_include(\"gcc-c-api/gcc-variable.h\")\n\nmodinit_preinit = ''\nmodinit_postinit = ''\n\ndef generate_variable():\n    global modinit_preinit\n    global modinit_postinit\n\n    getsettable = PyGetSetDefTable('PyGccVariable_getset_table', [])\n    def add_simple_getter(name, c_expression, doc):\n        getsettable.add_gsdef(name,\n                              cu.add_simple_getter('PyGccVariable_get_%s' % name,\n                                                   'PyGccVariable',\n                                                   c_expression),\n                              None,\n                              doc)\n\n    add_simple_getter('decl',\n                      'PyGccTree_New(gcc_variable_get_decl(self->var))',\n                      'The declaration of this variable, as a gcc.Tree')\n\n    cu.add_defn(getsettable.c_defn())\n    \n    pytype = PyGccWrapperTypeObject(identifier = 'PyGccVariable_TypeObj',\n                          localname = 'Variable',\n                          tp_name = 'gcc.Variable',\n                          tp_dealloc = 'PyGccWrapper_Dealloc',\n                          struct_name = 'PyGccVariable',\n                          tp_new = 'PyType_GenericNew',\n                          tp_getset = getsettable.identifier,\n                          #tp_repr = '(reprfunc)PyGccVariable_repr',\n                          #tp_str = '(reprfunc)PyGccVariable_repr',\n                          )\n    cu.add_defn(pytype.c_defn())\n    modinit_preinit += pytype.c_invoke_type_ready()\n    modinit_postinit += pytype.c_invoke_add_to_module()\n    \ngenerate_variable()\n\n\n\ncu.add_defn(\"\"\"\nint autogenerated_variable_init_types(void)\n{\n\"\"\" + modinit_preinit + \"\"\"\n    return 1;\n\nerror:\n    return 0;\n}\n\"\"\")\n\ncu.add_defn(\"\"\"\nvoid autogenerated_variable_add_types(PyObject *m)\n{\n\"\"\" + modinit_postinit + \"\"\"\n}\n\"\"\")\n\nprint(cu.as_str())\n"
  },
  {
    "path": "gimple-types.txt.in",
    "content": "#define DEFGSCODE(GIMPLE_symbol, printable_name, GSS_symbol)  \\\n   GIMPLE_symbol, printable_name, GSS_symbol\n#include \"gimple.def\"\n#undef DEFGSCODE\n\n#define DEFGSSTRUCT(GSS_enumeration_value, structure_name, has_tree_operands) \\\n   GSS_enumeration_value, structure_name, has_tree_operands\n#include \"gsstruct.def\"\n#undef DEFGSSTRUCT\n\n\n"
  },
  {
    "path": "libcpychecker/PyArg_ParseTuple.py",
    "content": "#   Copyright 2011, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Domain-specific warning:\n#  Detecting errors in usage of the PyArg_ParseTuple API\n#  \n#  See http://docs.python.org/c-api/arg.html\n#\n#  Note that all of the \"#\" codes are affected by the presence of the\n#  macro PY_SSIZE_T_CLEAN. If the macro was defined before including Python.h,\n#  the various lengths for these format codes are of C type \"Py_ssize_t\" rather\n#  than \"int\".\n#\n#  This behavior was clarified in the Python 3 version of the C API\n#  documentation[1], though the Python 2 version of the API docs leave which\n#  codes are affected somewhat ambiguoues.\n#\n#  Nevertheless, the API _does_ work this way in Python 2: all format codes\n#  with a \"#\" do work this way.\n#\n#  You can see the implementation of the API in CPython's Python/getargs.c\n#\n#  [1] The relevant commit to the CPython docs was:\n#    http://hg.python.org/cpython/rev/5d4a5655575f/\n\nimport gcc\n\nfrom libcpychecker.formatstrings import *\nfrom libcpychecker.types import *\nfrom libcpychecker.utils import log\n\ndef _type_of_simple_arg(arg):\n    # Convert 1-character argument code to a gcc.Type, covering the easy cases\n    #\n    # Analogous to Python/getargs.c:convertsimple, this is the same order as\n    # that function's \"switch\" statement:\n    simple = {'b': gcc.Type.unsigned_char,\n              'B': gcc.Type.unsigned_char,\n              'h': gcc.Type.short,\n              'H': gcc.Type.unsigned_short,\n              'i': gcc.Type.int,\n              'I': gcc.Type.unsigned_int,\n              'l': gcc.Type.long,\n              'k': gcc.Type.unsigned_long,\n              'f': gcc.Type.float,\n              'd': gcc.Type.double,\n              'c': gcc.Type.char,\n              }\n    if arg in simple:\n        # FIXME: ideally this shouldn't need calling; it should just be an\n        # attribute:\n        return simple[arg]()\n\n    if arg == 'n':\n        return get_Py_ssize_t()\n\n    if arg == 'L':\n        return get_PY_LONG_LONG()\n\n    if arg == 'K':\n        return get_PY_LONG_LONG().unsigned_equivalent\n\n    if arg == 'D':\n        return get_Py_complex()\n\nclass TypeCheck(FormatUnit):\n    \"\"\"\n    Handler for the \"O!\" format code\n    \"\"\"\n    def __init__(self, code):\n        FormatUnit.__init__(self, code)\n        self.checker = TypeCheckCheckerType(self)\n        self.result = TypeCheckResultType(self)\n\n        # The gcc.VarDecl for the PyTypeObject, if we know it (or None):\n        self.typeobject = None\n\n    def get_expected_types(self):\n        # We will discover the actual types as we go, using \"self\" to bind\n        # together the two arguments\n        return [self.checker, self.result]\n\n    def get_other_type(self):\n        if not self.typeobject:\n            return None\n        return get_type_for_typeobject(self.typeobject)\n\nclass TypeCheckCheckerType(AwkwardType):\n    def __init__(self, typecheck):\n        self.typecheck = typecheck\n\n    def is_compatible(self, actual_type, actual_arg):\n        # We should be encountering a pointer to a PyTypeObject\n        # The result type (next argument) should be either a PyObject* or\n        # an pointer to the corresponding type.\n        #\n        # For example, \"O!\" with\n        #     &PyCode_Type, &code,\n        # then \"code\" should be either a PyObject* or a PyCodeObject*\n        # (and &code gets the usual extra level of indirection)\n\n        if str(actual_type) != 'struct PyTypeObject *':\n            return False\n\n        # OK, the type for this argument is good.\n        # Try to record the actual type object, assuming it's a pointer to a\n        # global:\n        if not isinstance(actual_arg, gcc.AddrExpr):\n            return True\n\n        if not isinstance(actual_arg.operand, gcc.VarDecl):\n            return True\n\n        # OK, we have a ptr to a global; record it:\n        self.typecheck.typeobject = actual_arg.operand\n\n        return True\n\n    def describe(self):\n        return '\"struct PyTypeObject *\"'\n\nclass TypeCheckResultType(AwkwardType):\n    def __init__(self, typecheck):\n        self.typecheck = typecheck\n        self.base_type = get_PyObject().pointer.pointer\n\n    def is_compatible(self, actual_type, actual_arg):\n        if not isinstance(actual_type, gcc.PointerType):\n            return False\n\n        # If something went wrong with figuring out the type, we can only check\n        # against PyObject*:\n\n        # (PyObject **) is good:\n        if compatible_type(actual_type,\n                           self.base_type):\n            return True\n\n        other_type = self.typecheck.get_other_type()\n        if other_type:\n            if compatible_type(actual_type,\n                               other_type.pointer.pointer):\n                return True\n\n        return False\n\n    def describe(self):\n        other_type = self.typecheck.get_other_type()\n        if other_type:\n            return ('%s (based on PyTypeObject: %r) or %s'\n                    % (describe_type(other_type.pointer.pointer),\n                       self.typecheck.typeobject.name,\n                       describe_type(self.base_type)))\n        else:\n            if self.typecheck.typeobject:\n                return ('\"%s\" (unfamiliar with PyTypeObject: %r)'\n                        % (describe_type(self.base_type),\n                           self.typecheck.typeobject.name))\n            else:\n                return '\"%s\" (unable to determine relevant PyTypeObject)' % describe_type(self.base_type)\n\n\nclass Conversion(FormatUnit):\n    \"\"\"\n    Handler for the \"O&\" format code\n    \"\"\"\n    def __init__(self, code):\n        FormatUnit.__init__(self, code)\n        self.callback = ConverterCallbackType(self)\n        self.result = ConverterResultType(self)\n\n    def get_expected_types(self):\n        # We will discover the actual types as we go, using \"self\" to bind\n        # together the two arguments\n        return [self.callback, self.result]\n\nclass ConverterCallbackType(AwkwardType):\n    def __init__(self, conv):\n        self.conv = conv\n        self.actual_type = None\n\n    def is_compatible(self, actual_type, actual_arg):\n        # We should be encountering a function pointer of type:\n        #   int (fn)(PyObject *, T*)\n        # The result type (next argument) should be a T*\n        if not isinstance(actual_type, gcc.PointerType):\n            return False\n\n        signature = actual_type.dereference\n        if not isinstance(signature, gcc.FunctionType):\n            return False\n\n        # Check return type:\n        if signature.type != gcc.Type.int():\n            return False\n\n        # Check argument types:\n        if len(signature.argument_types) != 2:\n            return False\n\n        if not compatible_type(signature.argument_types[0],\n                               get_PyObject().pointer):\n            return False\n\n        if not isinstance(signature.argument_types[1], gcc.PointerType):\n            return False\n\n        # Write back to the ConverterResultType with the second arg:\n        log('2nd argument of converter should be of type %s', signature.argument_types[1])\n        self.conv.result.type = signature.argument_types[1]\n        self.actual_type = actual_type\n\n        return True\n\n    def describe(self):\n        return '\"int (converter)(PyObject *, T*)\" for some type T'\n\nclass ConverterResultType(AwkwardType):\n    def __init__(self, conv):\n        self.conv = conv\n        self.type = None\n\n    def is_compatible(self, actual_type, actual_arg):\n        if not isinstance(actual_type, gcc.PointerType):\n            return False\n\n        # If something went wrong with figuring out the type, we can't check\n        # it:\n        if self.type is None:\n            return True\n\n        return compatible_type(self.type, actual_type)\n\n    def describe(self):\n        if self.type:\n            return ('%s (from second argument of %s)'\n                    % (describe_type(self.type),\n                       describe_type(self.conv.callback.actual_type)))\n        else:\n            return '\"T*\" for some type T'\n\nclass PyArgParseFmt(ParsedFormatString):\n    \"\"\"\n    Python class representing the string arg to PyArg_ParseTuple and friends\n    \"\"\"\n\n    def add_argument(self, code, expected_types):\n        self.args.append(ConcreteUnit(code, expected_types))\n\n    def num_expected(self):\n        return len(list(self.iter_exp_types()))\n\n    def iter_exp_types(self):\n        \"\"\"\n        Yield a sequence of (FormatUnit, gcc.Type) pairs, representing\n        the expected types of the varargs\n        \"\"\"\n        for arg in self.args:\n            for exp_type in arg.get_expected_types():\n                yield (arg, exp_type)\n\n    @classmethod\n    def from_string(cls, fmt_string, with_size_t):\n        \"\"\"\n        Parse fmt_string, generating a PyArgParseFmt instance\n        Compare to Python/getargs.c:vgetargs1\n        FIXME: only implements a subset of the various cases; no tuples yet etc\n        \"\"\"\n        result = PyArgParseFmt(fmt_string)\n        i = 0\n        paren_nesting = 0\n        while i < len(fmt_string):\n            c = fmt_string[i]\n            i += 1\n            if i < len(fmt_string):\n                next = fmt_string[i]\n            else:\n                next = None\n\n            if c == '(':\n                paren_nesting += 1\n                continue\n\n            if c == ')':\n                if paren_nesting > 0:\n                    paren_nesting -= 1\n                    continue\n                else:\n                    raise MismatchedParentheses(fmt_string)\n\n            if c in [':', ';']:\n                break\n\n            if c =='|':\n                continue\n\n            simple_type = _type_of_simple_arg(c)\n            if simple_type:\n                result.add_argument(c, [simple_type.pointer])\n\n            elif c in ['s', 'z']: # string, possibly NULL/None\n                if next == '#':\n                    result.add_argument(c + '#',\n                                        [get_const_char_ptr_ptr(),\n                                         get_hash_size_type(with_size_t).pointer])\n                    i += 1\n                elif next == '*':\n                    result.add_argument(c + '*', [get_Py_buffer().pointer])\n                    i += 1\n                else:\n                    result.add_argument(c, [get_const_char_ptr_ptr()])\n\n            elif c == 'e':\n                if next in ['s', 't']:\n                    arg = ConcreteUnit('e' + next,\n                                       [(get_const_char_ptr(), get_char_ptr(), NullPointer()),\n                                        gcc.Type.char().pointer.pointer])\n                    i += 1\n                    if i < len(fmt_string):\n                        if fmt_string[i] == '#':\n                            arg.code += '#'\n                            # es# and et# within getargs.c use FETCH_SIZE and\n                            # STORE_SIZE and are thus affected by the size\n                            # macro:\n                            arg.expected_types.append(get_hash_size_type(with_size_t).pointer)\n                            i+=1\n                    result.args.append(arg)\n            elif c == 'u':\n                if next == '#':\n                    result.add_argument('u#',\n                                        [Py_UNICODE().pointer.pointer,\n                                         get_hash_size_type(with_size_t).pointer])\n                    i += 1\n                else:\n                    result.add_argument('u', [Py_UNICODE().pointer.pointer])\n            elif c == 'S':\n                if is_py3k():\n                    # S (bytes) [PyBytesObject *] (or PyObject *)\n                    result.add_argument('S', [(get_PyBytesObject().pointer.pointer,\n                                               get_PyObject().pointer.pointer)])\n                else:\n                    # S (string) [PyStringObject *] (or PyObject *)\n                    result.add_argument('S', [(get_PyStringObject().pointer.pointer,\n                                               get_PyObject().pointer.pointer)])\n            elif c == 'U':\n                result.add_argument('U', [(get_PyUnicodeObject().pointer.pointer,\n                                           get_PyObject().pointer.pointer)])\n            elif c == 'O': # object\n                if next == '!':\n                    result.args.append(TypeCheck('O!'))\n                    i += 1\n                elif next == '?':\n                    raise UnhandledCode(richloc, fmt_string, c + next) # FIXME\n                elif next == '&':\n                    result.args.append(Conversion('O&'))\n                    i += 1\n                else:\n                    result.add_argument('O',\n                                        [get_PyObject().pointer.pointer])\n            elif c == 'w':\n                if next == '#':\n                    result.add_argument('w#',\n                                        [gcc.Type.char().pointer.pointer,\n                                         get_hash_size_type(with_size_t).pointer])\n                    # Note: reading CPython sources indicates it's a FETCH_SIZE\n                    # type, not an Py_ssize_t, as the docs current suggest\n                    i += 1\n                elif next == '*':\n                    result.add_argument('w*', [get_Py_buffer().pointer])\n                    i += 1\n                else:\n                    result.add_argument('w', [gcc.Type.char().pointer.pointer])\n            elif c == 't':\n                if next == '#':\n                    result.add_argument('t#',\n                                        [gcc.Type.char().pointer.pointer,\n                                         get_hash_size_type(with_size_t).pointer])\n                    # Note: reading CPython sources indicates it's a FETCH_SIZE\n                    # type, not an int, as the docs current suggest\n                    i += 1\n            else:\n                raise UnknownFormatChar(fmt_string, c)\n\n        if paren_nesting > 0:\n            raise MismatchedParentheses(fmt_string)\n\n        return result\n"
  },
  {
    "path": "libcpychecker/Py_BuildValue.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Domain-specific warning:\n#  Detecting errors in usage of the Py_BuildValue API\n#  \n#  See http://docs.python.org/c-api/arg.html#Py_BuildValue\n#\n# FIXME:\n#  Note that all of the \"#\" codes are affected by the presence of the\n#  macro PY_SSIZE_T_CLEAN. If the macro was defined before including Python.h,\n#  the various lengths for these format codes are of C type \"Py_ssize_t\" rather\n#  than \"int\".\n#\n#  This behavior was clarified in the Python 3 version of the C API\n#  documentation[1], though the Python 2 version of the API docs leave which\n#  codes are affected somewhat ambiguoues.\n#\n#  Nevertheless, the API _does_ work this way in Python 2: all format codes\n#  with a \"#\" do work this way.\n#\n#  You can see the implementation of the API in CPython's Python/getargs.c\n#\n#  [1] The relevant commit to the CPython docs was:\n#    http://hg.python.org/cpython/rev/5d4a5655575f/\n\nimport gcc\nimport sys\n\nfrom libcpychecker.formatstrings import *\nfrom libcpychecker.types import *\nfrom libcpychecker.utils import log\n\ndef _type_of_simple_arg(arg):\n    # Convert 1-character argument code to a gcc.Type, covering the easy cases\n    #\n    # Analogous to Python/modsupport.c:do_mkvalue, this is the same order as\n    # that function's \"switch\" statement:\n    simple = {\n        # all of these actually just use \"int\":\n        'b': gcc.Type.char,\n        'B': gcc.Type.unsigned_char,\n        'h': gcc.Type.short,\n        'i': gcc.Type.int,\n        'H': gcc.Type.unsigned_short,\n        'I': gcc.Type.unsigned_int,\n        # 'n' covered below\n        'l': gcc.Type.long,\n        'k': gcc.Type.unsigned_long,\n        # 'L' covered below\n        # 'K' covered below\n        # 'u': covered in from_string() below\n\n        'f': gcc.Type.double,\n        # (although documented as \"[float]\", 'f' accepts a \"va_double\" in\n        # modsupport.c)\n\n        'd': gcc.Type.double,\n        # 'D' covered below\n\n        'c': gcc.Type.int,\n        # (although documented as \"[char]\", 'c' accepts an \"int\" in\n        # modsupport.c)\n\n        # 's': covered in from_string() below\n        # 'z': covered in from_string() below\n        # 'N': covered in from_string() below\n        # 'S': covered in from_string() below\n        # 'O': covered in from_string() below\n        # ':': covered in from_string() below\n        # ',': covered in from_string() below\n        # ' ': covered in from_string() below\n        # '\\t': covered in from_string() below\n        }\n    if arg in simple:\n        # FIXME: ideally this shouldn't need calling; it should just be an\n        # attribute:\n        return simple[arg]()\n\n    if arg == 'n':\n        return get_Py_ssize_t()\n    elif arg == 'L':\n        return get_PY_LONG_LONG()\n    elif arg == 'K':\n        return get_PY_LONG_LONG().unsigned_equivalent\n    elif arg == 'D':\n        return get_Py_complex().pointer\n\nclass AnyPyObjectPtr(AwkwardType):\n    \"\"\"\n    For use when we expect PyObject*, or any subclass\n    \"\"\"\n    def is_compatible(self, actual_type, actual_arg):\n        # We expect a pointer to a PyObject*, or any subclass:\n        from libcpychecker.refcounts import type_is_pyobjptr_subclass\n        return type_is_pyobjptr_subclass(actual_type)\n\nclass ObjectFormatUnit(FormatUnit):\n    \"\"\"\n    Base class for Py_BuildValue format codes that expect a PyObject*\n    \"\"\"\n    def get_expected_types(self):\n        return [AnyPyObjectPtr()]\n\nclass CodeSO(ObjectFormatUnit):\n    \"\"\"\n    Corresponds to Py_BuildValue format codes \"S\" and \"O\"\n    \"\"\"\n    pass\n\nclass CodeN(ObjectFormatUnit):\n    \"\"\"\n    Corresponds to Py_BuildValue format code \"N\"\n    \"\"\"\n    pass\n\n\nclass CompoundFmt:\n    def __init__(self, opench, closech):\n        self.opench = opench\n        self.closech = closech\n        self.args = []\n\n    def __repr__(self):\n        return 'CompoundFmt(%r, %r, %r)' % (self.opench, self.args, self.closech)\n\n    def append(self, item):\n        self.args.append(item)\n\n    def iter_exp_types(self):\n        for arg in self.args:\n            if isinstance(arg, CompoundFmt):\n                for inner in arg.iter_exp_types():\n                    yield inner\n            else:\n                for exp_type in arg.get_expected_types():\n                    yield (arg, exp_type)\n        \nclass PyBuildValueFmt(ParsedFormatString):\n    def __init__(self, fmt_string):\n        ParsedFormatString.__init__(self, fmt_string)\n        self.arg_stack = [self.args]\n\n    def num_expected(self):\n        from pprint import pformat\n        #sys.stderr.write('%s\\n' % pformat(list(self.iter_exp_types())))\n        return len(list(self.iter_exp_types()))\n\n    def iter_exp_types(self):\n        \"\"\"\n        Yield a sequence of (FormatUnit, gcc.Type) pairs, representing\n        the expected types of the varargs\n        \"\"\"\n        for arg in self.args:\n            if isinstance(arg, CompoundFmt):\n                for inner in arg.iter_exp_types():\n                    yield inner\n            else:\n                for exp_type in arg.get_expected_types():\n                    yield (arg, exp_type)\n\n    def add_argument(self, code, expected_types):\n        self.arg_stack[-1].append(ConcreteUnit(code, expected_types))\n\n    def add_complex_argument(self, arg):\n        self.arg_stack[-1].append(arg)\n\n    def _do_open_compound_fmt(self, opench, closech):\n        \"\"\"\n        Analogous to Python/modsupport.c:do_mktuple\n        \"\"\"\n        # Store tuples using lists, so that they are mutable during\n        # construction:\n        new = CompoundFmt(opench, closech)\n        self.arg_stack[-1].append(new)\n        self.arg_stack.append(new)\n\n    def _do_close_compound_fmt(self, closech):\n        if len(self.arg_stack) < 1:\n            raise MismatchedParentheses(self.fmt_string)\n        cf = self.arg_stack.pop()\n        if cf.closech != closech:\n            raise MismatchedParentheses(self.fmt_string)\n\n    @classmethod\n    def from_string(cls, fmt_string, with_size_t):\n        \"\"\"\n        Parse fmt_string, generating a PyBuildValue instance\n        Compare to Python/modsupport.c:va_build_value\n        FIXME: only implements a subset of the various cases\n        \"\"\"\n        result = PyBuildValueFmt(fmt_string)\n        i = 0\n        while i < len(fmt_string):\n            c = fmt_string[i]\n            i += 1\n            if i < len(fmt_string):\n                next = fmt_string[i]\n            else:\n                next = None\n            #sys.stderr.write('(%r, %r)\\n' % (c, None))\n\n            # Analogous to Python/modsupport.c:do_mkvalue, this is in the same\n            # order as that function's \"switch\" statement:\n            simple_type = _type_of_simple_arg(c)\n            if simple_type:\n                result.add_argument(c, [simple_type])\n                continue\n                \n            if c == '(':\n                result._do_open_compound_fmt('(', ')')\n                continue\n            if c == '[':\n                result._do_open_compound_fmt('[', ']')\n                continue\n            if c == '{':\n                result._do_open_compound_fmt('{', '}')\n                continue\n\n            if c in ')]}':\n                result._do_close_compound_fmt(c)\n                continue\n\n            if c in 'sz':\n                if next == '#':\n                    result.add_argument(c + '#',\n                                        [get_char_ptr(),\n                                         get_hash_size_type(with_size_t)])\n                    i += 1\n                else:\n                    result.add_argument(c,\n                                        [get_char_ptr()])\n                continue\n\n            if c == 'u':\n                if next == '#':\n                    result.add_argument(c + '#',\n                                        [Py_UNICODE().pointer,\n                                         get_hash_size_type(with_size_t)])\n                    i += 1\n                else:\n                    result.add_argument(c,\n                                        [Py_UNICODE().pointer])\n                continue\n\n            if c in 'NSO':\n                if next == '&':\n                    result.add_complex_argument()\n                    i += 1\n                else:\n                    if c == 'N':\n                        result.add_complex_argument(CodeN(c))\n                    else:\n                        result.add_complex_argument(CodeSO(c))\n                continue\n\n            if c in \":, \\t\":\n                continue\n\n            raise UnknownFormatChar(fmt_string, c)\n\n        if len(result.arg_stack) > 1:\n            # Not all parentheses were closed:\n            raise MismatchedParentheses(self.fmt_string)\n\n        #print result\n        #from pprint import pprint\n        #pprint(result.args)\n        \n        return result\n"
  },
  {
    "path": "libcpychecker/__init__.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom __future__ import print_function\nimport sys\nimport gcc\nfrom libcpychecker.formatstrings import check_pyargs\nfrom libcpychecker.utils import log\nfrom libcpychecker.refcounts import check_refcounts, get_traces\nfrom libcpychecker.attributes import register_our_attributes\nfrom libcpychecker.initializers import check_initializers\nfrom libcpychecker.types import get_PyObject\nif hasattr(gcc, 'PLUGIN_FINISH_DECL'):\n    from libcpychecker.compat import on_finish_decl\n\nclass CpyCheckerGimplePass(gcc.GimplePass):\n    \"\"\"\n    The custom pass that implements the per-function part of\n    our extra compile-time checks\n    \"\"\"\n    def __init__(self,\n                 dump_traces=False,\n                 show_traces=False,\n                 verify_pyargs=True,\n                 verify_refcounting=False,\n                 show_possible_null_derefs=False,\n                 only_on_python_code=True,\n                 maxtrans=256,\n                 dump_json=False,\n                 verbose=False):\n        gcc.GimplePass.__init__(self, 'cpychecker-gimple')\n        self.dump_traces = dump_traces\n        self.show_traces = show_traces\n        self.verify_pyargs = verify_pyargs\n        # Refcounting verification is run before rewriting gimple into ssa form,\n        # and as such is not expected to handle ssa.  In gcc 7 and later, gcc\n        # introduces ssa names before the ssa rewrite (for call arguments that\n        # are calls themselves), and this causes Python exceptions in\n        # refcounting verification.  So, disable refcounting for gcc 7 and\n        # later, until refcounting verification can handle ssa names.\n        if verify_refcounting and gcc.GCC_VERSION >= 7000:\n            if verbose:\n                print(\"cpychecker: warning: \"\n                      + \"Detected gcc 7 or later, disabling verify_refcounting\",\n                      file=sys.stderr)\n            self.verify_refcounting = False\n        else:\n            self.verify_refcounting = verify_refcounting\n        self.show_possible_null_derefs = show_possible_null_derefs\n        self.only_on_python_code = only_on_python_code\n        self.maxtrans = maxtrans\n        self.dump_json = dump_json\n\n    def execute(self, fun):\n        if fun:\n            log('%s', fun)\n            if self.verify_pyargs:\n                check_pyargs(fun)\n\n            if self.only_on_python_code:\n                # Only run the refcount checker on code that\n                # includes <Python.h>:\n                if not get_PyObject():\n                    return\n\n            # The refcount code is too buggy for now to be on by default:\n            if self.verify_refcounting:\n                if 0:\n                    # Profiled version:\n                    import cProfile\n                    prof_filename = '%s.%s.refcount-profile' % (gcc.get_dump_base_name(),\n                                                                fun.decl.name)\n                    cProfile.runctx('self._check_refcounts(fun)',\n                                    globals(), locals(),\n                                    filename=prof_filename)\n                    import pstats\n                    prof = pstats.Stats(prof_filename)\n                    prof.sort_stats('cumulative').print_stats(20)\n                else:\n                    # Normal mode (without profiler):\n                    self._check_refcounts(fun)\n\n    def _check_refcounts(self, fun):\n        check_refcounts(fun, self.dump_traces, self.show_traces,\n                        self.show_possible_null_derefs,\n                        maxtrans=self.maxtrans,\n                        dump_json=self.dump_json)\n\n\nclass CpyCheckerIpaPass(gcc.SimpleIpaPass):\n    \"\"\"\n    The custom pass that implements the whole-program part of\n    our extra compile-time checks\n    \"\"\"\n    def __init__(self):\n        gcc.SimpleIpaPass.__init__(self, 'cpychecker-ipa')\n\n    def execute(self):\n        check_initializers()\n\ndef main(**kwargs):\n    # Register our custom attributes:\n    gcc.register_callback(gcc.PLUGIN_ATTRIBUTES,\n                          register_our_attributes)\n\n    # Hook for GCC 4.7 and later:\n    if hasattr(gcc, 'PLUGIN_FINISH_DECL'):\n        gcc.register_callback(gcc.PLUGIN_FINISH_DECL,\n                              on_finish_decl)\n\n    # Register our GCC passes:\n    gimple_ps = CpyCheckerGimplePass(**kwargs)\n    if 1:\n        # non-SSA version:\n        gimple_ps.register_before('*warn_function_return')\n    else:\n        # SSA version:\n        gimple_ps.register_after('ssa')\n\n    ipa_ps = CpyCheckerIpaPass()\n    ipa_ps.register_before('*free_lang_data')\n"
  },
  {
    "path": "libcpychecker/absinterp.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nimport gccutils\nimport re\nimport sys\nfrom six import StringIO, integer_types\n\nfrom gccutils import get_src_for_loc, get_nonnull_arguments, check_isinstance\nfrom gccutils.graph.stmtgraph import StmtGraph, StmtNode\n\nfrom collections import OrderedDict\nfrom libcpychecker.utils import log, logging_enabled\nfrom libcpychecker.types import *\nfrom libcpychecker.diagnostics import location_as_json, type_as_json\n\ndebug_comparisons = 0\n\nnumeric_types = integer_types + (float, )\n\n# I found myself regularly getting State and Transition instances confused.  To\n# ameliorate that, here are some naming conventions and abbreviations:\n#\n# Within method names:\n#   \"mktrans_\" means \"make a Transition\"\n#   \"mkstate_\" means \"make a State\"\n#\n# Within variable names\n#   the prefix \"t_\" means a Transition\n#   the prefix \"s_\" means a State\n#   the prefix \"v_\" means an AbstractValue\n#   the prefix \"r_\" means a Region\n#   the prefix \"f_\" means a Facet\n\n# Valid 'opname' parameters to eval_comparison hooks:\nopnames = frozenset(['eq', 'ge', 'gt', 'le', 'lt'])\n\ndef raw_comparison(a, opname, b):\n    assert opname in opnames\n    if opname == 'eq':\n        return a == b\n    elif opname == 'ge':\n        return a >= b\n    elif opname == 'gt':\n        return a > b\n    elif opname == 'le':\n        return a <= b\n    elif opname == 'lt':\n        return a < b\n    else:\n        raise ValueError()\n\ndef flip_opname(opname):\n    \"\"\"\n    Given:\n      A op B\n    get the op' for:\n      B op' A\n    that has the same results\n    \"\"\"\n    assert opname in opnames\n    if opname == 'eq':\n        return 'eq' # symmetric\n    elif opname == 'ge':\n        return 'le'\n    elif opname == 'gt':\n        return 'lt'\n    elif opname == 'le':\n        return 'ge'\n    elif opname == 'lt':\n        return 'gt'\n    else:\n        raise ValueError()\n\nif debug_comparisons:\n    debug_indent = 0\n    # Decorator for adding debug tracking to the various comparison operators\n    def dump_comparison(f):\n        def impl_fn(self, *args):\n            global debug_indent\n            print('%s%s.%s:' % ('  ' * debug_indent, self.__class__.__name__, f.__name__))\n            for arg in [self] + list(args):\n                print(' %s%s' % ('  ' * debug_indent, arg))\n            debug_indent += 1\n            r = f(self, *args)\n            debug_indent -= 1\n            print('%sreturned: %s' % ('  ' * debug_indent, r))\n            return r\n        return impl_fn\n    def debug_comparison(msg):\n        print('%s%s' % ('  ' * debug_indent, msg))\nelse:\n    # empty decorator\n    def dump_comparison(f):\n        return f\n\n########################################################################\n\nclass FnMeta(object):\n    \"\"\"\n    Metadata describing an API function\n    \"\"\"\n    __slots__ = ('name', # the name of the function\n                 'docurl', # URL of the API documentation, on docs.python.org\n                 'declared_in', # name of the header file in which this is declared\n                 'prototype', # fragment of C giving the prototype (for documentation purposes)\n                 'defined_in', # where is this function defined (in CPython)\n                 'notes', # fragment of text, giving notes on the function\n                 )\n    def __init__(self, **kwargs):\n        for key in self.__slots__:\n            setattr(self, key, None)\n        for key, value in kwargs.items():\n            setattr(self, key, value)\n\n    def desc_when_call_returns_value(self, valuedesc):\n        \"\"\"\n        Generate descriptive text for a Transition involving a call to this\n        function that returns some value (described in string form)\n\n        e.g. \"when PyTuple_Size() returns ob_size\"\n        \"\"\"\n        return 'when %s() returns %s' % (self.name, valuedesc)\n\n    def desc_when_call_succeeds(self):\n        \"\"\"\n        Generate descriptive text for a Transition involving a call to this\n        function that succeeds.\n\n        e.g. \"when PyTuple_SetItem() succeeds\"\n        \"\"\"\n        return 'when %s() succeeds' % self.name\n\n    def desc_when_call_fails(self, why=None):\n        \"\"\"\n        Generate descriptive text for a Transition involving a call to this\n        function that fails, optionally with a textual description of the\n        kind of failure\n\n        e.g. \"when PyTuple_SetItem() fails (index out of range)\"\n        \"\"\"\n        if why:\n            return 'when %s() fails (%s)' % (self.name, why)\n        else:\n            return 'when %s() fails' % self.name\n\n    def desc_special(self, event):\n        \"\"\"\n        Generate descriptive text for a Transition involving a call to this\n        function that does somthing unusual\n\n        e.g. \"when PyString_Concat() does nothing due to NULL *lhs\"\n        \"\"\"\n        return 'when %s() %s' % (self.name, event)\n\n############################################################################\n# Various kinds of r-value:\n############################################################################\n\nclass AbstractValue(object):\n    \"\"\"\n    Base class, representing some subset of possible values out of the full\n    set of values that this r-value could hold.\n    \"\"\"\n    __slots__ = ('gcctype', 'loc', 'fromsplit')\n\n    def __init__(self, gcctype, loc):\n        if gcctype:\n            check_isinstance(gcctype, gcc.Type)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        self.gcctype = gcctype\n        self.loc = loc\n\n    def __str__(self):\n        if self.gcctype:\n            result = '%s' % self.gcctype\n        else:\n            result = 'unknown type'\n        if self.loc:\n            result += ' from %s' % self.loc\n        return result\n\n    def __repr__(self):\n        return ('%s(gcctype=%r, loc=%r)'\n                % (self.__class__.__name__, str(self.gcctype), self.loc))\n\n    def as_json(self, state):\n        result = dict(kind=self.__class__.__name__,\n                      gcctype=type_as_json(self.gcctype),\n                      value_comes_from=location_as_json(self.loc))\n        # Get extra per-class JSON fields:\n        result.update(self.json_fields(state))\n        return result\n\n    def json_fields(self, state):\n        # Hook for getting extra per-class fields for JSON serialization\n        # Empty for the base class\n        return dict()\n\n    def is_null_ptr(self):\n        \"\"\"\n        Is this AbstractValue *definitely* a NULL pointer?\n        \"\"\"\n        # Overridden by ConcreteValue\n        return False\n\n    def get_transitions_for_function_call(self, state, stmt):\n        \"\"\"\n        For use for handling function pointers.  Return a list of Transition\n        instances giving the outcome of calling this function ptr value\n        \"\"\"\n        check_isinstance(state, State)\n        check_isinstance(stmt, gcc.GimpleCall)\n        returntype = stmt.fn.type.dereference.type\n\n        from libcpychecker.refcounts import type_is_pyobjptr_subclass\n        if type_is_pyobjptr_subclass(returntype):\n            log('Invocation of function pointer returning PyObject * (or subclass)')\n            # Assume that all such functions either:\n            #   - return a new reference, or\n            #   - return NULL and set an exception (e.g. MemoryError)\n            return state.cpython.make_transitions_for_new_ref_or_fail(stmt,\n                                                                      None,\n                                                                      'new ref from call through function pointer')\n        return state.apply_fncall_side_effects(\n            [state.mktrans_assignment(stmt.lhs,\n                                      UnknownValue.make(returntype, stmt.loc),\n                                      'calling %s' % self)],\n            stmt)\n\n    def eval_unary_op(self, exprcode, gcctype, loc):\n        if exprcode == gcc.ConvertExpr:\n            raise NotImplementedError(\"Don't know how to cope with type conversion of: %r (%s) at %s to type %s\"\n                                      % (self, self, loc, gcctype))\n        else:\n            raise NotImplementedError(\"Don't know how to cope with exprcode: %r (%s) on %s at %s\"\n                                      % (exprcode, exprcode, self, loc))\n\n    def eval_binop(self, exprcode, rhs, rhsdesc, gcctype, loc):\n        raise NotImplementedError\n\n    @dump_comparison\n    def eval_comparison(self, opname, rhs, rhsdesc):\n        \"\"\"\n        opname is a string in opnames\n        Return a boolean, or None (meaning we don't know)\n        \"\"\"\n        raise NotImplementedError(\"eval_comparison for %s (%s)\" % (self, opname))\n\n    def extract_from_parent(self, region, gcctype, loc):\n        \"\"\"\n        Called on a parent when inheriting a value from it for a child region,\n        for example, when a whole struct has \"UnknownValue\", we can extract\n        a particular field, giving an UnknownValue of the appropriate type\n        \"\"\"\n        raise NotImplementedError('%s.extract_from_parent(%s, %s, %s)'\n                                  % (self.__class__.__name__, region, gcctype, loc))\n\n    def as_string_constant(self):\n        \"\"\"\n        If this is a pointer to a string constant, return the underlying\n        string, otherwise return None\n        \"\"\"\n        if isinstance(self, PointerToRegion):\n            if isinstance(self.region, RegionForStringConstant):\n                return self.region.text\n            # We could be dealing with e.g. char *ptr = \"hello world\";\n            # where \"hello world\" is a 'char[12]', and thus ptr has been\n            # assigned a char* pointing to '\"hello world\"[0]'\n            if isinstance(self.region, ArrayElementRegion):\n                if isinstance(self.region.parent, RegionForStringConstant):\n                    return self.region.parent.text[self.region.index:]\n        # Otherwise, not a string constant, return None\n\n    def union(self, v_other):\n        check_isinstance(v_other, AbstractValue)\n        raise NotImplementedError('%s.union(%s, %s)'\n                                  % (self.__class__.__name__, v_other))\n\nclass EmptySet(AbstractValue):\n    \"\"\"\n    The empty set: there are no possible values for this variable (yet).\n    \"\"\"\n    def union(self, v_other):\n        check_isinstance(v_other, AbstractValue)\n        return v_other\n\nclass UnknownValue(AbstractValue):\n    \"\"\"\n    A value that we know nothing about: it could be any of the possible values\n    \"\"\"\n    @classmethod\n    def make(cls, gcctype, loc):\n        \"\"\"\n        For some types, we may be able to supply more information\n        \"\"\"\n        if gcctype:\n            check_isinstance(gcctype, gcc.Type)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        if gcctype:\n            if isinstance(gcctype, gcc.IntegerType):\n                # Supply range limits for integer types, from the type itself:\n                return WithinRange(gcctype, loc,\n                                   gcctype.min_value.constant,\n                                   gcctype.max_value.constant)\n        return UnknownValue(gcctype, loc)\n\n    def __str__(self):\n        if self.gcctype:\n            return 'unknown %s from %s' % (self.gcctype, self.loc)\n        else:\n            if self.loc:\n                return 'unknown value from %s' % self.loc\n            else:\n                return 'unknown value'\n\n    def __repr__(self):\n        return 'UnknownValue(gcctype=%r, loc=%r)' % (self.gcctype, self.loc)\n\n    def eval_unary_op(self, exprcode, gcctype, loc):\n        return UnknownValue.make(gcctype, loc)\n\n    def eval_binop(self, exprcode, rhs, rhsdesc, gcctype, loc):\n        return UnknownValue.make(gcctype, loc)\n\n    @dump_comparison\n    def eval_comparison(self, opname, rhs, rhsdesc):\n        if opname == 'eq':\n            # If it's the *same* value, it's equal to itself:\n            if self is rhs:\n                return True\n        return None\n\n    def extract_from_parent(self, region, gcctype, loc):\n        return UnknownValue.make(gcctype, loc)\n\n    def union(self, v_other):\n        check_isinstance(v_other, AbstractValue)\n        return self\n\ndef eval_binop(exprcode, a, b, rhsvalue):\n    \"\"\"\n    Evaluate a gcc exprcode on a pair of Python values (as opposed to\n    AbstractValue instances)\n    \"\"\"\n    log('eval_binop(%s, %s, %s)', exprcode, a, b)\n    assert isinstance(a, numeric_types)\n    assert isinstance(b, numeric_types)\n    assert isinstance(rhsvalue, AbstractValue)\n\n    def inner():\n        if exprcode == gcc.PlusExpr:\n            return a + b\n        elif exprcode == gcc.MinusExpr:\n            return a - b\n        elif exprcode == gcc.MultExpr:\n            return a * b\n        elif exprcode == gcc.TruncDivExpr:\n            return a // b\n        elif exprcode == gcc.ExactDivExpr:\n            return a / b\n        elif exprcode == gcc.TruncModExpr:\n            return a % b\n        elif exprcode == gcc.MaxExpr:\n            return max(a, b)\n        elif exprcode == gcc.MinExpr:\n            return min(a, b)\n        elif exprcode == gcc.BitIorExpr:\n            return a | b\n        elif exprcode == gcc.BitAndExpr:\n            return a & b\n        elif exprcode == gcc.BitXorExpr:\n            return a ^ b\n        elif exprcode == gcc.LshiftExpr:\n            return a << b\n        elif exprcode == gcc.RshiftExpr:\n            return a >> b\n        elif exprcode == gcc.TruthAndExpr:\n            return a and b\n        elif exprcode == gcc.TruthOrExpr:\n            return a or b\n\n        # (an implicit return of None means \"did not know how to handle this\n        # expression\")\n\n    try:\n        result = inner()\n    except (ArithmeticError, ValueError):\n        err = sys.exc_info()[1]\n        isdefinite = not hasattr(rhsvalue, 'fromsplit')\n        raise PredictedArithmeticError(err, rhsvalue, isdefinite)\n    log('result: %s', result)\n    assert isinstance(result, numeric_types)\n    return result\n\n\nclass ConcreteValue(AbstractValue):\n    \"\"\"\n    A known, specific value (e.g. 0)\n    \"\"\"\n    __slots__ = ('value', )\n\n    def __init__(self, gcctype, loc, value):\n        check_isinstance(gcctype, gcc.Type)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        check_isinstance(value, numeric_types)\n        self.gcctype = gcctype\n        self.loc = loc\n        self.value = value\n\n    @classmethod\n    def from_int(self, value):\n        return ConcreteValue(gcc.Type.int(), None, value)\n\n    def __ne__(self, other):\n        if isinstance(other, ConcreteValue):\n            return self.value != other.value\n        return NotImplemented\n\n    def __str__(self):\n        if self.loc:\n            return ('(%s)%s from %s'\n                    % (self.gcctype, value_to_str(self.value), self.loc))\n        else:\n            return ('(%s)%s'\n                    % (self.gcctype, value_to_str(self.value)))\n\n    def __repr__(self):\n        return ('ConcreteValue(gcctype=%r, loc=%r, value=%s)'\n                % (str(self.gcctype), self.loc, value_to_str(self.value)))\n\n    def json_fields(self, state):\n        return dict(value=self.value)\n\n    def is_null_ptr(self):\n        if isinstance(self.gcctype, gcc.PointerType):\n            return self.value == 0\n\n    def get_transitions_for_function_call(self, state, stmt):\n        check_isinstance(state, State)\n        check_isinstance(stmt, gcc.GimpleCall)\n\n        class CallOfNullFunctionPtr(PredictedError):\n            def __init__(self, stmt, value):\n                check_isinstance(stmt, gcc.Gimple)\n                check_isinstance(value, AbstractValue)\n                self.stmt = stmt\n                self.value = value\n\n            def __str__(self):\n                return ('call of NULL function pointer at %s: %s'\n                        % (self.stmt.loc, self.value))\n\n        if self.is_null_ptr():\n            raise CallOfNullFunctionPtr(stmt, self)\n\n        return AbstractValue.get_transitions_for_function_call(self, state, stmt)\n\n    def eval_unary_op(self, exprcode, gcctype, loc):\n        if exprcode == gcc.AbsExpr:\n            return ConcreteValue(gcctype, loc, abs(self.value))\n        elif exprcode == gcc.BitNotExpr:\n            # FIXME: bitwise-complement, with the correct width\n            #   self.gcctype.precision\n            return ConcreteValue(gcctype, loc, ~self.value)\n        elif exprcode == gcc.NegateExpr:\n            return ConcreteValue(gcctype, loc, -self.value)\n        elif exprcode == gcc.ConvertExpr:\n            # Is this value expressible within the new type?\n            # If not, we might lose information\n            if isinstance(self.gcctype, gcc.IntegerType) \\\n                    and isinstance(gcctype, gcc.IntegerType):\n                if (self.value >= gcctype.min_value.constant\n                    and self.value <= gcctype.max_value.constant):\n                    # The old range will convert OK to the new type:\n                    return ConcreteValue(gcctype, loc, self.value)\n            # We might lose information e.g. truncation; be pessimistic for now:\n            return UnknownValue.make(gcctype, loc)\n        elif exprcode == gcc.FixTruncExpr:\n            return ConcreteValue(gcctype, loc, int(self.value))\n        elif exprcode == gcc.FloatExpr:\n            return ConcreteValue(gcctype, loc, float(self.value))\n        else:\n            raise NotImplementedError(\"Don't know how to cope with exprcode: %r (%s) on %s at %s\"\n                                      % (exprcode, exprcode, self, loc))\n\n    def eval_binop(self, exprcode, rhs, rhsdesc, gcctype, loc):\n        if isinstance(rhs, ConcreteValue):\n            newvalue = eval_binop(exprcode, self.value, rhs.value, rhs)\n            if newvalue is not None:\n                return ConcreteValue(gcctype, loc, newvalue)\n        return UnknownValue.make(gcctype, loc)\n\n    @dump_comparison\n    def eval_comparison(self, opname, rhs, rhsdesc):\n        log('ConcreteValue.eval_comparison(%s, %s%s)', self, opname, rhs)\n        if isinstance(rhs, ConcreteValue):\n            return raw_comparison(self.value, opname, rhs.value)\n        elif isinstance(rhs, WithinRange):\n            # Specialcase for equality:\n            if opname == 'eq':\n                if not rhs.contains(self.value):\n                    return False\n                # Split into 2 or 3 parts:\n                ranges = []\n                if rhs.minvalue < self.value:\n                    # subrange that's <\n                    ranges.append(WithinRange.make(rhs.gcctype,\n                                                   rhs.loc,\n                                                   rhs.minvalue,\n                                                   self.value-1))\n                ranges.append(WithinRange.make(rhs.gcctype,\n                                               rhs.loc,\n                                               self.value))\n                if self.value < rhs.maxvalue:\n                    # subrange that's >\n                    ranges.append(WithinRange.make(rhs.gcctype,\n                                                   rhs.loc,\n                                                   self.value+1,\n                                                   rhs.maxvalue))\n                rhs.raise_split(rhsdesc, *ranges)\n\n            # For everything else (inequalities), consider ranges:\n            self_vs_min = raw_comparison(self.value, opname, rhs.minvalue)\n            self_vs_max = raw_comparison(self.value, opname, rhs.maxvalue)\n            if self_vs_min == self_vs_max:\n                return self_vs_min\n            else:\n                # Prepare a split, autogenerating the appropriate\n                # boundaries:\n                class RangeOfComparison:\n                    \"\"\"\n                    A range over which the comparison against the ConcreteValue\n                    has a constant value\n                    \"\"\"\n                    __slots__ = ('rng', 'result')\n                    def __init__(self, rng, result):\n                        check_isinstance(rng, (ConcreteValue, WithinRange))\n                        check_isinstance(result, (bool, None))\n                        self.rng = rng\n                        self.result = result\n                    def __repr__(self):\n                        return ('RangeOfComparison(%r, %r)'\n                                % (self.rng, self.result))\n\n                # Where are the boundary values?\n                raw_boundaries = sorted(list(set([self.value - 1,\n                                                  self.value,\n                                                  self.value + 1,\n                                                  rhs.minvalue,\n                                                  rhs.maxvalue])))\n                # Filter them to be within the existing range:\n                raw_boundaries = [v\n                                  for v in raw_boundaries\n                                  if rhs.contains(v)]\n                if debug_comparisons:\n                    debug_comparison([value_to_str(v) for v in raw_boundaries])\n\n                # Calculate a minimal list of RangeOfComparison instances\n                # Within each one, the comparison against the ConcreteValue has\n                # a consistent result:\n                ranges = []\n                num_boundary_ranges = len(raw_boundaries)\n                if debug_comparisons:\n                    debug_comparison('num_boundary_ranges: %r' % num_boundary_ranges)\n                for i in range(num_boundary_ranges):\n                    minvalue = raw_boundaries[i]\n                    if minvalue < rhs.gcctype.min_value.constant:\n                        minvalue = rhs.gcctype.min_value.constant\n\n                    if i < num_boundary_ranges - 1:\n                        # Extend up to but not including the next range:\n                        maxvalue = raw_boundaries[i + 1] - 1\n                    else:\n                        # Final range: use full range:\n                        maxvalue = rhs.maxvalue\n\n                    if maxvalue > rhs.gcctype.max_value.constant:\n                        maxvalue = rhs.gcctype.max_value.constant\n\n                    if debug_comparisons:\n                        debug_comparison('%i [%s..%s]'\n                                         % (i,\n                                            value_to_str(minvalue),\n                                            value_to_str(maxvalue)))\n\n                    check_isinstance(minvalue, numeric_types)\n                    check_isinstance(maxvalue, numeric_types)\n\n                    # Only \"proper\" ranges:\n                    if minvalue <= maxvalue:\n                        self_vs_min = raw_comparison(self.value, opname, minvalue)\n                        self_vs_max = raw_comparison(self.value, opname, maxvalue)\n\n                        # All ranges should have identical value when compared\n                        # against the concrete value:\n                        assert self_vs_min == self_vs_max\n                        if debug_comparisons:\n                            debug_comparison('  [%s..%s] %s %s ?: %s'\n                                             % (value_to_str(minvalue),\n                                                value_to_str(maxvalue),\n                                                opname, self.value,\n                                                self_vs_min))\n\n                        if ranges and ranges[-1].result == self_vs_min:\n                            # These ranges are adjacent and have the same result;\n                            # merge them:\n                            oldrange = ranges[-1].rng\n                            if isinstance(oldrange, ConcreteValue):\n                                newrange = WithinRange(oldrange.gcctype,\n                                                       oldrange.loc,\n                                                       oldrange.value,\n                                                       maxvalue)\n                            else:\n                                check_isinstance(oldrange, WithinRange)\n                                newrange = WithinRange(oldrange.gcctype,\n                                                       oldrange.loc,\n                                                       oldrange.minvalue,\n                                                       maxvalue)\n                            ranges[-1].rng = newrange\n                        else:\n                            # We have a range with a different value:\n                            roc = RangeOfComparison(WithinRange.make(rhs.gcctype, rhs.loc,\n                                                                     minvalue, maxvalue),\n                                                    self_vs_min)\n                            ranges.append(roc)\n\n                if debug_comparisons:\n                    from pprint import pprint\n                    pprint(ranges)\n                rhs.raise_split(rhsdesc, *[roc.rng for roc in ranges])\n        return None\n\n    def extract_from_parent(self, region, gcctype, loc):\n        return ConcreteValue(gcctype, loc, self.value)\n\n    def union(self, v_other):\n        check_isinstance(v_other, AbstractValue)\n        if isinstance(v_other, ConcreteValue):\n            if self.value == v_other.value:\n                return self\n            return WithinRange.make(self.gcctype, self.loc,\n                               self.value, v_other.value)\n        if isinstance(v_other, WithinRange):\n            return WithinRange.make(self.gcctype, self.loc,\n                               *(self.value, v_other.minvalue, v_other.maxvalue))\n        raise NotImplementedError('%s.union(%s)'\n                                  % (self.__class__.__name__, v_other))\n\ndef value_to_str(value):\n    \"\"\"\n    Display large integers/longs in hexadecimal, since it's easier\n    to decipher\n       -0x8000000000000000\n    than\n       -9223372036854775808\n    \"\"\"\n    check_isinstance(value, numeric_types)\n\n    if isinstance(value, integer_types):\n        if abs(value) > 0x100000:\n            return hex(value)\n    return str(value)\n\nclass WithinRange(AbstractValue):\n    \"\"\"\n    A value known to be within a given range e.g. -3 <= val <= +4\n    \"\"\"\n    __slots__ = ('minvalue', 'maxvalue', )\n\n    def __init__(self, gcctype, loc, *values):\n        \"\"\"\n        The constructor can take one or more values; the resulting set\n        is the minimal range covering all of the input values,\n        For example,\n           WithinRange(gcctype, loc, 7, 4, -4, -2)\n        will give the range -2 <= val < 7\n        \"\"\"\n        check_isinstance(gcctype, gcc.Type)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        assert len(values) >= 1\n        for value in values:\n            check_isinstance(value, numeric_types)\n        self.gcctype = gcctype\n        self.loc = loc\n        self.minvalue = min(values)\n        self.maxvalue = max(values)\n\n        # Clamp to be within the type's expressible range:\n        if self.minvalue < gcctype.min_value.constant:\n            self.minvalue = gcctype.min_value.constant\n        if self.maxvalue > gcctype.max_value.constant:\n            self.maxvalue = gcctype.max_value.constant\n\n    @classmethod\n    def make(cls, gcctype, loc, *values):\n        \"\"\"\n        Generate a WithinRange instance, unless the range uniqely identifies\n        a value, in which case generate a ConcreteValue instance\n        \"\"\"\n        minvalue = min(values)\n        maxvalue = max(values)\n        if minvalue == maxvalue:\n            return ConcreteValue(gcctype, loc, minvalue)\n        else:\n            return WithinRange(gcctype, loc, minvalue, maxvalue)\n\n    @classmethod\n    def ge_zero(cls, gcctype, loc):\n        \"\"\"\n        Make a WithinRange for the given type, assuming a value >= 0, up to\n        the maximum value representable by the type\n        \"\"\"\n        return WithinRange(gcctype, loc, 0, gcctype.max_value.constant)\n\n    def __str__(self):\n        if self.loc:\n            return ('(%s)val [%s <= val <= %s] from %s'\n                    % (self.gcctype, value_to_str(self.minvalue),\n                       value_to_str(self.maxvalue), self.loc))\n        else:\n            return ('(%s)val [%s <= val <= %s]'\n                    % (self.gcctype, value_to_str(self.minvalue),\n                       value_to_str(self.maxvalue)))\n\n    def __repr__(self):\n        return ('WithinRange(gcctype=%r, loc=%r, minvalue=%s, maxvalue=%s)'\n                % (str(self.gcctype), self.loc, value_to_str(self.minvalue),\n                   value_to_str(self.maxvalue)))\n\n    def json_fields(self, state):\n        return dict(minvalue=self.minvalue,\n                    maxvalue=self.maxvalue)\n\n    def eval_unary_op(self, exprcode, gcctype, loc):\n        if exprcode == gcc.AbsExpr:\n            values = [abs(val)\n                      for val in (self.minvalue, self.maxvalue)]\n            return WithinRange.make(gcctype, loc, min(values), max(values))\n        elif exprcode == gcc.BitNotExpr:\n            return UnknownValue.make(gcctype, loc)\n        elif exprcode == gcc.NegateExpr:\n            return WithinRange.make(gcctype, loc, -self.maxvalue, -self.minvalue)\n        elif exprcode == gcc.ConvertExpr:\n            # Is the whole of this range fully expressible within the new type?\n            # If not, we might lose information\n            if isinstance(self.gcctype, gcc.IntegerType) \\\n                    and isinstance(gcctype, gcc.IntegerType):\n                if (self.minvalue >= gcctype.min_value.constant\n                    and self.maxvalue <= gcctype.max_value.constant):\n                    # The old range will convert OK to the new type:\n                    return WithinRange.make(gcctype, loc,\n                                       self.minvalue, self.maxvalue)\n            # We might lose information e.g. truncation; be pessimistic for now:\n            return UnknownValue.make(gcctype, loc)\n        elif exprcode == gcc.FloatExpr:\n            return UnknownValue.make(gcctype, loc)\n        else:\n            raise NotImplementedError(\"Don't know how to cope with exprcode: %r (%s) on %s at %s\"\n                                      % (exprcode, exprcode, self, loc))\n\n    def eval_binop(self, exprcode, rhs, rhsdesc, gcctype, loc):\n        if isinstance(rhs, ConcreteValue):\n            values = [eval_binop(exprcode, val, rhs.value, rhs)\n                      for val in (self.minvalue, self.maxvalue)]\n            return WithinRange.make(gcctype, loc, min(values), max(values))\n        elif isinstance(rhs, WithinRange):\n            # Assume that the operations are \"concave\" in that the resulting\n            # range is within that found by trying all four corners:\n\n            # Avoid division by zero:\n            # (see https://fedorahosted.org/gcc-python-plugin/ticket/25 )\n            if exprcode == gcc.TruncDivExpr or exprcode == gcc.TruncModExpr:\n                if rhs.minvalue == 0 and rhs.maxvalue > 0:\n                    zero_range = WithinRange.make(rhs.gcctype, rhs.loc, 0)\n                    gt_zero_range = WithinRange.make(rhs.gcctype, rhs.loc,\n                                                1, rhs.maxvalue)\n                    rhs.raise_split(rhsdesc, zero_range, gt_zero_range)\n\n            # Avoid negative shifts:\n            # (see https://fedorahosted.org/gcc-python-plugin/ticket/14 )\n            if exprcode == gcc.LshiftExpr or exprcode == gcc.RshiftExpr:\n                if rhs.minvalue < 0 and rhs.maxvalue >= 0:\n                    neg_range = WithinRange.make(rhs.gcctype, rhs.loc,\n                                            rhs.minvalue, -1)\n                    ge_zero_range = WithinRange.make(rhs.gcctype, rhs.loc,\n                                                0, rhs.maxvalue)\n                    rhs.raise_split(rhsdesc, neg_range, ge_zero_range)\n\n            values = (eval_binop(exprcode, self.minvalue, rhs.minvalue, rhs),\n                      eval_binop(exprcode, self.minvalue, rhs.maxvalue, rhs),\n                      eval_binop(exprcode, self.maxvalue, rhs.minvalue, rhs),\n                      eval_binop(exprcode, self.maxvalue, rhs.maxvalue, rhs))\n            return WithinRange.make(gcctype, loc,\n                               min(values),\n                               max(values))\n        return UnknownValue.make(gcctype, loc)\n\n    def contains(self, rawvalue):\n        check_isinstance(rawvalue, numeric_types)\n        return self.minvalue <= rawvalue and rawvalue <= self.maxvalue\n\n    @dump_comparison\n    def eval_comparison(self, opname, rhs, rhsdesc):\n        log('WithinRange.eval_comparison(%s, %s%s)', self, opname, rhs)\n\n        # If it's the *same* value, it's equal to itself:\n        if opname == 'eq':\n            if self is rhs:\n                return True\n\n            if isinstance(rhs, WithinRange):\n                # They can only be equal if there's an overlap:\n                if self.contains(rhs.minvalue) or self.contains(rhs.maxvalue):\n                    # Maybe equal:\n                    return None\n                else:\n                    # No overlap: definitely non-equal:\n                    return False\n\n        if isinstance(rhs, ConcreteValue):\n            # to implement WithinRange op ConcreteValue, use:\n            #   ConcreteValue flip(op) WithinRange\n            return rhs.eval_comparison(flip_opname(opname), self, None)\n\n        return None\n\n    def raise_split(self, valuedesc, *new_ranges):\n        \"\"\"\n        Raise a SplitValue exception to subdivide this range into subranges\n        \"\"\"\n        descriptions = []\n        if valuedesc is None:\n            valuedesc = 'value'\n        for r in new_ranges:\n            if isinstance(r, WithinRange):\n                descriptions.append('when considering range: %s <= %s <= %s' %\n                                    (value_to_str(r.minvalue),\n                                     valuedesc,\n                                     value_to_str(r.maxvalue)))\n            elif isinstance(r, ConcreteValue):\n                descriptions.append('when considering %s == %s' % (valuedesc, r))\n            else:\n                raise TypeError('unrecognized type: %r' % r)\n        raise SplitValue(self, new_ranges, descriptions)\n\n    def raise_as_concrete(self, loc, value, desc):\n        \"\"\"\n        Raise a SplitValue exception to reinterpret this range as a specific\n        ConcreteValue from now on.\n\n        This is slightly abusing the SplitValue mechanism, as it's just one\n        new value, but it should at least add the descriptive text into the\n        trace.\n        \"\"\"\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        check_isinstance(value, numeric_types)\n        check_isinstance(desc, str)\n        v_new = ConcreteValue(self.gcctype, loc,\n                              value)\n        raise SplitValue(self, [v_new], [desc])\n\n    def extract_from_parent(self, region, gcctype, loc):\n        return WithinRange.make(gcctype, self.loc, self.minvalue, self.maxvalue)\n\n    def union(self, v_other):\n        check_isinstance(v_other, AbstractValue)\n        if isinstance(v_other, ConcreteValue):\n            return WithinRange.make(self.gcctype, self.loc,\n                               *(self.minvalue, self.maxvalue, v_other.value))\n        if isinstance(v_other, WithinRange):\n            return WithinRange.make(self.gcctype, self.loc,\n                               *(self.minvalue, self.maxvalue,\n                                 v_other.minvalue, v_other.maxvalue))\n        raise NotImplementedError('%s.union(%s)'\n                                  % (self.__class__.__name__, v_other))\n\nclass PointerToRegion(AbstractValue):\n    \"\"\"A non-NULL pointer value, pointing at a specific Region\"\"\"\n    __slots__ = ('region', )\n\n    def __init__(self, gcctype, loc, region):\n        AbstractValue.__init__(self, gcctype, loc)\n        check_isinstance(region, Region)\n        self.region = region\n\n    def __str__(self):\n        if self.loc:\n            return '(%s)&%r from %s' % (self.gcctype, self.region, self.loc)\n        else:\n            return '(%s)&%r' % (self.gcctype, self.region)\n\n    def __repr__(self):\n        return 'PointerToRegion(gcctype=%r, loc=%r, region=%r)' % (str(self.gcctype), self.loc, self.region)\n\n    def json_fields(self, state):\n        return dict(target=self.region.as_json())\n\n    def eval_comparison(self, opname, rhs, rhsdesc):\n        log('PointerToRegion.eval_comparison:(%s, %s%s)', self, opname, rhs)\n\n        if opname == 'eq':\n            if isinstance(rhs, ConcreteValue) and rhs.value == 0:\n                log('ptr to region vs 0: %s is definitely not equal to %s', self, rhs)\n                return False\n\n            if isinstance(rhs, PointerToRegion):\n                log('comparing regions: %s %s', self, rhs)\n                return self.region == rhs.region\n\n            # We don't know:\n            return None\n\n    def eval_unary_op(self, exprcode, gcctype, loc):\n        if exprcode == gcc.ConvertExpr:\n            # Casting of this non-NULL pointer to another type:\n            return UnknownValue.make(gcctype, loc)\n\n        # Defer to base class:\n        AbstractValue.eval_unary_op(self, exprcode, gcctype, loc)\n\nclass DeallocatedMemory(AbstractValue):\n    \"\"\"\n    A 'poisoned' r-value: this memory has been deallocated, so the r-value\n    is meaningless.\n    \"\"\"\n    def __str__(self):\n        if self.loc:\n            return 'memory deallocated at %s' % self.loc\n        else:\n            return 'deallocated memory'\n\n    def extract_from_parent(self, region, gcctype, loc):\n        return DeallocatedMemory(gcctype, self.loc)\n\nclass UninitializedData(AbstractValue):\n    \"\"\"\n    A 'poisoned' r-value: this memory has not yet been written to, so the\n    r-value is meaningless.\n    \"\"\"\n    def __str__(self):\n        if self.loc:\n            return 'uninitialized data at %s' % self.loc\n        else:\n            return 'uninitialized data'\n\n    def get_transitions_for_function_call(self, state, stmt):\n        check_isinstance(state, State)\n        check_isinstance(stmt, gcc.GimpleCall)\n\n        class CallOfUninitializedFunctionPtr(PredictedError):\n            def __init__(self, stmt, value):\n                check_isinstance(stmt, gcc.Gimple)\n                check_isinstance(value, AbstractValue)\n                self.stmt = stmt\n                self.value = value\n\n            def __str__(self):\n                return ('call of uninitialized function pointer at %s: %s'\n                        % (self.stmt.loc, self.value))\n\n        raise CallOfUninitializedFunctionPtr(stmt, self)\n\n    def extract_from_parent(self, region, gcctype, loc):\n        return UninitializedData(gcctype, self.loc)\n\ndef make_null_ptr(gcctype, loc):\n    return ConcreteValue(gcctype, loc, 0)\n\n############################################################################\n# Various kinds of predicted error:\n############################################################################\n\nclass PredictedError(Exception):\n    pass\n\nclass InvalidlyNullParameter(PredictedError):\n    # Use this when we can predict that a function is called with NULL as an\n    # argument for an argument that must not be NULL\n    def __init__(self, fnname, paramidx, nullvalue):\n        self.fnname = fnname\n        self.paramidx = paramidx # starts at 1\n        self.nullvalue = nullvalue\n\n    def __str__(self):\n        return ('%s can be called with NULL as parameter %i; %s'\n                % (self.fnname, self.paramidx, self.nullvalue))\n\n\nclass PredictedValueError(PredictedError):\n    def __init__(self, state, expr, value, isdefinite):\n        check_isinstance(state, State)\n        check_isinstance(expr, gcc.Tree)\n        check_isinstance(value, AbstractValue)\n        self.state = state\n        self.expr = expr\n        self.value = value\n        self.isdefinite = isdefinite\n\nclass PredictedArithmeticError(PredictedError):\n    def __init__(self, err, rhsvalue, isdefinite):\n        check_isinstance(err, (ArithmeticError, ValueError))\n        self.err = err\n        self.rhsvalue = rhsvalue\n        self.isdefinite = isdefinite\n\n    def __str__(self):\n        if self.isdefinite:\n            return '%s with right-hand-side %s' % (self.err, self.rhsvalue)\n        else:\n            return 'possible %s with right-hand-side %s' % (self.err, self.rhsvalue)\n\nclass UsageOfUninitializedData(PredictedValueError):\n    def __init__(self, state, expr, value, desc):\n        check_isinstance(state, State)\n        check_isinstance(expr, gcc.Tree)\n        check_isinstance(value, AbstractValue)\n        PredictedValueError.__init__(self, state, expr, value, True)\n        check_isinstance(desc, str)\n        self.desc = desc\n\n    def __str__(self):\n        return ('%s at %s'\n                % (self.desc, self.state.stmtnode.get_stmt().loc))\n\nclass NullPtrDereference(PredictedValueError):\n    def __init__(self, state, expr, ptr, isdefinite):\n        check_isinstance(state, State)\n        check_isinstance(expr, gcc.Tree)\n        check_isinstance(expr, (gcc.ComponentRef, gcc.MemRef))\n        PredictedValueError.__init__(self, state, expr, ptr, isdefinite)\n\n    def __str__(self):\n        if self.isdefinite:\n            return ('dereferencing NULL (%s) at %s'\n                    % (self.expr, self.state.stmtnode.get_stmt().loc))\n        else:\n            return ('possibly dereferencing NULL (%s) at %s'\n                    % (self.expr, self.state.stmtnode.get_stmt().loc))\n\nclass NullPtrArgument(PredictedValueError):\n    def __init__(self, state, stmt, idx, ptr, isdefinite, why):\n        check_isinstance(state, State)\n        check_isinstance(stmt, gcc.Gimple)\n        check_isinstance(idx, int)\n        check_isinstance(ptr, AbstractValue)\n        if why is not None:\n            check_isinstance(why, str)\n        PredictedValueError.__init__(self, state, stmt.args[idx], ptr, isdefinite)\n        self.stmt = stmt\n        self.idx = idx\n        # this is a 0-based index; it is changed to a 1-based index when\n        # printed\n        self.why = why\n\n    def __str__(self):\n        if self.isdefinite:\n            return ('calling %s with NULL as argument %i (%s) at %s'\n                    % (self.stmt.fn,\n                       self.idx + 1,\n                       self.expr,\n                       self.state.stmtnode.get_stmt().loc))\n        else:\n            return ('possibly calling %s with NULL as argument %i (%s) at %s'\n                    % (self.stmt.fn,\n                       self.idx + 1,\n                       self.expr,\n                       self.state.stmtnode.get_stmt().loc))\n\n\n\nclass ReadFromDeallocatedMemory(PredictedError):\n    def __init__(self, stmt, value):\n        check_isinstance(stmt, gcc.Gimple)\n        check_isinstance(value, DeallocatedMemory)\n        self.stmt = stmt\n        self.value = value\n\n    def __str__(self):\n        return ('reading from deallocated memory at %s: %s'\n                % (self.stmt.loc, self.value))\n\nclass PassingPointerToDeallocatedMemory(PredictedError):\n    def __init__(self, argidx, fnname, stmt, value):\n        check_isinstance(stmt, gcc.Gimple)\n        check_isinstance(value, DeallocatedMemory)\n        self.argidx = argidx\n        self.fnname = fnname\n        self.stmt = stmt\n        self.value = value\n\n    def __str__(self):\n        return ('passing pointer to deallocated memory as argument %i of %s at %s: %s'\n                % (self.argidx + 1, self.fnname, self.stmt.loc, self.value))\n\n\ndef describe_stmt(stmt):\n    if isinstance(stmt, gcc.GimpleCall):\n        if isinstance(stmt.fn.operand, gcc.FunctionDecl):\n            fnname = stmt.fn.operand.name\n            return 'call to %s at line %i' % (fnname, stmt.loc.line)\n    else:\n        return str(stmt.loc)\n\nclass Region(object):\n    __slots__ = ('name', 'parent', 'children', 'fields', )\n\n    def __init__(self, name, parent):\n        self.name = name\n        self.parent = parent\n        self.children = []\n        self.fields = {}\n        if parent:\n            parent.children.append(self)\n\n    def __repr__(self):\n        return '%s(%r)' % (self.__class__.__name__, self.name)\n\n    def as_json(self):\n        m = re.match(r\"region for gcc.ParmDecl\\('(\\S+)'\\)\\.(\\S+)\", self.name)\n        if m:\n            return '%s->%s' % (m.group(1), m.group(2))\n        return self.name\n\n    def is_on_stack(self):\n        if isinstance(self, RegionOnStack):\n            return True\n        if self.parent:\n            return self.parent.is_on_stack()\n        return False\n\nclass RegionForGlobal(Region):\n    \"\"\"\n    Represents the area of memory (e.g. in .data or .bss section)\n    used to store a particular globa\n    \"\"\"\n    __slots__ = ('vardecl', )\n\n    def __init__(self, vardecl):\n        check_isinstance(vardecl, (gcc.VarDecl, gcc.FunctionDecl))\n        Region.__init__(self, vardecl.name, None)\n        self.vardecl = vardecl\n\n    def __repr__(self):\n        return 'RegionForGlobal(%r)' % self.vardecl\n\n    def as_json(self):\n        return str(self.vardecl)\n\nclass RegionOnStack(Region):\n    def __repr__(self):\n        return 'RegionOnStack(%r)' % self.name\n\n    def __str__(self):\n        return '%s on stack' % self.name\n\nclass RegionForLocal(RegionOnStack):\n    __slots__ = ('vardecl', )\n\n    def __init__(self, vardecl, stack):\n        RegionOnStack.__init__(self, 'region for %r' % vardecl, stack)\n        self.vardecl = vardecl\n\n    def as_json(self):\n        return str(self.vardecl)\n\nclass RegionForStaticLocal(RegionForGlobal):\n    # \"static\" locals work more like globals.  In particular, they're not on\n    # the stack\n    pass\n\nclass RegionOnHeap(Region):\n    \"\"\"\n    Represents an area of memory allocated on the heap\n    \"\"\"\n    __slots__ = ('alloc_stmt', )\n\n    def __init__(self, name, alloc_stmt):\n        check_isinstance(alloc_stmt, gcc.Gimple)\n        Region.__init__(self, name, None)\n        self.alloc_stmt = alloc_stmt\n\n    def __repr__(self):\n        return 'RegionOnHeap(%r, %r)' % (self.name, self.alloc_stmt.loc)\n\n    def __str__(self):\n        return '%s allocated at %s' % (self.name, self.alloc_stmt.loc)\n\n\nclass RegionForStringConstant(Region):\n    \"\"\"\n    Represents an area of memory used for string constants\n    typically allocated in the .data segment\n    \"\"\"\n    __slots__ = ('text', )\n\n    def __init__(self, text):\n        Region.__init__(self, text, None)\n        self.text = text\n\n    def as_json(self):\n        return str(repr(self.text))\n\nclass ArrayElementRegion(Region):\n    __slots__ = ('index', )\n\n    def __init__(self, name, parent, index):\n        Region.__init__(self, name, parent)\n        self.index = index\n\nclass MissingValue(Exception):\n    \"\"\"\n    The value tracking system couldn't figure out any information about the\n    given region\n    \"\"\"\n    def __init__(self, region):\n        self.region = region\n\n    def __str__(self):\n        return 'Missing value for %s' % self.region\n\nclass SplitValue(Exception):\n    \"\"\"\n    We encountered an value (e.g. UnknownValue), but we'd like to know more\n    about it.\n\n    Backtrack the analysis, splitting it into multiple possible worlds\n    with alternate abstract values for said value\n    \"\"\"\n    def __init__(self, value, altvalues, descriptions):\n        self.value = value\n        self.altvalues = altvalues\n        self.descriptions = descriptions\n\n    def __str__(self):\n        return ('Splitting:\\n%r\\ninto\\n%s'\n                % (self.value,\n                   '\\n'.join([repr(alt) for alt in self.altvalues])))\n\n    def split(self, state):\n        log('creating states for split of %s into %s', self.value, self.altvalues)\n        result = []\n        for altvalue, desc in zip(self.altvalues, self.descriptions):\n            log(' creating state for split where %s is %s', self.value, altvalue)\n            altvalue.fromsplit = True\n\n            newstate = state.copy()\n            newstate.fromsplit = True\n            for r in newstate.value_for_region:\n                # Replace instances of the value itself:\n                if newstate.value_for_region[r] is self.value:\n                    log('  replacing value for region %s with %s', r, altvalue)\n                    newstate.value_for_region[r] = altvalue\n            result.append(Transition(state,\n                                     newstate,\n                                     desc))\n        return result\n\n\nclass Facet(object):\n    \"\"\"\n    A facet of state, relating to a particular API (e.g. libc, cpython, etc)\n\n    Each facet knows which State instance it relates to, and knows how to\n    copy itself to a new State.\n\n    Potentially it can also supply \"impl_\" methods, which implement named\n    functions within the API, describing all possible transitions from the\n    current state to new states (e.g. success, failure, etc), creating\n    appropriate new States with appropriate new Facet subclass instances.\n    \"\"\"\n    __slots__ = ('state', )\n\n    def __init__(self, state):\n        check_isinstance(state, State)\n        self.state = state\n\n    def copy(self, newstate):\n        # Concrete subclasses should implement this.\n        raise NotImplementedError\n\nclass State(object):\n    \"\"\"\n    A Location with memory state, and zero or more additional \"facets\" of\n    state, one per API that we care about.\n\n    'facets' is a dict, mapping attribute names to Facet subclass.\n\n    For example, it might be:\n       {'cpython': CPython,\n        'libc': Libc,\n        'glib': GLib}\n    indicating that we expect all State instances to have a s.cpython field,\n    with a CPython instance, and a s.libc field (a Libc instance), etc.\n\n    Every State \"knows\" what all its facets are, and each Facet has a \"state\"\n    attribute recording which State instance it is part of.\n\n    For example, a CPython facet can keep track of the thread-local exception\n    status, and a Libc facet can keep track of file-descriptors, malloc\n    buffers, etc.\n\n    Hopefully this will allow checking of additional APIs to be slotted into\n    the checker, whilst keeping each API's special-case rules isolated.\n    \"\"\"\n\n    # We can't use the __slots__ optimization here, as we're adding additional\n    # per-facet attributes\n\n    def __init__(self, stmtgraph, stmtnode, lastgccloc,\n                 facets, region_for_var=None, value_for_region=None,\n                 return_rvalue=None, has_returned=False, not_returning=False):\n        check_isinstance(stmtgraph, StmtGraph)\n        check_isinstance(stmtnode, StmtNode)\n        check_isinstance(facets, dict)\n        self.stmtgraph = stmtgraph\n        self.fun = stmtgraph.fun\n        self.stmtnode = stmtnode\n        self.lastgccloc = lastgccloc\n        self.facets = facets\n\n        # Mapping from VarDecl.name to Region:\n        if region_for_var:\n            check_isinstance(region_for_var, OrderedDict)\n            self.region_for_var = region_for_var\n        else:\n            self.region_for_var = OrderedDict()\n\n        # Mapping from Region to AbstractValue:\n        if value_for_region:\n            check_isinstance(value_for_region, OrderedDict)\n            self.value_for_region = value_for_region\n        else:\n            self.value_for_region = OrderedDict()\n\n        self.return_rvalue = return_rvalue\n        self.has_returned = has_returned\n        self.not_returning = not_returning\n\n    def __str__(self):\n        return ('loc: %s region_for_var:%s value_for_region:%s'\n                % (self.stmtnode,\n                   self.region_for_var,\n                   self.value_for_region))\n\n    def __repr__(self):\n        return ('loc: %r region_for_var:%r value_for_region:%r'\n                % (self.stmtnode,\n                   self.region_for_var,\n                   self.value_for_region))\n\n    def as_str_table(self):\n        # Generate a string, displaying the data in tabular form:\n        from gccutils import Table\n        t = Table(['Expression', 'Region', 'Value'])\n        for k in self.region_for_var:\n            region = self.region_for_var[k]\n            value = self.value_for_region.get(region, None)\n            t.add_row((k, region, value),)\n        s = StringIO()\n        t.write(s)\n        return s.getvalue()\n\n    def as_json(self, desc):\n        variables = OrderedDict()\n        for k in self.region_for_var:\n            region = self.region_for_var[k]\n            value = self.value_for_region.get(region, None)\n            if value:\n                variables[region.as_json()] = value.as_json(self)\n        result = dict(location=location_as_json(self.stmtnode.get_gcc_loc()),\n                      message=desc,\n                      variables=variables)\n        return result\n\n    def log(self, logger):\n        if not logging_enabled:\n            return\n        # Display data in tabular form:\n        logger('%s', self.as_str_table())\n\n        #logger('extra: %s' % (self._extra(), ), indent)\n\n        # FIXME: derived class/extra:\n        #self.resources.log(logger, indent)\n\n        logger('loc: %s', self.stmtnode)\n        if self.stmtnode.get_stmt():\n            logger('%s', self.stmtnode.get_stmt().loc)\n\n    def copy(self):\n        s_new = State(self.stmtgraph,\n                      self.stmtnode,\n                      self.lastgccloc,\n                      self.facets,\n                      self.region_for_var.copy(),\n                      self.value_for_region.copy(),\n                      self.return_rvalue,\n                      self.has_returned,\n                      self.not_returning)\n        # Make a copy of each facet into the new state:\n        for key in self.facets:\n            facetcls = self.facets[key]\n            f_old = getattr(self, key)\n            f_new = f_old.copy(s_new)\n            setattr(s_new, key, f_new)\n        return s_new\n\n    def verify(self):\n        \"\"\"\n        Perform self-tests to ensure sanity of this State\n        \"\"\"\n        for k in self.value_for_region:\n            check_isinstance(k, Region)\n            if not isinstance(self.value_for_region[k], AbstractValue):\n                raise TypeError('value for region %r is not an AbstractValue: %r'\n                                % (k, self.value_for_region[k]))\n\n    def eval_lvalue(self, expr, loc):\n        \"\"\"\n        Return the Region for the given expression\n        \"\"\"\n        log('eval_lvalue: %r %s', expr, expr)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        if isinstance(expr, gcc.SsaName):\n            region = self.var_region(expr.var)\n            check_isinstance(region, Region)\n            return region\n        if isinstance(expr, (gcc.VarDecl, gcc.ParmDecl, gcc.ResultDecl, gcc.FunctionDecl)):\n            region = self.var_region(expr)\n            check_isinstance(region, Region)\n            return region\n        elif isinstance(expr, gcc.ArrayRef):\n            region = self.element_region(expr, loc)\n            check_isinstance(region, Region)\n            return region\n        elif isinstance(expr, gcc.ComponentRef):\n            check_isinstance(expr.field, gcc.FieldDecl)\n            return self.get_field_region(expr, loc)\n        elif isinstance(expr, gcc.StringCst):\n            region = self.string_constant_region(expr, loc)\n            check_isinstance(region, Region)\n            return region\n        elif isinstance(expr, gcc.MemRef):\n            # Write through a pointer:\n            dest_ptr = self.eval_rvalue(expr.operand, loc)\n            log('dest_ptr: %r', dest_ptr)\n            self.raise_any_null_ptr_deref(expr, dest_ptr)\n            if isinstance(dest_ptr, UnknownValue):\n                # Split into null/non-null pointers:\n                self.raise_split_value(dest_ptr)\n            check_isinstance(dest_ptr, PointerToRegion)\n            dest_region = dest_ptr.region\n            log('dest_region: %r', dest_region)\n            return dest_region\n        raise NotImplementedError('eval_lvalue: %r %s' % (expr, expr))\n\n    def eval_rvalue(self, expr, loc):\n        \"\"\"\n        Return the value for the given expression, as an AbstractValue\n        FIXME: also as a Region?\n        \"\"\"\n        log('eval_rvalue: %r %s', expr, expr)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n\n        if isinstance(expr, AbstractValue):\n            return expr\n        if isinstance(expr, Region):\n            return expr\n        if isinstance(expr, gcc.IntegerCst):\n            return ConcreteValue(expr.type, loc, expr.constant)\n        if isinstance(expr, gcc.RealCst):\n            return ConcreteValue(expr.type, loc, expr.constant)\n        if isinstance(expr, gcc.StringCst):\n            return AbstractValue(expr.type, loc)\n        if isinstance(expr, gcc.SsaName):\n            region = self.var_region(expr.var)\n            check_isinstance(region, Region)\n            value = self.get_store(region, expr.type, loc)\n            check_isinstance(value, AbstractValue)\n            return value\n        if isinstance(expr, (gcc.VarDecl, gcc.ParmDecl, gcc.ResultDecl)):\n            region = self.var_region(expr)\n            check_isinstance(region, Region)\n            value = self.get_store(region, expr.type, loc)\n            check_isinstance(value, AbstractValue)\n            return value\n            #return UnknownValue.make(expr.type, str(expr))\n        if isinstance(expr, gcc.ComponentRef):\n            #check_isinstance(expr.field, gcc.FieldDecl)\n            region = self.get_field_region(expr, loc)#.target, expr.field.name)\n            check_isinstance(region, Region)\n            log('got field region for %s: %r', expr, region)\n            try:\n                value = self.get_store(region, expr.type, loc)\n                log('got value: %r', value)\n            except MissingValue:\n                value = UnknownValue.make(expr.type, loc)\n                log('no value; using: %r', value)\n            check_isinstance(value, AbstractValue)\n            return value\n        if isinstance(expr, gcc.AddrExpr):\n            log('expr.operand: %r', expr.operand)\n            lvalue = self.eval_lvalue(expr.operand, loc)\n            check_isinstance(lvalue, Region)\n            if isinstance(expr.operand.type, gcc.ArrayType):\n                index0_lvalue = self._array_region(lvalue, 0)\n                return PointerToRegion(expr.type, loc, index0_lvalue)\n            else:\n                return PointerToRegion(expr.type, loc, lvalue)\n        if isinstance(expr, gcc.ArrayRef):\n            log('expr.array: %r', expr.array)\n            log('expr.index: %r', expr.index)\n            lvalue = self.eval_lvalue(expr, loc)\n            check_isinstance(lvalue, Region)\n            rvalue = self.get_store(lvalue, expr.type, loc)\n            check_isinstance(rvalue, AbstractValue)\n            return rvalue\n        if isinstance(expr, gcc.MemRef):\n            log('expr.operand: %r', expr.operand)\n            opvalue = self.eval_rvalue(expr.operand, loc)\n            check_isinstance(opvalue, AbstractValue)\n            log('opvalue: %r', opvalue)\n            self.raise_any_null_ptr_deref(expr, opvalue)\n            if isinstance(opvalue, UnknownValue):\n                # Split into null/non-null pointers:\n                self.raise_split_value(opvalue)\n            check_isinstance(opvalue, PointerToRegion) # FIXME\n            rvalue = self.get_store(opvalue.region, expr.type, loc)\n            check_isinstance(rvalue, AbstractValue)\n            return rvalue\n        if isinstance(expr, gcc.BitFieldRef):\n            # e.g. in 'D.2694 = BIT_FIELD_REF <*foo, 8, 0>;'\n            # for now, pessimistically assume nothing:\n            return UnknownValue.make(expr.type, loc)\n\n        raise NotImplementedError('eval_rvalue: %r %s' % (expr, expr))\n        return UnknownValue.make(expr.type, loc) # FIXME\n\n    def assign(self, lhs, rhs, loc):\n        log('assign(%r, %r)', lhs, rhs)\n        log('assign(%s, %s)', lhs, rhs)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        dest_region = self.eval_lvalue(lhs, loc)\n        log('dest_region: %s %r', dest_region, dest_region)\n        value = self.eval_rvalue(rhs, loc)\n        log('value: %s %r', value, value)\n        check_isinstance(value, AbstractValue)\n        check_isinstance(dest_region, Region)\n        self.value_for_region[dest_region] = value\n\n    def var_region(self, var):\n        check_isinstance(var, (gcc.VarDecl, gcc.ParmDecl, gcc.ResultDecl, gcc.FunctionDecl))\n        if var not in self.region_for_var:\n            # Presumably a reference to a global variable:\n            log('adding region for global var: %r', var)\n            region = RegionForGlobal(var)\n            # it is its own region:\n            self.region_for_var[var] = region\n\n            # Initialize the refcount of global PyObject instances\n            # e.g. _Py_NoneStruct to 0 i.e. we don't own any references to them\n            if str(var.type) == 'struct PyObject':\n                from libcpychecker.refcounts import RefcountValue\n                ob_refcnt = self.make_field_region(region, 'ob_refcnt') # FIXME: this should be a memref and fieldref\n                self.value_for_region[ob_refcnt] = RefcountValue.borrowed_ref(None, region)\n        return self.region_for_var[var]\n\n    def element_region(self, ar, loc):\n        log('element_region: %s', ar)\n        check_isinstance(ar, gcc.ArrayRef)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n\n        log('  ar.array: %r', ar.array)\n        log('  ar.index: %r', ar.index)\n        parent = self.eval_lvalue(ar.array, loc)\n        check_isinstance(parent, Region)\n        log('  parent: %r', parent)\n        index = self.eval_rvalue(ar.index, loc)\n        check_isinstance(index, AbstractValue)\n        log('  index: %r', index)\n        if isinstance(index, ConcreteValue):\n            index = index.value\n        return self._array_region(parent, index)\n\n    def pointer_plus_region(self, stmt):\n        # Cope with treating pointers as arrays.\n        # The constant appears to be in bytes, rather than as units of the type\n        log('pointer_add_region')\n        assert stmt.exprcode == gcc.PointerPlusExpr\n        rhs = stmt.rhs\n        a = self.eval_rvalue(rhs[0], stmt.loc)\n        b = self.eval_rvalue(rhs[1], stmt.loc)\n        log('a: %r', a)\n        log('b: %r', b)\n        if isinstance(a, PointerToRegion) and isinstance(b, ConcreteValue):\n            parent = a.region\n            log('%s', rhs[0].type)\n            log('%s', rhs[0].type.dereference)\n            t = rhs[0].type.dereference\n            if isinstance(t, gcc.VoidType):\n                index = b.value\n            else:\n                sizeof = t.sizeof\n                log('%s', sizeof)\n                index = b.value // sizeof\n            # Offset of zero? just reuse the existing pointer's region:\n            if index == 0:\n                return a.region\n            # Are we offsetting within an array?\n            if isinstance(parent, ArrayElementRegion):\n                return self._array_region(parent.parent, parent.index + index)\n            return self._array_region(parent, index)\n        else:\n            raise NotImplementedError(\"Don't know how to cope with pointer addition of\\n  %r\\nand\\n  %rat %s\"\n                                      % (a, b, stmt.loc))\n\n    def _array_region(self, parent, index):\n        # Used by element_region, and pointer_add_region\n        log('_array_region(%s, %s)', parent, index)\n        check_isinstance(parent, Region)\n        check_isinstance(index, (integer_types, UnknownValue, ConcreteValue, WithinRange))\n        if isinstance(index, ConcreteValue):\n            index = index.value\n        if index in parent.fields:\n            log('reusing')\n            return parent.fields[index]\n        log('not reusing')\n        region = ArrayElementRegion('%s[%s]' % (parent.name, index), parent, index)\n        parent.fields[index] = region\n        # it is its own region:\n        self.region_for_var[region] = region\n        return region\n\n    def get_field_region(self, cr, loc): #target, field):\n        check_isinstance(cr, gcc.ComponentRef)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        #cr.debug()\n        log('target: %r %s ', cr.target, cr.target)\n        log('field: %r', cr.field)\n        if isinstance(cr.target, gcc.MemRef):\n            ptr = self.eval_rvalue(cr.target.operand, loc) # FIXME\n            log('ptr: %r', ptr)\n            self.raise_any_null_ptr_deref(cr, ptr)\n            if isinstance(ptr, UnknownValue):\n                # It could be NULL; it could be non-NULL\n                # Split the analysis\n                # Non-NULL pointer:\n                log('splitting %s into non-NULL/NULL pointers', cr)\n                self.raise_split_value(ptr)\n            check_isinstance(ptr, PointerToRegion)\n            return self.make_field_region(ptr.region, cr.field.name)\n\n        target_region = self.eval_lvalue(cr.target, loc)\n        return self.make_field_region(target_region, cr.field.name)\n\n    def string_constant_region(self, expr, loc):\n        log('string_constant_region: %s', expr)\n        check_isinstance(expr, gcc.StringCst)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        region = RegionForStringConstant(expr.constant)\n        return region\n\n    def get_store(self, region, gcctype, loc):\n        if gcctype:\n            check_isinstance(gcctype, gcc.Type)\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        try:\n            val = self._get_store_recursive(region, gcctype, loc)\n            return val\n        except MissingValue:\n            # The first time we look up the value of a global, assign it a new\n            # \"unknown\" value:\n            if isinstance(region, RegionForGlobal):\n                newval = UnknownValue.make(region.vardecl.type, region.vardecl.location)\n                log('setting up %s for %s', newval, region.vardecl)\n                self.value_for_region[region] = newval\n                return newval\n\n            # OK: no value known:\n            return UnknownValue.make(gcctype, loc)\n\n    def summarize_array(self, r_array, v_range, gcctype, loc):\n        \"\"\"\n        Determine if the region r_array is fully populated with values\n        in the range of indices covered by v_range\n\n        If it is, return a representative value\n        \"\"\"\n        check_isinstance(r_array, Region)\n        check_isinstance(v_range, WithinRange)\n\n        v_result = EmptySet(gcctype, loc)\n\n        # (This loop should rapidly fail when the range is large and/or outside\n        # the bounds of the array)\n        for index in range(v_range.minvalue,\n                           v_range.maxvalue + 1):\n            # print 'index: %i' % index\n            if index not in r_array.fields:\n                # We have an uninitialized element:\n                return None\n            r_at_index = r_array.fields[index]\n            # print 'r_at_index: %s' % r_at_index\n            check_isinstance(r_at_index, Region)\n            v_at_index = self.value_for_region[r_at_index]\n            # print 'v_at_index: %s' % v_at_index\n            check_isinstance(v_at_index, AbstractValue)\n            v_result = v_result.union(v_at_index)\n            # print 'v_result: %s' % v_result\n\n        # Every subregion within the given range is initialized:\n        return v_result\n\n    def _get_store_recursive(self, region, gcctype, loc):\n        check_isinstance(region, Region)\n        log('_get_store_recursive(%s, %s, %s)', region, gcctype, loc)\n        if region in self.value_for_region:\n            return self.value_for_region[region]\n\n        # Not found; try default value from parent region:\n        if region.parent:\n            try:\n                parent_value = self._get_store_recursive(region.parent, gcctype, loc)\n\n                # If we're looking up within an array on the stack that has\n                # been fully initialized, then the default value from the\n                # parent is UninitializedData(), but every actual value that\n                # could be looked up is some sane value.  If we're indexing\n                # to an unknown location, don't falsely say it's unitialized:\n                if isinstance(parent_value, UninitializedData):\n                    if isinstance(region, ArrayElementRegion):\n                        if isinstance(region.index, WithinRange):\n                            v_lookup = self.summarize_array(region.parent,\n                                                            region.index,\n                                                            gcctype, loc)\n                            if v_lookup:\n                                return v_lookup\n                return parent_value.extract_from_parent(region, gcctype, loc)\n            except MissingValue:\n                raise MissingValue(region)\n\n        raise MissingValue(region)\n\n    def make_heap_region(self, name, stmt):\n        region = RegionOnHeap(name, stmt)\n        # it is its own region:\n        self.region_for_var[region] = region\n        return region\n\n    def make_field_region(self, target, field):\n        check_isinstance(target, Region)\n        if field:\n            # (field can be None for C++ destructors)\n            check_isinstance(field, str)\n        log('make_field_region(%r, %r)', target, field)\n        if field in target.fields:\n            log('reusing')\n            return target.fields[field]\n        log('not reusing')\n        region = Region('%s.%s' % (target.name, field), target)\n        target.fields[field] = region\n        # it is its own region:\n        self.region_for_var[region] = region\n        return region\n\n\n    def get_value_of_field_by_varname(self, varname, field):\n        # Lookup varname.field\n        # For use in writing selftests\n        log('get_value_of_field_by_varname(%r, %r)', varname, field)\n        check_isinstance(varname, str)\n        check_isinstance(field, str)\n        for k in self.region_for_var:\n            if isinstance(k, gcc.VarDecl):\n                if k.name == varname:\n                    region = self.region_for_var[k]\n                    region =  self.make_field_region(region, field)\n                    value = self.value_for_region.get(region, None)\n                    return value\n\n    def get_value_of_field_by_region(self, region, field):\n        \"\"\"\n        Lookup region->field, getting its AbstractValue, if any, or None\n\n        For use in writing selftests and diagnostics, as it has no\n        side-effects.\n\n        You may want to use read_field_by_name() instead\n        \"\"\"\n        log('get_value_of_field_by_region(%r, %r)', region, field)\n        check_isinstance(region, Region)\n        check_isinstance(field, str)\n        if field in region.fields:\n            field_region = region.fields[field]\n            return self.value_for_region.get(field_region, None)\n        return None\n\n    def read_field_by_name(self, stmt, gcctype, region, fieldname):\n        \"\"\"\n        Lookup region->field, getting its AbstractValue.\n\n        If the field doesn't have a value yet, if will be set to a new\n        UnknownValue so that subsequent reads of the field receive the\n        *same* unknown value\n        \"\"\"\n        log('read_field_by_name(%r, %r)', region, fieldname)\n        check_isinstance(stmt, gcc.Gimple)\n        if gcctype:\n            check_isinstance(gcctype, gcc.Type)\n        check_isinstance(region, Region)\n        check_isinstance(fieldname, str)\n\n        v_field = self.get_value_of_field_by_region(region,\n                                                    fieldname)\n        if v_field is None:\n            v_field = UnknownValue.make(gcctype, stmt.loc)\n            r_field = self.make_field_region(region,\n                                             fieldname)\n            self.value_for_region[r_field] = v_field\n\n        return v_field\n\n    def set_field_by_name(self, r_struct, fieldname, v_field):\n        r_field = self.make_field_region(r_struct, fieldname)\n        self.value_for_region[r_field] = v_field\n\n    def dereference(self, expr, v_ptr, loc):\n        check_isinstance(v_ptr, AbstractValue)\n\n        if isinstance(v_ptr, UnknownValue):\n            self.raise_split_value(v_ptr, loc)\n        self.raise_any_null_ptr_deref(expr, v_ptr)\n\n        check_isinstance(v_ptr, PointerToRegion)\n        if v_ptr.region not in self.value_for_region:\n            # Add a new UnknownValue:\n            if v_ptr.gcctype:\n                gcctype = v_ptr.gcctype.dereference\n            else:\n                gcctype = None\n            self.value_for_region[v_ptr.region] = UnknownValue.make(gcctype, loc)\n        return self.value_for_region[v_ptr.region]\n\n    def init_for_function(self, fun):\n        log('State.init_for_function(%r)', fun)\n        self.fun = fun\n        root_region = Region('root', None)\n        stack = RegionOnStack('stack for %s' % fun.decl.name, root_region)\n\n        nonnull_args = get_nonnull_arguments(fun.decl.type)\n        for idx, parm in enumerate(fun.decl.arguments):\n            def parm_is_this():\n                if idx == 0 and parm.is_artificial and parm.name == 'this':\n                    return True\n            region = RegionForLocal(parm, stack)\n            self.region_for_var[parm] = region\n            if idx in nonnull_args or parm_is_this() \\\n                    or isinstance(parm.type, gcc.ReferenceType):\n                # Make a non-NULL ptr:\n                other = Region('region-for-arg-%r' % parm, None)\n                self.region_for_var[other] = other\n                self.value_for_region[region] = PointerToRegion(parm.type, parm.location, other)\n            else:\n                self.value_for_region[region] = UnknownValue.make(parm.type, parm.location)\n        for local in fun.local_decls:\n            if local.static:\n                # Statically-allocated locals are zero-initialized before the\n                # function is called for the first time, and then preserve\n                # state between function calls\n                region = RegionForStaticLocal(local)\n\n                # For now, don't try to track all possible values a static var\n                # can take; simply treat it as an UnknownValue\n                v_local = UnknownValue.make(local.type, fun.start)\n            else:\n                region = RegionForLocal(local, stack)\n                v_local = UninitializedData(local.type, fun.start)\n            self.region_for_var[local] = region\n            self.value_for_region[region] = v_local\n\n        # Region for the gcc.ResultDecl, if any:\n        if fun.decl.result:\n            result = fun.decl.result\n            region = RegionForLocal(result, stack)\n            self.region_for_var[result] = region\n            self.value_for_region[region] = UninitializedData(result.type, fun.start)\n        self.verify()\n\n    def mktrans_assignment(self, lhs, rhs, desc):\n        \"\"\"\n        Return a Transition to a state at the next location, with the RHS\n        assigned to the LHS, if LHS is not None\n        \"\"\"\n        log('mktrans_assignment(%r, %r, %r)', lhs, rhs, desc)\n        if desc:\n            check_isinstance(desc, str)\n        new = self.use_next_stmt_node()\n        if lhs:\n            new.assign(lhs, rhs, self.stmtnode.get_gcc_loc())\n        return Transition(self, new, desc)\n\n    def update_stmt_node(self, new_stmt_node):\n        new = self.copy()\n        new.stmtnode = new_stmt_node\n        if new.stmtnode.stmt and new.stmtnode.stmt.loc:\n            new.lastgccloc = new.stmtnode.stmt.loc\n        else:\n            new.lastgccloc = self.lastgccloc\n        return new\n\n    def use_next_stmt_node(self):\n        def next_stmt_node(stmtnode):\n            if len(stmtnode.succs) != 1:\n                raise ValueError('len(stmtnode.succs) == %i at %s'\n                                 % (len(stmtnode.succs), stmtnode))\n            edge = list(stmtnode.succs)[0]\n            assert edge.srcnode == stmtnode\n            assert edge.dstnode != stmtnode\n            return edge.dstnode\n        new_stmt_node = next_stmt_node(self.stmtnode)\n        return self.update_stmt_node(new_stmt_node)\n\n    def get_gcc_loc_or_none(self):\n        # Return the gcc.Location for this state, which could be None\n        stmt = self.stmtnode.get_stmt()\n        if stmt:\n            return stmt.loc\n\n    def get_gcc_loc(self, fun):\n        # Return a non-None gcc.Location for this state\n        # Some statements have None for their location, but gcc.error() etc\n        # don't allow this.  Use the end of the function for this case.\n        stmt = self.stmtnode.get_stmt()\n        if stmt:\n            log('%s' % self.stmtnode.get_stmt().loc)\n            # grrr... not all statements have a non-NULL location\n            gccloc = self.stmtnode.get_stmt().loc\n            if gccloc is None:\n                assert self.lastgccloc\n                return self.lastgccloc\n            return gccloc\n        else:\n            return fun.end\n\n    def raise_any_null_ptr_deref(self, expr, ptr):\n        check_isinstance(expr, gcc.Tree)\n        check_isinstance(ptr, AbstractValue)\n\n        if isinstance(ptr, UninitializedData):\n            raise UsageOfUninitializedData(self, expr, ptr,\n                      'dereferencing uninitialized pointer (%s)' % expr)\n\n        if ptr.is_null_ptr():\n            # Read through NULL\n            # If we earlier split the analysis into NULL/non-NULL\n            # cases, then we're only considering the possibility\n            # that this pointer was NULL; we don't know for sure\n            # that it was.\n            isdefinite = not hasattr(ptr, 'fromsplit')\n            raise NullPtrDereference(self, expr, ptr, isdefinite)\n\n    def raise_any_null_ptr_func_arg(self, stmt, idx, ptr, why=None):\n        # idx is the 0-based index of the argument\n\n        check_isinstance(stmt, gcc.Gimple)\n        check_isinstance(idx, int)\n        check_isinstance(ptr, AbstractValue)\n        if why:\n            check_isinstance(why, str)\n        if isinstance(ptr, UnknownValue):\n            self.raise_split_value(ptr, stmt.loc)\n        if ptr.is_null_ptr():\n            # NULL argument to a function that requires non-NULL\n            # If we earlier split the analysis into NULL/non-NULL\n            # cases, then we're only considering the possibility\n            # that this pointer was NULL; we don't know for sure\n            # that it was.\n            isdefinite = not hasattr(ptr, 'fromsplit')\n            raise NullPtrArgument(self, stmt, idx, ptr, isdefinite, why)\n\n    def raise_split_value(self, ptr_rvalue, loc=None):\n        \"\"\"\n        Raise a SplitValue exception on the given rvalue, so that we can\n        backtrack and split the current state into a version with an explicit\n        NULL value and a version with a non-NULL value\n\n        FIXME: we should split into multiple non-NULL values, covering the\n        various aliasing possibilities\n        \"\"\"\n        check_isinstance(ptr_rvalue, AbstractValue)\n        check_isinstance(ptr_rvalue, UnknownValue)\n        check_isinstance(ptr_rvalue.gcctype, gcc.PointerType)\n        global region_id\n        region = Region('heap-region-%i' % region_id, None)\n        region_id += 1\n        self.region_for_var[region] = region\n        non_null_ptr = PointerToRegion(ptr_rvalue.gcctype, loc, region)\n        null_ptr = ConcreteValue(ptr_rvalue.gcctype, loc, 0)\n        raise SplitValue(ptr_rvalue,\n                         [non_null_ptr, null_ptr],\n                         [(\"when treating %s as non-NULL\" % ptr_rvalue),\n                          (\"when treating %s as NULL\" % ptr_rvalue)])\n\n    def deallocate_region(self, stmt, region):\n        # Mark the region as deallocated\n        # Since regions are shared with other states, we have to set this up\n        # for this state by assigning it with a special \"DeallocatedMemory\"\n        # value\n        # Clear the value for any fields within the region:\n        for k, v in region.fields.items():\n            if v in self.value_for_region:\n                del self.value_for_region[v]\n        # Set the default value for the whole region to be \"DeallocatedMemory\"\n        self.region_for_var[region] = region\n        self.value_for_region[region] = DeallocatedMemory(None, stmt.loc)\n\n    def get_transitions(self):\n        # Return a list of Transition instances, based on input State\n        stmt = self.stmtnode.get_stmt()\n        if stmt:\n            return self._get_transitions_for_stmt(stmt)\n        else:\n            result = []\n            for succedge in sorted(self.stmtnode.succs):\n                newstate = self.copy()\n                newstate.stmtnode = succedge.dstnode\n                result.append(Transition(self, newstate, ''))\n            log('result: %s', result)\n            return result\n\n    def _get_transitions_for_stmt(self, stmt):\n        log('_get_transitions_for_stmt: %r %s', stmt, stmt)\n        log('dir(stmt): %s', dir(stmt))\n        if stmt.loc:\n            gcc.set_location(stmt.loc)\n        if isinstance(stmt, gcc.GimpleCall):\n            return self._get_transitions_for_GimpleCall(stmt)\n        elif isinstance(stmt, (gcc.GimpleDebug, gcc.GimpleLabel,\n                               gcc.GimplePredict, gcc.GimpleNop)):\n            return [Transition(self,\n                               self.use_next_stmt_node(),\n                               None)]\n        elif isinstance(stmt, gcc.GimpleCond):\n            return self._get_transitions_for_GimpleCond(stmt)\n        elif isinstance(stmt, gcc.GimpleReturn):\n            return self._get_transitions_for_GimpleReturn(stmt)\n        elif isinstance(stmt, gcc.GimpleAssign):\n            return self._get_transitions_for_GimpleAssign(stmt)\n        elif isinstance(stmt, gcc.GimpleSwitch):\n            return self._get_transitions_for_GimpleSwitch(stmt)\n        elif isinstance(stmt, gcc.GimpleAsm):\n            return self._get_transitions_for_GimpleAsm(stmt)\n        else:\n            raise NotImplementedError(\"Don't know how to cope with %r (%s) at %s\"\n                                      % (stmt, stmt, stmt.loc))\n\n    def mkstate_nop(self, stmt):\n        \"\"\"\n        Clone this state (at a function call), updating the location, for\n        functions with \"void\" return type\n        \"\"\"\n        newstate = self.use_next_stmt_node()\n        return newstate\n\n    def mkstate_return_of(self, stmt, v_return):\n        \"\"\"\n        Clone this state (at a function call), updating the location, and\n        setting the result of the call to the given AbstractValue\n        \"\"\"\n        check_isinstance(v_return, AbstractValue)\n        newstate = self.use_next_stmt_node()\n        if stmt.lhs:\n            newstate.assign(stmt.lhs,\n                            v_return,\n                            stmt.loc)\n        return newstate\n\n    def mkstate_concrete_return_of(self, stmt, value):\n        \"\"\"\n        Clone this state (at a function call), updating the location, and\n        setting the result of the call to the given concrete value\n        \"\"\"\n        check_isinstance(value, numeric_types)\n        newstate = self.use_next_stmt_node()\n        if stmt.lhs:\n            newstate.assign(stmt.lhs,\n                            ConcreteValue(stmt.lhs.type, stmt.loc, value),\n                            stmt.loc)\n        return newstate\n\n    def mktrans_nop(self, stmt, fnname):\n        \"\"\"\n        Make a Transition for handling a function call that has no \"visible\"\n        effect within our simulation (beyond advancing to the next location).\n        [We might subsequently modify the destination state, though]\n        \"\"\"\n        newstate = self.use_next_stmt_node()\n        return Transition(self, newstate, 'calling %s()' % fnname)\n\n\n    def mktrans_not_returning(self, desc):\n        # The function being called does not return e.g. \"exit(0);\"\n        # Transition to a special noreturn state:\n        s_new = self.copy()\n        s_new.not_returning = True\n        return Transition(self, s_new, desc)\n\n    def mktrans_from_fncall_state(self, stmt, state, partialdesc, has_siblings):\n        \"\"\"\n        Given a function call here, convert a State instance into a Transition\n        instance, marking it.\n        \"\"\"\n        check_isinstance(stmt, gcc.GimpleCall)\n        check_isinstance(state, State)\n        check_isinstance(partialdesc, str)\n        fnname = stmt.fn.operand.name\n        if has_siblings:\n            desc = 'when %s() %s' % (fnname, partialdesc)\n        else:\n            desc = '%s() %s' % (fnname, partialdesc)\n        return Transition(self, state, desc)\n\n    def make_transitions_for_fncall(self, stmt, fnmeta, s_success, s_failure):\n        \"\"\"\n        Given a function call, convert a pair of State instances into a pair\n        of Transition instances, marking one as a successful call, the other\n        as a failed call.\n        \"\"\"\n        check_isinstance(stmt, gcc.GimpleCall)\n        if fnmeta:\n            check_isinstance(fnmeta, FnMeta)\n        check_isinstance(s_success, State)\n        check_isinstance(s_failure, State)\n\n        if fnmeta:\n            return [Transition(self, s_success, fnmeta.desc_when_call_succeeds()),\n                    Transition(self, s_failure, fnmeta.desc_when_call_fails())]\n        else:\n            return [Transition(self, s_success, 'when call succeeds'),\n                    Transition(self, s_failure, 'when call fails')]\n\n\n    def eval_stmt_args(self, stmt):\n        check_isinstance(stmt, gcc.GimpleCall)\n        return [self.eval_rvalue(arg, stmt.loc)\n                for arg in stmt.args]\n\n    def _get_transitions_for_GimpleCall(self, stmt):\n        log('stmt.lhs: %s %r', stmt.lhs, stmt.lhs)\n        log('stmt.fn: %s %r', stmt.fn, stmt.fn)\n        log('dir(stmt.fn): %s', dir(stmt.fn))\n        if hasattr(stmt.fn, 'operand'):\n            log('stmt.fn.operand: %s', stmt.fn.operand)\n        returntype = stmt.fn.type.dereference.type\n        log('returntype: %s', returntype)\n\n        if stmt.noreturn:\n            # The function being called does not return e.g. \"exit(0);\"\n            # Transition to a special noreturn state:\n            return [self.mktrans_not_returning('not returning from %s'\n                                               % stmt.fn)]\n\n        if isinstance(stmt.fn, (gcc.VarDecl, gcc.ParmDecl, gcc.SsaName)):\n            # Calling through a function pointer:\n            val = self.eval_rvalue(stmt.fn, stmt.loc)\n            log('val: %s',  val)\n            check_isinstance(val, AbstractValue)\n            return val.get_transitions_for_function_call(self, stmt)\n\n        # Evaluate the arguments:\n        args = self.eval_stmt_args(stmt)\n\n        # Check for uninitialized and deallocated data:\n        for i, arg in enumerate(args):\n            if isinstance(arg, UninitializedData):\n                raise UsageOfUninitializedData(self, stmt.args[i],\n                                               arg,\n                                               'passing uninitialized data (%s) as argument %i to function' % (stmt.args[i], i + 1))\n            if isinstance(arg, PointerToRegion):\n                rvalue = self.value_for_region.get(arg.region, None)\n                if isinstance(rvalue, DeallocatedMemory):\n                    raise PassingPointerToDeallocatedMemory(i, 'function', stmt, rvalue)\n\n        if isinstance(stmt.fn.operand, gcc.FunctionDecl):\n            log('dir(stmt.fn.operand): %s', dir(stmt.fn.operand))\n            log('stmt.fn.operand.name: %r', stmt.fn.operand.name)\n            fnname = stmt.fn.operand.name\n\n            # Hand off to impl_* methods of facets, where these methods exist\n            # In each case, the method should have the form:\n            #   def impl_foo(self, stmt, v_arg0, v_arg1, *args):\n            # for a C function named \"foo\" i.e. it takes \"self\", plus the\n            # gcc.GimpleCall statement, followed by the AbstractValue instances\n            # for the evaluated arguments (which for some functions will\n            # involve varargs, like above).\n            # They should return a list of Transition instances.\n            methname = 'impl_%s' % fnname\n            for key in self.facets:\n                facet = getattr(self, key)\n                if hasattr(facet, methname):\n                    meth = getattr(facet, 'impl_%s' % fnname)\n\n                    # Call the facet's method:\n                    return meth(stmt, *args)\n\n            #from libcpychecker.c_stdio import c_stdio_functions, handle_c_stdio_function\n\n            #if fnname in c_stdio_functions:\n            #    return handle_c_stdio_function(self, fnname, stmt)\n\n            if 0:\n                # For extending coverage of the Python API:\n                # Detect and complain about Python API entrypoints that\n                # weren't explicitly handled\n                if fnname.startswith('_Py') or fnname.startswith('Py'):\n                    raise NotImplementedError('not yet implemented: %s' % fnname)\n\n            # Unknown function returning (PyObject*):\n            from libcpychecker.refcounts import type_is_pyobjptr_subclass\n            if type_is_pyobjptr_subclass(stmt.fn.operand.type.type):\n                log('Invocation of unknown function returning PyObject * (or subclass): %r' % fnname)\n\n                fnmeta = FnMeta(name=fnname)\n\n                # Assume that all such functions either:\n                #   - return a new reference, or\n                #   - return NULL and set an exception (e.g. MemoryError)\n                from libcpychecker.attributes import fnnames_returning_borrowed_refs\n                if fnname in fnnames_returning_borrowed_refs:\n                    # The function being called was marked as returning a\n                    # borrowed ref, rather than a new ref:\n                    return self.apply_fncall_side_effects(\n                        self.cpython.make_transitions_for_borrowed_ref_or_fail(stmt,\n                                                                               fnmeta),\n                        stmt)\n                return self.apply_fncall_side_effects(\n                    self.cpython.make_transitions_for_new_ref_or_fail(stmt,\n                                                                      fnmeta,\n                                                                 'new ref from (unknown) %s' % fnname),\n                    stmt)\n\n            # GCC builtins:\n            if fnname == '__builtin_expect':\n                # http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html\n                # The return value of:\n                #    __builtin_expect(long exp, long c)\n                # is \"exp\" (the 0-th argument):\n                return [self.mktrans_assignment(stmt.lhs, stmt.args[0], None)]\n\n            # Unknown function of other type:\n            log('Invocation of unknown function: %r', fnname)\n            return self.apply_fncall_side_effects(\n                [self.mktrans_assignment(stmt.lhs,\n                                         UnknownValue.make(returntype, stmt.loc),\n                                         None)],\n                stmt)\n\n        log('stmt.args: %s %r', stmt.args, stmt.args)\n        for i, arg in enumerate(stmt.args):\n            log('args[%i]: %s %r', i, arg, arg)\n\n    def get_function_name(self, stmt):\n        \"\"\"\n        Try to get the function name for a gcc.GimpleCall statement as a\n        string, or None if we're unable to determine it.\n\n        For a simple function invocation this is easy, but if we're\n        calling through a function pointer we may or may not know.\n        \"\"\"\n        check_isinstance(stmt, gcc.GimpleCall)\n\n        v_fn = self.eval_rvalue(stmt.fn, stmt.loc)\n        if isinstance(v_fn, PointerToRegion):\n            if isinstance(v_fn.region, RegionForGlobal):\n                if isinstance(v_fn.region.vardecl, gcc.FunctionDecl):\n                    return v_fn.region.vardecl.name\n\n        # Unable to determine it:\n        return None\n\n    def apply_fncall_side_effects(self, transitions, stmt):\n        \"\"\"\n        Given a list of Transition instances for a call to a function with\n        unknown side-effects, modify all of the destination states.\n\n        Specifically: any pointer arguments to the function are modified in\n        the destination states to be an UnknownValue, given that the function\n        could have written an arbitrary r-value back into the input\n        \"\"\"\n        check_isinstance(transitions, list)\n        check_isinstance(stmt, gcc.GimpleCall)\n\n        args = self.eval_stmt_args(stmt)\n\n        fnname = self.get_function_name(stmt)\n\n        # cpython: handle functions marked as stealing references to their\n        # arguments:\n        from libcpychecker.attributes import stolen_refs_by_fnname\n        if fnname in stolen_refs_by_fnname:\n            for t_iter in transitions:\n                check_isinstance(t_iter, Transition)\n                for argindex in stolen_refs_by_fnname[stmt.fn.operand.name]:\n                    v_arg = args[argindex-1]\n                    if isinstance(v_arg, PointerToRegion):\n                        t_iter.dest.cpython.steal_reference(v_arg, stmt.loc)\n\n        # cpython: handle functions that have been marked as setting the\n        # exception state:\n        from libcpychecker.attributes import fnnames_setting_exception\n        if fnname in fnnames_setting_exception:\n            for t_iter in transitions:\n                # Mark the global exception state (with an arbitrary\n                # error):\n                t_iter.dest.cpython.set_exception('PyExc_MemoryError',\n                                                  stmt.loc)\n\n        # cpython: handle functions that have been marked as setting the\n        # exception state when they return a negative value:\n        from libcpychecker.attributes import fnnames_setting_exception_on_negative_result\n        if fnname in fnnames_setting_exception_on_negative_result:\n\n            def handle_negative_return(t_iter):\n                check_isinstance(t_iter, Transition)\n                check_isinstance(t_iter.src, State)\n                check_isinstance(stmt, gcc.GimpleCall)\n                if stmt.lhs:\n                    v_returnval = t_iter.dest.eval_rvalue(stmt.lhs, stmt.loc)\n                    # This could raise a SplitValue exception:\n                    # the split value affects State instances that are already\n                    # within the trace, whereas we're splitting on a new value\n                    # that only exists within a new State.\n                    # Hence we have to do this within\n                    #  process_splittable_transitions\n                    # so that we can split the new state:\n                    eqzero = v_returnval.eval_comparison(\n                        'lt',\n                        ConcreteValue.from_int(0),\n                        None)\n                    if eqzero is True:\n                        # Mark the global exception state (with an arbitrary\n                        # error):\n                        t_iter.dest.cpython.set_exception('PyExc_MemoryError',\n                                                          stmt.loc)\n\n            transitions = process_splittable_transitions(transitions,\n                                                         handle_negative_return)\n\n        for t_iter in transitions:\n            check_isinstance(t_iter, Transition)\n            for v_arg in args:\n                if isinstance(v_arg, PointerToRegion):\n                    v_newval = UnknownValue.make(v_arg.gcctype, stmt.loc)\n                    t_iter.dest.value_for_region[v_arg.region] = v_newval\n        return transitions\n\n    def _get_transitions_for_GimpleCond(self, stmt):\n        def make_transition_for_true(stmt, has_siblings):\n            e = true_edge(self.stmtnode)\n            assert e\n            nextstate = self.update_stmt_node(e.dstnode)\n            nextstate.prior_bool = True\n            if has_siblings:\n                desc = 'when taking True path'\n            else:\n                desc = 'taking True path'\n            return Transition(self, nextstate, desc)\n\n        def make_transition_for_false(stmt, has_siblings):\n            e = false_edge(self.stmtnode)\n            assert e\n            nextstate = self.update_stmt_node(e.dstnode)\n            nextstate.prior_bool = False\n            if has_siblings:\n                desc = 'when taking False path'\n            else:\n                desc = 'taking False path'\n            return Transition(self, nextstate, desc)\n\n        log('stmt.exprcode: %s', stmt.exprcode)\n        log('stmt.exprtype: %s', stmt.exprtype)\n        log('stmt.lhs: %r %s', stmt.lhs, stmt.lhs)\n        log('stmt.rhs: %r %s', stmt.rhs, stmt.rhs)\n        boolval = self.eval_condition(stmt, stmt.lhs, stmt.exprcode, stmt.rhs)\n        if boolval is True:\n            log('taking True edge')\n            nextstate = make_transition_for_true(stmt, False)\n            return [nextstate]\n        elif boolval is False:\n            log('taking False edge')\n            nextstate = make_transition_for_false(stmt, False)\n            return [nextstate]\n        else:\n            check_isinstance(boolval, UnknownValue)\n            # We don't have enough information; both branches are possible:\n            return [make_transition_for_true(stmt, True),\n                    make_transition_for_false(stmt, True)]\n\n    def eval_condition(self, stmt, expr_lhs, exprcode, expr_rhs):\n        \"\"\"\n        Evaluate a comparison, returning one of True, False, or None\n        \"\"\"\n        log('eval_condition: %s %s %s ', expr_lhs, exprcode, expr_rhs)\n        check_isinstance(expr_lhs, gcc.Tree)\n        check_isinstance(exprcode, type) # it's a type, rather than an instance\n        check_isinstance(expr_rhs, gcc.Tree)\n\n        lhs = self.eval_rvalue(expr_lhs, stmt.loc)\n        rhs = self.eval_rvalue(expr_rhs, stmt.loc)\n        check_isinstance(lhs, AbstractValue)\n        check_isinstance(rhs, AbstractValue)\n\n        # Detect usage of uninitialized data:\n        if isinstance(lhs, UninitializedData):\n            raise UsageOfUninitializedData(self, expr_lhs, lhs,\n                                           'comparison against uninitialized data (%s)' % expr_lhs)\n        if isinstance(rhs, UninitializedData):\n            raise UsageOfUninitializedData(self, expr_rhs, rhs,\n                                           'comparison against uninitialized data (%s)' % expr_rhs)\n\n        if exprcode == gcc.EqExpr:\n            result = lhs.eval_comparison('eq', rhs, expr_rhs)\n            if result is not None:\n                return result\n        elif exprcode == gcc.NeExpr:\n            result = lhs.eval_comparison('eq', rhs, expr_rhs)\n            if result is not None:\n                return not result\n        elif exprcode == gcc.LtExpr:\n            result = lhs.eval_comparison('lt', rhs, expr_rhs)\n            if result is not None:\n                return result\n        elif exprcode == gcc.LeExpr:\n            result = lhs.eval_comparison('le', rhs, expr_rhs)\n            if result is not None:\n                return result\n        elif exprcode == gcc.GeExpr:\n            result = lhs.eval_comparison('ge', rhs, expr_rhs)\n            if result is not None:\n                return result\n        elif exprcode == gcc.GtExpr:\n            result = lhs.eval_comparison('gt', rhs, expr_rhs)\n            if result is not None:\n                return result\n\n        # Specialcasing: comparison of unknown ptr with NULL:\n        if (isinstance(expr_lhs, gcc.VarDecl)\n            and isinstance(expr_rhs, gcc.IntegerCst)\n            and isinstance(expr_lhs.type, gcc.PointerType)):\n            # Split the ptr variable immediately into NULL and non-NULL\n            # versions, so that we can evaluate the true and false branch with\n            # explicitly data\n            log('splitting %s into non-NULL/NULL pointers', expr_lhs)\n            self.raise_split_value(lhs, stmt.loc)\n\n        log('unable to compare %r with %r', lhs, rhs)\n        #raise NotImplementedError(\"Don't know how to do %s comparison of %s with %s\"\n        #                          % (exprcode, lhs, rhs))\n        return UnknownValue(stmt.lhs.type, stmt.loc)\n\n    def eval_binop_args(self, stmt):\n        rhs = stmt.rhs\n        a = self.eval_rvalue(rhs[0], stmt.loc)\n        b = self.eval_rvalue(rhs[1], stmt.loc)\n        log('a: %r', a)\n        log('b: %r', b)\n        return a, b\n\n    def eval_rhs(self, stmt):\n        log('eval_rhs(%s): %s', stmt, stmt.rhs)\n        rhs = stmt.rhs\n        # Handle arithmetic and boolean expressions:\n        if stmt.exprcode in (gcc.PlusExpr, gcc.MinusExpr,  gcc.MultExpr, gcc.TruncDivExpr,\n                             gcc.TruncModExpr,\n                             gcc.RdivExpr, gcc.ExactDivExpr,\n                             gcc.MaxExpr, gcc.MinExpr,\n                             gcc.BitIorExpr, gcc.BitAndExpr, gcc.BitXorExpr,\n                             gcc.LshiftExpr, gcc.RshiftExpr,\n\n                             gcc.TruthAndExpr, gcc.TruthOrExpr\n                             ):\n            a, b = self.eval_binop_args(stmt)\n            if isinstance(a, UninitializedData):\n                raise UsageOfUninitializedData(self, stmt.rhs[0], a,\n                                               'usage of uninitialized data (%s) on left-hand side of %s'\n                                               % (stmt.rhs[0], stmt.exprcode.get_symbol()))\n            if isinstance(b, UninitializedData):\n                raise UsageOfUninitializedData(self, stmt.rhs[1], b,\n                                               'usage of uninitialized data (%s) on right-hand side of %s'\n                                               % (stmt.rhs[0], stmt.exprcode.get_symbol()))\n            try:\n                c = a.eval_binop(stmt.exprcode, b, rhs[1], stmt.lhs.type, stmt.loc)\n                check_isinstance(c, AbstractValue)\n                return c\n            except NotImplementedError:\n                return UnknownValue.make(stmt.lhs.type, stmt.loc)\n        elif stmt.exprcode == gcc.ComponentRef:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.VarDecl:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.ParmDecl:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.IntegerCst:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.RealCst:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.StringCst:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.AddrExpr:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.NopExpr:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.ArrayRef:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.MemRef:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.PointerPlusExpr:\n            try:\n                region = self.pointer_plus_region(stmt)\n                return PointerToRegion(stmt.lhs.type, stmt.loc, region)\n            except NotImplementedError:\n                return UnknownValue.make(stmt.lhs.type, stmt.loc)\n        elif stmt.exprcode in (gcc.EqExpr, gcc.NeExpr, gcc.LtExpr,\n                               gcc.LeExpr, gcc.GeExpr, gcc.GtExpr):\n            # Comparisons\n            result = self.eval_condition(stmt, rhs[0], stmt.exprcode, rhs[1])\n            if result is not None:\n                return ConcreteValue(stmt.lhs.type, stmt.loc,\n                                     1 if result else 0)\n            else:\n                return UnknownValue.make(stmt.lhs.type, stmt.loc)\n        # Unary expressions:\n        elif stmt.exprcode in (gcc.AbsExpr, gcc.BitNotExpr, gcc.ConvertExpr,\n                               gcc.NegateExpr, gcc.FixTruncExpr, gcc.FloatExpr):\n            v_rhs = self.eval_rvalue(stmt.rhs[0], stmt.loc)\n            return v_rhs.eval_unary_op(stmt.exprcode, stmt.lhs.type, stmt.loc)\n        elif stmt.exprcode == gcc.BitFieldRef:\n            return self.eval_rvalue(rhs[0], stmt.loc)\n        elif stmt.exprcode == gcc.Constructor:\n            # Default value for whole array becomes 0:\n            return ConcreteValue(stmt.lhs.type,\n                                 stmt.loc, 0)\n        else:\n            raise NotImplementedError(\"Don't know how to cope with exprcode: %r (%s) at %s\"\n                                      % (stmt.exprcode, stmt.exprcode, stmt.loc))\n\n    def _get_transitions_for_GimpleAssign(self, stmt):\n        log('stmt.lhs: %r %s', stmt.lhs, stmt.lhs)\n        log('stmt.rhs: %r %s', stmt.rhs, stmt.rhs)\n        log('stmt: %r %s', stmt, stmt)\n        log('stmt.exprcode: %r', stmt.exprcode)\n\n        value = self.eval_rhs(stmt)\n        log('value from eval_rhs: %r', value)\n        check_isinstance(value, AbstractValue)\n\n        if isinstance(value, DeallocatedMemory):\n            raise ReadFromDeallocatedMemory(stmt, value)\n\n        nextstate = self.use_next_stmt_node()\n        return [self.mktrans_assignment(stmt.lhs,\n                                        value,\n                                        None)]\n\n    def _get_transitions_for_GimpleReturn(self, stmt):\n        #log('stmt.lhs: %r %s', stmt.lhs, stmt.lhs)\n        #log('stmt.rhs: %r %s', stmt.rhs, stmt.rhs)\n        log('stmt: %r %s', stmt, stmt)\n        log('stmt.retval: %r', stmt.retval)\n\n        nextstate = self.copy()\n\n        if stmt.retval:\n            rvalue = self.eval_rvalue(stmt.retval, stmt.loc)\n            log('rvalue from eval_rvalue: %r', rvalue)\n            nextstate.return_rvalue = rvalue\n        nextstate.has_returned = True\n        return [Transition(self, nextstate, 'returning')]\n\n    def _get_transitions_for_GimpleSwitch(self, stmt):\n        def get_labels_for_rvalue(self, stmt, rvalue):\n            # Gather all possible labels for the given rvalue\n            result = []\n            for label in stmt.labels:\n                # FIXME: for now, treat all labels as possible:\n                result.append(label)\n            return result\n        log('stmt.indexvar: %r', stmt.indexvar)\n        log('stmt.labels: %r', stmt.labels)\n        indexval = self.eval_rvalue(stmt.indexvar, stmt.loc)\n        log('indexval: %r', indexval)\n        labels = get_labels_for_rvalue(self, stmt, indexval)\n        log('labels: %r', labels)\n        result = []\n        for label in labels:\n            newstate = self.copy()\n            bb = self.stmtgraph.fun.cfg.get_block_for_label(label.target)\n            newstate.stmtnode = self.stmtgraph.entry_of_bb[bb]\n            if label.low:\n                check_isinstance(label.low, gcc.IntegerCst)\n                if label.high:\n                    check_isinstance(label.high, gcc.IntegerCst)\n                    desc = 'when following cases %i...%i' % (label.low.constant, label.high.constant)\n                else:\n                    desc = 'when following case %i' % label.low.constant\n            else:\n                desc = 'when following default'\n            result.append(Transition(self,\n                                     newstate,\n                                     desc))\n        return result\n\n    def _get_transitions_for_GimpleAsm(self, stmt):\n        log('stmt: %r %s', stmt, stmt)\n\n        if stmt.string == '':\n            # Empty fragment of inline assembler:\n            s_next = self.use_next_stmt_node()\n            return [Transition(self, s_next, None)]\n\n        raise NotImplementedError('Unable to handle inline assembler: %s'\n                                  % stmt.string)\n\n    def get_persistent_refs_for_region(self, dst_region):\n        # Locate all regions containing pointers that point at the given region\n        # that are either on the heap or are globals (not locals)\n        check_isinstance(dst_region, Region)\n        result = []\n        for src_region in self.get_all_refs_for_region(dst_region):\n            if src_region.is_on_stack():\n                continue\n            result.append(src_region)\n        return result\n\n    def get_all_refs_for_region(self, dst_region):\n        # Locate all regions containing pointers that point at the given region\n        check_isinstance(dst_region, Region)\n        result = []\n        for src_region in self.value_for_region:\n            v = self.value_for_region[src_region]\n            if isinstance(v, PointerToRegion):\n                if v.region == dst_region:\n                    result.append(src_region)\n        return result\n\nregion_id = 0\n\nclass Transition(object):\n    __slots__ = ('src', # State\n                 'dest', # State\n                 'desc', # str\n                 )\n\n    def __init__(self, src, dest, desc):\n        check_isinstance(src, State)\n        check_isinstance(dest, State)\n        if desc:\n            check_isinstance(desc, str)\n        self.src = src\n        self.dest = dest\n        self.desc = desc\n\n    def __repr__(self):\n        return 'Transition(%r, %r)' % (self.dest, self.desc)\n\n    def log(self, logger):\n        logger('desc: %r' % self.desc)\n        logger('dest:')\n        self.dest.log(logger)\n\nclass Trace(object):\n    __slots__ = ('states', 'transitions', 'err', 'paths_taken')\n\n    \"\"\"A sequence of States and Transitions\"\"\"\n    def __init__(self):\n        self.states = []\n        self.transitions = []\n        self.err = None\n\n        # A list of (src gcc.StmtNode, dest gcc.StmtNode) pairs\n        self.paths_taken = []\n\n    def add(self, transition):\n        check_isinstance(transition, Transition)\n        self.states.append(transition.dest)\n        self.transitions.append(transition)\n        if transition.src.stmtnode.bb != transition.dest.stmtnode.bb:\n            self.paths_taken.append( (transition.src.stmtnode.bb,\n                                      transition.dest.stmtnode.bb) )\n        return self\n\n    def add_error(self, err):\n        self.err = err\n\n    def copy(self):\n        t = Trace()\n        t.states = self.states[:]\n        t.transitions = self.transitions[:]\n        t.err = self.err # FIXME: should this be a copy?\n        t.paths_taken = self.paths_taken[:]\n        return t\n\n    def log(self, logger, name):\n        logger('%s:' % name)\n        for i, state in enumerate(self.states):\n            logger('%i:' % i)\n            state.log(logger)\n        if self.err:\n            logger('  Trace ended with error: %s' % self.err)\n\n    def get_last_stmt(self):\n        return self.states[-1].stmtnode.get_stmt()\n\n    def return_value(self):\n        return self.states[-1].return_rvalue\n\n    def has_looped(self):\n        \"\"\"\n        Is the tail transition a path we've followed before?\n        \"\"\"\n        endstate = self.states[-1]\n        if hasattr(endstate, 'fromsplit'):\n            # We have a state that was created from a SplitValue.  It will have\n            # the same location as the state before it (before the split).\n            # Don't treat it as a loop:\n            return False\n        if endstate.not_returning:\n            # The handler not \"exit\" etc leads to a transition that has a\n            # repeated location:\n            return False\n\n        endtransition = self.transitions[-1]\n        if 0:\n            gcc.inform(endstate.get_gcc_loc(endstate.fun),\n                       ('paths_taken: %s'\n                        % (self.paths_taken,)))\n            gcc.inform(endstate.get_gcc_loc(endstate.fun),\n                       'src, loc: %s' % ((endtransition.src.loc, endtransition.dest.loc),))\n\n        # Is this a path we've followed before?\n        src_bb = endtransition.src.stmtnode.bb\n        dest_bb = endtransition.dest.stmtnode.bb\n        if src_bb != dest_bb:\n            if (src_bb, dest_bb) in self.paths_taken[0:-1]:\n                return True\n\n    def get_all_var_region_pairs(self):\n        \"\"\"\n        Get the set of all (LHS,region) pairs in region_for_var within all of\n        the states in this trace, without duplicates\n        \"\"\"\n        result = set()\n        for s_iter in self.states:\n            for var_iter, r_iter in s_iter.region_for_var.items():\n                pair = (var_iter, r_iter)\n                result.add(pair)\n        return result\n\n    def var_points_unambiguously_to(self, r_srcptr, r_dstptr):\n        \"\"\"\n        Does the source region (a pointer variable) always point to the\n        destination region (or be NULL, or uninitialized) throughout all of\n        the states in this trace?\n        \"\"\"\n        ever_had_value = False\n        #print('r_srcptr, r_dstptr: %r, %r' % (r_srcptr, r_dstptr))\n        for s_iter in self.states:\n            if r_srcptr not in s_iter.value_for_region:\n                continue\n\n            v_srcptr = s_iter.value_for_region[r_srcptr]\n            #print ('v_srcptr: %s' % v_srcptr)\n\n            # It doesn't matter if it's uninitialized, or NULL:\n            if isinstance(v_srcptr, UninitializedData):\n                continue\n            if v_srcptr.is_null_ptr():\n                continue\n            if isinstance(v_srcptr, PointerToRegion):\n                if v_srcptr.region == r_dstptr:\n                    ever_had_value = True\n                    continue\n                else:\n                    # This variable is pointing at another region at\n                    # this point within the trace:\n                    return False\n\n            # Some kind of value we weren't expecting:\n            return False\n\n        # If we get here, there was no state in which the var pointed to\n        # anything else.\n        #\n        # If it ever pointed to the region in question, then it's a good way\n        # of referring to the region:\n        return ever_had_value\n\n    def get_description_for_region(self, r_in):\n        \"\"\"\n        Try to come up with a human-readable description of the input region\n        \"\"\"\n        check_isinstance(r_in, Region)\n\n        # If a local pointer variable has just the given region as a value (as\n        # well as its initial \"uninitialized\" or NULL states), then that's a\n        # good name for this region:\n        for var_iter, r_iter in self.get_all_var_region_pairs():\n            if self.var_points_unambiguously_to(r_iter, r_in):\n                if isinstance(r_iter, (RegionForLocal, RegionForGlobal)):\n                    # Only do it for variables with names, not for temporaries:\n                    if r_iter.vardecl.name:\n                        return \"'*%s'\" % r_iter.vardecl.name\n\n        # Otherwise, just use the name of the region\n        return r_in.name\n\ndef true_edge(stmtnode):\n    for e in stmtnode.succs:\n        if e.true_value:\n            return e\n\ndef false_edge(stmtnode):\n    for e in stmtnode.succs:\n        if e.false_value:\n            return e\n\ndef process_splittable_transitions(transitions, callback):\n    \"\"\"\n    Apply a processing function to each Transition in transitions,\n    handling the case where a SplitValue exception is raised by\n    splitting the destination states.\n\n    Return a new list of Transition instances: which will be the\n    old Transition objects, potentially with additional Transition\n    instances if any have been split\n    \"\"\"\n    newtransitions = []\n    for t_iter in transitions:\n        try:\n            callback(t_iter)\n            newtransitions.append(t_iter)\n        except SplitValue:\n            err = sys.exc_info()[1]\n            splittransitions = err.split(t_iter.dest)\n            check_isinstance(splittransitions, list)\n            # Recurse:\n            newtransitions += process_splittable_transitions(splittransitions,\n                                                             callback)\n    return newtransitions\n\nclass Resources:\n    # Resource tracking for a state\n    def __init__(self):\n        # Resources that we've acquired:\n        self._acquisitions = []\n\n        # Resources that we've released:\n        self._releases = []\n\n    def copy(self):\n        new = Resources()\n        new._acquisitions = self._acquisitions[:]\n        new._releases = self._releases[:]\n        return new\n\n    def acquire(self, resource):\n        self._acquisitions.append(resource)\n\n    def release(self, resource):\n        self._releases.append(resource)\n\n    def log(self, logger):\n        logger('resources:')\n        logger('acquisitions: %s' % self._acquisitions)\n        logger('releases: %s' % self._releases)\n\nclass TooComplicated(Exception):\n    \"\"\"\n    The function is too complicated for the checker to analyze.\n\n    We have a list of Trace instances, each of which is \"complete\" in the sense\n    that it fully captures one path through the function.  However, we know\n    that the list itself is incomplete: it's not the full list of all\n    possible traces.\n    \"\"\"\n    def __init__(self, complete_traces):\n        check_isinstance(complete_traces, list)\n        self.complete_traces = complete_traces\n\nclass Limits:\n    \"\"\"\n    Resource limits, to avoid an analysis going out of control\n    \"\"\"\n    def __init__(self, maxtrans):\n        self.maxtrans = maxtrans\n        self.trans_seen = 0\n\n    def on_transition(self, transition, result):\n        \"\"\"\n        result is a list of all *complete* traces so far\n        \"\"\"\n        if 0:\n            print('%s -> %s'\n                  % (transition.src.stmtnode, transition.dest.stmtnode))\n        self.trans_seen += 1\n        if self.trans_seen > self.maxtrans:\n            raise TooComplicated(result)\n\ndef iter_traces(stmtgraph, facets, prefix=None, limits=None, depth=0):\n    \"\"\"\n    Traverse the tree of traces of program state, returning a list\n    of Trace instances.\n\n    For now, don't include any traces that contain loops, as a primitive\n    way of ensuring termination of the analysis\n\n    This is recursive, setting up a depth-first traversal of the state tree.\n    If it's interrupted by a TooComplicated exception, we should at least\n    capture an incomplete list of paths down to some of the bottoms of the\n    tree.\n    \"\"\"\n    fun = stmtgraph.fun\n    log('iter_traces(%r, %r, %r)', fun, facets, prefix)\n    if prefix is None:\n        prefix = Trace()\n        curstate = State(stmtgraph,\n                         stmtgraph.get_entry_nodes()[0],\n                         None,\n                         facets,\n                         None, None, None)\n        #Resources())\n        curstate.init_for_function(fun)\n        for key in facets:\n            facet_cls = facets[key]\n            f_new = facet_cls(curstate, fun=fun)\n            setattr(curstate, key, f_new)\n            f_new.init_for_function(fun)\n    else:\n        check_isinstance(prefix, Trace)\n        curstate = prefix.states[-1]\n\n        if curstate.has_returned:\n            # This state has returned a value (and hence terminated):\n            return [prefix]\n\n        if curstate.not_returning:\n            # This state has called \"exit\" or similar, and thus this\n            # trace should terminate:\n            return [prefix]\n\n        # Stop interpreting when you see a loop, to ensure termination:\n        if prefix.has_looped():\n            log('loop detected; stopping iteration')\n            if 0:\n                gcc.inform(curstate.get_gcc_loc(fun),\n                           'loop detected; stopping iteration')\n            # Don't return the prefix so far: it is not a complete trace\n            return []\n\n    # We need the prevstate in order to handle Phi nodes\n    if len(prefix.states) > 1:\n        prevstate = prefix.states[-2]\n    else:\n        prevstate = None\n\n    prefix.log(log, 'PREFIX')\n    log('  %s:%s', fun.decl.name, curstate.stmtnode)\n    try:\n        transitions = curstate.get_transitions()\n        check_isinstance(transitions, list)\n    except PredictedError:\n        # We're at a terminating state:\n        err = sys.exc_info()[1]\n        err.loc = prefix.get_last_stmt().loc\n        trace_with_err = prefix.copy()\n        trace_with_err.add_error(err)\n        trace_with_err.log(log, 'FINISHED TRACE WITH ERROR: %s' % err)\n        return [trace_with_err]\n    except SplitValue:\n        # Split the state up, splitting into parallel worlds with different\n        # values for the given value\n        # FIXME: this doesn't work; it thinks it's a loop :(\n        err = sys.exc_info()[1]\n        transitions = err.split(curstate)\n        check_isinstance(transitions, list)\n\n    log('transitions: %s', transitions)\n\n    if len(transitions) > 0:\n        result = []\n        for transition in transitions:\n            check_isinstance(transition, Transition)\n            transition.dest.verify()\n\n            # Potentially raise a TooComplicated exception:\n            if limits:\n                limits.on_transition(transition, result)\n\n            newprefix = prefix.copy().add(transition)\n\n            # Recurse\n            # This gives us a depth-first traversal of the state tree\n            try:\n                for trace in iter_traces(stmtgraph, facets, newprefix, limits,\n                                         depth + 1):\n                    result.append(trace)\n            except TooComplicated:\n                err = sys.exc_info()[1]\n                traces = err.complete_traces\n                traces += result\n                raise TooComplicated(traces)\n        return result\n    else:\n        # We're at a terminating state:\n        prefix.log(log, 'FINISHED TRACE')\n        return [prefix]\n\nclass StateGraph:\n    \"\"\"\n    A graph of states, representing the various routes through a function,\n    tracking state.\n\n    For now, we give up when we encounter a loop, as an easy way to ensure\n    termination of the analysis\n    \"\"\"\n    def __init__(self, fun, logger, stateclass):\n        check_isinstance(fun, gcc.Function)\n        self.fun = fun\n        self.states = []\n        self.transitions = []\n        self.stateclass = stateclass\n\n        logger('StateGraph.__init__(%r)' % fun)\n\n        # Recursively gather states:\n        initial = stateclass(Location.get_block_start(fun.cfg.entry),\n                             None, None, None,\n                             Resources(),\n                             ConcreteValue(get_PyObjectPtr(), fun.start, 0))\n        initial.init_for_function(fun)\n        self.states.append(initial)\n        self._gather_states(initial, logger)\n\n    def _gather_states(self, curstate, logger):\n        logger('  %s:%s' % (self.fun.decl.name, curstate.stmtnode))\n        try:\n            transitions = curstate.get_transitions()\n            #print transitions\n            check_isinstance(transitions, list)\n        except PredictedError:\n            # We're at a terminating state:\n            err = sys.exc_info()[1]\n            errstate = curstate.copy()\n            transition = Transition(curstate, errstate, str(err))\n            self.states.append(transition.dest)\n            self.transitions.append(transition)\n            return\n\n        logger('transitions:', 2)\n        for t in transitions:\n            t.log(logger, 3)\n\n        if len(transitions) > 0:\n            for transition in transitions:\n                # FIXME: what about loops???\n                check_isinstance(transition, Transition)\n                self.states.append(transition.dest)\n                self.transitions.append(transition)\n\n                if transition.dest.has_returned():\n                    # This state has returned a value (and hence terminated)\n                    continue\n\n                if transition.dest.not_returning():\n                    # This state has called \"exit\" or similar, and thus this\n                    # trace should terminate:\n                    continue\n\n                # Recurse:\n                self._gather_states(transition.dest, logger)\n        else:\n            # We're at a terminating state:\n            logger('FINISHED TRACE')\n\n    def get_prev_state(self, state):\n        assert state in self.states\n        for t in self.transitions:\n            if t.dest == state:\n                return t.src\n        # Not found:\n        return None\n\ndef extra_text(msg, indent):\n    sys.stderr.write('%s%s\\n' % ('  ' * indent, msg))\n\n"
  },
  {
    "path": "libcpychecker/attributes.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import check_isinstance\nfrom libcpychecker.types import register_type_object\n\n# Recorded attribute data, primed with some special-case knowledge about\n# the code that Cython and SWIG generate:\nfnnames_returning_borrowed_refs = set([\n        '__Pyx_GetStdout',\n\n        'SWIG_Python_ErrorType',\n        # returns a borrowed ref to one of the global exception objects\n\n])\n\nfnnames_setting_exception = set()\nfnnames_setting_exception_on_negative_result = set()\n\n# A dictionary mapping from fnname to set of argument indices:\nstolen_refs_by_fnname = {}\n\ndef register_our_attributes():\n    # Callback, called by the gcc.PLUGIN_ATTRIBUTES event\n\n    # Handler for __attribute__((cpychecker_returns_borrowed_ref))\n    # and #ifdef WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE\n    def attribute_callback_for_returns_borrowed_ref(*args):\n        if 0:\n            print('attribute_callback_for_returns_borrowed_ref(%r)' % args)\n        check_isinstance(args[0], gcc.FunctionDecl)\n        fnname = args[0].name\n        fnnames_returning_borrowed_refs.add(fnname)\n\n    gcc.register_attribute('cpychecker_returns_borrowed_ref',\n                           0, 0,\n                           False, False, False,\n                           attribute_callback_for_returns_borrowed_ref)\n    gcc.define_macro('WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE')\n\n    # Handler for __attribute__((cpychecker_steals_reference_to_arg(n)))\n    # and #ifdef WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE\n    def attribute_callback_for_steals_reference_to_arg(*args):\n        if 0:\n            print('attribute_callback_for_steals_reference_to_arg(%r)' % (args, ))\n        check_isinstance(args[0], gcc.FunctionDecl)\n        check_isinstance(args[1], gcc.IntegerCst)\n        fnname = args[0].name\n        argindex = int(args[1].constant)\n\n        if fnname in stolen_refs_by_fnname:\n            stolen_refs_by_fnname[fnname].add(argindex)\n        else:\n            stolen_refs_by_fnname[fnname] = set([argindex])\n\n    gcc.register_attribute('cpychecker_steals_reference_to_arg',\n                           1, 1,\n                           False, False, False,\n                           attribute_callback_for_steals_reference_to_arg)\n    gcc.define_macro('WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE')\n\n    # Handler for __attribute__((cpychecker_type_object_for_struct(type)))\n    # and #ifdef WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE\n    def attribute_callback_type_object_for_typedef(*args):\n        if 0:\n            print('attribute_callback_type_object_for_typedef(%r)' % (args, ))\n        check_isinstance(args[0], gcc.VarDecl)\n        check_isinstance(args[1], gcc.StringCst)\n        typedef_name = args[1].constant\n        register_type_object(args[0], typedef_name)\n\n    gcc.register_attribute('cpychecker_type_object_for_typedef',\n                           1, 1,\n                           False, False, False,\n                           attribute_callback_type_object_for_typedef)\n    gcc.define_macro('WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE')\n\n    # Handler for __attribute__((cpychecker_sets_exception))\n    # and #ifdef WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE\n    def attribute_callback_for_sets_exception(*args):\n        if 0:\n            print('attribute_callback_for_sets_exception(%r)' % args)\n        check_isinstance(args[0], gcc.FunctionDecl)\n        fnname = args[0].name\n        fnnames_setting_exception.add(fnname)\n\n    gcc.register_attribute('cpychecker_sets_exception',\n                           0, 0,\n                           False, False, False,\n                           attribute_callback_for_sets_exception)\n    gcc.define_macro('WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE')\n\n    # Handler for __attribute__((cpychecker_negative_result_sets_exception))\n    # and #ifdef WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE\n    def attribute_callback_for_negative_result_sets_exception(*args):\n        if 0:\n            print('attribute_callback_for_negative_result_sets_exception(%r)' % args)\n        check_isinstance(args[0], gcc.FunctionDecl)\n        fnname = args[0].name\n        fnnames_setting_exception_on_negative_result.add(fnname)\n\n    gcc.register_attribute('cpychecker_negative_result_sets_exception',\n                           0, 0,\n                           False, False, False,\n                           attribute_callback_for_negative_result_sets_exception)\n    gcc.define_macro('WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE')\n"
  },
  {
    "path": "libcpychecker/c_stdio.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Checking of C's stdio functions\n# Only partial coverage so var\nimport gcc\n\nfrom absinterp import AbstractValue, ConcreteValue, InvalidlyNullParameter\n\nclass InternalCheckerError(Exception):\n    pass\n\nclass UnrecognizedFunction(InternalCheckerError):\n    def __init__(self, fnname):\n        self.fnname = fnname\n\n    def __str__(self):\n        return 'Unrecognized function: %r' % self.fnname\n\nc_stdio_functions = [\n    'fopen',\n    'fclose',\n]\n\nclass NonNullFilePtr(AbstractValue):\n    def __init__(self, stmt):\n        self.stmt = stmt\n\n    def __str__(self):\n        return 'non-NULL (FILE*) acquired at %s' % self.stmt\n\n    def __repr__(self):\n        return 'NonNullFilePtr(%r)' % self.stmt\n\ndef handle_c_stdio_function(state, fnname, stmt):\n    if fnname == 'fopen':\n        # The \"success\" case:\n        file_ptr = NonNullFilePtr(stmt)\n        success = state.make_assignment(stmt.lhs,\n                                        file_ptr,\n                                        '%s() succeeded' % fnname)\n        success.dest.acquire(file_ptr)\n\n        # The \"failure\" case:\n        failure = state.make_assignment(stmt.lhs,\n                                        NullPtrValue(stmt),\n                                        '%s() failed' % fnname)\n\n        return [success, failure]\n    elif fnname == 'fclose':\n        expr = state.eval_expr(stmt.args[0])\n        if isinstance(expr, NonNullFilePtr):\n            result = state.make_assignment(stmt.lhs,\n                                           AbstractValue(gcc.Type.int(), stmt),\n                                           '%s() succeeded' % fnname) # FIXME errno handling!\n            result.release(expr)\n            return [result]\n        elif isinstance(expr, NullPtrValue):\n            raise InvalidlyNullParameter(fnname, 1, expr)\n        else:\n            result = state.make_assignment(stmt.lhs,\n                                           AbstractValue(gcc.Type.int(), stmt),\n                                           '%s() succeeded' % fnname) # FIXME errno handling!\n            result.dest.release(expr)\n            return [result]\n    else:\n        # We claimed to handle this function, but didn't:\n        raise UnrecognizedFunction(fnname)\n"
  },
  {
    "path": "libcpychecker/compat.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Code for handling compatibility between different GCC versions\n\nimport gcc\nimport gccutils\n\n# The checker need to be able to access global declarations for exception\n# objects, such as:\n#    PyAPI_DATA(PyObject *) PyExc_MemoryError;\n# and of type objects, such as:\n#    PyAPI_DATA(PyTypeObject) PyList_Type;\n#\n# Originally we did this using gccutils.get_global_vardecl_by_name(), which\n# walks the translation units' top-level blocks looking for gcc.VarDecl\n# Unfortunately as of GCC PR debug/51410 (in 4.7 onwards), those that aren't\n# directly referenced by the code being compiled get stripped (to condense\n# the debug data), and so we can't see them anymore.\n# However, GCC 4.7 gained a PLUGIN_FINISH_DECL event, so we can use that\n# instead to gather the decls for later use.\n#\n# See https://fedorahosted.org/gcc-python-plugin/ticket/21\n\nclass CouldNotFindVarDecl(RuntimeError):\n    def __init__(self, varname):\n        self.varname = varname\n    def __str__(self):\n        return ('could not find expected global variable %r'\n                % self.varname)\n\nif hasattr(gcc, 'PLUGIN_FINISH_DECL'):\n    # GCC 4.7 and later\n    global_exceptions = {}\n    global_typeobjs = {}\n\n    def on_finish_decl(*args):\n        # GCC 4.7 and later: callback to the PLUGIN_FINISH_DECL event\n        # print(args) # FIXME: why two args?\n\n        global global_exceptions\n        global global_typeobjs\n\n        decl = args[0]\n        if isinstance(decl, gcc.VarDecl):\n            if decl.name:\n                if decl.name.startswith('PyExc_'):\n                    global_exceptions[decl.name] = decl\n                if decl.name.endswith('_Type'):\n                    global_typeobjs[decl.name] = decl\n\n    def _get_exception_decl_by_name(exc_name):\n        return global_exceptions[exc_name]\n\n    def _get_typeobject_decl_by_name(typeobjname):\n        return global_typeobjs[typeobjname]\n\nelse:\n    # GCC 4.6 doesn't have PLUGIN_FINISH_DECL, but\n    # gccutils.get_global_vardecl_by_name() finds the declarations we need\n\n    def _get_exception_decl_by_name(exc_name):\n        return gccutils.get_global_vardecl_by_name(exc_name)\n\n    def _get_typeobject_decl_by_name(typeobjname):\n        return gccutils.get_global_vardecl_by_name(typeobjname)\n\ndef get_exception_decl_by_name(exc_name):\n    exc_decl = _get_exception_decl_by_name(exc_name)\n    if not exc_decl:\n        raise CouldNotFindVarDecl(exc_name)\n    return exc_decl\n\ndef get_typeobject_decl_by_name(typeobjname):\n    typeobjdecl = _get_typeobject_decl_by_name(typeobjname)\n    if not typeobjdecl:\n        raise CouldNotFindVarDecl(typeobjname)\n    return typeobjdecl\n"
  },
  {
    "path": "libcpychecker/diagnostics.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n\"\"\"\nError reporting interface, supporting regular GCC messages plus higher-level\nHTML visualizations, with de-duplication.\n\nGCC diagnostic messages are buffered up within Report instances and eventually\nflushed, allowing us to de-duplicate error reports.\n\"\"\"\n\nimport gcc\nfrom gccutils import get_src_for_loc, check_isinstance\nfrom libcpychecker.visualizations import HtmlRenderer\nfrom libcpychecker.utils import log\n\nclass Annotator:\n    \"\"\"\n    A collection of hooks for use when describing a trace (either as text,\n    or as an HTML report)\n\n    This allows us to add the annotations to the correct place in the textual\n    stream when reporting on flow through a function\n    \"\"\"\n    def get_notes(self, transition):\n        \"\"\"\n        Return a list of Note instances giving extra information about the\n        transition\n        \"\"\"\n        raise NotImplementedError\n\nclass TestAnnotator(Annotator):\n    \"\"\"\n    A sample annotator that adds information to the trace on movement between\n    gimple statements\n    \"\"\"\n    def get_notes(self, transition):\n        result = []\n        srcloc = transition.src.get_gcc_loc_or_none()\n        if srcloc:\n            if transition.src.loc != transition.dest.loc:\n                result.append(Note(srcloc,\n                                   ('transition from \"%s\" to \"%s\"'\n                                    % (transition.src.loc.get_stmt(),\n                                       transition.dest.loc.get_stmt()))))\n        return result\n\ndef describe_trace(trace, report, annotator):\n    \"\"\"\n    Buffer up more details about the path through the function that\n    leads to the error, using report.add_inform()\n    \"\"\"\n    awaiting_target = None\n    for t in trace.transitions:\n        log('transition: %s', t)\n        srcloc = t.src.get_gcc_loc_or_none()\n        if t.desc:\n            if srcloc:\n                report.add_inform(t.src.get_gcc_loc(report.fun),\n                                  ('%s at: %s'\n                                   % (t.desc, get_src_for_loc(srcloc))))\n            else:\n                report.add_inform(t.src.get_gcc_loc(report.fun),\n                                  '%s' % t.desc)\n\n            if t.src.stmtnode.bb != t.dest.stmtnode.bb:\n                # Tell the user where conditionals reach:\n                destloc = t.dest.get_gcc_loc_or_none()\n                if destloc:\n                    report.add_inform(destloc,\n                                      'reaching: %s' % get_src_for_loc(destloc))\n\n        if annotator:\n            notes = annotator.get_notes(t)\n            for note in notes:\n                if note.loc and note.loc == srcloc:\n                    report.add_inform(note.loc, note.msg)\n\nclass Reporter:\n    \"\"\"\n    Error-reporting interface.  Gathers information, sending it to GCC's\n    regular diagnostic interface, but also storing it for e.g. HTML dumps\n\n    Error reports can be de-duplicated by finding sufficiently similar Report\n    instances, and only fully flushing one of them within each equivalence\n    class\n    \"\"\"\n    def __init__(self):\n        self.reports = []\n        self._got_warnings = False\n\n    def make_warning(self, fun, loc, msg):\n        assert isinstance(fun, gcc.Function)\n        assert isinstance(loc, gcc.Location)\n\n        self._got_warnings = True\n\n        w = Report(fun, loc, msg)\n        self.reports.append(w)\n\n        w.add_warning(loc, msg)\n\n        return w\n\n    def make_debug_dump(self, fun, loc, msg):\n        assert isinstance(fun, gcc.Function)\n        assert isinstance(loc, gcc.Location)\n        r = Report(fun, loc, msg)\n        self.reports.append(r)\n        return r\n\n    def got_warnings(self):\n        return self._got_warnings\n\n    def to_json(self, fun):\n        result = dict(filename=fun.start.file,\n                      function=dict(name=fun.decl.name,\n                                    # line number range:\n                                    lines=(fun.decl.location.line - 1,\n                                           fun.end.line + 1)),\n                      reports=[])\n        for report in self.reports:\n            result['reports'].append(report.to_json(fun))\n        return result\n\n    def dump_json(self, fun, filename):\n        js = self.to_json(fun)\n        from json import dump, dumps\n        with open(filename, 'w') as f:\n            dump(js, f, sort_keys=True, indent=4)\n        if 0:\n            print(dumps(js, sort_keys=True, indent=4))\n\n    def to_html(self, fun):\n        # (FIXME: eliminate self.fun from HtmlRenderer and the above arg)\n        r = HtmlRenderer(fun)\n        html = r.make_header()\n        for report in self.reports:\n            html += r.make_report(report)\n        html += r.make_footer()\n        return html\n\n    def dump_html(self, fun, filename):\n        html = self.to_html(fun)\n        with open(filename, 'w') as f:\n            f.write(html)\n\n    def remove_duplicates(self):\n        \"\"\"\n        Try to organize Report instances into equivalence classes, and only\n        keep the first Report within each class\n        \"\"\"\n        for report in self.reports[:]:\n            # The report might have been removed during the iteration:\n            if report.is_duplicate:\n                continue\n            for candidate in self.reports[:]:\n                if report != candidate and not report.is_duplicate:\n                    if candidate.is_duplicate_of(report):\n                        report.add_duplicate(candidate)\n                        self.reports.remove(candidate)\n\n        # Add a note to each report that survived about any duplicates:\n        for report in self.reports:\n            if report.duplicates:\n                report.add_note(report.loc,\n                                ('found %i similar trace(s) to this'\n                                 % len(report.duplicates)))\n\n    def flush(self):\n        for r in self.reports:\n            r.flush()\n\nclass SavedDiagnostic:\n    \"\"\"\n    A saved GCC diagnostic, which we can choose to emit or suppress at a later\n    date\n    \"\"\"\n    def __init__(self, loc, msg):\n        assert isinstance(loc, gcc.Location)\n        assert isinstance(msg, str)\n        self.loc = loc\n        self.msg = msg\n\nclass SavedWarning(SavedDiagnostic):\n    def flush(self):\n        gcc.warning(self.loc, self.msg)\n\nclass SavedInform(SavedDiagnostic):\n    def flush(self):\n        gcc.inform(self.loc, self.msg)\n\nclass Report:\n    \"\"\"\n    Data about a particular bug found by the checker\n    \"\"\"\n    def __init__(self, fun, loc, msg):\n        self.fun = fun\n        self.loc = loc\n        self.msg = msg\n        self.trace = None\n        self._annotators = {}\n        self.notes = []\n        self._saved_diagnostics = [] # list of SavedDiagnostic\n\n        # De-duplication handling:\n        self.is_duplicate = False\n        self.duplicates = [] # list of Report\n\n    def add_warning(self, loc, msg):\n        # Add a gcc.warning() to the buffer of GCC diagnostics\n        self._saved_diagnostics.append(SavedWarning(loc, msg))\n\n    def add_inform(self, loc, msg):\n        # Add a gcc.inform() to the buffer of GCC diagnostics\n        self._saved_diagnostics.append(SavedInform(loc, msg))\n\n    def flush(self):\n        # Flush the buffer of GCC diagnostics\n        for d in self._saved_diagnostics:\n            d.flush()\n\n    def add_trace(self, trace, annotator=None):\n        self.trace = trace\n        self._annotators[trace] = annotator\n        describe_trace(trace, self, annotator)\n\n    def add_note(self, loc, msg):\n        \"\"\"\n        Add a note at the given location.  This is added both to\n        the buffer of GCC diagnostics, and also to a saved list that's\n        available to the HTML renderer.\n        \"\"\"\n        self.add_inform(loc, msg)\n        note = Note(loc, msg)\n        self.notes.append(note)\n        return note\n\n    def get_annotator_for_trace(self, trace):\n        return self._annotators.get(trace)\n\n    def is_duplicate_of(self, other):\n        check_isinstance(other, Report)\n\n        # Simplistic equivalence classes for now:\n        # the same function, source location, and message; everything\n        # else can be different\n        if self.fun != other.fun:\n            return False\n        if self.loc != other.loc:\n            return False\n        if self.msg != other.msg:\n            return False\n\n        return True\n\n    def add_duplicate(self, other):\n        assert not self.is_duplicate\n        self.duplicates.append(other)\n        other.is_duplicate = True\n\n    def to_json(self, fun):\n        assert self.trace\n        result = dict(message=self.msg,\n                      severity='warning', # FIXME\n                      states=[])\n        # Generate a list of (state, desc) pairs, putting the desc from the\n        # transition into source state; the final state will have an empty\n        # string\n        pairs = []\n        for t_iter in self.trace.transitions:\n            pairs.append( (t_iter.src, t_iter.desc) )\n        pairs.append( (self.trace.transitions[-1].dest, None) )\n        for i, (s_iter, desc) in enumerate(pairs):\n            result['states'].append(s_iter.as_json(desc))\n        result['notes'] = [dict(location=location_as_json(note.loc),\n                                message=note.msg)\n                           for note in self.notes]\n        return result\n\n\nclass Note:\n    \"\"\"\n    A note within a self\n    \"\"\"\n    def __init__(self, loc, msg):\n        self.loc = loc\n        self.msg = msg\n\n\ndef location_as_json(loc):\n    if loc:\n        return (dict(line=loc.line,\n                     column=loc.column),\n                dict(line=loc.line,\n                     column=loc.column))\n    else:\n        return None\n\ndef type_as_json(t):\n    if t:\n        return str(t)\n    else:\n        return None\n"
  },
  {
    "path": "libcpychecker/formatstrings.py",
    "content": "#   Copyright 2011, 2016 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2016 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport sys\n\nfrom gccutils import get_src_for_loc, get_global_typedef\n\nfrom libcpychecker.types import *\nfrom libcpychecker.utils import log\n\nconst_correctness = True\n\ndef get_char_ptr():\n    return gcc.Type.char().pointer\n\ndef get_const_char_ptr():\n    return gcc.Type.char().const_equivalent.pointer\n\ndef get_const_char_ptr_ptr():\n    if const_correctness:\n        return gcc.Type.char().const_equivalent.pointer.pointer\n    else:\n        # Allow people to be sloppy about const-correctness here:\n        return (gcc.Type.char().const_equivalent.pointer.pointer,\n                gcc.Type.char().pointer.pointer)\n\ndef get_hash_size_type(with_size_t):\n    # Was PY_SSIZE_T_CLEAN defined?\n    if with_size_t:\n        return get_Py_ssize_t()\n    else:\n        return gcc.Type.int()\n\nclass NullPointer:\n    # Dummy value, for pointer arguments that can legitimately be NULL\n    def describe(self):\n        return 'NULL'\n\nclass CExtensionWarning(Exception):\n    # Base class for warnings discovered by static analysis in C extension code\n    pass\n\nclass FormatStringWarning(CExtensionWarning):\n    def __init__(self, fmt_string):\n        self.fmt_string = fmt_string\n\n    def emit_as_warning(self, loc):\n        if gcc.warning(loc, str(self)):\n            sys.stderr.write(self.extra_info())\n\n    def extra_info(self):\n        return \"\"\n\nclass UnknownFormatChar(FormatStringWarning):\n    def __init__(self, fmt_string, ch):\n        FormatStringWarning.__init__(self, fmt_string)\n        self.ch = ch\n\n    def __str__(self):\n        return \"unknown format char in \\\"%s\\\": '%s'\" % (self.fmt_string, self.ch)\n\nclass UnhandledCode(UnknownFormatChar):\n    def __str__(self):\n        return \"unhandled format code in \\\"%s\\\": '%s' (FIXME)\" % (self.fmt_string, self.ch)\n\n\nclass MismatchedParentheses(FormatStringWarning):\n    def __str__(self):\n        return \"mismatched parentheses in format string \\\"%s\\\"\" % (self.fmt_string, )\n\nclass ParsedFormatStringWarning(FormatStringWarning):\n    def __init__(self, funcname, fmt):\n        FormatStringWarning.__init__(self, fmt.fmt_string)\n        self.funcname = funcname\n        self.fmt = fmt\n\nclass FormatUnit:\n    \"\"\"\n    One fragment of the string arg to PyArg_ParseTuple and friends\n    \"\"\"\n    def __init__(self, code):\n        self.code = code\n\n    def get_expected_types(self):\n        # Return a list of the types expected for this format unit,\n        # either as gcc.Type instances, or as instances of AwkwardType\n        raise NotImplementedError\n\nclass ConcreteUnit(FormatUnit):\n    \"\"\"\n    The common case: a fragment of a format string that corresponds to a\n    pre-determined list of types (often just a single element)\n    \"\"\"\n    def __init__(self, code, expected_types):\n        FormatUnit.__init__(self, code)\n        self.expected_types = expected_types\n\n    def get_expected_types(self):\n        return self.expected_types\n\n    def __repr__(self):\n        return 'ConcreteUnit(%r,%r)' % (self.code, self.expected_types)\n\nclass AwkwardType:\n    \"\"\"\n    Base class for expected types within a format unit that need special\n    handling (e.g. for \"O!\" and \"O&\")\n    \"\"\"\n    def is_compatible(self, actual_type, actual_arg):\n        raise NotImplementedError\n\n    def describe(self):\n        raise NotImplementedError\n\nclass ParsedFormatString:\n    \"\"\"\n    Python class representing the result of parsing a format string\n    \"\"\"\n    def __init__(self, fmt_string):\n        self.fmt_string = fmt_string\n        self.args = []\n\n    def __repr__(self):\n        return ('%s(fmt_string=%r, args=%r)'\n                % (self.__class__.__name__, self.fmt_string, self.args))\n\nclass WrongNumberOfVars(ParsedFormatStringWarning):\n    def __init__(self, funcname, fmt, varargs):\n        ParsedFormatStringWarning.__init__(self, funcname, fmt)\n        self.varargs = varargs\n\n    def __str__(self):\n        return ('%s in call to %s with format string \"%s\"'\n                % (self._get_desc_prefix(),\n                   self.funcname,\n                   self.fmt.fmt_string))\n\n    def extra_info(self):\n        result = ('  expected %i extra arguments:\\n'\n                  % self.fmt.num_expected())\n        for (arg, exp_type) in self.fmt.iter_exp_types():\n            result += '    %s\\n' % describe_type(exp_type)\n        if len(self.varargs) == 0:\n            result += '  but got none\\n'\n        else:\n            result += '  but got %i:\\n' % len(self.varargs)\n        for arg in self.varargs:\n            result += '    %s\\n' % describe_type(arg.type)\n        return result\n\n    def _get_desc_prefix(self):\n        raise NotImplementedError\n\nclass NotEnoughVars(WrongNumberOfVars):\n    def _get_desc_prefix(self):\n        return 'Not enough arguments'\n\nclass TooManyVars(WrongNumberOfVars):\n    def _get_desc_prefix(self):\n        return 'Too many arguments'\n\nclass MismatchingType(ParsedFormatStringWarning):\n    def __init__(self, funcname, fmt, arg_num, arg_fmt_string, exp_type, vararg):\n        super(self.__class__, self).__init__(funcname, fmt)\n        self.arg_num = arg_num\n        self.arg_fmt_string = arg_fmt_string\n        self.exp_type = exp_type\n        self.vararg = vararg\n\n    def extra_info(self):\n        def _describe_vararg(va):\n            result = '\"%s\"' % va.type\n            if hasattr(va, 'operand'):\n                result += describe_precision(va.operand.type)\n            return result\n\n        return ('  argument %i (\"%s\") had type\\n'\n                '    %s\\n'\n                '  but was expecting\\n'\n                '    %s\\n'\n                '  for format code \"%s\"\\n'\n                % (self.arg_num, self.vararg, describe_type(self.vararg.type),\n                   describe_type(self.exp_type), self.arg_fmt_string))\n\n    def __str__(self):\n        return ('Mismatching type in call to %s with format code \"%s\"'\n                % (self.funcname, self.fmt.fmt_string))\n\ndef describe_precision(t):\n    if hasattr(t, 'precision'):\n        return ' (pointing to %i bits)' % t.precision\n    else:\n        return ''\n\ndef describe_type(t):\n    if isinstance(t, AwkwardType):\n        return t.describe()\n    if isinstance(t, NullPointer):\n        return t.describe()\n    if isinstance(t, tuple):\n        result = 'one of ' + ' or '.join([describe_type(tp) for tp in t])\n    else:\n        # Special-case handling of function types, to avoid embedding the ID:\n        #   c.f. void (*<T792>) (void)\n        if isinstance(t, gcc.PointerType):\n            if isinstance(t.dereference, gcc.FunctionType):\n                signature = t.dereference\n                return ('\"%s (*fn) (%s)\"' %\n                        (signature.type,\n                         ', '.join([str(argtype)\n                                    for argtype in signature.argument_types])))\n        result = '\"%s\"' % t\n    if hasattr(t, 'dereference'):\n        result += describe_precision(t.dereference)\n    return result\n\ndef compatible_type(exp_type, actual_type, actualarg=None):\n    log('comparing exp_type: %s (%r) with actual_type: %s (%r)', exp_type, exp_type, actual_type, actual_type)\n    log('type(exp_type): %r %s', type(exp_type), type(exp_type))\n    log('actualarg: %s (%r)', actualarg, actualarg)\n\n    # Support exp_type being actually a tuple of expected types (we need this\n    # for \"S\" and \"U\"):\n    if isinstance(exp_type, tuple):\n        for exp in exp_type:\n            if compatible_type(exp, actual_type, actualarg):\n                return True\n        # Didn't match any of them:\n        return False\n\n    # Support the \"O!\" and \"O&\" converter codes:\n    if isinstance(exp_type, AwkwardType):\n        return exp_type.is_compatible(actual_type, actualarg)\n\n    # Support the codes that can accept NULL:\n    if isinstance(exp_type, NullPointer):\n        if isinstance(actual_type, gcc.PointerType):\n            if isinstance(actual_type.dereference, gcc.VoidType):\n                # We have a (void*), double-check that it's actually NULL:\n                if actualarg:\n                    if isinstance(actualarg, gcc.IntegerCst):\n                        if actualarg.constant == 0:\n                            # We have NULL:\n                            return True\n        return False\n\n    assert isinstance(exp_type, gcc.Type) or isinstance(exp_type, gcc.TypeDecl)\n    assert isinstance(actual_type, gcc.Type) or isinstance(actual_type, gcc.TypeDecl)\n\n    # Try direct comparison:\n    if actual_type == exp_type:\n        return True\n\n    # Sometimes we get the typedef rather than the type, for both exp and\n    # actual.  Compare using the actual types, but report using the typedefs\n    # so that we can report that e.g.\n    #   PyObject * *\n    # was expected, rather than:\n    #   struct PyObject * *\n    if isinstance(exp_type, gcc.TypeDecl):\n        if compatible_type(exp_type.type, actual_type):\n            return True\n\n    if isinstance(actual_type, gcc.TypeDecl):\n        if compatible_type(exp_type, actual_type.type):\n            return True\n\n    # Dereference for pointers (and ptrs to ptrs etc):\n    if isinstance(actual_type, gcc.PointerType) and isinstance(exp_type, gcc.PointerType):\n        if compatible_type(exp_type.dereference, actual_type.dereference):\n            return True\n\n    # Support (const char*) vs (char*)\n    # Somewhat counter-intuitively, the APIs that expect a char* are those that\n    # read the string data (Py_BuildValue); those that expect a const char* are\n    # those that write back a const char* value (PyArg_ParseTuple)\n    #\n    # Hence it's OK to accept a (const char*) when a (char*) was expected:\n    if str(exp_type) == 'char *':\n        if str(actual_type) == 'const char *':\n            return True\n\n    # Don't be too fussy about typedefs to integer types\n    # For instance:\n    #   typedef unsigned PY_LONG_LONG gdb_py_ulongest;\n    # gives a different IntegerType instance to that of\n    #   gcc.Type.long_long().unsigned_equivalent\n    # As long as the size, signedness etc are the same, let it go\n    if isinstance(actual_type, gcc.IntegerType) and isinstance(exp_type, gcc.IntegerType):\n        def compare_int_types():\n            for attr in ('precision', 'unsigned',\n                         'const', 'volatile', 'restrict'):\n                if getattr(actual_type, attr) != getattr(exp_type, attr):\n                    return False\n            return True\n        if compare_int_types():\n            return True\n\n    # Support character arrays vs char*:\n    if str(exp_type) == 'char *':\n        if isinstance(actual_type, gcc.PointerType):\n            if isinstance(actual_type.dereference, gcc.ArrayType):\n                if actual_type.dereference.dereference == gcc.Type.char():\n                    return True\n\n    return False\n\ndef check_pyargs(fun):\n    from libcpychecker.PyArg_ParseTuple import PyArgParseFmt\n    from libcpychecker.Py_BuildValue import PyBuildValueFmt\n\n    def get_format_string(stmt, format_idx):\n        fmt_code = stmt.args[format_idx]\n        # We can only cope with the easy case, when it's a AddrExpr(StringCst())\n        # i.e. a reference to a string constant, i.e. a string literal in the C\n        # source:\n        if isinstance(fmt_code, gcc.AddrExpr):\n            operand = fmt_code.operand\n            if isinstance(operand, gcc.StringCst):\n                return operand.constant\n\n    def check_keyword_array(stmt, idx):\n        keywords = stmt.args[idx]\n        if isinstance(keywords, gcc.AddrExpr):\n            operand = keywords.operand\n            if isinstance(operand, gcc.VarDecl):\n                # Caveat: \"initial\" will only be set up on the VarDecl of a\n                # global variable, or a \"static\" variable in function scope;\n                # for other local variables we appear to need to track the\n                # gimple statements to get the value at the callsite\n                initial = operand.initial\n                if isinstance(initial, gcc.Constructor):\n                    elements = [None] * len(initial.elements)\n                    for elt in initial.elements:\n                        (num, contents) = elt\n                        elt_idx = num.constant\n                        if isinstance(contents, gcc.NopExpr):\n                            contents = contents.operand\n                        if isinstance(contents, gcc.AddrExpr):\n                            contents = contents.operand\n                            if isinstance(contents, gcc.StringCst):\n                                elements[elt_idx] = contents.constant\n                        elif isinstance(contents, gcc.IntegerCst):\n                            elements[elt_idx] = contents.constant\n                    if elements[-1] != 0:\n                        gcc.warning(stmt.loc, 'keywords to PyArg_ParseTupleAndKeywords are not NULL-terminated')\n                    i = 0\n                    for elt in elements[0:-1]:\n                        if not elt:\n                            gcc.warning(stmt.loc, 'keyword argument %d missing in PyArg_ParseTupleAndKeywords call' % i)\n                        i = i + 1\n\n    def check_callsite(stmt, parser, funcname, format_idx, varargs_idx, with_size_t):\n        log('got call at %s', stmt.loc)\n        log(get_src_for_loc(stmt.loc))\n        # log('stmt: %r %s', (stmt, stmt))\n        # log('args: %r', stmt.args)\n        # for arg in stmt.args:\n        #    # log('  arg: %s %r', (arg, arg))\n            \n\n        # We expect the following args:\n        #   args[0]: PyObject *input_tuple\n        #   args[1]: char * format\n        #   args[2...]: output pointers\n\n        if len(stmt.args) >= format_idx:\n            fmt_string = get_format_string(stmt, format_idx)\n            if fmt_string:\n                log('fmt_string: %r', fmt_string)\n\n                loc = stmt.loc\n\n                # Figure out expected types, based on the format string...\n                try:\n                    fmt = parser.from_string(fmt_string, with_size_t)\n                except FormatStringWarning:\n                    err = sys.exc_info()[1]\n                    err.emit_as_warning(stmt.loc)\n                    return\n                log('fmt: %r', fmt.args)\n\n                exp_types = list(fmt.iter_exp_types())\n                log('exp_types: %r', exp_types)\n\n                # ...then compare them against the actual types:\n                varargs = stmt.args[varargs_idx:]\n                # log('varargs: %r', varargs)\n                if len(varargs) < len(exp_types):\n                    NotEnoughVars(funcname, fmt, varargs).emit_as_warning(loc)\n                    return\n\n                if len(varargs) > len(exp_types):\n                    TooManyVars(funcname, fmt, varargs).emit_as_warning(loc)\n                    return\n\n                for index, ((exp_arg, exp_type), vararg) in enumerate(zip(exp_types, varargs)):\n                    if not compatible_type(exp_type, vararg.type, actualarg=vararg):\n                        err = MismatchingType(funcname, fmt,\n                                              index + varargs_idx + 1,\n                                              exp_arg.code, exp_type, vararg)\n                        if hasattr(vararg, 'location'):\n                            loc = vararg.location\n                        else:\n                            loc = stmt.loc\n                        err.emit_as_warning(loc)\n\n    def maybe_check_callsite(stmt):\n        if stmt.fndecl:\n            # If \"PY_SSIZE_T_CLEAN\" is defined before #include <Python.h>, then\n            # the preprocessor is actually turning these into \"_SizeT\"-suffixed\n            # variants, which handle some format codes differently\n\n            # FIXME: should we report the name as seen by the compiler?\n            # It doesn't appear in the CPython API docs\n\n            if stmt.fndecl.name == 'PyArg_ParseTuple':\n                check_callsite(stmt,\n                               PyArgParseFmt,\n                               'PyArg_ParseTuple',\n                               1, 2, False)\n            elif stmt.fndecl.name == '_PyArg_ParseTuple_SizeT':\n                check_callsite(stmt,\n                               PyArgParseFmt,\n                               'PyArg_ParseTuple',\n                               1, 2, True)\n            elif stmt.fndecl.name == 'PyArg_Parse':\n                check_callsite(stmt,\n                               PyArgParseFmt,\n                               'PyArg_Parse',\n                               1, 2, False)\n            elif stmt.fndecl.name == '_PyArg_Parse_SizeT':\n                check_callsite(stmt,\n                               PyArgParseFmt,\n                               'PyArg_Parse',\n                               1, 2, True)\n            elif stmt.fndecl.name == 'PyArg_ParseTupleAndKeywords':\n                check_keyword_array(stmt, 3)\n                check_callsite(stmt,\n                               PyArgParseFmt,\n                               'PyArg_ParseTupleAndKeywords',\n                               2, 4, False)\n            elif stmt.fndecl.name == '_PyArg_ParseTupleAndKeywords_SizeT':\n                check_keyword_array(stmt, 3)\n                check_callsite(stmt,\n                               PyArgParseFmt,\n                               'PyArg_ParseTupleAndKeywords',\n                               2, 4, True)\n            elif stmt.fndecl.name == 'Py_BuildValue':\n                check_callsite(stmt,\n                               PyBuildValueFmt,\n                               'Py_BuildValue',\n                               0, 1, False)\n            elif stmt.fndecl.name == 'Py_BuildValue_SizeT':\n                check_callsite(stmt,\n                               PyBuildValueFmt,\n                               'Py_BuildValue',\n                               0, 1, True)\n\n    if fun.cfg:\n        for bb in fun.cfg.basic_blocks:\n            if isinstance(bb.gimple, list):\n                for stmt in bb.gimple:\n                    if stmt.loc:\n                        gcc.set_location(stmt.loc)\n                    if isinstance(stmt, gcc.GimpleCall):\n                        maybe_check_callsite(stmt)\n"
  },
  {
    "path": "libcpychecker/initializers.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verification of data initializers (e.g. PyMethodDef tables)\n\nimport gcc\n\nfrom gccutils import check_isinstance\n\nfrom libcpychecker.utils import log\n\ndef check_initializers():\n    # Invoked by the \"cpychecker-ipa\" pass, once per compilation unit\n    verify_any_PyMethodDef_flags()\n\nfrom collections import OrderedDict\nclass StructInitializer(object):\n    def __init__(self, ctor):\n        check_isinstance(ctor, gcc.Constructor)\n        self.ctor = ctor\n\n        # Mapping from string fieldname to gcc.Tree value:\n        self.fielddict = OrderedDict()\n        for key, tree in ctor.elements:\n            check_isinstance(key, gcc.FieldDecl)\n            self.fielddict[key.name] = tree\n\n    def __repr__(self):\n        attrs = ','.join(['%s=%s' % (k, v)\n                          for k, v in self.fielddict.items()])\n        return '%s(%s)' % (self.__class__.__name__, attrs)\n\n    def int_field(self, fieldname):\n        \"\"\"\n        Extract the initializer for the given field, as an int\n        \"\"\"\n        if fieldname not in self.fielddict:\n            return 0 # implicit 0\n\n        tree = self.fielddict[fieldname]\n        check_isinstance(tree, gcc.IntegerCst)\n        return tree.constant\n\n    def char_ptr_field(self, fieldname):\n        if fieldname not in self.fielddict:\n            return None # implicit NULL\n\n        tree = self.fielddict[fieldname]\n        if isinstance(tree, gcc.IntegerCst):\n            if tree.constant == 0:\n                return None # NULL\n        # go past casts:\n        if isinstance(tree, gcc.NopExpr):\n            tree = tree.operand\n        check_isinstance(tree, gcc.AddrExpr)\n        check_isinstance(tree.operand, gcc.StringCst)\n        return tree.operand.constant\n\n    def function_ptr_field(self, fieldname):\n        \"\"\"\n        Extract the initializer for the given field, as a gcc.FunctionDecl,\n        or None for NULL.\n        \"\"\"\n        if fieldname not in self.fielddict:\n            return None # implicit NULL\n\n        tree = self.fielddict[fieldname]\n\n        # go past casts:\n        if isinstance(tree, gcc.NopExpr):\n            tree = tree.operand\n        if isinstance(tree, gcc.IntegerCst):\n            if tree.constant == 0:\n                return None # NULL\n        check_isinstance(tree, gcc.AddrExpr)\n        return tree.operand\n\nclass PyMethodDefInitializer(StructInitializer):\n    def get_location(self):\n        return self.fielddict['ml_meth'].location\n\n# Adapted from Include/methodobject.h:\nMETH_OLDARGS  = 0x0000\nMETH_VARARGS  = 0x0001\nMETH_KEYWORDS = 0x0002\nMETH_NOARGS   = 0x0004\nMETH_O        = 0x0008\nMETH_CLASS    = 0x0010\nMETH_STATIC   = 0x0020\nMETH_COEXIST  = 0x0040\n\ndef verify_any_PyMethodDef_flags():\n    \"\"\"\n    Check all initializers for PyMethodDef arrays.\n    Verify that the flags used match the real signature of the callback\n    function (albeit usually cast to a PyCFunction):\n      http://docs.python.org/c-api/structures.html#PyMethodDef\n    \"\"\"\n    methods = get_all_PyMethodDef_initializers()\n    #from pprint import pprint\n    #pprint(methods)\n\n    for si in methods:\n        if 0:\n            print(si)\n        ml_meth = si.function_ptr_field('ml_meth')\n        ml_flags = si.int_field('ml_flags')\n        if 0:\n            print('  ml_meth: %r' % ml_meth)\n            print('  ml_flags: %r' % ml_flags)\n        check_isinstance(ml_flags, int)\n\n        if ml_meth is not None:\n            check_isinstance(ml_meth, gcc.FunctionDecl)\n            if ml_flags & METH_KEYWORDS:\n                expargs = 3\n                exptypemsg = 'expected ml_meth callback of type \"PyObject (fn)(someobject *, PyObject *args, PyObject *kwargs)\" due to METH_KEYWORDS flag'\n            else:\n                expargs = 2\n                exptypemsg = 'expected ml_meth callback of type \"PyObject (fn)(someobject *, PyObject *)\"'\n            actualargs = len(ml_meth.type.argument_types)\n            if expargs != actualargs:\n                gcc.warning(si.get_location(),\n                            'flags do not match callback signature for %r'\n                            ' within PyMethodDef table'\n                            % ml_meth.name)\n                gcc.inform(si.get_location(),\n                           exptypemsg + ' (%s arguments)' % expargs)\n                gcc.inform(si.get_location(),\n                           'actual type of underlying callback: %s' % ml_meth.type\n                            + ' (%s arguments)' % actualargs)\n                gcc.inform(si.get_location(),\n                           'see http://docs.python.org/c-api/structures.html#PyMethodDef')\n\ndef get_all_PyMethodDef_initializers():\n    \"\"\"\n    Locate all initializers for PyMethodDef, returning a list\n    of StructInitializer instances\n    \"\"\"\n    log('get_all_PyMethodDef_initializers')\n\n    result = []\n    vars = gcc.get_variables()\n    for var in vars:\n        if isinstance(var.decl, gcc.VarDecl):\n            if isinstance(var.decl.type, gcc.ArrayType):\n                if str(var.decl.type.type) == 'struct PyMethodDef':\n                    if var.decl.initial:\n                        table = []\n                        for idx, ctor in var.decl.initial.elements:\n                            #print idx, ctor\n                            si = PyMethodDefInitializer(ctor)\n                            table.append(si)\n                        # Warn about missing sentinel entry with\n                        #   ml->ml_name == NULL\n                        ml_name = table[-1].char_ptr_field('ml_name')\n                        if 0:\n                            print('final ml_name: %r' % ml_name)\n                        if ml_name is not None:\n                            gcc.warning(table[-1].get_location(),\n                                        'missing NULL sentinel value at end of PyMethodDef table')\n                        result += table\n    return result\n\nclass PyTypeObjectInitializer(StructInitializer):\n    pass\n\ndef get_all_PyTypeObject_initializers():\n    \"\"\"\n    Locate all initializers for PyTypeObject, returning a list\n    of PyTypeObjectInitializer instances\n    \"\"\"\n    log('get_all_PyTypeObject_initializers')\n\n    result = []\n    vars = gcc.get_variables()\n    for var in vars:\n        if isinstance(var.decl, gcc.VarDecl):\n            if str(var.decl.type) == 'struct PyTypeObject':\n                ctor = var.decl.initial\n                if ctor:\n                    si = PyTypeObjectInitializer(ctor)\n                    result.append(si)\n    return result\n"
  },
  {
    "path": "libcpychecker/refcounts.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Attempt to check that C code is implementing CPython's reference-counting\n# rules.  See:\n#   http://docs.python.org/c-api/intro.html#reference-counts\n# for a description of how such code is meant to be written\n\nimport sys\nimport gcc\n\nfrom gccutils import cfg_to_dot, invoke_dot, get_src_for_loc, check_isinstance\n\nfrom libcpychecker.absinterp import *\nfrom libcpychecker.attributes import fnnames_returning_borrowed_refs, \\\n    stolen_refs_by_fnname, fnnames_setting_exception, \\\n    fnnames_setting_exception_on_negative_result\nfrom libcpychecker.diagnostics import Reporter, Annotator, Note\nfrom libcpychecker.PyArg_ParseTuple import PyArgParseFmt, FormatStringWarning,\\\n    TypeCheckCheckerType, TypeCheckResultType, \\\n    ConverterCallbackType, ConverterResultType\nfrom libcpychecker.Py_BuildValue import PyBuildValueFmt, ObjectFormatUnit, \\\n    CodeSO, CodeN\nfrom libcpychecker.types import is_py3k, is_debug_build, get_PyObjectPtr, \\\n    get_Py_ssize_t\nfrom libcpychecker.utils import log\nfrom libcpychecker import compat\n\ndef stmt_is_assignment_to_count(stmt):\n    if hasattr(stmt, 'lhs'):\n        if stmt.lhs:\n            if isinstance(stmt.lhs, gcc.ComponentRef):\n                # print 'stmt.lhs.target: %s' % stmt.lhs.target\n                # print 'stmt.lhs.target.type: %s' % stmt.lhs.target.type\n                # (presumably we need to filter these to structs that are\n                # PyObject, or subclasses)\n                if stmt.lhs.field.name == 'ob_refcnt':\n                    return True\n\ndef type_is_pyobjptr(t):\n    assert t is None or isinstance(t, gcc.Type)\n    if str(t) == 'struct PyObject *':\n        return True\n\ndef type_is_pyobjptr_subclass(t):\n    assert t is None or isinstance(t, gcc.Type)\n    # It must be a pointer:\n    if not isinstance(t, gcc.PointerType):\n        return False\n\n    # ...to a struct:\n    if not isinstance(t.dereference, gcc.RecordType):\n        return False\n\n    # Obtain the fields of the struct/class\n    # For C++ \"fields\" will also contain a gcc.TypeDecl for the\n    # type itself, and for any nested types (e.g. typedefs), so filter them\n    # out.  This avoids an infinite recursion for classes with no data, where\n    # the initial decl of the type otherwise would make it appear that there's\n    # a nested copy of the struct inside itself.\n    fields = [field for field in t.dereference.fields\n              if isinstance(field, gcc.FieldDecl)]\n\n    if len(fields) == 0:\n        # Opaque struct: there's nothing we can do.\n        # Assume it's *not* a PyObject subclass:\n        return False\n\n    # if first field is a PyObject subclass, then we're good:\n    if type_is_pyobjptr_subclass(fields[0].type.pointer):\n        return True\n\n    fieldnames = [f.name for f in fields]\n\n    if is_py3k():\n        # For Python 3, the first field must be \"ob_base\", or it must be \"PyObject\":\n        if str(t) == 'struct PyObject *':\n            return True\n        if fieldnames[0] != 'ob_base':\n            return False\n    else:\n        # For Python 2, the first two fields must be \"ob_refcnt\" and \"ob_type\".\n        # (In a debug build, these are preceded by _ob_next and _ob_prev)\n        # FIXME: debug builds!\n        if is_debug_build():\n            if fieldnames[:4] != ['_ob_next', '_ob_prev',\n                                  'ob_refcnt', 'ob_type']:\n                return False\n        else:\n            if fieldnames[:2] != ['ob_refcnt', 'ob_type']:\n                return False\n\n    # Passed all tests:\n    return True\n\ndef stmt_is_assignment_to_objptr(stmt):\n    if hasattr(stmt, 'lhs'):\n        if stmt.lhs:\n            if type_is_pyobjptr(stmt.lhs.type):\n                return True\n\ndef stmt_is_return_of_objptr(stmt):\n    if isinstance(stmt, gcc.GimpleReturn):\n        if stmt.retval:\n            if type_is_pyobjptr(stmt.retval.type):\n                return True\n\ndef make_null_pyobject_ptr(stmt):\n    return make_null_ptr(get_PyObjectPtr(), stmt.loc)\n\n############################################################################\n# API for describing the effect of a function call, attempting to abstract\n# away the internals of the checker\n############################################################################\nclass FunctionCall:\n    # A way to describe the behaviors of a function\n    def __init__(self, s_src, stmt, fnmeta, args=None, varargs=None):\n        check_isinstance(s_src, State)\n        self.s_src = s_src\n        self.stmt = stmt\n        self.fnmeta = fnmeta\n        self.args = args\n        self.varargs = varargs\n        self._crashes_on_null_arg = []\n        self.outcomes = []\n        self._never_returns = False\n\n    def crashes_on_null_arg(self, argidx, why):\n        self._crashes_on_null_arg.append( (argidx, why) )\n\n    def never_returns(self):\n        assert self.outcomes == []\n        self._never_returns = True\n\n    def add_outcome(self, desc, s_new=None):\n        assert not self._never_returns\n        if s_new is None:\n            s_new = self.s_src.use_next_stmt_node()\n        oc_new = Outcome(self, desc, s_new)\n        self.outcomes.append(oc_new)\n        return oc_new\n\n    def always(self):\n        # For functions with a single outcome\n        return self.add_outcome('calling %s()' % self.fnmeta.name)\n\n    def can_succeed(self):\n        return self.add_outcome(self.fnmeta.desc_when_call_succeeds())\n\n    def can_fail(self):\n        return self.add_outcome(self.fnmeta.desc_when_call_fails())\n\n    def can_succeed_new_ref(self, name=None, typeobjregion=None):\n        if name is None:\n            name = 'new ref from %s()' % self.fnmeta.name\n        oc = self.add_outcome(self.fnmeta.desc_when_call_succeeds())\n        s_new, r_nonnull = self.s_src.cpython.mkstate_new_ref(self.stmt, name, typeobjregion)\n        oc.state = s_new\n        oc.returns_ptr(r_nonnull)\n        return oc\n\n    def new_ref_or_fail(self, objname=None):\n        # Return (on_success, on_failure) pair of Outcome instances\n        if objname is None:\n            objname = 'new ref from call to %s' % self.fnmeta.name\n        on_success = self.can_succeed_new_ref(objname)\n        on_failure = self.can_fail()\n        on_failure.sets_exception('PyExc_MemoryError')\n        on_failure.returns_NULL()\n        return on_success, on_failure\n\n    def get_transitions(self):\n        # Sanity-check:\n        if self.stmt.lhs:\n            for oc in self.outcomes:\n                if not oc.v_return:\n                    class OutcomeHasNoReturnValue(Exception):\n                        def __init__(self, oc):\n                            self.oc = oc\n                        def __str__(self):\n                            return '%s does not define a return value' % oc\n                    raise OutcomeHasNoReturnValue(oc)\n        # Check for null args:\n        for argidx, why in self._crashes_on_null_arg:\n            assert self.args\n            self.s_src.raise_any_null_ptr_func_arg(self.stmt, argidx,\n                                                   self.args[argidx],\n                                                   why)\n        if self._never_returns:\n            # Terminates the process; no further transitions:\n            return [self.s_src.mktrans_not_returning('calling %s() and exiting'\n                                                     % self.fnmeta.name)]\n\n        return [self._make_transition(oc)\n                for oc in self.outcomes if oc.is_possible]\n\n    def _make_transition(self, oc):\n        t_new = Transition(self.s_src, oc.state, oc.desc)\n        return t_new\n\nclass Outcome:\n    # A particular outcome of a FunctionCall\n    # Naming convention \"oc_*\" or \"on_*\" within an implementation\n    def __init__(self, fncall, desc, state):\n        check_isinstance(state, State)\n        self.fncall = fncall\n        self.desc = desc\n        self.state = state\n        self.is_possible = True\n        # Use this to ensure that the client sets up the return value:\n        self.v_return = None\n\n    def __str__(self):\n        return 'outcome %r' % self.desc\n\n    def get_stmt(self):\n        return self.fncall.stmt\n\n    def get_return_type(self):\n        return self.get_stmt().fn.type.dereference.type\n\n    def returns(self, value):\n        check_isinstance(value, numeric_types)\n        self._returns(ConcreteValue(self.get_return_type(),\n                                    self.get_stmt().loc,\n                                    value))\n    def returns_ptr(self, region):\n        check_isinstance(region, Region)\n        self._returns(PointerToRegion(self.get_return_type(),\n                                      self.get_stmt().loc,\n                                      region))\n\n    def returns_NULL(self):\n        self._returns(ConcreteValue(self.get_return_type(),\n                                    self.get_stmt().loc,\n                                    0))\n\n    def _returns(self, v_return):\n        self.v_return = v_return\n        if self.get_stmt().lhs:\n            self.state.assign(self.get_stmt().lhs,\n                              v_return,\n                              self.get_stmt().loc)\n\n    def sets_exception(self, exc_name):\n        self.state.cpython.set_exception(exc_name, self.get_stmt().loc)\n\n    def sets_exception_ptr(self, v_ptr):\n        self.state.cpython.exception_rvalue = v_ptr\n\n    def adds_external_ref(self, v_ptr):\n        if isinstance(v_ptr, PointerToRegion):\n            self.state.cpython.add_external_ref(v_ptr, self.get_stmt().loc)\n\n\n############################################################################\n\nclass RefcountValue(AbstractValue):\n    \"\"\"\n    Value for an ob_refcnt field.\n\n    'relvalue' is all of the references owned within this function.\n\n    'external' is a WithinRange, a bound on all references owned outside the\n    scope of this function.\n\n    The actual value of ob_refcnt = (relvalue + external)\n    hence:\n\n        (relvalue + external.minvalue) <= ob_refcnt <= (relvalue + external.minvalue)\n\n    Examples:\n\n      - an argument passed in a borrowed ref starts with (0, [1, 1]), in that\n      the function doesn't own any refs on it, but it has a refcount of at\n      least 1, due to refs we know nothing about.\n\n      - a newly constructed object gets (1, [0, 0]): we own a reference on it,\n      and we don't know if there are any external refs on it.\n    \"\"\"\n    __slots__ = ('r_obj', 'relvalue', 'external')\n\n    def __init__(self, loc, r_obj, relvalue, external):\n        if loc:\n            check_isinstance(loc, gcc.Location)\n        if r_obj:\n            check_isinstance(r_obj, Region)\n        check_isinstance(external, WithinRange)\n        AbstractValue.__init__(self, get_Py_ssize_t().type, loc)\n        self.r_obj = r_obj\n        self.relvalue = relvalue\n        self.external = external\n\n    @classmethod\n    def new_ref(cls, loc, r_obj):\n        return RefcountValue(loc, r_obj,\n                             relvalue=1,\n                             external=WithinRange(get_Py_ssize_t().type, loc,\n                                                  0, 0))\n\n    @classmethod\n    def borrowed_ref(cls, loc, r_obj):\n        return RefcountValue(loc, r_obj,\n                             relvalue=0,\n                             external=WithinRange(get_Py_ssize_t().type, loc,\n                                                  1, 1))\n\n    def get_min_value(self):\n        return self.relvalue + self.external.minvalue\n\n    def __str__(self):\n        # Try to present the simplest possible string representation of\n        # a refcount:\n        if self.external.minvalue == self.external.maxvalue:\n            # Known value for external refcount\n            if self.external.minvalue == 0:\n                # We know there are no external refs; don't display it\n                # at all, rather than \"0\":\n                return 'refs: %i owned' % self.relvalue\n            else:\n                # We know of an exact number of external refs; display\n                # it as borrowed:\n                return ('refs: %i owned, %i borrowed'\n                        % (self.relvalue, self.external.minvalue))\n        return ('refs: %i owned + B borrowed where %s'\n                % (self.relvalue, str(self.external).replace('val', 'B')))\n\n    def __repr__(self):\n        return 'RefcountValue(%i, %r)' % (self.relvalue, self.external)\n\n    def get_referrers_as_json(self, state):\n        # FIXME:\n        # Get a list of Regions holding pointers that:\n        #   (a) point at the object for this value, and\n        #   (b) ought to contribute to this ob_refcnt's relvalue\n        exp_refs = []\n        v_return = state.return_rvalue\n        if v_return:\n            if (isinstance(v_return, PointerToRegion)\n                and v_return.region == self.r_obj):\n\n                # The return value points at this obj:\n                if state.fun.decl.name not in fnnames_returning_borrowed_refs:\n                    # ...and this function has not been marked as returning a\n                    # borrowed reference: it returns a new one:\n                    exp_refs = ['return value']\n\n        exp_refs += [ref.as_json()\n                     for ref in state.get_persistent_refs_for_region(self.r_obj)]\n        return exp_refs\n\n    def json_fields(self, state):\n        actual = OrderedDict(refs_we_own=self.relvalue,\n                             lower_bound_of_other_refs=self.external.minvalue)\n        exp_refs = self.get_referrers_as_json(state)\n        expected = dict(pointers_to_this=exp_refs)\n        return dict(actual_ob_refcnt=actual,\n                    expected_ob_refcnt=expected)\n\n    def eval_binop(self, exprcode, rhs, rhsdesc, gcctype, loc):\n        if isinstance(rhs, ConcreteValue):\n            if exprcode == gcc.PlusExpr:\n                return RefcountValue(loc, self.r_obj,\n                                     self.relvalue + rhs.value, self.external)\n            elif exprcode == gcc.MinusExpr:\n                return RefcountValue(loc, self.r_obj,\n                                     self.relvalue - rhs.value, self.external)\n        return UnknownValue.make(gcctype, loc)\n\n    def eval_comparison(self, opname, rhs, rhsdesc):\n        \"\"\"\n        opname is a string in opnames\n        Return a boolean, or None (meaning we don't know)\n        \"\"\"\n        if opname == 'eq':\n            if isinstance(rhs, ConcreteValue):\n                log('comparing refcount value %s with concrete value: %s', self, rhs)\n                # The actual value of ob_refcnt >= lhs.relvalue\n                if self.get_min_value() > rhs.value:\n                    # (Equality is thus not possible for this case)\n                    return False\n\n        elif opname == 'le':\n            if isinstance(rhs, ConcreteValue):\n                log('comparing refcount value %s with concrete value: %s', self, rhs)\n                if self.get_min_value() > rhs.value:\n                    return False\n\n        elif opname == 'lt':\n            if isinstance(rhs, ConcreteValue):\n                log('comparing refcount value %s with concrete value: %s', self, rhs)\n                if self.get_min_value() >= rhs.value:\n                    return False\n\n        elif opname == 'ge':\n            if isinstance(rhs, ConcreteValue):\n                log('comparing refcount value %s with concrete value: %s', self, rhs)\n                if self.get_min_value() >= rhs.value:\n                    return True\n\n        elif opname == 'gt':\n            if isinstance(rhs, ConcreteValue):\n                log('comparing refcount value %s with concrete value: %s', self, rhs)\n                if self.get_min_value() > rhs.value:\n                    return True\n\n\nclass GenericTpDealloc(AbstractValue):\n    \"\"\"\n    A function pointer that points to a \"typical\" tp_dealloc callback\n    i.e. one that frees up the underlying memory\n    \"\"\"\n    def get_transitions_for_function_call(self, state, stmt):\n        check_isinstance(state, State)\n        check_isinstance(stmt, gcc.GimpleCall)\n        returntype = stmt.fn.type.dereference.type\n\n        # Mark the arg as being deallocated:\n        value = state.eval_rvalue(stmt.args[0], stmt.loc)\n\n        if value.is_null_ptr():\n            # Freeing NULL has no effect:\n            desc = 'calling tp_dealloc on NULL'\n            region = None\n        else:\n            check_isinstance(value, PointerToRegion)\n            region = value.region\n            check_isinstance(region, Region)\n            log('generic tp_dealloc called for %s', region)\n\n            # Get the description of the region before trashing it:\n            desc = 'calling tp_dealloc on %s' % region\n        result = state.mktrans_assignment(stmt.lhs,\n                                       UnknownValue.make(returntype, stmt.loc),\n                                          desc)\n        s_new = state.use_next_stmt_node()\n\n        if region is not None:\n            # Mark the region as deallocated:\n            s_new.deallocate_region(stmt, region)\n\n        return [Transition(state, s_new, desc)]\n\n\n########################################################################\n# Helper functions to generate meaningful explanations of why a NULL\n# argument is a bug:\n########################################################################\ndef invokes_Py_TYPE(fnmeta, within=None):\n    check_isinstance(fnmeta, FnMeta)\n    if within:\n        return ('%s() invokes Py_TYPE() on the pointer within %s(), thus accessing'\n                ' (NULL)->ob_type' % (fnmeta.name, within))\n    else:\n        return ('%s() invokes Py_TYPE() on the pointer, thus accessing'\n                ' (NULL)->ob_type' % fnmeta.name)\n\ndef invokes_Py_TYPE_via_macro(fnmeta, macro):\n    \"\"\"\n    Generate a descriptive message for cases of raise_any_null_ptr_func_arg()\n    such as PyDict_SetItem() which invoke the PyDict_Check() macro\n    \"\"\"\n    check_isinstance(fnmeta, FnMeta)\n    return ('%s() invokes Py_TYPE() on the pointer via the %s()'\n            ' macro, thus accessing (NULL)->ob_type' % (fnmeta.name, macro))\n\ndef invokes_Py_INCREF(fnmeta):\n    check_isinstance(fnmeta, FnMeta)\n    return ('%s() invokes Py_INCREF() on the pointer, thus accessing'\n            ' (NULL)->ob_refcnt' % fnmeta.name)\n\n########################################################################\n\nclass CPython(Facet):\n    __slots__ = ('exception_rvalue', 'has_gil',)\n\n    def __init__(self, state, exception_rvalue=None,\n                 has_gil=True, fun=None):\n        Facet.__init__(self, state)\n        check_isinstance(has_gil, bool)\n        if exception_rvalue:\n            check_isinstance(exception_rvalue, AbstractValue)\n            self.exception_rvalue = exception_rvalue\n        else:\n            check_isinstance(fun, gcc.Function)\n            self.exception_rvalue = ConcreteValue(get_PyObjectPtr(),\n                                                  fun.start,\n                                                  0)\n        self.has_gil = has_gil\n\n    def copy(self, newstate):\n        f_new = CPython(newstate,\n                        self.exception_rvalue,\n                        self.has_gil)\n        return f_new\n\n    def init_for_function(self, fun):\n        log('CPython.init_for_function(%r)', fun)\n\n        # Initialize PyObject* arguments to sane values\n        # (assume that they're non-NULL)\n        nonnull_args = get_nonnull_arguments(fun.decl.type)\n        for idx, parm in enumerate(fun.decl.arguments):\n            region = self.state.eval_lvalue(parm, None)\n            if type_is_pyobjptr_subclass(parm.type):\n                # We have a PyObject* (or a derived class)\n                log('got python obj arg: %r', region)\n                # Assume it's a non-NULL ptr:\n                objregion = RegionForLocal(parm, None)\n                self.state.region_for_var[objregion] = objregion\n                self.state.value_for_region[region] = PointerToRegion(parm.type,\n                                                                parm.location,\n                                                                objregion)\n                # Assume we have a borrowed reference:\n                ob_refcnt = self.state.make_field_region(objregion, 'ob_refcnt') # FIXME: this should be a memref and fieldref\n                self.state.value_for_region[ob_refcnt] = \\\n                    RefcountValue.borrowed_ref(parm.location,\n                                               objregion)\n\n                # Assume it has a non-NULL ob_type:\n                ob_type = self.state.make_field_region(objregion, 'ob_type')\n                typeobjregion = Region('region-for-type-of-arg-%r' % parm, None)\n                self.state.value_for_region[ob_type] = PointerToRegion(get_PyTypeObject().pointer,\n                                                                 parm.location,\n                                                                 typeobjregion)\n        self.state.verify()\n\n    def get_refcount(self, v_pyobjectptr, stmt):\n        \"\"\"\n        Get the ob_refcnt of the given PyObject*, as an AbstractValue\n        \"\"\"\n        check_isinstance(v_pyobjectptr, PointerToRegion)\n        check_isinstance(stmt, gcc.Gimple)\n        v_ob_refcnt = self.state.read_field_by_name(stmt,\n                                                    get_Py_ssize_t().type,\n                                                    v_pyobjectptr.region,\n                                                    'ob_refcnt')\n        return v_ob_refcnt\n\n    def change_refcount(self, pyobjectptr, loc, fn):\n        \"\"\"\n        Manipulate pyobjectptr's ob_refcnt.\n\n        fn is a function taking a RefcountValue instance, returning another one\n        \"\"\"\n        if isinstance(pyobjectptr, UnknownValue):\n            self.state.raise_split_value(pyobjectptr, loc)\n        check_isinstance(pyobjectptr, PointerToRegion)\n        ob_refcnt = self.state.make_field_region(pyobjectptr.region,\n                                                 'ob_refcnt')\n        check_isinstance(ob_refcnt, Region)\n        oldvalue = self.state.get_store(ob_refcnt, None, loc) # FIXME: gcctype\n        check_isinstance(oldvalue, AbstractValue)\n        log('oldvalue: %r', oldvalue)\n        # If we never had a ob_refcnt, treat it as a borrowed reference:\n        if isinstance(oldvalue, UnknownValue):\n            oldvalue = RefcountValue.borrowed_ref(loc, pyobjectptr.region)\n        check_isinstance(oldvalue, RefcountValue)\n        newvalue = fn(oldvalue)\n        log('newvalue: %r', newvalue)\n        self.state.value_for_region[ob_refcnt] = newvalue\n        return newvalue\n\n    def add_ref(self, pyobjectptr, loc):\n        \"\"\"\n        Add a \"visible\" reference to pyobjectptr's ob_refcnt i.e. a reference\n        being held by a PyObject* that we are directly tracking.\n        \"\"\"\n        def _incref_internal(oldvalue):\n            return RefcountValue(loc,\n                                 pyobjectptr.region,\n                                 oldvalue.relvalue + 1,\n                                 oldvalue.external)\n        self.change_refcount(pyobjectptr,\n                             loc,\n                             _incref_internal)\n\n    def add_external_ref(self, pyobjectptr, loc):\n        \"\"\"\n        Add an \"external\" reference to pyobjectptr's ob_refcnt i.e. a reference\n        being held by a PyObject* that we're not directly tracking.\n        \"\"\"\n        def _incref_external(oldvalue):\n            return RefcountValue(loc,\n                                 pyobjectptr.region,\n                                 oldvalue.relvalue,\n                                 WithinRange(oldvalue.external.gcctype,\n                                             loc,\n                                             oldvalue.external.minvalue + 1,\n                                             oldvalue.external.maxvalue + 1))\n        self.change_refcount(pyobjectptr,\n                             loc,\n                             _incref_external)\n\n    def dec_ref(self, pyobjectptr, loc):\n        \"\"\"\n        Remove a \"visible\" reference to pyobjectptr's ob_refcnt i.e. a\n        reference being held by a PyObject* that we are directly tracking.\n        \"\"\"\n        def _decref_internal(oldvalue):\n            return RefcountValue(loc,\n                                 pyobjectptr.region,\n                                 oldvalue.relvalue - 1,\n                                 oldvalue.external)\n        check_isinstance(pyobjectptr, PointerToRegion)\n        v_ob_refcnt = self.change_refcount(pyobjectptr,\n                                           loc,\n                                           _decref_internal)\n        # FIXME: potentially this destroys the object\n\n    def mktransitions_Py_DECREF(self, v_pyobjectptr, stmt):\n        \"\"\"\n        Generate a transitions in which the equivalent to a Py_DECREF occurs:\n        decrement ob_refcnt, and if 0, call _Py_Dealloc((PyObject *)(op))\n\n        Does *not* take you to the next statement\n        \"\"\"\n        if isinstance(v_pyobjectptr, UnknownValue):\n            self.state.raise_split_value(v_pyobjectptr, stmt.loc)\n        check_isinstance(v_pyobjectptr, PointerToRegion)\n        check_isinstance(stmt, gcc.Gimple)\n        s_new = self.state.copy()\n        s_new.cpython.dec_ref(v_pyobjectptr, stmt.loc)\n        v_ob_refcnt = s_new.cpython.get_refcount(v_pyobjectptr, stmt)\n        # print('ob_refcnt: %r' % v_ob_refcnt)\n        eq_zero = v_ob_refcnt.eval_comparison('eq', ConcreteValue.from_int(1), None)\n        # print('eq_zero: %r' % eq_zero)\n        if eq_zero or eq_zero is None:\n            # tri-state; it might be zero:\n            s_dealloc = s_new.copy()\n            # FIXME: call _Py_Dealloc\n            return [Transition(self.state,\n                               s_new,\n                               'Py_DECREF() without deallocation'),\n                    Transition(self.state,\n                               s_dealloc,\n                               'Py_DECREF() with deallocation')]\n        else:\n            # ob_refcnt != 0, so it doesn't dealloc:\n            return [Transition(self.state,\n                               s_new,\n                               'Py_DECREF() without deallocation')]\n\n    def set_exception(self, exc_name, loc):\n        \"\"\"\n        Given the name of a (PyObject*) global for an exception class, such as\n        the string \"PyExc_MemoryError\", set the exception state to the\n        (PyObject*) for said exception class.\n\n        The list of standard exception classes can be seen at:\n          http://docs.python.org/c-api/exceptions.html#standard-exceptions\n        \"\"\"\n        check_isinstance(exc_name, str)\n        exc_decl = compat.get_exception_decl_by_name(exc_name)\n        check_isinstance(exc_decl, gcc.VarDecl)\n        r_exception = self.state.var_region(exc_decl)\n        v_exception = PointerToRegion(get_PyObjectPtr(), loc, r_exception)\n        self.exception_rvalue = v_exception\n\n    def bad_internal_call(self, loc):\n        \"\"\"\n        Analogous to PyErr_BadInternalCall(), which is a macro to\n        _PyErr_BadInternalCall() at the source file/line location\n        \"\"\"\n        self.set_exception('PyExc_SystemError', loc)\n\n    def bad_argument(self, loc):\n        \"\"\"\n        Analogous to PyErr_BadArgument()\n        \"\"\"\n        self.set_exception('PyExc_TypeError', loc)\n\n    def typeobjregion_by_name(self, typeobjname):\n        \"\"\"\n        Given a type object string e.g. \"PyString_Type\", locate\n        the Region storing the PyTypeObject\n        \"\"\"\n        check_isinstance(typeobjname, str)\n        # the C identifier of the global PyTypeObject for the type\n\n        # Get the gcc.VarDecl for the global PyTypeObject\n        typeobjdecl = compat.get_typeobject_decl_by_name(typeobjname)\n        check_isinstance(typeobjdecl, gcc.VarDecl)\n\n        typeobjregion = self.state.var_region(typeobjdecl)\n        return typeobjregion\n\n\n    def object_ctor(self, stmt, typename, typeobjname):\n        \"\"\"\n        Given a gcc.GimpleCall to a Python API function that returns a\n        PyObject*, generate a\n           (r_newobj, t_success, t_failure)\n        triple, where r_newobj is a region, and success/failure are Transitions\n        \"\"\"\n        check_isinstance(stmt, gcc.GimpleCall)\n        check_isinstance(stmt.fn.operand, gcc.FunctionDecl)\n        check_isinstance(typename, str)\n        # the C struct for the type\n\n        check_isinstance(typeobjname, str)\n        # the C identifier of the global PyTypeObject for the type\n\n        fnname = stmt.fn.operand.name\n        returntype = stmt.fn.type.dereference.type\n\n        # (the region hierarchy is shared by all states, so we can get the\n        # var region from \"self\", rather than \"success\")\n        typeobjregion = self.typeobjregion_by_name(typeobjname)\n\n        # The \"success\" case:\n        s_success, nonnull = self.mkstate_new_ref(stmt, typename, typeobjregion)\n        t_success = Transition(self.state,\n                               s_success,\n                               'when %s() succeeds' % fnname)\n        # The \"failure\" case:\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                       ConcreteValue(returntype, stmt.loc, 0),\n                                       'when %s() fails' % fnname)\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return (nonnull, t_success, t_failure)\n\n    def object_ctor_bytes(self, stmt):\n        \"\"\"\n        As per self.object_ctor(stmt, typename, typeobjname), returning:\n          (r_newobj, t_success, t_failure)\n        where the API entrypoint returns:\n          * a PyStringObject in Python 2\n          * a PyBytesObject in Python 3\n        \"\"\"\n        if is_py3k():\n            typename, typeobjname = 'PyBytesObject', 'PyBytes_Type'\n        else:\n            typename, typeobjname = 'PyStringObject', 'PyString_Type'\n        return self.object_ctor(stmt,\n                                typename, typeobjname)\n\n    def steal_reference(self, pyobjectptr, loc):\n        def _steal_ref(v_old):\n            # We have a value known relative to all of the refs owned by the\n            # rest of the program.  Given that the rest of the program is\n            # stealing a ref, that is increasing by one, hence our value must\n            # go down by one:\n            return RefcountValue(loc,\n                                 pyobjectptr.region,\n                                 v_old.relvalue - 1,\n                                 WithinRange(v_old.external.gcctype,\n                                             loc,\n                                             v_old.external.minvalue + 1,\n                                             v_old.external.maxvalue + 1))\n        check_isinstance(pyobjectptr, PointerToRegion)\n        self.change_refcount(pyobjectptr,\n                             loc,\n                             _steal_ref)\n\n    def make_sane_object(self, stmt, name, v_refcount, r_typeobj=None):\n        \"\"\"\n        Modify this State, adding a new object.\n\n        The ob_refcnt is set to the given value.\n\n        The object has ob_type set to either the given typeobj,\n        or a sane new one.\n\n        Returns r_nonnull, a Region\n        \"\"\"\n        check_isinstance(stmt, gcc.Gimple)\n        check_isinstance(name, str)\n        check_isinstance(v_refcount, RefcountValue)\n\n        # Claim a Region for the object:\n        r_nonnull = self.state.make_heap_region(name, stmt)\n\n        # Set up ob_refcnt to the given value:\n        r_ob_refcnt = self.state.make_field_region(r_nonnull,\n                                             'ob_refcnt') # FIXME: this should be a memref and fieldref\n        self.state.value_for_region[r_ob_refcnt] = v_refcount\n\n        # If the RefcountValue doesn't have a Region yet, associate it\n        # with that of the new object:\n        if not v_refcount.r_obj:\n            v_refcount.r_obj = r_nonnull\n\n        # Ensure that the new object has a sane ob_type:\n        if r_typeobj is None:\n            # If no specific type object provided by caller, supply one:\n            r_typeobj = Region('PyTypeObject for %s' % name, None)\n            # it is its own region:\n            self.state.region_for_var[r_typeobj] = r_typeobj\n\n        # Set up obj->ob_type:\n        ob_type = self.state.make_field_region(r_nonnull, 'ob_type')\n        self.state.value_for_region[ob_type] = PointerToRegion(get_PyTypeObject().pointer,\n                                                         stmt.loc,\n                                                         r_typeobj)\n        # Set up obj->ob_type->tp_dealloc:\n        tp_dealloc = self.state.make_field_region(r_typeobj, 'tp_dealloc')\n        type_of_tp_dealloc = gccutils.get_field_by_name(get_PyTypeObject().type,\n                                                        'tp_dealloc').type\n        self.state.value_for_region[tp_dealloc] = GenericTpDealloc(type_of_tp_dealloc,\n                                                             stmt.loc)\n        return r_nonnull\n\n    def mkstate_new_ref(self, stmt, name, typeobjregion=None):\n        \"\"\"\n        Make a new State, in which a new ref to some object has been\n        assigned to the statement's LHS.\n\n        Returns a pair: (newstate, RegionOnHeap for the new object)\n        \"\"\"\n        newstate = self.state.use_next_stmt_node()\n\n        r_nonnull = newstate.cpython.make_sane_object(stmt, name,\n                                              RefcountValue.new_ref(stmt.loc, None),\n                                              typeobjregion)\n        if stmt.lhs:\n            newstate.assign(stmt.lhs,\n                            PointerToRegion(stmt.lhs.type,\n                                            stmt.loc,\n                                            r_nonnull),\n                            stmt.loc)\n        # FIXME\n        return newstate, r_nonnull\n\n    def mkstate_borrowed_ref(self, stmt, fnmeta, r_typeobj=None):\n        \"\"\"Make a new State, giving a borrowed ref to some object\"\"\"\n        check_isinstance(fnmeta, FnMeta)\n        newstate = self.state.use_next_stmt_node()\n\n        r_nonnull = newstate.cpython.make_sane_object(stmt,\n                                              'borrowed reference returned by %s()' % fnmeta.name,\n                                              RefcountValue.borrowed_ref(stmt.loc, None),\n                                              r_typeobj)\n        if stmt.lhs:\n            newstate.assign(stmt.lhs,\n                            PointerToRegion(stmt.lhs.type,\n                                            stmt.loc,\n                                            r_nonnull),\n                            stmt.loc)\n        return newstate\n\n    def mkstate_exception(self, stmt):\n        \"\"\"Make a new State, giving NULL and some exception\"\"\"\n        if stmt.lhs:\n            value = ConcreteValue(stmt.lhs.type, stmt.loc, 0)\n        else:\n            value = None\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                                  value,\n                                                  None)\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return t_failure.dest\n\n    def make_transitions_for_new_ref_or_fail(self, stmt, fnmeta, objname=None):\n        \"\"\"\n        Generate the appropriate list of 2 transitions for a call to a\n        function that either:\n          - returns either a new ref, or\n          - fails with NULL and sets an exception\n        Optionally, a name for the new object can be supplied; otherwise\n        a sane default will be used.\n        \"\"\"\n        if fnmeta:\n            check_isinstance(fnmeta, FnMeta)\n        if objname is None:\n            objname = 'new ref from call to %s' % fnmeta.name\n        s_success, nonnull = self.mkstate_new_ref(stmt, objname)\n        s_failure = self.mkstate_exception(stmt)\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def make_transitions_for_borrowed_ref_or_fail(self, stmt, fnmeta):\n        \"\"\"\n        Generate the appropriate list of 2 transitions for a call to a\n        function that either:\n          - returns either a borrowed ref, or\n          - fails with NULL and sets an exception\n        \"\"\"\n        check_isinstance(fnmeta, FnMeta)\n        s_success = self.mkstate_borrowed_ref(stmt, fnmeta)\n        s_failure = self.mkstate_exception(stmt)\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def object_ptr_has_global_ob_type(self, v_object_ptr, vardecl_name):\n        \"\"\"\n        Boolean: do we know that the given PyObject* has an ob_type matching\n        the given global PyTypeObject (e.g. \"PyString_Type\")\n        \"\"\"\n        check_isinstance(v_object_ptr, AbstractValue)\n        check_isinstance(vardecl_name, str)\n        if isinstance(v_object_ptr, PointerToRegion):\n            v_ob_type = self.state.get_value_of_field_by_region(v_object_ptr.region,\n                                                          'ob_type')\n            if isinstance(v_ob_type, PointerToRegion):\n                if isinstance(v_ob_type.region, RegionForGlobal):\n                    if v_ob_type.region.vardecl.name == vardecl_name:\n                        return True\n\n    def iter_python_refcounts(self):\n        # yield a sequence of (Region, AbstractValue) pairs:\n        #  [...., (r_obj, v_ob_refcnt), ....]\n        # corresponding to all of the PyObject* memory regions that we know\n        # about, and their ob_refcnt values\n        for var in self.state.region_for_var:\n            check_isinstance(self.state.region_for_var[var], Region)\n            r_obj = self.state.region_for_var[var]\n\n            log('considering ob_refcnt of %r', r_obj)\n            check_isinstance(r_obj, Region)\n\n            # Consider those for which we know something about an \"ob_refcnt\"\n            # field:\n            if 'ob_refcnt' not in r_obj.fields:\n                continue\n\n            v_ob_refcnt = self.state.get_value_of_field_by_region(r_obj,\n                                                                  'ob_refcnt')\n            yield (r_obj, v_ob_refcnt)\n\n    def handle_null_error(self, stmt, idx, ptr, rawreturnvalue=0):\n        # Handle Objects/abstract.c's null_error()\n        # idx is the 0-based index of the argument\n        check_isinstance(stmt, gcc.Gimple)\n        check_isinstance(idx, int)\n        check_isinstance(ptr, AbstractValue)\n        if isinstance(ptr, UnknownValue):\n            self.state.raise_split_value(ptr, stmt.loc)\n        if ptr.is_null_ptr():\n            if stmt.lhs:\n                # null_error() returns a NULL PyObject*\n                # some callsites where the fn returns a PyObject* have:\n                #    return null_error()\n                # but others where the fn returns an int have:\n                #    null_error()\n                #    return -1\n                value = ConcreteValue(stmt.lhs.type, stmt.loc, rawreturnvalue)\n            else:\n                value = None\n            t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                                      value,\n                                                      None)\n            # null_error() sets PyExc_SystemError if (!PyErr_Occurred()):\n            if t_failure.dest.cpython.exception_rvalue.is_null_ptr():\n                t_failure.desc = ('when %s raises SystemError due to'\n                                  ' NULL as argument %i at %s'\n                                  % (stmt.fn, idx + 1, stmt.loc))\n                t_failure.dest.cpython.set_exception('PyExc_SystemError',\n                                                     stmt.loc)\n            else:\n                t_failure.desc = ('when %s fails due to'\n                                  ' NULL as argument %i at %s'\n                                  % (stmt.fn, idx + 1, stmt.loc))\n            return t_failure\n        # otherwise, implicit return of None to signify no problems\n\n    def handle_BadInternalCall_on_null(self, stmt, idx, ptr, v_return):\n        # various API calls have code of the form:\n        #   if (ptr == NULL) {\n        #      PyErr_BadInternalCall();\n        #      return NULL;\n        #   }\n        # idx is the 0-based index of the argument\n        check_isinstance(stmt, gcc.Gimple)\n        check_isinstance(idx, int)\n        check_isinstance(ptr, AbstractValue)\n        if isinstance(ptr, UnknownValue):\n            self.state.raise_split_value(ptr, stmt.loc)\n        if ptr.is_null_ptr():\n            t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                                      v_return,\n                                                      None)\n            t_failure.desc = ('when %s raises SystemError (via'\n                              ' PyErr_BadInternalCall) due to'\n                              ' NULL as argument %i at %s'\n                              % (stmt.fn, idx + 1, stmt.loc))\n            t_failure.dest.cpython.bad_internal_call(stmt.loc)\n            return t_failure\n        # otherwise, implicit return of None to signify no problems\n\n    # Treat calls to various function prefixed with __cpychecker as special,\n    # to help with debugging, and when writing selftests:\n\n    def impl___cpychecker_log(self, stmt, *args):\n        \"\"\"\n        Assuming a C function with this declaration:\n            extern void __cpychecker_log(const char *);\n        and that it is called with a string constant, log the message\n        within the trace.\n        \"\"\"\n        returntype = stmt.fn.type.dereference.type\n        desc =  args[0].as_string_constant()\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                     UnknownValue.make(returntype, stmt.loc),\n                                     desc)]\n\n    def impl___cpychecker_dump(self, stmt, *args):\n        returntype = stmt.fn.type.dereference.type\n        # Give the transition a description that embeds the argument values\n        # This will show up in selftests (and in error reports that embed\n        # traces)\n        desc = '__dump(%s)' % (','.join([str(arg) for arg in args]))\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                     UnknownValue.make(returntype, stmt.loc),\n                                     desc)]\n\n    def impl___cpychecker_dump_all(self, stmt, *args):\n        \"\"\"\n        Dump all of our state to stdout, to help with debugging\n        \"\"\"\n        print(str(stmt.loc))\n        print(self.state.as_str_table())\n        returntype = stmt.fn.type.dereference.type\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                     UnknownValue.make(returntype, stmt.loc),\n                                              None)]\n\n    def impl___cpychecker_assert_equal(self, stmt, *args):\n        \"\"\"\n        Assuming a C function with this declaration:\n            extern void __cpychecker_assert_equal(T, T);\n        for some type T, raise an exception within the checker if the two\n        arguments are non-equal (for use in writing selftests).\n        \"\"\"\n        returntype = stmt.fn.type.dereference.type\n        # Give the transition a description that embeds the argument values\n        # This will show up in selftests (and in error reports that embed\n        # traces)\n        if args[0] != args[1]:\n            raise AssertionError('%s != %s' % (args[0], args[1]))\n        desc = '__cpychecker_assert_equal(%s)' % (','.join([str(arg) for arg in args]))\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                     UnknownValue.make(returntype, stmt.loc),\n                                     desc)]\n\n    # Specific Python API function implementations\n    # (keep this list alphabetized, discounting case and underscores)\n\n    ########################################################################\n    # PyArg_*\n    ########################################################################\n    def _handle_PyArg_function(self, stmt, fnmeta, v_fmt, v_varargs, with_size_t):\n        \"\"\"\n        Handle one of the various PyArg_Parse* functions\n        \"\"\"\n        check_isinstance(v_fmt, AbstractValue)\n        check_isinstance(v_varargs, tuple) # of AbstractValue\n        check_isinstance(with_size_t, bool)\n\n        s_success = self.state.mkstate_concrete_return_of(stmt, 1)\n\n        s_failure = self.state.mkstate_concrete_return_of(stmt, 0)\n        # Various errors are possible, but a TypeError is always possible\n        # e.g. for the case of the wrong number of arguments:\n        s_failure.cpython.set_exception('PyExc_TypeError', stmt.loc)\n\n        # Parse the format string, and figure out what the effects of a\n        # successful parsing are:\n\n        def _get_new_value_for_vararg(unit, exptype):\n            if unit.code == 'O':\n                # non-NULL sane PyObject*:\n                return PointerToRegion(exptype.dereference,\n                                       stmt.loc,\n                                       self.make_sane_object(stmt, 'object from arg \"O\"',\n                                                             RefcountValue.borrowed_ref(stmt.loc, None)))\n\n            if unit.code == 'O!':\n                if isinstance(exptype, TypeCheckCheckerType):\n                    # This is read from, not written to:\n                    return None\n                if isinstance(exptype, TypeCheckResultType):\n                    # non-NULL sane PyObject*\n                    # FIXME: we could perhaps set ob_type to the given type.\n                    # However \"O!\" only enforces the weaker condition:\n                    #    if (PyType_IsSubtype(arg->ob_type, type))\n                    return PointerToRegion(get_PyObjectPtr(),\n                                           stmt.loc,\n                                           self.make_sane_object(stmt, 'object from arg \"O!\"',\n                                                                 RefcountValue.borrowed_ref(stmt.loc, None)))\n\n            if unit.code == 'O&':\n                # Assume for now that conversion succeeds\n                if isinstance(exptype, ConverterCallbackType):\n                    # This is read from, not written to:\n                    return None\n                if isinstance(exptype, ConverterResultType):\n                    return UnknownValue.make(exptype.type, stmt.loc)\n\n            # Unknown value:\n            check_isinstance(exptype, gcc.PointerType)\n            return UnknownValue.make(exptype.dereference, stmt.loc)\n\n        def _handle_successful_parse(fmt):\n            exptypes = fmt.iter_exp_types()\n            for v_vararg, (unit, exptype) in zip(v_varargs, exptypes):\n                if 0:\n                    print('v_vararg: %r' % v_vararg)\n                    print('  unit: %r' % unit)\n                    print('  exptype: %r %s' % (exptype, exptype))\n                if isinstance(v_vararg, PointerToRegion):\n                    v_new = _get_new_value_for_vararg(unit, exptype)\n                    if v_new:\n                        check_isinstance(v_new, AbstractValue)\n                        s_success.value_for_region[v_vararg.region] = v_new\n\n        fmt_string = v_fmt.as_string_constant()\n        if fmt_string:\n            try:\n                fmt = PyArgParseFmt.from_string(fmt_string, with_size_t)\n                _handle_successful_parse(fmt)\n            except FormatStringWarning:\n                pass\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyArg_Parse(self, stmt, v_args, v_fmt, *v_varargs):\n        fnmeta = FnMeta(name='PyArg_Parse',\n                        docurl='http://docs.python.org/c-api/arg.html#PyArg_Parse',\n                        declared_in='modsupport.h',\n                        prototype='PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);',)\n        # Also, with #ifdef PY_SSIZE_T_CLEAN\n        #   #define PyArg_Parse\t\t\t_PyArg_Parse_SizeT\n        return self._handle_PyArg_function(stmt, fnmeta,\n                                           v_fmt, v_varargs, with_size_t=False)\n\n    def impl__PyArg_Parse_SizeT(self, stmt, v_args, v_fmt, *v_varargs):\n        fnmeta = FnMeta(name='_PyArg_Parse_SizeT',\n                        docurl='http://docs.python.org/c-api/arg.html#PyArg_Parse',\n                        declared_in='modsupport.h',\n                        prototype='PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);',)\n        # Also, with #ifdef PY_SSIZE_T_CLEAN\n        #   #define PyArg_Parse\t\t\t_PyArg_Parse_SizeT\n        return self._handle_PyArg_function(stmt, fnmeta,\n                                           v_fmt, v_varargs, with_size_t=True)\n\n    def impl_PyArg_ParseTuple(self, stmt, v_args, v_fmt, *v_varargs):\n        fnmeta = FnMeta(name='PyArg_ParseTuple',\n                        docurl='http://docs.python.org/c-api/arg.html#PyArg_ParseTuple',\n                        declared_in='modsupport.h',\n                        prototype='PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);',)\n        # Also, with #ifdef PY_SSIZE_T_CLEAN\n        #   #define PyArg_ParseTuple\t\t_PyArg_ParseTuple_SizeT\n\n        return self._handle_PyArg_function(stmt, fnmeta,\n                                           v_fmt, v_varargs, with_size_t=False)\n\n    def impl__PyArg_ParseTuple_SizeT(self, stmt, v_args, v_fmt, *v_varargs):\n        fnmeta = FnMeta(name='_PyArg_ParseTuple_SizeT',\n                        docurl='http://docs.python.org/c-api/arg.html#PyArg_ParseTuple',\n                        declared_in='modsupport.h',\n                        prototype='PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...) Py_FORMAT_PARSETUPLE(PyArg_ParseTuple, 2, 3);',)\n        # Also, with #ifdef PY_SSIZE_T_CLEAN\n        #   #define PyArg_ParseTuple\t\t_PyArg_ParseTuple_SizeT\n\n        return self._handle_PyArg_function(stmt, fnmeta,\n                                           v_fmt, v_varargs, with_size_t=True)\n\n    def impl_PyArg_ParseTupleAndKeywords(self, stmt, v_args, v_kwargs,\n                                         v_fmt, v_keywords, *v_varargs):\n        fnmeta = FnMeta(name='PyArg_ParseTupleAndKeywords',\n                        docurl='http://docs.python.org/c-api/arg.html#PyArg_ParseTupleAndKeywords',\n                        declared_in='modsupport.h',\n                        prototype=('PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,\\n'\n                                   '                                            const char *, char **, ...);'),)\n        #\n        # Also, with #ifdef PY_SSIZE_T_CLEAN\n        #   #define PyArg_ParseTupleAndKeywords\t_PyArg_ParseTupleAndKeywords_SizeT\n\n        return self._handle_PyArg_function(stmt, fnmeta,\n                                           v_fmt, v_varargs, with_size_t=False)\n\n    def impl__PyArg_ParseTupleAndKeywords_SizeT(self, stmt, v_args, v_kwargs,\n                                                v_fmt, v_keywords, *v_varargs):\n        fnmeta = FnMeta(name='_PyArg_ParseTupleAndKeywords_SizeT',\n                        docurl='http://docs.python.org/c-api/arg.html#PyArg_ParseTupleAndKeywords',\n                        declared_in='modsupport.h',\n                        prototype=('PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,\\n'\n                                   '                                            const char *, char **, ...);'),)\n        #\n        # Also, with #ifdef PY_SSIZE_T_CLEAN\n        #   #define PyArg_ParseTupleAndKeywords\t_PyArg_ParseTupleAndKeywords_SizeT\n\n        return self._handle_PyArg_function(stmt, fnmeta,\n                                           v_fmt, v_varargs, with_size_t=True)\n\n    def impl_PyArg_UnpackTuple(self, stmt, v_args, v_name, v_min, v_max,\n                               *v_varargs):\n        fnmeta = FnMeta(name='PyArg_UnpackTuple',\n                        docurl='http://docs.python.org/c-api/arg.html#PyArg_UnpackTuple',\n                        declared_in='modsupport.h',\n                        prototype=('PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *,\\n'\n                                   '                                  Py_ssize_t, Py_ssize_t, ...);'),\n                        defined_in='Python/getargs.c')\n        #   int\n        #   PyArg_UnpackTuple(PyObject *args, const char *name,\n        #                     Py_ssize_t min, Py_ssize_t max, ...)\n        #\n        # Will only write betweeen v_min..v_max values back\n\n        # For now, assume that we can figure out min and max during the\n        # analysis:\n        check_isinstance(v_min, ConcreteValue)\n        check_isinstance(v_max, ConcreteValue)\n\n        # for arg in v_varargs:\n        #     print arg\n\n        # Detect wrong number of arguments:\n        if len(v_varargs) != v_max.value:\n            class WrongNumberOfVarargs(PredictedError):\n                def __init__(self, v_max, v_varargs):\n                    self.v_max = v_max\n                    self.v_varargs = v_varargs\n                def __str__(self):\n                    return ('expected %i vararg pointer(s); got %i' %\n                            (v_max.value, len(v_varargs)))\n            raise WrongNumberOfVarargs(v_max, v_varargs)\n\n        s_failure = self.state.mkstate_concrete_return_of(stmt, 0)\n        # Various errors are possible, but a TypeError is always possible\n        # e.g. for the case of the wrong number of arguments:\n        s_failure.cpython.set_exception('PyExc_TypeError', stmt.loc)\n        result = [self.state.mktrans_from_fncall_state(stmt,\n                        s_failure, 'fails', has_siblings=True)]\n\n        # Enumerate all possible successes, to detect the case where an\n        # optional argument doesn't get initialized\n        for numargs in range(v_min.value, v_max.value + 1):\n            s_success = self.state.mkstate_concrete_return_of(stmt, 1)\n            result.append(self.state.mktrans_from_fncall_state(\n                    stmt, s_success, 'successfully unpacks %i argument(s)' % numargs,\n                    has_siblings=True))\n            # Write sane objects to each location that gets written to,\n            # given this number of arguments:\n            for i in range(numargs):\n                vararg = v_varargs[i]\n                if isinstance(vararg, PointerToRegion):\n                    # Write back a sane object:\n                    v_obj = PointerToRegion(get_PyObjectPtr(),\n                                            stmt.loc,\n                                            s_success.cpython.make_sane_object(stmt,\n                                                                               'argument %i' % (i + 1),\n                                                                               RefcountValue.borrowed_ref(stmt.loc, None)))\n                    s_success.value_for_region[vararg.region] = v_obj\n\n        return result\n\n    ########################################################################\n    def impl_Py_AtExit(self, stmt, v_func):\n        fnmeta = FnMeta(name='Py_AtExit',\n                        docurl='http://docs.python.org/c-api/sys.html#Py_AtExit')\n\n        # Dummy implementation\n        t_return = self.state.mktrans_assignment(stmt.lhs,\n                                       UnknownValue.make(stmt.lhs.type, stmt.loc),\n                                       'when %s() returns' % fnmeta.name)\n        return [t_return]\n\n\n    ########################################################################\n    # PyBool_*\n    ########################################################################\n    def impl_PyBool_FromLong(self, stmt, v_long):\n        fnmeta = FnMeta(name='PyBool_FromLong',\n                        docurl='http://docs.python.org/c-api/bool.html#PyBool_FromLong',\n                        declared_in='boolobject.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyBool_FromLong(long);',\n                        defined_in='Objects/boolobject.c',\n                        notes=('Always succeeds, returning a new ref to one of'\n                               ' the two singleton booleans'))\n        # v_ok = self.state.eval_stmt_args(stmt)[0]\n        s_success, r_nonnull = self.mkstate_new_ref(stmt, 'PyBool_FromLong')\n        return [self.state.mktrans_from_fncall_state(stmt, s_success,\n                                                     'returns', False)]\n\n    ########################################################################\n    # Py_BuildValue*\n    ########################################################################\n    def _handle_Py_BuildValue(self, stmt, fnmeta, v_fmt, v_varargs, with_size_t):\n        \"\"\"\n        Handle one of the various Py_BuildValue functions\n\n        http://docs.python.org/c-api/arg.html#Py_BuildValue\n\n        We don't try to model the resulting object, just the success/failure\n        and the impact on the refcounts of any inputs\n        \"\"\"\n        check_isinstance(v_fmt, AbstractValue)\n        check_isinstance(v_varargs, tuple) # of AbstractValue\n        check_isinstance(with_size_t, bool)\n\n        # The function can succeed or fail\n        # If any of the PyObject* inputs are NULL, it is doomed to failure\n        def _handle_successful_parse(fmt):\n            \"\"\"\n            Returns a boolean: is success of the function possible?\n            \"\"\"\n            exptypes = fmt.iter_exp_types()\n            for v_vararg, (unit, exptype) in zip(v_varargs, exptypes):\n                if 0:\n                    print('v_vararg: %r' % v_vararg)\n                    print('  unit: %r' % unit)\n                    print('  exptype: %r %s' % (exptype, exptype))\n                if isinstance(unit, ObjectFormatUnit):\n                    # NULL inputs ptrs guarantee failure:\n                    if isinstance(v_vararg, ConcreteValue):\n                        if v_vararg.is_null_ptr():\n                            # The call will fail:\n                            return False\n\n                    # non-NULL input ptrs receive \"external\" references on\n                    # success for codes \"S\" and \"O\":\n                    if isinstance(v_vararg, PointerToRegion):\n                        if isinstance(unit, CodeSO):\n                            t_success.dest.cpython.add_external_ref(v_vararg, stmt.loc)\n                        else:\n                            t_success.dest.cpython.steal_reference(v_vararg, stmt.loc)\n            return True\n\n        t_success, t_failure = self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n        fmt_string = v_fmt.as_string_constant()\n        if fmt_string:\n            try:\n                fmt = PyBuildValueFmt.from_string(fmt_string, with_size_t)\n                if not _handle_successful_parse(fmt):\n                    return [t_failure]\n            except FormatStringWarning:\n                pass\n\n        return [t_success, t_failure]\n\n    def impl_Py_BuildValue(self, stmt, v_fmt, *args):\n        fnmeta = FnMeta(name='Py_BuildValue',\n                        docurl='http://docs.python.org/c-api/arg.html#Py_BuildValue',\n                        declared_in='modsupport.h',\n                        prototype='PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);',\n                        defined_in='Python/modsupport.c')\n        #   PyObject *\n        #   Py_BuildValue(const char *format, ...)\n        #\n        return self._handle_Py_BuildValue(stmt, fnmeta,\n                                          v_fmt, args, with_size_t=False)\n\n    def impl__Py_BuildValue_SizeT(self, stmt, v_fmt, *args):\n        fnmeta = FnMeta(name='_Py_BuildValue_SizeT',\n                        docurl='http://docs.python.org/c-api/arg.html#Py_BuildValue',\n                        declared_in='modsupport.h',\n        #   #ifdef PY_SSIZE_T_CLEAN\n        #   #define Py_BuildValue   _Py_BuildValue_SizeT\n        #   #endif\n        #\n                        prototype='PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);',\n                        defined_in='Python/modsupport.c')\n        #   PyObject *\n        #   _Py_BuildValue_SizeT(const char *format, ...)\n        #\n        return self._handle_Py_BuildValue(stmt, fnmeta,\n                                          v_fmt, args, with_size_t=True)\n\n    ########################################################################\n\n    def impl_PyCallable_Check(self, stmt, v_o):\n        fnmeta = FnMeta(name='PyCallable_Check',\n                        docurl='http://docs.python.org/c-api/object.html#PyCallable_Check',\n                        defined_in='Objects/object.c', # not abstract.c\n                        notes='Always succeeds')\n        # robust against NULL\n        s_true = self.state.mkstate_concrete_return_of(stmt, 1)\n        s_false = self.state.mkstate_concrete_return_of(stmt, 0)\n\n        return [Transition(self.state, s_true,\n                           fnmeta.desc_when_call_returns_value('1 (true)')),\n                Transition(self.state, s_false,\n                           fnmeta.desc_when_call_returns_value('0 (false)'))]\n\n    ########################################################################\n    # PyCapsule_*\n    ########################################################################\n\n    def impl_PyCapsule_GetPointer(self, stmt, v_capsule, v_name):\n        fnmeta = FnMeta(name='PyCapsule_GetPointer',\n                        docurl='http://docs.python.org/c-api/capsule.html#PyCapsule_GetPointer',\n                        prototype='void* PyCapsule_GetPointer(PyObject *capsule, const char *name)',\n                        defined_in='Objects/capsule.c')\n        # either returns NULL, setting an exception, or returns non-NULL\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                           UnknownValue.make(stmt.lhs.type,\n                                             stmt.loc),\n                           fnmeta.desc_when_call_succeeds())\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                           make_null_ptr(stmt.lhs.type,\n                                         stmt.loc),\n                           fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_ValueError',\n                                             stmt.loc)\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyCObject_*\n    ########################################################################\n\n    def impl_PyCObject_AsVoidPtr(self, stmt, v_self):\n        fnmeta = FnMeta(name='PyCObject_AsVoidPtr',\n                        docurl='http://docs.python.org/c-api/cobject.html#PyCObject_AsVoidPtr',\n                        declared_in='cobject.h',\n                        prototype='void * PyCObject_AsVoidPtr(PyObject *self)',\n                        defined_in='Objects/cobject.c')\n        # TODO: robust against NULL ptr, lazily setting exception\n        returntype = stmt.fn.type.dereference.type\n        t_result = self.state.mktrans_assignment(stmt.lhs,\n                                                 UnknownValue.make(returntype, stmt.loc),\n                                                 'when %s() returns' % fnmeta.name)\n        return [t_result]\n\n    def mktrans_cobject_deprecation_warning(self, fnmeta, stmt):\n        \"\"\"\n        Generate a Transition simulating the outcome of these clauses:\n            if (cobject_deprecation_warning()) {\n                return NULL;\n            }\n        in CPython 2.7's Objects/cobject.c\n\n        This indicates that Py_Py3kWarningFlag is enabled, and that the\n        warnings have been so configured (perhaps in other code in the process)\n        as to trigger an exception, leading to a NULL return.\n\n        Plenty of legacy code doesn't expect a NULL return from these APIs,\n        alas.\n\n        Include/warnings.h has:\n         #define PyErr_WarnPy3k(msg, stacklevel) \\\n            (Py_Py3kWarningFlag ? PyErr_WarnEx(PyExc_DeprecationWarning, msg, stacklevel) : 0)\n        Python/_warnings.c defines PyErr_WarnEx\n        \"\"\"\n        s_deprecation = self.mkstate_exception(stmt)\n        t_deprecation = Transition(self.state,\n                                   s_deprecation,\n                                   desc=fnmeta.desc_when_call_fails(\n            why=('when py3k deprecation warnings are enabled and configured'\n                 ' to raise exceptions')))\n        return t_deprecation\n\n    def impl_PyCObject_FromVoidPtr(self, stmt, v_cobj, v_destr):\n        fnmeta = FnMeta(name='PyCObject_FromVoidPtr',\n                        docurl='http://docs.python.org/c-api/cobject.html#PyCObject_FromVoidPtr',\n                        declared_in='cobject.h',\n                        prototype='PyObject* PyCObject_FromVoidPtr(void* cobj, void (*destr)(void *))',\n                        defined_in='Objects/cobject.c',\n                        notes='Deprecated API')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyCObject',\n                                                          'PyCObject_Type')\n        return [t_success,\n                # Prioritize the more interesting failure over regular malloc\n                # failure, so that it doesn't disapper in de-duplication:\n                self.mktrans_cobject_deprecation_warning(fnmeta, stmt),\n                t_failure]\n\n    def impl_PyCObject_FromVoidPtrAndDesc(self, stmt, v_cobj, v_desc, v_destr):\n        fnmeta = FnMeta(name='PyCObject_FromVoidPtrAndDesc',\n                        docurl='http://docs.python.org/c-api/cobject.html#PyCObject_FromVoidPtrAndDesc',\n                        declared_in='cobject.h',\n                        prototype=('PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc(\\n'\n                                   '        void *cobj, void *desc, void (*destruct)(void*,void*));'),\n                        defined_in='Objects/cobject.c',\n                        notes='Deprecated API')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyCObject',\n                                                          'PyCObject_Type')\n        return [t_success,\n                # Prioritize the more interesting failure over regular malloc\n                # failure, so that it doesn't disapper in de-duplication:\n                self.mktrans_cobject_deprecation_warning(fnmeta, stmt),\n                t_failure]\n\n    ########################################################################\n    # PyCode_*\n    ########################################################################\n    def impl_PyCode_New(self, stmt,\n                        v_argcount, v_nlocals, v_stacksize, v_flags,\n                        v_code, v_consts, v_names,\n                        v_varnames, v_freevars, v_cellvars,\n                        v_filename, v_name, v_firstlineno,\n                        v_lnotab):\n        fnmeta = FnMeta(name='PyCode_New',\n                        docurl='http://docs.python.org/c-api/code.html#PyCode_New',\n                        declared_in='code.h',\n                        prototype=('PyCodeObject *\\n'\n                                   'PyCode_New(int argcount, int nlocals, int stacksize, int flags,\\n'\n                                   '           PyObject *code, PyObject *consts, PyObject *names,\\n'\n                                   '           PyObject *varnames, PyObject *freevars, PyObject *cellvars,\\n'\n                                   '           PyObject *filename, PyObject *name, int firstlineno,\\n'\n                                   '           PyObject *lnotab);'),\n                        defined_in='Objects/codeobject.c')\n        # (used by Cython-generated code in static void __Pyx_AddTraceback in\n        # each file)\n        # For now, ignore the effects on the input variables:\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyCodeObject',\n                                                          'PyCode_Type')\n        return [t_success, t_failure]\n\n\n    ########################################################################\n    # PyDict_*\n    ########################################################################\n    def impl_PyDict_GetItem(self, stmt, v_mp, v_key):\n        fnmeta = FnMeta(name='PyDict_GetItem',\n                        docurl='http://docs.python.org/c-api/dict.html#PyDict_GetItem',\n                        declared_in='dictobject.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);',\n                        defined_in='Objects/dictobject.c',\n                        notes=('Returns a borrowed reference, or NULL if not'\n                               ' found.  It does *not* set an exception (for'\n                               ' historical reasons)'))\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_mp,\n                          why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                        'PyDict_Check'))\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_key,\n                          why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                        'PyString_CheckExact'))\n        s_success = self.mkstate_borrowed_ref(stmt, fnmeta)\n        t_notfound = self.state.mktrans_assignment(stmt.lhs,\n                                             make_null_pyobject_ptr(stmt),\n                                             'when PyDict_GetItem does not find item')\n        return [self.state.mktrans_from_fncall_state(stmt, s_success,\n                                                     'succeeds', True),\n                t_notfound]\n\n    def impl_PyDict_GetItemString(self, stmt, v_dp, v_key):\n        fnmeta = FnMeta(name='PyDict_GetItemString',\n                        docurl='http://docs.python.org/c-api/dict.html#PyDict_GetItemString',\n                        declared_in='dictobject.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);',\n                        defined_in='Objects/dictobject.c',\n                        notes=('Returns a borrowed ref, or NULL if not found'\n                               ' (can also return NULL and set MemoryError)'))\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_dp,\n                          why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                        'PyDict_Check'))\n        # (within PyDict_GetItem)\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_key,\n                          why='%s() invokes PyString_FromString()' % fnmeta.name)\n\n        s_success = self.mkstate_borrowed_ref(stmt, fnmeta)\n        t_notfound = self.state.mktrans_assignment(stmt.lhs,\n                                             make_null_pyobject_ptr(stmt),\n                                             'PyDict_GetItemString does not find string')\n        if 0:\n            t_memoryexc = self.state.mktrans_assignment(stmt.lhs,\n                                                  make_null_pyobject_ptr(stmt),\n                                                  'OOM allocating string') # FIXME: set exception\n        return [self.state.mktrans_from_fncall_state(stmt, s_success,\n                                                     'succeeds', True),\n                t_notfound]\n                #t_memoryexc]\n\n    def impl_PyDict_New(self, stmt):\n        fnmeta = FnMeta(name='PyDict_New',\n                        docurl='http://docs.python.org/c-api/dict.html#PyDict_New')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyDictObject',\n                                                          'PyDict_Type')\n        return [t_success, t_failure]\n\n    def _handle_PyDict_SetItem(self, stmt, fnmeta,\n                               v_dp, v_key, v_item):\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n        # the dictionary now owns a new ref on \"item\".  We won't model the\n        # insides of the dictionary type.  Instead, treat it as a new\n        # external reference:\n        s_success.cpython.add_external_ref(v_item, stmt.loc)\n\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyDict_SetItem(self, stmt, v_dp, v_key, v_item):\n        fnmeta = FnMeta(name='PyDict_SetItem',\n                        declared_in='dictobject.h',\n                        prototype='PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);',\n                        defined_in='Objects/dictobject.c',\n                        docurl='http://docs.python.org/c-api/dict.html#PyDict_SetItem',\n                        notes='Can return -1, setting MemoryError.  Otherwise returns 0, and adds a ref on the value')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_dp,\n                          why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                        'PyDict_Check'))\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_key,\n                          why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                        'PyString_CheckExact'))\n        self.state.raise_any_null_ptr_func_arg(stmt, 2, v_item,\n                          why=invokes_Py_INCREF(fnmeta))\n\n        return self._handle_PyDict_SetItem(stmt, fnmeta,\n                                           v_dp, v_key, v_item)\n\n    def impl_PyDict_SetItemString(self, stmt, v_dp, v_key, v_item):\n        fnmeta = FnMeta(name='PyDict_SetItemString',\n                        declared_in='dictobject.h',\n                        prototype='PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);',\n                        defined_in='Objects/dictobject.c',\n                        docurl='http://docs.python.org/c-api/dict.html#PyDict_SetItemString',\n                        notes=('Can return -1, setting MemoryError.'\n                               '  Otherwise returns 0, and adds a ref on the value'))\n        # This is implemented in terms of PyDict_SetItem and shows the same\n        # success and failures:\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_key)\n        self.state.raise_any_null_ptr_func_arg(stmt, 2, v_item)\n        # (strictly speaking, v_key goes from being a char* to a PyObject*)\n\n        return self._handle_PyDict_SetItem(stmt, fnmeta,\n                                           v_dp, v_key, v_item)\n\n    def impl_PyDict_Size(self, stmt, v_mp):\n        fnmeta = FnMeta(name='PyDict_Size',\n                        declared_in='dictobject.h',\n                        prototype='Py_ssize_t PyDict_Size(PyObject *mp);',\n                        defined_in='Objects/dictobject.c',\n                        docurl='http://docs.python.org/c-api/dict.html#PyDict_Size')\n        # Explicitly checks for NULL (or not a dict)\n        # with PyErr_BadInternalCall(); return -1\n        t_err = self.handle_BadInternalCall_on_null(stmt, 0, v_mp,\n                       ConcreteValue(stmt.lhs.type, stmt.loc, -1))\n        if t_err:\n            return [t_err]\n        # FIXME: doesn't yet handle the !PyDict_Check(mp) case\n\n        returntype = stmt.fn.type.dereference.type\n        v_ma_used = self.state.read_field_by_name(stmt,\n                                                  returntype,\n                                                  v_mp.region, 'ma_used')\n\n        t_return = self.state.mktrans_assignment(stmt.lhs,\n                          v_ma_used,\n                          fnmeta.desc_when_call_returns_value('ma_used'))\n        return [t_return]\n\n    ########################################################################\n    # PyErr_*\n    ########################################################################\n    def impl_PyErr_Clear(self, stmt):\n        fnmeta = FnMeta(name='PyErr_Clear',\n                        # FIXME docurl='http://docs.python.org/c-api/exceptions.html#PyErr_Clear',\n                        declared_in='pyerrors.h',\n                        prototype='PyAPI_FUNC(void) PyErr_Clear(void);',\n                        defined_in='Python/errors.c')\n        # equiv to PyErr_Restore(NULL, NULL, NULL)\n        t_next = self.state.mktrans_nop(stmt, fnmeta.name)\n        t_next.dest.cpython.exception_rvalue = make_null_pyobject_ptr(stmt)\n        return [t_next]\n\n    def impl_PyErr_Format(self, stmt, v_exc, v_fmt, *v_args):\n        fnmeta = FnMeta(name='PyErr_Format',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_Format',\n                        declared_in='pyerrors.h',\n                        prototype='PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *);',\n                        defined_in='Python/errors.c',\n                        notes='Always returns NULL',)\n        t_next = self.state.mktrans_assignment(stmt.lhs,\n                                         make_null_pyobject_ptr(stmt),\n                                         'PyErr_Format()')\n        t_next.dest.cpython.exception_rvalue = v_exc\n        return [t_next]\n\n    def impl_PyErr_NewException(self, stmt, v_name, v_base, v_dict):\n        fnmeta = FnMeta(name='PyErr_NewException',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_NewException',\n                        prototype=('PyObject*\\n'\n                                   'Err_NewException(char *name, PyObject *base, PyObject *dict)'),\n                        defined_in='Python/errors.c',\n                        notes='Return value: New reference (or NULL e.g. MemoryError)')\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_name)\n        # \"base\" and \"dict\" may be NULL\n\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta,\n                        objname='new exception object from %s' % fnmeta.name)\n\n    def impl_PyErr_NoMemory(self, stmt):\n        fnmeta = FnMeta(name='PyErr_NoMemory',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_NoMemory',\n                        declared_in='pyerrors.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);',\n                        defined_in='Python/errors.c',\n                        notes='Always returns NULL',)\n        t_next = self.state.mktrans_assignment(stmt.lhs,\n                                         make_null_pyobject_ptr(stmt),\n                                         ('PyErr_NoMemory() returns NULL,'\n                                          ' raising MemoryError'))\n        t_next.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_next]\n\n    def impl_PyErr_Occurred(self, stmt):\n        fnmeta = FnMeta(name='PyErr_Occurred',\n                        declared_in='pyerrors.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyErr_Occurred(void);',\n                        defined_in='Python/errors.c',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_Occurred',\n                        notes=\"Returns a borrowed reference; can't fail\")\n        t_next = self.state.mktrans_assignment(stmt.lhs,\n                                         self.exception_rvalue,\n                                         'PyErr_Occurred()')\n        return [t_next]\n\n    def impl_PyErr_Print(self, stmt):\n        fnmeta = FnMeta(name='PyErr_Print',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_Print',\n                        declared_in='pythonrun.h',\n                        prototype='PyAPI_FUNC(void) PyErr_Print(void);',\n                        defined_in='Python/pythonrun.c',)\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        always = fncall.always()\n        # Clear the error indicator:\n        always.sets_exception_ptr(make_null_pyobject_ptr(stmt))\n        return fncall.get_transitions()\n\n    def impl_PyErr_PrintEx(self, stmt, v_int):\n        fnmeta = FnMeta(name='PyErr_PrintEx',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_PrintEx',\n                        declared_in='pythonrun.h',\n                        prototype='PyAPI_FUNC(void) PyErr_PrintEx(int);',\n                        defined_in='Python/pythonrun.c',)\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_int, ))\n        always = fncall.always()\n        # Clear the error indicator:\n        always.sets_exception_ptr(make_null_pyobject_ptr(stmt))\n        return fncall.get_transitions()\n\n    def impl_PyErr_SetFromErrno(self, stmt, v_exc):\n        fnmeta = FnMeta(name='PyErr_SetFromErrno',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_SetFromErrno',\n                        notes='Always returns NULL',)\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_exc, ))\n        always = fncall.always()\n        always.returns_NULL()\n        always.sets_exception_ptr(v_exc)\n        return fncall.get_transitions()\n\n    def impl_PyErr_SetFromErrnoWithFilename(self, stmt, v_exc, v_filename):\n        fnmeta = FnMeta(name='PyErr_SetFromErrnoWithFilename',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_SetFromErrnoWithFilename',\n                        defined_in='Python/errors.c',\n                        notes='Always returns NULL',)\n        #   PyObject *\n        #   PyErr_SetFromErrnoWithFilename(PyObject *exc, const char *filename)\n        #\n        # \"filename\" can be NULL.\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        always = fncall.always()\n        always.returns_NULL()\n        always.sets_exception_ptr(v_exc)\n        return fncall.get_transitions()\n\n    def impl_PyErr_SetNone(self, stmt, v_exc):\n        fnmeta = FnMeta(name='PyErr_SetNone',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_SetNone',\n                        defined_in='Python/errors.c',)\n        #   void\n        #   PyErr_SetNone(PyObject *exception)\n\n        # It's acceptable for v_exc to be NULL\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        always = fncall.always()\n        always.sets_exception_ptr(v_exc)\n        always.adds_external_ref(v_exc)\n        return fncall.get_transitions()\n\n    def impl_PyErr_SetObject(self, stmt, v_exc, v_value):\n        fnmeta = FnMeta(name='PyErr_SetObject',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_SetObject',\n                        declared_in='pyerrors.h',\n                        prototype='PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);',\n                        defined_in='Python/errors.c',)\n        #   void\n        #   PyErr_SetObject(PyObject *exception, PyObject *value)\n        #\n        # It's acceptable for each of v_exc and v_value to be NULL\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        always = fncall.always()\n        always.sets_exception_ptr(v_exc)\n        always.adds_external_ref(v_exc)\n        always.adds_external_ref(v_value)\n        return fncall.get_transitions()\n\n    def impl_PyErr_SetString(self, stmt, v_exc, v_string):\n        fnmeta = FnMeta(name='PyErr_SetString',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_SetString',\n                        declared_in='pyerrors.h',\n                        prototype='PyAPI_FUNC(void) PyErr_SetString(PyObject *, const char *);',\n                        defined_in='Python/errors.c',)\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        always = fncall.always()\n        always.sets_exception_ptr(v_exc)\n        return fncall.get_transitions()\n\n    def impl_PyErr_WarnEx(self, stmt, v_category, v_text, v_stack_level):\n        fnmeta = FnMeta(name='PyErr_WarnEx',\n                        docurl='http://docs.python.org/c-api/exceptions.html#PyErr_WarnEx',\n        #  int\n        #  PyErr_WarnEx(PyObject *category, const char *text, Py_ssize_t stack_level)\n        # returns 0 on OK\n        # returns -1 if an exception is raised\n                        defined_in='Python/_warnings.c')\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        on_success = fncall.can_succeed()\n        on_success.returns(0)\n\n        on_failure = fncall.can_fail()\n        on_failure.returns(-1)\n        on_failure.sets_exception('PyExc_MemoryError')\n\n        return fncall.get_transitions()\n\n    ########################################################################\n    # PyEval_InitThreads()\n    ########################################################################\n\n    def impl_PyEval_CallMethod(self, stmt, v_obj, v_method, v_fmt, *v_varargs):\n        fnmeta = FnMeta(name='PyEval_CallMethod',\n                        prototype=('PyObject *\\n'\n                                   'PyEval_CallMethod(PyObject *obj, const char *methodname, const char *format, ...)'),\n                        declared_in='ceval.h',\n                        defined_in='Python/modsupport.c')\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_obj, v_method, v_fmt),\n                              varargs=v_varargs)\n        fncall.crashes_on_null_arg(0,\n            why=invokes_Py_TYPE(fnmeta, within='PyObject_GetAttrString'))\n        # not affected by PY_SSIZE_T_CLEAN\n        self._handle_PyObject_CallMethod(fncall, 2, with_size_t=False)\n        return fncall.get_transitions()\n\n    def impl_PyEval_CallObjectWithKeywords(self, stmt, v_func, v_arg, v_kw):\n        fnmeta = FnMeta(name='PyEval_CallObjectWithKeywords',\n                        prototype=('PyObject *\\n'\n                                   'PyEval_CallObjectWithKeywords(PyObject *func, PyObject *arg, PyObject *kw)'),\n                        defined_in='Python/ceval.c')\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_func, v_arg, v_kw))\n        fncall.crashes_on_null_arg(0,\n            why='looks up func->ob_type within inner call to PyObject_Call()')\n        # arg and kw can each be NULL, though\n\n        fncall.new_ref_or_fail()\n\n        return fncall.get_transitions()\n\n    def impl_PyEval_InitThreads(self, stmt):\n        fnmeta = FnMeta(name='PyEval_InitThreads',\n                        docurl='http://docs.python.org/c-api/init.html#PyEval_InitThreads')\n        # For now, treat it as a no-op:\n        return [self.state.mktrans_nop(stmt, 'PyEval_InitThreads')]\n\n    def impl_PyEval_RestoreThread(self, stmt, v_tstate):\n        fnmeta = FnMeta(name='PyEval_RestoreThread',\n                        docurl='http://docs.python.org/c-api/init.html#PyEval_RestoreThread',\n                        prototype='void PyEval_RestoreThread(PyThreadState *tstate)',\n                        defined_in='Python/ceval.c',\n                        notes='Reclaims the GIL')\n        t_success = self.state.mktrans_nop(stmt, fnmeta.name)\n        t_success.desc = 'reacquiring the GIL by calling %s()' % fnmeta.name\n        # Acquire the GIL:\n        t_success.dest.cpython.has_gil = True\n        return [t_success]\n\n    def impl_PyEval_SaveThread(self, stmt):\n        fnmeta = FnMeta(name='PyEval_SaveThread',\n                        docurl='http://docs.python.org/c-api/init.html#PyEval_SaveThread',\n                        prototype='PyThreadState* PyEval_SaveThread()',\n                        defined_in='Python/ceval.c',\n                        notes='Releases the GIL')\n\n        returntype = stmt.fn.type.dereference.type\n\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                                                  UnknownValue.make(returntype, stmt.loc),\n                                                  'releasing the GIL by calling %s()' % fnmeta.name)\n        # Release the GIL:\n        t_success.dest.cpython.has_gil = False\n        return [t_success]\n\n    ########################################################################\n    # Py_FatalError()\n    ########################################################################\n    def impl_Py_FatalError(self, stmt, v_message):\n        fnmeta = FnMeta(name='Py_FatalError',\n                        docurl='http://docs.python.org/c-api/sys.html#Py_FatalError',\n                        prototype='void Py_FatalError(const char *message)')\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        fncall.never_returns()\n        return fncall.get_transitions()\n\n    ########################################################################\n    # PyFile_*\n    ########################################################################\n    def impl_PyFile_SoftSpace(self, stmt, v_f, v_newflag):\n        fnmeta = FnMeta(name='PyFile_SoftSpace',\n                        docurl='http://docs.python.org/c-api/file.html#PyFile_SoftSpace',\n                        defined_in='Objects/fileobject.c')\n        # used in Cython-generated code, in static int __Pyx_Print()\n        returntype = stmt.fn.type.dereference.type\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                              UnknownValue.make(returntype, stmt.loc),\n                                              fnmeta.name)]\n\n    def impl_PyFile_WriteObject(self, stmt, v_obj, v_p, v_flags):\n        fnmeta = FnMeta(name='PyFile_WriteObject',\n                        docurl='http://docs.python.org/c-api/file.html#PyFile_WriteObject',\n                        prototype='int PyFile_WriteObject(PyObject *obj, PyObject *p, int flags)',\n                        defined_in='Objects/fileobject.c')\n        # used in Cython-generated code, in static int __Pyx_Print()\n        returntype = stmt.fn.type.dereference.type\n\n        # FIXME: gracefully handles NULL for second argument, but not for first\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        # Various errors can happen; this is just one:\n        s_failure.cpython.set_exception('PyExc_IOError', stmt.loc)\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyFile_WriteString(self, stmt, v_s, v_p):\n        fnmeta = FnMeta(name='PyFile_WriteString',\n                        docurl='http://docs.python.org/c-api/file.html#PyFile_WriteString',\n                        defined_in='Objects/fileobject.c')\n        # FIXME: gracefully handles NULL for second argument, but not for first\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        # Various errors can happen; this is just one:\n        s_failure.cpython.set_exception('PyExc_IOError', stmt.loc)\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    ########################################################################\n    # Py_Finalize()\n    ########################################################################\n    def impl_Py_Finalize(self, stmt):\n        fnmeta = FnMeta(name='Py_Finalize',\n                        docurl='http://docs.python.org/c-api/init.html#Py_Finalize')\n        # For now, treat it as a no-op:\n        return [self.state.mktrans_nop(stmt, 'Py_Finalize')]\n\n    ########################################################################\n    # PyFloat_*\n    ########################################################################\n    def impl_PyFloat_AsDouble(self, stmt, v_op):\n        fnmeta = FnMeta(name='PyFloat_AsDouble',\n                        declared_in='floatobject.h',\n                        # FIXME: docurl\n                        prototype=('double '\n                                   'PyFloat_AsDouble(PyObject *op)'),\n                        defined_in='Objects/floatobject.c')\n        # gracefully handles NULL with PyErr_BadArgument:\n        if isinstance(v_op, UnknownValue):\n            self.state.raise_split_value(v_op, stmt.loc)\n        if v_op.is_null_ptr():\n            s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n            s_failure.cpython.bad_argument(stmt.loc)\n            return [Transition(self.state,\n                               s_failure,\n                               '%s() fails due to NULL argument' % fnmeta.name)]\n\n        # if it's exactly a PyFloat_Type, we extract ob_fval\n        # otherwise, we can call into nb_float\n        # or raise TypeError\n        returntype = stmt.fn.type.dereference.type\n\n        if self.object_ptr_has_global_ob_type(v_op, 'PyFloat_Type'):\n            # We know it's a PyFloatObject; the call will succeed:\n            # FIXME: cast:\n            v_ob_fval = self.state.read_field_by_name(stmt,\n                                                      returntype,\n                                                      v_op.region,\n                                                      'ob_fval')\n            t_success = self.state.mktrans_assignment(stmt.lhs,\n                                                v_ob_fval,\n                                                'PyFloat_AsDouble() returns ob_fval')\n            return [t_success]\n        # We don't know if it's a PyFloatObject (or subclass); the call could\n        # fail with TypeError or MemoryError:\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                                            UnknownValue.make(returntype, stmt.loc),\n                                            fnmeta.desc_when_call_succeeds())\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                            ConcreteValue(returntype, stmt.loc, -1),\n                                            fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_success, t_failure]\n\n    def impl_PyFloat_FromDouble(self, stmt, v_fval):\n        fnmeta = FnMeta(name='PyFloat_FromDouble',\n                        declared_in='floatobject.h',\n                        # FIXME: docurl\n                        prototype=('PyObject *'\n                                   ' PyFloat_FromDouble(double fval)'),\n                        defined_in='Objects/floatobject.c')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyFloatObject',\n                                                          'PyFloat_Type')\n        # Set ob_fval in the new object (when successful):\n        t_success.dest.set_field_by_name(r_newobj, 'ob_fval', v_fval)\n\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyFrame_*\n    ########################################################################\n    def impl_PyFrame_New(self, stmt,\n                         v_tstate, v_code, v_globals, v_locals):\n        fnmeta = FnMeta(name='PyFrame_New',\n                        declared_in='frameobject.h',\n                        prototype=('PyFrameObject *\\n'\n                                   'PyFrame_New(PyThreadState *tstate, PyCodeObject *code, PyObject *globals,\\n'\n                                   'PyObject *locals'),\n                        defined_in='Objects/frameobject.c')\n        # (used by Cython-generated code in static void __Pyx_AddTraceback in\n        # each file)\n        # For now, ignore the effects on the input variables:\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyFrameObject',\n                                                          'PyFrame_Type')\n        return [t_success, t_failure]\n\n    ########################################################################\n    # Py_GetVersion\n    ########################################################################\n    def impl_Py_GetVersion(self, stmt):\n        fnmeta = FnMeta(name='Py_GetVersion',\n                        docurl='http://docs.python.org/c-api/init.html#Py_GetVersion',\n                        defined_in='Python/getversion.c')\n        # Returns a non-NULL pointer\n        returntype = stmt.fn.type.dereference.type\n        r_result = Region('region-for-sys-version', None)\n        self.state.region_for_var[r_result] = r_result\n        v_nonnull = PointerToRegion(returntype, stmt.loc, r_result)\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                              v_nonnull,\n                                              fnmeta.name)]\n\n    ########################################################################\n    # PyGILState_*\n    ########################################################################\n    def impl_PyGILState_Ensure(self, stmt):\n        fnmeta = FnMeta(name='PyGILState_Ensure',\n        docurl='http://docs.python.org/c-api/init.html#PyGILState_Ensure')\n        # Return some opaque handle:\n        returntype = stmt.fn.type.dereference.type\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                              UnknownValue.make(returntype, stmt.loc),\n                                              'PyGILState_Ensure')]\n\n    def impl_PyGILState_Release(self, stmt, v_state):\n        fnmeta = FnMeta(name='PyGILState_Release',\n                        docurl='http://docs.python.org/c-api/init.html#PyGILState_Release')\n        # For now, treat it as a no-op:\n        return [self.state.mktrans_nop(stmt, 'PyGILState_Release')]\n\n    ########################################################################\n    # PyImport_*\n    ########################################################################\n    def impl_PyImport_AddModule(self, stmt, v_name):\n        fnmeta = FnMeta(name='PyImport_AddModule',\n                        docurl='http://docs.python.org/c-api/import.html#PyImport_AddModule')\n        # used by cython-generated modules\n        # returns a borrowed ref (or NULL+exc)\n        return self.make_transitions_for_borrowed_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyImport_AppendInittab(self, stmt, v_name, v_initfunc):\n        fnmeta = FnMeta(name='PyImport_AppendInittab',\n                        docurl='http://docs.python.org/c-api/import.html#PyImport_AppendInittab')\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        # (doesn't set an exception on failure, and Py_Initialize shouldn't\n        # have been called yet, in any case)\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyImport_ImportModule(self, stmt, v_name):\n        fnmeta = FnMeta(name='PyImport_ImportModule',\n                        docurl='http://docs.python.org/c-api/import.html#PyImport_ImportModule')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyModuleObject',\n                                                          'PyModule_Type')\n        return [t_success, t_failure]\n\n    ########################################################################\n    # Py_Initialize*\n    ########################################################################\n    def impl_Py_Initialize(self, stmt):\n        fnmeta = FnMeta(name='Py_Initialize',\n                        docurl='http://docs.python.org/c-api/init.html#Py_Initialize')\n        # For now, treat it as a no-op:\n        return [self.state.mktrans_nop(stmt, 'Py_Initialize')]\n\n    ########################################################################\n    # Py_InitModule*\n    ########################################################################\n    def impl_Py_InitModule4_64(self, stmt, v_name, v_methods,\n                               v_doc, v_self, v_apiver):\n        fnmeta = FnMeta(name='Py_InitModule4_64',\n                        prototype=('PyAPI_FUNC(PyObject *) Py_InitModule4(const char *name, PyMethodDef *methods,\\n'\n                                   '                                      const char *doc, PyObject *self,\\n'\n                                   '                                      int apiver);'),\n                        notes=('Returns a borrowed reference'))\n        # FIXME:\n        #  On 64-bit:\n        #    #define Py_InitModule4 Py_InitModule4_64\n        #  with tracerefs:\n        #    #define Py_InitModule4 Py_InitModule4TraceRefs_64\n        #    #define Py_InitModule4 Py_InitModule4TraceRefs\n        s_success = self.mkstate_borrowed_ref(stmt, fnmeta)\n        s_failure = self.mkstate_exception(stmt)\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    ########################################################################\n    # Py_Int*\n    ########################################################################\n    def impl_PyInt_AsLong(self, stmt, v_op):\n        fnmeta = FnMeta(name='PyInt_AsLong',\n                        declared_in='intobject.h',\n                        prototype='PyAPI_FUNC(long) PyInt_AsLong(PyObject *);',\n                        defined_in='Objects/intobject.c',\n                        docurl='http://docs.python.org/c-api/int.html#PyInt_AsLong')\n\n        # Can fail (gracefully) with NULL, and with non-int objects\n\n        returntype = stmt.fn.type.dereference.type\n\n        if self.object_ptr_has_global_ob_type(v_op, 'PyInt_Type'):\n            # We know it's a PyIntObject; the call will succeed:\n            # FIXME: cast:\n            v_ob_ival = self.state.read_field_by_name(stmt,\n                                                      returntype,\n                                                      v_op.region,\n                                                      'ob_ival')\n            t_success = self.state.mktrans_assignment(stmt.lhs,\n                                                v_ob_ival,\n                                                'PyInt_AsLong() returns ob_ival')\n            return [t_success]\n\n        # We don't know if it's a PyIntObject (or subclass); the call could\n        # fail:\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                                            UnknownValue.make(returntype, stmt.loc),\n                                            fnmeta.desc_when_call_succeeds())\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                            ConcreteValue(returntype, stmt.loc, -1),\n                                            fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_success, t_failure]\n\n    def impl_PyInt_FromLong(self, stmt, v_ival):\n        fnmeta = FnMeta(name='PyInt_FromLong',\n                        docurl='http://docs.python.org/c-api/int.html#PyInt_FromLong',\n                        declared_in='intobject.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyInt_FromLong(long);',\n                        defined_in='Objects/intobject.c')\n        #\n        # CPython2 shares objects for integers in the range:\n        #   -5 <= ival < 257\n        # within intobject.c's \"small_ints\" array and these are preallocated\n        # by _PyInt_Init().  Thus, for these values, we know that the call\n        # cannot fail\n\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyIntObject',\n                                                          'PyInt_Type')\n        # Set ob_ival:\n        t_success.dest.set_field_by_name(r_newobj, 'ob_ival', v_ival)\n\n        if isinstance(v_ival, ConcreteValue):\n            if v_ival.value >= -5 and v_ival.value < 257:\n                # We know that failure isn't possible:\n                return [t_success]\n\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyIter_*\n    ########################################################################\n    def impl_PyIter_Next(self, stmt, v_iter):\n        fnmeta = FnMeta(name='PyIter_Next',\n                        declared_in='abstract.h',\n                        prototype='PyObject * PyIter_Next(PyObject *iter);',\n                        defined_in='Objects/abstract.c',\n                        docurl='http://docs.python.org/c-api/iter.html#PyIter_Next')\n\n        returntype = stmt.fn.type.dereference.type\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_iter,\n                               why='directly accesses iter->ob_type')\n\n        # Three outcomes:\n        #   * returns a new ref (next item)\n        #   * returns NULL with no exception set (no more items)\n        #   * returns NULL with an exception (error occurred)\n\n        # The \"next value\" case:\n        s_nextvalue, nonnull = \\\n            self.mkstate_new_ref(stmt,\n                                 'new ref returned by %s()' % fnmeta.name)\n\n        t_nextvalue = Transition(self.state,\n                                 s_nextvalue,\n                                 'when %s() retrieves a value (new ref)' % fnmeta.name)\n\n        # The \"end of iteration\" case:\n        t_end = self.state.mktrans_assignment(stmt.lhs,\n                                              ConcreteValue(returntype, stmt.loc, 0),\n                                              'when %s() returns NULL without setting an exception (end of iteration)' % fnmeta.name)\n\n        # The \"error occurred\" case:\n        t_error = self.state.mktrans_assignment(stmt.lhs,\n                                                ConcreteValue(returntype, stmt.loc, 0),\n                                                'when %s() returns NULL setting an exception (error occurred)' % fnmeta.name)\n\n        t_error.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_nextvalue, t_end, t_error]\n\n    ########################################################################\n    # PyList_*\n    ########################################################################\n    def impl_PyList_Append(self, stmt, v_op, v_newitem):\n        fnmeta = FnMeta(name='PyList_Append',\n                        declared_in='listobject.h',\n                        prototype='PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);',\n                        defined_in='Objects/listobject.c',\n                        docurl='http://docs.python.org/c-api/list.html#PyList_Append')\n\n        # If it succeeds, it adds a reference on the item\n        #\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_op,\n                               why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                             'PyList_Check'))\n\n        # It handles newitem being NULL:\n        if v_newitem.is_null_ptr():\n            s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n            s_failure.cpython.bad_internal_call(stmt.loc)\n            return [Transition(self.state,\n                               s_failure,\n                               'returning -1 from %s() due to NULL item' % fnmeta.name)]\n\n        # On success, adds a ref on input:\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n        s_success.cpython.add_ref(v_newitem, stmt.loc)\n        #...and set the pointer value within ob_item array, so that we can\n        # discount that refcount:\n        ob_item_region = self.state.make_field_region(v_op.region, 'ob_item')\n        ob_size_region = self.state.make_field_region(v_op.region, 'ob_size')\n\n        # Locate the insertion index, based on ob_size:\n        v_index = self.state.read_field_by_name(stmt,\n                                                get_Py_ssize_t().type,\n                                                v_op.region, 'ob_size')\n        if isinstance(v_index, ConcreteValue):\n            index_value = v_index.value\n        elif isinstance(v_index, WithinRange):\n            # We don't know the size of the list, just that it (presumably)\n            # has some sane ob_size.\n            # Use the smallest non-negative size (raising it as a 1-item\n            # SplitValue so that the assumption is noted):\n            index_value = max(0, v_index.minvalue)\n            v_index.raise_as_concrete(stmt.loc,\n                                      index_value,\n                                      'when treating ob_size as %i' % index_value)\n        else:\n            raise NotImplementedError()\n        array_region = s_success._array_region(ob_item_region, index_value)\n\n        s_success.value_for_region[array_region] = v_newitem\n\n        # Can fail with memory error, overflow error:\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyList_GetItem(self, stmt, v_list, v_index):\n        fnmeta = FnMeta(name='PyList_GetItem',\n                        docurl='http://docs.python.org/c-api/list.html#PyList_GetItem',\n                        prototype='PyObject* PyList_GetItem(PyObject *list, Py_ssize_t index)',\n                        defined_in='Objects/listobject.c',\n                        notes='Returns a borrowed reference, or raises an IndexError')\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_list,\n                                               why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                                             'PyList_Check'))\n\n        # FIXME: for now, simply return a borrowed ref, rather than\n        # trying to track indices and the array:\n        s_success = self.mkstate_borrowed_ref(stmt,\n                                              fnmeta)\n        return [Transition(self.state, s_success, None)]\n\n    def impl_PyList_New(self, stmt, v_len):\n        fnmeta = FnMeta(name='PyList_New',\n                        docurl='http://docs.python.org/c-api/list.html#PyList_New',\n                        prototype='PyObject* PyList_New(Py_ssize_t len)',\n                        notes='Returns a new reference, or raises MemoryError')\n\n        check_isinstance(v_len, AbstractValue)\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyListObject',\n                                                          'PyList_Type')\n        # Set ob_size:\n        t_success.dest.set_field_by_name(r_newobj, 'ob_size', v_len)\n\n        # \"Allocate\" ob_item, and set it up so that all of the array is\n        # treated as NULL:\n        ob_item_region = t_success.dest.make_heap_region(\n            'ob_item array for PyListObject',\n            stmt)\n        t_success.dest.value_for_region[ob_item_region] = \\\n            ConcreteValue(get_PyObjectPtr(),\n                          stmt.loc, 0)\n\n        ob_item = t_success.dest.make_field_region(r_newobj, 'ob_item')\n        t_success.dest.value_for_region[ob_item] = PointerToRegion(get_PyObjectPtr().pointer,\n                                                                 stmt.loc,\n                                                                 ob_item_region)\n\n        return [t_success, t_failure]\n\n    def impl_PyList_SetItem(self, stmt, v_list, v_index, v_item):\n        fnmeta = FnMeta(name='PyList_SetItem',\n                        prototype='int PyList_SetItem(PyObject *list, Py_ssize_t index, PyObject *item)',\n                        docurl='http://docs.python.org/c-api/list.html#PyList_SetItem',)\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_list,\n                       why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                     'PyList_Check'))\n\n        # However, it appears to be robust in the face of NULL \"item\" pointers\n\n        result = []\n\n        # Is it really a list?\n        if 0: # FIXME: check\n            not_a_list = self.state.mkstate_concrete_return_of(stmt, -1)\n            result.append(Transition(self.state,\n                           not_a_list,\n                           fnmeta.desc_when_call_fails('not a list')))\n\n        # Index out of range?\n        if 0: # FIXME: check\n            out_of_range = self.state.mkstate_concrete_return_of(stmt, -1)\n            result.append(Transition(self.state,\n                           out_of_range,\n                           fnmeta.desc_when_call_fails('index out of range)')))\n\n        if 1:\n            s_success  = self.state.mkstate_concrete_return_of(stmt, 0)\n            # FIXME: update refcounts\n            # \"Steal\" a reference to item:\n            if isinstance(v_item, PointerToRegion):\n                s_success.cpython.steal_reference(v_item, stmt.loc)\n\n            # and discards a\n            # reference to an item already in the list at the affected position.\n            result.append(Transition(self.state,\n                                     s_success,\n                                     '%s() succeeds' % fnmeta.name))\n\n        return result\n\n    def impl_PyList_Size(self, stmt, v_list):\n        fnmeta = FnMeta(name='PyList_Size',\n                        docurl='http://docs.python.org/c-api/list.html#PyList_Size',\n                        prototype='Py_ssize_t PyList_Size(PyObject *list)',\n                        defined_in='Objects/listobject.c')\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_list,\n                       why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                     'PyList_Check'))\n\n        returntype = stmt.fn.type.dereference.type\n        v_ob_size = self.state.read_field_by_name(stmt,\n                                                  returntype,\n                                                  v_list.region, 'ob_size')\n\n        t_return = self.state.mktrans_assignment(stmt.lhs,\n                                       v_ob_size,\n                                       fnmeta.desc_when_call_returns_value('ob_size'))\n        return [t_return]\n\n    ########################################################################\n    # PyLong_*\n    ########################################################################\n    def impl_PyLong_FromLong(self, stmt, v_long):\n        fnmeta = FnMeta(name='PyLong_FromLong',\n                        docurl='http://docs.python.org/c-api/long.html#PyLong_FromLong')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyLongObject',\n                                                          'PyLong_Type')\n        return [t_success, t_failure]\n\n    def impl_PyLong_FromLongLong(self, stmt, v_v):\n        fnmeta = FnMeta(name='PyLong_FromLongLong',\n                        docurl='http://docs.python.org/c-api/long.html#PyLong_FromLongLong',\n                        prototype='PyObject* PyLong_FromLongLong(PY_LONG_LONG v)')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyLongObject',\n                                                          'PyLong_Type')\n        return [t_success, t_failure]\n\n    def impl_PyLong_FromString(self, stmt, v_str, v_pend, v_base):\n        fnmeta = FnMeta(name='PyLong_FromString',\n                        declared_in='longobject.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyLong_FromString(char *, char **, int);',\n                        defined_in='Objects/longobject.c',\n                        docurl='http://docs.python.org/c-api/long.html#PyLong_FromString')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyLongObject',\n                                                          'PyLong_Type')\n        return [t_success, t_failure]\n\n    def impl_PyLong_FromVoidPtr(self, stmt, v_p):\n        fnmeta = FnMeta(name='PyLong_FromVoidPtr',\n                        docurl='http://docs.python.org/c-api/long.html#PyLong_FromVoidPtr')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyLongObject',\n                                                          'PyLong_Type')\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyMapping_*\n    ########################################################################\n\n    def impl_PyMapping_Size(self, stmt, v_o):\n        fnmeta = FnMeta(name='PyMapping_Size',\n                        docurl='http://docs.python.org/c-api/mapping.html#PyMapping_Size',\n                        prototype='Py_ssize_t PyMapping_Size(PyObject *o)',\n                        defined_in='Objects/abstract.c',\n                        notes='Can cope with NULL (sets exception)')\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                           UnknownValue.make(stmt.lhs.type,\n                                             stmt.loc),\n                           fnmeta.desc_when_call_succeeds())\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                           ConcreteValue(stmt.lhs.type,\n                                         stmt.loc,\n                                         -1),\n                           fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_TypeError',\n                                             stmt.loc)\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyMem_*\n    ########################################################################\n    def impl_PyMem_Free(self, stmt, v_ptr):\n        fnmeta = FnMeta(name='PyMem_Free',\n                        docurl='http://docs.python.org/c-api/memory.html#PyMem_Free')\n\n        # FIXME: it's unsafe to call repeatedly, or on the wrong memory region\n\n        s_new = self.state.use_next_stmt_node()\n        desc = None\n\n        # It's safe to call on NULL\n        if v_ptr.is_null_ptr():\n            desc = 'calling PyMem_Free on NULL'\n        elif isinstance(v_ptr, PointerToRegion):\n            # Mark the arg as being deallocated:\n            region = v_ptr.region\n            check_isinstance(region, Region)\n\n            # Get the description of the region before trashing it:\n            desc = 'calling PyMem_Free on %s' % region\n            #t_temp = state.mktrans_assignment(stmt.lhs,\n            #                                  UnknownValue.make(None, stmt.loc),\n            #                                  'calling tp_dealloc on %s' % region)\n\n            # Mark the region as deallocated\n            # Since regions are shared with other states, we have to set this up\n            # for this state by assigning it with a special \"DeallocatedMemory\"\n            # value\n            # Clear the value for any fields within the region:\n            for k, v in region.fields.items():\n                if v in s_new.value_for_region:\n                    del s_new.value_for_region[v]\n            # Set the default value for the whole region to be \"DeallocatedMemory\"\n            s_new.region_for_var[region] = region\n            s_new.value_for_region[region] = DeallocatedMemory(None, stmt.loc)\n\n        return [Transition(self.state, s_new, desc)]\n\n    def impl_PyMem_Malloc(self, stmt, v_size):\n        fnmeta = FnMeta(name='PyMem_Malloc',\n                        docurl='http://docs.python.org/c-api/memory.html#PyMem_Malloc')\n\n        returntype = stmt.fn.type.dereference.type\n        r_nonnull = self.state.make_heap_region('PyMem_Malloc', stmt)\n        v_nonnull = PointerToRegion(returntype, stmt.loc, r_nonnull)\n        # FIXME: it hasn't been initialized\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                                            v_nonnull,\n                                            fnmeta.desc_when_call_succeeds())\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                            ConcreteValue(returntype, stmt.loc, 0),\n                                            fnmeta.desc_when_call_fails())\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyModule_*\n    ########################################################################\n    def impl_PyModule_AddIntConstant(self, stmt, v_module, v_name, v_value):\n        fnmeta = FnMeta(name='PyModule_AddIntConstant',\n                        docurl='http://docs.python.org/c-api/module.html#PyModule_AddIntConstant')\n\n        # (No externally-visible refcount changes)\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n\n        # Can fail with memory error, overflow error:\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyModule_AddObject(self, stmt, v_module, v_name, v_value):\n        fnmeta = FnMeta(name='PyModule_AddObject',\n                        docurl='http://docs.python.org/c-api/module.html#PyModule_AddObject',\n                        defined_in='Python/modsupport.c',\n                        notes='Steals a reference to the object if if succeeds')\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_module,\n                       why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                     'PyModule_Check'))\n\n        # Explicitly checks for non-NULL obj:\n        if v_value.is_null_ptr():\n            s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n            s_failure.cpython.set_exception('PyExc_TypeError', stmt.loc)\n            return [Transition(self.state,\n                               s_failure,\n                               'returning -1 from %s()' % fnmeta.name)]\n\n        # On success, steals a ref from v_value:\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n        s_success.cpython.steal_reference(v_value, stmt.loc)\n\n        # Can fail with memory error, overflow error:\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyModule_AddStringConstant(self, stmt, v_module, v_name, v_value):\n        fnmeta = FnMeta(name='PyModule_AddStringConstant',\n                        docurl='http://docs.python.org/c-api/module.html#PyModule_AddStringConstant',)\n\n        # (No externally-visible refcount changes)\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n\n        # Can fail with memory error, overflow error:\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PyModule_GetDict(self, stmt, v_module):\n        fnmeta = FnMeta(name='PyModule_GetDict',\n                        docurl='http://docs.python.org/c-api/module.html#PyModule_GetDict',\n                        prototype='PyObject* PyModule_GetDict(PyObject *module)',\n                        notes='Returns a borrowed reference.  Always succeeds')\n\n        s_success = self.mkstate_borrowed_ref(stmt, fnmeta)\n        return [Transition(self.state, s_success, None)]\n\n    ########################################################################\n    # PyNumber_*\n    ########################################################################\n    def impl_PyNumber_Int(self, stmt, v_o):\n        fnmeta = FnMeta(name='PyNumber_Int',\n                        docurl='http://docs.python.org/c-api/number.html#PyNumber_Int',\n                        prototype='PyObject * PyNumber_Int(PyObject *o)')\n        t_err = self.handle_null_error(stmt, 0, v_o)\n        if t_err:\n            return [t_err]\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyNumber_Remainer(self, stmt, v_v, v_w):\n        fnmeta = FnMeta(name='PyNumber_Remainder',\n                        docurl='http://docs.python.org/c-api/number.html#PyNumber_Remainder',\n                        prototype='PyObject * PyNumber_Remainder(PyObject *v, PyObject *w)')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_v,\n                       why='%s() reads though v->ob_type within binary_op1()' % fnmeta.name)\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_w,\n                       why='%s() reads though w->ob_type within binary_op1()' % fnmeta.name)\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    ########################################################################\n    # PyObject_*\n    ########################################################################\n    def _handle_PyObject_CallMethod(self, fncall, fmtargidx, with_size_t):\n        \"\"\"\n        For functions in Objects/abstract.c that use Py_VaBuildValue or\n        _Py_VaBuildValue_SizeT, then use call_function_tail\n        (e.g. handles PyObject_CallFunction also)\n        Also used by PyEval_CallMethod\n        \"\"\"\n        check_isinstance(fncall, FunctionCall)\n        check_isinstance(with_size_t, bool)\n\n        on_success, on_failure = fncall.new_ref_or_fail()\n\n        # The function can succeed or fail\n        # If any of the PyObject* inputs are NULL, it is doomed to failure\n        def _handle_successful_parse(fmt):\n            \"\"\"\n            Returns a boolean: is success of the function possible?\n            \"\"\"\n            exptypes = fmt.iter_exp_types()\n            for v_vararg, (unit, exptype) in zip(fncall.varargs, exptypes):\n                if 0:\n                    print('v_vararg: %r' % v_vararg)\n                    print('  unit: %r' % unit)\n                    print('  exptype: %r %s' % (exptype, exptype))\n                if isinstance(unit, ObjectFormatUnit):\n                    # NULL inputs ptrs guarantee failure:\n                    if v_vararg.is_null_ptr():\n                        # The call will fail:\n                        return False\n\n                    # non-NULL input ptrs receive \"external\" references on\n                    # success for codes \"S\" and \"O\", but code \"N\" steals a\n                    # reference for the args.  The args are then decref-ed\n                    # by the call.  Hence args with code \"N\" lose a ref:\n                    if isinstance(v_vararg, PointerToRegion):\n                        if isinstance(unit, CodeN):\n                            on_success.state.cpython.dec_ref(v_vararg, fncall.stmt.loc)\n                            on_failure.state.cpython.dec_ref(v_vararg, fncall.stmt.loc)\n            return True\n\n        fmt_string = fncall.args[fmtargidx].as_string_constant()\n        if fmt_string:\n            try:\n                fmt = PyBuildValueFmt.from_string(fmt_string, with_size_t)\n                if not _handle_successful_parse(fmt):\n                    on_success.is_possible = False\n            except FormatStringWarning:\n                pass\n\n        return fncall.get_transitions()\n\n    def impl_PyObject_AsFileDescriptor(self, stmt, v_o):\n        fnmeta = FnMeta(name='PyObject_AsFileDescriptor',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_AsFileDescriptor',\n                        prototype='int PyObject_AsFileDescriptor(PyObject *o)',\n                        defined_in='Objects/fileobject.c')\n\n        # Uses PyInt_Check(o) macro, which will segfault on NULL\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_o,\n                   why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                 'PyInt_Check'))\n\n        # For now, don't try to implement the internal logic:\n        t_return = self.state.mktrans_assignment(stmt.lhs,\n                                       UnknownValue.make(stmt.lhs.type, stmt.loc),\n                                       'when %s() returns' % fnmeta.name)\n        return [t_return]\n\n    def impl_PyObject_Call(self, stmt, v_o, v_args, v_kw):\n        fnmeta = FnMeta(name='PyObject_Call',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_Call',\n                        defined_in='Objects/abstract.c',\n                        prototype=('PyObject *\\n'\n                                   'PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw)'))\n        # \"func\" and \"args\" must not be NULL, but \"kw\" can be:\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_o,\n                                               why='looks up func->ob_type')\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_args)\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyObject_CallFunction(self, stmt, v_callable, v_format, *args):\n        fnmeta = FnMeta(name='PyObject_CallFunction',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_CallFunction',\n                        defined_in='Objects/abstract.c',\n                        prototype='PyObject* PyObject_CallFunction(PyObject *callable, char *format, ...)')\n        # callable can be NULL\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_callable, v_format),\n                              varargs=args)\n        self._handle_PyObject_CallMethod(fncall, 1, with_size_t=False)\n        return fncall.get_transitions()\n\n    def impl__PyObject_CallFunction_SizeT(self, stmt, v_callable, v_format, *args):\n        fnmeta = FnMeta(name='_PyObject_CallFunction_SizeT',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_CallFunction',\n                        defined_in='Objects/abstract.c',\n                        prototype='PyObject * _PyObject_CallFunction_SizeT(PyObject *callable, char *format, ...)')\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_callable, v_format),\n                              varargs=args)\n        self._handle_PyObject_CallMethod(fncall, 1, with_size_t=True)\n        return fncall.get_transitions()\n\n    def _check_objargs(self, stmt, fnmeta, args, base_idx):\n        \"\"\"\n        Object/abstract.c: objargs_mktuple(va_list va)\n        expects a NULL-terminated list of PyObject*\n        \"\"\"\n        check_isinstance(fnmeta, FnMeta)\n\n        # must be PyObject* (or NULL):\n        for i, v_arg in enumerate(args):\n            if v_arg.is_null_ptr():\n                continue\n            if not type_is_pyobjptr_subclass(v_arg.gcctype):\n                loc = v_arg.loc\n                if not loc:\n                    loc = stmt.loc\n                gcc.warning(loc,\n                            ('argument %i had type %s but was expecting a PyObject* (or subclass)'\n                             % (i + base_idx + 1, v_arg.gcctype)))\n\n        # check NULL-termination:\n        if not args or not args[-1].is_null_ptr():\n            gcc.warning(stmt.loc,\n                        ('arguments to %s were not NULL-terminated'\n                         % fnmeta.name))\n\n    def impl_PyObject_CallFunctionObjArgs(self, stmt, v_callable, *args):\n        fnmeta = FnMeta(name='PyObject_CallFunctionObjArgs',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_CallFunctionObjArgs',\n                        prototype='PyObject* PyObject_CallFunctionObjArgs(PyObject *callable, ...)',\n                        defined_in='Objects/abstract.c',\n                        notes='args must be NULL-terminated')\n\n        # \"callable\" can be NULL\n\n        # Check args:\n        self._check_objargs(stmt, fnmeta, args, 1)\n\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyObject_CallMethod(self, stmt, v_o, v_name, v_format, *args):\n        fnmeta = FnMeta(name='PyObject_CallMethod',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_CallMethod',\n                        defined_in='Objects/abstract.c',\n                        prototype=('PyObject *\\n'\n                                   'PyObject_CallMethod(PyObject *o, char *name, char *format, ...)'))\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_o, v_name, v_format),\n                              varargs=args)\n        self._handle_PyObject_CallMethod(fncall, 2, with_size_t=False)\n        return fncall.get_transitions()\n\n    def impl__PyObject_CallMethod_SizeT(self, stmt, v_o, v_name, v_format, *args):\n        fnmeta = FnMeta(name='_PyObject_CallMethod_SizeT',\n        # abstract.h has:\n        #   #ifdef PY_SSIZE_T_CLEAN\n        #   #define PyObject_CallMethod _PyObject_CallMethod_SizeT\n        #   #endif\n        #\n                        defined_in='Objects/abstract.c')\n        #   PyObject *\n        #   _PyObject_CallMethod_SizeT(PyObject *o, char *name, char *format, ...)\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_o, v_name, v_format),\n                              varargs=args)\n        self._handle_PyObject_CallMethod(fncall, 2, with_size_t=True)\n        return fncall.get_transitions()\n\n    def impl_PyObject_CallMethodObjArgs(self, stmt, v_o, v_name, *args):\n        fnmeta = FnMeta(name='PyObject_CallMethodObjArgs',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_CallMethodObjArgs',\n                        defined_in='Objects/abstract.c',\n                        prototype='PyObject* PyObject_CallMethodObjArgs(PyObject *o, PyObject *name, ..., NULL)')\n\n        # \"callable\" and \"name\" can be NULL\n\n        # Check args:\n        self._check_objargs(stmt, fnmeta, args, 2)\n\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyObject_CallObject(self, stmt, v_o, v_args):\n        fnmeta = FnMeta(name='PyObject_CallObject',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_CallObject',\n                        defined_in='Objects/abstract.c',\n                        prototype=('PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable_object,\\n'\n                                   '                                           PyObject *args);'))\n        # internally, is just:\n        #    return PyEval_CallObjectWithKeywords(o, a, NULL);\n\n        # args can be NULL, but the callable obj can't be:\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_o,\n                                               why=('%s() looks up func->ob_type (within PyObject_Call'\n                                                    ' within PyEval_CallObjectWithKeywords)'\n                                                    % fnmeta.name))\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyObject_GetAttr(self, stmt, v_v, v_name):\n        fnmeta = FnMeta(name='PyObject_GetAttr',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_GetAttr',\n                        defined_in='Objects/object.c',\n                        prototype='PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name)')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_v,\n               why=invokes_Py_TYPE(fnmeta))\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_name,\n               why=invokes_Py_TYPE_via_macro(fnmeta, 'PyString_Check'))\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyObject_GetAttrString(self, stmt, v_v, v_name):\n        fnmeta = FnMeta(name='PyObject_GetAttrString',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_GetAttrString',\n                        defined_in='Objects/object.c',\n                        prototype='PyObject* PyObject_GetAttrString(PyObject *v, const char *name)')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_v,\n               why=invokes_Py_TYPE(fnmeta))\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_name,\n                                               why=('%s() can call PyString_InternFromString(), '\n                                                    'which calls PyString_FromString(), '\n                                                    'which requires a non-NULL pointer' % fnmeta.name))\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyObject_GetItem(self, stmt, v_o, v_key):\n        fnmeta = FnMeta(name='PyObject_GetItem',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_GetItem',\n                        defined_in='Objects/abstract.c',\n                        prototype='PyObject* PyObject_GetItem(PyObject *o, PyObject *key)')\n        # safely handles NULL for either argument via null_error():\n        t_err = self.handle_null_error(stmt, 0, v_o)\n        if t_err:\n            return [t_err]\n        t_err = self.handle_null_error(stmt, 1, v_key)\n        if t_err:\n            return [t_err]\n        return self.make_transitions_for_new_ref_or_fail(stmt, fnmeta)\n\n    def impl_PyObject_GenericGetAttr(self, stmt, v_o, v_name):\n        fnmeta = FnMeta(name='PyObject_GenericGetAttr',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_GenericGetAttr',\n                        prototype='PyObject* PyObject_GenericGetAttr(PyObject *o, PyObject *name)',\n                        defined_in='Objects/object.c')\n\n        fncall = FunctionCall(self.state, stmt, fnmeta, (v_o, v_name))\n        fncall.crashes_on_null_arg(0,\n                                   why=invokes_Py_TYPE(fnmeta))\n        fncall.crashes_on_null_arg(1,\n                                   why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                                 'PyString_Check'))\n\n        # The \"success\" case:\n        on_success = fncall.can_succeed_new_ref()\n\n        # The \"failure\" case:\n        on_failure = fncall.can_fail()\n        on_failure.returns_NULL()\n        on_failure.sets_exception('PyExc_MemoryError')\n\n        return fncall.get_transitions()\n\n    def impl_PyObject_GenericSetAttr(self, stmt, v_o, v_name, v_value):\n        fnmeta = FnMeta(name='PyObject_GenericSetAttr',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_GenericSetAttr',\n                        prototype='PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)',\n                        defined_in='Objects/object.c')\n\n        fncall = FunctionCall(self.state, stmt, fnmeta, (v_o, v_name, v_value))\n        fncall.crashes_on_null_arg(0,\n                                   why=invokes_Py_TYPE(fnmeta))\n        fncall.crashes_on_null_arg(1,\n                                   why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                                 'PyString_Check'))\n        # (it appears that value can legitimately be NULL)\n\n        on_success = fncall.can_succeed()\n        on_success.returns(0)\n\n        on_failure = fncall.can_fail()\n        on_failure.returns(-1)\n        on_failure.sets_exception('PyExc_AttributeError')\n\n        return fncall.get_transitions()\n\n    def impl_PyObject_HasAttrString(self, stmt, v_o, v_attr_name):\n        fnmeta = FnMeta(name='PyObject_HasAttrString',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_HasAttrString')\n\n        # the object must be non-NULL: it is unconditionally\n        # dereferenced to get the ob_type:\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_o)\n\n        # attr_name must be non-NULL, this fn calls:\n        #   PyObject_GetAttrString(PyObject *v, const char *name)\n        # which can call:\n        #   PyString_InternFromString(const char *cp)\n        #     PyString_FromString(str) <-- must be non-NULL\n        self.state.raise_any_null_ptr_func_arg(stmt, 1, v_attr_name)\n\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        on_true = fncall.add_outcome(fnmeta.desc_when_call_returns_value('1 (true)'))\n        on_true.returns(1)\n\n        on_false = fncall.add_outcome(fnmeta.desc_when_call_returns_value('0 (false)'))\n        on_false.returns(0)\n\n        return fncall.get_transitions()\n\n    def impl_PyObject_IsTrue(self, stmt, v_o):\n        fnmeta = FnMeta(name='PyObject_IsTrue',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_IsTrue')\n\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        on_true = fncall.add_outcome(fnmeta.desc_when_call_returns_value('1 (true)'))\n        on_true.returns(1)\n\n        on_false = fncall.add_outcome(fnmeta.desc_when_call_returns_value('0 (false)'))\n        on_false.returns(0)\n\n        on_failure = fncall.add_outcome(fnmeta.desc_when_call_returns_value('-1 (failure)'))\n        on_failure.returns(-1)\n        on_failure.sets_exception('PyExc_MemoryError') # arbitrarily chosen error\n\n        return fncall.get_transitions()\n\n    def impl__PyObject_New(self, stmt, v_typeptr):\n        fnmeta = FnMeta(name='_PyObject_New',\n        # Declaration in objimpl.h',\n                        prototype='PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);')\n        #\n        # For use via this macro:\n        #   #define PyObject_New(type, typeobj) \\\n        #      ( (type *) _PyObject_New(typeobj) )\n        #\n        # Definition is in Objects/object.c\n        #\n        #   Return value: New reference.\n        check_isinstance(stmt, gcc.GimpleCall)\n        check_isinstance(stmt.fn.operand, gcc.FunctionDecl)\n\n        # Success case: allocation and assignment:\n        s_success, nonnull = self.mkstate_new_ref(stmt, '_PyObject_New')\n        # ...and set up ob_type on the result object:\n        ob_type = s_success.make_field_region(nonnull, 'ob_type')\n        s_success.value_for_region[ob_type] = v_typeptr\n        t_success = Transition(self.state,\n                               s_success,\n                               fnmeta.desc_when_call_succeeds())\n        # Failure case:\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                       ConcreteValue(stmt.lhs.type, stmt.loc, 0),\n                                       fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_success, t_failure]\n\n    def impl_PyObject_Repr(self, stmt, v_o):\n        fnmeta = FnMeta(name='PyObject_Repr',\n                        declared_in='object.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_Repr')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyStringObject',\n                                                          'PyString_Type')\n        return [t_success, t_failure]\n\n    def impl_PyObject_SetAttr(self, stmt,\n                              v_o, v_attr_name, v_v):\n        fnmeta = FnMeta(name='PyObject_SetAttr',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_SetAttr',\n                        defined_in='Objects/object.c',\n                        prototype='int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)')\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_o, v_attr_name, v_v))\n        fncall.crashes_on_null_arg(0,\n               why=invokes_Py_TYPE(fnmeta))\n        fncall.crashes_on_null_arg(1,\n               why=invokes_Py_TYPE_via_macro(fnmeta, 'PyString_Check'))\n        # v_v can be NULL: clears the attribute\n\n        on_success = fncall.can_succeed()\n        on_success.returns(0)\n\n        on_failure = fncall.can_fail()\n        on_failure.returns(-1)\n        on_failure.sets_exception('PyExc_TypeError') # e.g.\n\n        return fncall.get_transitions()\n\n    def impl_PyObject_SetAttrString(self, stmt,\n                                    v_o, v_attr_name, v_v):\n        fnmeta = FnMeta(name='PyObject_SetAttrString',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_SetAttrString',\n                        defined_in='Objects/object.c',\n                        prototype='int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)')\n        fncall = FunctionCall(self.state, stmt, fnmeta,\n                              args=(v_o, v_attr_name, v_v))\n        fncall.crashes_on_null_arg(0,\n            why=invokes_Py_TYPE(fnmeta))\n        fncall.crashes_on_null_arg(1,\n            why=('%s() can call PyString_InternFromString(), '\n                 'which calls PyString_FromString(), '\n                 'which requires a non-NULL pointer' % fnmeta.name))\n        # v_v can be NULL: clears the attribute\n        on_success = fncall.can_succeed()\n        on_success.returns(0)\n\n        on_failure = fncall.can_fail()\n        on_failure.returns(-1)\n        on_failure.sets_exception('PyExc_TypeError') # e.g.\n\n        return fncall.get_transitions()\n\n    def impl_PyObject_Str(self, stmt, v_o):\n        fnmeta = FnMeta(name='PyObject_Str',\n                        docurl='http://docs.python.org/c-api/object.html#PyObject_Str',\n                        declared_in='object.h')\n        #  PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);\n        # also with:\n        #  #define PyObject_Bytes PyObject_Str\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyStringObject',\n                                                          'PyString_Type')\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyOS_*\n    ########################################################################\n    def impl_PyOS_snprintf(self, stmt, v_str, v_size, v_format, *v_args):\n        fnmeta = FnMeta(name='PyOS_snprintf',\n                        docurl='http://docs.python.org/c-api/conversion.html#PyOS_snprintf',\n                        prototype='int PyOS_snprintf(char *str, size_t size, const char *format, ...)')\n        returntype = stmt.fn.type.dereference.type\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                              UnknownValue.make(returntype,\n                                                                stmt.loc),\n                                              None)]\n\n    ########################################################################\n    # PyRun_*\n    ########################################################################\n    def impl_PyRun_SimpleFileExFlags(self, stmt, v_fp, v_filename,\n                                     v_closeit, v_flags):\n        fnmeta = FnMeta(name='PyRun_SimpleFileExFlags',\n                        docurl='http://docs.python.org/c-api/veryhigh.html#PyRun_SimpleFileExFlags')\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        on_success = fncall.can_succeed()\n        on_success.returns(0)\n\n        on_failure = fncall.can_fail()\n        on_failure.returns(-1)\n        # (no way to get the exception on failure)\n\n        # (FIXME: handle the potential autoclosing of the FILE*)\n\n        return fncall.get_transitions()\n\n    def impl_PyRun_SimpleStringFlags(self, stmt, v_command, v_flags):\n        fnmeta = FnMeta(name='PyRun_SimpleStringFlags',\n                        docurl='http://docs.python.org/c-api/veryhigh.html#PyRun_SimpleStringFlags')\n        fncall = FunctionCall(self.state, stmt, fnmeta)\n        on_success = fncall.can_succeed()\n        on_success.returns(0)\n\n        on_failure = fncall.can_fail()\n        on_failure.returns(-1)\n        # (no way to get the exception on failure)\n\n        return fncall.get_transitions()\n\n    ########################################################################\n    # PySequence_*\n    ########################################################################\n    def impl_PySequence_Concat(self, stmt, v_o1, v_o2):\n        fnmeta = FnMeta(name='PySequence_Concat',\n                        docurl='http://docs.python.org/c-api/sequence.html#PySequence_Concat',\n                        declared_in='abstract.h',\n                        prototype='PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2);',\n                        defined_in='Objects/abstract.c')\n        # safely handles NULL for either argument via null_error():\n        t_err = self.handle_null_error(stmt, 0, v_o1)\n        if t_err:\n            return [t_err]\n        t_err = self.handle_null_error(stmt, 1, v_o2)\n        if t_err:\n            return [t_err]\n        return self.make_transitions_for_new_ref_or_fail(stmt,\n                                                         fnmeta,\n                                                         'new ref from %s' % fnmeta.name)\n\n    def impl_PySequence_DelItem(self, stmt, v_o, v_i):\n        fnmeta = FnMeta(name='PySequence_DelItem',\n                        docurl='http://docs.python.org/c-api/sequence.html#PySequence_DelItem',\n                        declared_in='abstract.h',\n                        prototype='int PySequence_DelItem(PyObject *o, Py_ssize_t i);',\n                        defined_in='Objects/abstract.c')\n        # safely handles NULL via null_error():\n        t_err = self.handle_null_error(stmt, 0, v_o, rawreturnvalue=-1)\n        if t_err:\n            return [t_err]\n\n        # can fail with -1, setting an exception\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_TypeError', stmt.loc)\n\n        # otherwise, expect zero\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    def impl_PySequence_GetItem(self, stmt, v_o, v_i):\n        fnmeta = FnMeta(name='PySequence_GetItem',\n                        docurl='http://docs.python.org/c-api/sequence.html#PySequence_GetItem',\n                        declared_in='abstract.h',\n                        prototype='PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);',\n                        defined_in='Objects/abstract.c')\n        #   PyObject *\n        #   PySequence_GetItem(PyObject *s, Py_ssize_t i)\n        #   {\n        #      [... setup and error handling ...]\n        #      return m->sq_item(s, i);\n        #   }\n        #\n        # When it succeeds, it returns a new reference; see e.g.\n        # Objects/listobject.c: list_item (the sq_item callback for\n        # PyList_Type): it Py_INCREFs the returned item.\n\n        return self.make_transitions_for_new_ref_or_fail(stmt,\n                                                         fnmeta,\n                                                         'new ref from %s' % fnmeta.name)\n\n    def impl_PySequence_GetSlice(self, stmt, v_o, v_i1, v_i2):\n        fnmeta = FnMeta(name='PySequence_GetSlice',\n                        docurl='http://docs.python.org/c-api/sequence.html#PySequence_GetSlice',\n                        declared_in='abstract.h',\n                        prototype='PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);',\n                        defined_in='Objects/abstract.c')\n        # safely handles NULL for the obj via null_error():\n        t_err = self.handle_null_error(stmt, 0, v_o)\n        if t_err:\n            return [t_err]\n        return self.make_transitions_for_new_ref_or_fail(stmt,\n                                                         fnmeta,\n                                                         'new ref from %s' % fnmeta.name)\n\n    def impl_PySequence_Length(self, stmt, v_o):\n        return self.impl_PySequence_Size(stmt, v_o)\n\n    def impl_PySequence_SetItem(self, stmt, v_o, v_i, v_item):\n        fnmeta = FnMeta(name='PySequence_SetItem',\n                        prototype='int PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *item)',\n                        docurl='http://docs.python.org/c-api/sequence.html#PySequence_SetItem',\n                        defined_in='Objects/abstract.c')\n        # safely handles NULL for the obj via null_error():\n        t_err = self.handle_null_error(stmt, 0, v_o, rawreturnvalue=-1)\n        if t_err:\n            return [t_err]\n\n        result = []\n\n        s_success  = self.state.mkstate_concrete_return_of(stmt, 0)\n        # The function *doesn't* steal a reference to item\n\n        # For now, this only covers the \"success\" case.  The call can fail\n        # returning -1:\n        #   * raising TypeError if passed a non-sequence, or if the type's\n        #     PySequenceMethods table lacks a sq_ass_item callback\n        #   * if the call to sq_length fails, propagating some exception\n        #   * if the call to sq_ass_item fails, propagating some exception\n        # but we don't track these possibilities yet.\n\n        result.append(Transition(self.state,\n                                 s_success,\n                                 '%s() succeeds' % fnmeta.name))\n\n        return result\n\n    def impl_PySequence_Size(self, stmt, v_o):\n        fnmeta = FnMeta(name='PySequence_Size',\n                        docurl='http://docs.python.org/c-api/sequence.html#PySequence_Size',\n                        prototype='Py_ssize_t PySequence_Size(PyObject *s)',\n                        defined_in='Objects/abstract.c')\n\n        # safely handles NULL for the obj via null_error():\n        t_err = self.handle_null_error(stmt, 0, v_o, rawreturnvalue=-1)\n        if t_err:\n            return [t_err]\n\n        # on success, expect a value >= 0\n        returntype = stmt.fn.type.dereference.type\n        s_success = self.state.mkstate_return_of(stmt,\n                                                 WithinRange.ge_zero(returntype,\n                                                                     stmt.loc))\n        # else, return -1 and set an exception\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_TypeError', stmt.loc)\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    ########################################################################\n    # PyString_*\n    ########################################################################\n    def impl_PyString_AsString(self, stmt, v_op):\n        fnmeta = FnMeta(name='PyString_AsString',\n                        declared_in='stringobject.h',\n                        prototype='PyAPI_FUNC(char *) PyString_AsString(PyObject *);',\n                        defined_in='Objects/stringobject.c',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_AsString')\n        #\n        # With PyStringObject and their subclasses, it returns\n        #    ((PyStringObject *)op) -> ob_sval\n        # With other classes, this call can fail\n\n        # It will segfault if called with NULL, since it uses PyString_Check,\n        # which reads through the object's ob_type:\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_op,\n                     why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                   'PyString_Check'))\n\n        returntype = stmt.fn.type.dereference.type\n\n        if self.object_ptr_has_global_ob_type(v_op, 'PyString_Type'):\n            # We know it's a PyStringObject; the call will succeed:\n            # FIXME: cast:\n            r_ob_sval = self.state.make_field_region(v_op.region, 'ob_sval')\n            v_result = PointerToRegion(returntype, stmt.loc, r_ob_sval)\n            t_success = self.state.mktrans_assignment(stmt.lhs,\n                                                v_result,\n                                                'PyString_AsString() returns ob_sval')\n            return [t_success]\n\n        # We don't know if it's a PyStringObject (or subclass); the call could\n        # fail:\n        r_nonnull = self.state.make_heap_region('buffer from PyString_AsString()', stmt)\n        v_success = PointerToRegion(returntype, stmt.loc, r_nonnull)\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                                            v_success,\n                                            fnmeta.desc_when_call_succeeds())\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                            ConcreteValue(returntype, stmt.loc, 0),\n                                            fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_success, t_failure]\n\n    def impl_PyString_Concat(self, stmt, v_pv, v_w):\n        fnmeta = FnMeta(name='PyString_Concat',\n                        prototype='void PyString_Concat(PyObject **string, PyObject *newpart)',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_Concat',\n                        defined_in='Objects/stringobject.c',\n                        notes='')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_pv,\n               why='%s unconditionally dereferences its first argument' % fnmeta.name)\n\n        # However, it can survive *pv being NULL; does nothing\n        v_star_pv = self.state.dereference(stmt.fn.operand,\n                                           v_pv,\n                                           stmt.loc)\n        if v_star_pv.is_null_ptr():\n            s_nop = self.state.mkstate_nop(stmt)\n            return [Transition(self.state,\n                               s_nop,\n                               fnmeta.desc_special('does nothing due to NULL *lhs'))]\n\n        # It can survive w being NULL: cleans up *pv\n        if v_w.is_null_ptr():\n            # Py_DECREF(*pv)\n            s_nop = self.state.mkstate_nop(stmt)\n            result = s_nop.cpython.mktransitions_Py_DECREF(v_star_pv,\n                                                           stmt)\n\n            # *pv = NULL, and set desc:\n            for t_new in result:\n                t_new.dest.value_for_region[v_pv.region] = \\\n                    make_null_ptr(get_PyObjectPtr(), stmt.loc)\n                t_new.desc = fnmeta.desc_special(\n                    'cleans up due to NULL right-hand side (%s on *LHS)'\n                    % t_new.desc)\n            return result\n\n        # Try to allocate new string, which can fail:\n        s_success = self.state.mkstate_nop(stmt)\n        typeobjregion = self.typeobjregion_by_name('PyString_Type')\n        r_nonnull = s_success.cpython.make_sane_object(\n            stmt,\n            'result of %s' % fnmeta.name,\n            RefcountValue.new_ref(stmt.loc, None))\n        s_failure = self.mkstate_exception(stmt)\n\n\n        # Handle Py_DECREF(*pv):\n        t_successes = s_success.cpython.mktransitions_Py_DECREF(v_star_pv,\n                                                                stmt)\n        t_failures = s_failure.cpython.mktransitions_Py_DECREF(v_star_pv,\n                                                               stmt)\n\n        # Handle *pv = v:\n        for t_success in t_successes:\n            t_success.dest.value_for_region[v_pv.region] = \\\n                    PointerToRegion(get_PyObjectPtr(), stmt.loc, r_nonnull)\n            t_success.desc = fnmeta.desc_when_call_succeeds() + ' (%s on *LHS)' % t_success.desc\n\n        for t_failure in t_failures:\n            t_failure.dest.value_for_region[v_pv.region] = \\\n                ConcreteValue(get_PyObjectPtr(), stmt.loc, 0)\n            t_failure.desc = fnmeta.desc_when_call_fails() + ' (%s on *LHS)' % t_failure.desc\n\n        return t_successes + t_failures\n\n    def impl_PyString_ConcatAndDel(self, stmt, v_pv, v_w):\n        fnmeta = FnMeta(name='PyString_ConcatAndDel',\n                        prototype='void PyString_ConcatAndDel(PyObject **string, PyObject *newpart)',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_ConcatAndDel',\n                        defined_in='Objects/stringobject.c',\n                        notes='Decrements the reference count of newpart')\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_pv,\n               why='dereferences it unconditionally within PyString_Concat')\n        # However, it can survive *pv being NULL; does nothing\n\n        # It can survive w being NULL: cleans up *pv\n\n        if isinstance(v_w, UnknownValue):\n            self.state.raise_split_value(v_w, stmt.loc)\n\n        # Mostly implemented in terms of PyString_Concat:\n        results = self.impl_PyString_Concat(stmt, v_pv, v_w)\n        # decrefs the new *pv, if non-NULL\n        if not v_w.is_null_ptr():\n            new_results = []\n            for t_concat in results:\n                for t_withdecref in t_concat.dest.cpython.mktransitions_Py_DECREF(v_w,\n                                                                                  stmt):\n                    t_withdecref.desc = t_concat.desc + ' (%s on RHS)' % t_withdecref.desc\n                    new_results.append(t_withdecref)\n            return new_results\n        return results\n\n    def impl_PyString_FromFormat(self, stmt, v_fmt, *v_args):\n        fnmeta = FnMeta(name='PyString_FromFormat',\n                        declared_in='stringobject.h',\n                        prototype=('PyAPI_FUNC(PyObject *) PyString_FromFormat(const char*, ...)\\n'\n                                   '    Py_GCC_ATTRIBUTE((format(printf, 1, 2)));'),\n                        notes='Returns a new reference',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_FromFormat')\n        # (We do not yet check that the format string matches the types of the\n        # varargs)\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyStringObject',\n                                                          'PyString_Type')\n        return [t_success, t_failure]\n\n    def impl_PyString_FromString(self, stmt, v_str):\n        fnmeta = FnMeta(name='PyString_FromString',\n                        declared_in='stringobject.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyString_FromString(const char *);',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_FromString')\n        # The input _must_ be non-NULL; it is not checked:\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_str)\n\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyStringObject',\n                                                          'PyString_Type')\n        return [t_success, t_failure]\n\n    def impl_PyString_FromStringAndSize(self, stmt, v_str, v_size):\n        fnmeta = FnMeta(name='PyString_FromStringAndSize',\n                        declared_in='stringobject.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyString_FromStringAndSize(const char *, Py_ssize_t);',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_FromStringAndSize',\n                        defined_in='Objects/stringobject.c')\n        #   # PyObject *\n        #   PyString_FromStringAndSize(const char *str, Py_ssize_t size)\n\n        # v_str, v_size = self.state.eval_stmt_args(stmt)\n        # (the input can legitimately be NULL)\n\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyStringObject',\n                                                          'PyString_Type')\n        return [t_success, t_failure]\n\n    def impl_PyString_InternFromString(self, stmt, v_v):\n        fnmeta = FnMeta(name='PyString_InternFromString',\n                        declared_in='stringobject.h',\n                        prototype='PyObject* PyString_InternFromString(const char *v)',\n                        defined_in='Objects/stringobject.c',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_InternFromString')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_v,\n               why=('%s() calls PyString_FromString(), '\n                    'which requires a non-NULL pointer' % fnmeta.name))\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyStringObject',\n                                                          'PyString_Type')\n        return [t_success, t_failure]\n\n    def impl_PyString_Size(self, stmt, v_string):\n        fnmeta = FnMeta(name='PyString_Size',\n                        docurl='http://docs.python.org/c-api/string.html#PyString_Size',\n                        prototype='Py_ssize_t PyString_Size(PyObject *string)',\n                        defined_in='Objects/stringobject.c')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_string,\n                     why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                   'PyString_Check'))\n        # for strings, returns ob_size\n        if self.object_ptr_has_global_ob_type(v_string, 'PyString_Type'):\n            # We know it's a PyStringObject; the call will succeed:\n            returntype = stmt.fn.type.dereference.type\n            v_ob_size = self.state.read_field_by_name(stmt,\n                                                      returntype,\n                                                      v_op.region,\n                                                      'ob_size')\n            t_success = self.state.mktrans_assignment(stmt.lhs,\n                                                v_ob_size,\n                                                fnmeta.desc_when_call_returns_value('ob_size'))\n            return [t_success]\n\n        # for non-strings, can fail with -1, setting an exception\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n\n        # otherwise, expect a non-negative value:\n        returntype = stmt.fn.type.dereference.type\n        s_success = self.state.mkstate_return_of(stmt,\n                                                 WithinRange.ge_zero(returntype,\n                                                                     stmt.loc))\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    ########################################################################\n    # PyStructSequence_*\n    ########################################################################\n    def impl_PyStructSequence_InitType(self, stmt, v_type, v_desc):\n        fnmeta = FnMeta(name='PyStructSequence_InitType',\n                        prototype='void PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc)',\n                        defined_in='Objects/structseq.c')\n        # For now, treat it as a no-op:\n        return [self.state.mktrans_nop(stmt, 'PyStructSequence_InitType')]\n\n    def impl_PyStructSequence_New(self, stmt, v_typeptr):\n        fnmeta = FnMeta(name='PyStructSequence_New',\n                        declared_in='structseq.h',\n                        prototype='PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);',\n                        defined_in='Objects/structseq.c')\n\n        # From our perspective, this is very similar to _PyObject_New\n        check_isinstance(stmt, gcc.GimpleCall)\n        check_isinstance(stmt.fn.operand, gcc.FunctionDecl)\n\n        # Success case: allocation and assignment:\n        s_success, nonnull = self.mkstate_new_ref(stmt, 'PyStructSequence_New')\n        # ...and set up ob_type on the result object:\n        ob_type = s_success.make_field_region(nonnull, 'ob_type')\n        s_success.value_for_region[ob_type] = v_typeptr\n        t_success = Transition(self.state,\n                               s_success,\n                               fnmeta.desc_when_call_succeeds())\n        # Failure case:\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                       ConcreteValue(stmt.lhs.type, stmt.loc, 0),\n                                       fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PySys_*\n    ########################################################################\n    def impl_PySys_GetObject(self, stmt, v_name):\n        fnmeta = FnMeta(name='PySys_GetObject',\n                        declared_in='sysmodule.h',\n                        defined_in='Python/sysmodule.c',\n                        prototype='PyAPI_FUNC(PyObject *) PySys_GetObject(char *);',\n                        docurl='http://docs.python.org/c-api/sys.html#PySys_GetObject')\n\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_name,\n                          why='%s() invokes PyString_FromString()' % fnmeta.name)\n\n        s_success = self.mkstate_borrowed_ref(stmt, fnmeta)\n        t_notfound = self.state.mktrans_assignment(stmt.lhs,\n                                             make_null_pyobject_ptr(stmt),\n                                             '%s does not find string' % fnmeta.name)\n        return [self.state.mktrans_from_fncall_state(stmt, s_success,\n                                                     'succeeds', True),\n                t_notfound]\n\n    def impl_PySys_SetObject(self, stmt, v_name, v_value):\n        fnmeta = FnMeta(name='PySys_SetObject',\n                        declared_in='sysmodule.h',\n                        defined_in='Python/sysmodule.c',\n                        prototype='int PySys_SetObject(char *name, PyObject *v)',\n                        docurl='http://docs.python.org/c-api/sys.html#PySys_SetObject')\n        #\n        # can be called with NULL or non-NULL, calls PyDict_SetItemString\n        # on non-NULL, which adds a ref on it\n\n        returntype = stmt.fn.type.dereference.type\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                                            ConcreteValue(returntype, stmt.loc, 0),\n                                            fnmeta.desc_when_call_succeeds())\n        if isinstance(v_value, PointerToRegion):\n            t_success.dest.cpython.add_external_ref(v_value, stmt.loc)\n        t_failure = self.state.mktrans_assignment(stmt.lhs,\n                                            ConcreteValue(returntype, stmt.loc, -1),\n                                            fnmeta.desc_when_call_fails())\n        t_failure.dest.cpython.set_exception('PyExc_MemoryError', stmt.loc)\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyTraceback_*\n    ########################################################################\n    def impl_PyTraceBack_Here(self, stmt, v_frame):\n        fnmeta = FnMeta(name='PyTraceBack_Here',\n                        prototype='int PyTraceBack_Here(PyFrameObject *frame)',\n                        declared_in='traceback.h',\n                        defined_in='Python/traceback.c')\n        # (used in cython-generated code __Pyx_AddTraceback)\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    ########################################################################\n    # PyTuple_*\n    ########################################################################\n    def impl_PyTuple_GetItem(self, stmt, v_op, v_i):\n        fnmeta = FnMeta(name='PyTuple_GetItem',\n                        docurl='http://docs.python.org/c-api/tuple.html#PyTuple_GetItem',\n                        defined_in='Objects/tupleobject.c')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_op,\n                   why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                 'PyTuple_Check'))\n        # FIXME: for now, simply return a borrowed ref, rather than\n        # trying to track indices and the array:\n        s_success = self.mkstate_borrowed_ref(stmt,\n                                              fnmeta)\n        return [Transition(self.state, s_success, None)]\n\n    def impl_PyTuple_New(self, stmt, v_len):\n        fnmeta = FnMeta(name='PyTuple_New',\n                        docurl='http://docs.python.org/c-api/tuple.html#PyTuple_New')\n\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyTupleObject',\n                                                          'PyTuple_Type')\n        # Set ob_size:\n        t_success.dest.set_field_by_name(r_newobj, 'ob_size', v_len)\n        return [t_success, t_failure]\n\n    def impl_PyTuple_Pack(self, stmt, v_n, *v_args):\n        fnmeta = FnMeta(name='PyTuple_Pack',\n                        docurl='http://docs.python.org/c-api/tuple.html#PyTuple_Pack',\n                        defined_in='Objects/tupleobject.c')\n\n        if isinstance(v_n, ConcreteValue):\n            if v_n.value != len(v_args):\n                class WrongArgCount(PredictedError):\n                    def __str__(self):\n                        return 'mismatching argument count in call to %s' % fnmeta.name\n                raise WrongArgCount()\n\n        # All PyObject* args must be non-NULL:\n        for i, v_arg in enumerate(v_args):\n            self.state.raise_any_null_ptr_func_arg(stmt, i+1, v_arg,\n                                  why=invokes_Py_INCREF(fnmeta))\n\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyTupleObject',\n                                                          'PyTuple_Type')\n        # Set ob_size:\n        t_success.dest.set_field_by_name(r_newobj, 'ob_size', v_n)\n\n        #FIXME: adds a ref on each item; sets ob_item\n        return [t_success, t_failure]\n\n    def impl_PyTuple_SetItem(self, stmt, v_op, v_i, v_newitem):\n        fnmeta = FnMeta(name='PyTuple_SetItem',\n                        docurl='http://docs.python.org/c-api/tuple.html#PyTuple_SetItem',\n                        defined_in='Objects/tupleobject.c')\n\n        returntype = stmt.fn.type.dereference.type\n\n        # The CPython implementation uses PyTuple_Check, which uses\n        # Py_TYPE(op), an unchecked read through the ptr:\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_op,\n                   why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                 'PyTuple_Check'))\n\n        # i is range checked\n        # newitem can safely be NULL\n\n        result = []\n\n        # Check that it's a tuple:\n        if not self.object_ptr_has_global_ob_type(v_op, 'PyTuple_Type'):\n            # FIXME: Py_XDECREF on newitem\n            s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n            s_failure.cpython.bad_internal_call(stmt.loc)\n            result.append(Transition(self.state,\n                                     s_failure,\n                                     fnmeta.desc_when_call_fails('not a tuple')))\n\n        # Check that refcount is 1 (mutation during initial creation):\n        v_ob_refcnt = self.state.get_value_of_field_by_region(v_op.region,\n                                                              'ob_refcnt')\n        # Because of the way we store RefcountValue instances, we can't\n        # easily prove that the refcount == 1, so only follow this path\n        # if we can prove that refcount != 1\n        eq_one = v_ob_refcnt.eval_comparison('eq', ConcreteValue.from_int(1), None)\n        if eq_one is False: # tri-state\n            # FIXME: Py_XDECREF on newitem\n            s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n            s_failure.cpython.bad_internal_call(stmt.loc)\n            result.append(Transition(self.state,\n                                     s_failure,\n                                     fnmeta.desc_when_call_fails('refcount is not 1')))\n\n            # It's known that no further outcomes are possible:\n            return result\n\n        # Range check:\n        v_ob_size = self.state.read_field_by_name(stmt,\n                                                  None,\n                                                  v_op.region,\n                                                  'ob_size')\n\n        lt_zero = v_i.eval_comparison('lt', ConcreteValue.from_int(0), None)\n        lt_size = v_i.eval_comparison('lt', v_ob_size, None)\n        # The above could be None: signifying that we don't know, and that\n        # False is possible.  Out-of-range is possible if either aren't known\n        # to be non-False:\n        if lt_zero is not False or lt_size is not True:\n            s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n            s_failure.cpython.set_exception('PyExc_IndexError', stmt.loc)\n            result.append(Transition(self.state,\n                                     s_failure,\n                                     fnmeta.desc_when_call_fails('index out of range')))\n\n        # Within range is only possible if both boundaries are known to not\n        # definitely be wrong:\n        if lt_zero is not True and lt_size is not False:\n            s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n            r_ob_item = s_success.make_field_region(v_op.region, 'ob_item')\n            r_indexed = s_success._array_region(r_ob_item, v_i)\n            # v_olditem = s_success.value_for_region[r_indexed]\n            # FIXME: it does an XDECREF on the olditem\n            s_success.value_for_region[r_indexed] = v_newitem\n\n            result.append(Transition(self.state,\n                                     s_success,\n                                     fnmeta.desc_when_call_succeeds()))\n\n        return result\n\n\n    def impl_PyTuple_Size(self, stmt, v_op):\n        fnmeta = FnMeta(name='PyTuple_Size',\n                        docurl='http://docs.python.org/c-api/tuple.html#PyTuple_Size',\n                        defined_in='Objects/tupleobject.c')\n\n        returntype = stmt.fn.type.dereference.type\n\n        # The CPython implementation uses PyTuple_Check, which uses\n        # Py_TYPE(op), an unchecked read through the ptr:\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_op,\n                   why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                 'PyTuple_Check'))\n\n        # FIXME: cast:\n        v_ob_size = self.state.read_field_by_name(stmt,\n                                                  returntype,\n                                                  v_op.region,\n                                                  'ob_size')\n\n        t_success = self.state.mktrans_assignment(stmt.lhs,\n                                            v_ob_size,\n                                            fnmeta.desc_when_call_returns_value('ob_size'))\n\n        if self.object_ptr_has_global_ob_type(v_op, 'PyTuple_Type'):\n            # We know it's a PyTupleObject; the call will succeed:\n            return [t_success]\n\n        # Can fail if not a tuple:\n        # (For now, ignore the fact that it could be a tuple subclass)\n\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_SystemError', stmt.loc)\n        t_failure = Transition(self.state,\n                               s_failure,\n                               fnmeta.desc_when_call_fails('not a tuple'))\n        return [t_success, t_failure]\n\n    ########################################################################\n    # PyType_*\n    ########################################################################\n    def impl_PyType_IsSubtype(self, stmt, v_a, v_b):\n        fnmeta = FnMeta(name='PyType_IsSubtype',\n                        docurl='http://docs.python.org/dev/c-api/type.html#PyType_IsSubtype')\n        returntype = stmt.fn.type.dereference.type\n        return [self.state.mktrans_assignment(stmt.lhs,\n                                        UnknownValue.make(returntype, stmt.loc),\n                                        None)]\n\n    def impl_PyType_Ready(self, stmt, v_type):\n        fnmeta = FnMeta(name='PyType_Ready',\n                        docurl='http://docs.python.org/dev/c-api/type.html#PyType_Ready')\n        s_success = self.state.mkstate_concrete_return_of(stmt, 0)\n\n        s_failure = self.state.mkstate_concrete_return_of(stmt, -1)\n        s_failure.cpython.set_exception('PyExc_MemoryError', stmt.loc) # various possible errors\n\n        return self.state.make_transitions_for_fncall(stmt, fnmeta,\n                                                      s_success, s_failure)\n\n    ########################################################################\n    # PyUnicode_*\n    ########################################################################\n\n    def impl_PyUnicode_AsUTF8String(self, stmt, v_unicode):\n        fnmeta = FnMeta(name='PyUnicode_AsUTF8String',\n                        docurl='http://docs.python.org/c-api/unicode.html#PyUnicode_AsUTF8String',\n                        prototype='PyObject* PyUnicode_AsUTF8String(PyObject *unicode)',\n                        defined_in='Objects/unicodeobject.c')\n        self.state.raise_any_null_ptr_func_arg(stmt, 0, v_unicode,\n                          why=invokes_Py_TYPE_via_macro(fnmeta,\n                                                        'PyUnicode_Check'))\n        r_newobj, t_success, t_failure = self.object_ctor_bytes(stmt)\n        return [t_success, t_failure]\n\n    def impl_PyUnicodeUCS4_AsUTF8String(self, stmt, v_unicode):\n        return self.impl_PyUnicode_AsUTF8String(stmt, v_unicode)\n\n    def impl_PyUnicode_DecodeUTF8(self, stmt, v_s, v_size, v_errors):\n        fnmeta = FnMeta(name='PyUnicode_DecodeUTF8',\n                        docurl='http://docs.python.org/c-api/unicode.html#PyUnicode_DecodeUTF8',\n                        prototype=('PyObject *\\n'\n                                   'PyUnicode_DecodeUTF8(const char *s,\\n'\n                                   '                     Py_ssize_t size,\\n'\n                                   '                     const char *errors)'),\n                        defined_in='Objects/unicodeobject.c')\n        r_newobj, t_success, t_failure = self.object_ctor(stmt,\n                                                          'PyUnicodeObject',\n                                                          'PyUnicode_Type')\n        return [t_success, t_failure]\n\n    def impl_PyUnicodeUCS4_DecodeUTF8(self, stmt, v_s, v_size, v_errors):\n        return self.impl_PyUnicode_DecodeUTF8(stmt, v_s, v_size, v_errors)\n\n    ########################################################################\n    # PyWeakref_*\n    ########################################################################\n\n    def impl_PyWeakref_GetObject(self, stmt, v_op):\n        fnmeta = FnMeta(name='PyWeakref_GetObject',\n                        docurl='http://docs.python.org/c-api/weakref.html#PyWeakref_GetObject',\n                        defined_in='Objects/weakrefobject.c')\n        if isinstance(v_op, UnknownValue):\n            self.state.raise_split_value(v_op, stmt.loc)\n        if v_op.is_null_ptr():\n            s_failure = self.state.mkstate_concrete_return_of(stmt, 0)\n            s_failure.cpython.bad_internal_call(stmt.loc)\n            return [Transition(self.state,\n                               s_failure,\n                               '%s() fails due to NULL argument' % fnmeta.name)]\n        s_success = self.mkstate_borrowed_ref(stmt,\n                                              fnmeta)\n        return [Transition(self.state, s_success, None)]\n\n\n    ########################################################################\n    # (end of Python API implementations)\n    ########################################################################\n\n    ########################################################################\n    # SWIG_*\n    ########################################################################\n    def impl_SWIG_Python_ErrorType(self, stmt, v_code):\n        fnmeta = FnMeta(name='SWIG_Python_ErrorType',\n                        prototype='PyObject* SWIG_Python_ErrorType(int code)')\n        # returns a borrowed reference to one of the builtin exception types\n        # Cannot return NULL\n        # For now, hardcode a TypeError:\n        exc_decl = compat.get_exception_decl_by_name('PyExc_TypeError')\n        check_isinstance(exc_decl, gcc.VarDecl)\n        r_exception = self.state.var_region(exc_decl)\n        v_exception = PointerToRegion(get_PyObjectPtr(), stmt.loc, r_exception)\n        t_next = self.state.mktrans_assignment(stmt.lhs,\n                                               v_exception,\n                                               '%s()' % fnmeta.name)\n        return [t_next]\n\n    def impl_SWIG_Python_SetErrorMsg(self, stmt, v_errtype, v_msg):\n        fnmeta = FnMeta(name='SWIG_Python_SetErrorMsg')\n\n        # Calls PyErr_SetString:\n        result = self.impl_PyErr_SetString(stmt, v_errtype, v_msg)\n        for t_iter in result:\n            t_iter.desc = 'calling %s()' % fnmeta.name\n        return result\n\n\ndef get_traces(fun):\n    stmtgraph = make_stmt_graph(fun)\n    return list(iter_traces(stmtgraph,\n                            {'cpython':CPython},\n                            limits=Limits(maxtrans=1024)))\n\ndef dump_traces_to_stdout(traces):\n    \"\"\"\n    For use in selftests: dump the traces to stdout, in a form that (hopefully)\n    will allow usable comparisons against \"gold\" output ( not embedding\n    anything that changes e.g. names of temporaries, address of wrapper\n    objects, etc)\n    \"\"\"\n    def dump_object(rvalue, title):\n        check_isinstance(rvalue, AbstractValue)\n        print('  %s:' % title)\n        print('    repr(): %r' % rvalue)\n        print('    str(): %s' % rvalue)\n        if isinstance(rvalue, PointerToRegion):\n            print('    r->ob_refcnt: %s'\n                  % endstate.get_value_of_field_by_region(rvalue.region, 'ob_refcnt'))\n            print('    r->ob_type: %r'\n                  % endstate.get_value_of_field_by_region(rvalue.region, 'ob_type'))\n\n    def dump_region(region, title):\n        check_isinstance(region, Region)\n        print('  %s:' % title)\n        print('    repr(): %r' % region)\n        print('    str(): %s' % region)\n        print('    r->ob_refcnt: %s'\n              % endstate.get_value_of_field_by_region(region, 'ob_refcnt'))\n        print('    r->ob_type: %r'\n              % endstate.get_value_of_field_by_region(region, 'ob_type'))\n\n    for i, trace in enumerate(traces):\n        print('Trace %i:' % i)\n\n        # Emit the \"interesting transitions\" i.e. those with descriptions:\n        print('  Transitions:')\n        for trans in trace.transitions:\n            if trans.desc:\n                print('    %r' % trans.desc)\n\n        # Emit information about the end state:\n        endstate = trace.states[-1]\n\n        if trace.err:\n            print('  error: %r' % trace.err)\n            print('  error: %s' % trace.err)\n\n        if endstate.return_rvalue:\n            dump_object(endstate.return_rvalue, 'Return value')\n\n        # Other affected PyObject instances:\n        for k in endstate.region_for_var:\n            if not isinstance(endstate.region_for_var[k], Region):\n                continue\n            region = endstate.region_for_var[k]\n\n            # Consider those for which we know something about an \"ob_refcnt\"\n            # field:\n            if 'ob_refcnt' not in region.fields:\n                continue\n\n            if (isinstance(endstate.return_rvalue, PointerToRegion)\n                and region == endstate.return_rvalue.region):\n                # (We did the return value above)\n                continue\n\n            dump_region(region, str(region))\n\n        # Exception state:\n        if hasattr(endstate, 'cpython'):\n            print('  Exception:')\n            print('    %s' % endstate.cpython.exception_rvalue)\n\n        if i + 1 < len(traces):\n            sys.stdout.write('\\n')\n\nclass DebugAnnotator(Annotator):\n    \"\"\"\n    Annotate a trace with copious debug information\n    \"\"\"\n    def get_notes(self, transition):\n        loc = transition.src.get_gcc_loc_or_none()\n        if loc is None:\n            # (we can't add a note without a valid location)\n            return []\n\n        result = []\n\n        # Add refcount information on all PyObject*\n        for k in transition.dest.region_for_var:\n            region = transition.dest.region_for_var[k]\n            check_isinstance(region, Region)\n            if 'ob_refcnt' not in region.fields:\n                continue\n            ra = RefcountAnnotator(region,\n                                   region.name)\n            result += ra.get_notes(transition)\n\n        # Show all new/changing regions:\n        for region in transition.dest.value_for_region:\n            dest_value = transition.dest.value_for_region[region]\n            if region in transition.src.value_for_region:\n                src_value = transition.src.value_for_region[region]\n                if dest_value != src_value:\n                    result.append(Note(loc,\n                                       ('%s now has value: %s'\n                                        % (region, dest_value))))\n            else:\n                result.append(Note(loc,\n                                   ('%s has initial value: %s'\n                                    % (region, dest_value))))\n\n        # Show exception information:\n        esa = ExceptionStateAnnotator()\n        result += esa.get_notes(transition)\n\n        return result\n\n\nclass RefcountAnnotator(Annotator):\n    \"\"\"\n    Annotate a trace with information on the reference count of a particular\n    object\n    \"\"\"\n    def __init__(self, region, desc):\n        check_isinstance(region, Region)\n        check_isinstance(desc, str)\n        self.region = region\n        self.desc = desc\n\n    def get_notes(self, transition):\n        \"\"\"\n        Add a note to every transition that affects reference-counting for\n        our target object\n        \"\"\"\n        loc = transition.src.get_gcc_loc_or_none()\n        if loc is None:\n            # (we can't add a note without a valid location)\n            return []\n\n        result = []\n\n        # Add a note when the ob_refcnt of the object changes:\n        src_refcnt = transition.src.get_value_of_field_by_region(self.region,\n                                                                 'ob_refcnt')\n        dest_refcnt = transition.dest.get_value_of_field_by_region(self.region,\n                                                                   'ob_refcnt')\n        if src_refcnt != dest_refcnt:\n            log('src_refcnt: %r', src_refcnt)\n            log('dest_refcnt: %r', dest_refcnt)\n            result.append(Note(loc,\n                               ('ob_refcnt is now %s' % dest_refcnt)))\n\n        # Add a note when there's a change to the set of persistent storage\n        # locations referencing this object:\n        src_refs = transition.src.get_persistent_refs_for_region(self.region)\n        dest_refs = transition.dest.get_persistent_refs_for_region(self.region)\n        if src_refs != dest_refs:\n            result.append(Note(loc,\n                               ('%s is now referenced by %i non-stack value(s): %s'\n                                % (self.desc,\n                                   len(dest_refs),\n                                   ', '.join([ref.name for ref in dest_refs])))))\n\n        if 0:\n            # For debugging: show the history of all references to the given\n            # object:\n            src_refs = transition.src.get_all_refs_for_region(self.region)\n            dest_refs = transition.dest.get_all_refs_for_region(self.region)\n            if src_refs != dest_refs:\n                result.append(Note(loc,\n                                   ('all refs: %s' % dest_refs)))\n        return result\n\nclass ExceptionStateAnnotator(Annotator):\n    \"\"\"\n    Annotate a trace with information on changes to the thread-local exception\n    state\n    \"\"\"\n    def get_notes(self, transition):\n        \"\"\"\n        Add a note to every transition that affects thread-local exception\n        state\n        \"\"\"\n        loc = transition.src.get_gcc_loc_or_none()\n        if loc is None:\n            # (we can't add a note without a valid location)\n            return []\n\n        result = []\n\n        if hasattr(transition.dest, 'cpython'):\n            if transition.dest.cpython.exception_rvalue != transition.src.cpython.exception_rvalue:\n                result.append(Note(loc,\n                                   ('thread-local exception state now has value: %s'\n                                    % transition.dest.cpython.exception_rvalue)))\n\n        return result\n\nfrom libcpychecker.initializers import get_all_PyTypeObject_initializers\ndef function_is_tp_iternext_callback(fun):\n    \"\"\"\n    Is the given gcc.Function known to be used as the tp_iternext callback\n    within a PyTypeObject?\n    \"\"\"\n    check_isinstance(fun, gcc.Function)\n    for typeobj in get_all_PyTypeObject_initializers():\n        tp_iternext = typeobj.function_ptr_field('tp_iternext')\n        if fun.decl == tp_iternext:\n            return True\n\n# Helper function for when ob_refcnt is wrong:\ndef emit_refcount_warning(msg,\n                          exp_refcnt, exp_refs, v_ob_refcnt, r_obj, desc,\n                          trace, endstate, fun, rep):\n    w = rep.make_warning(fun, endstate.get_gcc_loc(fun), msg)\n\n    # For dynamically-allocated objects, indicate where they\n    # were allocated:\n    if isinstance(r_obj, RegionOnHeap):\n        alloc_loc = r_obj.alloc_stmt.loc\n        if alloc_loc:\n            w.add_note(r_obj.alloc_stmt.loc,\n                         ('%s was allocated at: %s'\n                          % (desc,\n                             get_src_for_loc(alloc_loc))))\n\n    details = ('was expecting final owned ob_refcnt of %s to be %i'\n               % (desc, exp_refcnt))\n    if exp_refcnt > 0:\n        details += (' due to object being referenced by: %s'\n                    % ', '.join(exp_refs))\n    else:\n        details += (' since nothing references it')\n    details += ' but final ob_refcnt is %s' % v_ob_refcnt\n    w.add_note(endstate.get_gcc_loc(fun),\n               details)\n\n    # Summarize the control flow we followed through the function:\n    if 1:\n        annotator = RefcountAnnotator(r_obj, desc)\n    else:\n        # Debug help:\n        from libcpychecker.diagnostics import TestAnnotator\n        annotator = TestAnnotator()\n    w.add_trace(trace, annotator)\n\n    if 0:\n        # Handy for debugging:\n        w.add_note(endstate.get_gcc_loc(fun),\n                   'this was trace %i' % i)\n    return w\n\n\n# Inner loop of check_refcounts() below, split out to keep the\n# function a more manageable length.\n# Performs refcount-checking on a single object within one end State\n# of a Trace\ndef check_refcount_for_one_object(r_obj, v_ob_refcnt, v_return,\n                                  trace, endstate, fun, rep):\n\n    # If it's the return value, it should have a net refcnt delta of\n    # 1; all other PyObject should have a net delta of 0:\n    if isinstance(v_return, PointerToRegion) and r_obj == v_return.region:\n        is_return_value = True\n        desc = 'return value'\n        if fun.decl.name in fnnames_returning_borrowed_refs:\n            # ...then this function has been marked as returning a\n            # borrowed reference, rather than a new one:\n            exp_refs = []\n        else:\n            exp_refs = ['return value']\n    else:\n        is_return_value = False\n        # Try to get a descriptive name for the region:\n        desc = trace.get_description_for_region(r_obj)\n        # print('desc: %r' % desc)\n        exp_refs = []\n\n    # The reference count should also reflect any non-stack pointers\n    # that point at this object:\n    exp_refs += [ref.name\n                 for ref in endstate.get_persistent_refs_for_region(r_obj)]\n    exp_refcnt = len(exp_refs)\n    log('exp_refs: %r', exp_refs)\n\n    if fun.decl.name in stolen_refs_by_fnname:\n        # Then this function is marked as stealing references to one or\n        # more of its arguments:\n        for argindex in stolen_refs_by_fnname[fun.decl.name]:\n            # Get argument's value (in initial state of trace):\n            parm = fun.decl.arguments[argindex - 1]\n            v_parm = trace.states[0].eval_rvalue(parm, None)\n            if isinstance(v_parm, PointerToRegion):\n                if r_obj == v_parm.region:\n                    exp_refcnt -= 1\n\n    # Here's where we verify the refcount:\n    if isinstance(v_ob_refcnt, RefcountValue):\n        if v_ob_refcnt.relvalue > exp_refcnt:\n            # Refcount is too high:\n            w = emit_refcount_warning('memory leak: ob_refcnt of %s is %i too high'\n                                      % (desc,\n                                         v_ob_refcnt.relvalue - exp_refcnt),\n                                      exp_refcnt, exp_refs, v_ob_refcnt, r_obj, desc,\n                                      trace, endstate, fun, rep)\n        elif v_ob_refcnt.relvalue < exp_refcnt:\n            # Refcount is too low:\n            w = emit_refcount_warning('future use-after-free: ob_refcnt of %s is %i too low'\n                                      % (desc,\n                                         exp_refcnt - v_ob_refcnt.relvalue),\n                                      exp_refcnt, exp_refs, v_ob_refcnt, r_obj, desc,\n                                      trace, endstate, fun, rep)\n            # Special-case hint for when None has too low a refcount:\n            if is_return_value:\n                if isinstance(v_return.region, RegionForGlobal):\n                    if v_return.region.vardecl.name == '_Py_NoneStruct':\n                        w.add_note(endstate.get_gcc_loc(fun),\n                                   'consider using \"Py_RETURN_NONE;\"')\n\n# Detect failure to set exceptions when returning NULL,\n# and verify usage of\n#   __attribute__((cpychecker_negative_result_sets_exception))\ndef warn_about_NULL_without_exception(v_return,\n                                      trace, endstate, fun, rep):\n    if not trace.err:\n        if (isinstance(v_return, ConcreteValue)\n            and v_return.value == 0\n            and str(v_return.gcctype)=='struct PyObject *'):\n\n            if (isinstance(endstate.cpython.exception_rvalue,\n                          ConcreteValue)\n                and endstate.cpython.exception_rvalue.value == 0):\n\n                # Don't emit the error for functions that are a\n                # PyTypeObject's tp_iternext callback, as it's\n                # legitimate to return NULL from them:\n                # http://docs.python.org/c-api/typeobj.html#tp_iternext\n                if function_is_tp_iternext_callback(fun):\n                    return\n\n                w = rep.make_warning(fun,\n                                     endstate.get_gcc_loc(fun),\n                                     'returning (PyObject*)NULL without setting an exception')\n                w.add_trace(trace, ExceptionStateAnnotator())\n\n    # If this is function was marked with our custom\n    #    __attribute__((cpychecker_sets_exception))\n    # then verify that this is the case:\n    if fun.decl.name in fnnames_setting_exception:\n        if (isinstance(endstate.cpython.exception_rvalue,\n                       ConcreteValue)\n            and endstate.cpython.exception_rvalue.value == 0):\n            w = rep.make_warning(fun,\n                      endstate.get_gcc_loc(fun),\n                      ('function is marked with'\n                       ' __attribute__((cpychecker_sets_exception))'\n                       ' but can return without setting an exception'))\n            w.add_trace(trace, ExceptionStateAnnotator())\n\n    # If this is function was marked with our custom\n    #    __attribute__((cpychecker_negative_result_sets_exception))\n    # then verify that this is the case:\n    if fun.decl.name in fnnames_setting_exception_on_negative_result:\n        if (isinstance(v_return, ConcreteValue)\n            and v_return.value < 0):\n            if (isinstance(endstate.cpython.exception_rvalue,\n                           ConcreteValue)\n                and endstate.cpython.exception_rvalue.value == 0):\n                w = rep.make_warning(fun,\n                      endstate.get_gcc_loc(fun),\n                      ('function is marked with __attribute__(('\n                       'cpychecker_negative_result_sets_exception))'\n                       ' but can return %s without setting an exception'\n                       % v_return.value))\n                w.add_trace(trace, ExceptionStateAnnotator())\n\ndef make_stmt_graph(fun):\n    stmtgraph = StmtGraph(fun, False, omit_complex_edges=True)\n    return stmtgraph\n\ndef impl_check_refcounts(fun, dump_traces=False,\n                         show_possible_null_derefs=False,\n                         maxtrans=256):\n    \"\"\"\n    Inner implementation of the refcount checker, checking the refcounting\n    behavior of a function, returning a Reporter instance.\n\n    Used by check_refcounts, but also exposed for use by unit tests\n    that want to get at the Reporter directly (e.g. for JSON output)\n\n    fun: the gcc.Function to be checked\n\n    dump_traces: bool: if True, dump information about the traces through\n    the function to stdout (for self tests)\n    \"\"\"\n    # Abstract interpretation:\n    # Walk the CFG, gathering the information we're interested in\n\n    check_isinstance(fun, gcc.Function)\n\n    # Generate a mapping from facet names to facet classes, so that we know\n    # what additional attributes each State instance will have.\n    #\n    # For now, we just have an optional CPython instance per state, but only\n    # for code that's included Python's headers:\n    facets = {}\n    if get_PyObject():\n        facets['cpython'] = CPython\n\n    limits=Limits(maxtrans=maxtrans)\n\n    stmtgraph = make_stmt_graph(fun)\n    if 0:\n        dot = stmtgraph.to_dot('foo')\n        from gccutils import invoke_dot\n        invoke_dot(dot)\n\n    try:\n        traces = iter_traces(stmtgraph,\n                             facets,\n                             limits=limits)\n    except TooComplicated:\n        err = sys.exc_info()[1]\n        gcc.inform(fun.start,\n                   'this function is too complicated for the reference-count checker to fully analyze: not all paths were analyzed')\n        traces = err.complete_traces\n\n    if dump_traces:\n        traces = list(traces)\n        dump_traces_to_stdout(traces)\n\n    # Debug dump of all traces in HTML form:\n    if 0:\n        filename = ('%s.%s-refcount-traces.html'\n                    % (gcc.get_dump_base_name(), fun.decl.name))\n        rep = Reporter()\n        for i, trace in enumerate(traces):\n            endstate = trace.states[-1]\n            r = rep.make_debug_dump(fun,\n                                    endstate.get_gcc_loc(fun),\n                                    'Debug dump of trace %i' % i)\n            r.add_trace(trace, DebugAnnotator())\n        rep.dump_html(fun, filename)\n        rep.flush()\n        gcc.inform(fun.start,\n                   ('graphical debug report for function %r written out to %r'\n                    % (fun.decl.name, filename)))\n\n    rep = Reporter()\n\n    # Iterate through all traces, adding reports to the Reporter:\n    for i, trace in enumerate(traces):\n        trace.log(log, 'TRACE %i' % i)\n        if trace.err:\n            # This trace bails early with a fatal error; it probably doesn't\n            # have a return value\n            log('trace.err: %s %r', trace.err, trace.err)\n\n            # Unless explicitly enabled, don't report on NULL pointer\n            # dereferences that are only possible, not definite: it may be\n            # that there are invariants that we know nothing about that mean\n            # that they can't happen:\n            # (similarly for arithmetic issues e.g. negative shift, divide by\n            # zero, etc)\n            if isinstance(trace.err, (NullPtrDereference, NullPtrArgument,\n                                      PredictedArithmeticError)):\n                if not trace.err.isdefinite:\n                    if not show_possible_null_derefs:\n                        continue\n\n            w = rep.make_warning(fun, trace.err.loc, str(trace.err))\n            w.add_trace(trace)\n            if hasattr(trace.err, 'why'):\n                if trace.err.why:\n                    w.add_note(trace.err.loc,\n                               trace.err.why)\n            # FIXME: in our example this ought to mention where the values came from\n            continue\n        # Otherwise, the trace proceeds normally\n        v_return = trace.return_value()\n        log('trace.return_value(): %s', trace.return_value())\n\n        # Ideally, we should \"own\" exactly one reference, and it should be\n        # the return value.  Anything else is an error (and there are other\n        # kinds of error...)\n\n        # Locate all PyObject that we touched\n        endstate = trace.states[-1]\n        endstate.log(log)\n        log('return_value: %r', v_return)\n        log('endstate.region_for_var: %r', endstate.region_for_var)\n        log('endstate.value_for_region: %r', endstate.value_for_region)\n\n        if endstate.not_returning:\n            # We have a function that calls exit() or abort() or similar\n            # Don't bother reporting reference leaks etc: the process is\n            # going away\n            continue\n\n        # Check the refcount of all Python objects we know about:\n        if hasattr(endstate, 'cpython'):\n            for r_obj, v_ob_refcnt in endstate.cpython.iter_python_refcounts():\n                check_refcount_for_one_object(r_obj, v_ob_refcnt, v_return,\n                                              trace, endstate, fun, rep)\n\n        # Detect returning a deallocated object:\n        if v_return:\n            if isinstance(v_return, PointerToRegion):\n                rvalue = endstate.value_for_region.get(v_return.region, None)\n                if isinstance(rvalue, DeallocatedMemory):\n                    w = rep.make_warning(fun,\n                                         endstate.get_gcc_loc(fun),\n                                         'returning pointer to deallocated memory')\n                    w.add_trace(trace)\n                    w.add_note(rvalue.loc,\n                               'memory deallocated here')\n\n        warn_about_NULL_without_exception(v_return,\n                                          trace, endstate, fun, rep)\n\n    # (all traces analysed)\n\n    return rep\n\n\ndef check_refcounts(fun, dump_traces=False, show_traces=False,\n                    show_possible_null_derefs=False,\n                    show_timings=False,\n                    maxtrans=256,\n                    dump_json=False):\n    \"\"\"\n    The top-level function of the refcount checker, checking the refcounting\n    behavior of a function\n\n    fun: the gcc.Function to be checked\n\n    dump_traces: bool: if True, dump information about the traces through\n    the function to stdout (for self tests)\n\n    show_traces: bool: if True, display a diagram of the state transition graph\n\n    show_timings: bool: if True, add timing information to stderr\n    \"\"\"\n\n    log('check_refcounts(%r, %r, %r)', fun, dump_traces, show_traces)\n\n    # show_timings = 1\n\n    if show_timings:\n        import time\n        start_cpusecs = time.clock()\n        gcc.inform(fun.start, 'Analyzing reference-counting within %s' % fun.decl.name)\n\n    if show_traces:\n        from libcpychecker.visualizations import StateGraphPrettyPrinter\n        sg = StateGraph(fun, log, MyState)\n        sgpp = StateGraphPrettyPrinter(sg)\n        dot = sgpp.to_dot()\n        #dot = sgpp.extra_items()\n        # print(dot)\n        invoke_dot(dot)\n\n    rep = impl_check_refcounts(fun,\n                               dump_traces,\n                               show_possible_null_derefs,\n                               maxtrans)\n\n    # Organize the Report instances into equivalence classes, simplifying\n    # the list of reports:\n    rep.remove_duplicates()\n\n    # Flush the reporter's messages, which will actually emit gcc errors and\n    # warnings (if any), for those Report instances that survived\n    # de-duplication\n    rep.flush()\n\n    if rep.got_warnings():\n        if dump_json:\n            # JSON output:\n            filename = ('%s.%s.json'\n                    % (gcc.get_dump_base_name(), fun.decl.name))\n            rep.dump_json(fun, filename)\n\n        filename = ('%s.%s-refcount-errors.html'\n                    % (gcc.get_dump_base_name(), fun.decl.name))\n        rep.dump_html(fun, filename)\n        gcc.inform(fun.start,\n                   ('graphical error report for function %r written out to %r'\n                    % (fun.decl.name, filename)))\n\n        filename_v2 = ('%s.%s-refcount-errors.v2.html'\n                       % (gcc.get_dump_base_name(), fun.decl.name))\n\n        from libcpychecker_html.make_html import HtmlPage\n        data = rep.to_json(fun)\n        srcfile = open(fun.start.file)\n        htmlfile = open(filename_v2, 'w')\n        htmlfile.write(str(HtmlPage(srcfile, data)))\n        htmlfile.close()\n        srcfile.close()\n\n\n    if show_timings:\n        end_cpusecs = time.clock()\n        gcc.inform(fun.start, 'Finished analyzing reference-counting within %s' % fun.decl.name)\n        gcc.inform(fun.start,\n                   ('%i transitions, %fs CPU'\n                    % (limits.trans_seen, end_cpusecs - start_cpusecs)))\n\n    if 0:\n        dot = cfg_to_dot(fun.cfg, fun.decl.name)\n        invoke_dot(dot)\n\n    return rep\n"
  },
  {
    "path": "libcpychecker/types.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n\"\"\"\nHelper functions for looking up various CPython implementation types.\n\"\"\"\nimport gcc\nfrom gccutils import get_global_typedef, check_isinstance\n\ndef is_py3k():\n    \"\"\"\n    Is the Python.h we're compiling against python 3?\n    \"\"\"\n    if get_global_typedef('PyStringObject'):\n        return False\n    else:\n        return True\n\ndef is_debug_build():\n    \"\"\"\n    Is the Python.h we're compiling against configured --with-pydebug ?\n    \"\"\"\n    obj = get_global_typedef('PyObject')\n    return obj.type.fields[0].name == '_ob_next'\n\ndef get_Py_ssize_t():\n    return get_global_typedef('Py_ssize_t')\n\ndef get_Py_buffer():\n    return get_global_typedef('Py_buffer')\n\ndef Py_UNICODE():\n    return get_global_typedef('Py_UNICODE')\n\ndef get_PY_LONG_LONG():\n    # pyport.h can supply PY_LONG_LONG as a #define, as a typedef, or not at all\n    # FIXME\n    # If we have \"long long\", pyport.h uses that.\n    # Assume so for now:\n    return gcc.Type.long_long()\n\ndef get_PyObject():\n    return get_global_typedef('PyObject')\n\ndef get_PyObjectPtr():\n    return get_global_typedef('PyObject').pointer\n\ndef get_PyTypeObject():\n    return get_global_typedef('PyTypeObject')\n\ndef get_PyStringObject():\n    return get_global_typedef('PyStringObject')\n\ndef get_PyUnicodeObject():\n    return get_global_typedef('PyUnicodeObject')\n\ndef get_Py_complex():\n    return get_global_typedef('Py_complex')\n\n# Python 3:\ndef get_PyBytesObject():\n    return get_global_typedef('PyBytesObject')\n\n# Map from name of PyTypeObject global to the typedef for the corresponding\n# object structure:\ntype_dict = {\n    'PyBuffer_Type' : 'PyBufferObject',\n    'PyComplex_Type' : 'PyComplexObject',\n    'PyCode_Type' : 'PyCodeObject',\n    'PyDict_Type' : 'PyDictObject',\n    'PyFile_Type' : 'PyFileObject',\n    'PyFloat_Type' : 'PyFloatObject',\n    'PyFrame_Type' : 'PyFrameObject',\n    'PyFunction_Type' : 'PyFunctionObject',\n    'PyInt_Type' : 'PyIntObject',\n    'PyList_Type' : 'PyListObject',\n    'PyLong_Type' : 'PyLongObject',\n    'PyModule_Type' : 'PyModuleObject',\n    'PyCapsule_Type' : 'PyCapsuleObject',\n    'PyRange_Type' : 'PyRangeObject',\n    'PySet_Type' : 'PySetObject',\n    'PyFrozenSet_Type' : 'PyFrozenSetObject',\n    'PyString_Type' : 'PyStringObject',\n    'PyTuple_Type' : 'PyTupleObject',\n    'PyType_Type' : 'PyTypeObject',\n    'PyUnicode_Type' : 'PyUnicodeObject',\n}\n\ndef get_type_for_typeobject(typeobject):\n    check_isinstance(typeobject, gcc.VarDecl)\n    if typeobject.name not in type_dict:\n        return None\n\n    type_name = type_dict[typeobject.name]\n    return get_global_typedef(type_name)\n\ndef register_type_object(typeobject, typedef):\n    check_isinstance(typeobject, gcc.VarDecl)\n    type_dict[typeobject.name] = typedef\n"
  },
  {
    "path": "libcpychecker/utils.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Logging\nimport sys\n\nimport gcc\n\nlogfile = None\n\nlogging_enabled = False\n\ndef log(msg, *args):\n    if logging_enabled:\n        # Only do the work of expanding the message if logging is enabled:\n        expanded_msg = msg % args\n        if 1:\n            global logfile\n            if not logfile:\n                filename = gcc.get_dump_base_name() + '.cpychecker-log.txt'\n                logfile = open(filename, 'w')\n            logfile.write(expanded_msg)\n            logfile.write('\\n')\n        if 0:\n            sys.stderr.write(expanded_msg)\n            sys.stderr.write('\\n')\n"
  },
  {
    "path": "libcpychecker/visualizations.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import CfgPrettyPrinter, get_src_for_loc, check_isinstance\n\nclass StatePrettyPrinter(CfgPrettyPrinter):\n    \"\"\"\n    Various ways of annotating a CFG with state information\n    \"\"\"\n    def state_to_dot_label(self, state):\n        result = '<table cellborder=\"0\" border=\"0\" cellspacing=\"0\">\\n'\n        for key in state.data:\n            value = state.data[key]\n            result += ('<tr> %s %s </tr>\\n'\n                       % (self._dot_td(key),\n                          self._dot_td(value)))\n        result += '</table>\\n'\n        return result\n\nclass TracePrettyPrinter(StatePrettyPrinter):\n    \"\"\"\n    Annotate a CFG, showing a specific trace of execution through it\n    \"\"\"\n    def __init__(self, cfg, trace):\n        self.cfg = cfg\n        self.trace = trace\n\n    def extra_items(self):\n        # Hook for expansion\n        result = ''\n        result += ' subgraph cluster_trace {\\n'\n        result += '  label=\"Trace\";\\n'\n        for i, state in enumerate(self.trace.states):\n\n            result += ('  state%i [label=<%s>];\\n'\n                       % (i, self.state_to_dot_label(state)))\n\n            if i > 0:\n                result += ' state%i -> state%i;\\n' % (i-1, i)\n            result += '  state%i -> %s:stmt%i;\\n' % (i,\n                                                     self.block_id(state.loc.bb),\n                                                     state.loc.idx)\n        result += ' }\\n';\n        return result\n\nclass StateGraphPrettyPrinter(StatePrettyPrinter):\n    \"\"\"\n    Annotate a CFG, showing all possible states as execution proceeds through\n    it\n    \"\"\"\n    def __init__(self, sg):\n        self.sg = sg\n        self.name = sg.fun.decl.name\n        self.cfg = sg.fun.cfg\n\n    def state_id(self, state):\n        return 'state%i' % id(state)\n\n    def state_to_dot_label(self, state, prevstate):\n        result = '<table cellborder=\"0\" border=\"0\" cellspacing=\"0\">\\n'\n\n        # Show data:\n        result += '<tr><td colspan=\"2\"><table border=\"0\" cellborder=\"1\">'\n        result += ('<tr> %s %s %s</tr>\\n'\n                  % (self._dot_td('Expression'),\n                     self._dot_td('lvalue'),\n                     self._dot_td('rvalue')))\n        for key in state.region_for_var:\n            region = state.region_for_var[key]\n            value = state.value_for_region.get(region, None)\n\n            # Highlight new and changing values:\n            is_new_key = True\n            is_different_value = False\n            if prevstate:\n                if key in prevstate.region_for_var:\n                    is_new_key = False\n                    prevregion = prevstate.region_for_var[key]\n                    prevvalue = prevstate.value_for_region.get(prevregion, None)\n                    if value != prevvalue:\n                        is_different_value = True\n\n            if is_new_key:\n                bgcolor = 'green'\n                value_bgcolor = 'green'\n            else:\n                bgcolor = None\n                if is_different_value:\n                    value_bgcolor = 'green'\n                else:\n                    value_bgcolor = None\n\n            result += ('<tr> %s %s %s</tr>\\n'\n                       % (self._dot_td(key, bgcolor=bgcolor),\n                          self._dot_td(region, bgcolor=bgcolor),\n                          self._dot_td(value, bgcolor=value_bgcolor)))\n\n        # Show any return value:\n        if state.return_rvalue:\n            result += ('<tr> %s %s %s</tr>\\n'\n                       % (self._dot_td(''),\n                          self._dot_td('Return Value', bgcolor='green'),\n                          self._dot_td(state.return_rvalue, bgcolor='green')))\n        result += '</table></td></tr>'\n\n        # Show location:\n        stmt = state.loc.get_stmt()\n        if stmt:\n            if stmt.loc:\n                result += ('<tr><td>'\n                           + self.to_html('%4i ' % stmt.loc.line)\n                           + self.code_to_html(get_src_for_loc(stmt.loc))\n                           + '<br/>'\n                           + (' ' * (5 + stmt.loc.column-1)) + '^'\n                           + '</td></tr>\\n')\n                result += '<tr><td></td>' + self.stmt_to_html(stmt, state.loc.idx) + '</tr>\\n'\n\n        result += '</table>\\n'\n        return result\n\n    def extra_items(self):\n        # Hook for expansion\n        result = ''\n        result += ' subgraph cluster_state_transitions {\\n'\n        result += '  label=\"State Transitions\";\\n'\n        result += '  node [shape=box];\\n'\n        for state in self.sg.states:\n            prevstate = self.sg.get_prev_state(state)\n            result += ('  %s [label=<%s>];\\n'\n                       % (self.state_id(state),\n                          self.state_to_dot_label(state, prevstate)))\n\n            #result += ('  %s -> %s:stmt%i;\\n'\n            #           % (self.state_id(state),\n            #              self.block_id(state.loc.bb),\n            #              state.loc.idx))\n\n        for transition in self.sg.transitions:\n            if transition.desc:\n                attrliststr = '[label = \"%s\"]' % self.to_html(transition.desc)\n            else:\n                attrliststr = ''\n            result += ('  %s -> %s %s;\\n'\n                       % (self.state_id(transition.src),\n                          self.state_id(transition.dest),\n                          attrliststr))\n\n        result += ' }\\n';\n        return result\n\n    #def to_dot(self):\n    #    result = 'digraph {\\n'\n    #    result += self.extra_items()\n    #    result += '}\\n';\n    #    return result\n\nclass HtmlRenderer:\n    \"\"\"\n    Render a function as HTML, possibly with annotations\n\n    Uses pygments to syntax-highlight the code.\n\n    The resulting HTML uses jsplumb to add lines indicating control flow:\n      http://code.google.com/p/jsplumb/\n    which requires JavaScript and the HTML <canvas> element\n    \"\"\"\n    def __init__(self, fun):\n        check_isinstance(fun, gcc.Function)\n        self.fun = fun\n\n        from pygments.styles import get_style_by_name\n        from pygments.formatters import HtmlFormatter\n\n        # Get ready to use Pygments:\n        style = get_style_by_name('default')\n        self.formatter = HtmlFormatter(classprefix='source_')\n\n        self.trace_idx = 0\n\n    def make_header(self):\n        result = '<html>\\n'\n        result += '  <head>\\n'\n        result += '    <title>%s</title>\\n' % self.fun.decl.name\n\n        # CSS defs, as part of the file:\n        result += '''    <style type=\"text/css\">\n.unreached-line {\n    #margin:1em;\n    #border:0.1em dotted #00aa00;\n\n    opacity:1.0;\n    filter:alpha(opacity=0);\n    #color:black;\n}\n\n.reached-line {\n    #margin:1em;\n    #border:0.1em dotted #00aa00;\n    border: 0.1em solid blue;\n    font-weight: bold;\n\n    opacity:1.0;\n    filter:alpha(opacity=0);\n    #color:black;\n}\n\n.reached-lineno {\n    border: 0.1em solid blue;\n    font-weight: bold;\n}\n\npre {\n    #line-height:200%\n}\n\n._jsPlumb_connector { z-index: -2; }\n._jsPlumb_endpoint { z-index: -1; }\n\n.transition {\n    #border: 0.1em dotted #ddffdd;\n    #padding: 1em;\n    border: 0.1em solid #ccc;\n    -moz-box-shadow: 2px 2px 2px #ccc;\n    -webkit-box-shadow: 2px 2px 2px #ccc;\n    box-shadow: 2px 2px 2px #ccc;\n    margin-left: 5em;\n    font-family: proportional;\n    font-style: italic;\n    font-size: 90%;\n}\n\n.error {\n    #border: 0.1em dotted #ddffdd;\n    #padding: 1em;\n    border: 0.1em solid #cc0000;\n    -moz-box-shadow: 2px 2px 2px #cc0000;\n    -webkit-box-shadow: 2px 2px 2px #cc0000;\n    box-shadow: 2px 2px 2px #cc0000;\n    margin-left: 5em;\n    color: red;\n    font-family: proportional;\n    font-weight: bold;\n    font-style: italic;\n    font-size: 90%;\n}\n\n.note {\n    #border: 0.1em dotted #ddffdd;\n    #padding: 1em;\n    border: 0.1em solid #ccc;\n    -moz-box-shadow: 2px 2px 2px #ccc;\n    -webkit-box-shadow: 2px 2px 2px #ccc;\n    box-shadow: 2px 2px 2px #ccc;\n    margin-left: 5em;\n    font-family: proportional;\n    font-weight: bold;\n    font-style: italic;\n    font-size: 90%;\n}\n\n'''\n        result += self.formatter.get_style_defs()\n        result += '    </style>\\n'\n\n        result += '  </head>\\n'\n\n        result += '  <body>\\n'\n\n        # Add scripts for jsplumb:\n        result += '<script type=\"text/javascript\" src=\"http://explorercanvas.googlecode.com/svn/trunk/excanvas.js\"></script>\\n'\n        result += '<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js\"></script>\\n'\n        result += '<script type=\"text/javascript\" src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js\"></script>\\n'\n        result += '<script type=\"text/javascript\" src=\"http://jsplumb.googlecode.com/files/jquery.jsPlumb-1.2.6-all-min.js\"></script>\\n'\n\n        return result\n\n    def make_report(self, report):\n        result = '<div id=\"report-%i\">\\n' % self.trace_idx\n        # Heading:\n        result += '<table>\\n'\n        result += '  <tr><td>File:</td> <td><b>%s</b></td></tr>\\n' % self.fun.start.file\n        result += '  <tr><td>Function:</td> <td><b>%s</b></td></tr>\\n' % self.fun.decl.name\n        result += '  <tr><td>Error:</td> <td><b>%s</b></td></tr>\\n' % report.msg\n        result += '</table>\\n'\n\n        # Render any trace that we have:\n        if report.trace:\n            result += self.make_html_for_trace(report, report.trace)\n            result += '<hr/>'\n\n        result += '</div>\\n'\n        return result\n\n    def make_html_for_trace(self, report, trace):\n        start_line = self.fun.decl.location.line - 1\n        end_line = self.fun.end.line + 1\n\n        # Figure out which lines get executed.\n        # (Is this the finest granularity we can measure?)\n        reached_lines = set()\n        for state in trace.states:\n            loc = state.get_gcc_loc_or_none()\n            if loc:\n                reached_lines.add(loc.line)\n\n        # Render source code:\n        srcfile = self.fun.start.file\n\n        # Extract the source code for the function:\n        import linecache\n        code = ''\n        for linenum in range(start_line, end_line):\n            code += linecache.getline(srcfile, linenum)\n\n        # Use pygments to convert it all to HTML:\n        from pygments import highlight\n        from pygments.lexers import CLexer\n        html = highlight(code,\n                         CLexer(),\n                         # FIXME: ^^^ this hardcodes the source language\n                         # (e.g. what about C++?)\n                         self.formatter)\n\n        # Carve it up by line, adding our own line numbering:\n        # It contains some initial content, leading up to a <pre> element\n        # Break on it, starting \"result\" with the initial material:\n        html = html.replace('<pre>', '<pre>\\n')\n        lines = html.splitlines()\n        result = lines[0]\n\n        # Generate any notes from the report's annotator (if any):\n        notes = []\n        annotator = report.get_annotator_for_trace(trace)\n        if annotator:\n            for trans in trace.transitions:\n                notes += annotator.get_notes(trans)\n\n        # The rest contains the actual source lines:\n        lines = lines[1:]\n        for linenum, line in zip(range(start_line, end_line), lines):\n            # Line number:\n            if linenum in reached_lines:\n                cls = 'reached-lineno'\n            else:\n                cls = 'lineno'\n            result += '<span class=\"%s\">%i</span> ' % (cls, linenum)\n\n            # The body of the line:\n            if linenum in reached_lines:\n                cls = 'reached-line'\n            else:\n                cls = 'unreached-line'\n            result += '<span id=\"trace%i-line%i\" class=\"%s\">' % (self.trace_idx, linenum, cls)\n            result += line\n            result += '</span>\\n'\n\n            # Add any comments for this line:\n            for trans in trace.transitions:\n                if trans.desc:\n                    src_loc = trans.src.get_gcc_loc_or_none()\n                    if src_loc and src_loc.line == linenum:\n                        result += '<span class=\"transition\">%s</span>\\n' % trans.desc\n            # Report the top-level message, if it happens here:\n            if report.loc.line == linenum:\n                result += '<span class=\"error\">%s</span>\\n' % report.msg\n            # Add notes attached to the report:\n            for note in report.notes:\n                if note.loc and note.loc.line == linenum:\n                    result += '<span class=\"note\">%s</span>\\n' % note.msg\n            # Add any notes from the annotator:\n            for note in notes:\n                if note.loc and note.loc.line == linenum:\n                    result += '<span class=\"transition\">%s</span>\\n' % note.msg\n\n        result += '</pre></div>\\n'\n        result += '\\n'\n        result += '<script type=\"text/javascript\">\\n'\n        result += '  jsPlumb.bind(\"ready\", function() {\\n'\n        result += '    /* Set up defaults: */\\n'\n        result += '    jsPlumb.Defaults.Connector = [ \"Bezier\", 1 ];\\n'\n        result += '    jsPlumb.Defaults.Connector = [ \"Straight\" ];\\n'\n        result += '    jsPlumb.Defaults.PaintStyle = { strokeStyle:\"blue\", lineWidth:1 };\\n'\n        result += '    jsPlumb.Defaults.EndpointStyle = { radius:2, fillStyle:\"red\" };\\n'\n        result += '    jsPlumb.Defaults.Anchors =  [ \"BottomCenter\", \"TopCenter\" ];\\n'\n        #result += '    jsPlumb.Defaults.Anchors =  [ \"Center\", \"Center\" ];\\n'\n        result += '\\n'\n        result += '    /* Add lines: */\\n'\n        for i, trans in enumerate(trace.transitions):\n            if trans.desc:\n                src_loc = trans.src.get_gcc_loc_or_none()\n                dest_loc = trans.dest.get_gcc_loc_or_none()\n                if src_loc and dest_loc and src_loc != dest_loc:\n                    result += (\"    jsPlumb.connect({source:'trace%i-line%i',\\n\"\n                               \"                     target:'trace%i-line%i',\\n\"\n                               \"                     label:%r,\\n\"\n                               \"                     overlays:[['PlainArrow', { width:10, length:10, location:1.0 }]]\\n\"\n                               \"                   });\\n\"\n                               % (self.trace_idx, src_loc.line,\n                                  self.trace_idx, dest_loc.line,\n                                  ''))#trans.desc))\n        result += '  })\\n'\n        result += '</script>\\n'\n\n        self.trace_idx += 1\n\n        return result\n\n    def make_footer(self):\n        result = '  </body>\\n'\n        return result\n"
  },
  {
    "path": "libcpychecker_html/TODO",
    "content": "# Copying and distribution of this file, with or without modification,\n# are permitted in any medium without royalty provided the copyright\n# notice and this notice are preserved.  This file is offered as-is,\n# without any warranty.\n\nThese are things we planned, but didn't get done, yet.\n\nbuttons:\n    \n    Should add the \"selected\" style to the annotations, allowing the user to\n    step through them.\n\nreport selection:\n\n    Figure out which report is visible, and make the buttons control *that*\n    report if more than one report is visible, use the previous selection.\n    Change selection when clicking report links as well.\n\nannotation clicking:\n\n    Clicking an annotation makes it selected, until clicking the selected\n    event.  Users can use this to stop stepping through notes as well.\n\nalignment of notes:\n\n    When selecting a note, it should line up with the line it's annotating.\n    Move the \"states\" pane up and down, and make sure the overflow is clipped.\n    There may be some jquery plugins that will make this much easier.\n\n    * https://developer.mozilla.org/en/DOM/element.offsetTop\n    * http://api.jquery.com/position/\n\nmore data:\n\n    When a state is selected, we could apply mouseovers to variables that show\n    their value within that state.\n"
  },
  {
    "path": "libcpychecker_html/__init__.py",
    "content": ""
  },
  {
    "path": "libcpychecker_html/c-api.txt",
    "content": "#   Copyright 2012 Buck Golemon <buck@yelp.com>\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n#\n# This is simply a listing of all the function names in the Python C API\n#\n# To regenerate, run this from a checkout of cpython:\n# grep -RI '\\.\\. cfunction::' Doc/c-api/ | sed 's|Doc/c-api/||;s/(.*//;s/\\.rst:.* / /'\n#\ninit Py_Initialize\ninit Py_InitializeEx\ninit Py_IsInitialized\ninit Py_Finalize\ninit Py_NewInterpreter\ninit Py_EndInterpreter\ninit Py_SetProgramName\ninit Py_GetProgramName\ninit Py_GetPrefix\ninit Py_GetExecPrefix\ninit Py_GetProgramFullPath\ninit Py_GetPath\ninit Py_GetVersion\ninit Py_GetPlatform\ninit Py_GetCopyright\ninit Py_GetCompiler\ninit Py_GetBuildInfo\ninit PySys_SetArgvEx\ninit PySys_SetArgv\ninit Py_SetPythonHome\ninit Py_GetPythonHome\ninit PyEval_InitThreads\ninit PyEval_ThreadsInitialized\ninit PyEval_AcquireLock\ninit PyEval_ReleaseLock\ninit PyEval_AcquireThread\ninit PyEval_ReleaseThread\ninit PyEval_SaveThread\ninit PyEval_RestoreThread\ninit PyEval_ReInitThreads\ninit PyInterpreterState_New\ninit PyInterpreterState_Clear\ninit PyInterpreterState_Delete\ninit PyThreadState_New\ninit PyThreadState_Clear\ninit PyThreadState_Delete\ninit PyThreadState_Get\ninit PyThreadState_Swap\ninit PyThreadState_GetDict\ninit PyThreadState_SetAsyncExc\ninit PyGILState_Ensure\ninit PyGILState_Release\ninit Py_AddPendingCall\ninit PyEval_SetProfile\ninit PyEval_SetTrace\ninit PyEval_GetCallStats\ninit PyInterpreterState_Head\ninit PyInterpreterState_Next\ninit PyInterpreterState_ThreadHead\ninit PyThreadState_Next\nfile PyFile_Check\nfile PyFile_CheckExact\nfile PyFile_FromString\nfile PyFile_FromFile\nfile PyFile_AsFile\nfile PyFile_IncUseCount\nfile PyFile_DecUseCount\nfile PyFile_GetLine\nfile PyFile_Name\nfile PyFile_SetBufSize\nfile PyFile_SetEncoding\nfile PyFile_SetEncodingAndErrors\nfile PyFile_SoftSpace\nfile PyFile_WriteObject\nfile PyFile_WriteString\nimport PyImport_ImportModule\nimport PyImport_ImportModuleNoBlock\nimport PyImport_ImportModuleEx\nimport PyImport_ImportModuleLevel\nimport PyImport_Import\nimport PyImport_ReloadModule\nimport PyImport_AddModule\nimport PyImport_ExecCodeModule\nimport PyImport_ExecCodeModuleEx\nimport PyImport_GetMagicNumber\nimport PyImport_GetModuleDict\nimport PyImport_GetImporter\nimport _PyImport_Init\nimport PyImport_Cleanup\nimport _PyImport_Fini\nimport _PyImport_FindExtension\nimport _PyImport_FixupExtension\nimport PyImport_ImportFrozenModule\nimport PyImport_AppendInittab\nimport PyImport_ExtendInittab\nset PySet_Check\nset PyFrozenSet_Check\nset PyAnySet_Check\nset PyAnySet_CheckExact\nset PyFrozenSet_CheckExact\nset PySet_New\nset PyFrozenSet_New\nset PySet_Size\nset PySet_GET_SIZE\nset PySet_Contains\nset PySet_Add\nset PySet_Discard\nset PySet_Pop\nset PySet_Clear\nallocation _PyObject_New\nallocation _PyObject_NewVar\nallocation _PyObject_Del\nallocation PyObject_Init\nallocation PyObject_InitVar\nallocation PyObject_New\nallocation PyObject_NewVar\nallocation PyObject_Del\nallocation Py_InitModule\nallocation Py_InitModule3\nallocation Py_InitModule4\nbool PyBool_Check\nbool PyBool_FromLong\nmethod PyMethod_Check\nmethod PyMethod_New\nmethod PyMethod_Class\nmethod PyMethod_GET_CLASS\nmethod PyMethod_Function\nmethod PyMethod_GET_FUNCTION\nmethod PyMethod_Self\nmethod PyMethod_GET_SELF\nmethod PyMethod_ClearFreeList\nmodule PyModule_Check\nmodule PyModule_CheckExact\nmodule PyModule_New\nmodule PyModule_GetDict\nmodule PyModule_GetName\nmodule PyModule_GetFilename\nmodule PyModule_AddObject\nmodule PyModule_AddIntConstant\nmodule PyModule_AddStringConstant\nmodule PyModule_AddIntMacro\nmodule PyModule_AddStringMacro\nmarshal PyMarshal_WriteLongToFile\nmarshal PyMarshal_WriteObjectToFile\nmarshal PyMarshal_WriteObjectToString\nmarshal PyMarshal_ReadLongFromFile\nmarshal PyMarshal_ReadShortFromFile\nmarshal PyMarshal_ReadObjectFromFile\nmarshal PyMarshal_ReadLastObjectFromFile\nmarshal PyMarshal_ReadObjectFromString\nslice PySlice_Check\nslice PySlice_New\nslice PySlice_GetIndices\nslice PySlice_GetIndicesEx\nunicode PyUnicode_Check\nunicode PyUnicode_CheckExact\nunicode PyUnicode_GET_SIZE\nunicode PyUnicode_GET_DATA_SIZE\nunicode PyUnicode_AS_UNICODE\nunicode PyUnicode_AS_DATA\nunicode PyUnicode_ClearFreeList\nunicode Py_UNICODE_ISSPACE\nunicode Py_UNICODE_ISLOWER\nunicode Py_UNICODE_ISUPPER\nunicode Py_UNICODE_ISTITLE\nunicode Py_UNICODE_ISLINEBREAK\nunicode Py_UNICODE_ISDECIMAL\nunicode Py_UNICODE_ISDIGIT\nunicode Py_UNICODE_ISNUMERIC\nunicode Py_UNICODE_ISALPHA\nunicode Py_UNICODE_ISALNUM\nunicode Py_UNICODE_TOLOWER\nunicode Py_UNICODE_TOUPPER\nunicode Py_UNICODE_TOTITLE\nunicode Py_UNICODE_TODECIMAL\nunicode Py_UNICODE_TODIGIT\nunicode Py_UNICODE_TONUMERIC\nunicode PyUnicode_FromUnicode\nunicode PyUnicode_FromStringAndSize\nunicode *PyUnicode_FromString\nunicode PyUnicode_FromFormat\nunicode PyUnicode_FromFormatV\nunicode PyUnicode_AsUnicode\nunicode PyUnicode_GetSize\nunicode PyUnicode_FromEncodedObject\nunicode PyUnicode_FromObject\nunicode PyUnicode_FromWideChar\nunicode PyUnicode_AsWideChar\nunicode PyUnicode_Decode\nunicode PyUnicode_Encode\nunicode PyUnicode_AsEncodedString\nunicode PyUnicode_DecodeUTF8\nunicode PyUnicode_DecodeUTF8Stateful\nunicode PyUnicode_EncodeUTF8\nunicode PyUnicode_AsUTF8String\nunicode PyUnicode_DecodeUTF32\nunicode PyUnicode_DecodeUTF32Stateful\nunicode PyUnicode_EncodeUTF32\nunicode PyUnicode_AsUTF32String\nunicode PyUnicode_DecodeUTF16\nunicode PyUnicode_DecodeUTF16Stateful\nunicode PyUnicode_EncodeUTF16\nunicode PyUnicode_AsUTF16String\nunicode PyUnicode_DecodeUTF7\nunicode PyUnicode_DecodeUTF7Stateful\nunicode PyUnicode_EncodeUTF7\nunicode PyUnicode_DecodeUnicodeEscape\nunicode PyUnicode_EncodeUnicodeEscape\nunicode PyUnicode_AsUnicodeEscapeString\nunicode PyUnicode_DecodeRawUnicodeEscape\nunicode PyUnicode_EncodeRawUnicodeEscape\nunicode PyUnicode_AsRawUnicodeEscapeString\nunicode PyUnicode_DecodeLatin1\nunicode PyUnicode_EncodeLatin1\nunicode PyUnicode_AsLatin1String\nunicode PyUnicode_DecodeASCII\nunicode PyUnicode_EncodeASCII\nunicode PyUnicode_AsASCIIString\nunicode PyUnicode_DecodeCharmap\nunicode PyUnicode_EncodeCharmap\nunicode PyUnicode_AsCharmapString\nunicode PyUnicode_TranslateCharmap\nunicode PyUnicode_DecodeMBCS\nunicode PyUnicode_DecodeMBCSStateful\nunicode PyUnicode_EncodeMBCS\nunicode PyUnicode_AsMBCSString\nunicode PyUnicode_Concat\nunicode PyUnicode_Split\nunicode PyUnicode_Splitlines\nunicode PyUnicode_Translate\nunicode PyUnicode_Join\nunicode PyUnicode_Tailmatch\nunicode PyUnicode_Find\nunicode PyUnicode_Count\nunicode PyUnicode_Replace\nunicode PyUnicode_Compare\nunicode PyUnicode_RichCompare\nunicode PyUnicode_Format\nunicode PyUnicode_Contains\nint PyInt_Check\nint PyInt_CheckExact\nint PyInt_FromString\nint PyInt_FromLong\nint PyInt_FromSsize_t\nint PyInt_FromSize_t\nint PyInt_AsLong\nint PyInt_AS_LONG\nint PyInt_AsUnsignedLongMask\nint PyInt_AsUnsignedLongLongMask\nint PyInt_AsSsize_t\nint PyInt_GetMax\nint PyInt_ClearFreeList\ntype PyType_Check\ntype PyType_CheckExact\ntype PyType_ClearCache\ntype PyType_Modified\ntype PyType_HasFeature\ntype PyType_IS_GC\ntype PyType_IsSubtype\ntype PyType_GenericAlloc\ntype PyType_GenericNew\ntype PyType_Ready\nnumber PyNumber_Check\nnumber PyNumber_Add\nnumber PyNumber_Subtract\nnumber PyNumber_Multiply\nnumber PyNumber_Divide\nnumber PyNumber_FloorDivide\nnumber PyNumber_TrueDivide\nnumber PyNumber_Remainder\nnumber PyNumber_Divmod\nnumber PyNumber_Power\nnumber PyNumber_Negative\nnumber PyNumber_Positive\nnumber PyNumber_Absolute\nnumber PyNumber_Invert\nnumber PyNumber_Lshift\nnumber PyNumber_Rshift\nnumber PyNumber_And\nnumber PyNumber_Xor\nnumber PyNumber_Or\nnumber PyNumber_InPlaceAdd\nnumber PyNumber_InPlaceSubtract\nnumber PyNumber_InPlaceMultiply\nnumber PyNumber_InPlaceDivide\nnumber PyNumber_InPlaceFloorDivide\nnumber PyNumber_InPlaceTrueDivide\nnumber PyNumber_InPlaceRemainder\nnumber PyNumber_InPlacePower\nnumber PyNumber_InPlaceLshift\nnumber PyNumber_InPlaceRshift\nnumber PyNumber_InPlaceAnd\nnumber PyNumber_InPlaceXor\nnumber PyNumber_InPlaceOr\nnumber PyNumber_Coerce\nnumber PyNumber_CoerceEx\nnumber PyNumber_Int\nnumber PyNumber_Long\nnumber PyNumber_Float\nnumber PyNumber_Index\nnumber PyNumber_ToBase\nnumber PyNumber_AsSsize_t\nnumber PyIndex_Check\nfunction PyFunction_Check\nfunction PyFunction_New\nfunction PyFunction_GetCode\nfunction PyFunction_GetGlobals\nfunction PyFunction_GetModule\nfunction PyFunction_GetDefaults\nfunction PyFunction_SetDefaults\nfunction PyFunction_GetClosure\nfunction PyFunction_SetClosure\nstructures Py_FindMethod\niterator PySeqIter_Check\niterator PySeqIter_New\niterator PyCallIter_Check\niterator PyCallIter_New\nsys Py_FdIsInteractive\nsys PyOS_AfterFork\nsys PyOS_CheckStack\nsys PyOS_getsig\nsys PyOS_setsig\nsys *PySys_GetObject\nsys *PySys_GetFile\nsys PySys_SetObject\nsys PySys_ResetWarnOptions\nsys PySys_AddWarnOption\nsys PySys_SetPath\nsys PySys_WriteStdout\nsys PySys_WriteStderr\nsys Py_FatalError\nsys Py_Exit\nsys Py_AtExit\ncobject PyCObject_Check\ncobject PyCObject_FromVoidPtr\ncobject PyCObject_FromVoidPtrAndDesc\ncobject PyCObject_AsVoidPtr\ncobject PyCObject_GetDesc\ncobject PyCObject_SetVoidPtr\nveryhigh Py_Main\nveryhigh PyRun_AnyFile\nveryhigh PyRun_AnyFileFlags\nveryhigh PyRun_AnyFileEx\nveryhigh PyRun_AnyFileExFlags\nveryhigh PyRun_SimpleString\nveryhigh PyRun_SimpleStringFlags\nveryhigh PyRun_SimpleFile\nveryhigh PyRun_SimpleFileFlags\nveryhigh PyRun_SimpleFileEx\nveryhigh PyRun_SimpleFileExFlags\nveryhigh PyRun_InteractiveOne\nveryhigh PyRun_InteractiveOneFlags\nveryhigh PyRun_InteractiveLoop\nveryhigh PyRun_InteractiveLoopFlags\nveryhigh PyParser_SimpleParseString\nveryhigh PyParser_SimpleParseStringFlags\nveryhigh PyParser_SimpleParseStringFlagsFilename\nveryhigh PyParser_SimpleParseFile\nveryhigh PyParser_SimpleParseFileFlags\nveryhigh PyRun_String\nveryhigh PyRun_StringFlags\nveryhigh PyRun_File\nveryhigh PyRun_FileEx\nveryhigh PyRun_FileFlags\nveryhigh PyRun_FileExFlags\nveryhigh Py_CompileString\nveryhigh Py_CompileStringFlags\nveryhigh PyEval_EvalCode\nveryhigh PyEval_EvalCodeEx\nveryhigh PyEval_EvalFrame\nveryhigh PyEval_EvalFrameEx\nveryhigh PyEval_MergeCompilerFlags\ncapsule PyCapsule_CheckExact\ncapsule PyCapsule_New\ncapsule PyCapsule_GetPointer\ncapsule PyCapsule_GetDestructor\ncapsule PyCapsule_GetContext\ncapsule PyCapsule_GetName\ncapsule PyCapsule_Import\ncapsule PyCapsule_IsValid\ncapsule PyCapsule_SetContext\ncapsule PyCapsule_SetDestructor\ncapsule PyCapsule_SetName\ncapsule PyCapsule_SetPointer\nbytearray PyByteArray_Check\nbytearray PyByteArray_CheckExact\nbytearray PyByteArray_FromObject\nbytearray PyByteArray_FromStringAndSize\nbytearray PyByteArray_Concat\nbytearray PyByteArray_Size\nbytearray PyByteArray_AsString\nbytearray PyByteArray_Resize\nbytearray PyByteArray_AS_STRING\nbytearray PyByteArray_GET_SIZE\nsequence PySequence_Check\nsequence PySequence_Size\nsequence PySequence_Concat\nsequence PySequence_Repeat\nsequence PySequence_InPlaceConcat\nsequence PySequence_InPlaceRepeat\nsequence PySequence_GetItem\nsequence PySequence_GetSlice\nsequence PySequence_SetItem\nsequence PySequence_DelItem\nsequence PySequence_SetSlice\nsequence PySequence_DelSlice\nsequence PySequence_Count\nsequence PySequence_Contains\nsequence PySequence_Index\nsequence PySequence_List\nsequence PySequence_Tuple\nsequence PySequence_Fast\nsequence PySequence_Fast_GET_ITEM\nsequence PySequence_Fast_ITEMS\nsequence PySequence_ITEM\nsequence PySequence_Fast_GET_SIZE\nobject PyObject_Print\nobject PyObject_HasAttr\nobject PyObject_HasAttrString\nobject PyObject_GetAttr\nobject PyObject_GetAttrString\nobject PyObject_GenericGetAttr\nobject PyObject_SetAttr\nobject PyObject_SetAttrString\nobject PyObject_GenericSetAttr\nobject PyObject_DelAttr\nobject PyObject_DelAttrString\nobject PyObject_RichCompare\nobject PyObject_RichCompareBool\nobject PyObject_Cmp\nobject PyObject_Compare\nobject PyObject_Repr\nobject PyObject_Str\nobject PyObject_Bytes\nobject PyObject_Unicode\nobject PyObject_IsInstance\nobject PyObject_IsSubclass\nobject PyCallable_Check\nobject PyObject_Call\nobject PyObject_CallObject\nobject PyObject_CallFunction\nobject PyObject_CallMethod\nobject PyObject_CallFunctionObjArgs\nobject PyObject_CallMethodObjArgs\nobject PyObject_Hash\nobject PyObject_HashNotImplemented\nobject PyObject_IsTrue\nobject PyObject_Not\nobject PyObject_Type\nobject PyObject_TypeCheck\nobject PyObject_Length\nobject PyObject_GetItem\nobject PyObject_SetItem\nobject PyObject_DelItem\nobject PyObject_AsFileDescriptor\nobject PyObject_Dir\nobject PyObject_GetIter\nclass PyClass_Check\nclass PyClass_IsSubclass\nclass PyInstance_Check\nclass PyInstance_New\nclass PyInstance_NewRaw\ncode PyCode_Check\ncode PyCode_GetNumFree\ncode *PyCode_New\ncode PyCode_NewEmpty\ncomplex _Py_c_sum\ncomplex _Py_c_diff\ncomplex _Py_c_neg\ncomplex _Py_c_prod\ncomplex _Py_c_quot\ncomplex _Py_c_pow\ncomplex PyComplex_Check\ncomplex PyComplex_CheckExact\ncomplex PyComplex_FromCComplex\ncomplex PyComplex_FromDoubles\ncomplex PyComplex_RealAsDouble\ncomplex PyComplex_ImagAsDouble\ncomplex PyComplex_AsCComplex\ncell PyCell_Check\ncell PyCell_New\ncell PyCell_Get\ncell PyCell_GET\ncell PyCell_Set\ncell PyCell_SET\ngcsupport PyObject_GC_New\ngcsupport PyObject_GC_NewVar\ngcsupport PyObject_GC_Resize\ngcsupport PyObject_GC_Track\ngcsupport _PyObject_GC_TRACK\ngcsupport PyObject_GC_Del\ngcsupport PyObject_GC_UnTrack\ngcsupport _PyObject_GC_UNTRACK\ngcsupport Py_VISIT\nlist PyList_Check\nlist PyList_CheckExact\nlist PyList_New\nlist PyList_Size\nlist PyList_GET_SIZE\nlist PyList_GetItem\nlist PyList_GET_ITEM\nlist PyList_SetItem\nlist PyList_SET_ITEM\nlist PyList_Insert\nlist PyList_Append\nlist PyList_GetSlice\nlist PyList_SetSlice\nlist PyList_Sort\nlist PyList_Reverse\nlist PyList_AsTuple\ncodec PyCodec_Register\ncodec PyCodec_KnownEncoding\ncodec PyCodec_Encode\ncodec PyCodec_Decode\ncodec PyCodec_Encoder\ncodec PyCodec_Decoder\ncodec PyCodec_IncrementalEncoder\ncodec PyCodec_IncrementalDecoder\ncodec PyCodec_StreamReader\ncodec PyCodec_StreamWriter\ncodec PyCodec_RegisterError\ncodec PyCodec_LookupError\ncodec PyCodec_StrictErrors\ncodec PyCodec_IgnoreErrors\ncodec PyCodec_ReplaceErrors\ncodec PyCodec_XMLCharRefReplaceErrors\ncodec PyCodec_BackslashReplaceErrors\nmemory PyMem_Malloc\nmemory PyMem_Realloc\nmemory PyMem_Free\nmemory PyMem_New\nmemory PyMem_Resize\nmemory PyMem_Del\nrefcounting Py_INCREF\nrefcounting Py_XINCREF\nrefcounting Py_DECREF\nrefcounting Py_XDECREF\nrefcounting Py_CLEAR\ndatetime PyDate_Check\ndatetime PyDate_CheckExact\ndatetime PyDateTime_Check\ndatetime PyDateTime_CheckExact\ndatetime PyTime_Check\ndatetime PyTime_CheckExact\ndatetime PyDelta_Check\ndatetime PyDelta_CheckExact\ndatetime PyTZInfo_Check\ndatetime PyTZInfo_CheckExact\ndatetime PyDate_FromDate\ndatetime PyDateTime_FromDateAndTime\ndatetime PyTime_FromTime\ndatetime PyDelta_FromDSU\ndatetime PyDateTime_GET_YEAR\ndatetime PyDateTime_GET_MONTH\ndatetime PyDateTime_GET_DAY\ndatetime PyDateTime_DATE_GET_HOUR\ndatetime PyDateTime_DATE_GET_MINUTE\ndatetime PyDateTime_DATE_GET_SECOND\ndatetime PyDateTime_DATE_GET_MICROSECOND\ndatetime PyDateTime_TIME_GET_HOUR\ndatetime PyDateTime_TIME_GET_MINUTE\ndatetime PyDateTime_TIME_GET_SECOND\ndatetime PyDateTime_TIME_GET_MICROSECOND\ndatetime PyDateTime_FromTimestamp\ndatetime PyDate_FromTimestamp\nweakref PyWeakref_Check\nweakref PyWeakref_CheckRef\nweakref PyWeakref_CheckProxy\nweakref PyWeakref_NewRef\nweakref PyWeakref_NewProxy\nweakref PyWeakref_GetObject\nweakref PyWeakref_GET_OBJECT\nobjbuffer PyObject_AsCharBuffer\nobjbuffer PyObject_AsReadBuffer\nobjbuffer PyObject_CheckReadBuffer\nobjbuffer PyObject_AsWriteBuffer\nbuffer PyObject_CheckBuffer\nbuffer PyObject_GetBuffer\nbuffer PyBuffer_Release\nbuffer PyBuffer_SizeFromFormat\nbuffer PyObject_CopyToObject\nbuffer PyBuffer_IsContiguous\nbuffer PyBuffer_FillContiguousStrides\nbuffer PyBuffer_FillInfo\nbuffer *PyMemoryView_FromObject\nbuffer *PyMemoryView_FromBuffer\nbuffer *PyMemoryView_GetContiguous\nbuffer PyMemoryView_Check\nbuffer *PyMemoryView_GET_BUFFER\nbuffer PyBuffer_Check\nbuffer PyBuffer_FromObject\nbuffer PyBuffer_FromReadWriteObject\nbuffer PyBuffer_FromMemory\nbuffer PyBuffer_FromReadWriteMemory\nbuffer PyBuffer_New\narg PyArg_ParseTuple\narg PyArg_VaParse\narg PyArg_ParseTupleAndKeywords\narg PyArg_VaParseTupleAndKeywords\narg PyArg_Parse\narg PyArg_UnpackTuple\narg Py_BuildValue\narg Py_VaBuildValue\ngen PyGen_Check\ngen PyGen_CheckExact\ngen PyGen_New\ndescriptor PyDescr_NewGetSet\ndescriptor PyDescr_NewMember\ndescriptor PyDescr_NewMethod\ndescriptor PyDescr_NewWrapper\ndescriptor PyDescr_NewClassMethod\ndescriptor PyDescr_IsData\ndescriptor PyWrapper_New\nstring PyString_Check\nstring PyString_CheckExact\nstring PyString_FromString\nstring PyString_FromStringAndSize\nstring PyString_FromFormat\nstring PyString_FromFormatV\nstring PyString_Size\nstring PyString_GET_SIZE\nstring PyString_AsString\nstring PyString_AS_STRING\nstring PyString_AsStringAndSize\nstring PyString_Concat\nstring PyString_ConcatAndDel\nstring _PyString_Resize\nstring PyString_Format\nstring PyString_InternInPlace\nstring PyString_InternFromString\nstring PyString_Decode\nstring PyString_AsDecodedObject\nstring PyString_Encode\nstring PyString_AsEncodedObject\nlong PyLong_Check\nlong PyLong_CheckExact\nlong PyLong_FromLong\nlong PyLong_FromUnsignedLong\nlong PyLong_FromSsize_t\nlong PyLong_FromSize_t\nlong PyLong_FromSsize_t\nlong PyLong_FromSize_t\nlong PyLong_FromLongLong\nlong PyLong_FromUnsignedLongLong\nlong PyLong_FromDouble\nlong PyLong_FromString\nlong PyLong_FromUnicode\nlong PyLong_FromVoidPtr\nlong PyLong_AsLong\nlong PyLong_AsLongAndOverflow\nlong PyLong_AsLongLongAndOverflow\nlong PyLong_AsSsize_t\nlong PyLong_AsUnsignedLong\nlong PyLong_AsSsize_t\nlong PyLong_AsLongLong\nlong PyLong_AsUnsignedLongLong\nlong PyLong_AsUnsignedLongMask\nlong PyLong_AsUnsignedLongLongMask\nlong PyLong_AsDouble\nlong PyLong_AsVoidPtr\nfloat PyFloat_Check\nfloat PyFloat_CheckExact\nfloat PyFloat_FromString\nfloat PyFloat_FromDouble\nfloat PyFloat_AsDouble\nfloat PyFloat_AS_DOUBLE\nfloat PyFloat_GetInfo\nfloat PyFloat_GetMax\nfloat PyFloat_GetMin\nfloat PyFloat_ClearFreeList\nfloat PyFloat_AsString\nfloat PyFloat_AsReprString\nconversion PyOS_snprintf\nconversion PyOS_vsnprintf\nconversion PyOS_string_to_double\nconversion PyOS_ascii_strtod\nconversion PyOS_ascii_formatd\nconversion PyOS_double_to_string\nconversion PyOS_ascii_atof\nconversion PyOS_stricmp\nconversion PyOS_strnicmp\niter PyIter_Check\niter PyIter_Next\nmapping PyMapping_Check\nmapping PyMapping_Size\nmapping PyMapping_DelItemString\nmapping PyMapping_DelItem\nmapping PyMapping_HasKeyString\nmapping PyMapping_HasKey\nmapping PyMapping_Keys\nmapping PyMapping_Values\nmapping PyMapping_Items\nmapping PyMapping_GetItemString\nmapping PyMapping_SetItemString\ndict PyDict_Check\ndict PyDict_CheckExact\ndict PyDict_New\ndict PyDictProxy_New\ndict PyDict_Clear\ndict PyDict_Contains\ndict PyDict_Copy\ndict PyDict_SetItem\ndict PyDict_SetItemString\ndict PyDict_DelItem\ndict PyDict_DelItemString\ndict PyDict_GetItem\ndict PyDict_GetItemString\ndict PyDict_Items\ndict PyDict_Keys\ndict PyDict_Values\ndict PyDict_Size\ndict PyDict_Next\ndict PyDict_Merge\ndict PyDict_Update\ndict PyDict_MergeFromSeq2\nreflection PyEval_GetBuiltins\nreflection PyEval_GetLocals\nreflection PyEval_GetGlobals\nreflection PyEval_GetFrame\nreflection PyFrame_GetLineNumber\nreflection PyEval_GetRestricted\nreflection PyEval_GetFuncName\nreflection PyEval_GetFuncDesc\ntuple PyTuple_Check\ntuple PyTuple_CheckExact\ntuple PyTuple_New\ntuple PyTuple_Pack\ntuple PyTuple_Size\ntuple PyTuple_GET_SIZE\ntuple PyTuple_GetItem\ntuple PyTuple_GET_ITEM\ntuple PyTuple_GetSlice\ntuple PyTuple_SetItem\ntuple PyTuple_SET_ITEM\ntuple _PyTuple_Resize\ntuple PyTuple_ClearFreeList\nexceptions PyErr_PrintEx\nexceptions PyErr_Print\nexceptions PyErr_Occurred\nexceptions PyErr_ExceptionMatches\nexceptions PyErr_GivenExceptionMatches\nexceptions PyErr_NormalizeException\nexceptions PyErr_Clear\nexceptions PyErr_Fetch\nexceptions PyErr_Restore\nexceptions PyErr_SetString\nexceptions PyErr_SetObject\nexceptions PyErr_Format\nexceptions PyErr_SetNone\nexceptions PyErr_BadArgument\nexceptions PyErr_NoMemory\nexceptions PyErr_SetFromErrno\nexceptions PyErr_SetFromErrnoWithFilename\nexceptions PyErr_SetFromWindowsErr\nexceptions PyErr_SetExcFromWindowsErr\nexceptions PyErr_SetFromWindowsErrWithFilename\nexceptions PyErr_SetExcFromWindowsErrWithFilename\nexceptions PyErr_BadInternalCall\nexceptions PyErr_WarnEx\nexceptions PyErr_Warn\nexceptions PyErr_WarnExplicit\nexceptions PyErr_WarnPy3k\nexceptions PyErr_CheckSignals\nexceptions PyErr_SetInterrupt\nexceptions PySignal_SetWakeupFd\nexceptions PyErr_NewException\nexceptions PyErr_NewExceptionWithDoc\nexceptions PyErr_WriteUnraisable\nexceptions PyUnicodeDecodeError_Create\nexceptions PyUnicodeEncodeError_Create\nexceptions PyUnicodeTranslateError_Create\nexceptions PyUnicodeDecodeError_GetEncoding\nexceptions PyUnicodeDecodeError_GetObject\nexceptions PyUnicodeDecodeError_GetStart\nexceptions PyUnicodeDecodeError_SetStart\nexceptions PyUnicodeDecodeError_GetEnd\nexceptions PyUnicodeDecodeError_SetEnd\nexceptions PyUnicodeDecodeError_GetReason\nexceptions PyUnicodeDecodeError_SetReason\nexceptions Py_EnterRecursiveCall\nexceptions Py_LeaveRecursiveCall\n"
  },
  {
    "path": "libcpychecker_html/capi.py",
    "content": "#   Copyright 2012 Buck Golemon <buck@yelp.com>\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\"\"\"\nModule to help figure out urls for Python C-API functions.\n\"\"\"\nfrom os.path import dirname, abspath, join\nHERE = dirname(abspath(__file__))\n\n# Map functions to their modules.\nFUNCTIONS = {}\n\ndef init():\n    \"\"\"Initialize this module\"\"\"\n    for line in open(join(HERE, 'c-api.txt')):\n        line = line.strip()\n        if line.startswith('#'):\n            continue\n        module, function = line.split()\n        FUNCTIONS[function] = module\n    del module, function\n\ndef get_url(function):\n    \"\"\"Get a url for a function\"\"\"\n    module = FUNCTIONS.get(function)\n    if module:\n        return \"http://docs.python.org/c-api/%s.html#%s\" % (module, function)\n    else:\n        return None\n\ninit() # This is done once, upon import\n"
  },
  {
    "path": "libcpychecker_html/foo.html",
    "content": "<!DOCTYPE html>\n<html><head><meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\"><title>_mysql.c -- GCC Python Plugin</title><style media=\"screen\" type=\"text/css\">\n/* http://meyerweb.com/eric/tools/css/reset/ \n   v2.0 | 20110126\n   License: none (public domain)\n*/\na,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}table{border-collapse:collapse;border-spacing:0}\n</style><style media=\"screen\" type=\"text/css\">\n.source .hll { background-color: #ffffcc }\n.source  { background: #f8f8f8; }\n.source .c { color: #408080; font-style: italic } /* Comment */\n.source .err { border: 1px solid #FF0000 } /* Error */\n.source .k { color: #008000; font-weight: bold } /* Keyword */\n.source .o { color: #666666 } /* Operator */\n.source .cm { color: #408080; font-style: italic } /* Comment.Multiline */\n.source .cp { color: #BC7A00 } /* Comment.Preproc */\n.source .c1 { color: #408080; font-style: italic } /* Comment.Single */\n.source .cs { color: #408080; font-style: italic } /* Comment.Special */\n.source .gd { color: #A00000 } /* Generic.Deleted */\n.source .ge { font-style: italic } /* Generic.Emph */\n.source .gr { color: #FF0000 } /* Generic.Error */\n.source .gh { color: #000080; font-weight: bold } /* Generic.Heading */\n.source .gi { color: #00A000 } /* Generic.Inserted */\n.source .go { color: #888888 } /* Generic.Output */\n.source .gp { color: #000080; font-weight: bold } /* Generic.Prompt */\n.source .gs { font-weight: bold } /* Generic.Strong */\n.source .gu { color: #800080; font-weight: bold } /* Generic.Subheading */\n.source .gt { color: #0044DD } /* Generic.Traceback */\n.source .kc { color: #008000; font-weight: bold } /* Keyword.Constant */\n.source .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */\n.source .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */\n.source .kp { color: #008000 } /* Keyword.Pseudo */\n.source .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */\n.source .kt { color: #B00040 } /* Keyword.Type */\n.source .m { color: #666666 } /* Literal.Number */\n.source .s { color: #BA2121 } /* Literal.String */\n.source .na { color: #7D9029 } /* Name.Attribute */\n.source .nb { color: #008000 } /* Name.Builtin */\n.source .nc { color: #0000FF; font-weight: bold } /* Name.Class */\n.source .no { color: #880000 } /* Name.Constant */\n.source .nd { color: #AA22FF } /* Name.Decorator */\n.source .ni { color: #999999; font-weight: bold } /* Name.Entity */\n.source .ne { color: #D2413A; font-weight: bold } /* Name.Exception */\n.source .nf { color: #0000FF } /* Name.Function */\n.source .nl { color: #A0A000 } /* Name.Label */\n.source .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */\n.source .nt { color: #008000; font-weight: bold } /* Name.Tag */\n.source .nv { color: #19177C } /* Name.Variable */\n.source .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */\n.source .w { color: #bbbbbb } /* Text.Whitespace */\n.source .mf { color: #666666 } /* Literal.Number.Float */\n.source .mh { color: #666666 } /* Literal.Number.Hex */\n.source .mi { color: #666666 } /* Literal.Number.Integer */\n.source .mo { color: #666666 } /* Literal.Number.Oct */\n.source .sb { color: #BA2121 } /* Literal.String.Backtick */\n.source .sc { color: #BA2121 } /* Literal.String.Char */\n.source .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */\n.source .s2 { color: #BA2121 } /* Literal.String.Double */\n.source .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */\n.source .sh { color: #BA2121 } /* Literal.String.Heredoc */\n.source .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */\n.source .sx { color: #008000 } /* Literal.String.Other */\n.source .sr { color: #BB6688 } /* Literal.String.Regex */\n.source .s1 { color: #BA2121 } /* Literal.String.Single */\n.source .ss { color: #19177C } /* Literal.String.Symbol */\n.source .bp { color: #008000 } /* Name.Builtin.Pseudo */\n.source .vc { color: #19177C } /* Name.Variable.Class */\n.source .vg { color: #19177C } /* Name.Variable.Global */\n.source .vi { color: #19177C } /* Name.Variable.Instance */\n.source .il { color: #666666 } /* Literal.Number.Integer.Long */</style><style media=\"screen\" type=\"text/css\">\n/*  Copyright 2012 Buck Golemon <buck@yelp.com>\n *  with help from http://jsfiddle.net/simevidas/udyTs/show/light/\n \n    This is free software: you can redistribute it and/or modify it\n    under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n \n    This program is distributed in the hope that it will be useful, but\n    WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    General Public License for more details.\n \n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see\n    <http://www.gnu.org/licenses/>.\n*/\nhtml, body {\n    width: 100%;\n    background: black;\n}\nhtml {\n    height: 100%;\n}\nbody {\n    font: 12px \"DejaVu Sans\", \"Bitstream Vera Sans\", \"Ubuntu Sans\", Helvetica, Arial, sans-serif;\n    color: black;\n    background: #EBEBEB;\n    height: 100%;\n\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: vertical;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: column;\n    -ms-flex-direction: column;\n    flex-direction: column;\n}\nh1, h2 {\n    font-weight: bolder;\n}\nh1 a {\n    text-decoration: none;\n    color: inherit;\n}\nh3 {\n    display: inline-block;\n    font-weight: bold;\n    margin-right: 0.33em;\n}\nh3:after {\n    content: ':';\n}\nhr {\n    border-bottom: 1px solid #CCC; width: 640px;\n}\nimg {\n    vertical-align: middle;\n}\n\n\n/* Main page layout */\n#header {\n    background-color: #0099ff;\n}\n#reports {\n    -webkit-box-flex: 1;\n    -webkit-flex: 1;\n    -ms-flex: 1;\n    flex: 1;\n    overflow-y: auto;\n    overflow-x: hidden;\n}\n\n\n/* Header */\n#title {\n    display:-webkit-box;\n    display:-webkit-flex;\n    display:-ms-flexbox;\n    display:flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n    -webkit-box-align: center;\n    -webkit-align-items: center;\n    -ms-flex-align: center;\n    align-items: center;\n    padding: 0.5em 1em;\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n    color: white;\n    border-bottom: 1px solid #7A7A7A;\n    -webkit-box-shadow: 0px 0px 2px #000;\n    box-shadow: 0px 0px 2px #000;\n}\n#title h1 {\n    font-size: 1.2em;\n    text-shadow: 0 1px 1px black;\n}\n#title #info {\n    -webkit-box-flex: 1;\n    -webkit-flex: 1;\n    -ms-flex: 1;\n    flex: 1;\n    -webkit-box-align: end;\n    -webkit-align-items: flex-end;\n    -ms-flex-align: end;\n    align-items: flex-end;\n    text-shadow: 0 1px 0 black;\n}\n\n/* Navigation */\n#nav {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n    -webkit-box-align: center;\n    -webkit-align-items: center;\n    -ms-flex-align: center;\n    align-items: center;\n    padding: 0.5em 1em;\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n    background-color: #E4E4E4;\n    border-bottom: 1px solid #7A7A7A;\n    -webkit-box-shadow: 0px 0px 2px #000;\n    box-shadow: 0px 0px 2px #000;\n}\n#report-pagination a {\n    padding: 4px;\n}\n#prev,\n#next {\n    padding: 0.25em 1em;\n    background-color: white;\n    border: 1px solid #ccc;\n    margin-left: 1em;\n}\n\n\n#header-container {\n    border-bottom:1px solid #7A7A7A;\n}\n\n#header ul {\n    margin: 0;\n    padding: 0;\n    list-style: none;\n    position: absolute;\n    top: 35px;\n    right: 0;\n}\n\n#header ul li {\n    float: left;\n    margin-right: 5px;\n}\n\n#header ul li a{\n    color: #90b874;\n    font-weight: bold;\n    font-size: 1.4em;\n    margin-right: 5px;\n    text-decoration: none;\n}\n\n#header ul li a:hover {\n    color: #beffbf;\n}\n\n\n\n\n\n#reports > li {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: vertical;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: column;\n    -ms-flex-direction: column;\n    flex-direction: column;\n    width: 100%;\n}\n#reports > li + li {\n    border-top: 1px dashed hsl(0, 0%, 70%);\n}\n#reports > li header {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n    padding: .5em;\n    background: white;\n}\n#reports > li header .error {\n    -webkit-box-flex: 1;\n    -webkit-flex: 1;\n    -ms-flex: 1;\n    flex: 1;\n    color: darkred;\n    font-weight: bold;\n    text-align: center;\n}\n#reports > li .body {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n}\n\n\n\n.label {\n    font-size: 12px;\n    font-weight:bolder;\n    margin-left: 2em;\n}\n\n#main {\n    background: red;\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n}\n\n\n.source {\n    height: 100%;\n    font-size: 12px;\n    background: white;\n    line-height: 1.33;\n    overflow-x: auto;\n    border-right: 1px solid hsl(0, 0%, 70%);\n    -webkit-box-flex: 1;\n    -webkit-flex: 1 0 40em;\n    -ms-flex: 1 0 40em;\n    flex: 1 0 40em;\n}\n.source table {\n    width: 100%;\n    font-family: monospace;\n}\n\n#code {\n    background: blue;\n    min-width: 300px;\n    -webkit-box-flex: 2;\n    -webkit-flex: 2;\n    -ms-flex: 2;\n    flex: 2;\n}\n.source tr:nth-child(2n) {\n    background: hsl(0, 0%, 93%);\n}\n\n#container {\n    width: 1000px;\n    margin: 0 auto;\n    font-size:12px;\n    overflow: auto;\n    padding: 70px 0 0px;\n    background-color:#f8f8f8;\n}\n\n#content {\n    float: left;\n    width: 660px;\n    padding-top:20px;\n    padding-left:20px;\n    padding-right:10px;\n}\n\n#content .source td {\n    font-family: monospace;\n    white-space: pre;\n    min-height: 1em;\n    line-height: 20px;\n}\n\n\n.fnc-report {\n    font-size:12px;\n}\n\n#error-box {\n    font-size:12px;\n    font-color:000;\n    float:left;\n}\n\n#report-count{\n    font-size:12px;\n    float:right;\n}\n\n/* Left column: source code */\n.source tr:hover {\n    background: hsl(210, 30%, 87%);\n}\n.source .lineno {\n    padding-right: 0.5em;\n    text-align: right;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    color: hsl(0, 0%, 60%);\n    vertical-align: middle;\n}\n.source .code {\n    white-space: pre;\n}\n\n\n/* Right column: list of states */\n.states {\n    font-size: 12px;\n    top: 0.5em;\n    height: 100%;\n    min-width: 25em;\n    border-left: 1px solid hsl(0, 0%, 70%);\n    border-top: 2px solid #B2B2B2\n}\n.states li {\n    position: relative;\n    padding: 0.5em;\n    margin: 1em;\n    background: white;\n    border: 1px solid hsl(0, 0%, 80%);\n}\n.states li.new-subflow {\n    border-top-width: 4px;\n}\n.states h2 {\n    float: right;\n    padding: 0.33em 0.5em;\n    margin: -0.5em -0.5em 0.5em 0.5em;\n    background: hsl(0, 0%, 80%);\n    color: hsl(0, 0%, 30%);\n    border-radius: 0 0 0 0.5em;\n}\n.states p {\n    line-height: 1.5;\n}\n.states p + p {\n    margin-top: 0.5em;\n}\n\nvar {\n    color: navy;\n}\nvar.leak {\n    color: darkred;\n    font-weight: bold;\n    background: hsl(0, 100%, 90%);\n}\n\n.flow-line {\n    background: hsl(210, 80%, 60%);\n    -webkit-background-clip: content-box;\n    background-clip: content-box;\n    width: 2px;\n}\n.flow-empty, .flow-line {\n    padding: 0 5px;\n    text-align: center;\n}\n.flow-dot {\n    display: inline-block;\n    background: hsl(210, 80%, 60%);\n    outline: 1px solid rgba(100%, 100%, 100%, 0.5);\n    height: 6px;\n    width: 6px;\n    margin: -2px;\n    border-radius: 100px;\n    outline-radius: 100px;\n    vertical-align: middle;\n}\n\n/* Selection overrides */\n.states li {\n    left: 0;\n    -webkit-transition-property: left, background-color, border-color;\n    transition-property: left, background-color, border-color;\n}\n.source tr\n.states li h2 {\n    -webkit-transition-property: background-color;\n    transition-property: background-color;\n}\ntd .flow-dot,\n.states li,\n.states li h2 {\n    -webkit-transition-duration: 0.25s;\n    transition-duration: 0.25s;\n    -webkit-transition-timing-function: ease-out;\n    transition-timing-function: ease-out;\n}\n\ntd:hover .flow-dot,\ntd.selected .flow-dot {\n    height: 10px;\n    width: 10px;\n    background: hsl(30, 80%, 60%);\n    margin: -5px;\n}\n\n.source tr:hover,\n.source tr.selected {\n    background-color: #ffe181;\n}\n.states li:hover,\n.states li.selected {\n    left: -2em;\n    background-color: #fef8cb;\n    border-color: #ffe181;\n}\n.states li:hover h2,\n.states li.selected h2 {\n    background-color: #ffe181;\n}\n\n#notes {\n    background: yellow;\n    min-width: 200px;\n}\n\n.note {\n    font-weight: bolder;\n}\n.note:first-of-type::before {\n    /* content: url('images/exclamation.png');\n     * to regenerate:\n     *      from libcpychecker_html.make_html import data_uri\n     *      data_uri('image/png', 'images/exclamation.png')\n     */\n    content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjBJREFUeNqkk0trE1EUx8/cO49OfGTSRNJMYsA0aVonoYh13YW71uJCKFQhKqibfgFLwYULsR/AhY+VG1d+C124kJiFIGipmoIZNUXtZDKTycz1njGpaRNU8MJv7txzzv/c5xEYY/A/TRQEAW5c5KwM+aKcR73/a5zvg84HT371wv07Apwuj0x+PZW/vArA4NO7x/f4+OGoIHLKAAiC/fBdHadSbCGZPTeTzC7OUElbQNvBOISMMnIqeqFSYs57mTkfZD1/qYS2f0rAZ5pVDmXnY/FSbn3jM6xvfAEtfjKnRDLz6BtK4PPPADi+ms6vGK71lti2DUintUVSJ84b6OvF7GlI4PNMPVgAZ49oxpyqRnXf+wGWZYX4ngWRiKYfPpqfw5hBjej7eweqCkSo6JOLhmd/hI7vQLVaBdM0YXt1FgK2CeJ40fCbmxUWsGc8vh3egtcFQPhyLsQnzpQJcbVmuw5mawtqtRo0Gg3wJQeY7ALIrqZEM2WM7esIPkROAgR5OZEpTTV3X4IXNEGiLnw1b4fItBNCBQuiqeQUA7qMGtSSLt8C38aVRLo47QVvVJFYoFAnJJG8FdIfI6rSVWMTx6ZRg1rS7UKeSspSMj2Wk+AbjPGZ+vTboA1JZbQcEcUl1Iq2zdZyxURBpruUMTzR38Vl79wM+9bO0/3vlwLVs+OF16/MNdFug/vi+Xadm+vDL/3uHyuR16Er4E3gKvEaOTLa/1LBuEQPF8hxfgowAINnMqTBUH7hAAAAAElFTkSuQmCC');\n    padding: 5px;\n}\n</style></head><body><header id=\"header\"><div id=\"title\"><h1><a href=\"http://gcc-python-plugin.readthedocs.org/\">GCC Python Plugin</a></h1><div id=\"info\"><span class=\"label\">Filename: </span>_mysql.c<span class=\"label\">Function: </span>init_mysql</div><div id=\"report-pagination\"><span class=\"label\">Report: </span><a href=\"#state1\">1</a><a href=\"#state2\">2</a><a href=\"#state3\">3</a><a href=\"#state4\">4</a><a href=\"#state5\">5</a></div><div id=\"prev\"><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAAmVBMVEUAAAAyjdgRYKsAAAAAAAAAAAAAAAAAAAAWZrEuh9IAAAAAAAA+nOc8muU4leAzjtkGUp0LWKMQX6oid8Iof8ocbrlAnuknfskCOnMdb7oCMmMFPnYXZ7IthtF4xfU8qOZCreeX5P9msu6J1ftotO8dvf9xvvNer+xVp+BEltNBk9CS3v2P2/xWyfo2xf8Oq/WCzvkruPdJm9g8P9teAAAAHnRSTlMAXFwHDjMCGtXVFSpc1dXV1dXV1dXVmVyoXHRcmZmc7OcWAAAAg0lEQVQY03XI1xKCMBRF0SskhCId7JpCx+7/f5x3yIOEGdfDmdkH/lhvFh2GRq8iGRkdyyqetyfbl6edsbfFta7bi1bgkd+UUl3/GcZx6HM89mXVcS6E4LglIMu9P9+udoLpyR5NBnNW2qRgOCbJLxzCAnrYUUoDRhxANvHZxCc2HktfOAUJ2EcSIOkAAAAASUVORK5CYII=\"></div><div id=\"next\"><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAArlBMVEUAAAAAAAAAAAAAAAAuh9IAAAAAAAAbarIAAAAWZrEAAAAAAAA+nOc1kdwaa7Y8muU4leAyjtkOXKgGUp4LWKQQX6oid8InfsocbrknfslAnukthtECOnMFPnYCMmMuh9IXZ7IthtFCred3w/SX5P9msu47p+Z6xvWJ1ftotO8dvf9er+xVp+BEltNBk9A+quWS3v2P2/xyvvSCzvlWyfo2xf8Oq/VxvfIruPdJm9jCm9cMAAAAInRSTlMADwcO1DMCARrWFSpaWlzV1dVc1tbW1tXWW5laqVx01ZuZpXRnmQAAAI9JREFUGNN1zscWgjAURVFa6NKbXSMkdOzl/3/MkDgwujijt/bkXWEqbWH/gOvaPHi5N+PEL3OfyV6hbS/nXFmOkOIDCeNHVR3TOYGk7fq+e7VNURSnhEAG0TBACBFqyswhsDNYz/vVcOhDVlzf4uB7R1RHATcsDNefUxV1CwCw2gBLl9URJNHUaaYsacJfbzuuC9BZF0LQAAAAAElFTkSuQmCC\"></div></div></header><ol id=\"reports\"><li id=\"state1\"><header><div class=\"error\">ob_refcnt of '*module' is 1 too high</div><div class=\"report-count\"><h3>Report</h3>1</div></header><div class=\"body\"><div class=\"source\"><table data-first-line=\"2981\"><tr><td class=\"code\"><span class=\"n\">DL_EXPORT</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"n\">init_mysql</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">module</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">emod</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">edict</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span> <span class=\"o\">=</span> <span class=\"n\">mysql_init</span><span class=\"p\">(</span><span class=\"nb\">NULL</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span><span class=\"o\">-&gt;</span><span class=\"n\">charset</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">my_charset_utf8mb4_unicode_ci</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\">PyModule_Create</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysqlmodule</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/allocation.html#Py_InitModule4\">Py_InitModule4</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_methods</span><span class=\"p\">,</span> <span class=\"n\">_mysql___doc__</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"nb\">NULL</span><span class=\"p\">,</span> <span class=\"n\">PYTHON_API_VERSION</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#if PY_VERSION_HEX &gt;= 0x02020000</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifndef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">dict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"version_info\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\"><a href=\"http://docs.python.org/c-api/veryhigh.html#PyRun_String\">PyRun_String</a></span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">version_info</span><span class=\"p\">),</span> <span class=\"n\">Py_eval_input</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t       <span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">dict</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"__version__\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\">PyUnicode_FromString</span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">__version__</span><span class=\"p\">))))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"connection\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"result\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\t\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">emod</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/import.html#PyImport_ImportModule\">PyImport_ImportModule</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql_exceptions\"</span><span class=\"p\">)))</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t    <span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Print\">PyErr_Print</a></span><span class=\"p\">();</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">edict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_MySQLError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"MySQLError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Warning</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Warning\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Error</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Error\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InterfaceError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InterfaceError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DatabaseError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DatabaseError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DataError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DataError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_OperationalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"OperationalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_IntegrityError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"IntegrityError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InternalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InternalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_ProgrammingError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"ProgrammingError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NotSupportedError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"NotSupportedError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NULL</span> <span class=\"o\">=</span> <span class=\"n\">PyBytes_FromString</span><span class=\"p\">(</span><span class=\"s\">\"NULL\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"NULL\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_NULL</span><span class=\"p\">))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">  <span class=\"nl\">error:</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Occurred\">PyErr_Occurred</a></span><span class=\"p\">())</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_SetString\">PyErr_SetString</a></span><span class=\"p\">(</span><span class=\"n\">PyExc_ImportError</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"s\">\"_mysql: init failed\"</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"nb\">NULL</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">    <span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">}</span>\n</td></tr></table></div><ol class=\"states\"><li data-line=\"2988\"><p>when treating unknown struct MYSQL * from _mysql.c:2987 as non-NULL</p></li><li data-line=\"2994\"><p>when Py_InitModule4TraceRefs_64() succeeds</p><p class=\"note\">new ref from (unknown) Py_InitModule4TraceRefs_64 allocated at: \tmodule = Py_InitModule4(\"_mysql\", _mysql_methods, _mysql___doc__,</p></li><li data-line=\"2996\"><p>taking False path</p></li><li data-line=\"3016\"><p>taking False path</p></li><li data-line=\"3017\"><p>when PyRun_StringFlags() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3021\"><p>when PyUnicodeUCS4_FromString() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3024\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3028\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3032\"><p>when PyImport_ImportModule() succeeds</p><p>taking False path</p></li><li data-line=\"3036\"><p>taking False path</p></li><li data-line=\"3038\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3037\"><p>taking False path</p></li><li data-line=\"3041\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3040\"><p>taking False path</p></li><li data-line=\"3044\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3043\"><p>taking False path</p></li><li data-line=\"3047\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3046\"><p>taking False path</p></li><li data-line=\"3050\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3049\"><p>taking False path</p></li><li data-line=\"3053\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3052\"><p>taking False path</p></li><li data-line=\"3056\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3055\"><p>taking False path</p></li><li data-line=\"3059\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3058\"><p>taking False path</p></li><li data-line=\"3062\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3061\"><p>taking False path</p></li><li data-line=\"3065\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3064\"><p>taking False path</p></li><li data-line=\"3068\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3067\"><p>taking False path</p></li><li data-line=\"3070\"><p>when PyString_FromString() succeeds</p><p>taking False path</p></li><li data-line=\"3072\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3074\"><p>taking True path</p><p>when taking True path</p><p>taking False path</p></li><li data-line=\"3075\"><p>PyErr_Occurred()</p><p>taking False path</p></li><li data-line=\"2996\"><p>returning</p><p class=\"note\">was expecting final ob_refcnt to be N + 0 (for some unknown N)</p><p class=\"note\">but final ob_refcnt is N + 1</p><p class=\"note\">found 1 similar trace(s) to this</p></li></ol></div></li><li id=\"state2\"><header><div class=\"error\">ob_refcnt of '*_mysql_ConnectionObject_Type.355' is 1 too high</div><div class=\"report-count\"><h3>Report</h3>2</div></header><div class=\"body\"><div class=\"source\"><table data-first-line=\"2981\"><tr><td class=\"code\"><span class=\"n\">DL_EXPORT</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"n\">init_mysql</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">module</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">emod</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">edict</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span> <span class=\"o\">=</span> <span class=\"n\">mysql_init</span><span class=\"p\">(</span><span class=\"nb\">NULL</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span><span class=\"o\">-&gt;</span><span class=\"n\">charset</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">my_charset_utf8mb4_unicode_ci</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\">PyModule_Create</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysqlmodule</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/allocation.html#Py_InitModule4\">Py_InitModule4</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_methods</span><span class=\"p\">,</span> <span class=\"n\">_mysql___doc__</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"nb\">NULL</span><span class=\"p\">,</span> <span class=\"n\">PYTHON_API_VERSION</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#if PY_VERSION_HEX &gt;= 0x02020000</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifndef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">dict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"version_info\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\"><a href=\"http://docs.python.org/c-api/veryhigh.html#PyRun_String\">PyRun_String</a></span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">version_info</span><span class=\"p\">),</span> <span class=\"n\">Py_eval_input</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t       <span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">dict</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"__version__\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\">PyUnicode_FromString</span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">__version__</span><span class=\"p\">))))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"connection\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"result\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\t\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">emod</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/import.html#PyImport_ImportModule\">PyImport_ImportModule</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql_exceptions\"</span><span class=\"p\">)))</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t    <span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Print\">PyErr_Print</a></span><span class=\"p\">();</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">edict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_MySQLError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"MySQLError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Warning</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Warning\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Error</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Error\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InterfaceError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InterfaceError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DatabaseError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DatabaseError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DataError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DataError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_OperationalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"OperationalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_IntegrityError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"IntegrityError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InternalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InternalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_ProgrammingError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"ProgrammingError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NotSupportedError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"NotSupportedError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NULL</span> <span class=\"o\">=</span> <span class=\"n\">PyBytes_FromString</span><span class=\"p\">(</span><span class=\"s\">\"NULL\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"NULL\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_NULL</span><span class=\"p\">))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">  <span class=\"nl\">error:</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Occurred\">PyErr_Occurred</a></span><span class=\"p\">())</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_SetString\">PyErr_SetString</a></span><span class=\"p\">(</span><span class=\"n\">PyExc_ImportError</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"s\">\"_mysql: init failed\"</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"nb\">NULL</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">    <span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">}</span>\n</td></tr></table></div><ol class=\"states\"><li data-line=\"2988\"><p>when treating unknown struct MYSQL * from _mysql.c:2987 as non-NULL</p></li><li data-line=\"2994\"><p>when Py_InitModule4TraceRefs_64() succeeds</p></li><li data-line=\"2996\"><p>taking False path</p></li><li data-line=\"3016\"><p>taking False path</p></li><li data-line=\"3017\"><p>when PyRun_StringFlags() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3021\"><p>when PyUnicodeUCS4_FromString() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3024\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3028\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3032\"><p>when PyImport_ImportModule() succeeds</p><p>taking False path</p></li><li data-line=\"3036\"><p>taking False path</p></li><li data-line=\"3038\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3037\"><p>taking False path</p></li><li data-line=\"3041\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3040\"><p>taking False path</p></li><li data-line=\"3044\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3043\"><p>taking False path</p></li><li data-line=\"3047\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3046\"><p>taking False path</p></li><li data-line=\"3050\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3049\"><p>taking False path</p></li><li data-line=\"3053\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3052\"><p>taking False path</p></li><li data-line=\"3056\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3055\"><p>taking False path</p></li><li data-line=\"3059\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3058\"><p>taking False path</p></li><li data-line=\"3062\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3061\"><p>taking False path</p></li><li data-line=\"3065\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3064\"><p>taking False path</p></li><li data-line=\"3068\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3067\"><p>taking False path</p></li><li data-line=\"3070\"><p>when PyString_FromString() succeeds</p><p>taking False path</p></li><li data-line=\"3072\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3074\"><p>taking True path</p><p>when taking True path</p><p>taking False path</p></li><li data-line=\"3075\"><p>PyErr_Occurred()</p><p>taking False path</p></li><li data-line=\"2996\"><p>returning</p><p class=\"note\">was expecting final ob_refcnt to be N + 0 (for some unknown N)</p><p class=\"note\">but final ob_refcnt is N + 1</p><p class=\"note\">found 9 similar trace(s) to this</p></li></ol></div></li><li id=\"state3\"><header><div class=\"error\">ob_refcnt of '*_mysql_ResultObject_Type.358' is 1 too high</div><div class=\"report-count\"><h3>Report</h3>3</div></header><div class=\"body\"><div class=\"source\"><table data-first-line=\"2981\"><tr><td class=\"code\"><span class=\"n\">DL_EXPORT</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"n\">init_mysql</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">module</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">emod</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">edict</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span> <span class=\"o\">=</span> <span class=\"n\">mysql_init</span><span class=\"p\">(</span><span class=\"nb\">NULL</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span><span class=\"o\">-&gt;</span><span class=\"n\">charset</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">my_charset_utf8mb4_unicode_ci</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\">PyModule_Create</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysqlmodule</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/allocation.html#Py_InitModule4\">Py_InitModule4</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_methods</span><span class=\"p\">,</span> <span class=\"n\">_mysql___doc__</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"nb\">NULL</span><span class=\"p\">,</span> <span class=\"n\">PYTHON_API_VERSION</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#if PY_VERSION_HEX &gt;= 0x02020000</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifndef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">dict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"version_info\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\"><a href=\"http://docs.python.org/c-api/veryhigh.html#PyRun_String\">PyRun_String</a></span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">version_info</span><span class=\"p\">),</span> <span class=\"n\">Py_eval_input</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t       <span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">dict</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"__version__\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\">PyUnicode_FromString</span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">__version__</span><span class=\"p\">))))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"connection\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"result\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\t\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">emod</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/import.html#PyImport_ImportModule\">PyImport_ImportModule</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql_exceptions\"</span><span class=\"p\">)))</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t    <span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Print\">PyErr_Print</a></span><span class=\"p\">();</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">edict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_MySQLError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"MySQLError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Warning</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Warning\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Error</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Error\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InterfaceError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InterfaceError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DatabaseError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DatabaseError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DataError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DataError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_OperationalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"OperationalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_IntegrityError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"IntegrityError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InternalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InternalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_ProgrammingError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"ProgrammingError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NotSupportedError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"NotSupportedError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NULL</span> <span class=\"o\">=</span> <span class=\"n\">PyBytes_FromString</span><span class=\"p\">(</span><span class=\"s\">\"NULL\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"NULL\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_NULL</span><span class=\"p\">))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">  <span class=\"nl\">error:</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Occurred\">PyErr_Occurred</a></span><span class=\"p\">())</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_SetString\">PyErr_SetString</a></span><span class=\"p\">(</span><span class=\"n\">PyExc_ImportError</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"s\">\"_mysql: init failed\"</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"nb\">NULL</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">    <span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">}</span>\n</td></tr></table></div><ol class=\"states\"><li data-line=\"2988\"><p>when treating unknown struct MYSQL * from _mysql.c:2987 as non-NULL</p></li><li data-line=\"2994\"><p>when Py_InitModule4TraceRefs_64() succeeds</p></li><li data-line=\"2996\"><p>taking False path</p></li><li data-line=\"3016\"><p>taking False path</p></li><li data-line=\"3017\"><p>when PyRun_StringFlags() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3021\"><p>when PyUnicodeUCS4_FromString() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3024\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3028\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3032\"><p>when PyImport_ImportModule() succeeds</p><p>taking False path</p></li><li data-line=\"3036\"><p>taking False path</p></li><li data-line=\"3038\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3037\"><p>taking False path</p></li><li data-line=\"3041\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3040\"><p>taking False path</p></li><li data-line=\"3044\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3043\"><p>taking False path</p></li><li data-line=\"3047\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3046\"><p>taking False path</p></li><li data-line=\"3050\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3049\"><p>taking False path</p></li><li data-line=\"3053\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3052\"><p>taking False path</p></li><li data-line=\"3056\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3055\"><p>taking False path</p></li><li data-line=\"3059\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3058\"><p>taking False path</p></li><li data-line=\"3062\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3061\"><p>taking False path</p></li><li data-line=\"3065\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3064\"><p>taking False path</p></li><li data-line=\"3068\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3067\"><p>taking False path</p></li><li data-line=\"3070\"><p>when PyString_FromString() succeeds</p><p>taking False path</p></li><li data-line=\"3072\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3074\"><p>taking True path</p><p>when taking True path</p><p>taking False path</p></li><li data-line=\"3075\"><p>PyErr_Occurred()</p><p>taking False path</p></li><li data-line=\"2996\"><p>returning</p><p class=\"note\">was expecting final ob_refcnt to be N + 0 (for some unknown N)</p><p class=\"note\">but final ob_refcnt is N + 1</p><p class=\"note\">found 9 similar trace(s) to this</p></li></ol></div></li><li id=\"state4\"><header><div class=\"error\">ob_refcnt of new ref from (unknown) PyRun_StringFlags is 1 too high</div><div class=\"report-count\"><h3>Report</h3>4</div></header><div class=\"body\"><div class=\"source\"><table data-first-line=\"2981\"><tr><td class=\"code\"><span class=\"n\">DL_EXPORT</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"n\">init_mysql</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">module</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">emod</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">edict</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span> <span class=\"o\">=</span> <span class=\"n\">mysql_init</span><span class=\"p\">(</span><span class=\"nb\">NULL</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span><span class=\"o\">-&gt;</span><span class=\"n\">charset</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">my_charset_utf8mb4_unicode_ci</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\">PyModule_Create</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysqlmodule</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/allocation.html#Py_InitModule4\">Py_InitModule4</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_methods</span><span class=\"p\">,</span> <span class=\"n\">_mysql___doc__</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"nb\">NULL</span><span class=\"p\">,</span> <span class=\"n\">PYTHON_API_VERSION</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#if PY_VERSION_HEX &gt;= 0x02020000</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifndef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">dict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"version_info\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\"><a href=\"http://docs.python.org/c-api/veryhigh.html#PyRun_String\">PyRun_String</a></span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">version_info</span><span class=\"p\">),</span> <span class=\"n\">Py_eval_input</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t       <span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">dict</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"__version__\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\">PyUnicode_FromString</span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">__version__</span><span class=\"p\">))))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"connection\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"result\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\t\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">emod</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/import.html#PyImport_ImportModule\">PyImport_ImportModule</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql_exceptions\"</span><span class=\"p\">)))</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t    <span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Print\">PyErr_Print</a></span><span class=\"p\">();</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">edict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_MySQLError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"MySQLError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Warning</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Warning\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Error</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Error\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InterfaceError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InterfaceError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DatabaseError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DatabaseError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DataError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DataError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_OperationalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"OperationalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_IntegrityError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"IntegrityError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InternalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InternalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_ProgrammingError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"ProgrammingError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NotSupportedError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"NotSupportedError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NULL</span> <span class=\"o\">=</span> <span class=\"n\">PyBytes_FromString</span><span class=\"p\">(</span><span class=\"s\">\"NULL\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"NULL\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_NULL</span><span class=\"p\">))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">  <span class=\"nl\">error:</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Occurred\">PyErr_Occurred</a></span><span class=\"p\">())</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_SetString\">PyErr_SetString</a></span><span class=\"p\">(</span><span class=\"n\">PyExc_ImportError</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"s\">\"_mysql: init failed\"</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"nb\">NULL</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">    <span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">}</span>\n</td></tr></table></div><ol class=\"states\"><li data-line=\"2988\"><p>when treating unknown struct MYSQL * from _mysql.c:2987 as non-NULL</p></li><li data-line=\"2994\"><p>when Py_InitModule4TraceRefs_64() succeeds</p></li><li data-line=\"2996\"><p>taking False path</p></li><li data-line=\"3016\"><p>taking False path</p></li><li data-line=\"3017\"><p>when PyRun_StringFlags() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3021\"><p>when PyUnicodeUCS4_FromString() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3024\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3028\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3032\"><p>when PyImport_ImportModule() succeeds</p><p>taking False path</p></li><li data-line=\"3036\"><p>taking False path</p></li><li data-line=\"3038\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3037\"><p>taking False path</p></li><li data-line=\"3041\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3040\"><p>taking False path</p></li><li data-line=\"3044\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3043\"><p>taking False path</p></li><li data-line=\"3047\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3046\"><p>taking False path</p></li><li data-line=\"3050\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3049\"><p>taking False path</p></li><li data-line=\"3053\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3052\"><p>taking False path</p></li><li data-line=\"3056\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3055\"><p>taking False path</p></li><li data-line=\"3059\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3058\"><p>taking False path</p></li><li data-line=\"3062\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3061\"><p>taking False path</p></li><li data-line=\"3065\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3064\"><p>taking False path</p></li><li data-line=\"3068\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3067\"><p>taking False path</p></li><li data-line=\"3070\"><p>when PyString_FromString() succeeds</p><p>taking False path</p></li><li data-line=\"3072\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3074\"><p>taking True path</p><p>when taking True path</p><p>taking False path</p></li><li data-line=\"3075\"><p>PyErr_Occurred()</p><p>taking False path</p></li><li data-line=\"2996\"><p>returning</p><p class=\"note\">was expecting final ob_refcnt to be N + 0 (for some unknown N)</p><p class=\"note\">but final ob_refcnt is N + 1</p><p class=\"note\">found 9 similar trace(s) to this</p></li><li data-line=\"3017\"><p class=\"note\">new ref from (unknown) PyRun_StringFlags allocated at: \tif (PyDict_SetItemString(dict, \"version_info\",</p></li></ol></div></li><li id=\"state5\"><header><div class=\"error\">ob_refcnt of new ref from (unknown) PyUnicodeUCS4_FromString is 1 too high</div><div class=\"report-count\"><h3>Report</h3>5</div></header><div class=\"body\"><div class=\"source\"><table data-first-line=\"2981\"><tr><td class=\"code\"><span class=\"n\">DL_EXPORT</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"n\">init_mysql</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">module</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">emod</span><span class=\"p\">,</span> <span class=\"o\">*</span><span class=\"n\">edict</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span> <span class=\"o\">=</span> <span class=\"n\">mysql_init</span><span class=\"p\">(</span><span class=\"nb\">NULL</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">utf8conn</span><span class=\"o\">-&gt;</span><span class=\"n\">charset</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">my_charset_utf8mb4_unicode_ci</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\">PyModule_Create</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysqlmodule</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/allocation.html#Py_InitModule4\">Py_InitModule4</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_methods</span><span class=\"p\">,</span> <span class=\"n\">_mysql___doc__</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"nb\">NULL</span><span class=\"p\">,</span> <span class=\"n\">PYTHON_API_VERSION</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"k\">return</span><span class=\"p\">;</span> <span class=\"cm\">/* this really should never happen */</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">Py_TYPE</span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">)</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#else</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">ob_type</span> <span class=\"o\">=</span> <span class=\"o\">&amp;</span><span class=\"n\">PyType_Type</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#if PY_VERSION_HEX &gt;= 0x02020000</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_alloc</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericAlloc\">PyType_GenericAlloc</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_new</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/type.html#PyType_GenericNew\">PyType_GenericNew</a></span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifndef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">.</span><span class=\"n\">tp_free</span> <span class=\"o\">=</span> <span class=\"n\">_PyObject_GC_Del</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\">\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">dict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"version_info\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\"><a href=\"http://docs.python.org/c-api/veryhigh.html#PyRun_String\">PyRun_String</a></span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">version_info</span><span class=\"p\">),</span> <span class=\"n\">Py_eval_input</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t       <span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">dict</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"__version__\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"n\">PyUnicode_FromString</span><span class=\"p\">(</span><span class=\"n\">QUOTE</span><span class=\"p\">(</span><span class=\"n\">__version__</span><span class=\"p\">))))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"connection\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ConnectionObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"result\"</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t       <span class=\"p\">(</span><span class=\"n\">PyObject</span> <span class=\"o\">*</span><span class=\"p\">)</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\t\n</td></tr><tr><td class=\"code\">\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_INCREF\">Py_INCREF</a></span><span class=\"p\">(</span><span class=\"o\">&amp;</span><span class=\"n\">_mysql_ResultObject_Type</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">emod</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/import.html#PyImport_ImportModule\">PyImport_ImportModule</a></span><span class=\"p\">(</span><span class=\"s\">\"_mysql_exceptions\"</span><span class=\"p\">)))</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t    <span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Print\">PyErr_Print</a></span><span class=\"p\">();</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">edict</span> <span class=\"o\">=</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/module.html#PyModule_GetDict\">PyModule_GetDict</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_MySQLError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"MySQLError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Warning</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Warning\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_Error</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"Error\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InterfaceError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InterfaceError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DatabaseError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DatabaseError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_DataError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"DataError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_OperationalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"OperationalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_IntegrityError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"IntegrityError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_InternalError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"InternalError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_ProgrammingError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"ProgrammingError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NotSupportedError</span> <span class=\"o\">=</span>\n</td></tr><tr><td class=\"code\">\t      <span class=\"n\">_mysql_NewException</span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"n\">edict</span><span class=\"p\">,</span> <span class=\"s\">\"NotSupportedError\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"o\">!</span><span class=\"p\">(</span><span class=\"n\">_mysql_NULL</span> <span class=\"o\">=</span> <span class=\"n\">PyBytes_FromString</span><span class=\"p\">(</span><span class=\"s\">\"NULL\"</span><span class=\"p\">)))</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/dict.html#PyDict_SetItemString\">PyDict_SetItemString</a></span><span class=\"p\">(</span><span class=\"n\">dict</span><span class=\"p\">,</span> <span class=\"s\">\"NULL\"</span><span class=\"p\">,</span> <span class=\"n\">_mysql_NULL</span><span class=\"p\">))</span> <span class=\"k\">goto</span> <span class=\"n\">error</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">  <span class=\"nl\">error:</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">emod</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_Occurred\">PyErr_Occurred</a></span><span class=\"p\">())</span> <span class=\"p\">{</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\"><a href=\"http://docs.python.org/c-api/exceptions.html#PyErr_SetString\">PyErr_SetString</a></span><span class=\"p\">(</span><span class=\"n\">PyExc_ImportError</span><span class=\"p\">,</span>\n</td></tr><tr><td class=\"code\">\t\t\t\t<span class=\"s\">\"_mysql: init failed\"</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"k\">if</span> <span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">)</span> <span class=\"n\"><a href=\"http://docs.python.org/c-api/refcounting.html#Py_DECREF\">Py_DECREF</a></span><span class=\"p\">(</span><span class=\"n\">module</span><span class=\"p\">);</span>\n</td></tr><tr><td class=\"code\">\t\t<span class=\"n\">module</span> <span class=\"o\">=</span> <span class=\"nb\">NULL</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\">    <span class=\"p\">}</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#ifdef IS_PY3K</span>\n</td></tr><tr><td class=\"code\">    <span class=\"k\">return</span> <span class=\"n\">module</span><span class=\"p\">;</span>\n</td></tr><tr><td class=\"code\"><span class=\"cp\">#endif</span>\n</td></tr><tr><td class=\"code\"><span class=\"p\">}</span>\n</td></tr></table></div><ol class=\"states\"><li data-line=\"2988\"><p>when treating unknown struct MYSQL * from _mysql.c:2987 as non-NULL</p></li><li data-line=\"2994\"><p>when Py_InitModule4TraceRefs_64() succeeds</p></li><li data-line=\"2996\"><p>taking False path</p></li><li data-line=\"3016\"><p>taking False path</p></li><li data-line=\"3017\"><p>when PyRun_StringFlags() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3021\"><p>when PyUnicodeUCS4_FromString() succeeds</p><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3024\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3028\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3032\"><p>when PyImport_ImportModule() succeeds</p><p>taking False path</p></li><li data-line=\"3036\"><p>taking False path</p></li><li data-line=\"3038\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3037\"><p>taking False path</p></li><li data-line=\"3041\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3040\"><p>taking False path</p></li><li data-line=\"3044\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3043\"><p>taking False path</p></li><li data-line=\"3047\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3046\"><p>taking False path</p></li><li data-line=\"3050\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3049\"><p>taking False path</p></li><li data-line=\"3053\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3052\"><p>taking False path</p></li><li data-line=\"3056\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3055\"><p>taking False path</p></li><li data-line=\"3059\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3058\"><p>taking False path</p></li><li data-line=\"3062\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3061\"><p>taking False path</p></li><li data-line=\"3065\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3064\"><p>taking False path</p></li><li data-line=\"3068\"><p>when _mysql_NewException() succeeds</p></li><li data-line=\"3067\"><p>taking False path</p></li><li data-line=\"3070\"><p>when PyString_FromString() succeeds</p><p>taking False path</p></li><li data-line=\"3072\"><p>when PyDict_SetItemString() succeeds</p><p>taking False path</p></li><li data-line=\"3074\"><p>taking True path</p><p>when taking True path</p><p>taking False path</p></li><li data-line=\"3075\"><p>PyErr_Occurred()</p><p>taking False path</p></li><li data-line=\"2996\"><p>returning</p><p class=\"note\">was expecting final ob_refcnt to be N + 0 (for some unknown N)</p><p class=\"note\">but final ob_refcnt is N + 1</p><p class=\"note\">found 9 similar trace(s) to this</p></li><li data-line=\"3021\"><p class=\"note\">new ref from (unknown) PyUnicodeUCS4_FromString allocated at: \tif (PyDict_SetItemString(dict, \"__version__\",</p></li></ol></div></li></ol><footer><script src=\"http://cdnjs.cloudflare.com/ajax/libs/zepto/1.1.3/zepto.js\" type=\"text/javascript\"></script><script type=\"text/javascript\">\n/*  Copyright 2012 Buck Golemon <buck@yelp.com>\n \n    This is free software: you can redistribute it and/or modify it\n    under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n \n    This program is distributed in the hope that it will be useful, but\n    WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    General Public License for more details.\n \n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see\n    <http://www.gnu.org/licenses/>.\n*/\n$(function() {\n    \"use strict\";\n\n    var $reports = $('#reports > li');\n    $reports.each(function() {\n        var $report = $(this);\n\n        // Add line numbers to the source code, and create a mapping of line\n        // numbers to table rows\n        var $source = $report.find('.source table');\n        var first_line = parseInt($source.data('first-line'), 10);\n        var $lines = $source.find('tr');\n        var $line_index = {};\n        $lines.each(function(idx) {\n            var $line = $(this);\n            var lineno = first_line + idx;\n            $line.prepend($('<td>', { 'class': 'lineno' }).append(lineno));\n\n            $line_index[lineno] = $line;\n        });\n\n        // Figure out the state flow based on the state list: this is a list of\n        // lists of line numbers that strictly increase.  If the flow moves\n        // backwards, that starts a new subflow\n        var $states = $report.find('.states li');\n        var source_flow = [];\n        var last_line = null;\n        $states.each(function() {\n            var $state = $(this);\n            var lineno = parseInt($state.data('line'), 10);\n            var $assoc_line = $line_index[lineno];\n            $state.data('line-element', $assoc_line);\n            $state.prepend($('<h2>').text(String(lineno)));\n\n            var flow;\n            if (! last_line || last_line >= lineno) {\n                // Mark commentary that starts a new subflow (but not the\n                // first)\n                if (source_flow.length) {\n                    $state.addClass('new-subflow');\n                }\n\n                flow = [];\n                source_flow.push(flow);\n            }\n            else {\n                flow = source_flow[source_flow.length - 1];\n            }\n            flow.push({ 'lineno': lineno, '$state': $state });\n\n            last_line = lineno;\n        });\n\n        // Add the flows to the source code table.  Each subflow becomes its\n        // own column.  A line actually executed within this subflow gets a\n        // td.flow-line; otherwise it gets td.flow-empty.  If there's\n        // commentary for a particular line, the cell gets a .flow-dot child as\n        // well.\n        var started = [];\n        $.each($line_index, function(lineno, $row) {\n            var $paths = $();\n            var $selectables = $();\n            $.each(source_flow, function(idx, flow) {\n                // Lines mentioned in the flow get dots...\n                if (flow.length && flow[0].lineno == lineno) {\n                    var $new_cell = $('<td>', { \"class\": \"flow-line\" });\n                    $new_cell.append($('<span>', { \"class\": \"flow-dot\" }).html('&#x200b;'));\n                    $paths = $paths.add($new_cell);\n                    $selectables = $selectables.add($new_cell).add(flow[0].$state);\n                    started[idx] = true;\n\n                    // When hovering either the dotted cell or the associated\n                    // state commentary, highlight the dot and the comment and\n                    // the row itself\n                    var $group = $row.add(flow[0].$state).add($new_cell);\n                    $new_cell.add(flow[0].$state).on({\n                        mouseenter: function() { $group.addClass('selected'); },\n                        mouseleave: function() { $group.removeClass('selected'); }\n                    });\n\n                    flow.shift();\n                }\n                // Lines between the start and end of a subflow, or before the\n                // start of the first subflow, or after the end of the last\n                // subflow, get undotted lines\n                else if (\n                    (idx == 0 && flow.length) ||\n                    (idx == source_flow.length - 1 && ! flow.length) ||\n                    (started[idx] && flow.length)\n                ) {\n                    $paths = $paths.add($('<td>', { \"class\": \"flow-line\" }).html('&#x200b;'));\n                }\n                // Anywhere else gets nothing\n                else {\n                    $paths = $paths.add($('<td>', { \"class\": \"flow-empty\" }).html('&#x200b;'));\n                }\n            });\n            $row.prepend($paths);\n\n            // When hovering the row, highlight *all* commentary associated\n            // with that line\n            if ($selectables.length) {\n                $selectables = $selectables.add($row);\n                $row.find('td:last-child').on({\n                    mouseenter: function() { $selectables.addClass('selected') },\n                    mouseleave: function() { $selectables.removeClass('selected') }\n                });\n            }\n        });\n    });\n});\n</script></footer></body></html>\n"
  },
  {
    "path": "libcpychecker_html/html_to_lxml.py",
    "content": "#!/usr/bin/env python\n\"\"\"transform html into lxml statements\"\"\"\n\n#   Copyright 2012 Buck Golemon <buck@yelp.com>\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\ndef main():\n    \"\"\"entry point\"\"\"\n    from lxml.html import parse\n\n    from sys import argv, stdout\n\n    tree = parse(argv[1])\n    root = tree.getroot()\n\n    stack = [ (0, root) ]\n    indent = 0\n\n    def newline():\n        \"\"\"write a newline\"\"\"\n        stdout.write('\\n' + '    ' * indent)\n\n    while stack:\n        indent, node = stack.pop()\n        newline()\n\n        if isinstance(node, basestring):\n            stdout.write(node)\n            continue\n\n        try:\n            stdout.write('E.%s(' % node.tag.upper())\n        except:\n            import pudb\n            pudb.set_trace()\n            raise\n\n        indent += 1\n        children = node.getchildren()\n        attrs = node.attrib\n        if 'class' in attrs:\n            newline()\n            stdout.write('E.CLASS(%r),' % attrs.pop('class'))\n\n        if attrs:\n            newline()\n            if children or node.text:\n                stdout.write('E.ATTR(')\n            if any('-' in attr for attr in attrs):\n                stdout.write('{')\n                stdout.write(\n                        ', '.join('%r: %r' % attr for attr in attrs.items())\n                )\n                stdout.write('}')\n            else:\n                stdout.write(\n                        ', '.join('%s=%r' % attr for attr in attrs.items())\n                )\n            if children or node.text:\n                stdout.write(')')\n            stdout.write(',')\n\n        if node.text:\n            newline()\n            stdout.write(repr(node.text))\n            stdout.write(',')\n\n        stack.append((indent-1, '),'))\n        for child in reversed(children):\n            if child.tail:\n                stack.append((indent, repr(child.tail) + ','))\n            stack.append((indent, child))\n\nmain()\n"
  },
  {
    "path": "libcpychecker_html/json.rst",
    "content": "Notes on JSON serialization of error reports\n============================================\n\nAt the top level::\n\n   {\n       # Path to the source file being analyzed:\n       \"filename\": \"libcpychecker_html/test/example1/bug.c\", \n\n       # The particular function containing the error:\n       \"function\": {\n           # The range of lines within the above file:\n           \"lines\": [\n               6, \n               22\n           ], \n           # Name of the function:\n           \"name\": \"make_a_list_of_random_ints_badly\"\n       }, \n\n       # List of error reports within the function:\n       \"reports\": []\n   }\n\nWithin an individual report::\n\n        # This is an individual report\n        {\n            # Description of the problem:\n            \"message\": \"ob_refcnt of '*item' is 1 too high\", \n\n            # Severity of the problem: warning vs error\n            \"severity\": \"warning\", \n\n            # List of states\n            \"states\": []\n\n            # List of notes\n            \"notes\": []\n        }\n\nLocations within the source code are expressed as ranges i.e. a pair of\nvalues::\n\n                    \"location\": [\n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }, \n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }\n                    ], \n\nwhere both column and line are 1-based.  However, in the current implementation\nthey are all just points (i.e. both start and end are always equal).  (Fixing\nthis would be difficult, but not impossible, I think).\n\n\nNotes convey high-level information about the message::\n\n                {\n                    \"location\": [\n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }, \n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }\n                    ], \n                    \"message\": \"was expecting final ob_refcnt to be N + 1 (for some unknown N)\"\n                }\n\nNotes are arguably not well-designed, and it's something of a misfeature that\nstates and notes are separate.\n\n\nThe list of states is ordered, representing the sequence of states of a path\nthrough the function that demonstrates the bug.\n\nExample of a state::\n\n                {\n                    # Where are we within the source code?\n                    \"location\": [\n                        {\n                            \"column\": 10, \n                            \"line\": 14\n                        }, \n                        {\n                            \"column\": 10, \n                            \"line\": 14\n                        }\n                    ],\n\n                    # A descriptive message of what happens immediately after\n                    # this state (possibly empty or null if this transition is\n                    # unremarkable):\n                    \"message\": \"when PyList_New() succeeds\", \n\n\n                    # Variables and their values at this point within the\n                    # program's execution\n                    \"variables\": {}\n                 }\n\nAnother example of a state::\n\n                {\n                    # Where are we within the source code?\n                    # Ideally all locations will be non-null, but GCC can make\n                    # this difficult\n                    \"location\": null, \n\n                    # A descriptive message of what happens immediately after\n                    # this state (possibly empty or null if this transition is\n                    # unremarkable):\n                    \"message\": \"\",\n\n                    # Variables and their values at this point within the\n                    # program's execution\n                    \"variables\": {}\n                }\n\n\nVariables within a states \"variables\" dict::\n\n                        # The name of the variable, or an expression:\n                        \"count\": {\n                            # The underlying C type:\n                            \"gcctype\": \"int\", \n\n                            # The internal type of the value as seen by the\n                            # analyzer:\n                            \"kind\": \"WithinRange\", \n\n                            # For a \"WithinRange\", the range of possible\n                            # values:\n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n\n                            # Where did this value come from?\n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n\nSome other kinds of value:\n\n  * \"kind\": \"UninitializedData\"\n\n    This value hasn't been written to yet: accessing\n    this would be a bug\n\n\n  * \"kind\": \"RefcountValue\"\n\n     Example data::\n\n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n\n     Fields:\n\n        * \"actual_ob_refcnt\"\n        \n           the actual value of the ob_refcnt field, split into the references\n           that the function owns (\"refs_we_own\"), plus a\n           \"lower_bound_of_other_refs\" which can probably be ignored (it exists\n           so that we can prove that some Py_DECREF(obj) invocations\n           don't deallocate the object: even though the function might not own\n           any refs on obj, other things might)\n\n           \"refs_we_own\" is of most interest to the user::\n\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n\n        * \"expected_ob_refcnt\"\n\n           information on what the ob_refcnt field *ought* to be.\n\n           Contains a single field, \"pointers_to_this\", which is a list of all\n           pointers to the object::\n\n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n\n           In theory, \"refs_we_own\" ought to equal the\n           length of this list: the user is interested in when they're\n           non-equal\n\n  * \"kind\": \"ConcreteValue\"\n\n     A specific known value (either integer or float)::\n\n        \"value\": 0, \n\n  * \"kind\": \"WithinRange\", \n\n     A integer value within a specifc range::\n\n        \"maxvalue\": 2147483647, \n        \"minvalue\": 1, \n\n     For large values it may make sense to print these in hexadecimal form\n     (e.g. \"0x7fffffff\" rather than \"2147483647\")\n\n  * \"kind\": \"PointerToRegion\", \n    \n    A non-NULL pointer.  The target field describes what it's pointing at::\n\n       \"target\": \"PyListObject\", \n\n  * \"kind\": \"GenericTpDealloc\", \n\n    FWIW, this is a destructor callback for deallocating a PyObject*: the\n    analyzer knows that if this callback is called, the object will be\n    deallocated\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "libcpychecker_html/make_html.py",
    "content": "#!/usr/bin/env python\n\"\"\"Make our data into HTML!\nThese reports should be usable as email attachments, offline.\nThis means we need to embed *all* our assets.\n\nWe make an exception for zepto; it's (relatively) big, and the behaviors\nit adds are non-essential to reading the report.\n\"\"\"\nfrom __future__ import print_function\nfrom __future__ import unicode_literals\n\n#   Copyright 2012 Buck Golemon <buck@yelp.com>\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\nfrom os.path import realpath, dirname, join\nHERE = dirname(realpath(__file__))\n\nfrom . import capi\n\nfrom lxml.html import (\n    tostring, fragment_fromstring as parse, builder as E\n)\n\nfrom pygments import highlight\nfrom pygments.lexers.compiled import CLexer\nfrom pygments.formatters.html import HtmlFormatter\n\nimport base64\nfrom copy import deepcopy\nfrom itertools import islice\n\n\ndef open(filename, mode='r'):  # pylint:disable=redefined-builtin\n    \"\"\"All files are treated as UTF-8, unless explicitly binary.\"\"\"\n    import io\n    if 'b' in mode:\n        return io.open(filename, mode)\n    else:\n        return io.open(filename, mode, encoding='UTF-8')\n\n\nclass HtmlPage(object):\n    \"\"\"Represent one html page.\"\"\"\n    def __init__(self, codefile, data):\n        self.codefile = codefile\n        self.data = data\n\n    def __str__(self):\n        html = tostring(self.__html__())\n        return '<!DOCTYPE html>\\n' + html.decode('utf-8')\n\n    def __html__(self):\n        return E.HTML(self.head(), self.body())\n\n    def head(self):\n        \"\"\"The HEAD of the html document\"\"\"\n        head = E.HEAD(\n            E.META({\n                'http-equiv': 'Content-Type',\n                'content': 'text/html; charset=utf-8'\n            }),\n            E.TITLE('%s -- GCC Python Plugin' % self.data['filename']),\n        )\n        head.extend(\n            E.STYLE(\n                file_contents(css + '.css'),\n                media='screen',\n                type='text/css'\n            )\n            for css in ('extlib/reset-20110126.min', 'pygments_c', 'style')\n        )\n        return head\n\n    def raw_code(self):\n        \"\"\"Get the correct lines from the code file\"\"\"\n        first, last = self.data['function']['lines']\n        # Line numbers are ONE-based\n        return ''.join(islice(self.codefile, first - 1, last))\n\n    def code(self):\n        \"\"\"generate the contents of the #code section\"\"\"\n        # Get ready to use Pygments:\n        formatter = CodeHtmlFormatter(\n            style='default',\n            cssclass='source',\n            linenostart=self.data['function']['lines'][0],\n        )\n\n        # <link rel=\"stylesheet\", href=\"pygments_c.css\", type=\"text/css\">\n        open('pygments_c.css', 'w').write(formatter.get_style_defs())\n\n        # Use pygments to convert it all to HTML:\n        code = parse(highlight(self.raw_code(), CLexer(), formatter))\n\n        # linkify the python C-API functions\n        for name in code.xpath('//span[@class=\"n\"]'):\n            url = capi.get_url(name.text)\n            if url is not None:\n                link = E.A(name.text, href=url)\n                name.text = None\n                name.append(link)\n\n        return code\n\n    def header(self):\n        \"\"\"Make the header bar of the webpage\"\"\"\n\n        return E.E.header(\n            E.ATTR(id='header'),\n            E.DIV(\n                E.ATTR(id='title'),\n                E.H1(\n                    E.A(\n                        'GCC Python Plugin',\n                        href='http://gcc-python-plugin.readthedocs.org/',\n                    ),\n                ),\n                E.DIV(\n                    E.ATTR(id='info'),\n                    E.SPAN(\n                        E.CLASS('label'),\n                        'Filename: ',\n                    ),\n                    self.data['filename'],\n                    E.SPAN(\n                        E.CLASS('label'),\n                        'Function: ',\n                    ),\n                    self.data['function']['name'],\n                ),\n                E.DIV(\n                    E.ATTR(id='report-pagination'),\n                    E.SPAN(\n                        E.CLASS('label'),\n                        'Report: ',\n                    ),\n                    *(\n                        E.A(str(i + 1), href=\"#state{0}\".format(i + 1))\n                        for i in range(len(self.data['reports']))\n                    )\n                ),\n                E.DIV(\n                    E.ATTR(id='prev'),\n                    E.IMG(\n                        src=data_uri('image/png', 'images/arrow-180.png'),\n                    ),\n                ),\n                E.DIV(\n                    E.ATTR(id='next'),\n                    E.IMG(\n                        src=data_uri('image/png', 'images/arrow.png'),\n                    ),\n                ),\n            ),\n        )\n\n    @staticmethod\n    def footer():\n        \"\"\"put non-essential javascript in the footer\"\"\"\n        return E.E.footer(\n            # zepto is the one resource we don't embed.\n            # It's (relatively) big, and non-essential.\n            E.SCRIPT(\n                src=(\n                    'http://cdnjs.cloudflare.com'\n                    '/ajax/libs/zepto/1.1.3/zepto.js'\n                ),\n                type='text/javascript',\n            ),\n            E.SCRIPT(\n                file_contents('script.js'),\n                type='text/javascript',\n            ),\n        )\n\n    def states(self):\n        \"\"\"Return an ordered-list of states, for each report.\"\"\"\n        for report in self.data['reports']:\n            annotations = E.OL({'class': 'states'})\n\n            prevline = None\n            lineno_to_index = {}\n            index = -1\n            for state in report['states']:\n                if not state['location'] or not state['message']:\n                    continue\n\n                line = state['location'][0]['line']\n                state = E.P(state['message'])\n\n                # We try to combine with the previous state.\n                if line != prevline:\n                    child = E.LI({'data-line': str(line)})\n                    annotations.append(child)\n                    index += 1\n\n                child.append(state)\n\n                lineno_to_index[line] = (index, child)\n                prevline = line\n\n            for note in report['notes']:\n                line = note['location'][0]['line']\n                note = E.P({'class': 'note'}, note['message'])\n\n                # Put this note on the last matching state, if possible\n                for ann in reversed(tuple(annotations)):\n                    annline = int(ann.attrib['data-line'])\n                    if line == annline:\n                        ann.append(note)\n                        break\n                    elif line > annline:\n                        ann.addnext(\n                            E.LI({'data-line': str(line)}, note)\n                        )\n                        break\n                else:\n                    annotations.insert(0, E.LI({'data-line': str(line)}, note))\n\n            yield annotations, report['message']\n\n    def body(self):\n        \"\"\"The BODY of the html document\"\"\"\n        reports = E.OL(id='reports')\n        code = self.code()\n\n        for i, (state_html, state_problem) in enumerate(self.states(), 1):\n            reports.append(\n                E.LI(\n                    E.ATTR(id=\"state{0}\".format(i)),\n                    E.E.header(\n                        E.DIV(\n                            E.CLASS('error'),\n                            state_problem,\n                        ),\n                        E.DIV(\n                            E.CLASS('report-count'),\n                            E.H3('Report'),\n                            str(i),\n                        ),\n                    ),\n                    E.DIV(\n                        E.CLASS('body'),\n                        E.DIV(\n                            E.CLASS('source'),\n                            deepcopy(code),\n                        ),\n                        state_html,\n                    ),\n                ),\n            )\n\n        return E.BODY(\n            self.header(),\n            reports,\n            self.footer(),\n        )\n\n\ndef data_uri(mimetype, filename):\n    \"\"\"represent a file as a data uri\"\"\"\n    data = open(join(HERE, filename), 'rb').read()\n    data = base64.encodestring(data)\n    data = data.replace(b'\\n', b'')\n    return 'data:%s;base64,%s' % (mimetype, data.decode('ascii'))\n\n\ndef file_contents(filename):\n    \"\"\"Add a leading newline to make the first line show up in the right spot.\n    \"\"\"\n    return '\\n' + open(join(HERE, filename)).read()\n\n\nclass CodeHtmlFormatter(HtmlFormatter):\n    \"\"\"Format our HTML!\"\"\"\n\n    def wrap(self, source, outfile):\n        yield 0, '<table data-first-line=\"%s\">' % (\n            self.linenostart,\n        )\n        for i, line in source:\n            if i == 1:\n                # it's a line of formatted code\n                yield 0, '<tr><td class=\"code\">'\n                yield i, line\n                yield 0, '</td></tr>'\n            else:\n                yield i, line\n        yield 0, '</table>'\n\n\ndef main(argv):\n    \"\"\"our entry point\"\"\"\n    if len(argv) < 3:\n        return \"Please provide code and json filenames.\"\n\n    from json import load\n    codefile = open(argv[1])\n    data = load(open(argv[2]))\n    print(HtmlPage(codefile, data))\n\nif __name__ == '__main__':\n    from sys import argv as ARGV\n    exit(main(ARGV))\n"
  },
  {
    "path": "libcpychecker_html/script.js",
    "content": "/*  Copyright 2012 Buck Golemon <buck@yelp.com>\n \n    This is free software: you can redistribute it and/or modify it\n    under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n \n    This program is distributed in the hope that it will be useful, but\n    WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    General Public License for more details.\n \n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see\n    <http://www.gnu.org/licenses/>.\n*/\n$(function() {\n    \"use strict\";\n\n    var $reports = $('#reports > li');\n    $reports.each(function() {\n        var $report = $(this);\n\n        // Add line numbers to the source code, and create a mapping of line\n        // numbers to table rows\n        var $source = $report.find('.source table');\n        var first_line = parseInt($source.data('first-line'), 10);\n        var $lines = $source.find('tr');\n        var $line_index = {};\n        $lines.each(function(idx) {\n            var $line = $(this);\n            var lineno = first_line + idx;\n            $line.prepend($('<td>', { 'class': 'lineno' }).append(lineno));\n\n            $line_index[lineno] = $line;\n        });\n\n        // Figure out the state flow based on the state list: this is a list of\n        // lists of line numbers that strictly increase.  If the flow moves\n        // backwards, that starts a new subflow\n        var $states = $report.find('.states li');\n        var source_flow = [];\n        var last_line = null;\n        $states.each(function() {\n            var $state = $(this);\n            var lineno = parseInt($state.data('line'), 10);\n            var $assoc_line = $line_index[lineno];\n            $state.data('line-element', $assoc_line);\n            $state.prepend($('<h2>').text(String(lineno)));\n\n            var flow;\n            if (! last_line || last_line >= lineno) {\n                // Mark commentary that starts a new subflow (but not the\n                // first)\n                if (source_flow.length) {\n                    $state.addClass('new-subflow');\n                }\n\n                flow = [];\n                source_flow.push(flow);\n            }\n            else {\n                flow = source_flow[source_flow.length - 1];\n            }\n            flow.push({ 'lineno': lineno, '$state': $state });\n\n            last_line = lineno;\n        });\n\n        // Add the flows to the source code table.  Each subflow becomes its\n        // own column.  A line actually executed within this subflow gets a\n        // td.flow-line; otherwise it gets td.flow-empty.  If there's\n        // commentary for a particular line, the cell gets a .flow-dot child as\n        // well.\n        var started = [];\n        $.each($line_index, function(lineno, $row) {\n            var $paths = $();\n            var $selectables = $();\n            $.each(source_flow, function(idx, flow) {\n                // Lines mentioned in the flow get dots...\n                if (flow.length && flow[0].lineno == lineno) {\n                    var $new_cell = $('<td>', { \"class\": \"flow-line\" });\n                    $new_cell.append($('<span>', { \"class\": \"flow-dot\" }).html('&#x200b;'));\n                    $paths = $paths.add($new_cell);\n                    $selectables = $selectables.add($new_cell).add(flow[0].$state);\n                    started[idx] = true;\n\n                    // When hovering either the dotted cell or the associated\n                    // state commentary, highlight the dot and the comment and\n                    // the row itself\n                    var $group = $row.add(flow[0].$state).add($new_cell);\n                    $new_cell.add(flow[0].$state).on({\n                        mouseenter: function() { $group.addClass('selected'); },\n                        mouseleave: function() { $group.removeClass('selected'); }\n                    });\n\n                    flow.shift();\n                }\n                // Lines between the start and end of a subflow, or before the\n                // start of the first subflow, or after the end of the last\n                // subflow, get undotted lines\n                else if (\n                    (idx == 0 && flow.length) ||\n                    (idx == source_flow.length - 1 && ! flow.length) ||\n                    (started[idx] && flow.length)\n                ) {\n                    $paths = $paths.add($('<td>', { \"class\": \"flow-line\" }).html('&#x200b;'));\n                }\n                // Anywhere else gets nothing\n                else {\n                    $paths = $paths.add($('<td>', { \"class\": \"flow-empty\" }).html('&#x200b;'));\n                }\n            });\n            $row.prepend($paths);\n\n            // When hovering the row, highlight *all* commentary associated\n            // with that line\n            if ($selectables.length) {\n                $selectables = $selectables.add($row);\n                $row.find('td:last-child').on({\n                    mouseenter: function() { $selectables.addClass('selected') },\n                    mouseleave: function() { $selectables.removeClass('selected') }\n                });\n            }\n        });\n    });\n});\n"
  },
  {
    "path": "libcpychecker_html/style-noprefix.css",
    "content": "/*  Copyright 2012 Buck Golemon <buck@yelp.com>\n *  with help from http://jsfiddle.net/simevidas/udyTs/show/light/\n \n    This is free software: you can redistribute it and/or modify it\n    under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n \n    This program is distributed in the hope that it will be useful, but\n    WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    General Public License for more details.\n \n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see\n    <http://www.gnu.org/licenses/>.\n*/\nhtml, body {\n    width: 100%;\n    background: black;\n}\nhtml {\n    height: 100%;\n}\nbody {\n    font: 12px \"DejaVu Sans\", \"Bitstream Vera Sans\", \"Ubuntu Sans\", Helvetica, Arial, sans-serif;\n    color: black;\n    background: #EBEBEB;\n    height: 100%;\n\n    display: flex;\n    flex-direction: column;\n}\nh1, h2 {\n    font-weight: bolder;\n}\nh1 a {\n    text-decoration: none;\n    color: inherit;\n}\nh3 {\n    display: inline-block;\n    font-weight: bold;\n    margin-right: 0.33em;\n}\nh3:after {\n    content: ':';\n}\nhr {\n    border-bottom: 1px solid #CCC; width: 640px;\n}\nimg {\n    vertical-align: middle;\n}\n\n\n/* Main page layout */\n#header {\n    background-color: #0099ff;\n}\n#reports {\n    flex: 1;\n    overflow-y: auto;\n    overflow-x: hidden;\n}\n\n\n/* Header */\n#title {\n    display:flex;\n    flex-direction: row;\n    align-items: center;\n    padding: 0.5em 1em;\n    box-sizing: border-box;\n    color: white;\n    border-bottom: 1px solid #7A7A7A;\n    box-shadow: 0px 0px 2px #000;\n}\n#title h1 {\n    font-size: 1.2em;\n    text-shadow: 0 1px 1px black;\n}\n#title #info {\n    flex: 1;\n    align-items: flex-end;\n    text-shadow: 0 1px 0 black;\n}\n\n/* Navigation */\n#nav {\n    display: flex;\n    flex-direction: row;\n    align-items: center;\n    padding: 0.5em 1em;\n    box-sizing: border-box;\n    background-color: #E4E4E4;\n    border-bottom: 1px solid #7A7A7A;\n    box-shadow: 0px 0px 2px #000;\n}\n#report-pagination a {\n    padding: 4px;\n}\n#prev,\n#next {\n    padding: 0.25em 1em;\n    background-color: white;\n    border: 1px solid #ccc;\n    margin-left: 1em;\n}\n\n\n#header-container {\n    border-bottom:1px solid #7A7A7A;\n}\n\n#header ul {\n    margin: 0;\n    padding: 0;\n    list-style: none;\n    position: absolute;\n    top: 35px;\n    right: 0;\n}\n\n#header ul li {\n    float: left;\n    margin-right: 5px;\n}\n\n#header ul li a{\n    color: #90b874;\n    font-weight: bold;\n    font-size: 1.4em;\n    margin-right: 5px;\n    text-decoration: none;\n}\n\n#header ul li a:hover {\n    color: #beffbf;\n}\n\n\n\n\n\n#reports > li {\n    display: flex;\n    flex-direction: column;\n    width: 100%;\n}\n#reports > li + li {\n    border-top: 1px dashed hsl(0, 0%, 70%);\n}\n#reports > li header {\n    display: flex;\n    flex-direction: row;\n    padding: .5em;\n    background: white;\n}\n#reports > li header .error {\n    flex: 1;\n    color: darkred;\n    font-weight: bold;\n    text-align: center;\n}\n#reports > li .body {\n    display: flex;\n    flex-direction: row;\n}\n\n\n\n.label {\n    font-size: 12px;\n    font-weight:bolder;\n    margin-left: 2em;\n}\n\n#main {\n    background: red;\n    display: flex;\n}\n\n\n.source {\n    height: 100%;\n    font-size: 12px;\n    background: white;\n    line-height: 1.33;\n    overflow-x: auto;\n    border-right: 1px solid hsl(0, 0%, 70%);\n    flex: 1 0 40em;\n}\n.source table {\n    width: 100%;\n    font-family: monospace;\n}\n\n#code {\n    background: blue;\n    min-width: 300px;\n    flex: 2;\n}\n.source tr:nth-child(2n) {\n    background: hsl(0, 0%, 93%);\n}\n\n#container {\n    width: 1000px;\n    margin: 0 auto;\n    font-size:12px;\n    overflow: auto;\n    padding: 70px 0 0px;\n    background-color:#f8f8f8;\n}\n\n#content {\n    float: left;\n    width: 660px;\n    padding-top:20px;\n    padding-left:20px;\n    padding-right:10px;\n}\n\n#content .source td {\n    font-family: monospace;\n    white-space: pre;\n    min-height: 1em;\n    line-height: 20px;\n}\n\n\n.fnc-report {\n    font-size:12px;\n}\n\n#error-box {\n    font-size:12px;\n    font-color:000;\n    float:left;\n}\n\n#report-count{\n    font-size:12px;\n    float:right;\n}\n\n/* Left column: source code */\n.source tr:hover {\n    background: hsl(210, 30%, 87%);\n}\n.source .lineno {\n    padding-right: 0.5em;\n    text-align: right;\n    user-select: none;\n    color: hsl(0, 0%, 60%);\n    vertical-align: middle;\n}\n.source .code {\n    white-space: pre;\n}\n\n\n/* Right column: list of states */\n.states {\n    font-size: 12px;\n    top: 0.5em;\n    height: 100%;\n    min-width: 25em;\n    border-left: 1px solid hsl(0, 0%, 70%);\n    border-top: 2px solid #B2B2B2\n}\n.states li {\n    position: relative;\n    padding: 0.5em;\n    margin: 1em;\n    background: white;\n    border: 1px solid hsl(0, 0%, 80%);\n}\n.states li.new-subflow {\n    border-top-width: 4px;\n}\n.states h2 {\n    float: right;\n    padding: 0.33em 0.5em;\n    margin: -0.5em -0.5em 0.5em 0.5em;\n    background: hsl(0, 0%, 80%);\n    color: hsl(0, 0%, 30%);\n    border-radius: 0 0 0 0.5em;\n}\n.states p {\n    line-height: 1.5;\n}\n.states p + p {\n    margin-top: 0.5em;\n}\n\nvar {\n    color: navy;\n}\nvar.leak {\n    color: darkred;\n    font-weight: bold;\n    background: hsl(0, 100%, 90%);\n}\n\n.flow-line {\n    background: hsl(210, 80%, 60%);\n    background-clip: content-box;\n    width: 2px;\n}\n.flow-empty, .flow-line {\n    padding: 0 5px;\n    text-align: center;\n}\n.flow-dot {\n    display: inline-block;\n    background: hsl(210, 80%, 60%);\n    outline: 1px solid rgba(100%, 100%, 100%, 0.5);\n    height: 6px;\n    width: 6px;\n    margin: -2px;\n    border-radius: 100px;\n    outline-radius: 100px;\n    vertical-align: middle;\n}\n\n/* Selection overrides */\n.states li {\n    left: 0;\n    transition-property: left, background-color, border-color;\n}\n.source tr\n.states li h2 {\n    transition-property: background-color;\n}\ntd .flow-dot,\n.states li,\n.states li h2 {\n    transition-duration: 0.25s;\n    transition-timing-function: ease-out;\n}\n\ntd:hover .flow-dot,\ntd.selected .flow-dot {\n    height: 10px;\n    width: 10px;\n    background: hsl(30, 80%, 60%);\n    margin: -5px;\n}\n\n.source tr:hover,\n.source tr.selected {\n    background-color: #ffe181;\n}\n.states li:hover,\n.states li.selected {\n    left: -2em;\n    background-color: #fef8cb;\n    border-color: #ffe181;\n}\n.states li:hover h2,\n.states li.selected h2 {\n    background-color: #ffe181;\n}\n\n#notes {\n    background: yellow;\n    min-width: 200px;\n}\n\n.note {\n    font-weight: bolder;\n}\n.note:first-of-type::before {\n    /* content: url('images/exclamation.png');\n     * to regenerate:\n     *      from libcpychecker_html.make_html import data_uri\n     *      data_uri('image/png', 'images/exclamation.png')\n     */\n    content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjBJREFUeNqkk0trE1EUx8/cO49OfGTSRNJMYsA0aVonoYh13YW71uJCKFQhKqibfgFLwYULsR/AhY+VG1d+C124kJiFIGipmoIZNUXtZDKTycz1njGpaRNU8MJv7txzzv/c5xEYY/A/TRQEAW5c5KwM+aKcR73/a5zvg84HT371wv07Apwuj0x+PZW/vArA4NO7x/f4+OGoIHLKAAiC/fBdHadSbCGZPTeTzC7OUElbQNvBOISMMnIqeqFSYs57mTkfZD1/qYS2f0rAZ5pVDmXnY/FSbn3jM6xvfAEtfjKnRDLz6BtK4PPPADi+ms6vGK71lti2DUintUVSJ84b6OvF7GlI4PNMPVgAZ49oxpyqRnXf+wGWZYX4ngWRiKYfPpqfw5hBjej7eweqCkSo6JOLhmd/hI7vQLVaBdM0YXt1FgK2CeJ40fCbmxUWsGc8vh3egtcFQPhyLsQnzpQJcbVmuw5mawtqtRo0Gg3wJQeY7ALIrqZEM2WM7esIPkROAgR5OZEpTTV3X4IXNEGiLnw1b4fItBNCBQuiqeQUA7qMGtSSLt8C38aVRLo47QVvVJFYoFAnJJG8FdIfI6rSVWMTx6ZRg1rS7UKeSspSMj2Wk+AbjPGZ+vTboA1JZbQcEcUl1Iq2zdZyxURBpruUMTzR38Vl79wM+9bO0/3vlwLVs+OF16/MNdFug/vi+Xadm+vDL/3uHyuR16Er4E3gKvEaOTLa/1LBuEQPF8hxfgowAINnMqTBUH7hAAAAAElFTkSuQmCC');\n    padding: 5px;\n}\n"
  },
  {
    "path": "libcpychecker_html/style.css",
    "content": "/*  Copyright 2012 Buck Golemon <buck@yelp.com>\n *  with help from http://jsfiddle.net/simevidas/udyTs/show/light/\n \n    This is free software: you can redistribute it and/or modify it\n    under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n \n    This program is distributed in the hope that it will be useful, but\n    WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n    General Public License for more details.\n \n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see\n    <http://www.gnu.org/licenses/>.\n*/\nhtml, body {\n    width: 100%;\n    background: black;\n}\nhtml {\n    height: 100%;\n}\nbody {\n    font: 12px \"DejaVu Sans\", \"Bitstream Vera Sans\", \"Ubuntu Sans\", Helvetica, Arial, sans-serif;\n    color: black;\n    background: #EBEBEB;\n    height: 100%;\n\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: vertical;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: column;\n    -ms-flex-direction: column;\n    flex-direction: column;\n}\nh1, h2 {\n    font-weight: bolder;\n}\nh1 a {\n    text-decoration: none;\n    color: inherit;\n}\nh3 {\n    display: inline-block;\n    font-weight: bold;\n    margin-right: 0.33em;\n}\nh3:after {\n    content: ':';\n}\nhr {\n    border-bottom: 1px solid #CCC; width: 640px;\n}\nimg {\n    vertical-align: middle;\n}\n\n\n/* Main page layout */\n#header {\n    background-color: #0099ff;\n}\n#reports {\n    -webkit-box-flex: 1;\n    -webkit-flex: 1;\n    -ms-flex: 1;\n    flex: 1;\n    overflow-y: auto;\n    overflow-x: hidden;\n}\n\n\n/* Header */\n#title {\n    display:-webkit-box;\n    display:-webkit-flex;\n    display:-ms-flexbox;\n    display:flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n    -webkit-box-align: center;\n    -webkit-align-items: center;\n    -ms-flex-align: center;\n    align-items: center;\n    padding: 0.5em 1em;\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n    color: white;\n    border-bottom: 1px solid #7A7A7A;\n    -webkit-box-shadow: 0px 0px 2px #000;\n    box-shadow: 0px 0px 2px #000;\n}\n#title h1 {\n    font-size: 1.2em;\n    text-shadow: 0 1px 1px black;\n}\n#title #info {\n    -webkit-box-flex: 1;\n    -webkit-flex: 1;\n    -ms-flex: 1;\n    flex: 1;\n    -webkit-box-align: end;\n    -webkit-align-items: flex-end;\n    -ms-flex-align: end;\n    align-items: flex-end;\n    text-shadow: 0 1px 0 black;\n}\n\n/* Navigation */\n#nav {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n    -webkit-box-align: center;\n    -webkit-align-items: center;\n    -ms-flex-align: center;\n    align-items: center;\n    padding: 0.5em 1em;\n    -webkit-box-sizing: border-box;\n    -moz-box-sizing: border-box;\n    box-sizing: border-box;\n    background-color: #E4E4E4;\n    border-bottom: 1px solid #7A7A7A;\n    -webkit-box-shadow: 0px 0px 2px #000;\n    box-shadow: 0px 0px 2px #000;\n}\n#report-pagination a {\n    padding: 4px;\n}\n#prev,\n#next {\n    padding: 0.25em 1em;\n    background-color: white;\n    border: 1px solid #ccc;\n    margin-left: 1em;\n}\n\n\n#header-container {\n    border-bottom:1px solid #7A7A7A;\n}\n\n#header ul {\n    margin: 0;\n    padding: 0;\n    list-style: none;\n    position: absolute;\n    top: 35px;\n    right: 0;\n}\n\n#header ul li {\n    float: left;\n    margin-right: 5px;\n}\n\n#header ul li a{\n    color: #90b874;\n    font-weight: bold;\n    font-size: 1.4em;\n    margin-right: 5px;\n    text-decoration: none;\n}\n\n#header ul li a:hover {\n    color: #beffbf;\n}\n\n\n\n\n\n#reports > li {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: vertical;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: column;\n    -ms-flex-direction: column;\n    flex-direction: column;\n    width: 100%;\n}\n#reports > li + li {\n    border-top: 1px dashed hsl(0, 0%, 70%);\n}\n#reports > li header {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n    padding: .5em;\n    background: white;\n}\n#reports > li header .error {\n    -webkit-box-flex: 1;\n    -webkit-flex: 1;\n    -ms-flex: 1;\n    flex: 1;\n    color: darkred;\n    font-weight: bold;\n    text-align: center;\n}\n#reports > li .body {\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n    -webkit-box-orient: horizontal;\n    -webkit-box-direction: normal;\n    -webkit-flex-direction: row;\n    -ms-flex-direction: row;\n    flex-direction: row;\n}\n\n\n\n.label {\n    font-size: 12px;\n    font-weight:bolder;\n    margin-left: 2em;\n}\n\n#main {\n    background: red;\n    display: -webkit-box;\n    display: -webkit-flex;\n    display: -ms-flexbox;\n    display: flex;\n}\n\n\n.source {\n    height: 100%;\n    font-size: 12px;\n    background: white;\n    line-height: 1.33;\n    overflow-x: auto;\n    border-right: 1px solid hsl(0, 0%, 70%);\n    -webkit-box-flex: 1;\n    -webkit-flex: 1 0 40em;\n    -ms-flex: 1 0 40em;\n    flex: 1 0 40em;\n}\n.source table {\n    width: 100%;\n    font-family: monospace;\n}\n\n#code {\n    background: blue;\n    min-width: 300px;\n    -webkit-box-flex: 2;\n    -webkit-flex: 2;\n    -ms-flex: 2;\n    flex: 2;\n}\n.source tr:nth-child(2n) {\n    background: hsl(0, 0%, 93%);\n}\n\n#container {\n    width: 1000px;\n    margin: 0 auto;\n    font-size:12px;\n    overflow: auto;\n    padding: 70px 0 0px;\n    background-color:#f8f8f8;\n}\n\n#content {\n    float: left;\n    width: 660px;\n    padding-top:20px;\n    padding-left:20px;\n    padding-right:10px;\n}\n\n#content .source td {\n    font-family: monospace;\n    white-space: pre;\n    min-height: 1em;\n    line-height: 20px;\n}\n\n\n.fnc-report {\n    font-size:12px;\n}\n\n#error-box {\n    font-size:12px;\n    font-color:000;\n    float:left;\n}\n\n#report-count{\n    font-size:12px;\n    float:right;\n}\n\n/* Left column: source code */\n.source tr:hover {\n    background: hsl(210, 30%, 87%);\n}\n.source .lineno {\n    padding-right: 0.5em;\n    text-align: right;\n    -webkit-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    color: hsl(0, 0%, 60%);\n    vertical-align: middle;\n}\n.source .code {\n    white-space: pre;\n}\n\n\n/* Right column: list of states */\n.states {\n    font-size: 12px;\n    top: 0.5em;\n    height: 100%;\n    min-width: 25em;\n    border-left: 1px solid hsl(0, 0%, 70%);\n    border-top: 2px solid #B2B2B2\n}\n.states li {\n    position: relative;\n    padding: 0.5em;\n    margin: 1em;\n    background: white;\n    border: 1px solid hsl(0, 0%, 80%);\n}\n.states li.new-subflow {\n    border-top-width: 4px;\n}\n.states h2 {\n    float: right;\n    padding: 0.33em 0.5em;\n    margin: -0.5em -0.5em 0.5em 0.5em;\n    background: hsl(0, 0%, 80%);\n    color: hsl(0, 0%, 30%);\n    border-radius: 0 0 0 0.5em;\n}\n.states p {\n    line-height: 1.5;\n}\n.states p + p {\n    margin-top: 0.5em;\n}\n\nvar {\n    color: navy;\n}\nvar.leak {\n    color: darkred;\n    font-weight: bold;\n    background: hsl(0, 100%, 90%);\n}\n\n.flow-line {\n    background: hsl(210, 80%, 60%);\n    -webkit-background-clip: content-box;\n    background-clip: content-box;\n    width: 2px;\n}\n.flow-empty, .flow-line {\n    padding: 0 5px;\n    text-align: center;\n}\n.flow-dot {\n    display: inline-block;\n    background: hsl(210, 80%, 60%);\n    outline: 1px solid rgba(100%, 100%, 100%, 0.5);\n    height: 6px;\n    width: 6px;\n    margin: -2px;\n    border-radius: 100px;\n    outline-radius: 100px;\n    vertical-align: middle;\n}\n\n/* Selection overrides */\n.states li {\n    left: 0;\n    -webkit-transition-property: left, background-color, border-color;\n    transition-property: left, background-color, border-color;\n}\n.source tr\n.states li h2 {\n    -webkit-transition-property: background-color;\n    transition-property: background-color;\n}\ntd .flow-dot,\n.states li,\n.states li h2 {\n    -webkit-transition-duration: 0.25s;\n    transition-duration: 0.25s;\n    -webkit-transition-timing-function: ease-out;\n    transition-timing-function: ease-out;\n}\n\ntd:hover .flow-dot,\ntd.selected .flow-dot {\n    height: 10px;\n    width: 10px;\n    background: hsl(30, 80%, 60%);\n    margin: -5px;\n}\n\n.source tr:hover,\n.source tr.selected {\n    background-color: #ffe181;\n}\n.states li:hover,\n.states li.selected {\n    left: -2em;\n    background-color: #fef8cb;\n    border-color: #ffe181;\n}\n.states li:hover h2,\n.states li.selected h2 {\n    background-color: #ffe181;\n}\n\n#notes {\n    background: yellow;\n    min-width: 200px;\n}\n\n.note {\n    font-weight: bolder;\n}\n.note:first-of-type::before {\n    /* content: url('images/exclamation.png');\n     * to regenerate:\n     *      from libcpychecker_html.make_html import data_uri\n     *      data_uri('image/png', 'images/exclamation.png')\n     */\n    content: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAjBJREFUeNqkk0trE1EUx8/cO49OfGTSRNJMYsA0aVonoYh13YW71uJCKFQhKqibfgFLwYULsR/AhY+VG1d+C124kJiFIGipmoIZNUXtZDKTycz1njGpaRNU8MJv7txzzv/c5xEYY/A/TRQEAW5c5KwM+aKcR73/a5zvg84HT371wv07Apwuj0x+PZW/vArA4NO7x/f4+OGoIHLKAAiC/fBdHadSbCGZPTeTzC7OUElbQNvBOISMMnIqeqFSYs57mTkfZD1/qYS2f0rAZ5pVDmXnY/FSbn3jM6xvfAEtfjKnRDLz6BtK4PPPADi+ms6vGK71lti2DUintUVSJ84b6OvF7GlI4PNMPVgAZ49oxpyqRnXf+wGWZYX4ngWRiKYfPpqfw5hBjej7eweqCkSo6JOLhmd/hI7vQLVaBdM0YXt1FgK2CeJ40fCbmxUWsGc8vh3egtcFQPhyLsQnzpQJcbVmuw5mawtqtRo0Gg3wJQeY7ALIrqZEM2WM7esIPkROAgR5OZEpTTV3X4IXNEGiLnw1b4fItBNCBQuiqeQUA7qMGtSSLt8C38aVRLo47QVvVJFYoFAnJJG8FdIfI6rSVWMTx6ZRg1rS7UKeSspSMj2Wk+AbjPGZ+vTboA1JZbQcEcUl1Iq2zdZyxURBpruUMTzR38Vl79wM+9bO0/3vlwLVs+OF16/MNdFug/vi+Xadm+vDL/3uHyuR16Er4E3gKvEaOTLa/1LBuEQPF8hxfgowAINnMqTBUH7hAAAAAElFTkSuQmCC');\n    padding: 5px;\n}\n"
  },
  {
    "path": "libcpychecker_html/test/example1/bug.c",
    "content": "#include <Python.h>\n\nPyObject *\nmake_a_list_of_random_ints_badly(PyObject *self,\n                                 PyObject *args)\n{\n    PyObject *list, *item;\n    long count, i;\n\n    if (!PyArg_ParseTuple(args, \"i\", &count)) {\n         return NULL;\n    }\n\n    list = PyList_New(0);\n\n    for (i = 0; i < count; i++) {\n        item = PyLong_FromLong(random());\n        PyList_Append(list, item);\n    }\n\n    return list;\n}\n"
  },
  {
    "path": "libcpychecker_html/test/example1/bug.c.make_a_list_of_random_ints_badly.json",
    "content": "{\n    \"filename\": \"libcpychecker_html/test/example1/bug.c\", \n    \"function\": {\n        \"lines\": [\n            3, \n            23\n        ], \n        \"name\": \"make_a_list_of_random_ints_badly\"\n    }, \n    \"reports\": [\n        {\n            \"message\": \"ob_refcnt of '*item' is 1 too high\", \n            \"notes\": [\n                {\n                    \"location\": [\n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }, \n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }\n                    ], \n                    \"message\": \"was expecting final ob_refcnt to be N + 1 (for some unknown N)\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }, \n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }\n                    ], \n                    \"message\": \"due to object being referenced by: PyListObject.ob_item[0]\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }, \n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }\n                    ], \n                    \"message\": \"but final ob_refcnt is N + 2\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 14, \n                            \"line\": 17\n                        }, \n                        {\n                            \"column\": 14, \n                            \"line\": 17\n                        }\n                    ], \n                    \"message\": \"PyLongObject allocated at:         item = PyLong_FromLong(random());\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }, \n                        {\n                            \"column\": 1, \n                            \"line\": 22\n                        }\n                    ], \n                    \"message\": \"found 1 similar trace(s) to this\"\n                }\n            ], \n            \"severity\": \"warning\", \n            \"states\": [\n                {\n                    \"location\": null, \n                    \"message\": \"\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 26, \n                            \"line\": 10\n                        }, \n                        {\n                            \"column\": 26, \n                            \"line\": 10\n                        }\n                    ], \n                    \"message\": \"when PyArg_ParseTuple() succeeds\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 10\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 10\n                        }\n                    ], \n                    \"message\": \"taking False path\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 10, \n                            \"line\": 14\n                        }, \n                        {\n                            \"column\": 10, \n                            \"line\": 14\n                        }\n                    ], \n                    \"message\": \"when PyList_New() succeeds\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": \"when considering range: 1 <= count.0 <= 0x7fffffff\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": \"taking True path\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 31, \n                            \"line\": 17\n                        }, \n                        {\n                            \"column\": 31, \n                            \"line\": 17\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 14, \n                            \"line\": 17\n                        }, \n                        {\n                            \"column\": 14, \n                            \"line\": 17\n                        }\n                    ], \n                    \"message\": \"when PyLong_FromLong() succeeds\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }\n                    ], \n                    \"message\": \"when PyList_Append() succeeds\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 29, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 29, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item[0]\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item[0]\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": \"when considering count.0 == (int)1 from libcpychecker_html/test/example1/bug.c:10\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item[0]\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": \"taking False path\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item[0]\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 21\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 21\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item[0]\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": null, \n                    \"message\": \"returning\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item[0]\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": null, \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item\": {\n                            \"gcctype\": \"struct PyObject * *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"ob_item array for PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_item[0]\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"return value\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_size\": {\n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyListObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyList_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyList_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 2\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": [\n                                    \"PyListObject.ob_item[0]\"\n                                ]\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }, \n                                {\n                                    \"column\": 22, \n                                    \"line\": 18\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 29, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyListObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"ob_item array for PyListObject\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }\n            ]\n        }, \n        {\n            \"message\": \"calling PyList_Append with NULL as argument 1 (list) at libcpychecker_html/test/example1/bug.c:18\", \n            \"notes\": [\n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }\n                    ], \n                    \"message\": \"PyList_Append() invokes Py_TYPE() on the pointer via the PyList_Check() macro, thus accessing (NULL)->ob_type\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }\n                    ], \n                    \"message\": \"found 1 similar trace(s) to this\"\n                }\n            ], \n            \"severity\": \"warning\", \n            \"states\": [\n                {\n                    \"location\": null, \n                    \"message\": \"\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 26, \n                            \"line\": 10\n                        }, \n                        {\n                            \"column\": 26, \n                            \"line\": 10\n                        }\n                    ], \n                    \"message\": \"when PyArg_ParseTuple() succeeds\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 10\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 10\n                        }\n                    ], \n                    \"message\": \"taking False path\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 10, \n                            \"line\": 14\n                        }, \n                        {\n                            \"column\": 10, \n                            \"line\": 14\n                        }\n                    ], \n                    \"message\": \"when PyList_New() fails\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": \"when considering range: 1 <= count.0 <= 0x7fffffff\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": -2147483648, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 16\n                        }\n                    ], \n                    \"message\": \"taking True path\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 31, \n                            \"line\": 17\n                        }, \n                        {\n                            \"column\": 31, \n                            \"line\": 17\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 14, \n                            \"line\": 17\n                        }, \n                        {\n                            \"column\": 14, \n                            \"line\": 17\n                        }\n                    ], \n                    \"message\": \"when PyLong_FromLong() succeeds\", \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 18\n                        }\n                    ], \n                    \"message\": null, \n                    \"variables\": {\n                        \"<retval>\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12024\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"D.12027\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"UninitializedData\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }, \n                                {\n                                    \"column\": 1, \n                                    \"line\": 6\n                                }\n                            ]\n                        }, \n                        \"D.12028\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 9223372036854775807, \n                            \"minvalue\": -9223372036854775808, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 31, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 0, \n                                \"refs_we_own\": 1\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLongObject.ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLong_Type\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"PyLong_Type.tp_dealloc\": {\n                            \"gcctype\": \"void (*destructor) (struct PyObject *)\", \n                            \"kind\": \"GenericTpDealloc\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"args\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"args\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"args->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('args')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 5\n                                }\n                            ]\n                        }, \n                        \"count\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"count.0\": {\n                            \"gcctype\": \"int\", \n                            \"kind\": \"WithinRange\", \n                            \"maxvalue\": 2147483647, \n                            \"minvalue\": 1, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }, \n                                {\n                                    \"column\": 26, \n                                    \"line\": 10\n                                }\n                            ]\n                        }, \n                        \"i\": {\n                            \"gcctype\": \"long int\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }, \n                                {\n                                    \"column\": 12, \n                                    \"line\": 16\n                                }\n                            ]\n                        }, \n                        \"item\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"PyLongObject\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }, \n                                {\n                                    \"column\": 14, \n                                    \"line\": 17\n                                }\n                            ]\n                        }, \n                        \"list\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"ConcreteValue\", \n                            \"value\": 0, \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }, \n                                {\n                                    \"column\": 10, \n                                    \"line\": 14\n                                }\n                            ]\n                        }, \n                        \"self\": {\n                            \"gcctype\": \"struct PyObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"self\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_refcnt\": {\n                            \"actual_ob_refcnt\": {\n                                \"lower_bound_of_other_refs\": 1, \n                                \"refs_we_own\": 0\n                            }, \n                            \"expected_ob_refcnt\": {\n                                \"pointers_to_this\": []\n                            }, \n                            \"gcctype\": \"Py_ssize_t\", \n                            \"kind\": \"RefcountValue\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }, \n                        \"self->ob_type\": {\n                            \"gcctype\": \"struct PyTypeObject *\", \n                            \"kind\": \"PointerToRegion\", \n                            \"target\": \"region-for-type-of-arg-gcc.ParmDecl('self')\", \n                            \"value_comes_from\": [\n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }, \n                                {\n                                    \"column\": 44, \n                                    \"line\": 4\n                                }\n                            ]\n                        }\n                    }\n                }\n            ]\n        }\n    ]\n}\n"
  },
  {
    "path": "libcpychecker_html/test/example2/_pylibmcmodule.h",
    "content": "/**\n * _pylibmc: hand-made libmemcached bindings for Python\n *\n * Copyright (c) 2008, Ludvig Ericson\n * All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n * \n *  - Redistributions of source code must retain the above copyright notice,\n *  this list of conditions and the following disclaimer.\n * \n *  - Redistributions in binary form must reproduce the above copyright notice,\n *  this list of conditions and the following disclaimer in the documentation\n *  and/or other materials provided with the distribution.\n * \n *  - Neither the name of the author nor the names of the contributors may be\n *  used to endorse or promote products derived from this software without\n *  specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef __PYLIBMC_H__\n#define __PYLIBMC_H__\n\n/* This makes the \"s#\" format for PyArg_ParseTuple and such take a Py_ssize_t\n * instead of an int or whatever. */\n#define PY_SSIZE_T_CLEAN\n\n#include <Python.h>\n#include <libmemcached/memcached.h>\n\n//#include \"pylibmc-version.h\"\n\n/* Py_ssize_t appeared in Python 2.5. */\n#ifndef PY_SSIZE_T_MAX\ntypedef ssize_t Py_ssize_t;\n#endif\n\n/* Server types. */\n#define PYLIBMC_SERVER_TCP   (1 << 0)\n#define PYLIBMC_SERVER_UDP   (1 << 1)\n#define PYLIBMC_SERVER_UNIX  (1 << 2)\n\n/* {{{ Key flags from python-memcached\n * Some flags (like the compression one, ZLIB) are combined with others.\n */\n#define PYLIBMC_FLAG_NONE    0\n#define PYLIBMC_FLAG_PICKLE  (1 << 0)\n#define PYLIBMC_FLAG_INTEGER (1 << 1)\n#define PYLIBMC_FLAG_LONG    (1 << 2)\n/* Note: this is an addition! python-memcached doesn't handle bools. */\n#define PYLIBMC_FLAG_BOOL    (1 << 4)\n#define PYLIBMC_FLAG_TYPES   (PYLIBMC_FLAG_PICKLE | PYLIBMC_FLAG_INTEGER | \\\n                              PYLIBMC_FLAG_LONG | PYLIBMC_FLAG_BOOL)\n/* Modifier flags */\n#define PYLIBMC_FLAG_ZLIB    (1 << 3)\n/* }}} */\n\ntypedef memcached_return (*_PylibMC_SetCommand)(memcached_st *, const char *,\n        size_t, const char *, size_t, time_t, uint32_t);\ntypedef memcached_return (*_PylibMC_IncrCommand)(memcached_st *,\n        const char *, size_t, unsigned int, uint64_t*);\n\ntypedef struct {\n  char *key;\n  Py_ssize_t key_len;\n  char* value;\n  Py_ssize_t value_len;\n  time_t time;\n  uint32_t flags;\n\n  /* the objects that must be freed after the mset is executed */\n  PyObject* key_obj;\n  PyObject* prefixed_key_obj;\n  PyObject* value_obj;\n\n  /* the success of executing the mset afterwards */\n  int success;\n\n} pylibmc_mset;\n\ntypedef struct {\n  char* key;\n  Py_ssize_t key_len;\n  _PylibMC_IncrCommand incr_func;\n  unsigned int delta;\n  uint64_t result;\n} pylibmc_incr;\n\ntypedef struct {\n    PyObject *self;\n    PyObject *retval;\n    memcached_server_st *servers;  /* DEPRECATED */\n    memcached_stat_st *stats;\n    int index;\n} _PylibMC_StatsContext;\n\n/* {{{ Exceptions */\nstatic PyObject *PylibMCExc_MemcachedError;\n\n/* Mapping of memcached_return value -> Python exception object. */\ntypedef struct {\n    memcached_return rc;\n    char *name;\n    PyObject *exc;\n} PylibMC_McErr;\n\nstatic PylibMC_McErr PylibMCExc_mc_errs[] = {\n    { MEMCACHED_FAILURE, \"Failure\", NULL },\n    { MEMCACHED_HOST_LOOKUP_FAILURE, \"HostLookupError\", NULL },\n    { MEMCACHED_CONNECTION_FAILURE, \"ConnectionError\", NULL },\n    { MEMCACHED_CONNECTION_BIND_FAILURE, \"ConnectionBindError\", NULL },\n    { MEMCACHED_WRITE_FAILURE, \"WriteError\", NULL },\n    { MEMCACHED_READ_FAILURE, \"ReadError\", NULL },\n    { MEMCACHED_UNKNOWN_READ_FAILURE, \"UnknownReadFailure\", NULL },\n    { MEMCACHED_PROTOCOL_ERROR, \"ProtocolError\", NULL },\n    { MEMCACHED_CLIENT_ERROR, \"ClientError\", NULL },\n    { MEMCACHED_SERVER_ERROR, \"ServerError\", NULL },\n    { MEMCACHED_CONNECTION_SOCKET_CREATE_FAILURE, \"SocketCreateError\", NULL },\n    { MEMCACHED_DATA_EXISTS, \"DataExists\", NULL },\n    { MEMCACHED_DATA_DOES_NOT_EXIST, \"DataDoesNotExist\", NULL },\n    //{ MEMCACHED_NOTSTORED, \"NotStored\", NULL },\n    //{ MEMCACHED_STORED, \"Stored\", NULL },\n    { MEMCACHED_NOTFOUND, \"NotFound\", NULL },\n    { MEMCACHED_MEMORY_ALLOCATION_FAILURE, \"AllocationError\", NULL },\n    //{ MEMCACHED_PARTIAL_READ, \"PartialRead\", NULL },\n    { MEMCACHED_SOME_ERRORS, \"SomeErrors\", NULL },\n    { MEMCACHED_NO_SERVERS, \"NoServers\", NULL },\n    //{ MEMCACHED_END, \"\", NULL },\n    //{ MEMCACHED_DELETED, \"\", NULL },\n    //{ MEMCACHED_VALUE, \"\", NULL },\n    //{ MEMCACHED_STAT, \"\", NULL },\n    //{ MEMCACHED_ITEM, \"\", NULL },\n    //{ MEMCACHED_ERRNO, \"\", NULL },\n    { MEMCACHED_FAIL_UNIX_SOCKET, \"UnixSocketError\", NULL },\n    { MEMCACHED_NOT_SUPPORTED, \"NotSupportedError\", NULL },\n    { MEMCACHED_FETCH_NOTFINISHED, \"FetchNotFinished\", NULL },\n    //{ MEMCACHED_TIMEOUT, \"TimeoutError\", NULL },\n    //{ MEMCACHED_BUFFERED, \"Buffer, NULL },\n    { MEMCACHED_BAD_KEY_PROVIDED, \"BadKeyProvided\", NULL },\n    { MEMCACHED_INVALID_HOST_PROTOCOL, \"InvalidHostProtocolError\", NULL },\n    { MEMCACHED_SERVER_MARKED_DEAD, \"ServerDead\", NULL },\n#ifdef MEMCACHED_SERVER_TEMPORARILY_DISABLED\n    { MEMCACHED_SERVER_TEMPORARILY_DISABLED, \"ServerDown\", NULL },\n#endif\n    { MEMCACHED_UNKNOWN_STAT_KEY, \"UnknownStatKey\", NULL },\n    //{ MEMCACHED_E2BIG, \"TooBigError\", NULL },\n    { 0, NULL, NULL }\n};\n/* }}} */\n\n/* {{{ Behavior statics */\ntypedef struct {\n    int flag;\n    char *name;\n} PylibMC_Behavior;\n\nstatic PylibMC_Behavior PylibMC_behaviors[] = {\n    { MEMCACHED_BEHAVIOR_NO_BLOCK, \"no_block\" },\n    { MEMCACHED_BEHAVIOR_TCP_NODELAY, \"tcp_nodelay\" },\n    { MEMCACHED_BEHAVIOR_HASH, \"hash\" },\n    { MEMCACHED_BEHAVIOR_KETAMA_HASH, \"ketama_hash\" },\n    { MEMCACHED_BEHAVIOR_KETAMA, \"ketama\" },\n    { MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, \"ketama_weighted\" },\n    { MEMCACHED_BEHAVIOR_DISTRIBUTION, \"distribution\" },\n    { MEMCACHED_BEHAVIOR_SUPPORT_CAS, \"cas\" },\n    { MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, \"buffer_requests\" },\n    { MEMCACHED_BEHAVIOR_VERIFY_KEY, \"verify_keys\" },\n    { MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT, \"connect_timeout\" },\n    { MEMCACHED_BEHAVIOR_SND_TIMEOUT, \"send_timeout\" },\n    { MEMCACHED_BEHAVIOR_RCV_TIMEOUT, \"receive_timeout\" },\n    { MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, \"num_replicas\" },\n    { MEMCACHED_BEHAVIOR_AUTO_EJECT_HOSTS, \"auto_eject\" },\n    { MEMCACHED_BEHAVIOR_RETRY_TIMEOUT, \"retry_timeout\" },\n#if LIBMEMCACHED_VERSION_HEX >= 0x00049000\n    { MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS, \"remove_failed\" },\n#endif\n    /* make sure failure_limit is set after remove_failed\n     * as the latter overwrites the former. */\n    { MEMCACHED_BEHAVIOR_SERVER_FAILURE_LIMIT, \"failure_limit\" },\n\n    { MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK, \"_io_msg_watermark\" },\n    { MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK, \"_io_bytes_watermark\" },\n    { MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH, \"_io_key_prefetch\" },\n    { MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY, \"_hash_with_prefix_key\" },\n    { MEMCACHED_BEHAVIOR_NOREPLY, \"_noreply\" },\n    { MEMCACHED_BEHAVIOR_SORT_HOSTS, \"_sort_hosts\" },\n    { MEMCACHED_BEHAVIOR_POLL_TIMEOUT, \"_poll_timeout\" },\n    { MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE, \"_socket_send_size\" },\n    { MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE, \"_socket_recv_size\" },\n    { 0, NULL }\n};\n\nstatic PylibMC_Behavior PylibMC_hashers[] = {\n    { MEMCACHED_HASH_DEFAULT, \"default\" },\n    { MEMCACHED_HASH_MD5, \"md5\" },\n    { MEMCACHED_HASH_CRC, \"crc\" },\n    { MEMCACHED_HASH_FNV1_64, \"fnv1_64\" },\n    { MEMCACHED_HASH_FNV1A_64, \"fnv1a_64\" },\n    { MEMCACHED_HASH_FNV1_32, \"fnv1_32\" },\n    { MEMCACHED_HASH_FNV1A_32, \"fnv1a_32\" },\n    { MEMCACHED_HASH_MURMUR, \"murmur\" },\n#ifdef MEMCACHED_HASH_HSIEH\n    { MEMCACHED_HASH_HSIEH, \"hsieh\" },\n#endif\n    { 0, NULL }\n};\n\nstatic PylibMC_Behavior PylibMC_distributions[] = {\n    { MEMCACHED_DISTRIBUTION_MODULA, \"modula\" },\n    { MEMCACHED_DISTRIBUTION_CONSISTENT, \"consistent\" },\n    { MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, \"consistent_ketama\" },\n    { 0, NULL }\n};\n/* }}} */\n\n/* {{{ _pylibmc.client */\ntypedef struct {\n    PyObject_HEAD\n    memcached_st *mc;\n    uint8_t sasl_set;\n} PylibMC_Client;\n\n/* {{{ Prototypes */\nstatic PylibMC_Client *PylibMC_ClientType_new(PyTypeObject *, PyObject *,\n        PyObject *);\nstatic void PylibMC_ClientType_dealloc(PylibMC_Client *);\nstatic int PylibMC_Client_init(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_get(PylibMC_Client *, PyObject *arg);\nstatic PyObject *PylibMC_Client_gets(PylibMC_Client *, PyObject *arg);\nstatic PyObject *PylibMC_Client_set(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_replace(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_add(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_prepend(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_append(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_cas(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_delete(PylibMC_Client *, PyObject *);\nstatic PyObject *PylibMC_Client_incr(PylibMC_Client *, PyObject *);\nstatic PyObject *PylibMC_Client_decr(PylibMC_Client *, PyObject *);\nstatic PyObject *PylibMC_Client_incr_multi(PylibMC_Client*, PyObject*, PyObject*);\nstatic PyObject *PylibMC_Client_get_multi(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_set_multi(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_add_multi(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_delete_multi(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_get_behaviors(PylibMC_Client *);\nstatic PyObject *PylibMC_Client_set_behaviors(PylibMC_Client *, PyObject *);\nstatic PyObject *PylibMC_Client_get_stats(PylibMC_Client *, PyObject *);\nstatic PyObject *PylibMC_Client_flush_all(PylibMC_Client *, PyObject *, PyObject *);\nstatic PyObject *PylibMC_Client_disconnect_all(PylibMC_Client *);\nstatic PyObject *PylibMC_Client_clone(PylibMC_Client *);\nstatic PyObject *PylibMC_ErrFromMemcachedWithKey(PylibMC_Client *, const char *,\n        memcached_return, const char *, Py_ssize_t);\nstatic PyObject *PylibMC_ErrFromMemcached(PylibMC_Client *, const char *,\n        memcached_return);\nstatic PyObject *_PylibMC_Unpickle(const char *, size_t);\nstatic PyObject *_PylibMC_Pickle(PyObject *);\nstatic int _PylibMC_CheckKey(PyObject *);\nstatic int _PylibMC_CheckKeyStringAndSize(char *, Py_ssize_t);\nstatic int _PylibMC_SerializeValue(PyObject* key_obj,\n                                   PyObject* key_prefix,\n                                   PyObject* value_obj,\n                                   time_t time,\n                                   pylibmc_mset* serialized);\nstatic void _PylibMC_FreeMset(pylibmc_mset*);\nstatic PyObject *_PylibMC_RunSetCommandSingle(PylibMC_Client *self,\n        _PylibMC_SetCommand f, char *fname, PyObject *args, PyObject *kwds);\nstatic PyObject *_PylibMC_RunSetCommandMulti(PylibMC_Client* self,\n        _PylibMC_SetCommand f, char *fname, PyObject *args, PyObject *kwds);\nstatic bool _PylibMC_RunSetCommand(PylibMC_Client* self,\n                                   _PylibMC_SetCommand f, char *fname,\n                                   pylibmc_mset* msets, size_t nkeys,\n                                   size_t min_compress);\nstatic int _PylibMC_Deflate(char* value, size_t value_len,\n                            char** result, size_t *result_len);\nstatic bool _PylibMC_IncrDecr(PylibMC_Client*, pylibmc_incr*, size_t);\n\n/* }}} */\n\n/* {{{ Type's method table */\nstatic PyMethodDef PylibMC_ClientType_methods[] = {\n    {\"get\", (PyCFunction)PylibMC_Client_get, METH_O,\n        \"Retrieve a key from a memcached.\"},\n    {\"gets\", (PyCFunction)PylibMC_Client_gets, METH_O,\n        \"Retrieve a key and cas_id from a memcached.\"},\n    {\"set\", (PyCFunction)PylibMC_Client_set, METH_VARARGS|METH_KEYWORDS,\n        \"Set a key unconditionally.\"},\n    {\"replace\", (PyCFunction)PylibMC_Client_replace, METH_VARARGS|METH_KEYWORDS,\n        \"Set a key only if it exists.\"},\n    {\"add\", (PyCFunction)PylibMC_Client_add, METH_VARARGS|METH_KEYWORDS,\n        \"Set a key only if doesn't exist.\"},\n    {\"prepend\", (PyCFunction)PylibMC_Client_prepend, METH_VARARGS|METH_KEYWORDS,\n        \"Prepend data to  a key.\"},\n    {\"append\", (PyCFunction)PylibMC_Client_append, METH_VARARGS|METH_KEYWORDS,\n        \"Append data to a key.\"},\n    {\"cas\", (PyCFunction)PylibMC_Client_cas, METH_VARARGS|METH_KEYWORDS,\n        \"Attempt to compare-and-store a key by CAS ID.\"},\n    {\"delete\", (PyCFunction)PylibMC_Client_delete, METH_VARARGS,\n        \"Delete a key.\"},\n    {\"incr\", (PyCFunction)PylibMC_Client_incr, METH_VARARGS,\n        \"Increment a key by a delta.\"},\n    {\"decr\", (PyCFunction)PylibMC_Client_decr, METH_VARARGS,\n        \"Decrement a key by a delta.\"},\n    {\"incr_multi\", (PyCFunction)PylibMC_Client_incr_multi, METH_VARARGS|METH_KEYWORDS,\n        \"Increment more than one key by a delta.\"},\n    {\"get_multi\", (PyCFunction)PylibMC_Client_get_multi,\n        METH_VARARGS|METH_KEYWORDS, \"Get multiple keys at once.\"},\n    {\"set_multi\", (PyCFunction)PylibMC_Client_set_multi,\n        METH_VARARGS|METH_KEYWORDS, \"Set multiple keys at once.\"},\n    {\"add_multi\", (PyCFunction)PylibMC_Client_add_multi,\n        METH_VARARGS|METH_KEYWORDS, \"Add multiple keys at once.\"},\n    {\"delete_multi\", (PyCFunction)PylibMC_Client_delete_multi,\n        METH_VARARGS|METH_KEYWORDS, \"Delete multiple keys at once.\"},\n    {\"get_behaviors\", (PyCFunction)PylibMC_Client_get_behaviors, METH_NOARGS,\n        \"Get behaviors dict.\"},\n    {\"set_behaviors\", (PyCFunction)PylibMC_Client_set_behaviors, METH_O,\n        \"Set behaviors dict.\"},\n    {\"get_stats\", (PyCFunction)PylibMC_Client_get_stats,\n        METH_VARARGS, \"Retrieve statistics from all memcached servers.\"},\n    {\"flush_all\", (PyCFunction)PylibMC_Client_flush_all,\n        METH_VARARGS|METH_KEYWORDS, \"Flush all data on all servers.\"},\n    {\"disconnect_all\", (PyCFunction)PylibMC_Client_disconnect_all, METH_NOARGS,\n        \"Disconnect from all servers and reset own state.\"},\n    {\"clone\", (PyCFunction)PylibMC_Client_clone, METH_NOARGS,\n        \"Clone this client entirely such that it is safe to access from \"\n        \"another thread. This creates a new connection.\"},\n    {NULL, NULL, 0, NULL}\n};\n/* }}} */\n\n/* {{{ Type def */\nstatic PyTypeObject PylibMC_ClientType = {\n    PyObject_HEAD_INIT(NULL)\n    0,\n    \"client\",\n    sizeof(PylibMC_Client),\n    0,\n    (destructor)PylibMC_ClientType_dealloc,\n\n    0,\n    0,\n    0,\n    0,\n    0,\n\n    0,\n    0,\n    0,\n\n    0,\n    0,\n    0,\n    0,\n    0,\n    0,\n    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,\n    \"memcached client type\",\n    0,\n    0,\n    0,\n    0,\n    0,\n    0,\n    PylibMC_ClientType_methods,\n    0,\n    0,\n    0,\n    0,\n    0,\n    0,\n    0,\n    (initproc)PylibMC_Client_init,\n    0,\n    (newfunc)PylibMC_ClientType_new, //PyType_GenericNew,\n    0,\n    0,\n    0,\n    0,\n    0,\n    0,\n    0,\n    0\n};\n\n/* }}} */\n\n#endif /* def __PYLIBMC_H__ */\n"
  },
  {
    "path": "libcpychecker_html/test/example2/pylibmc-issue-68.c",
    "content": "/*\n  Example of a historical reference-counting error:\n\n  The code below was extracted from:\n    https://github.com/lericson/pylibmc/blob/bc1787c3e74ddebb44736fc4eaf8333a2e51a80f/_pylibmcmodule.c\n\n  TODO: does it find the bug?  can we simplify the code (e.g. just on the one function?)\n  \n  FIXME: don't add this: it adds a dependency on libmemcached\n*/\n\n/*\n  Add this here to fool the test harness:\n    #include <Python.h>\n */\n\n/**\n * _pylibmc: hand-made libmemcached bindings for Python\n *\n * Copyright (c) 2008, Ludvig Ericson\n * All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n * \n *  - Redistributions of source code must retain the above copyright notice,\n *  this list of conditions and the following disclaimer.\n * \n *  - Redistributions in binary form must reproduce the above copyright notice,\n *  this list of conditions and the following disclaimer in the documentation\n *  and/or other materials provided with the distribution.\n * \n *  - Neither the name of the author nor the names of the contributors may be\n *  used to endorse or promote products derived from this software without\n *  specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE\n * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n * POSSIBILITY OF SUCH DAMAGE.\n */\n\n#include \"_pylibmcmodule.h\"\n\n/* Extracted copy of PylibMC_Client_get_multi */\nstatic PyObject *PylibMC_Client_get_multi(\n        PylibMC_Client *self, PyObject *args, PyObject *kwds) {\n    PyObject *key_seq, **key_objs, *retval = NULL;\n    char **keys, *prefix = NULL;\n    char *err_func = NULL;\n    memcached_result_st *res, *results = NULL;\n    int prefix_len = 0;\n    Py_ssize_t i;\n    PyObject *key_it, *ckey;\n    size_t *key_lens;\n    size_t nkeys, nresults = 0;\n    memcached_return rc;\n\n    static char *kws[] = { \"keys\", \"key_prefix\", NULL };\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|s#:get_multi\", kws,\n            &key_seq, &prefix, &prefix_len))\n        return NULL;\n\n    if ((nkeys = (size_t)PySequence_Length(key_seq)) == -1)\n        return NULL;\n\n    /* Populate keys and key_lens. */\n    keys = PyMem_New(char *, nkeys);\n    key_lens = PyMem_New(size_t, nkeys);\n    key_objs = PyMem_New(PyObject *, nkeys);\n    if (!keys || !key_lens || !key_objs) {\n        PyMem_Free(keys);\n        PyMem_Free(key_lens);\n        PyMem_Free(key_objs);\n        return PyErr_NoMemory();\n    }\n\n    /* Clear potential previous exception, because we explicitly check for\n     * exceptions as a loop predicate. */\n    PyErr_Clear();\n\n    /* Iterate through all keys and set lengths etc. */\n    key_it = PyObject_GetIter(key_seq);\n    i = 0;\n    while ((ckey = PyIter_Next(key_it)) != NULL) {\n        char *key;\n        Py_ssize_t key_len;\n        PyObject *rkey;\n\n        assert(i < nkeys);\n\n        if (PyErr_Occurred() || !_PylibMC_CheckKey(ckey)) {\n            nkeys = i;\n            goto earlybird;\n        }\n\n        PyString_AsStringAndSize(ckey, &key, &key_len);\n\n        key_lens[i] = (size_t)(key_len + prefix_len);\n\n        /* Skip empty keys */\n        if (!key_lens[i])\n            continue;\n\n        /* determine rkey, the prefixed ckey */\n        if (prefix != NULL) {\n            rkey = PyString_FromStringAndSize(prefix, prefix_len);\n            PyString_Concat(&rkey, ckey);\n            if (rkey == NULL)\n                goto earlybird;\n            rkey = PyString_FromFormat(\"%s%s\",\n                    prefix, PyString_AS_STRING(ckey));\n        } else {\n            Py_INCREF(ckey);\n            rkey = ckey;\n        }\n        Py_DECREF(ckey);\n\n        keys[i] = PyString_AS_STRING(rkey);\n        key_objs[i++] = rkey;\n    }\n    nkeys = i;\n    Py_XDECREF(key_it);\n\n    if (nkeys == 0) {\n        retval = PyDict_New();\n        goto earlybird;\n    } else if (PyErr_Occurred()) {\n        nkeys--;\n        goto earlybird;\n    }\n\n    /* TODO Make an iterator interface for getting each key separately.\n     *\n     * This would help large retrievals, as a single dictionary containing all\n     * the data at once isn't needed. (Should probably look into if it's even\n     * worth it.)\n     */\n    Py_BEGIN_ALLOW_THREADS;\n    rc = pylibmc_memcached_fetch_multi(self->mc,\n                                       keys, nkeys, key_lens,\n                                       &results, &nresults,\n                                       &err_func);\n    Py_END_ALLOW_THREADS;\n\n    if (rc != MEMCACHED_SUCCESS) {\n        PylibMC_ErrFromMemcached(self, err_func, rc);\n        goto earlybird;\n    }\n\n    retval = PyDict_New();\n\n    for (i = 0; i < nresults; i++) {\n        PyObject *val, *key_obj;\n        int rc;\n\n        res = results + i;\n\n        /* Explicitly construct a key string object so that NUL-bytes and the\n         * likes can be contained within the keys (this is possible in the\n         * binary protocol.) */\n        key_obj = PyString_FromStringAndSize(memcached_result_key_value(res) + prefix_len,\n                                             memcached_result_key_length(res) - prefix_len);\n        if (key_obj == NULL)\n            goto unpack_error;\n\n        /* Parse out value */\n        val = _PylibMC_parse_memcached_result(res);\n        if (val == NULL)\n            goto unpack_error;\n\n        rc = PyDict_SetItem(retval, key_obj, val);\n        Py_DECREF(key_obj);\n        Py_DECREF(val);\n\n        if (rc != 0)\n            goto unpack_error;\n\n        continue;\n\nunpack_error:\n            Py_DECREF(retval);\n            break;\n    }\n\nearlybird:\n    PyMem_Free(key_lens);\n    PyMem_Free(keys);\n\n    for (i = 0; i < nkeys; i++)\n        Py_DECREF(key_objs[i]);\n    PyMem_Free(key_objs);\n\n    if (results != NULL) {\n        for (i = 0; i < nresults && results != NULL; i++) {\n            memcached_result_free(results + i);\n        }\n        PyMem_Free(results);\n    }\n\n    /* Not INCREFing because the only two outcomes are NULL and a new dict.\n     * We're the owner of that dict already, so. */\n    return retval;\n}\n"
  },
  {
    "path": "libcpychecker_html/test/example2/pylibmc-issue-68.c.PylibMC_Client_get_multi.json",
    "content": "{\n    \"filename\": \"libcpychecker_html/test/example2/pylibmc-issue-68.c\", \n    \"function\": {\n        \"lines\": [\n            52, \n            213\n        ], \n        \"name\": \"PylibMC_Client_get_multi\"\n    }, \n    \"reports\": [\n        {\n            \"message\": \"returning pointer to deallocated memory\", \n            \"notes\": [\n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": \"memory deallocated here\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 1, \n                            \"line\": 212\n                        }, \n                        {\n                            \"column\": 1, \n                            \"line\": 212\n                        }\n                    ], \n                    \"message\": \"found 11 similar trace(s) to this\"\n                }\n            ], \n            \"severity\": \"warning\", \n            \"states\": [\n                {\n                    \"location\": null, \n                    \"message\": \"\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 37, \n                            \"line\": 55\n                        }, \n                        {\n                            \"column\": 37, \n                            \"line\": 55\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 56\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 56\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 11, \n                            \"line\": 57\n                        }, \n                        {\n                            \"column\": 11, \n                            \"line\": 57\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 32, \n                            \"line\": 58\n                        }, \n                        {\n                            \"column\": 32, \n                            \"line\": 58\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 59\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 59\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 63\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 63\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 37, \n                            \"line\": 68\n                        }, \n                        {\n                            \"column\": 37, \n                            \"line\": 68\n                        }\n                    ], \n                    \"message\": \"when _PyArg_ParseTupleAndKeywords_SizeT() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 68\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 68\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 43, \n                            \"line\": 72\n                        }, \n                        {\n                            \"column\": 43, \n                            \"line\": 72\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 43, \n                            \"line\": 72\n                        }, \n                        {\n                            \"column\": 43, \n                            \"line\": 72\n                        }\n                    ], \n                    \"message\": \"when PySequence_Size() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 72\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 72\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 72\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 72\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }\n                    ], \n                    \"message\": \"when considering range: 0 <= value <= 0xfffffffffffffff\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 76\n                        }\n                    ], \n                    \"message\": \"when PyMem_Malloc() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 10, \n                            \"line\": 76\n                        }, \n                        {\n                            \"column\": 10, \n                            \"line\": 76\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 77\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 77\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 77\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 77\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 77\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 77\n                        }\n                    ], \n                    \"message\": \"when PyMem_Malloc() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 14, \n                            \"line\": 77\n                        }, \n                        {\n                            \"column\": 14, \n                            \"line\": 77\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 78\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 78\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 78\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 78\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 78\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 78\n                        }\n                    ], \n                    \"message\": \"when PyMem_Malloc() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 14, \n                            \"line\": 78\n                        }, \n                        {\n                            \"column\": 14, \n                            \"line\": 78\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 79\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 79\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 15, \n                            \"line\": 79\n                        }, \n                        {\n                            \"column\": 15, \n                            \"line\": 79\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 28, \n                            \"line\": 79\n                        }, \n                        {\n                            \"column\": 28, \n                            \"line\": 79\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 88\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 88\n                        }\n                    ], \n                    \"message\": \"calling PyErr_Clear()\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 30, \n                            \"line\": 91\n                        }, \n                        {\n                            \"column\": 30, \n                            \"line\": 91\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 91\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 91\n                        }\n                    ], \n                    \"message\": \"when PyObject_GetIter() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 7, \n                            \"line\": 92\n                        }, \n                        {\n                            \"column\": 7, \n                            \"line\": 92\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }, \n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }\n                    ], \n                    \"message\": \"when PyIter_Next() retrieves a value (new ref)\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }, \n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 98\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 98\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 98\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 98\n                        }\n                    ], \n                    \"message\": \"when considering range: 1 <= nkeys <= 0xfffffffffffffff\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 98\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 98\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 27, \n                            \"line\": 100\n                        }, \n                        {\n                            \"column\": 27, \n                            \"line\": 100\n                        }\n                    ], \n                    \"message\": \"PyErr_Occurred()\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 100\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 100\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 51, \n                            \"line\": 100\n                        }, \n                        {\n                            \"column\": 51, \n                            \"line\": 100\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 30, \n                            \"line\": 100\n                        }, \n                        {\n                            \"column\": 30, \n                            \"line\": 100\n                        }\n                    ], \n                    \"message\": \"when considering range: -0x80000000 <= value <= -1\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 30, \n                            \"line\": 100\n                        }, \n                        {\n                            \"column\": 30, \n                            \"line\": 100\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 33, \n                            \"line\": 105\n                        }, \n                        {\n                            \"column\": 33, \n                            \"line\": 105\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 40, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 21, \n                            \"line\": 107\n                        }, \n                        {\n                            \"column\": 21, \n                            \"line\": 107\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 110\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 110\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 110\n                        }\n                    ], \n                    \"message\": \"when considering range: -0x8000000000000000 <= value <= -1\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 110\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 110\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 20, \n                            \"line\": 114\n                        }, \n                        {\n                            \"column\": 20, \n                            \"line\": 114\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 114\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 114\n                        }\n                    ], \n                    \"message\": \"when treating unknown const char * from libcpychecker_html/test/example2/pylibmc-issue-68.c:68 as non-NULL\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 114\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 114\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }, \n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }, \n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }, \n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }, \n                        {\n                            \"column\": 46, \n                            \"line\": 115\n                        }\n                    ], \n                    \"message\": \"when PyString_FromStringAndSize() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 18, \n                            \"line\": 115\n                        }, \n                        {\n                            \"column\": 18, \n                            \"line\": 115\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 117\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 117\n                        }\n                    ], \n                    \"message\": \"when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS)\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 22, \n                            \"line\": 117\n                        }, \n                        {\n                            \"column\": 22, \n                            \"line\": 117\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 117\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 117\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 29, \n                            \"line\": 120\n                        }, \n                        {\n                            \"column\": 29, \n                            \"line\": 120\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 39, \n                            \"line\": 119\n                        }, \n                        {\n                            \"column\": 39, \n                            \"line\": 119\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 39, \n                            \"line\": 119\n                        }, \n                        {\n                            \"column\": 39, \n                            \"line\": 119\n                        }\n                    ], \n                    \"message\": \"when PyString_FromFormat() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 18, \n                            \"line\": 119\n                        }, \n                        {\n                            \"column\": 18, \n                            \"line\": 119\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 125\n                        }\n                    ], \n                    \"message\": \"when taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 127\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 127\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 127\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 127\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 127\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 127\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 127\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 127\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 127\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 127\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 127\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 127\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 128\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 128\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 128\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 128\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 128\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 128\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 128\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 128\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 128\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 128\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 128\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 128\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }, \n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }\n                    ], \n                    \"message\": \"when PyIter_Next() returns NULL without setting an exception (end of iteration)\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }, \n                        {\n                            \"column\": 11, \n                            \"line\": 93\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 11, \n                            \"line\": 130\n                        }, \n                        {\n                            \"column\": 11, \n                            \"line\": 130\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 131\n                        }\n                    ], \n                    \"message\": \"when taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 133\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 133\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 30, \n                            \"line\": 136\n                        }, \n                        {\n                            \"column\": 30, \n                            \"line\": 136\n                        }\n                    ], \n                    \"message\": \"PyErr_Occurred()\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 15, \n                            \"line\": 136\n                        }, \n                        {\n                            \"column\": 15, \n                            \"line\": 136\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 147\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 147\n                        }\n                    ], \n                    \"message\": \"releasing the GIL by calling PyEval_SaveThread()\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 39, \n                            \"line\": 148\n                        }, \n                        {\n                            \"column\": 39, \n                            \"line\": 148\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 39, \n                            \"line\": 148\n                        }, \n                        {\n                            \"column\": 39, \n                            \"line\": 148\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 148\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 148\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 152\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 152\n                        }\n                    ], \n                    \"message\": \"reacquiring the GIL by calling PyEval_RestoreThread()\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 154\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 154\n                        }\n                    ], \n                    \"message\": \"when considering value == (int)0 from libcpychecker_html/test/example2/pylibmc-issue-68.c:148\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 154\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 154\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 159\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 159\n                        }\n                    ], \n                    \"message\": \"when PyDict_New() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 161\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 161\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 161\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 161\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 161\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 161\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 161\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 161\n                        }\n                    ], \n                    \"message\": \"when taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 165\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 165\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 165\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 165\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 165\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 165\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 165\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 165\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 73, \n                            \"line\": 171\n                        }, \n                        {\n                            \"column\": 73, \n                            \"line\": 171\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 79, \n                            \"line\": 171\n                        }, \n                        {\n                            \"column\": 79, \n                            \"line\": 171\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 79, \n                            \"line\": 171\n                        }, \n                        {\n                            \"column\": 79, \n                            \"line\": 171\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 79, \n                            \"line\": 171\n                        }, \n                        {\n                            \"column\": 79, \n                            \"line\": 171\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 45, \n                            \"line\": 170\n                        }, \n                        {\n                            \"column\": 45, \n                            \"line\": 170\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 72, \n                            \"line\": 170\n                        }, \n                        {\n                            \"column\": 72, \n                            \"line\": 170\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 45, \n                            \"line\": 170\n                        }, \n                        {\n                            \"column\": 45, \n                            \"line\": 170\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 78, \n                            \"line\": 170\n                        }, \n                        {\n                            \"column\": 78, \n                            \"line\": 170\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 45, \n                            \"line\": 170\n                        }, \n                        {\n                            \"column\": 45, \n                            \"line\": 170\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 170\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 170\n                        }\n                    ], \n                    \"message\": \"when PyString_FromStringAndSize() succeeds\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 172\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 172\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 46, \n                            \"line\": 176\n                        }, \n                        {\n                            \"column\": 46, \n                            \"line\": 176\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 46, \n                            \"line\": 176\n                        }, \n                        {\n                            \"column\": 46, \n                            \"line\": 176\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 176\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 176\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 177\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 177\n                        }\n                    ], \n                    \"message\": \"when treating unknown struct PyObject * from libcpychecker_html/test/example2/pylibmc-issue-68.c:176 as non-NULL\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 177\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 177\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 180\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 180\n                        }\n                    ], \n                    \"message\": \"when PyDict_SetItem() fails\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 181\n                        }\n                    ], \n                    \"message\": \"when taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }\n                    ], \n                    \"message\": \"when considering range: -0x8000000000000000 <= value <= -1\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 182\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 184\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 184\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": null, \n                    \"message\": \"\"\n                }, \n                {\n                    \"location\": null, \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": \"when taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }, \n                        {\n                            \"column\": 13, \n                            \"line\": 190\n                        }\n                    ], \n                    \"message\": \"calling tp_dealloc on PyDictObject allocated at libcpychecker_html/test/example2/pylibmc-issue-68.c:159\"\n                }, \n                {\n                    \"location\": null, \n                    \"message\": \"\"\n                }, \n                {\n                    \"location\": null, \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 15, \n                            \"line\": 195\n                        }, \n                        {\n                            \"column\": 15, \n                            \"line\": 195\n                        }\n                    ], \n                    \"message\": \"calling PyMem_Free on PyMem_Malloc allocated at libcpychecker_html/test/example2/pylibmc-issue-68.c:77\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 15, \n                            \"line\": 196\n                        }, \n                        {\n                            \"column\": 15, \n                            \"line\": 196\n                        }\n                    ], \n                    \"message\": \"calling PyMem_Free on PyMem_Malloc allocated at libcpychecker_html/test/example2/pylibmc-issue-68.c:76\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 12, \n                            \"line\": 198\n                        }, \n                        {\n                            \"column\": 12, \n                            \"line\": 198\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 198\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 198\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 198\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 198\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 199\n                        }\n                    ], \n                    \"message\": \"when taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 29, \n                            \"line\": 198\n                        }, \n                        {\n                            \"column\": 29, \n                            \"line\": 198\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 198\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 198\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 198\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 198\n                        }\n                    ], \n                    \"message\": \"taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 15, \n                            \"line\": 200\n                        }, \n                        {\n                            \"column\": 15, \n                            \"line\": 200\n                        }\n                    ], \n                    \"message\": \"calling PyMem_Free on PyMem_Malloc allocated at libcpychecker_html/test/example2/pylibmc-issue-68.c:78\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 17, \n                            \"line\": 202\n                        }, \n                        {\n                            \"column\": 17, \n                            \"line\": 202\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 202\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 202\n                        }\n                    ], \n                    \"message\": \"when treating unknown struct memcached_result_st * * from libcpychecker_html/test/example2/pylibmc-issue-68.c:148 as non-NULL\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 8, \n                            \"line\": 202\n                        }, \n                        {\n                            \"column\": 8, \n                            \"line\": 202\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 16, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 16, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": \"when taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 45, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 45, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 34, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 34, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": \"taking True path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }, \n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }, \n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 43, \n                            \"line\": 204\n                        }, \n                        {\n                            \"column\": 43, \n                            \"line\": 204\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }, \n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }, \n                        {\n                            \"column\": 34, \n                            \"line\": 204\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 55, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 55, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 23, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 9, \n                            \"line\": 203\n                        }, \n                        {\n                            \"column\": 9, \n                            \"line\": 203\n                        }\n                    ], \n                    \"message\": \"when taking False path\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 206\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 206\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 19, \n                            \"line\": 206\n                        }, \n                        {\n                            \"column\": 19, \n                            \"line\": 206\n                        }\n                    ], \n                    \"message\": \"calling PyMem_Free on Region('heap-region-12')\"\n                }, \n                {\n                    \"location\": [\n                        {\n                            \"column\": 5, \n                            \"line\": 211\n                        }, \n                        {\n                            \"column\": 5, \n                            \"line\": 211\n                        }\n                    ], \n                    \"message\": null\n                }, \n                {\n                    \"location\": null, \n                    \"message\": \"returning\"\n                }, \n                {\n                    \"location\": null, \n                    \"message\": null\n                }\n            ]\n        }\n    ]\n}\n"
  },
  {
    "path": "libcpychecker_html/test/example3/_mysql.c",
    "content": "/*\nThis program is free software; you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation; either version 2, or (at your option)\nany later version. Alternatively, you may use the original license\nreproduced below.\n\nCopyright 1999 by Comstar.net, Inc., Atlanta, GA, US.\n\n                        All Rights Reserved\n\nPermission to use, copy, modify, and distribute this software and its\ndocumentation for any purpose and without fee is hereby granted,\nprovided that the above copyright notice appear in all copies and that\nboth that copyright notice and this permission notice appear in\nsupporting documentation, and that the name of Comstar.net, Inc.\nor COMSTAR not be used in advertising or publicity pertaining to\ndistribution of the software without specific, written prior permission.\n\nCOMSTAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,\nINCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO\nEVENT SHALL COMSTAR BE LIABLE FOR ANY SPECIAL, INDIRECT OR\nCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF\nUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\nPERFORMANCE OF THIS SOFTWARE.\n*/\n\n\n\n// This 2000 lines intentionally left blank.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nPyMODINIT_FUNC\nPyInit__mysql(void)\n#else\nDL_EXPORT(void)\ninit_mysql(void)\n#endif\n{\n\tPyObject *dict, *module, *emod, *edict;\n\n    utf8conn = mysql_init(NULL);\n    utf8conn->charset = &my_charset_utf8mb4_unicode_ci;\n\n#ifdef IS_PY3K\n    module = PyModule_Create(&_mysqlmodule);\n\tif (!module) return module; /* this really should never happen */\n#else\n\tmodule = Py_InitModule4(\"_mysql\", _mysql_methods, _mysql___doc__,\n\t\t\t\t(PyObject *)NULL, PYTHON_API_VERSION);\n\tif (!module) return; /* this really should never happen */\n#endif\n#ifdef IS_PY3K\n\tPy_TYPE(&_mysql_ConnectionObject_Type) = &PyType_Type;\n\tPy_TYPE(&_mysql_ResultObject_Type) = &PyType_Type;\n#else\n\t_mysql_ConnectionObject_Type.ob_type = &PyType_Type;\n\t_mysql_ResultObject_Type.ob_type = &PyType_Type;\n#endif\n#if PY_VERSION_HEX >= 0x02020000\n\t_mysql_ConnectionObject_Type.tp_alloc = PyType_GenericAlloc;\n\t_mysql_ResultObject_Type.tp_alloc = PyType_GenericAlloc;\n\t_mysql_ConnectionObject_Type.tp_new = PyType_GenericNew;\n\t_mysql_ResultObject_Type.tp_new = PyType_GenericNew;\n#ifndef IS_PY3K\n\t_mysql_ConnectionObject_Type.tp_free = _PyObject_GC_Del;\n\t_mysql_ResultObject_Type.tp_free = _PyObject_GC_Del;\n#endif\n#endif\n\n\tif (!(dict = PyModule_GetDict(module))) goto error;\n\tif (PyDict_SetItemString(dict, \"version_info\",\n\t\t\t       PyRun_String(QUOTE(version_info), Py_eval_input,\n\t\t\t\t       dict, dict)))\n\t\tgoto error;\n\tif (PyDict_SetItemString(dict, \"__version__\",\n\t\t\t       PyUnicode_FromString(QUOTE(__version__))))\n\t\tgoto error;\n\tif (PyDict_SetItemString(dict, \"connection\",\n\t\t\t       (PyObject *)&_mysql_ConnectionObject_Type))\n\t\tgoto error;\n\tPy_INCREF(&_mysql_ConnectionObject_Type);\n\tif (PyDict_SetItemString(dict, \"result\",\n\t\t\t       (PyObject *)&_mysql_ResultObject_Type))\n\t\tgoto error;\t\n\tPy_INCREF(&_mysql_ResultObject_Type);\n\tif (!(emod = PyImport_ImportModule(\"_mysql_exceptions\"))) {\n\t    PyErr_Print();\n\t\tgoto error;\n\t}\n\tif (!(edict = PyModule_GetDict(emod))) goto error;\n\tif (!(_mysql_MySQLError =\n\t      _mysql_NewException(dict, edict, \"MySQLError\")))\n\t\tgoto error;\n\tif (!(_mysql_Warning =\n\t      _mysql_NewException(dict, edict, \"Warning\")))\n\t\tgoto error;\n\tif (!(_mysql_Error =\n\t      _mysql_NewException(dict, edict, \"Error\")))\n\t\tgoto error;\n\tif (!(_mysql_InterfaceError =\n\t      _mysql_NewException(dict, edict, \"InterfaceError\")))\n\t\tgoto error;\n\tif (!(_mysql_DatabaseError =\n\t      _mysql_NewException(dict, edict, \"DatabaseError\")))\n\t\tgoto error;\n\tif (!(_mysql_DataError =\n\t      _mysql_NewException(dict, edict, \"DataError\")))\n\t\tgoto error;\n\tif (!(_mysql_OperationalError =\n\t      _mysql_NewException(dict, edict, \"OperationalError\")))\n\t\tgoto error;\n\tif (!(_mysql_IntegrityError =\n\t      _mysql_NewException(dict, edict, \"IntegrityError\")))\n\t\tgoto error;\n\tif (!(_mysql_InternalError =\n\t      _mysql_NewException(dict, edict, \"InternalError\")))\n\t\tgoto error;\n\tif (!(_mysql_ProgrammingError =\n\t      _mysql_NewException(dict, edict, \"ProgrammingError\")))\n\t\tgoto error;\n\tif (!(_mysql_NotSupportedError =\n\t      _mysql_NewException(dict, edict, \"NotSupportedError\")))\n\t\tgoto error;\n\tif (!(_mysql_NULL = PyBytes_FromString(\"NULL\")))\n\t\tgoto error;\n\tif (PyDict_SetItemString(dict, \"NULL\", _mysql_NULL)) goto error;\n  error:\n\tif (emod) Py_DECREF(emod);\n\tif (PyErr_Occurred()) {\n\t\tPyErr_SetString(PyExc_ImportError,\n\t\t\t\t\"_mysql: init failed\");\n\t\tif (module) Py_DECREF(module);\n\t\tmodule = NULL;\n    }\n#ifdef IS_PY3K\n    return module;\n#endif\n}\n\n\n// vim:noet:ts=4:\n"
  },
  {
    "path": "maketreetypes.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom collections import namedtuple\nfrom cpybuilder import camel_case\n\nclass TreeType(namedtuple('TreeType', 'SYM, STRING, TYPE, NARGS')):\n    def camel_cased_string(self):\n        return camel_case(self.STRING)\n\n    # \"type\" seems to be an \"enum_tree_code_class\"; see GCC's tree.h\n\ndef iter_tree_types():\n    import re\n    f = open('autogenerated-tree-types.txt')\n    for line in f:\n        # e.g.\n        #   ERROR_MARK, \"error_mark\", tcc_exceptional, 0\n        m = re.match('(.+), (.+), (.+), (.+)', line)\n        if m:\n            yield TreeType(SYM=m.group(1),\n                           STRING=m.group(2)[1:-1],\n                           TYPE=m.group(3),\n                           NARGS=int(m.group(4)))\n        else:\n            #    print 'UNMATCHED: ', line\n            assert(line.startswith('#') or line.strip() == '')\n    f.close()\n\nclass GimpleType(namedtuple('GimpleType', 'gimple_symbol printable_name gss_symbol')):\n    def camel_cased_string(self):\n        return camel_case(self.gimple_symbol)\n\ndef iter_gimple_types():\n    import re\n    f = open('autogenerated-gimple-types.txt')\n    for line in f:\n        # e.g.\n        #   GIMPLE_ERROR_MARK, \"gimple_error_mark\", GSS_BASE\n        m = re.match('(GIMPLE_.+), (.+), (.+)', line)\n        if m:\n            yield GimpleType(gimple_symbol=m.group(1),\n                             printable_name=m.group(2)[1:-1],\n                             gss_symbol=m.group(3))\n        else:\n            #    print 'UNMATCHED: ', line\n            assert(line.startswith('#') or line.strip() == '' or line.startswith('GSS_'))\n    f.close()\n\n\n# Corresponds to a DEFGSTRUCT macro from gsstruct.def\nclass GimpleStructType(namedtuple('GimpleStructType', 'enum_value struct_name has_tree_operands')):\n    def camel_cased_string(self):\n        return camel_case(self.struct_name)\n\ndef iter_gimple_struct_types():\n    import re\n    f = open('autogenerated-gimple-types.txt')\n    for line in f:\n        # e.g.\n        #   GSS_BASE, gimple_statement_base, false\n        m = re.match('(GSS_.+), (.+), (.+)', line)\n        if m:\n            yield GimpleStructType(enum_value=m.group(1),\n                                   struct_name=m.group(2),\n                                   has_tree_operands=m.group(3))\n        else:\n            #    print 'UNMATCHED: ', line\n            assert(line.startswith('#') or line.strip() == '' or line.startswith('GIMPLE_'))\n    f.close()\n\n# Corresponds to a DEF_RTL_EXPR macro from rtl.def\nclass DefRtlExpr(namedtuple('DefRtlExpr', 'ENUM, NAME, FORMAT, CLASS')):\n    def camel_cased_string(self):\n        return 'Rtl' + camel_case(self.ENUM)\n\ndef iter_rtl_expr_types():\n    import re\n    f = open('autogenerated-rtl-types.txt')\n    for line in f:\n        # e.g.\n        #   rtl_expr: DEBUG_EXPR, \"debug_expr\", \"0\", RTX_OBJ\n        m = re.match('rtl_expr: (.+), \"(.+)\", (.*), (.+)', line)\n        if m:\n            #print m.groups()\n            yield DefRtlExpr(ENUM=m.group(1),\n                             NAME=m.group(2),\n                             FORMAT=m.group(3),\n                             CLASS=m.group(4))\n        else:\n            #print 'UNMATCHED: %r' % line\n            assert(line.startswith('#') or line.strip() == '' or line.startswith('GIMPLE_'))\n    f.close()\n"
  },
  {
    "path": "misc/fedora/bugreporting.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom collections import OrderedDict, namedtuple\nimport glob\nimport os\nimport re\nimport urllib\n\nclass NewBug:\n    def __init__(self, product, version, component, summary, comment, blocked, bug_file_loc=None):\n        self.product = product\n        self.version = version\n        self.component = component\n        self.summary = summary\n        self.comment = comment\n        self.blocked = blocked\n        self.bug_file_loc = bug_file_loc # appears as \"URL\"\n\n    def make_url(self):\n        query = OrderedDict()\n        query['product'] = self.product\n        query['version'] = self.version\n        query['component'] = self.component\n        query['short_desc'] = self.summary\n        query['comment'] = self.comment\n        query['blocked'] = self.blocked\n        query['bug_file_loc'] = self.bug_file_loc\n\n        fields = urllib.urlencode(query, True)\n        return 'https://bugzilla.redhat.com/enter_bug.cgi?%s' % fields\n\nclass Srpm(namedtuple('Srpm',\n                      ('name', 'version', 'release'))):\n    @classmethod\n    def from_path(cls, path):\n        m = re.match('(\\S+)-(\\S+)-(\\S+)', os.path.basename(path))\n        n, v, r = m.groups()\n        return cls(n, v, r)\n\n    def __str__(self):\n        return '%s-%s-%s' % (self.name, self.version, self.release)\n\nclass BugReport(namedtuple('BugReport',\n                           ('srpm', 'id', 'url'))):\n    def get_status(self):\n        return ('bug already filed for %s (%s)'\n                % (self.srpm,\n                   'https://bugzilla.redhat.com/show_bug.cgi?id=%i'\n                   % self.id))\n\nclass Unreported(namedtuple('Unreported',\n                           ('srpm', 'notes'))):\n    def get_status(self):\n        return 'bug not filed for %s (%s)' % (self.srpm, self.notes)\n\nclass BugReportDb:\n    def __init__(self):\n        self.statuses = []\n        with open('bugreports.txt') as f:\n            for line in f:\n                # Skip comment lines:\n                if line.startswith('#'):\n                    continue\n                line = line.strip()\n                if line == '':\n                    continue\n                m = re.match('^(\\S+)-(\\S+)-(\\S+)\\s+rhbz#([0-9]+)\\s+(\\S+)$', line)\n                if m:\n                    # print(m.groups())\n                    srpm = Srpm(*(m.groups()[0:3]))\n                    self.statuses.append(BugReport(srpm=srpm,\n                                               id=int(m.group(4)),\n                                               url=m.group(5)))\n                    continue\n\n                m = re.match('^(\\S+)-(\\S+)-(\\S+)\\s+(.+)$', line)\n                if m:\n                    # print(m.groups())\n                    srpm = Srpm(*(m.groups()[0:3]))\n                    self.statuses.append(Unreported(srpm=srpm,\n                                                    notes=m.group(4)))\n                    continue\n\n                raise RuntimeError('unparsed line in bugreports.txt: %r' % line)\n        if 0:\n            from pprint import pprint\n            pprint(self.statuses)\n\n    def find(self, srpmname):\n        result = []\n        for status in self.statuses:\n            if srpmname == status.srpm.name:\n                result.append(status)\n        return result\n\n    def print_summary(self):\n        global total\n        num_bugs = 0\n        fixmes = 0\n        others = 0\n        cplusplus = 0\n        swig = 0\n        cython = 0\n        for status in self.statuses:\n            if isinstance(status, BugReport):\n                num_bugs += 1\n            elif isinstance(status, Unreported):\n                if 'FIXME' in status.notes or 'TODO' in status.notes:\n                    if 'C++' in status.notes:\n                        cplusplus += 1\n                    elif 'SWIG' in status.notes:\n                        swig += 1\n                    elif 'Cython' in status.notes:\n                        cython += 1\n                    else:\n                        fixmes += 1\n                else:\n                    others += 1\n        num_src_rpms = len(glob.glob('SRPMS/*.src.rpm'))\n        total = 0\n        def print_amount(desc, count):\n            global total\n            print('* %i %s (%i%%)'\n                  % (count, desc, count * 100 / num_src_rpms))\n            total += count\n        print_amount('bugs filed for src.rpms, where the checker found genuine problems', num_bugs)\n        print_amount('src.rpms not requiring a bug to be filed', others)\n        print_amount('src.rpms waiting on fix for C++ support', cplusplus)\n        print_amount('src.rpms waiting on better SWIG support', swig)\n        print_amount('src.rpms waiting on better Cython support', cython)\n        print_amount('src.rpms requiring other followup work', fixmes)\n        print_amount('src.rpms not accounted for', num_src_rpms - total)\n        print('out of %i total src.rpms (that link against libpython2.7)'\n              % num_src_rpms)\n\n    @classmethod\n    def add_status(cls, srpm, notes):\n        with open('bugreports.txt', 'a') as f:\n            f.write('%s  %s\\n' % (srpm, notes))\n\ndef main():\n    # Test code: open the user's webbrowser to a page with various fields\n    # prepopulated, for manual review.\n    bug = NewBug(product='Fedora',\n                 version='rawhide',\n                 component='python-krbV', # arbitrary component\n                 summary='This is the summary',\n                 comment='This is a comment\\n\\nSo is this',\n                 blocked=['cpychecker'])\n    url = bug.make_url()\n    import webbrowser\n    webbrowser.open(url)\n\nif __name__ == '__main__':\n    main()\n"
  },
  {
    "path": "misc/fedora/bugreports.txt",
    "content": "# Contains a series of lines of the form\n#\n# (1) Filed bugs:\n#       FEDORA-SRPM-NAME-VERSION-RELEASE   rhbz#FEDORA-BUG-ID  RESULT-URL\n#     e.g.:\n#       \"gstreamer-python-0.10.19-2.fc15 789467 http://people.fedoraproject.org/~dmalcolm/gcc-python-plugin/2012-02-10/gstreamer-python-0.10.19-2.fc15/\"\n#\n# meaning that fedora bug 789467 covers the bugs found when running\n# gstreamer-python-0.10.19-2.fc15 under the checker, and giving the URL\n# of the full results\n#\n# (2) SRPMs that haven't had a bug filed:\n#       FEDORA-SRPM-NAME-VERSION-RELEASE   NOTES\n#     e.g.\n#       \"PyYAML-3.10-2.fc17                Only false positives\"\n\n\n\n############################################################################\n# This list is in historical order (by bug ID, and also by version of the\n# checker)\n############################################################################\n\n# 2012-02-10\ngstreamer-python-0.10.19-2.fc15      rhbz#789467      http://people.fedoraproject.org/~dmalcolm/gcc-python-plugin/2012-02-10/gstreamer-python-0.10.19-2.fc15/\n\n# 2012-02-14\npython-crypto-2.5-1.fc17             rhbz#790584      http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-14/python-crypto-2.5-1.fc17/\n\n# 2012-02-15\nsssd-1.6.2-5.fc16                    rhbz#790693      http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-15/sssd-1.6.2-5.fc16/\npython-krbV-1.0.90-4.fc15            rhbz#790973      http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-15/python-krbV-1.0.90-4.fc15/\npython-imaging-1.1.7-4.fc16          rhbz#790976      http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-15/python-imaging-1.1.7-4.fc16/\nrpm-4.9.1.2-12.fc17                  rhbz#790979      http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-15/rpm-4.9.1.2-12.fc17/\nlibxml2-2.7.8-6.fc16                 rhbz#790983      http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-15/libxml2-2.7.8-6.fc16/\n\n# 2012-02-16\nPyPAM-0.5.0-12.fc17                  rhbz#791168     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/PyPAM-0.5.0-12.fc17/\nPySBIG-0.04-8.fc17                   rhbz#791171     (not-uploaded)\nPyX-0.11.1-2.fc17                    rhbz#791175     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/PyX-0.11.1-2.fc17/\nanaconda-17.8-1.fc17                 rhbz#791180     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/anaconda-17.8-1.fc17/\nbluefish-2.2.1-2.fc17                rhbz#791186     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/bluefish-2.2.1-2.fc17/\ncanto-0.7.4-4.fc17                   rhbz#791255     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/canto-0.7.4-4.fc17/\nclaws-mail-plugins-3.8.0-4.fc17      rhbz#791264     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/claws-mail-plugins-3.8.0-4.fc17/\nclearsilver-0.10.5-17.fc17           rhbz#791278     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/clearsilver-0.10.5-17.fc17/\ncmusphinx3-0.8-10.fc17               rhbz#791280     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/cmusphinx3-0.8-10.fc17/\ndeltarpm-3.6-0.7.20110223git.fc17    rhbz#791359     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/deltarpm-3.6-0.7.20110223git.fc17/\nfont-manager-0.5.7-4.fc17            rhbz#794528     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/font-manager-0.5.7-4.fc17/\nganglia-3.1.7-5.fc17                 rhbz#794532     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-16/ganglia-3.1.7-5.fc17/\n\n# 2012-02-17\nlibewf-20100226-4.fc17               rhbz#794874     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-17/libewf-20100226-4.fc17/\n\nlibopensync-plugin-python-0.22-6.fc17  rhbz#794879   http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-17/libopensync-plugin-python-0.22-6.fc17/\n\n# 2012-02-18\nlibpwquality-1.0.0-2.fc17            rhbz#794989     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-18/libpwquality-1.0.0-2.fc17/\nlibtdb-1.2.9-14.fc17                 rhbz#794991     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-18/libtdb-1.2.9-14.fc17/\nlunatic-python-1.0.1-0.6.20090917bzr.fc17  rhbz#794995  http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-18/lunatic-python-1.0.1-0.6.20090917bzr.fc17/\nnautilus-python-1.1-1.fc17           rhbz#795001     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-18/nautilus-python-1.1-1.fc17/\nnet-snmp-5.7.1-4.fc17                rhbz#795002     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-18/net-snmp-5.7.1-4.fc17/\npostgresql-9.1.2-2.fc17              rhbz#795011     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-02-18/postgresql-9.1.2-2.fc17/\n\n# 2012-03-03\nduplicity-0.6.17-2.fc17              rhbz#799618     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-03/duplicity-0.6.17-2.fc17/\n\n# 2012-03-05\nnewt-0.52.14-2.fc17                  rhbz#800075     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/newt-0.52.14-2.fc17/\npy-radix-0.5-9.fc17                  rhbz#800085     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/py-radix-0.5-9.fc17/\npyOpenSSL-0.12-2.fc17                rhbz#800086     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/pyOpenSSL-0.12-2.fc17/\npyaudio-0.2.3-5.fc17                 rhbz#800094     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/pyaudio-0.2.3-5.fc17/\npygoocanvas-0.14.1-6.fc17            rhbz#800113     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/pygoocanvas-0.14.1-6.fc17/\npyhunspell-0.1-6.fc17                rhbz#800116     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/pyhunspell-0.1-6.fc17/\npylibacl-0.5.0-4.fc17                rhbz#800126     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/pylibacl-0.5.0-4.fc17/\npython-GeoIP-1.2.5-0.4.20090931cvs.fc15  rhbz#800134  http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-GeoIP-1.2.5-0.4.20090931cvs.fc15/\npython-alsa-1.0.25-1.fc17            rhbz#800135     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-alsa-1.0.25-1.fc17/\npython-cryptsetup-0.1.4-2.fc17       rhbz#800138     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-cryptsetup-0.1.4-2.fc17/\npython-cups-1.9.60-1.fc17            rhbz#800143     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-cups-1.9.60-1.fc17/\npython-ethtool-0.7-2.fc16            rhbz#800146     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-ethtool-0.7-2.fc16/\npython-iwlib-1.1-2.fc17              rhbz#800154     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-iwlib-1.1-2.fc17/\npython-jinja-1.2-7.fc17              rhbz#800158     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-jinja-1.2-7.fc17/\npython-kerberos-1.1-8.1.fc17         rhbz#800161     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-kerberos-1.1-8.1.fc17/\npython-libasyncns-0.7.1-6.fc17       rhbz#800167     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-libasyncns-0.7.1-6.fc17/\npython-netifaces-0.5-2.fc17          rhbz#800171     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-netifaces-0.5-2.fc17/\npython-psutil-0.4.1-2.fc17           rhbz#800177     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-psutil-0.4.1-2.fc17/\npython-schedutils-0.2-8.fc17         rhbz#800180     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-schedutils-0.2-8.fc17/\npython-virtkey-0.50-11.fc17          rhbz#800184     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-virtkey-0.50-11.fc17/\npython-yenc-0.3-10.fc17              rhbz#800187     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/python-yenc-0.3-10.fc17/\nsetroubleshoot-3.1.2-1.fc17          rhbz#800190     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/setroubleshoot-3.1.2-1.fc17/\nurjtag-0.10-2.fc17.20111215gite1a4227  rhbz#800194   http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/urjtag-0.10-2.fc17.20111215gite1a4227/\nveusz-1.14-3.fc17                    rhbz#800196     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/veusz-1.14-3.fc17/\nwireshark-1.6.5-1.fc17               rhbz#800197     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/wireshark-1.6.5-1.fc17/\nyum-metadata-parser-1.1.4-6.fc17     rhbz#800200     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-05/yum-metadata-parser-1.1.4-6.fc17/\n\n# 2012-03-27\nIo-language-20080330-8.fc17.2        rhbz#807451     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-03-27/Io-language-20080330-8.fc17.2/\n\n# 2012-04-02\ngnome-hearts-0.3-10.fc17             rhbz#809253     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-02/gnome-hearts-0.3-10.fc17/\nlibssh2-python-0.7.1-4.fc17          rhbz#809280     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-02/libssh2-python-0.7.1-4.fc17/\npython-CDDB-1.4-9.fc17               rhbz#809283     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-02/python-CDDB-1.4-9.fc17/\npython-ZODB3-3.10.5-2.fc17           rhbz#809284     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-02/python-ZODB3-3.10.5-2.fc17/\npython-adns-1.2.1-9.fc17             rhbz#809288     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-02/python-adns-1.2.1-9.fc17/\npython-alsaaudio-0.7-2.fc17          rhbz#809291     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-02/python-alsaaudio-0.7-2.fc17/\npython-arm4-1.2-5.fc17               rhbz#809292     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-02/python-arm4-1.2-5.fc17/\n\n# 2012-04-03\npython-bibtex-1.2.5-4.fc17           rhbz#809425     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-03/python-bibtex-1.2.5-4.fc17/\npython-bitarray-0.3.5-4.fc15         rhbz#809428     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-03/python-bitarray-0.3.5-4.fc15/\npython-gitdb-0.5.4-3.fc17            rhbz#809573     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-03/python-gitdb-0.5.4-3.fc17/\npython-kaa-base-0.6.0-6.fc17         rhbz#809578     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-03/python-kaa-base-0.6.0-6.fc17/\npython-kaa-imlib2-0.2.3-12.fc17      rhbz#809580     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-03/python-kaa-imlib2-0.2.3-12.fc17/\n\n# 2012-04-04\npython-kaa-metadata-0.7.7-5.fc17     rhbz#809940     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-04/python-kaa-metadata-0.7.7-5.fc17/\npython-ldap-2.4.6-2.fc17             rhbz#809943     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-04/python-ldap-2.4.6-2.fc17/\npython-markupsafe-0.11-4.fc17        rhbz#809945     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-04/python-markupsafe-0.11-4.fc17/\npython-meld3-0.6.7-5.fc17            rhbz#809949     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-04/python-meld3-0.6.7-5.fc17/\npython-shout-0.2.1-7.fc17            rhbz#809958     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-04/python-shout-0.2.1-7.fc17/\npyxattr-0.5.0-4.fc17                 rhbz#809974     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-04/pyxattr-0.5.0-4.fc17/\nrrdtool-1.4.7-5.fc17                 rhbz#809978     http://fedorapeople.org/~dmalcolm/gcc-python-plugin/2012-04-04/rrdtool-1.4.7-5.fc17/\n\n\n\n############################################################################\n# The following are grouped by rough category:\n############################################################################\n\n# Apparent perfection:\npython-gnutls-1.1.9-4.fc17           Tool appears to have run, and not to have found any errors\npython-iptables-0.1.0-3.fc17         Tool appears to have run, and not to have found any errors\npython-pysctp-0.3.1-12.fc17          Tool appears to have run, and not to have found any errors\npython-smbpasswd-1.0.1-18.fc17       Tool appears to have run, and not to have found any errors\n\n# False positives:\nMayavi-3.4.0-2.fc15                  Only false positives\nPyYAML-3.10-2.fc17                   Only false positives\nScientificPython-2.8-15.fc17         Intended behavior of PyNetCDFFile_GetVariable unknown; may well be just a false positive\ndbus-python-0.83.0-9.fc17            Only false positives\n# (I ran it on dbus-1.0.0 manually and filed a bug upstream as https://bugs.freedesktop.org/show_bug.cgi?id=47108 )\npython-pycurl-7.19.0-9.fc15          Only false positives\nbrltty-4.3-4.fc17                    Only false positives\ndracut-modules-olpc-0.6.1-2.fc17     Appear to all be false positives\nfreeradius-2.1.12-5.fc17             Appear to all be false positives\ngcc-python-plugin-0.9-1.fc17         Only false positives\nmercurial-2.1-1.fc17                 Single false positive relating to _PyBytes_Resize (aka _PyString_Resize)\nmod_scgi-1.13-5.fc15                 Only a false positive\nmx-3.2.1-2.fc17                      Appear to all be false positives\nntop-4.1.0-3.fc17                    Only false positives\nnumpy-1.6.1-2.fc17                   Only false positives (bugs in cpychecker's union-handling)\nopensips-1.7.1-3.fc17                Only false positives\npyfribidi-0.10.0-3.fc17              Only false positives\npyliblo-0.9.1-3.fc17                 Appears to be a false positive\npyrit-0.4.0-5.fc17                   Only false positives\npystatgrab-0.5-9.fc17                Only false positives\npython-4Suite-XML-1.0.2-14.fc17      Only false positives\npython-async-0.6.1-4.fc17            Appear to all be false positives\npython-cheetah-2.4.4-2.fc17          Appear to all be false positives\npython-cjson-1.0.5-7.fc15            Appear to all be false positives\npython-daap-0.7.1-7.fc15             Only false positives\npython-dulwich-0.8.2-1.fc17          Only false positives\npython-imdb-4.7-2.fc17               Only false positives\npython-sqlalchemy-0.7.5-1.fc17       Single false positive\npython-sysv_ipc-0.4.2-6.fc17         Appears to be a false positive\npython-twisted-core-11.1.0-2.fc17    Only false positives\npython-urwid-1.0.0-3.fc17            Only false positives, I think\ntre-0.8.0-5.fc17                     False positives: https://fedorahosted.org/gcc-python-plugin/ticket/36 and https://fedorahosted.org/gcc-python-plugin/ticket/40\n\n# Not worth fixing:\ncalibre-0.8.39-1.fc17                Only when module initialization fails\ncwiid-0.6.00-18.20100505gitfadf11e.fc17  Only in module initialization\nfonttools-2.3-4.fc17                 Only in module initialization\nfreeipa-2.1.90-0.1.fc17              Only in module initialization\nglade3-3.10.2-3.fc17                 Only in module initialization\nlisten-0.6.5-7.fc17                  Only in module initialization\nmirage-0.9.5.2-2.fc17                Signedness of PyArg_Parse\nPyMca-4.4.1-3.p1.fc16                Only in module initialization\npy-bcrypt-0.2-6.fc17                 Signedness of PyArg_Parse\npyfits-3.0.5-1.fc17                  Only in module initialization\npyflowtools-0.3.4.1-2.fc17           Only in module initialization\npygame-1.9.1-8.fc17                  Only in module initialization, and a minor lack NULL-without-exception\npygpgme-0.2-2.fc17                   Only in module initialization\npysendfile-2.0.0-3.fc17              Only in module initialization, and a minor lack NULL-without-exception\npython-coverage-3.5.1-0.1.b1.fc17    Leak in one error-handling path\npython-durus-3.9-2.fc14              Only in module initialization\npython-genshi-0.6-4.fc17             NULL without exception\npython-guppy-0.1.9-5.fc17            Only in module initialization\npython-lirc-0.0.5-13.fc17            leak of ref to Py_None\npython-lzo-1.08-10.fc17              Only in module initialization\npython-nss-0.12-3.fc17               Only in module initialization\npython-ogg-1.3-16                    Only in module initialization\npython-osmgpsmap-0.7.3-6.fc17        The /usr/include/pygtk-2.0/pygobject.h issue\npython-PSI-0.3-0.4.b2.fc17           NULL without exception\npython-signalfd-0.1-2.fc17           Only in module initialization, and (possibly) NULL-without-exception\npython-zfec-1.4.22-3.fc17            Only in module initialization\nqmtest-2.4.1-6.fc17                  Only in module initialization\nquodlibet-2.3.92-1.fc17              Reference leak to a module\nrdiff-backup-1.2.8-7.fc17            Only in module initialization\nsanlock-1.8-2.fc17                   Only in module initialization, and (possibly) NULL-without-exception\ntomoe-0.6.0-19.fc15                  The /usr/include/pygtk-2.0/pygobject.h issue\n\npython-psycopg2-2.4.4-1.fc17         Upstream has been running the checker directly; see https://fedorahosted.org/pipermail/gcc-python-plugin/2012-March/000229.html\n\n# FIXMEs:\nlibsemanage-2.1.6-2.fc17             FIXME: build.log has: error: File /builddir/build/SOURCES/libsemanage-rhat.patch is smaller than 13 bytes\nMySQL-python-1.2.3-3.fc16            FIXME\nPyQt4-4.8.4-4.fc16                   FIXME\npython-lxml-2.3-1.fc16               FIXME: all appear to be bugs in the checker\n\n\n# TODOs: not being built with correct flags:\n\n\n# FIXME: checker fails completely on C++, with errors of the form:\n#   Traceback (most recent call last):\n#     File \"/usr/lib/gcc/x86_64-redhat-linux/4.6.2/plugin/python2/libcpychecker/__init__.py\", line 57, in execute\n#       if not get_PyObject():\n#     File \"/usr/lib/gcc/x86_64-redhat-linux/4.6.2/plugin/python2/libcpychecker/types.py\", line 57, in get_PyObject\n#       return get_global_typedef('PyObject')\n#     File \"/usr/lib/gcc/x86_64-redhat-linux/4.6.2/plugin/python2/gccutils.py\", line 38, in get_global_typedef\n#       for v in u.block.vars:\n#   AttributeError: 'NoneType' object has no attribute 'vars'\nOpenImageIO-0.10.4-2.fc17  FIXME: C++\nadonthell-0.3.5-0.12.fc17  FIXME: C++\nafflib-3.6.15-2.fc17       FIXME: C++\nairinv-0.1.2-2.fc17        FIXME: C++\nairrac-0.2.3-2.fc17        FIXME: C++\nairsched-0.1.4-2.fc17      FIXME: C++\navogadro-1.0.3-7.fc17      FIXME: C++\nbacula-5.2.5-3.fc17        FIXME: failing in same way, even for C files\nbacula2-2.4.4-9.fc17       FIXME: failing in same way, even for C files\nboost-1.48.0-9.fc17        FIXME: C++\nboost141-1.41.0-2.fc17     FIXME: C++\ncoot-0.6.2-12.20110715svn3566.fc17  FIXME: C++\ncsound-5.13.0-7.fc17       FIXME: C++\nfife-0.3.2-11.r2.fc17      FIXME: C++\nfontmatrix-0.9.99-2.r1218.fc17  FIXME: C++\ngdcm-2.0.18-2.fc17         FIXME: C++\ngeos-3.3.2-1.fc17          FIXME: C++\ngnofract4d-3.13-2.fc15     FIXME: C++\ngnome-commander-1.2.8.15-2.fc16  FIXME: C++\ngroonga-1.3.0-2.fc17       FIXME: C++\nhugin-2011.4.0-3.fc17      FIXME: C++\nk3d-0.8.0.2-6.fc17         FIXME: C++\nkvirc-4.0.4-3.fc17  FIXME: C++\nlcms-1.19-5.fc17  FIXME: C++\nlibdigidocpp-0.3.0-13.fc17  FIXME: C++\nlibimobiledevice-1.1.1-5.fc17  FIXME: C++\nlibprelude-1.0.0-11.fc17  FIXME: C++\nmapserver-6.0.1-5.fc17  FIXME: C++\nmatahari-0.6.0-3.fc17  FIXME: C++\nnatus-0.1.5-2.fc15  FIXME: C++\nopenbabel-2.3.1-1.fc17  FIXME: C++\nopencv-2.3.1-7.fc17  FIXME: C++\nparaview-3.12.0-7.fc17  FIXME: C++\npcapy-0.10.5-10.fc17  FIXME: C++\npicard-0.16-2.fc17  FIXME: C++\npicviz-0.6-7.fc17  FIXME: C++\nplplot-5.9.9-5.svn12161.fc17  FIXME: C++\nportmidi-217-5.fc17  FIXME: C++\npybox2d-2.0.2b2-7.fc17  FIXME: C++\npycryptopp-0.5.29-3.fc17  FIXME: C++\npymilia-0.3.0-11.fc17  FIXME: C++\npymol-1.4.1-7.20110502svn3947.fc17  FIXME: C++\npython-pyside-1.1.0-1.fc17  FIXME: C++\npython-tag-0.94.8-3.fc17  FIXME: C++\nqgis-1.7.3-1.fc17  FIXME: C++\nrekall-2.4.6-18.fc17  FIXME: C++\nrmol-0.25.3-3.fc17  FIXME: C++\nroot-5.32.00-1.fc17  FIXME: C++\nscim-python-0.1.13rc1-10.fc17  FIXME: C++\nscribus-1.4.0-3.fc17  FIXME: C++\nsemantik-0.7.3-3.fc17  FIXME: C++\nsevmgr-0.2.0-1.fc17  FIXME: C++\nshiboken-1.1.0-1.fc17  FIXME: C++\nsimfqt-0.1.3-2.fc17  FIXME: C++\nstdair-0.45.1-1.fc17  FIXME: C++\ntrademgen-0.2.2-2.fc17  FIXME: C++\ntravelccm-0.5.3-2.fc17  FIXME: C++\nvigra-1.8.0-2.fc17  FIXME: C++\nvtk-5.8.0-3.fc17  FIXME: C++\nxmms2-0.8-3.fc17  FIXME: C++\nzorba-2.1.0-4.fc17  FIXME: C++\n\n# Other C++ issues:\nbro-1.5.1-4.fc17    FIXME: configure: error: C++ compiler cannot create executables\ncegui-0.7.6-2.fc17  FIXME: configure: error: C++ compiler cannot create executables\ncyphesis-0.5.26-5.fc17  FIMXE: configure: error: C++ compiler cannot create executables\ngdl-0.9.2-3.fc17    FIXME: configure: error: C++ compiler cannot create executables\nglom-1.18.6-1.fc17  FIXME: configure: error: Failed to compile test program for Python embedding.\ninkscape-0.48.2-1.fc17   FIXME: configure: error: C++ compiler cannot create executables\nnordugrid-arc-1.1.0-2.fc17  FIXME: configure: error: C++ compiler cannot create executables\n\n\n# Fortran support:\ngetdata-0.7.3-2.fc17  FIXME: configure: error: cannot compile a simple Fortran program\n\ngnatcoll-2011-6.fc17  FIXME: gnat1: fatal error: -iplugindir <dir> option not passed from the gcc driver\n\n# Other issues:\nanjuta-3.3.4-1.fc17        FIXME: build failed for some reason\nfrepple-0.9.0-3.fc17       FIXME: build failed for some reason\nkalzium-4.8.0-1.fc17       FIXME: build failed for some reason\n\ncryptsetup-1.4.1-2.fc17    FIXME: checker got confused by PyObjectResult, and some tracebacks\n\n\n# To be reported:\nPyGreSQL-4.0-4.fc17        FIXME: to be reported\nPyXML-0.8.4-27.fc17        FIXME: for some reason the HTML is missing in places\ncollectd-4.10.4-2.fc17     FIXME: to be reported\ncrossfire-1.60.0-2.fc17    FIXME: to be reported\ndistcc-3.1-5.fc17          FIXME: to be reported\nekg2-0.3.1-2.fc17          FIXME: to be reported\ngammu-1.26.1-7.fc17        FIXME: to be reported\ngmpy-1.15-1.fc17           FIXME: false positives?\n\n# Is this a false positive?\n#    return Py_BuildValue(\"N\", pygobject_new((GObject *)icon));\n# when Py_Py_BuildValue() fails\nautobuild-applet-1.0.3-14.fc17   FIXME: false positive?\n\n\n# FIXME:\n#  False positives for \"Returning (PyObject*)NULL without setting an exception\"\n#  in Cython generated code: Cython seems to call __Pyx_Raise to set an\n#  exception\n\n\nbzr-2.5-0.2.b5.fc17   FIXME: various false positives (I think) in Cython-generated code\nmpi4py-1.3-2.fc17     FIXME: Cython-generated; various false positives (I think)\npocketsphinx-0.7-4.fc17   FIXME: Cython-generated\npython-basemap-0.99.4-13.fc17  FIXME: Cython-generated\npython-gevent-0.13.6-2.fc17    FIXME: Cython-generated\npython-logbook-0.3-4.fc17      FIXME: Cython-generated\npython-meliae-0.2.0-6.fc17     FIXME: Cython-generated\npython-msgpack-0.1.12-1.fc17   FIXME: Cython-generated\npython-protocols-1.0-0.15.a0dev_r2302.fc17  FIXME: Cython-generated\npython-ruledispatch-0.5a1-0.21.svnr2618.fc17  FIXME: Cython-built\npython-shapely-1.2.13-2.fc17  FIXME: Cython-built\npython-zmq-2.1.9-4.fc17  FIXME: Cython-built\nsphinxbase-0.7-4.fc17  FIXME: Cython-built\n\nlibftdi-0.19-3.fc17   FIXME: checking if we can build the C++ wrapper... ./configure: line 382: test: we: integer expression expected\n\ngnome-python2-2.28.1-8.fc17           TODO\ngnome-python2-extras-2.25.3-38.fc17   TODO\ngnubg-0.9.0.1-14.fc17    FIXME: wrong mock config?  configure: error: Package requirements (libpng15) were not met\nguake-0.4.2-6.fc17    TODO\nh5py-2.0.1-1.fc17     TODO\niscsi-initiator-utils-6.2.0.872-18.fc17  TODO\nlibpeas-1.2.0-2.fc17  TODO\nlibtalloc-2.0.7-4.fc17 TODO\npyephem-3.7.3.4-3.fc17 TODO\n\n# Various packages using SWIG; I probably need to add some specialcasing\n# to the checker for SWIG:\nghmm-0.7-7.svn2286.fc17  TODO: SWIG-built\nibus-anthy-1.2.6-5.fc17  TODO: SWIG-built\ninput-pad-1.0.1-3.fc17   TODO: SWIG-built\nlcgdm-1.8.2-2.fc17       TODO: SWIG-built\nlibopensync-0.22-11.fc17  TODO: SWIG-built\nlibpreludedb-1.0.0-10.fc17 TODO: SWIG-built\nlibteam-0.1-3.20120130gitb5cf2a8.fc17 TODO: SWIG-built\nm2crypto-0.21.1-6.fc17     TODO: SWIG-built\nobexftp-0.23-9.fc17      TODO: SWIG-built\npycdio-0.17-3.fc17       TODO: SWIG-built\npython-chm-0.8.4-10.fc15  TODO: SWIG-built\npyifp-0.2.2-5.fc17  FIXME: SWIG-built\npypop-0.7.0-8.fc17  FIXME: SWIG-built\npython-drizzle-0.08.2-7.fc15  FIXME: SWIG-built\npython-openhpi-1.2-0.4.20090109svn6930.fc15  FIXME: SWIG-built\npython-pbs-4.3.3-1.fc17  FIXME: SWIG-built\nunbound-1.4.16-1.fc17  FIXME: SWIG-built\nvolume_key-0.3.7-3.fc17  FIXME: SWIG-built\n\nldns-1.6.12-1.fc17       FIXME: many errors\n\nmod_python-3.3.1-17.fc17  FIXME: Was only partially run\n\nmysql-workbench-5.2.37-4.fc17  FIXME: configure: error: \"BOOST library is missing\"\n\ncoccinelle-1.0.0-0.rc9.6.fc17 TODO\ngdb-7.4.50.20120120-17.fc17  TODO\nkernel-3.3.0-0.rc3.git5.1.fc17  TODO\npybluez-0.18-4.fc17  TODO\npypar-2.1.4_94-6.fc17  TODO\npython-posix_ipc-0.5.3-5.fc17  TODO\npython-ptrace-0.6.3-1.fc17  TODO: some PyArg_Parse errors\npython-tables-2.3.1-4.fc17  FIXME: tracebacks dealing with gcc.FixTruncExpr\npyxmlsec-0.3.0-10.fc17   TODO\nsonata-1.6.2.1-6.fc17   TODO: errors aren't appearing in index for some reason\npython-2.7.2-18.fc17    TODO: this one will probably require special-casing\npython-greenlet-0.3.1-9.fc17  TODO\n\n\n# TODO: I think these are completely failing to build, rather than building with no errors:\ngnumeric-1.11.1-1.fc17           TODO: appears to have failed to build\ngraphviz-2.28.0-14.fc17          TODO: appears to have failed to build\nice-3.4.2-8.fc17                 TODO: appears to have failed to build\nkig-4.8.0-1.fc17                 TODO: appears to have failed to build\nkross-interpreters-4.8.0-1.fc17  TODO: appears to have failed to build\nlibreoffice-3.5.0.3-5.fc17       TODO: appears to have failed to build\nlibselinux-2.1.9-7.fc17          TODO: appears to have failed to build\nmarble-4.8.0-6.fc17              TODO: appears to have failed to build\npolicycoreutils-2.1.10-21.fc17   TODO: appears to have failed to build\npython-pywt-0.2.0-3.fc15         TODO: appears to have failed to build\nrb_libtorrent-0.15.8-3.fc17      TODO: build failed\n\nlibldb-1.1.4-2.fc17    TODO: checker got confused by PyLdb_GetPyType\npygsl-0.9.5-6.fc17     TODO: checker got confused by PyGSL_*\n\npython-isprelink-0.1.2-11.fc17  TODO: flags do not match callback signature\n\n# /usr/include/pygtk-2.0/pygobject.h: In function 'pygobject_init':\n# usage of PyErr_Fetch\n\n# GTK/GLib abort when out of memory:\n#   http://developer.gnome.org/glib/stable/glib-Memory-Allocation.html\n# so the value in coping with MemoryError\n# exceptions in Python extensions for GLib/GTK seems limited\ngcompris-12.01-1.fc17  Not filed: pygobject.h bug, plus various GTK segfaults under low-memory conditions\ngtkparasite-0-0.8.20090120git928494e5.fc17  Not filed: pygobject.h bug, plus a GTK segfaults under low-memory conditions\n\nlibdmtx-0.7.2-6.fc17 FIXME: tracebacks:\n\nCython-0.15.1-2.fc17   all false positives?\nIo-language-20080330-8.fc17.2  FIXME: C++\nPyAmanith-0.3.35-12.fc17  FIXME: C++\ngdal-1.7.3-12.fc17  FIXME: C++\nmypaint-1.0.0-2.fc17  FIXME: C++\npyicu-1.2-2.fc17  FIXME: C++\npykde4-4.8.0-1.fc17  FIXME: did not see rpmbuild -bb in build.log\npyodbc-2.1.5-6.fc17  FIXME: C++\npyparted-3.8-3.fc17  FIXME: did not see rpmbuild -bb in build.log\npython-kaa-display-0.1.0-6.fc17 FIXME: various errors during build\npython-matplotlib-1.0.1-18.fc17  FIXME: C++\npython-mecab-0.991-2.fc17  FIXME: did not see rpmbuild -bb in build.log\npython-poppler-qt4-0.16.2-3.fc17  FIXME: C++\npython-smbc-1.0.11-2.fc17  FIXME: traceback during build\npython-twisted-runner-11.1.0-2.fc17  FIXME: did not see rpmbuild -bb in build.log\npython-vorbis-1.5-0.10.a   FIXME: PyCObject_Import\npython-zope-i18nmessageid-3.5.3-5.fc17  FIXME: traceback during build\npywcs-1.11-1.fc17  FIXME: did not see rpmbuild -bb in build.log\nsetools-3.3.7-21.fc17  FIXME: did not see rpmbuild -bb in build.log\nsuperkaramba-4.8.0-1.fc17  FIXME: did not see rpmbuild -bb in build.log\ntexworks-0.4.3-4.fc17  FIXME: C++\nvegastrike-0.5.1-0.6.beta1.2.fc17  FIXME: C++\nwxPython-2.8.12.0-2.fc17  FIXME: C++\nxchat-gnome-0.26.2-6.git40c5bf988.fc17  FIXME: build failed\nxulrunner-python-2.0-1.20110406hg.fc16  FIXME: C++\nzarafa-7.0.4-2.fc17  FIXME: build failed\nzinnia-0.06-11.fc17  FIXME: C++\nekg-1.8-0.9.rc1.fc17  FIXME: 10 tracebacks during build\nfontforge-20110222-7.fc17  FIXME: 50 tracebacks during build\nfuse-python-0.2.1-4.fc17  FIXME: 8 tracebacks during build # NotImplementedError: Don't know how to cope with exprcode: <type 'gcc.FixTruncExpr'> (<type 'gcc.FixTruncExpr'>) at fuseparts/_fusemodule.c:245\nlibtevent-0.9.15-1.fc17  FIXME: 5 tracebacks during build\nlinkchecker-6.5-4.fc17   FIXME: yacc-generated code breaks HTML reports\nmod_wsgi-3.3-2.fc17 TODO\npyliblzma-0.5.3-6.fc17  FIXME: 4 tracebacks during build\npymongo-1.11-2.fc17  FIXME: 5 tracebacks during build\npython-Levenshtein-0.10.1-14.fc17  FIXME: 22 tracebacks during build\npython-Traits-3.5.0-3.fc17  FIXME: breaks my bug-reporting script\npython-biopython-1.58-2.fc17  FIXME: traceback during build\npython-blist-1.3.4-1.fc16  FIXME: apparently lots of borrowed refs\npython-cvxopt-1.1.4-2.fc17  FIXME: 5 tracebacks during build: gcc.FloatExpr\npython-dmidecode-3.10.13-3.fc15  FIXME: 10 tracebacks during build: gcc.FloatExpr\npython-gevent-0.13.6-2.fc17  FIXME: 7 tracebacks during build\npython-igraph-0.5.4-4.fc17  FIXME: 6 tracebacks during build: gcc.FloatExpr\npython-kinterbasdb-3.3.0-4.fc17  FIXME: 9 tracebacks during build; mostly gcc.FloatExpr\npython-numeric-24.2-17.fc17  FIXME: 35 tracebacks during build: mostly  gcc.FloatExpr plus some conversions\npython-numexpr-2.0.1-1.fc17  FIXME: 15 tracebacks during build: gcc.FloatExpr, gcc.RdivExpr and others\npython-pebl-1.0.2-8.fc17  FIXME: 39 tracebacks during build, though many are unrelated to the plugin\npython-pylibmc-1.2.0-5.20110805gitf01c31.fc17  FIXME: 9 tracebacks during build\npython-quixote-2.4-15.fc17 TODO\npython-reportlab-2.5-4.fc17  FIXME: 6 tracebacks during build: gcc.FloatExpr and others\npython-simplejson-2.3.0-2.fc17 TODO\npython-simpleparse-2.1.1-4.fc17 TODO\npython-sqlite2-2.3.5-5.fc17  TODO: build failed\npython-storm-0.19-2.fc17  TODO\npython-sybase-0.39-8.fc17 TODO\npython-zope-interface-3.7.0-1.fc17  TODO: lots of borrowed refs?\npython-zope-proxy-3.6.1-6.fc17      TODO: lots of borrowed refs?\nrpy-2.2.4-2.fc17  FIXME: too many errors - breaks my bug-reporting script\nsK1-0.9.1-0.5.pre_rev730.fc17 TODO\nsamba4-4.0.0-37.alpha16.fc17  FIXME: 5 tracebacks during build\nscipy-0.10.0-2.fc17  FIXME: 5 tracebacks during build\nsmart-1.3.1-68.fc17  TODO\nsyck-0.61-16.fc17 TODO\ntennix-1.0-7.fc17  FIXME: 5 tracebacks during build\nthunarx-python-0.2.3-5.fc17  TODO\nuniconvertor-1.1.4-5.fc17 TODO\nvim-7.3.444-1.fc17  FIXME: 8 tracebacks during build\nweechat-0.3.6-2.fc17  TODO\nxchat-2.8.8-10.fc16  FIXME: for some reason the triage tool isn't finding the errors\nxen-4.1.2-8.fc17  TODO\n"
  },
  {
    "path": "misc/fedora/fake-g++.py",
    "content": "#!/usr/bin/env python\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Harness for forcibly invoking GCC with the cpychecker Python code within the python\n# plugin\n# \n# This code assumes that it is /usr/bin/g++ and that the real GCC has been\n# moved to /usr/bin/the-real-g++\n# \n# (This code runs under the regular Python interpreter, not within gcc)\n\nimport subprocess\nimport sys\n\n# Enable the refcount-checker when running via this script\n#\n# We would use the regular keyword argument syntax:\n#   verify_refcounting=True\n# but unfortunately gcc's option parser seems to not be able to cope with '='\n# within an option's value.  So we do it using dictionary syntax instead:\ncmd = 'from libcpychecker import main; main(**{\"verify_refcounting\":True})'\n\nargs = ['the-real-g++',\n        '-fplugin=python2',\n\t'-fplugin-arg-python2-command=%s' % cmd]\nargs += sys.argv[1:] # (the args we didn't consume)\n\n# Beware of quoting: if the command is quoted within the Popen call, then\n# Python interprets it as a string literal, and does nothing.\n#\n# But if invoking from a shell, you need quotes aroung the command\n#\n# To add to the fun, \"gcc -v\" emits it in unquoted form,\n# which will need quotes added\n\nif 0:\n    print(' '.join(args))\np = subprocess.Popen(args)\n\ntry:\n    r = p.wait()\nexcept KeyboardInterrupt:\n    r = 1\nsys.exit(r)\n"
  },
  {
    "path": "misc/fedora/fake-gcc.py",
    "content": "#!/usr/bin/env python\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Harness for forcibly invoking GCC with the cpychecker Python code within the python\n# plugin\n# \n# This code assumes that it is /usr/bin/gcc and that the real GCC has been\n# moved to /usr/bin/the-real-gcc\n# \n# (This code runs under the regular Python interpreter, not within gcc)\n\nimport subprocess\nimport sys\n\n# Enable the refcount-checker when running via this script\n#\n# We would use the regular keyword argument syntax:\n#   verify_refcounting=True\n# but unfortunately gcc's option parser seems to not be able to cope with '='\n# within an option's value.  So we do it using dictionary syntax instead:\ncmd = 'from libcpychecker import main; main(**{\"verify_refcounting\":True})'\n\nargs = ['the-real-gcc',\n        '-fplugin=python2',\n\t'-fplugin-arg-python2-command=%s' % cmd]\nargs += sys.argv[1:] # (the args we didn't consume)\n\n# Beware of quoting: if the command is quoted within the Popen call, then\n# Python interprets it as a string literal, and does nothing.\n#\n# But if invoking from a shell, you need quotes aroung the command\n#\n# To add to the fun, \"gcc -v\" emits it in unquoted form,\n# which will need quotes added\n\nif 0:\n    print(' '.join(args))\np = subprocess.Popen(args)\n\ntry:\n    r = p.wait()\nexcept KeyboardInterrupt:\n    r = 1\nsys.exit(r)\n"
  },
  {
    "path": "misc/fedora/get-srpms.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport os\nimport re\nfrom subprocess import Popen, PIPE\nimport urllib2\n\ndef get_srpms_for_installed_rpms():\n    p = Popen(['rpm',\n               '-q',\n               '--qf=%{sourcerpm}\\n',\n               '--whatrequires',\n               'libpython2.7.so.1.0()(64bit)'],\n              stdout=PIPE)\n    out, err = p.communicate()\n    return sorted(set(out.splitlines()))\n\nfrom lxml import etree\nclass ElementWrapper:\n    def __init__(self, node):\n        self._node = node\n\n    # print(etree.tostring(doc, pretty_print=True))\n\n    def __str__(self):\n        return str(self._node)\n\ndef mktag_ns(raw):\n    return '{http://linux.duke.edu/metadata/common}%s' % raw\n\ndef mktag_rpm(raw):\n    return '{http://linux.duke.edu/metadata/rpm}%s' % raw\n\nclass RpmEntry(ElementWrapper):\n    def get_name(self):\n        return self._node.get('name')\n\nclass Package(ElementWrapper):\n    def get_name(self):\n        return self._node.find(mktag_ns('name')).text\n\n    def get_location(self):\n        return self._node.find(mktag_ns('location')).get('href')\n\n    def get_format_node(self):\n        return self._node.find(mktag_ns('format'))\n    \n    def get_requires(self):\n        # Get a list of RpmEntry\n        fmt_node = self.get_format_node()\n        requires_node = fmt_node.find(mktag_rpm('requires'))\n        if requires_node is None:\n            return []\n        return [RpmEntry(node)\n                for node in requires_node.iterchildren(tag=mktag_rpm('entry'))]\n\n    def has_requirement_by_name(self, pkgname):\n        for req in self.get_requires():\n            if pkgname == req.get_name():\n                return True\n\n    def get_source_rpm(self):\n        fmt_node = self.get_format_node()\n        return fmt_node.find(mktag_rpm('sourcerpm')).text\n\nclass DocWrapper:\n    def __init__(self, doc):\n        self._doc = doc\n\nclass YumPrimary(DocWrapper):\n    @classmethod\n    def from_file(cls, f):\n        doc = etree.parse(f)\n        return cls(doc)\n\n    def get_metadata(self):\n        return ElementWrapper(self._doc.getroot())\n\n    def get_packages(self):\n        for packagenode in self._doc.getroot():\n            yield Package(packagenode)\n\ndef get_src_rpms():\n    RPMS_FILENAME='SRPMS/9af2863661ee18b2fc70d804aabc8b316a8fc7bf8828d1e1d9a728d27da88939-primary.xml.gz'\n    # downloaded from:\n    #   http://download.fedora.devel.redhat.com/pub/fedora/linux/development/17/x86_64/os/repodata/9af2863661ee18b2fc70d804aabc8b316a8fc7bf8828d1e1d9a728d27da88939-primary.xml.gz\n    result = set()\n    yp = YumPrimary.from_file(RPMS_FILENAME)\n    for pkg in yp.get_packages():\n        if pkg.has_requirement_by_name('libpython2.7.so.1.0()(64bit)'):\n            # print '%s is linked against python' % pkg.get_name()\n            result.add(pkg.get_source_rpm())\n    return sorted(result)\n\n\nsrc_rpms = get_src_rpms()\n\nfrom pprint import pprint\npprint(src_rpms)\nprint(len(src_rpms))\n\nsrpmnames = []\nfor src_rpm in src_rpms:\n    m = re.match('(\\S+)-(\\S+)-(\\S+).src.rpm', src_rpm)\n    assert m\n    n, v, r = m.groups()\n    srpmnames.append(n)\n\npprint(srpmnames)\n\nSRPMS_FILENAME='SRPMS/2473adda4950c13396b0f9e1424a6310ad96ffc34368b53f50617eab7627ae8a-primary.xml.gz'\n# downloaded from:\n#   http://download.fedora.devel.redhat.com/pub/fedora/linux/development/17/source/SRPMS/repodata/2473adda4950c13396b0f9e1424a6310ad96ffc34368b53f50617eab7627ae8a-primary.xml.gz\n\nBASEURL='http://download.fedora.devel.redhat.com/pub/fedora/linux/development/17/source/SRPMS/'\n\nyp = YumPrimary.from_file(SRPMS_FILENAME)\nfor pkg in sorted(yp.get_packages(),\n                  lambda x, y: cmp(x.get_name(), y.get_name())):\n    if pkg.get_name() in srpmnames:\n        url = BASEURL + pkg.get_location()\n        print url\n        downloadpath = os.path.join('SRPMS', os.path.basename(url))\n        if not os.path.exists(downloadpath):\n            print downloadpath\n            p = Popen(['wget', url, '-O', downloadpath])\n            p.communicate()\n"
  },
  {
    "path": "misc/fedora/makeindex.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Walk a directory hierarchy looking for *-refcount-errors.html files,\n# building an index.html linking to them all\n\nfrom collections import namedtuple\nimport os\nimport re\n\nfrom BeautifulSoup import BeautifulSoup\n\nfrom bugreporting import BugReportDb, Srpm\n\nclass ErrorReport(namedtuple('ErrorReport',\n                             ('htmlpath', 'htmlid', 'filename', 'function', 'errmsg', 'htmlpre'))):\n    def href(self):\n        return '%s#%s' % (self.htmlpath, self.htmlid)\n\n    def contains_failure(self):\n        # Does this appear to be within an error-handling path?\n        if 0: #self.function == 'clawsmail_compose_new':\n            if self.errmsg == 'calling PyObject_Call with NULL as argument 1 (class) at composewindowtype.c:523':\n                print('htmlpre: %s' % self.htmlpre)\n        m = re.match('.*when (\\S+) fails.*',\n                     str(self.htmlpre),\n                     re.MULTILINE|re.DOTALL)\n        if m:\n            #print m.groups()\n            return True\n        else:\n            #print 'not matched'\n            return False\n\n    def is_within_initialization(self):\n        # Does this appear to be within an initialization function?\n        # (and thus called only once)\n        htmlpre = str(self.htmlpre)\n\n        # The following functions typically only appear in one-time\n        # initialization code:\n        initfns = (\n            # there are various init functions with this prefix:\n            'Py_InitModule',\n            # Other init functions:\n            'PyErr_NewException', 'PyType_Ready', 'PyCFunction_NewEx',\n            'PyImport_ImportModule',\n            )\n\n        for fnname in initfns:\n            if fnname in htmlpre:\n                return True\n        return False\n\n    def might_be_borrowed_ref(self):\n        htmlpre = str(self.htmlpre)\n\n        if 'new ref from (unknown)' in htmlpre:\n            # The reference that we're complaining about comes from\n            # an unknown function, for which we assumed it was a new\n            # ref - but it could be a borrowed ref, in which case it isn't\n            # a problem\n            return True\n\n        if 'new ref from call through function pointer' in htmlpre:\n            # Similar: we can't know the semantics of function pointers\n            # in user-supplied code:\n            return True\n\n        return False\n\ndef get_errors_from_file(htmlpath):\n    \"\"\"\n    Scrape metadata from out of a -refcount-errors.html file,\n    yielding a sequence of ErrorReport\n    \"\"\"\n    with open(htmlpath) as f:\n        soup = BeautifulSoup(f)\n        # Look within top-level <div> elements for result summaries that\n        # look like this:\n        #  <div id=\"report-0\">\n        #   <table>\n        #     <tr><td>File:</td> <td><b>gstmodule.c</b></td></tr>\n        #     <tr><td>Function:</td> <td><b>init_gst</b></td></tr>\n        #     <tr><td>Error:</td> <td><b>ob_refcnt of new ref from (unknown) pygobject_init is 1 too high</b></td></tr>\n        #   </table>\n        if not soup.html:\n            # broken file: error during output of HTML?\n            return\n        for div in soup.html.body.findAll('div'):\n            table = div.table\n            if not table:\n                continue\n            #print div['id']\n            #print 'div: %r' % div\n            rows = table('tr')\n            def get_second_col(row):\n                return row('td')[1].b.string\n            # Capture the marked up source code and notes from the report:\n            htmlpre = div.div.pre\n            \n            errmsg = get_second_col(rows[2])\n            if not errmsg:\n                continue\n            yield ErrorReport(htmlpath=htmlpath,\n                              htmlid=div['id'],\n                              filename=get_second_col(rows[0]),\n                              function = get_second_col(rows[1]),\n                              errmsg = errmsg,\n                              htmlpre = htmlpre)\n\nclass Severity(namedtuple('Severity', ('priority', 'title', 'description'))):\n    \"\"\"\n    priority: the int values are in asending severity (so that e.g. priority 5\n    is more severe than severity 4).  This should give us a useful sort order\n    for Severity instances\n    \"\"\"\n\n(PRIORITY__RETURNING_NULL_WITHOUT_SETTING_EXCEPTION,\n PRIORITY__POSSIBLE_REFERENCE_LEAK,\n PRIORITY__REFERENCE_LEAK_OF_SINGLETON,\n PRIORITY__SEGFAULT_IN_ERROR_HANDLING,\n PRIORITY__REFERENCE_LEAK_IN_INITIALIZATION,\n PRIORITY__REFERENCE_COUNT_TOO_LOW_IN_INITIALIZATION,\n PRIORITY__REFERENCE_LEAK_IN_NORMAL_USE,\n PRIORITY__REFERENCE_COUNT_TOO_LOW_IN_NORMAL_USE,\n PRIORITY__SEGFAULT_IN_NORMAL_USE,\n PRIORITY__UNCLASSIFIED,\n ) = range(10)\n\nclass Triager:\n    \"\"\"\n    Classify ErrorReport instances into various severity levels, identified by\n    Severity instances\n    \"\"\"\n    def _classify_segfault(self, report):\n        if report.contains_failure():\n            return Severity(priority=PRIORITY__SEGFAULT_IN_ERROR_HANDLING,\n                            title='Segfaults within error-handling paths',\n                            description='<p>Code paths in error-handling that will lead to a segmentatation fault (e.g. under low memory conditions)</p>')\n        else:\n            return Severity(priority=PRIORITY__SEGFAULT_IN_NORMAL_USE,\n                            title='Segfaults in normal paths',\n                            description='<p>Code paths that will lead to a segmentatation fault</p>')\n\n    def classify(self, report):\n        #print('report: %r' % (dir(report), ))\n        #print('report.errmsg: %r' % report.errmsg)\n        if report.errmsg is None:\n            return Severity(priority=PRIORITY__UNCLASSIFIED,\n                            title='Unclassified errors',\n                            description='''\n<p>The triager didn't know how to classify these ones</p>\n''')\n        m = re.match('ob_refcnt of (.+) too high', report.errmsg)\n        if m:\n            if report.might_be_borrowed_ref():\n                return Severity(priority=PRIORITY__POSSIBLE_REFERENCE_LEAK,\n                                title='Possible reference leaks',\n                                description=(\"\"\"\n<p>Code paths in which the reference count of an object might too large - but in\nwhich the reference in question came from a function not known to the\nanalyzer.</p>\n\n<p>The analyzer assumes such references are new references, but if the function\nreturns a borrowed reference instead, it's probably not a bug</p>\"\"\"\n                                             ))\n            if 'PyBool_FromLong' in report.errmsg:\n                is_singleton = True\n            else:\n                is_singleton = False\n            if is_singleton:\n                return Severity(priority=PRIORITY__REFERENCE_LEAK_OF_SINGLETON,\n                                title='Reference leaks of a singleton',\n                                description=('''\n<p>Code paths in which the reference count of a singleton object will be\nleft too large.</p>\n\n<p>Technically incorrect, but unlikely to cause problems</p>\n'''\n                                             ))\n            else:\n                if report.is_within_initialization():\n                    return Severity(priority=PRIORITY__REFERENCE_LEAK_IN_INITIALIZATION,\n                                    title='Reference leak within initialization',\n                                    description='''\n<p>Code paths in which the reference count of an object is left too high,\nbut within an initialization routine, and thus likely to only happen\nonce</p>''')\n                else:\n                    return Severity(priority=PRIORITY__REFERENCE_LEAK_IN_NORMAL_USE,\n                                    title='Reference leaks',\n                                    description='''\n<p>Code paths in which the reference count of an object is left too high,\nleading to memory leaks</p>''')\n        m = re.match('ob_refcnt of (.+) too low', report.errmsg)\n        if m:\n            if report.is_within_initialization():\n                return Severity(priority=PRIORITY__REFERENCE_COUNT_TOO_LOW_IN_INITIALIZATION,\n                                title='Reference count too low within an initialization routine',\n                                description='''\n<p>Code paths in which the reference count of an object is too low, but\nwithin an initialization routine, and thus likely to only happen once</p>\n'''\n                                )\n            else:\n                return Severity(priority=PRIORITY__REFERENCE_COUNT_TOO_LOW_IN_NORMAL_USE,\n                                title='Reference count too low',\n                                description='''\n<p>Code paths in which the reference count of an object is left too low.\nThis could lead to the object being deallocated too early, triggering\nsegfaults when later accessed.   Over repeated calls, these errors could\naccumulate, increasing the likelihood of a segfault.</p>''')\n\n        if report.errmsg == 'returning (PyObject*)NULL without setting an exception':\n            return Severity(priority=PRIORITY__RETURNING_NULL_WITHOUT_SETTING_EXCEPTION,\n                            title='Returning (PyObject*)NULL without setting an exception',\n                            description='''\n<p>These messages are often false-positives: the analysis tool has no knowledge\nabout internal API calls that can lead to an exception being set''')\n\n        m = re.match('calling (.+) with NULL as argument (.*)', report.errmsg)\n        if m:\n            return self._classify_segfault(report)\n\n        m = re.match('dereferencing NULL (.*)', report.errmsg)\n        if m:\n            return self._classify_segfault(report)\n\n        m = re.match('reading from deallocated memory (.*)', report.errmsg)\n        if m:\n            return self._classify_segfault(report)\n\n        return Severity(priority=PRIORITY__UNCLASSIFIED,\n                        title='Unclassified errors',\n                        description='''\n<p>The triager didn't know how to classify these ones</p>\n''')\n\nclass BuildLog:\n    # Wrapper around a \"build.log\" scraped from the mock build\n    def __init__(self, path):\n        self.unimplemented_functions = set()\n        self.cplusplus_failure = False\n        self.seen_rpmbuild = False\n        self.num_tracebacks = 0\n\n        buildlog = os.path.join(path, 'build.log')\n        with open(buildlog) as f:\n            for line in f.readlines():\n                if 0:\n                    print(repr(line))\n                m = re.match('NotImplementedError: not yet implemented: (\\S+)',\n                             line)\n                if m:\n                    self.unimplemented_functions.add(m.group(1))\n\n                # Am seeing errors of this form:\n                #  The C++ compiler \"/usr/bin/c++\" is not able to compile a simple test\n                #  program.\n                #  It fails with the following output:\n                #   Change Dir: /builddir/build/BUILD/airrac-0.2.3/CMakeFiles/CMakeTmp\n                #  \n                #  Run Build Command:/usr/bin/gmake \"cmTryCompileExec/fast\"\n                #  /usr/bin/gmake -f CMakeFiles/cmTryCompileExec.dir/build.make\n                #  CMakeFiles/cmTryCompileExec.dir/build\n                #  gmake[1]: Entering directory\n                #  `/builddir/build/BUILD/airrac-0.2.3/CMakeFiles/CMakeTmp'\n                #  /usr/bin/cmake -E cmake_progress_report\n                #  /builddir/build/BUILD/airrac-0.2.3/CMakeFiles/CMakeTmp/CMakeFiles 1\n                #  Building CXX object CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o\n                #  /usr/bin/c++ -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions\n                #  -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -o\n                #  CMakeFiles/cmTryCompileExec.dir/testCXXCompiler.cxx.o -c\n                #  /builddir/build/BUILD/airrac-0.2.3/CMakeFiles/CMakeTmp/testCXXCompiler.cxx\n                #  Traceback (most recent call last):\n                #    File \"/usr/bin/the-real-g++\", line 53, in <module>\n                #      p = subprocess.Popen(args)\n                #    File \"/usr/lib64/python2.7/subprocess.py\", line 679, in __init__\n                #      errread, errwrite)\n                #    File \"/usr/lib64/python2.7/subprocess.py\", line 1130, in _execute_child\n                #      self.pid = os.fork()\n                #  OSError: [Errno 11] Resource temporarily unavailable\n                if 'The C++ compiler \"/usr/bin/c++\" is not able to compile a simple test' in line:\n                    self.cplusplus_failure = 'The C++ compiler \"/usr/bin/c++\" is not able to compile a simple test'\n\n                if not self.cplusplus_failure:\n                    if 'OSError: [Errno 11] Resource temporarily unavailable' in line:\n                        self.cplusplus_failure = 'OSError: [Errno 11] Resource temporarily unavailable'\n\n                if 'configure: error: C++ compiler cannot create executables' in line:\n                    self.cplusplus_failure = 'configure: error: C++ compiler cannot create executables'\n\n                if 'rpmbuild -bb' in line:\n                    self.seen_rpmbuild = True\n\n                if line.startswith('Traceback '):\n                    self.num_tracebacks += 1\n\nclass Index:\n    def __init__(self, path, title):\n        self.reported = False\n        self.seen_SWIG = False\n        self.seen_Cython = False\n\n        outpath = os.path.join(path, 'index.html')\n        with open(outpath, 'w') as f:\n            f.write('<html><head><title>%s</title></head>\\n' % title)\n            f.write('  <body>\\n')\n\n            f.write('  <h1>%s</h1>\\n' % title)\n            f.write(\"  <p>This is a summary of errors seen when compiling with <a href='https://fedorahosted.org/gcc-python-plugin/'>an experimental static analysis tool</a></p>\")\n            f.write('  <p>Raw build logs can be seen <a href=\"build.log\">here</a></p>\\n')\n\n            buildlog = BuildLog(path)\n\n            if buildlog.cplusplus_failure:\n                f.write('    <p>C++ failure: %s</p>\\n' % buildlog.cplusplus_failure)\n                srpm = Srpm.from_path(path)\n                BugReportDb.add_status(srpm, \"FIXME: C++ failure: %s\" % buildlog.cplusplus_failure)\n                self.reported = True\n            \"\"\"\n            if not buildlog.seen_rpmbuild:\n                f.write('    <p>Did not see rpmbuild -bb in build.log</p>\\n')\n                srpm = Srpm.from_path(path)\n                BugReportDb.add_status(srpm, \"FIXME: did not see rpmbuild -bb in build.log\")\n                self.reported = True\n                return\n            \"\"\"\n\n            # Gather the ErrorReport by severity\n            triager = Triager()\n\n            # mapping from Severity to list of ErrorReport\n            self.severities = {}\n            self.num_reports = 0\n\n            for dirpath, dirnames, filenames in os.walk(path):\n                #print dirpath, dirnames, filenames\n                for filename in filenames:\n                    if filename.endswith('-refcount-errors.html'):\n                        #print '  ', os.path.join(dirpath, filename)\n                        htmlpath = os.path.join(dirpath, filename)\n                        for er in get_errors_from_file(htmlpath):\n                            if er is None:\n                                continue\n                            #print(er.filename)\n                            #print(er.function)\n                            #print(er.errmsg)\n                            sev = triager.classify(er)\n                            #print(sev)\n                            if sev in self.severities:\n                                self.severities[sev].append(er)\n                            else:\n                                self.severities[sev] = [er]\n\n            for sev, issues in self.iter_severities():\n                f.write('    <h2>%s</h2>\\n' % sev.title)\n                f.write('    %s\\n' % sev.description)\n                f.write('    <table>\\n')\n                for er in issues:\n                    self.num_reports += 1\n                    href = os.path.relpath(er.href(), path)\n                    f.write('      <tr> <td><a href=%s>%s</a></td> <td><a href=%s>%s</a></td> <td><a href=%s>%s</a></td> </tr>'\n                            % (href, er.filename,\n                               href, er.function,\n                               href, er.errmsg))\n                f.write('    </table>\\n')\n\n                if 'SWIG' in er.function or 'SWIG' in er.errmsg:\n                    self.seen_SWIG = True\n\n                if '__pyx' in er.function or '__pyx' in er.errmsg:\n                    self.seen_Cython = True\n\n            if buildlog.unimplemented_functions:\n                f.write('    <h2>Implementation notes for gcc-with-cpychecker</h2>\\n')\n                f.write('    <p>The following \"Py\" functions were used but aren\\'t\\n'\n                        '       yet explicitly handled by gcc-with-cpychecker</p>\\n'\n                        '    <ul>\\n')\n                for fnname in sorted(buildlog.unimplemented_functions):\n                    f.write('      <li><pre>%s</pre></li>\\n' % fnname)\n                f.write('    </ul>\\n')\n\n            if self.num_reports == 0 and not buildlog.unimplemented_functions:\n                f.write('    <p>Nothing was reported; did the plugin run correctly?\\n')\n\n            f.write('  </body>\\n')\n            f.write('</html>\\n')\n\n            if self.seen_Cython:\n                if not self.reported:\n                    srpm = Srpm.from_path(path)\n                    BugReportDb.add_status(srpm, \"FIXME: Cython-built\")\n                    self.reported = True\n\n            if self.seen_SWIG:\n                if not self.reported:\n                    srpm = Srpm.from_path(path)\n                    BugReportDb.add_status(srpm, \"FIXME: SWIG-built\")\n                    self.reported = True\n\n            if buildlog.num_tracebacks >= 5:\n                if not self.reported:\n                    srpm = Srpm.from_path(path)\n                    BugReportDb.add_status(srpm,\n                                           (\"FIXME: %i tracebacks during build\"\n                                            % buildlog.num_tracebacks))\n                    self.reported = True\n\n    def iter_severities(self):\n        for sev in sorted(self.severities.keys())[::-1]:\n            yield sev, self.severities[sev]\n\ndef main():\n    # locate .html\n    # iterate over toplevel in \"LOGS\":\n    for resultdir in os.listdir('LOGS'):\n        resultpath = os.path.join('LOGS', resultdir)\n        print(resultpath)\n        index = Index(resultpath, 'Errors seen in %s' % resultdir)\n\nif __name__ == '__main__':\n    main()\n\n"
  },
  {
    "path": "misc/fedora/mass-rebuild.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport commands\nimport datetime\nimport glob\nimport os\nimport re\nimport shutil\nfrom subprocess import check_output, Popen, PIPE\nimport sys\nimport webbrowser\n\nfrom bugreporting import NewBug, BugReportDb\nfrom makeindex import Index\n\ndef nvr_from_srpm_path(path):\n    filename = os.path.basename(path)\n    m = re.match('(.+)-(.+)-(.+).src.rpm', filename)\n    name, version, release = m.groups()\n    return name, version, release\n\ndef get_local_python_srpms():\n    \"\"\"\n    Extract a list of srpm names that require python 2 to build\n    \"\"\"\n    cmd = ['rpm',\n           '-q',\n           '--qf=%{sourcerpm}\\\\n',\n           '--whatrequires',\n           'libpython2.7.so.1.0()(64bit)']\n    out = check_output(cmd)\n    result = set()\n    for line in out.splitlines():\n        m = re.match('(.+)-(.+)-(.+)', line)\n        name, version, release = m.groups()\n        result.add(name)\n    return sorted(result)\n\n#print(get_local_python_srpms())\n#sys.exit(0)\n\n\"\"\"\nfor srpmname in get_local_python_srpms():\n    cmd = ['mock',\n           '-r', 'fedora-16-x86_64',\n           '--scm-enable',\n           '--scm-option', 'method=git',\n           '--scm-option', 'git_get=\"git clone SCM_BRN git://pkgs.fedoraproject.org/SCM_PKG.git SCM_PKG\"',\n           '--scm-option', 'package=%s' % srpmname,\n           '-v']\n    p = Popen(cmd)\n    p.communicate()\n\"\"\"\n\ndef get_result_dir(srpmpath):\n    n, v, r = nvr_from_srpm_path(srpmpath)\n    resultdir = 'LOGS/%s-%s-%s' % (n, v, r)\n    return resultdir\n\ndef local_rebuild_of_srpm_in_mock(srpmpath, mockcfg):\n    \"\"\"\n    Rebuild the given SRPM locally within mock, injecting the cpychecker\n    code in RPM form; gathering the results to a subdir within \"LOGS\"\n    \"\"\"\n    def run_mock(commands, captureOut=False, captureErr=False, failOnError=True):\n        cmds = ['mock', '-r', mockcfg, '--disable-plugin=ccache'] + commands\n        print('--------------------------------------------------------------')\n        print(' '.join(cmds))\n        print('--------------------------------------------------------------')\n        args = {}\n        if captureOut:\n            args['stdout'] = PIPE\n        if captureErr:\n            args['stderr'] = PIPE\n        p = Popen(cmds, **args)\n        out, err = p.communicate()\n        if p.returncode != 0 and failOnError:\n            msg = 'mock failed: return code %i' % p.returncode\n            if captureOut:\n                msg += 'stdout: %s' % out\n            if captureErr:\n                msg += 'stderr: %s' % err\n            raise RuntimeError(msg)\n        return out, err\n\n    resultdir = get_result_dir(srpmpath)\n    if os.path.exists(resultdir):\n        shutil.rmtree(resultdir)\n    os.mkdir(resultdir)\n        \n    # Experimenting with the script is much faster if we remove the --init here:\n    if 1:\n        run_mock(['--init'])\n    run_mock(['--installdeps', srpmpath])\n\n    # Install the pre-built plugin:\n    run_mock(['install', PLUGIN_PATH]) # this doesn't work when cleaned: can't open state.log\n\n    # Copy up latest version of the libcpychecker code from this working copy\n    # overriding the copy from the pre-built plugin:\n    if 1:\n        HACKED_PATH='/usr/lib/gcc/x86_64-redhat-linux/4.6.3/plugin/python2'\n        # FIXME: ^^ this will need changing\n        for module in glob.glob('../../libcpychecker/*.py'):\n            run_mock(['--copyin', module, os.path.join(HACKED_PATH, 'libcpychecker')])\n        run_mock(['--copyin', '../../gccutils.py', HACKED_PATH])\n\n    # Override the real gcc/g++ with our fake ones, which add the necessary flags\n    # and then invokes the real one:\n    run_mock(['--chroot', 'mv /usr/bin/gcc /usr/bin/the-real-gcc'])\n    run_mock(['--chroot', 'mv /usr/bin/g++ /usr/bin/the-real-g++'])\n    run_mock(['--chroot', 'mv /usr/bin/c++ /usr/bin/the-real-c++'])\n    run_mock(['--copyin', 'fake-gcc.py', '/usr/bin/gcc'])\n    run_mock(['--copyin', 'fake-g++.py', '/usr/bin/g++'])\n    run_mock(['--copyin', 'fake-g++.py', '/usr/bin/c++'])\n\n    # Rebuild src.rpm, using the script:\n    run_mock(['--rebuild', srpmpath,\n\n              '--no-clean',\n\n              ],\n             failOnError=False)\n\n    # Extract build logs:\n    shutil.copy('/var/lib/mock/%s/result/build.log' % mockcfg,\n                resultdir)\n\n    # Scrape out *refcount-errors.html:\n    BUILD_PREFIX='/builddir/build/BUILD'\n    out, err = run_mock(['chroot',\n                         'find %s -name *-refcount-errors.html' % BUILD_PREFIX],\n                        captureOut=True)\n    for line in out.splitlines():\n        if line.endswith('-refcount-errors.html'):\n            # Convert from e.g.\n            #    '/builddir/build/BUILD/gst-python-0.10.19/gst/.libs/gstmodule.c.init_gst-refcount-errors.html'\n            # to:\n            #    'gst-python-0.10.19/gst/.libs/gstmodule.c.init_gst-refcount-errors.html\"\n            dstPath = line[len(BUILD_PREFIX)+1:]\n\n            # Place it within resultdir:\n            dstPath = os.path.join(resultdir, dstPath)\n\n            # Lazily construct directory hierarchy:\n            dirPath = os.path.dirname(dstPath)\n            if not os.path.exists(dirPath):\n                os.makedirs(dirPath)\n            # Copy the file from the chroot to our result location:\n            run_mock(['--copyout', line, dstPath])\n\n#PLUGIN_PATH='gcc-python2-plugin-0.9-1.fc16.x86_64.rpm'\n#PLUGIN_PATH='gcc-python2-plugin-0.9-1.with.git.stuff.fc16.a29cf4f671e566a7ee92cb3d604cc6ccfb25b781.x86_64.rpm'\nPLUGIN_PATH='gcc-python2-plugin-0.9-1.with.git.stuff.fc16.1e4eb81.x86_64.rpm'\nMOCK_CONFIG='fedora-16-x86_64'\n\ndef prepare_bug_report(srpmpath, index):\n    srpmname, version, release = nvr_from_srpm_path(srpmpath)\n\n    resultdir = get_result_dir(srpmpath)\n    # Open local copy of results for manual inspection:\n    webbrowser.open(os.path.join(resultdir, 'index.html'))\n\n    today = datetime.date.today()\n    datestr = today.isoformat() # e.g. \"2012-02-15\"\n\n    # Emit shell commands to be run.\n    # These aren't yet done automatically, since we really ought to have the\n    # manual review from above.\n    mkdircmd = 'ssh dmalcolm@fedorapeople.org mkdir public_html/gcc-python-plugin/%(datestr)s' % locals()\n    print(mkdircmd)\n    scpcmd = 'scp -r %(resultdir)s dmalcolm@fedorapeople.org:public_html/gcc-python-plugin/%(datestr)s' % locals()\n    print(scpcmd)\n\n    reporturl = 'http://fedorapeople.org/~dmalcolm/gcc-python-plugin/%(datestr)s/%(srpmname)s-%(version)s-%(release)s/' % locals()\n\n    gitversion = commands.getoutput('git rev-parse HEAD')\n\n    # FIXME:\n    categorized_notes = ''\n    for sev, issues in index.iter_severities():\n        categorized_notes += ('Within the category \"%s\" the %i issues reported\\n'\n                              % (sev.title, len(issues)))\n        for er in issues:\n            categorized_notes += ('%s:%s:%s\\n' % (er.filename, er.function, er.errmsg))\n        categorized_notes += '\\n'\n\n    comment = \"\"\"\nDescription of problem:\nI've been writing an experimental static analysis tool to detect bugs commonly occurring within C Python extension modules:\n  https://fedorahosted.org/gcc-python-plugin/\n  http://gcc-python-plugin.readthedocs.org/en/latest/cpychecker.html\n  http://fedoraproject.org/wiki/Features/StaticAnalysisOfPythonRefcounts\n\nI ran the latest version of the tool (in git master; post 0.9) on\n%(srpmname)s-%(version)s-%(release)s.src.rpm, and it reports various errors.\n\nYou can see a list of errors here, triaged into categories (from most significant to least significant):\n%(reporturl)s\n\nI've manually reviewed the issues reported by the tool.\n\nFIXME:\n%(categorized_notes)s\n\nThere may of course be other bugs in my checker tool.\n\nHope this is helpful; let me know if you need help reading the logs that the tool generates - I know that it could use some improvement.\n\nVersion-Release number of selected component (if applicable):\n%(srpmname)s-%(version)s-%(release)s\ngcc-python-plugin post-0.9 git %(gitversion)s running the checker in an *f16* chroot\n\"\"\" % locals()\n\n    bug = NewBug(product='Fedora',\n                 version='rawhide',\n                 component=srpmname,\n                 summary=('Bugs found in %s-%s-%s using gcc-with-cpychecker'\n                          ' static analyzer' % (srpmname, version, release)),\n                 comment=comment,\n                 blocked=['cpychecker'],\n                 bug_file_loc=reporturl)\n    bugurl = bug.make_url()\n    webbrowser.open(bugurl)\n\n# Rebuild all src.rpm files found in \"SRPMS\" as necessary:\nif 1:\n    #unimplemented_functions = {}\n    for srpmpath in sorted(glob.glob('SRPMS/*.src.rpm')):\n        srpmname, version, release = nvr_from_srpm_path(srpmpath)\n\n        bugdb = BugReportDb()\n        # print(bugdb.bugs)\n        bugdb.print_summary()\n        print('Processing %s' % srpmpath)\n        statuses = bugdb.find(srpmname)\n        if statuses:\n            for status in statuses:\n                print(status.get_status())\n            continue\n\n        resultdir = get_result_dir(srpmpath)\n        if not os.path.exists(resultdir):\n            continue #!\n            local_rebuild_of_srpm_in_mock(srpmpath, MOCK_CONFIG)\n\n        from makeindex import BuildLog\n        try:\n            buildlog = BuildLog(resultdir)\n        except IOError:\n            continue\n        #for fn in buildlog.unimplemented_functions:\n        #    if fn in unimplemented_functions:\n        #        unimplemented_functions[fn] += 1\n        #    else:\n        #        unimplemented_functions[fn] = 1\n\n        #continue\n\n        index = Index(resultdir, 'Errors seen in %s' % resultdir)\n        if not index.reported:\n            prepare_bug_report(srpmpath, index)\n            break\n\nif 0:\n  from pprint import pprint\n  pprint(unimplemented_functions)\n  for key, value in sorted([(k, v) for (k, v) in unimplemented_functions.iteritems()],\n                           lambda (k1,v1), (k2, v2): cmp(v2, v1)):\n      print key, value\n                         \n\n# TODO:\n# - automate grabbing the src.rpms; see e.g.:\n#     http://download.fedora.devel.redhat.com/pub/fedora/linux/releases/16/Everything/source/SRPMS/\n#     http://download.fedora.devel.redhat.com/pub/fedora/linux/development/17/source/SRPMS/\n"
  },
  {
    "path": "print-gcc-version.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include \"config.h\"\n#include \"system.h\"\n#include \"coretypes.h\"\n#include \"plugin.h\"\n#include <stdio.h>\n\nint main(int argc, const char *argv[])\n{\n  printf(\"%i\\n\", GCC_VERSION);\n  return 0;\n}\n"
  },
  {
    "path": "rtl-types.txt.in",
    "content": "#define DEF_RTL_EXPR(ENUM, NAME, FORMAT, CLASS) \\\n  rtl_expr: ENUM, NAME, FORMAT, CLASS\n#include \"rtl.def\"\n#undef DEF_RTL_EXPR\n"
  },
  {
    "path": "run-test-suite.py",
    "content": "#   Copyright 2011-2015 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011-2015 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Test cases are in the form of subdirectories of the \"tests\" directory; any\n# subdirectory containing a \"script.py\" is regarded as a test case.\n#\n# A test consists of:\n#   input*.c/cc: C/C++ source code to be compiled\n#   script.py:  a Python script to be run by GCC during said compilation\n#   stdout.txt: (optional) the expected stdout from GCC (empty if not present)\n#   stderr.txt: (optional) as per stdout.txt\n#   getopts.py: (optional) if present, stdout from this script is\n#               added to GCC's invocation options\n#   metadata.ini: (optional) if present, can override other properties of the\n#                 test (see below)\n#\n# This runner either invokes all tests, or just a subset, if supplied the\n# names of the subdirectories as arguments.  All test cases within the given\n# directories will be run.\n\n# The optional metadata.ini can contain these sections:\n#\n# [WhenToRun]\n#   required_features = whitespace-separated list of #defines that must be on\n#                       within autogenerated-config.h\n#\n# [ExpectedBehavior]\n#   exitcode = integer value, for overriding defaults\n#\n\nimport glob\nimport os\nimport multiprocessing\nimport re\nimport sys\nfrom distutils.sysconfig import get_python_inc\nfrom subprocess import Popen, PIPE\n\nimport six\nfrom six.moves import configparser\n\nfrom cpybuilder import CommandError\n\nfrom testcpychecker import get_gcc_version\nfrom dejagnu import uses_dg_directives, DgContext\n\nWRITEBACK=0\n\nPLUGIN_NAME = os.environ.get('PLUGIN_NAME', 'python')\n\nclass CompilationError(CommandError):\n    def __init__(self, out, err, p, args):\n        CommandError.__init__(self, out, err, p)\n        self.args = args\n        \n    def _describe_activity(self):\n        return 'compiling: %s' % ' '.join(self.args)\n\nclass TestStream:\n    def __init__(self, exppath, srcdir):\n        self.exppath = exppath\n        self.srcdir = srcdir\n        if os.path.exists(exppath):\n            with open(exppath) as f:\n                expdata = f.read()\n            # The expected data is for Python 2\n            # Apply python3 fixups as necessary:\n            if six.PY3:\n                expdata = expdata.replace('<type ', '<class ')\n                expdata = expdata.replace('__builtin__', 'builtins')\n                # replace long literals with int literals:\n                expdata = re.sub('([0-9]+)L', '\\g<1>', expdata)\n                expdata = re.sub('(0x[0-9a-f]+)L', '\\g<1>', expdata)\n                expdata = expdata.replace('PyStringObject',\n                                          'PyBytesObject')\n                expdata = expdata.replace('PyString_Type',\n                                          'PyBytes_Type')\n            # The expected data is for 64-bit builds of Python\n            # Fix it up for 32-bit builds as necessary:\n            if six.MAXSIZE == 0x7fffffff:\n                expdata = expdata.replace('\"Py_ssize_t *\" (pointing to 64 bits)',\n                                          '\"Py_ssize_t *\" (pointing to 32 bits)')\n                expdata = expdata.replace('0x8000000000000000', '0x80000000')\n                expdata = expdata.replace('0x7fffffffffffffff', '0x7fffffff')\n            self.expdata = expdata\n        else:\n            self.expdata = ''\n\n    def _cleanup(self, text):\n        result = ''\n\n        # Debug builds of Python add reference-count logging lines of\n        # this form:\n        #   \"[84507 refs]\"\n        # Strip such lines out:\n        text = re.sub(r'(\\[[0-9]+ refs\\]\\n)', '', text)\n        for line in text.splitlines():\n            if line.startswith(\"Preprocessed source stored into\"):\n                # Handle stuff like this that changes every time:\n                # \"Preprocessed source stored into /tmp/ccRm9Xgx.out file, please attach this to your bugreport.\"\n                continue\n\n            # Strip away references to the srcdir\n            line = re.sub(self.srcdir, '', line)\n\n            # Remove exact pointer addresses from repr():\n            line = re.sub(' object at (0x[0-9a-f]*)>',\n                          ' object at 0xdeadbeef>',\n                          line)\n\n            # Remove exact numbers from declarations\n            # (e.g. from \"D.12021->fieldA\" to \"D.nnnnn->fieldA\"):\n            line = re.sub('D.([0-9]+)', 'D.nnnnn', line)\n            line = re.sub('VarDecl\\(([0-9]+)\\)', 'VarDecl(nnnn)', line)\n            line = re.sub('ParmDecl\\(([0-9]+)\\)', 'ParmDecl(nnnn)', line)\n            line = re.sub('LabelDecl\\(([0-9]+)\\)', 'LabelDecl(nnnn)', line)\n\n            # Remove exact numbers from types\n            # (e.g. from \"int (*<T513>) (int)\" to \"int (*<Tnnn>) (int)\"):\n            line = re.sub('<T([0-9a-f]+)>', '<Tnnn>', line)\n\n            # Remove exact path to Python header file and line number\n            # e.g.\n            #   unknown struct PyObject * from /usr/include/python2.7/pyerrors.h:135\n            #   unknown struct PyObject * from /usr/include/python3.2mu/pyerrors.h:132\n            # should both become:\n            #   unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n            line = re.sub('/usr/include/python(.*)/(.*).h:[0-9]+',\n                          r'/usr/include/python?.?/\\2.h:nn',\n                          line)\n\n            # Convert to the Python 3 format for the repr() of a frozenset:\n            # e.g. from:\n            #   frozenset([0, 1, 2])\n            # to:\n            #   frozenset({0, 1, 2})\n            # and from:\n            #   frozenset([])\n            # to:\n            #   frozenset()\n            line = re.sub(r'frozenset\\(\\[\\]\\)', 'frozenset()', line)\n            line = re.sub(r'frozenset\\(\\[(.*)\\]\\)',\n                          r'frozenset({\\1})',\n                          line)\n\n            # Avoid further 32-bit vs 64-bit differences due to int vs long\n            # overflow:\n            line = re.sub('0x7fffffffL', '0x7fffffff', line)\n            line = re.sub('0x7ffffffeL', '0x7ffffffe', line)\n            line = re.sub('0xffffffffL', '0xffffffff', line)\n            line = re.sub('0xfffffffeL', '0xfffffffe', line)\n\n            # GCC 4.7 tracks macro expansions, and this can change the column\n            # numbers in error reports:\n            line = re.sub(r'input.c:([0-9]+):([0-9]+):',\n                          r'input.c:\\1:nn:',\n                          line)\n            line = re.sub(r'hash_format_codes.inc:([0-9]+):([0-9]+):',\n                          r'hash_format_codes.inc:\\1:nn:',\n                          line)\n\n            # GCC 4.8's output sometimes omits the filename prefix for a\n            # diagnostic:\n            m = re.match(r\"(.+): (In function '.+':)\", line)\n            if m:\n                line = m.group(2)\n\n            # For some reason, some of the test cases emit (long int)\n            # refcounts, rather than (Py_ssize_t)\n            # I think this is to do with borrowed refs\n            line = re.sub(r'r->ob_refcnt: \\(long int\\)val',\n                          r'r->ob_refcnt: (Py_ssize_t)val',\n                          line)\n\n            # Strip off \" [enabled by default]\" suffixes from warning lines\n            line = re.sub(r' \\[enabled by default\\]', '', line)\n\n            # Python 3.3's unicode reimplementation drops the macro redirection\n            # to narrow/wide implementations (\"UCS2\"/\"UCS4\")\n            line = re.sub('PyUnicodeUCS4_AsUTF8String', 'PyUnicode_AsUTF8String', line)\n\n            # Avoid hardcoding timings from unittest's output:\n            line = re.sub(r'Ran ([0-9]+ tests?) in ([0-9]+\\.[0-9]+s)',\n                          r'Ran \\1 in #s',\n                          line)\n\n            result += line + '\\n'\n\n        return result\n\n    def check_for_diff(self, out, err, p, args, label, writeback):\n        actual = self._cleanup(self.actual)\n        expdata = self._cleanup(self.expdata)\n        if writeback:\n            # Special-case mode: don't compare, instead refresh the \"gold\"\n            # output by writing back to disk:\n            if self.expdata != '':\n                with open(self.exppath, 'w') as f:\n                    f.write(actual)\n            return\n        if actual != expdata:\n            raise UnexpectedOutput(out, err, p, args, self, label)\n\n    def diff(self, label):\n        from difflib import unified_diff\n        result = ''\n        for line in unified_diff(self._cleanup(self.expdata).splitlines(),\n                                 self._cleanup(self.actual).splitlines(),\n                                 fromfile='Expected %s (after cleaning)' % label,\n                                 tofile='Actual %s (after cleaning)' % label,\n                                 lineterm=\"\"):\n            result += '%s\\n' % line\n        return result\n\nclass UnexpectedOutput(CompilationError):\n    def __init__(self, out, err, p, args, stream, label):\n        CompilationError.__init__(self, out, err, p, args)\n        self.stream = stream\n        self.label = label\n    \n    def _extra_info(self):\n        return self.stream.diff(self.label)\n\nclass DejaGnuError(Exception):\n    def __init__(self, ctxt):\n        self.ctxt = ctxt\n\ndef get_source_files(testdir):\n    \"\"\"\n    Locate source files within the test directory,\n    of the form \"input*.c\", \"input*.cc\" etc\n    trying various different suffixes by programming language\n    \"\"\"\n    inputfiles = []\n    suffixes = ['.c', '.cc', '.java', '.f', '.f90']\n    for suffix in suffixes:\n        from glob import glob\n        inputfiles += glob(os.path.join(testdir, 'input*%s' % suffix))\n    if not inputfiles:\n        raise RuntimeError('Source file not found')\n    return inputfiles\n\nconfig_h = 'autogenerated-config.h'\ndef parse_autogenerated_config_h():\n    from collections import OrderedDict\n    result = OrderedDict()\n    with open(config_h) as f:\n        for line in f.readlines():\n            m = re.match('#define (.+)', line)\n            if m:\n                result[m.group(1)] = True\n            m = re.match('#undef (.+)', line)\n            if m:\n                result[m.group(1)] = False\n    return result\n\nfeatures = parse_autogenerated_config_h()\n\nCC = os.environ.get('CC', 'gcc')\nGCC_VERSION = get_gcc_version()\n\nclass SkipTest(Exception):\n    def __init__(self, reason):\n        self.reason = reason\n\ndef run_test(testdir, srcdir):\n    # Compile each 'input.c', using 'script.py'\n    # Assume success and empty stdout; compare against expected stderr, or empty if file not present\n    inputfiles = get_source_files(testdir)\n    outfile = os.path.join(testdir, 'output.o')\n    script_py = os.path.join(testdir, 'script.py')\n    out = TestStream(os.path.join(testdir, 'stdout.txt'), srcdir)\n    err = TestStream(os.path.join(testdir, 'stderr.txt'), srcdir)\n\n    cp = configparser.SafeConfigParser()\n    metadatapath = os.path.join(testdir, 'metadata.ini')\n    cp.read([metadatapath])\n\n    if cp.has_section('WhenToRun'):\n        if cp.has_option('WhenToRun', 'required_features'):\n            required_features = cp.get('WhenToRun', 'required_features').split()\n            for feature in required_features:\n                if feature not in features:\n                    raise ValueError('%s in %s not found in %s'\n                                     % (feature, metadatapath, config_h))\n                if not features[feature]:\n                    raise SkipTest('required feature %s not available in %s'\n                                   % (feature, config_h))\n\n    env = dict(os.environ)\n    env['LC_ALL'] = 'C'\n\n    # Generate the command-line for invoking gcc:\n    args = [CC]\n    if len(inputfiles) == 1:\n        args += ['-c'] # (don't run the linker)\n    else:\n        args += ['-fPIC', '-shared']\n        # Force LTO when there's more than one source file:\n        args += ['-flto', '-flto-partition=none']\n\n    if GCC_VERSION >= 4008:\n        # GCC 4.8 started showing the source line where the problem is,\n        # followed by another line showing a caret indicating column.\n        # This is a great usability feature, but totally breaks our \"gold\"\n        # output, so turn it off for running tests:\n        args += ['-fno-diagnostics-show-caret']\n\n        # Similarly, the macro expansion tracking is great for usability,\n        # but breaks the \"gold\" output, so we disable it during tests:\n        args += ['-ftrack-macro-expansion=0']\n\n    args += ['-o', outfile]\n    args += ['-fplugin=%s' % os.path.abspath('%s.so' % PLUGIN_NAME),\n             '-fplugin-arg-%s-script=%s' % (PLUGIN_NAME, script_py)]\n\n    # Force the signedness of char so that the tests have consistent\n    # behavior across all archs:\n    args += ['-fsigned-char']\n\n    # Special-case: add the python include dir (for this runtime) if the C code\n    # uses Python.h:\n    def uses_python_headers():\n        for inputfile in inputfiles:\n            with open(inputfile, 'r') as f:\n                code = f.read()\n            if '#include <Python.h>' in code:\n                return True\n\n    if uses_python_headers():\n        args += ['-I' + get_python_inc()]\n\n    # If there's a getopts.py, run it to get additional test-specific\n    # command-line options:\n    getopts_py = os.path.join(testdir, 'getopts.py')\n    if os.path.exists(getopts_py):\n        p = Popen([sys.executable, getopts_py], stdout=PIPE, stderr=PIPE)\n        opts_out, opts_err = p.communicate()\n        if six.PY3:\n            opts_out = opts_out.decode()\n            opts_err = opts_err.decode()\n        c = p.wait()\n        if c != 0:\n            raise CommandError()\n        args += opts_out.split()\n\n    # and the source files go at the end:\n    args += inputfiles\n\n    if uses_dg_directives(inputfiles):\n        dg_context = DgContext(inputfiles)\n        if GCC_VERSION >= 9000:\n            dg_context.options.append('-fno-diagnostics-show-line-numbers')\n        dg_context.echo_results = True\n        for inputfile in inputfiles:\n            dg_context.parse_directives(inputfile)\n        args += dg_context.get_args()\n    else:\n        dg_context = None\n\n    if options.show:\n        # Show the gcc invocation:\n        print(' '.join(args))\n\n    # Invoke the compiler:\n    p = Popen(args, env=env, stdout=PIPE, stderr=PIPE)\n    out.actual, err.actual = p.communicate()\n    if six.PY3:\n        out.actual = out.actual.decode()\n        err.actual = err.actual.decode()\n    #print 'out: %r' % out.actual\n    #print 'err: %r' % err.actual\n    exitcode_actual = p.wait()\n\n    if options.show:\n        # then the user wants to see the gcc invocation directly\n        sys.stdout.write(out.actual)\n        sys.stderr.write(err.actual)\n\n    if dg_context:\n        dg_context.check_result(out.actual, err.actual, exitcode_actual)\n        if dg_context.num_failures() > 0:\n            raise DejaGnuError(dg_context)\n        return\n\n    # Expected exit code\n    # By default, we expect success if the expected stderr is empty, and\n    # and failure if it's non-empty.\n    # This can be overridden if the test has a metadata.ini, by setting\n    # exitcode within the [ExpectedBehavior] section:\n    if err.expdata == '':\n        exitcode_expected = 0\n    else:\n        exitcode_expected = 1\n    if cp.has_section('ExpectedBehavior'):\n        if cp.has_option('ExpectedBehavior', 'exitcode'):\n            exitcode_expected = cp.getint('ExpectedBehavior', 'exitcode')\n\n    # Check exit code:\n    if exitcode_actual != exitcode_expected:\n        sys.stderr.write(out.diff('stdout'))\n        sys.stderr.write(err.diff('stderr'))\n        raise CompilationError(out.actual, err.actual, p, args)\n\n    if exitcode_expected == 0:\n        assert os.path.exists(outfile)\n    \n    out.check_for_diff(out.actual, err.actual, p, args, 'stdout', WRITEBACK)\n    err.check_for_diff(out.actual, err.actual, p, args, 'stderr', WRITEBACK)\n\n\nfrom optparse import OptionParser\nparser = OptionParser()\nparser.add_option(\"-x\", \"--exclude\",\n                  action=\"append\",\n                  type=\"string\",\n                  dest=\"excluded_dirs\",\n                  help=\"exclude tests in DIR and below\", metavar=\"DIR\")\nparser.add_option(\"--srcdir\",\n                  type=\"string\",\n                  dest=\"srcdir\",\n                  help=\"FIXME\", metavar=\"DIR\")\nparser.add_option(\"-s\", \"--show\",\n                  action=\"store_true\", dest=\"show\", default=False,\n                  help=\"Show stdout, stderr and the command line for each test\")\n(options, args) = parser.parse_args()\n\nif options.srcdir is None:\n    options.srcdir = os.getcwd() + os.sep\n\n# print (options, args)\n\ndef find_tests_below(path):\n    result = []\n    for dirpath, dirnames, filenames in os.walk(path):\n        if 'script.py' in filenames:\n            result.append(dirpath)\n    return result\n\n\nif len(args) > 0:\n    # Just run the given tests (or test subdirectories)\n    testdirs = []\n    for path in args:\n        testdirs += find_tests_below(path)\nelse:\n    # Run all the tests\n    path = os.path.join(options.srcdir, 'tests')\n    testdirs = find_tests_below(path)\n\ndef exclude_test(test):\n    if not test.startswith(options.srcdir):\n        test = os.path.join(options.srcdir, test)\n    if test in testdirs:\n        testdirs.remove(test)\n\ndef exclude_tests_below(path):\n    if not path.startswith(options.srcdir):\n        path = os.path.join(options.srcdir, path)\n    for test in find_tests_below(path):\n        exclude_test(test)\n\n# Handle exclusions:\nif options.excluded_dirs:\n    for path in options.excluded_dirs:\n        exclude_tests_below(path)\n\n# Certain tests don't work on 32-bit\nif six.MAXSIZE == 0x7fffffff:\n    # These two tests verify that we can detect int vs Py_ssize_t mismatches,\n    # but on 32-bit these are the same type, so don't find anything:\n    exclude_test('tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN')\n    exclude_test('tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN')\n\n    # One part of the expected output for this test assumes int vs Py_ssize_t\n    # mismatch:\n    exclude_test('tests/cpychecker/PyArg_ParseTuple/incorrect_converters')\n\n    # The expected output for the following tests assumes a 64-bit build:\n    exclude_test('tests/cpychecker/absinterp/casts/pointer-to-long')\n    exclude_test('tests/cpychecker/absinterp/casts/pyobjectptr-to-long')\n    exclude_test('tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O')\n    exclude_test('tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O')\n    exclude_test('tests/cpychecker/refcounts/PyInt_AsLong/correct_cast')\n    exclude_test('tests/cpychecker/refcounts/PyList_Size/known-size')\n    exclude_test('tests/cpychecker/refcounts/PyMapping_Size/basic')\n    exclude_test('tests/cpychecker/refcounts/PyString_Size/correct')\n    exclude_test('tests/cpychecker/refcounts/PyTuple_New/correct')\n    exclude_test('tests/cpychecker/refcounts/module_handling')\n    exclude_test('tests/cpychecker/refcounts/storage_regions/static/correct')\n    exclude_test('tests/examples/cplusplus/classes')\n    exclude_test('tests/plugin/constants')\n    exclude_test('tests/plugin/gimple-walk-tree/dump-all')\n    exclude_test('tests/plugin/gimple-walk-tree/find-one')\n\n# Certain tests don't work for Python 3:\nif six.PY3:\n    # The PyInt_ API doesn't exist anymore in Python 3:\n    exclude_tests_below('tests/cpychecker/refcounts/PyInt_AsLong/')\n    exclude_tests_below('tests/cpychecker/refcounts/PyInt_FromLong/')\n\n    # Similarly for the PyString_ API:\n    exclude_tests_below('tests/cpychecker/refcounts/PyString_AsString')\n    exclude_tests_below('tests/cpychecker/refcounts/PyString_Concat')\n    exclude_tests_below('tests/cpychecker/refcounts/PyString_ConcatAndDel')\n    exclude_tests_below('tests/cpychecker/refcounts/PyString_FromStringAndSize')\n    exclude_tests_below('tests/cpychecker/refcounts/PyString_Size')\n\n    # The PyCObject_ API was removed in 3.2:\n    exclude_tests_below('tests/cpychecker/refcounts/PyCObject_FromVoidPtr')\n    exclude_tests_below('tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc')\n\n    # The following tests happen to use PyInt or PyString APIs and thus we\n    # exclude them for now:\n    exclude_test('tests/cpychecker/refcounts/function-that-exits') # PyString\n    exclude_test('tests/cpychecker/refcounts/GIL/correct') # PyString\n    exclude_test('tests/cpychecker/refcounts/handle_null_error') # PyString\n    exclude_test('tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang') # PyString\n    exclude_test('tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct') # PyString\n    exclude_test('tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect') # PyString\n    exclude_test('tests/cpychecker/refcounts/PyStructSequence/correct') # PyInt\n    exclude_test('tests/cpychecker/refcounts/PySys_SetObject/correct') # PyString\n    exclude_test('tests/cpychecker/refcounts/subclass/handling') # PyString\n\n    # Module handling is very different in Python 2 vs 3.  For now, only run\n    # this test for Python 2:\n    exclude_test('tests/cpychecker/refcounts/module_handling')\n\n    # Uses METH_OLDARGS:\n    exclude_test('tests/cpychecker/refcounts/PyArg_Parse/correct_simple')\n\n# Certain tests don't work for debug builds of Python:\nif hasattr(sys, 'gettotalrefcount'):\n    exclude_test('tests/cpychecker/refcounts/PyDict_SetItem/correct')\n    exclude_test('tests/cpychecker/refcounts/PyDict_SetItem/incorrect')\n    exclude_test('tests/cpychecker/refcounts/PyDict_SetItemString/correct')\n    exclude_test('tests/cpychecker/refcounts/PyDict_SetItemString/incorrect')\n    exclude_test('tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject')\n    exclude_test('tests/cpychecker/refcounts/PyList_Append/correct')\n    exclude_test('tests/cpychecker/refcounts/PyList_Append/incorrect')\n    exclude_test('tests/cpychecker/refcounts/PyList_Append/incorrect-loop')\n    exclude_test('tests/cpychecker/refcounts/PyList_Append/null-newitem')\n    exclude_test('tests/cpychecker/refcounts/PyList_Append/ticket-22')\n    exclude_test('tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct')\n    exclude_test('tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple')\n    exclude_test('tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple')\n    exclude_test('tests/cpychecker/refcounts/PyList_Size/known-size')\n    exclude_test('tests/cpychecker/refcounts/PySequence_SetItem/correct')\n    exclude_test('tests/cpychecker/refcounts/PySequence_SetItem/incorrect')\n    exclude_test('tests/cpychecker/refcounts/PySequence_Size/correct')\n    exclude_test('tests/cpychecker/refcounts/PyString_AsString/correct')\n    exclude_test('tests/cpychecker/refcounts/PyString_AsString/incorrect')\n    exclude_test('tests/cpychecker/refcounts/PySys_SetObject/correct')\n    exclude_test('tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct')\n    exclude_test('tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple')\n    exclude_test('tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple')\n    exclude_test('tests/cpychecker/refcounts/PyTuple_SetItem/correct')\n    exclude_test('tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple')\n    exclude_test('tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple')\n    exclude_test('tests/cpychecker/refcounts/Py_BuildValue/correct-code-N')\n    exclude_test('tests/cpychecker/refcounts/Py_BuildValue/correct-code-O')\n    exclude_test('tests/cpychecker/refcounts/correct_decref')\n    exclude_test('tests/cpychecker/refcounts/loop_n_times')\n    exclude_test('tests/cpychecker/refcounts/loops/complex-loop-conditional-1')\n    exclude_test('tests/cpychecker/refcounts/loops/complex-loop-conditional-2')\n    exclude_test('tests/cpychecker/refcounts/module_handling')\n    exclude_test('tests/cpychecker/refcounts/object_from_callback')\n    exclude_test('tests/cpychecker/refcounts/passing_dead_object')\n    exclude_test('tests/cpychecker/refcounts/returning_dead_object')\n    exclude_test('tests/cpychecker/refcounts/ticket-20')\n    exclude_test('tests/cpychecker/refcounts/unrecognized_function2')\n    exclude_test('tests/cpychecker/refcounts/unrecognized_function4')\n    exclude_test('tests/cpychecker/refcounts/use_after_dealloc')\n    exclude_test('tests/examples/spelling-checker')\n\n# The debug build probably doesn't have lxml available:\nif hasattr(sys, 'gettotalrefcount'):\n    exclude_tests_below('tests/cpychecker')\n\n# This test is unreliable, due to differences in the dictionary:\nexclude_test('tests/examples/spelling-checker')\n\n# Various tests don't work under GCC 4.7\n# (or rather, don't give the same output as under 4.6):\nif features['GCC_PYTHON_PLUGIN_CONFIG_has_PLUGIN_FINISH_DECL']:\n    # assumes it's uninitialized:\n    exclude_test('tests/cpychecker/absinterp/arrays5')\n\n    # line number differerences:\n    exclude_test('tests/cpychecker/absinterp/comparisons/expressions')\n\n    exclude_test('tests/cpychecker/refcounts/combinatorial-explosion')\n    exclude_test('tests/cpychecker/refcounts/combinatorial-explosion-with-error')\n    exclude_test('tests/cpychecker/refcounts/correct_object_ctor')\n\n    # sense of a boolean is reversed:\n    exclude_test('tests/cpychecker/refcounts/fold_conditional')\n\n    # gains gcc.Function('__deleting_dtor '):\n    exclude_test('tests/examples/cplusplus/classes')\n\n    # some gimple changes:\n    exclude_test('tests/plugin/array-type')\n\n    exclude_test('tests/plugin/arrays')\n\n    # one less output:\n    exclude_test('tests/plugin/callbacks/refs')\n\n    # changes in output:\n    exclude_test('tests/plugin/dumpfiles')\n\n    # gains: :py:class:`gcc.WidenLshiftExpr`    `w<<`\n    exclude_test('tests/plugin/expressions/get_symbol')\n\n    # gains an extra gcc.GimpleLabel():\n    exclude_test('tests/plugin/gimple-cond/explicit-comparison')\n\n    # gains an extra gcc.GimpleLabel():\n    exclude_test('tests/plugin/gimple-cond/implicit-comparison')\n\n    # various gimple changes:\n    exclude_test('tests/plugin/gimple-walk-tree/dump-all')\n\n    # gimple change:\n    exclude_test('tests/plugin/gimple-walk-tree/exceptions')\n\n    # gimple changes:\n    exclude_test('tests/plugin/gimple-walk-tree/find-one')\n\n    # various (char*) go away:\n    exclude_test('tests/plugin/initializers')\n\n    #     cc1: fatal error: pass 'ipa-profile' not found but is referenced by new pass 'my-ipa-pass'\n    exclude_test('tests/plugin/new-passes')\n\n    # -Wunitialized is now disabled by default:\n    exclude_test('tests/plugin/options')\n\n    # KeyError: 'struct-reorg-cold-struct-ratio':\n    exclude_test('tests/plugin/parameters')\n\n    # gains an extra gcc.GimpleLabel():\n    exclude_test('tests/plugin/switch')\n\n    # test_var isn't visible; see\n    #   https://fedorahosted.org/gcc-python-plugin/ticket/21\n    exclude_test('tests/plugin/translation-units')\n\nif sys.version_info[:2] == (3, 3):\n    # These tests don't generate the same output under 3.3:\n    exclude_test('tests/cpychecker/refcounts/combinatorial-explosion')\n    exclude_test('tests/cpychecker/refcounts/combinatorial-explosion-with-error')\n\n# Tests failing with gcc 4.8:\nif GCC_VERSION >= 4008:\n    exclude_test('tests/cpychecker/refcounts/cplusplus/destructor')\n    exclude_test('tests/cpychecker/refcounts/cplusplus/empty-function')\n\n# GCC 4.6.3 appears not to have a way to get at global variables; see:\n#   https://fedorahosted.org/gcc-python-plugin/ticket/21\n# and:\n#   https://github.com/davidmalcolm/gcc-python-plugin/issues/5\n# This prevents these from working:\n#   libcpychecker.compat.get_exception_decl_by_name\n#   libcpychecker.compat.get_typeobject_decl_by_name\n# which renders much of cpychecker unusable.\n# For now, disable many of the tests on 4.6.*:\nif GCC_VERSION == 4006:\n    exclude_tests_below('tests/cpychecker/refcounts')\n    exclude_test('tests/cpychecker/absinterp/exceptions')\n    exclude_test('tests/plugin/array-type')\n    exclude_test('tests/plugin/translation-units')\n\n# Other tests that fail on 4.6:\nif GCC_VERSION == 4006:\n    # some minor changes to stdout:\n    exclude_test('tests/examples/cplusplus/classes')\n\n    # presence of stdout line:\n    #   :py:class:`gcc.WidenLshiftExpr`    `w<<`\n    exclude_test('tests/plugin/expressions/get_symbol')\n\n    # too fragile?\n    exclude_test('tests/plugin/gimple-walk-tree/dump-all')\n\n    # repr() for gcc.CaseLabelExpr and gcc.GimpleLabel\n    exclude_test('tests/plugin/switch')\n\nif GCC_VERSION >= 5000:\n    # Avoid warning from -Wshift-count-negative\n    exclude_test('tests/cpychecker/absinterp/arithmetic/negative-shift/definite')\n\n    # Various casting tests that fail:\n    exclude_test('tests/cpychecker/absinterp/casts/int-to-char-with-extraction')\n    exclude_test('tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation')\n    exclude_test('tests/cpychecker/absinterp/casts/int-to-char-within-range')\n    exclude_test('tests/cpychecker/absinterp/casts/pointer-to-long')\n    exclude_test('tests/cpychecker/absinterp/casts/pyobjectptr-to-long')\n\n    # Various other tests that fail:\n    exclude_test('tests/cpychecker/absinterp/comparisons/conditionals')\n    exclude_test('tests/cpychecker/refcounts/PyList_Size/known-size')\n    exclude_test('tests/cpychecker/refcounts/SWIG_Python_SetErrorMsg/correct')\n    exclude_test('tests/examples/attributes')\n    exclude_test('tests/examples/hello-world')\n    exclude_test('tests/plugin/rtl')\n\n    # Various tests failing with Python 3 with GCC 5:\n    if six.PY3:\n        exclude_test('tests/cpychecker/absinterp/arithmetic/division-by-zero/definite')\n        exclude_test('tests/cpychecker/absinterp/arithmetic/division-by-zero/possible')\n        exclude_test('tests/cpychecker/absinterp/arithmetic/negative-shift/possible')\n        exclude_test('tests/cpychecker/absinterp/arrays3')\n        exclude_test('tests/cpychecker/absinterp/arrays6')\n        exclude_test('tests/cpychecker/absinterp/arrays7')\n        exclude_test('tests/cpychecker/absinterp/bitfields/reading')\n        exclude_test('tests/cpychecker/absinterp/custom-strdup')\n        exclude_test('tests/cpychecker/absinterp/function-pointers')\n        exclude_test('tests/cpychecker/absinterp/nested-fields2')\n        exclude_test('tests/cpychecker/absinterp/nested-fields3')\n        exclude_test('tests/cpychecker/absinterp/read-through-global-ptr-unchecked')\n        exclude_test('tests/cpychecker/absinterp/read-through-uninitialized-ptr')\n        exclude_test('tests/cpychecker/absinterp/uninitialized-data')\n        exclude_test('tests/cpychecker/absinterp/write-through-arg-unchecked')\n        exclude_test('tests/cpychecker/absinterp/write-through-global-ptr-unchecked')\n        exclude_test('tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization')\n        exclude_test('tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs')\n        exclude_test('tests/cpychecker/refcounts/PyDict_GetItem/correct')\n        exclude_test('tests/cpychecker/refcounts/PyDict_GetItem/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyDict_GetItemString/correct')\n        exclude_test('tests/cpychecker/refcounts/PyDict_GetItemString/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyDict_SetItem/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyErr_NewException/basic')\n        exclude_test('tests/cpychecker/refcounts/PyEval_CallMethod/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyList_Append/ticket-19')\n        exclude_test('tests/cpychecker/refcounts/PyList_GetItem/correct')\n        exclude_test('tests/cpychecker/refcounts/PyObject_GetAttr/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyTuple_GetItem/correct')\n        exclude_test('tests/cpychecker/refcounts/PyTuple_GetItem/incorrect')\n        exclude_test('tests/cpychecker/refcounts/PyTuple_Size/incorrect')\n        exclude_test('tests/cpychecker/refcounts/passing_dead_object')\n        exclude_test('tests/cpychecker/refcounts/too_many_increfs')\n        exclude_test('tests/cpychecker/refcounts/uninitialized_data/comparison')\n        exclude_test('tests/cpychecker/refcounts/uninitialized_data/function_arg')\n        exclude_test('tests/cpychecker/refcounts/use_after_dealloc')\n\n# Tests failing due to repr changes in Python 3.4+\nif sys.version_info[0] == 3 and sys.version_info[1] >= 4:\n    exclude_test('tests/plugin/callgraph')\n    exclude_test('tests/plugin/rtl')\n\n# Tests that are over-specified and only work for GCC 5 and later:\nif GCC_VERSION < 5000:\n    exclude_test('tests/cpychecker/absinterp/comparisons/conditionals')\n    exclude_test('tests/plugin/rtl')\n\n# Tests that are over-specified and only work for GCC 6 and later:\nif GCC_VERSION < 6000:\n    exclude_test('tests/examples/find-global-state')\n\n# class rich_location was added to libcpp in gcc 6.\nif GCC_VERSION < 6000:\n    exclude_test('tests/plugin/rich-location')\n\n# compound locations are only supported for GCC 7 and later:\nif GCC_VERSION < 7000:\n    exclude_test('tests/plugin/compound-locations')\n\n# Tests that are over-specified and only work for GCC 7 and earlier:\nif GCC_VERSION >= 8000:\n    # change from '__base_ctor ' to '__ct_base ' etc:\n    exclude_test('tests/examples/cplusplus/methods')\n\n    # reorg of namespace lookup:\n    exclude_test('tests/plugin/namespace')\n\n    # removal of column number from \"In file included from\" in stderr:\n    exclude_test('tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN')\n    exclude_test('tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN')\n\n# absinterp and thus the refcount-checker have bit-rotted:\nif GCC_VERSION >= 7000:\n    exclude_tests_below('tests/cpychecker/absinterp')\n    exclude_tests_below('tests/cpychecker/refcounts')\n\ndef run_one_test(testdir):\n    try:\n        sys.stdout.write('%s: ' % testdir)\n        run_test(testdir, options.srcdir)\n        print('OK')\n        return (testdir, 'OK', None)\n    except SkipTest:\n        err = sys.exc_info()[1]\n        print('skipped: %s' % err.reason)\n        return (testdir, 'SKIP', err.reason)\n    except DejaGnuError:\n        print('FAIL')\n        return (testdir, 'FAIL', None)\n    except RuntimeError:\n        err = sys.exc_info()[1]\n        print('FAIL')\n        print(err)\n        return (testdir, 'FAIL', None)\n\nclass TestRunner:\n    def __init__(self):\n        self.num_passes = 0\n        self.skipped_tests = []\n        self.failed_tests = []\n\n    def run_tests(self, testdirs):\n        for testdir in sorted(testdirs):\n            tr.handle_outcome(run_one_test(testdir))\n\n    def run_tests_in_parallel(self, testdirs):\n        pool = multiprocessing.Pool(None) # uses cpu_count\n        for outcome in pool.map(run_one_test, testdirs):\n            tr.handle_outcome(outcome)\n\n    def handle_outcome(self, outcome):\n        testdir, result, detail = outcome\n        if result == 'OK':\n            self.num_passes += 1\n        elif result == 'SKIP':\n            self.skipped_tests.append(testdir)\n        else:\n            assert result == 'FAIL'\n            self.failed_tests.append(testdir)\n\n    def print_results(self):\n        def num(count, singular, plural):\n            return '%i %s' % (count, singular if count == 1 else plural)\n\n        print('%s; %s; %s' % (num(self.num_passes, \"success\", \"successes\"),\n                              num(len(self.failed_tests), \"failure\", \"failures\"),\n                              num(len(self.skipped_tests), \"skipped\", \"skipped\")))\n\ntr = TestRunner()\nif 1:\n    tr.run_tests_in_parallel(sorted(testdirs))\nelse:\n    tr.run_tests(sorted(testdirs))\n\ntr.print_results()\nif len(tr.failed_tests) > 0:\n    print('Failed tests:')\n    for test in tr.failed_tests:\n        print('  %s' % test)\n    sys.exit(1)\n"
  },
  {
    "path": "test-builder.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport os\nfrom maketreetypes import iter_tree_types\nfrom cpybuilder import CompilationUnit, SimpleModule\n\nsm = SimpleModule()\nsm.cu.add_include('config.h')\nsm.cu.add_include('system.h')\nsm.cu.add_include('coretypes.h')\nsm.cu.add_include('tree.h')\nsm.cu.add_decl(\"\"\"\nstruct PyGccTree {\n     PyObject_HEAD\n     tree t;\n};\n\"\"\")\n\n# FIXME: truncating the list for now, for sanity's sake:\nfor t in list(iter_tree_types())[:5]:\n    #tp = PyTypeObject(name = 'PyType%s' % t.camel_cased_string(),\n    #                  tp_name = 'tree.%s' % t.camel_cased_string(),\n    #                  struct_name = 'struct PyGccTree')\n    sm.add_type_object(name = 'tree_%sType' % t.camel_cased_string(),\n                       localname = t.camel_cased_string(),\n                       tp_name = 'tree.%s' % t.camel_cased_string(),\n                       struct_name = 'struct PyGccTree')\n\nsm.add_module_init('tree', modmethods=None, moddoc='This is a doc string')\nprint sm.cu.as_str()\n\nfrom subprocess import Popen, PIPE, check_call\n\n\nGCCPLUGINS_DIR = Popen([os.environ.get('CC', 'gcc'),\n                        '--print-file-name=plugin'], stdout=PIPE).communicate()[0].strip()\n\n\npyconfigs = ('python2.7-config',\n             'python2.7-debug-config',\n             'python3.2mu-config',\n             'python3.2dmu-config')\n             \nfor pyconfig in pyconfigs:\n    cflags = Popen([pyconfig, '--cflags', '--ldflags'], stdout=PIPE).communicate()[0]\n    args = [os.environ.get('CC', 'gcc')]\n    args += ['-x', 'c'] # specify that it's C\n    args += ['-o', 'test.so']\n    args += cflags.split()\n    args += ['-shared']\n    args += ['-I%s/include' % GCCPLUGINS_DIR]\n    args += ['-'] # read from stdin\n    print args\n\n    p = Popen(args, stdin = PIPE)\n    p.communicate(sm.cu.as_str())\n    c = p.wait()\n    assert c == 0\n        \n    # FIXME: actually run python and import the modules!\n    \n\n#tree_types = list(iter_tree_types())\n\n#print \"#include <Python.h>\"\n#print \"PyTypeObject *types_by_code[%i];\" % len(tree_types)\n#for t in iter_tree_types():\n#    print ('    \"%s\", /* %s %s %s %s */'\n#           % (t.camel_cased_string(), t.STRING, t.SYM, t.TYPE, t.NARGS))\n\n\n\n"
  },
  {
    "path": "test.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Trivial example code to be compiled, for testing purposes\n */\n\n#include <stdio.h>\n\nint\nhelper_function(void)\n{\n    printf(\"I am a helper function\\n\");\n    return 42;\n}\n\nint\nmain(int argc, char **argv)\n{\n    int i;\n\n    printf(\"argc: %i\\n\", argc);\n\n    for (i = 0; i < argc; i++) {\n        printf(\"argv[%i]: %s\\n\", argv[i]);\n    }\n\n    helper_function();\n\n    return 0;\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "test.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Sample python script, to be run by our gcc plugin (see \"make test\")\n#print \"hello world\"\n\nimport gcc\n\nimport sys\nprint('sys.version: %s' % sys.version)\n#print 'sys.path:', sys.path\n#help(gcc)\n\nprint(help(gcc.AddrExpr))\nprint(gcc.Type)\nprint(gcc.Type.char)\nprint(help(gcc.Type))\n\n\nfrom gccutils import get_src_for_loc, cfg_to_dot, invoke_dot\n\ndef my_pass_execution_callback(*args, **kwargs):\n    print('my_pass_execution_callback was called: args=%r  kwargs=%r' % (args, kwargs))\n    print('gcc.get_translation_units(): %s' % gcc.get_translation_units())\n    for u in gcc.get_translation_units():\n        print('u: %s %r' % (u, u))\n        u.debug()\n        print('u.block: %s' % u.block)\n    #help(args[0])\n    (optpass, fun) = args\n    print('optpass: %r' % optpass)\n    print('dir(optpass): %r' % dir(optpass))\n    print('optpass.name: %r' % optpass.name)\n    print('fun: %r' % fun)\n    if fun:\n        print('fun.cfg: %r' % fun.cfg)\n        if fun.cfg:\n            #print help(fun.cfg)\n            print('fun.cfg.basic_blocks: %r' % fun.cfg.basic_blocks)\n            print('fun.cfg.entry: %r' % fun.cfg.entry)\n            print('fun.cfg.exit: %r' % fun.cfg.exit)\n            print('fun.cfg.entry.succs: %r' % fun.cfg.entry.succs)\n            print('fun.cfg.exit.preds: %r' % fun.cfg.exit.preds)\n            \n            dot = cfg_to_dot(fun.cfg)\n            print(dot)\n            invoke_dot(dot)\n            for bb in fun.cfg.basic_blocks:\n                print('bb: %r' % bb)\n                print('bb.gimple: %r' % bb.gimple)\n                if isinstance(bb.gimple, list):\n                    for stmt in bb.gimple:\n                        print('  %r: %r : %s column: %i block: %r' % (stmt, repr(str(stmt)), stmt.loc, stmt.loc.column, stmt.block))\n                        print(get_src_for_loc(stmt.loc))\n                        print(' ' * (stmt.loc.column-1) + '^')\n                        if hasattr(stmt, 'loc'):\n                            print('      stmt.loc: %r' % stmt.loc)\n                        if hasattr(stmt, 'lhs'):\n                            print('      stmt.lhs: %r' % stmt.lhs)\n                        if hasattr(stmt, 'exprtype'):\n                            print('      stmt.exprtype: %r' % stmt.exprtype)\n                        if hasattr(stmt, 'exprcode'):\n                            print('      stmt.exprcode: %r' % stmt.exprcode)\n                        if hasattr(stmt, 'fn'):\n                            print('      stmt.fn: %r %s' % (stmt.fn, stmt.fn))\n                        if hasattr(stmt, 'retval'):\n                            print('      stmt.retval: %r' % stmt.retval)\n                        if hasattr(stmt, 'rhs'):\n                            print('      stmt.rhs: %r' % stmt.rhs)\n\ndef my_pre_genericize_callback(*args, **kwargs):\n    print('my_pre_genericize_callback was called: args=%r  kwargs=%r' % (args, kwargs))\n    #help(args[0])\n    t = args[0]\n    print(t)\n    print(dir(t))\n    print(type(t))\n    print(repr(t))\n    print(str(t))\n    #print(help(t))\n\n    print('t.name: %r' % t.name)\n    print('t.addr: %s' % hex(t.addr))\n    print('t.type: %r' % t.type)\n    print('t.function: %r' % t.function)\n    #print(help(t.function))\n\n    print('t.type.type: %r' % t.type.type)\n\n    loc = t.location\n\n    print(loc)\n    print(dir(loc))\n    print(type(loc))\n    print(repr(loc))\n    #print(help(loc))\n    print('loc.file: %r' % loc.file)\n    print('loc.line: %r' % loc.line)\n\n    # raise RuntimeError('what happens if we get an error here?')\n\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      my_pass_execution_callback)\ngcc.register_callback(gcc.PLUGIN_PRE_GENERICIZE,\n                      my_pre_genericize_callback)\n\n# Try some insane values:\n#gcc.register_callback(-1, my_callback)\n\n# Stupid hack idea: a UI for gcc:\n#import gtk\n#w = gtk.Window(gtk.WINDOW_TOPLEVEL)\n#w.show()\n#gtk.main()\n\n#from pprint import pprint\n#pprint(tree.subclass_for_code)\n"
  },
  {
    "path": "testcpybuilder.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n\nfrom distutils import sysconfig as sc\nimport os\nimport shutil\nfrom subprocess import Popen, PIPE\nimport sys\nimport sysconfig\nimport tempfile\nimport unittest\n\nimport six\n\nfrom cpybuilder import *\n\ndef get_module_filename(name):\n    # Python 3.2 onwards embeds the SOABI variable in module filenames\n    # (see PEP 3149):\n    SOABI = sysconfig.get_config_var('SOABI')\n    if SOABI:\n        return '%s.%s.so' % (name, SOABI)\n\n    if hasattr(sys, \"getobjects\"):\n        # debug build of Python:\n        # FIXME: this is a Fedora-ism:\n        return '%s_d.so' % name\n    else:\n        # regular (optimized) build of Python:\n        return '%s.so' % name\n\nclass CompilationError(CommandError):\n    def __init__(self, bm):\n        CommandError.__init__(self, bm.out, bm.err, bm.p)\n        self.bm = bm\n    \n    def _describe_activity(self):\n        return 'compiling: %s' % ' '.join(self.bm.args)\n\nclass BuiltModule:\n    \"\"\"A test build of a SimpleModule using sys.executable, done in a tempdir\"\"\"\n    def __init__(self, sm):\n        self.sm = sm\n\n    def write_src(self, modname, extra_cflags = None):\n        self.tmpdir = tempfile.mkdtemp()\n\n        self.srcfile = os.path.join(self.tmpdir, '%s.c' % modname)\n        self.modfile = os.path.join(self.tmpdir, get_module_filename(modname))\n\n        f = open(self.srcfile, 'w')\n        f.write(self.sm.cu.as_str())\n        f.close()\n\n\n    def compile_src(self, extra_cflags = None):\n        self.args = [os.environ.get('CC', 'gcc')]\n        self.args += ['-o', self.modfile]\n        self.args +=  ['-I' + sc.get_python_inc(),\n                       '-I' + sc.get_python_inc(plat_specific=True)]\n\n        # Get CFLAGS from sysconfig\n        cflags = sc.get_config_var('CFLAGS').split()\n        # Filter out LTO\n        cflags = filter(lambda flag: flag != '-flto', cflags)\n        self.args += cflags\n\n        self.args += ['-Wall',  '-Werror'] # during testing\n        # on some builds of Python, CFLAGS does not contain -fPIC, but it\n        # appears to still be necessary:\n        self.args += ['-fPIC']\n        self.args += ['-shared'] # not sure why this is necessary\n        if extra_cflags:\n            self.args += extra_cflags\n        self.args += [self.srcfile]\n        # print(self.args)\n\n        env = dict(os.environ)\n        env['LC_ALL'] = 'C'\n\n        # Invoke the compiler:\n        self.p = Popen(self.args, env=env, stdout=PIPE, stderr=PIPE)\n        self.out, self.err = self.p.communicate()\n        if six.PY3:\n            self.out = self.out.decode()\n            self.err = self.err.decode()\n        c = self.p.wait()\n        if c != 0:\n            raise CompilationError(self)\n\n        assert os.path.exists(self.modfile)\n        # print(self.modfile)\n\n    def build(self, modname, extra_cflags = None):\n        self.write_src(modname)\n        self.compile_src(extra_cflags)\n\n    def cleanup(self):\n        shutil.rmtree(self.tmpdir)\n\nclass SimpleTest(unittest.TestCase):\n\n    # We'll be manipulating sys.path during the test\n    # Save a copy, and restore it after each test:\n    def setUp(self):\n        self.saved_sys_path = sys.path\n        sys.path = sys.path[:]\n\n    def tearDown(self):\n        sys.path = self.saved_sys_path\n\n    def test_simple_compilation(self):\n        # Verify building and running a trivial module (against multiple Python runtimes)\n        MODNAME = 'simple_compilation'\n        sm = SimpleModule()\n\n        sm.cu.add_decl(\"\"\"\nstatic PyObject *\nexample_hello(PyObject *self, PyObject *args);\n\"\"\")\n\n        sm.cu.add_defn(\"\"\"\nstatic PyObject *\nexample_hello(PyObject *self, PyObject *args)\n{\n    return Py_BuildValue(\"s\", \"Hello world!\");\n}\n\"\"\")\n\n        methods = PyMethodTable('example_methods',\n                                [PyMethodDef('hello', 'example_hello',\n                                             METH_VARARGS, 'Return a greeting.')])\n        sm.cu.add_defn(methods.c_defn())\n\n        sm.add_module_init(MODNAME, modmethods=methods, moddoc='This is a doc string')\n        # print(sm.cu.as_str())\n\n        # Build the module:\n        bm = BuiltModule(sm)\n        bm.build(MODNAME)\n\n        # Verify that it built:\n        sys.path.append(bm.tmpdir)\n        import simple_compilation\n        self.assertEqual(simple_compilation.hello(), 'Hello world!')\n        \n        # Cleanup successful test runs:\n        bm.cleanup()\n\n    def test_module_with_type(self):\n        # Verify an extension with a type\n        MODNAME = 'module_with_type'\n        sm = SimpleModule()\n\n        sm.cu.add_decl(\"\"\"\nstruct PyExampleType {\n     PyObject_HEAD\n     int i;\n};\n\"\"\")\n\n        sm.cu.add_defn(\"PyObject *\\n\"\n                       \"example_Example_repr(PyObject * self)\\n\"\n                       \"{\\n\"\n                       \"#if PY_MAJOR_VERSION < 3\\n\"\n                       \"    return PyString_FromString(\\\"example.ExampleType('')\\\");\\n\"\n                       \"#else\\n\"\n                       \"    return PyUnicode_FromString(\\\"example.ExampleType('')\\\");\\n\"\n                       \"#endif\\n\"\n                       \"}\\n\")\n        sm.add_type_object(name = 'example_ExampleType',\n                           localname = 'ExampleType',\n                           tp_name = 'example.ExampleType',\n                           struct_name = 'struct PyExampleType',\n                           tp_repr = 'example_Example_repr')\n\n        sm.add_module_init(MODNAME, modmethods=None, moddoc='This is a doc string')\n        # print sm.cu.as_str()\n\n        # Build the module:\n        bm = BuiltModule(sm)\n        bm.build(MODNAME)\n\n        # Verify that it built:\n        sys.path.append(bm.tmpdir)\n        import module_with_type\n        self.assertEqual(repr(module_with_type.ExampleType()),\n                         \"example.ExampleType('')\")\n\n        # Cleanup successful test runs:\n        bm.cleanup()\n\n    def test_version_parsing(self):\n        vi  = PyVersionInfo.from_text(\"sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)\")\n        self.assertEqual(vi,\n                         PyVersionInfo(major=2, minor=7, micro=1, releaselevel='final', serial=0))\n\n        # \"sys.version_info(major=2, minor=7, micro=1, releaselevel='final', serial=0)\"\n        # \"sys.version_info(major=3, minor=2, micro=0, releaselevel='candidate', serial=1)\"\n\n                         \n\n\nif __name__ == '__main__':\n    unittest.main()\n"
  },
  {
    "path": "testcpychecker.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport os\nfrom subprocess import Popen, PIPE\nimport sys\nimport unittest\n\nimport six\n\nfrom testcpybuilder import BuiltModule, SimpleModule, CompilationError\nfrom cpybuilder import PyMethodTable, PyMethodDef, METH_VARARGS\n\nPLUGIN_NAME = os.environ.get('PLUGIN_NAME', 'python')\n\ndef get_gcc_version():\n    p = Popen(['./print-gcc-version'],\n              stdout=PIPE, stderr=PIPE)\n    out, err = p.communicate()\n    return(int(out))\n\nGCC_VERSION = get_gcc_version()\n\nclass ExpectedErrorNotFound(CompilationError):\n    def __init__(self, expected_err, actual_err, bm):\n        CompilationError.__init__(self, bm)\n        self.expected_err = expected_err\n        self.actual_err = actual_err\n\n\n    def _describe_activity(self):\n        result = 'This error was expected, but was not found:\\n'\n        result += '  ' + self._indent(self.expected_err) + '\\n'\n        result += '  whilst compiling:\\n'\n        result += '    ' + self.bm.srcfile + '\\n'\n        result += '  using:\\n'\n        result += '    ' + ' '.join(self.bm.args) + '\\n'\n        \n        from difflib import unified_diff\n        for line in unified_diff(self.expected_err.splitlines(),\n                                 self.actual_err.splitlines(),\n                                 fromfile='Expected stderr',\n                                 tofile='Actual stderr',\n                                 lineterm=\"\"):\n            result += '%s\\n' % line\n        return result\n\nclass AnalyzerTests(unittest.TestCase):\n    def compile_src(self, bm):\n        here = os.path.dirname(os.path.abspath(__file__))\n        extra_cflags=['-fplugin=%s' % os.path.abspath('%s.so' % PLUGIN_NAME),\n                      '-fplugin-arg-%s-script=%s/cpychecker.py' % (PLUGIN_NAME, here)]\n\n        # GCC 4.8 started showing the source line where the problem is,\n        # followed by another line showing a caret indicating column.\n        # This is a great usability feature, but totally breaks our \"gold\"\n        # output, so turn it off for running tests:\n        if GCC_VERSION >= 4008:\n            extra_cflags += ['-fno-diagnostics-show-caret']\n\n        bm.compile_src(extra_cflags)\n\n    def build_module(self, bm):\n        bm.write_src('example')\n        self.compile_src(bm)\n\n    def assertNoErrors(self, src):\n        if isinstance(src, SimpleModule):\n            sm = src\n        else:\n            sm = SimpleModule()\n            sm.cu.add_defn(src)\n        bm = BuiltModule(sm)\n        self.build_module(bm)\n        bm.cleanup()\n        return bm\n\n    def assertFindsError(self, src, experr):\n        if GCC_VERSION >= 4009:\n            experr = experr.replace('$(SRCFILE):12:26:', '$(SRCFILE):12:10:')\n            experr = experr.replace('$(SRCFILE):13:25:', '$(SRCFILE):13:9:')\n            experr = experr.replace('$(SRCFILE):13:26:', '$(SRCFILE):13:10:')\n            experr = experr.replace('$(SRCFILE):14:26:', '$(SRCFILE):14:10:')\n            experr = experr.replace('$(SRCFILE):14:37:', '$(SRCFILE):14:10:')\n            experr = experr.replace('$(SRCFILE):17:26:', '$(SRCFILE):17:10:')\n        if GCC_VERSION >= 5000:\n            experr = experr.replace('$(SRCFILE):12:5:', '$(SRCFILE):12:12:')\n            experr = experr.replace('$(SRCFILE):13:5:', '$(SRCFILE):13:12:')\n        if isinstance(src, SimpleModule):\n            sm = src\n        else:\n            sm = SimpleModule()\n            sm.cu.add_defn(src)\n        bm = BuiltModule(sm)\n        try:\n            bm.write_src('example')\n            experr = experr.replace('$(SRCFILE)', bm.srcfile)\n            self.compile_src(bm)\n        except CompilationError:\n            exc = sys.exc_info()[1]\n            if experr not in exc.err:\n                raise ExpectedErrorNotFound(experr, exc.err, bm)\n        else:\n            raise ExpectedErrorNotFound(experr, bm.err, bm)\n        bm.cleanup()\n        return bm\n\nclass PyArg_ParseTupleTests(AnalyzerTests):\n    def test_bogus_format_string(self):\n        src = ('PyObject *\\n'\n               'bogus_format_string(PyObject *self, PyObject *args)\\n'\n               '{\\n'\n               '    if (!PyArg_ParseTuple(args, \"This is not a valid format string\")) {\\n'\n               '  \t    return NULL;\\n'\n               '    }\\n'\n               '    Py_RETURN_NONE;\\n'\n               '}\\n')\n        experr = (\"$(SRCFILE): In function 'bogus_format_string':\\n\"\n                  '$(SRCFILE):12:26: error: unknown format char in \"This is not a valid format string\": \\'T\\' [-Werror]\\n')\n        self.assertFindsError(src, experr)\n                   \n    def test_finding_htons_error(self):\n        #  Erroneous argument parsing of socket.htons() on 64bit big endian\n        #  machines from CPython's Modules/socket.c; was fixed in svn r34931\n        #  FIXME: the original had tab indentation, but what does this mean\n        # for \"column\" offsets in the output?\n        if six.MAXSIZE == 0x7fffffff:\n            raise unittest.SkipTest('Test assumes a 64-bit machine')\n\n        src = \"\"\"\nextern uint16_t htons(uint16_t hostshort);\n\nPyObject *\nsocket_htons(PyObject *self, PyObject *args)\n{\n    unsigned long x1, x2;\n\n    if (!PyArg_ParseTuple(args, \"i:htons\", &x1)) {\n        return NULL;\n    }\n    x2 = (int)htons((short)x1);\n#if PY_MAJOR_VERSION >= 3\n    return PyLong_FromLong(x2);\n#else\n    return PyInt_FromLong(x2);\n#endif\n}\n\"\"\"\n        self.assertFindsError(src,\n                              \"$(SRCFILE): In function 'socket_htons':\\n\"\n                              '$(SRCFILE):17:26: error: Mismatching type in call to PyArg_ParseTuple with format code \"i:htons\" [-Werror]\\n'\n                              '  argument 3 (\"&x1\") had type\\n'\n                              '    \"long unsigned int *\" (pointing to 64 bits)\\n'\n                              '  but was expecting\\n'\n                              '    \"int *\" (pointing to 32 bits)\\n'\n                              '  for format code \"i\"\\n')\n\n    def test_not_enough_varargs(self):\n        src = \"\"\"\nPyObject *\nnot_enough_varargs(PyObject *self, PyObject *args)\n{\n   if (!PyArg_ParseTuple(args, \"i\")) {\n       return NULL;\n   }\n   Py_RETURN_NONE;\n}\n\"\"\"\n        self.assertFindsError(src,\n                              \"$(SRCFILE): In function 'not_enough_varargs':\\n\"\n                              '$(SRCFILE):13:25: error: Not enough arguments in call to PyArg_ParseTuple with format string \"i\" [-Werror]\\n'\n                              '  expected 1 extra arguments:\\n'\n                              '    \"int *\" (pointing to 32 bits)\\n'\n                              '  but got none\\n')\n\n    def test_too_many_varargs(self):\n        src = \"\"\"\nPyObject *\ntoo_many_varargs(PyObject *self, PyObject *args)\n{\n    int i, j;\n    if (!PyArg_ParseTuple(args, \"i\", &i, &j)) {\n\t return NULL;\n    }\n    Py_RETURN_NONE;\n}\n\"\"\"\n        self.assertFindsError(src,\n                              \"$(SRCFILE): In function 'too_many_varargs':\\n\"\n                              '$(SRCFILE):14:26: error: Too many arguments in call to PyArg_ParseTuple with format string \"i\" [-Werror]\\n'\n                              '  expected 1 extra arguments:\\n'\n                              '    \"int *\" (pointing to 32 bits)\\n'\n                              '  but got 2:\\n'\n                              '    \"int *\" (pointing to 32 bits)\\n'\n                              '    \"int *\" (pointing to 32 bits)\\n')\n\n    def test_correct_usage(self):\n        src = \"\"\"\nPyObject *\ncorrect_usage(PyObject *self, PyObject *args)\n{\n    int i;\n    if (!PyArg_ParseTuple(args, \"i\", &i)) {\n\t return NULL;\n    }\n    Py_RETURN_NONE;\n}\n\"\"\"\n        self.assertNoErrors(src)\n\n    def get_function_name(self, header, code):\n        name = '%s_%s' % (header, code)\n        name = name.replace('*', '_star')\n        name = name.replace('#', '_hash')\n        name = name.replace('!', '_bang')\n        name = name.replace('&', '_amp')\n        return name\n\n    def make_src_for_correct_function(self, code, typenames, params=None):\n        # Generate a C function that uses the format code correctly, and verify\n        # that it compiles with gcc with the cpychecker script, without errors\n        function_name = self.get_function_name('correct_usage_of', code)\n        src = ('PyObject *\\n'\n               '%(function_name)s(PyObject *self, PyObject *args)\\n'\n               '{\\n') % locals()\n        for i, typename in enumerate(typenames):\n            src += ('    %(typename)s val%(i)s;\\n') % locals()\n        if not params:\n            params = ', '.join('&val%i' % i for i in range(len(typenames)))\n        src += ('    if (!PyArg_ParseTuple(args, \"%(code)s\", %(params)s)) {\\n'\n                '              return NULL;\\n'\n                '    }\\n'\n                '    Py_RETURN_NONE;\\n'\n                '}\\n') % locals()\n        return src\n\n    def make_src_for_incorrect_function(self, code, typenames):\n        function_name = self.get_function_name('incorrect_usage_of', code)\n        params = ', '.join('&val' for i in range(len(typenames)))\n        src = ('PyObject *\\n'\n               '%(function_name)s(PyObject *self, PyObject *args)\\n'\n               '{\\n'\n               '    void *val;\\n'\n               '    if (!PyArg_ParseTuple(args, \"%(code)s\", %(params)s)) {\\n'\n               '  \t    return NULL;\\n'\n               '    }\\n'\n               '    Py_RETURN_NONE;\\n'\n               '}\\n') % locals()\n        return src, function_name\n\n    def get_funcname(self):\n        return 'PyArg_ParseTuple'\n\n    def get_argindex(self):\n        return 3\n\n    def get_linenum(self):\n        return 13\n\n    def get_colnum(self):\n        return 26\n\n    def get_expected_error(self):\n        return (\"$(SRCFILE): In function '%(function_name)s':\\n\"\n                '$(SRCFILE):%(linenum)i:%(colnum)i: error: Mismatching type in call to %(funcname)s with format code \"%(code)s\" [-Werror]\\n'\n                '  argument %(argindex)i (\"&val\") had type\\n'\n                '    \"void * *\"\\n'\n                '  but was expecting\\n'\n                '    %(exptypename)s')\n        # we stop there, to avoid spelling out the various possible\n        #    (pointing to N bits)\n        # variants of the message\n\n    def _test_format_code(self, code, typenames, exptypenames=None):\n        if isinstance(typenames, str):\n            typenames = [typenames]\n        if isinstance(exptypenames, str):\n            exptypenames = [exptypenames]\n        if not exptypenames:\n            exptypenames = ['\"%s *\"'%t for t in typenames]\n\n        def _test_correct_usage_of_format_code(self, code, typenames):\n            src = self.make_src_for_correct_function(code, typenames)\n            self.assertNoErrors(src)\n\n        def _test_incorrect_usage_of_format_code(self, code, typenames, exptypenames):\n            # Generate a C function that uses the format code, with the\n            # correct number of arguments, but all of the arguments being of\n            # the incorrect type; compile it with cpychecker, and verify that there's\n            # a warning\n            exptypename = exptypenames[0]\n            src, function_name = self.make_src_for_incorrect_function(code, typenames)\n            funcname = self.get_funcname()\n            argindex = self.get_argindex()\n            linenum = self.get_linenum()\n            colnum = self.get_colnum()\n            experr = self.get_expected_error() % locals()\n            bm = self.assertFindsError(src, experr)\n                                       \n        _test_correct_usage_of_format_code(self, code, typenames)\n        _test_incorrect_usage_of_format_code(self, code, typenames, exptypenames)\n\n    # The following test cases are intended to be in the same order as the API\n    # documentation at http://docs.python.org/c-api/arg.html\n        \n    def test_format_code_s(self):\n        self._test_format_code('s', 'const char *')\n\n    # \"s#\" is affected by the PY_SSIZE_T_CLEAN macro; we test it within:\n    #   tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN\n    #   tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN\n\n    def test_format_code_s_star(self):\n        self._test_format_code('s*', ['Py_buffer'], '\"struct Py_buffer *\"')\n\n    def test_format_code_z(self):\n        self._test_format_code('z', 'const char *')\n\n    # \"z#\" is affected by the PY_SSIZE_T_CLEAN macro; we test it within:\n    #   tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN\n    #   tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN\n\n    def test_format_code_z_star(self):\n        self._test_format_code('z*', ['Py_buffer'], '\"struct Py_buffer *\"')\n\n    def test_format_code_u(self):\n        self._test_format_code('u', 'Py_UNICODE *')\n\n    # \"u#\" is affected by the PY_SSIZE_T_CLEAN macro; we test it within:\n    #   tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN\n    #   tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN\n\n    def test_format_code_es(self):\n        self._test_format_code('es',\n          ['const char', 'char *'],\n          [('one of \"const char *\" (pointing to 8 bits)'\n            ' or \"char *\" (pointing to 8 bits) or NULL'),\n           '\"char * *\"'])\n\n    def test_format_code_et(self):\n        self._test_format_code('et',\n          ['const char', 'char *'],\n          [('one of \"const char *\" (pointing to 8 bits)'\n            ' or \"char *\" (pointing to 8 bits) or NULL'),\n           '\"char * *\"'])\n\n    # \"es#\" and \"et#\" are affected by the PY_SSIZE_T_CLEAN macro; we test them\n    # within:\n    #   tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN\n    #   tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN\n\n    def test_format_code_b(self):\n        self._test_format_code('b', 'unsigned char')\n\n    def test_format_code_B(self):\n        self._test_format_code('B', 'unsigned char')\n\n    def test_format_code_h(self):\n        self._test_format_code('h', 'short',\n                               '\"short int *\"')\n\n    def test_format_code_H(self):\n        self._test_format_code('H', 'unsigned short',\n                               '\"short unsigned int *\"')\n\n    def test_format_code_i(self):\n        self._test_format_code('i', 'int')\n\n    def test_format_code_I(self):\n        self._test_format_code('I', 'unsigned int')\n\n    def test_format_code_l(self):\n        self._test_format_code('l', 'long',\n                               '\"long int *\"')\n\n    def test_format_code_k(self):\n        self._test_format_code('k', 'unsigned long',\n                               '\"long unsigned int *\"')\n\n    def test_format_code_L(self):\n        self._test_format_code('L', 'PY_LONG_LONG',\n                               '\"long long int *\"')\n\n    def test_format_code_K(self):\n        self._test_format_code('K', 'unsigned PY_LONG_LONG',\n                               '\"long long unsigned int *\"')\n\n    def test_format_code_n(self):\n        self._test_format_code('n', 'Py_ssize_t')\n\n    def test_format_code_c(self):\n        self._test_format_code('c', 'char')\n\n    def test_format_code_f(self):\n        self._test_format_code('f', 'float')\n\n    def test_format_code_d(self):\n        self._test_format_code('d', 'double')\n\n    def test_format_code_D(self):\n        self._test_format_code('D', 'Py_complex', '\"struct Py_complex *\"')\n\n    def test_format_code_O(self):\n        self._test_format_code('O', ['PyObject *'], '\"struct PyObject * *\"')\n\n    # Code \"O!\" is tested by:\n    #   tests/cpychecker/PyArg_ParseTuple/code_O_bang/\n\n    # Code \"O&\" is tested by:\n    #   tests/cpychecker/PyArg_ParseTuple/correct_converter/\n    #   tests/cpychecker/PyArg_ParseTuple/incorrect_converters/\n\n    # Codes \"S\" and \"U\" require some special treatment, as they can support\n    # multiple types.  We tests them via these selftests:\n    #\ttests/cpychecker/PyArg_ParseTuple/correct_codes_S_and_U/\n    #\ttests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U/\n\n    # \"t#\" is affected by the PY_SSIZE_T_CLEAN macro; we test it within:\n    #   tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN\n    #   tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN\n\n    def test_format_code_w(self):\n        self._test_format_code('w', 'char *')\n\n    # \"w#\" is affected by the PY_SSIZE_T_CLEAN macro; we test it within:\n    #   tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN\n    #   tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN\n\n    def test_format_code_w_star(self):\n        self._test_format_code('w*', ['Py_buffer'], '\"struct Py_buffer *\"')\n\n    def test_mismatched_parentheses(self):\n        for code in ['(', ')', '(()']:\n            function_name = 'fn'\n            src = ('PyObject *\\n'\n                   '%(function_name)s(PyObject *self, PyObject *args)\\n'\n                   '{\\n') % locals()\n            src += ('    if (!PyArg_ParseTuple(args, \"%(code)s\")) {\\n'\n                    '              return NULL;\\n'\n                    '    }\\n'\n                    '    Py_RETURN_NONE;\\n'\n                    '}\\n') % locals()\n            experr = (\"$(SRCFILE): In function '%(function_name)s':\\n\"\n                      '$(SRCFILE):12:26: error: mismatched parentheses in format string \"%(code)s\"' % locals())\n            bm = self.assertFindsError(src, experr)\n\nclass PyArg_ParseTupleAndKeywordsTests(PyArg_ParseTupleTests):\n    def get_funcname(self):\n        return 'PyArg_ParseTupleAndKeywords'\n\n    def get_argindex(self):\n        return 5\n\n    def get_linenum(self):\n        return 14\n\n    def get_colnum(self):\n        return 37\n\n    def make_src_for_correct_function(self, code, typenames, params=None):\n        # Generate a C function that uses the format code correctly, and verify\n        # that it compiles with gcc with the cpychecker script, without errors\n        function_name = self.get_function_name('correct_usage_of', code)\n        src = ('PyObject *\\n'\n               '%(function_name)s(PyObject *self, PyObject *args, PyObject *kw)\\n'\n               '{\\n') % locals()\n        src += '    char *keywords[] = {\"fake_keyword\", NULL};\\n'\n        for i, typename in enumerate(typenames):\n            src += ('    %(typename)s val%(i)s;\\n') % locals()\n        if not params:\n            params = ', '.join('&val%i' % i for i in range(len(typenames)))\n        src += ('    if (!PyArg_ParseTupleAndKeywords(args, kw, \"%(code)s\", keywords, %(params)s)) {\\n'\n                '              return NULL;\\n'\n                '    }\\n'\n                '    Py_RETURN_NONE;\\n'\n                '}\\n') % locals()\n        return src\n\n    def make_src_for_incorrect_function(self, code, typenames):\n        function_name = self.get_function_name('incorrect_usage_of', code)\n        params = ', '.join('&val' for i in range(len(typenames)))\n        src = ('PyObject *\\n'\n               '%(function_name)s(PyObject *self, PyObject *args, PyObject *kw)\\n'\n               '{\\n'\n               '    void *val;\\n'\n               '    char *keywords[] = {\"fake_keyword\", NULL};\\n'\n               '    if (!PyArg_ParseTupleAndKeywords(args, kw, \"%(code)s\", keywords, %(params)s)) {\\n'\n               '        return NULL;\\n'\n               '    }\\n'\n               '    Py_RETURN_NONE;\\n'\n               '}\\n') % locals()\n        return src, function_name\n\nclass Py_BuildValueTests(AnalyzerTests):\n    def test_bogus_format_string(self):\n        src = ('PyObject *\\n'\n               'bogus_format_string(PyObject *self, PyObject *args)\\n'\n               '{\\n'\n               '    return Py_BuildValue(\"this is not a valid format string\");\\n'\n               '}\\n')\n        experr = (\"$(SRCFILE): In function 'bogus_format_string':\\n\"\n                  '$(SRCFILE):12:5: error: unknown format char in \"this is not a valid format string\": \\'t\\' [-Werror]\\n')\n        self.assertFindsError(src, experr)\n\n    def test_not_enough_varargs(self):\n        src = \"\"\"\nPyObject *\nnot_enough_varargs(PyObject *self, PyObject *args)\n{\n    return Py_BuildValue(\"i\");\n}\n\"\"\"\n        self.assertFindsError(src,\n                              \"$(SRCFILE): In function 'not_enough_varargs':\\n\"\n                              '$(SRCFILE):13:5: error: Not enough arguments in call to Py_BuildValue with format string \"i\" [-Werror]\\n'\n                              '  expected 1 extra arguments:\\n'\n                              '    \"int\"\\n'\n                              '  but got none\\n')\n\n    def test_too_many_varargs(self):\n        src = \"\"\"\nPyObject *\ntoo_many_varargs(PyObject *self, PyObject *args)\n{\n    return Py_BuildValue(\"i\", 0, 1);\n}\n\"\"\"\n        self.assertFindsError(src,\n                              \"$(SRCFILE): In function 'too_many_varargs':\\n\"\n                              '$(SRCFILE):13:5: error: Too many arguments in call to Py_BuildValue with format string \"i\" [-Werror]\\n'\n                              '  expected 1 extra arguments:\\n'\n                              '    \"int\"\\n'\n                              '  but got 2:\\n'\n                              '    \"int\"\\n'\n                              '    \"int\"\\n')\n\n    def test_correct_usage(self):\n        src = \"\"\"\nPyObject *\ncorrect_usage(PyObject *self, PyObject *args)\n{\n    return Py_BuildValue(\"ii\", 0, 1);\n}\n\"\"\"\n        self.assertNoErrors(src)\n\n\n\nif __name__ == '__main__':\n    unittest.main()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_Parse/incorrect_codes_S_and_U/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker warns about incorrect usage of\n  PyArg_Parse\n*/\nPyObject *\nincorrect_usage_of_S_and_U(PyObject *self, PyObject *args)\n{\n    int val1;\n    int val2;\n\n    /* Incorrect: mismatching types: */\n    if (!PyArg_Parse(args, \"SU\", &val1, &val2)) {\n        return NULL;\n    }\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_Parse/incorrect_codes_S_and_U/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_Parse/incorrect_codes_S_and_U/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_Parse/incorrect_codes_S_and_U/stderr.txt",
    "content": "In function 'incorrect_usage_of_S_and_U':\ntests/cpychecker/PyArg_Parse/incorrect_codes_S_and_U/input.c:33:nn: warning: Mismatching type in call to PyArg_Parse with format code \"SU\" [enabled by default]\n  argument 3 (\"&val1\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    one of \"struct PyStringObject * *\" or \"struct PyObject * *\"\n  for format code \"S\"\ntests/cpychecker/PyArg_Parse/incorrect_codes_S_and_U/input.c:33:nn: warning: Mismatching type in call to PyArg_Parse with format code \"SU\" [enabled by default]\n  argument 4 (\"&val2\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    one of \"struct PyUnicodeObject * *\" or \"struct PyObject * *\"\n  for format code \"U\"\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_O_bang/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  The Python source tree uses \"O!\" in a couple of places with explicit PyObject\n  subclassses:\n\nObjects/funcobject.c: In function ‘func_new’:\nObjects/funcobject.c:377:37: error: Mismatching type in call to PyArg_ParseTupleAndKeywords with format code \"O!O!|OOO:function\" [-fpermissive]\n  argument 6 (\"&code\") had type\n    \"struct PyCodeObject * *\"\n  but was expecting\n    \"PyObject * *\"\n  for format code \"O!\"\n\nObjects/typeobject.c: In function ‘super_init’:\nObjects/typeobject.c:6632:26: error: Mismatching type in call to PyArg_ParseTuple with format code \"O!|O:super\" [-fpermissive]\n  argument 4 (\"&type\") had type\n    \"struct PyTypeObject * *\"\n  but was expecting\n    \"PyObject * *\"\n  for format code \"O!\"\n\n  \"O!\" does check that the object is of the appropriate type, so the usage is\n  reasonable.\n\n  This plugin itself uses it in a few places. FIXME: does it?\n\n  We can examine a struct and verify that it has the same first fields as the\n  fields of a PyObject.\n\n  But how to map back from a PyTypeObject instance to the struct?\n  (i.e. how to ensure that the specific subclass type is correct?\n  (we might now even have the defn of the type object)\n*/\n#include <Python.h>\n\n/*\n  Example of a PyTypeObject which we can't know the value of at compile time:\n*/\nextern PyTypeObject *unknown_type_obj_ptr;\n\n/*\n  Example of an extension type, where cpychecker has no way to associate\n  the PyTypeObject with, say, \"struct ExtensionObject\"\n*/\nPyTypeObject UnknownExtension_Type = {};\n\n/*\n  Example of a PyTypeObject where the user supplies the value at compile time:\n*/\ntypedef struct UserDefinedObject UserDefinedObject;\n#if WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE\n  #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(typename) \\\n     __attribute__((cpychecker_type_object_for_typedef(typename)))\n#else\n  #define CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(typename)\n#endif\nPyTypeObject UserDefinedExtension_Type\n    CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF(\"UserDefinedObject\")\n  = {};\n\nPyObject *\nhandle_subclasses(PyObject *self, PyObject *args)\n{\n    PyCodeObject *code_obj;\n    PyObject *base_obj;\n    PyTypeObject *type_obj = NULL;\n    PyLongObject *long_obj;\n    struct UnknownObject *unknown_obj;\n    struct ExtensionObject *extension_obj;\n    UserDefinedObject *user_defined_obj;\n\n    if (!PyArg_ParseTuple(args, \"O!O!O!O!O!O!O!\",\n                          /* This is correct, PyCode_Type -> PyCodeObject */\n                          &PyCode_Type, &code_obj,\n\n                          /* This is correct: PyCode_Type -> PyObject also */\n                          &PyCode_Type, &base_obj,\n\n                          /* This is correct: PyType_Type -> PyTypeObject*/\n                          &PyType_Type, &type_obj,\n\n                          /* This is incorrect: wrong subclass (unicode vs long): */\n                          &PyUnicode_Type, long_obj,\n\n                          /* This must report a warning; we can't know which\n                             PyTypeObject is in use, and thus can't know if\n                             struct UnknownObject is OK: */\n                          unknown_type_obj_ptr, &unknown_obj,\n\n                          /* This must report a warning: we don't know about\n                             the association between Extension_Type and\n                             struct ExtensionObject: */\n                          &UnknownExtension_Type, &extension_obj,\n\n                          /* This is correct, the user has explicitly\n                             associated the typeobj with the struct: */\n                          &UserDefinedExtension_Type, &user_defined_obj\n                          )) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_O_bang/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_O_bang/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_O_bang/stderr.txt",
    "content": "In function 'handle_subclasses':\ntests/cpychecker/PyArg_ParseTuple/code_O_bang/input.c:85:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O!O!O!O!O!O!O!\" [enabled by default]\n  argument 10 (\"long_obj\") had type\n    \"struct PyLongObject *\"\n  but was expecting\n    \"struct PyUnicodeObject * *\" (based on PyTypeObject: 'PyUnicode_Type') or \"struct PyObject * *\"\n  for format code \"O!\"\ntests/cpychecker/PyArg_ParseTuple/code_O_bang/input.c:90:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O!O!O!O!O!O!O!\" [enabled by default]\n  argument 12 (\"&unknown_obj\") had type\n    \"struct UnknownObject * *\"\n  but was expecting\n    \"\"struct PyObject * *\"\" (unable to determine relevant PyTypeObject)\n  for format code \"O!\"\ntests/cpychecker/PyArg_ParseTuple/code_O_bang/input.c:90:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O!O!O!O!O!O!O!\" [enabled by default]\n  argument 14 (\"&extension_obj\") had type\n    \"struct ExtensionObject * *\"\n  but was expecting\n    \"\"struct PyObject * *\"\" (unfamiliar with PyTypeObject: 'UnknownExtension_Type')\n  for format code \"O!\"\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_s/incorrect-constness/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Verify that the checker emits a warning for code \"s\" with a non-const\n  char*\n\n  Code \"s\" writes a pointer back to the insides of an object's representation,\n  so it really should be a (const char*), not just a (char*)\n*/\n#include <Python.h>\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    char *str;\n\n    if (!PyArg_ParseTuple(args, \"s\",\n                          &str)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_s/incorrect-constness/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_s/incorrect-constness/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/code_s/incorrect-constness/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/PyArg_ParseTuple/code_s/incorrect-constness/input.c:34:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"s\" [enabled by default]\n  argument 3 (\"&str\") had type\n    \"char * *\"\n  but was expecting\n    \"const char * *\"\n  for format code \"s\"\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/codes_accepting_null/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n */\n#include <Python.h>\n\nPyObject *\ncodes_accepting_null(PyObject *self, PyObject *args)\n{\n    char *buffer = \"I am a buffer\";\n    int ival;\n\n    /* The various \"e\" codes can accept NULL as the encoding: */\n    if (!PyArg_ParseTuple(args, \"es#\", NULL, &buffer, &ival)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/codes_accepting_null/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/correct_codes_S_and_U/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Verify that the checker can cope with format codes that reference\n  specific object subtypes (e.g. PyStringObject) but are supplied\n  a PyObject ** instead.\n\n  This was erroneously giving errors like this:\n    error: Mismatching type in call to PyArg_ParseTuple with format code \"S\" [-fpermissive]\n      argument 3 (\"&stringobj\") had type \"struct PyObject * *\"\n      but was expecting \"PyStringObject * *\" for format code \"S\"\n  which is overconstraining things: a (PyObject**) is fine there.\n*/\n\n#include <Python.h>\n\nstatic PyObject *\nless_rigid_code_S(PyObject *self, PyObject *args)\n{\n    /*\n       Both of these ought to be acceptable for code \"S\":\n    */\n    PyObject *S_baseobj;\n#if PY_MAJOR_VERSION >= 3\n    PyBytesObject *S_subobj;\n#else\n    PyStringObject *S_subobj;\n#endif\n\n    if (!PyArg_ParseTuple(args, \"SS\",\n                          &S_baseobj,\n                          &S_subobj)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\nless_rigid_code_U(PyObject *self, PyObject *args)\n{\n    /*\n       Both of these ought to be acceptable for code \"U\":\n    */\n    PyObject *U_baseobj;\n    PyUnicodeObject *U_uniobj;\n\n    if (!PyArg_ParseTuple(args, \"UU\",\n                          &U_baseobj,\n                          &U_uniobj)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/correct_codes_S_and_U/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/correct_converter/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Adapted from Python's Objects/listobject.c:listindex */\nPyObject *\ncorrect_usage_of_converter(PyObject *self, PyObject *args)\n{\n    Py_ssize_t start, stop;\n    if (!PyArg_ParseTuple(args, \"O&O&\",\n                          _PyEval_SliceIndex, &start,\n                          _PyEval_SliceIndex, &stop)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/correct_converter/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/encodings/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n */\n#include <Python.h>\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    char *buffer = \"I am a buffer\";\n    int ival;\n\n    if (!PyArg_ParseTuple(args, \"et#\", \"utf-8\", &buffer, &ival)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/encodings/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/hash_format_codes.inc",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  The various format codes with a \"#\" work differently depending on whether\n  PY_SSIZE_T_CLEAN was defined before the #include <Python.h>\n\n  This file is #included by each of:\n    with_PY_SSIZE_T_CLEAN/input.c\n    without_PY_SSIZE_T_CLEAN/input.c\n  to verify how well we test these variants of the API\n*/\n#include <Python.h>\n\nPyObject *\nhash_format_codes(PyObject *self, PyObject *args)\n{\n    const char *str;\n    Py_UNICODE *unicode;\n    char *writable_str;\n    char *buffer = \"I am a buffer\";\n    const char *encoding = \"UTF-8\";\n\n    int ival;\n    Py_ssize_t sval;\n    char *keywords[] = {NULL};\n\n    /*\n      Verify the \"s#\" format code.\n    */\n\n    /* Try \"s#\" with an int: */\n    if (!PyArg_ParseTuple(args, \"s#\", &str, &ival)) {\n        return NULL;\n    }\n    if (!PyArg_ParseTupleAndKeywords(args, NULL,\n                                     \"s#\", keywords,\n                                     &str, &ival)) {\n        return NULL;\n    }\n\n    /* Try \"s#\" with an Py_ssize_t: */\n    if (!PyArg_ParseTuple(args, \"s#\", &str, &sval)) {\n        return NULL;\n    }\n    if (!PyArg_ParseTupleAndKeywords(args, NULL,\n                                     \"s#\", keywords,\n                                     &str, &sval)) {\n        return NULL;\n    }\n\n    /* (hopefully the above gives us sufficient coverage of the \"AndKeywords\"\n       variants) */\n\n    /* Try \"z#\" with an int... */\n    if (!PyArg_ParseTuple(args, \"z#\", &str, &ival)) {\n        return NULL;\n    }\n\n    /* ...and with a Py_ssize_t: */\n    if (!PyArg_ParseTuple(args, \"z#\", &str, &sval)) {\n        return NULL;\n    }\n\n\n    /* Try \"u#\" with an int: */\n    if (!PyArg_ParseTuple(args, \"u#\", &unicode, &ival)) {\n        return NULL;\n    }\n\n    /* ...and with a Py_ssize_t: */\n    if (!PyArg_ParseTuple(args, \"u#\", &unicode, &sval)) {\n        return NULL;\n    }\n\n\n    /*  Try \"es#\" with an int: */\n    if (!PyArg_ParseTuple(args, \"es#\", encoding, &buffer, &ival)) {\n        return NULL;\n    }\n\n    /* ...and with a Py_ssize_t: */\n    if (!PyArg_ParseTuple(args, \"es#\", encoding, &buffer, &sval)) {\n        return NULL;\n    }\n\n\n    /* Try \"et#\" with an int: */\n    if (!PyArg_ParseTuple(args, \"et#\", encoding, &buffer, &ival)) {\n        return NULL;\n    }\n\n    /* ...and with a Py_ssize_t: */\n    if (!PyArg_ParseTuple(args, \"et#\", encoding, &buffer, &sval)) {\n        return NULL;\n    }\n\n\n    /* Try \"t#\" with an int: */\n    if (!PyArg_ParseTuple(args, \"t#\", &writable_str, &ival)) {\n        return NULL;\n    }\n\n    /* ...and with a Py_ssize_t: */\n    if (!PyArg_ParseTuple(args, \"t#\", &writable_str, &sval)) {\n        return NULL;\n    }\n\n\n    /* Try \"w#\" with an int: */\n    if (!PyArg_ParseTuple(args, \"w#\", &writable_str, &ival)) {\n        return NULL;\n    }\n\n    /* ...and with a Py_ssize_t: */\n    if (!PyArg_ParseTuple(args, \"w#\", &writable_str, &sval)) {\n        return NULL;\n    }\n\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_code_z_hash/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Verify that the error message for bad types for code \"z#\" is correct\n  Bug reported in:\n    https://fedorahosted.org/pipermail/gcc-python-plugin/2011-June/000007.html\n*/\n\n#include <Python.h>\n\nstatic PyObject *\nincorrect_code_z_hash(PyObject *self, PyObject *args)\n{\n    const char *str;\n    float len; /* This is incorrect; should be \"int\" */\n\n    if (!PyArg_ParseTuple(args, \"z#\", &str, &len)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_code_z_hash/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_code_z_hash/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_code_z_hash/stderr.txt",
    "content": "In function 'incorrect_code_z_hash':\ntests/cpychecker/PyArg_ParseTuple/incorrect_code_z_hash/input.c:34:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"z#\" [enabled by default]\n  argument 4 (\"&len\") had type\n    \"float *\" (pointing to 32 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"z#\"\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nincorrect_usage_of_S_and_U(PyObject *self, PyObject *args)\n{\n    int val1;\n    int val2;\n\n    /* Incorrect: mismatching types: */\n    if (!PyArg_ParseTuple(args, \"SU\", &val1, &val2)) {\n        return NULL;\n    }\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U/stderr.txt",
    "content": "In function 'incorrect_usage_of_S_and_U':\ntests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U/input.c:29:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"SU\" [enabled by default]\n  argument 3 (\"&val1\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    one of \"struct PyStringObject * *\" or \"struct PyObject * *\"\n  for format code \"S\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_codes_S_and_U/input.c:29:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"SU\" [enabled by default]\n  argument 4 (\"&val2\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    one of \"struct PyUnicodeObject * *\" or \"struct PyObject * *\"\n  for format code \"U\"\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nextern void not_returning_int(void);\nextern int not_enough_args(PyObject *);\nextern int too_many_args(PyObject *, int *, int);\nextern int not_taking_PyObjectPtr(int, int);\nextern int convert_to_ssize(PyObject *, Py_ssize_t *);\n\nPyObject *\nincorrect_usages_of_converter(PyObject *self, PyObject *args)\n{\n    int i0;\n    int i1;\n    Py_ssize_t ssize0;\n\n    /* Not enough args: */\n    if (!PyArg_ParseTuple(args, \"O&\")) {\n        return NULL;\n    }\n    if (!PyArg_ParseTuple(args, \"O&\", 42)) {\n        return NULL;\n    }\n\n    /* First arg not even a pointer: */\n    if (!PyArg_ParseTuple(args, \"O&\", 42, &i1)) {\n        return NULL;\n    }\n\n    /* First arg not a function: */\n    if (!PyArg_ParseTuple(args, \"O&\", &i0, &i1)) {\n        return NULL;\n    }\n\n    /* Signature of callback is wrong: */\n    if (!PyArg_ParseTuple(args, \"O&\", not_returning_int, &i1)) {\n        return NULL;\n    }\n    if (!PyArg_ParseTuple(args, \"O&\", not_enough_args, &i1)) {\n        return NULL;\n    }\n    if (!PyArg_ParseTuple(args, \"O&\", too_many_args, &i1)) {\n        return NULL;\n    }\n    if (!PyArg_ParseTuple(args, \"O&\", not_taking_PyObjectPtr, &i1)) {\n        return NULL;\n    }\n\n    /* Second arg is not a pointer */\n    if (!PyArg_ParseTuple(args, \"O&\", convert_to_ssize, 42)) {\n        return NULL;\n    }\n\n    /* Mismatching second arg: */\n    if (!PyArg_ParseTuple(args, \"O&\", convert_to_ssize, &i0)) {\n        return NULL;\n    }\n\n    /* Correct usage: */\n    if (!PyArg_ParseTuple(args, \"O&\", convert_to_ssize, &ssize0)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_converters/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_converters/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/incorrect_converters/stderr.txt",
    "content": "In function 'incorrect_usages_of_converter':\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:36:nn: warning: Not enough arguments in call to PyArg_ParseTuple with format string \"O&\" [enabled by default]\n  expected 2 extra arguments:\n    \"int (converter)(PyObject *, T*)\" for some type T\n    \"T*\" for some type T\n  but got none\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:39:nn: warning: Not enough arguments in call to PyArg_ParseTuple with format string \"O&\" [enabled by default]\n  expected 2 extra arguments:\n    \"int (converter)(PyObject *, T*)\" for some type T\n    \"T*\" for some type T\n  but got 1:\n    \"int\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:44:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 3 (\"42\") had type\n    \"int\"\n  but was expecting\n    \"int (converter)(PyObject *, T*)\" for some type T\n  for format code \"O&\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:49:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 3 (\"&i0\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"int (converter)(PyObject *, T*)\" for some type T\n  for format code \"O&\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:54:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 3 (\"not_returning_int\") had type\n    \"void (*fn) ()\"\n  but was expecting\n    \"int (converter)(PyObject *, T*)\" for some type T\n  for format code \"O&\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:57:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 3 (\"not_enough_args\") had type\n    \"int (*fn) (struct PyObject *)\"\n  but was expecting\n    \"int (converter)(PyObject *, T*)\" for some type T\n  for format code \"O&\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:60:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 3 (\"too_many_args\") had type\n    \"int (*fn) (struct PyObject *, int *, int)\"\n  but was expecting\n    \"int (converter)(PyObject *, T*)\" for some type T\n  for format code \"O&\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:63:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 3 (\"not_taking_PyObjectPtr\") had type\n    \"int (*fn) (int, int)\"\n  but was expecting\n    \"int (converter)(PyObject *, T*)\" for some type T\n  for format code \"O&\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:68:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 4 (\"42\") had type\n    \"int\"\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits) (from second argument of \"int (*fn) (struct PyObject *, Py_ssize_t *)\")\n  for format code \"O&\"\ntests/cpychecker/PyArg_ParseTuple/incorrect_converters/input.c:73:nn: warning: Mismatching type in call to PyArg_ParseTuple with format code \"O&\" [enabled by default]\n  argument 4 (\"&i0\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits) (from second argument of \"int (*fn) (struct PyObject *, Py_ssize_t *)\")\n  for format code \"O&\"\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/keywords/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  A simple check of PyArg_ParseTupleAndKeywords\n*/\n\n#include <Python.h>\n\nstatic PyObject *\nparse_to_a_typedef(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    int val;\n    static char *keywords[] = { \"hi\" }; /* Note no NULL terminator.  */\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"i\", keywords, &val)) {\n        return NULL;\n    }\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs, \"i\", NULL, &val)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/keywords/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/keywords/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/keywords/stderr.txt",
    "content": "In function 'parse_to_a_typedef':\ntests/cpychecker/PyArg_ParseTuple/keywords/input.c:32:nn: warning: keywords to PyArg_ParseTupleAndKeywords are not NULL-terminated [enabled by default]\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/typedefs/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Verify that the checker can cope with typedefs of another type\n  c.f. error reported here:\n    https://fedorahosted.org/pipermail/gcc-python-plugin/2011-June/000006.html\n*/\n\n#include <Python.h>\n\n/* as seen in gdb source code: */\ntypedef unsigned PY_LONG_LONG gdb_py_ulongest;\n\nstatic PyObject *\nparse_to_a_typedef(PyObject *self, PyObject *args)\n{\n    gdb_py_ulongest val;\n\n    /*\n       \"K\" expects \"unsigned PY_LONG_LONG\", which \"val\" is, via a typedef\n    */\n    if (!PyArg_ParseTuple(args, \"K\", &val)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/typedefs/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  The various format codes with a \"#\" work differently depending on whether\n  PY_SSIZE_T_CLEAN was defined before the #include <Python.h>\n\n  This verifies the behavior for the case when it _is_ defined:\n*/\n#define PY_SSIZE_T_CLEAN\n#include <Python.h>\n\n#include \"../hash_format_codes.inc\"\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/stderr.txt",
    "content": "In file included from tests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/input.c:29:nn:\nIn function 'hash_format_codes':\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:49:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"s#\" [enabled by default]\n  argument 4 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"s#\"\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:52:37: warning: Mismatching type in call to PyArg_ParseTupleAndKeywords with format code \"s#\" [enabled by default]\n  argument 6 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"s#\"\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:72:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"z#\" [enabled by default]\n  argument 4 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"z#\"\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:83:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"u#\" [enabled by default]\n  argument 4 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"u#\"\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:94:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"es#\" [enabled by default]\n  argument 5 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"es#\"\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:105:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"et#\" [enabled by default]\n  argument 5 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"et#\"\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:116:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"t#\" [enabled by default]\n  argument 4 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"t#\"\ntests/cpychecker/PyArg_ParseTuple/with_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:127:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"w#\" [enabled by default]\n  argument 4 (\"&ival\") had type\n    \"int *\" (pointing to 32 bits)\n  but was expecting\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  for format code \"w#\"\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  The various format codes with a \"#\" work differently depending on whether\n  PY_SSIZE_T_CLEAN was defined before the #include <Python.h>\n\n  This verifies the behavior for the case when it is _not_ defined:\n*/\n#include <Python.h>\n\n#include \"../hash_format_codes.inc\"\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/stderr.txt",
    "content": "In file included from tests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/input.c:28:nn:\nIn function 'hash_format_codes':\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:59:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"s#\" [enabled by default]\n  argument 4 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"s#\"\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:62:37: warning: Mismatching type in call to PyArg_ParseTupleAndKeywords with format code \"s#\" [enabled by default]\n  argument 6 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"s#\"\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:77:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"z#\" [enabled by default]\n  argument 4 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"z#\"\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:88:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"u#\" [enabled by default]\n  argument 4 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"u#\"\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:99:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"es#\" [enabled by default]\n  argument 5 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"es#\"\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:110:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"et#\" [enabled by default]\n  argument 5 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"et#\"\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:121:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"t#\" [enabled by default]\n  argument 4 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"t#\"\ntests/cpychecker/PyArg_ParseTuple/without_PY_SSIZE_T_CLEAN/../hash_format_codes.inc:132:26: warning: Mismatching type in call to PyArg_ParseTuple with format code \"w#\" [enabled by default]\n  argument 4 (\"&sval\") had type\n    \"Py_ssize_t *\" (pointing to 64 bits)\n  but was expecting\n    \"int *\" (pointing to 32 bits)\n  for format code \"w#\"\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  http://docs.python.org/c-api/structures.html#PyMethodDef\n*/\n\n/*\n  Verify that the analyser can cope with various function signatures within\n  a table of PyMethodDef initializers\n*/\n\ntypedef struct MySubclass {\n    PyObject_HEAD\n    struct foo *f;\n} MySubclass;\n\nstatic PyObject *\ncorrect_pycfunction(PyObject *self, PyObject *args)\n{\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\ncorrect_subclass(MySubclass *self, PyObject *args)\n{\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\ncorrect_pycfunction_with_keywords(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    Py_RETURN_NONE;\n}\n\n/* etc */\n\nstatic PyMethodDef methods[] = {\n    {\"test1\", \n     (PyCFunction)correct_pycfunction,\n     0, /* ml_flags */\n     NULL},\n\n    {\"test2\", \n     (PyCFunction)correct_subclass,\n     0, /* ml_flags */\n     NULL},\n\n    {\"test3\", \n     (PyCFunction)correct_pycfunction_with_keywords,\n     (METH_VARARGS | METH_KEYWORDS),\n     NULL},\n\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=False)\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/correct/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/cpychecker/PyMethodDef/incorrect-types/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  http://docs.python.org/c-api/structures.html#PyMethodDef\n*/\n\n/*\n  Verify that the analyser warns about various incorrect function signatures\n  referred to from within a table of PyMethodDef initializers\n*/\n\ntypedef struct MySubclass {\n    PyObject_HEAD\n    struct foo *f;\n} MySubclass;\n\nstatic PyObject *\nincorrect_pycfunction(PyObject *self, PyObject *args)\n{\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\nincorrect_subclass(MySubclass *self, PyObject *args)\n{\n    Py_RETURN_NONE;\n}\n\nstatic PyObject *\nincorrect_pycfunction_with_keywords(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    Py_RETURN_NONE;\n}\n\n/* etc */\n\nstatic PyMethodDef methods[] = {\n    /* Mismatching flags vs signature: */\n    {\"test1\", \n     (PyCFunction)incorrect_pycfunction,\n     (METH_VARARGS | METH_KEYWORDS),\n     NULL},\n\n    /* Mismatching flags vs signature: */\n    {\"test2\", \n     (PyCFunction)incorrect_subclass,\n     (METH_VARARGS | METH_KEYWORDS),\n     NULL},\n\n    /* Mismatching flags vs signature: */\n    {\"test3\", \n     (PyCFunction)incorrect_pycfunction_with_keywords,\n     0, /* ml_flags */\n     NULL},\n\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/incorrect-types/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/incorrect-types/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=False)\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/incorrect-types/stderr.txt",
    "content": "tests/cpychecker/PyMethodDef/incorrect-types/input.c:59:nn: warning: flags do not match callback signature for 'incorrect_pycfunction' within PyMethodDef table [enabled by default]\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:59:nn: note: expected ml_meth callback of type \"PyObject (fn)(someobject *, PyObject *args, PyObject *kwargs)\" due to METH_KEYWORDS flag (3 arguments)\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:59:nn: note: actual type of underlying callback: struct PyObject * <Tnnn> (struct PyObject *, struct PyObject *) (2 arguments)\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:59:nn: note: see http://docs.python.org/c-api/structures.html#PyMethodDef\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:65:nn: warning: flags do not match callback signature for 'incorrect_subclass' within PyMethodDef table [enabled by default]\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:65:nn: note: expected ml_meth callback of type \"PyObject (fn)(someobject *, PyObject *args, PyObject *kwargs)\" due to METH_KEYWORDS flag (3 arguments)\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:65:nn: note: actual type of underlying callback: struct PyObject * <Tnnn> (struct MySubclass *, struct PyObject *) (2 arguments)\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:65:nn: note: see http://docs.python.org/c-api/structures.html#PyMethodDef\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:71:nn: warning: flags do not match callback signature for 'incorrect_pycfunction_with_keywords' within PyMethodDef table [enabled by default]\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:71:nn: note: expected ml_meth callback of type \"PyObject (fn)(someobject *, PyObject *)\" (2 arguments)\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:71:nn: note: actual type of underlying callback: struct PyObject * <Tnnn> (struct PyObject *, struct PyObject *, struct PyObject *) (3 arguments)\ntests/cpychecker/PyMethodDef/incorrect-types/input.c:71:nn: note: see http://docs.python.org/c-api/structures.html#PyMethodDef\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/incorrect-types/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/cpychecker/PyMethodDef/missing-sentinel/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  http://docs.python.org/c-api/structures.html#PyMethodDef\n*/\n\n/*\n  Verify that the analyser warns about a table of PyMethodDef initializers\n  missing a sentinel value\n*/\n\nstatic PyObject *\ncorrect_pycfunction(PyObject *self, PyObject *args)\n{\n    Py_RETURN_NONE;\n}\n\nstatic PyMethodDef methods[] = {\n    {\"test\",\n     (PyCFunction)correct_pycfunction,\n     0, /* ml_flags */\n     NULL},\n\n    /* missing a sentinel value */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/missing-sentinel/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/missing-sentinel/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=False)\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/missing-sentinel/stderr.txt",
    "content": "tests/cpychecker/PyMethodDef/missing-sentinel/input.c:39:nn: warning: missing NULL sentinel value at end of PyMethodDef table [enabled by default]\n"
  },
  {
    "path": "tests/cpychecker/PyMethodDef/missing-sentinel/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_O/subclass/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Example of a PyObject subclass */\nstruct SomeObject {\n    PyObject_HEAD\n    int some_field;\n};\n\n/* Instance of the PyObject subclass */\nstruct SomeObject *global_instance;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /* \n       Although \"O\" expects a (PyObject*), a subclass should be acceptable\n       also:\n    */\n    return Py_BuildValue(\"O\", global_instance);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_O/subclass/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_c/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify handling of the \"c\" format code to Py_BuildValue: */\n\nPyObject *\ntest(char ch)\n{\n    return Py_BuildValue(\"c\", ch);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_c/correct/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_f/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify handling of the \"f\" format code to Py_BuildValue: */\n\nPyObject *\ntest(float x, float y, float z)\n{\n    return Py_BuildValue(\"fff\", x, y, z);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_f/correct/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_lower_d/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify handling of the \"d\" format code to Py_BuildValue: */\n\nPyObject *\ntest(double x, double y, double z)\n{\n    return Py_BuildValue(\"ddd\", x, y, z);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_lower_d/correct/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_s_hash/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify handling of the \"s#\" format code to Py_BuildValue: */\n\nPyObject *\ntest(char *str, int len)\n{\n    return Py_BuildValue(\"s#\", str, len);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_s_hash/correct/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_u/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify handling of the \"u\" format code to Py_BuildValue: */\n\nPyObject *\ntest(Py_UNICODE *u)\n{\n    return Py_BuildValue(\"u\", u);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_u/correct/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_u_hash/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify handling of the \"u#\" format code to Py_BuildValue: */\n\nPyObject *\ntest(Py_UNICODE *u, int len)\n{\n    return Py_BuildValue(\"u#\", u, len);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_u_hash/correct/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_upper_D/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify handling of the \"D\" format code to Py_BuildValue: */\n\nPyObject *\ntest(Py_complex *c)\n{\n    return Py_BuildValue(\"D\", c);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_upper_D/correct/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_upper_D/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify detection of incorrect \"D\" format code to Py_BuildValue: */\n\nPyObject *\ntest(double d)\n{\n    /* BUG: expects a (Py_complex*): */\n    return Py_BuildValue(\"D\", d);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_upper_D/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_upper_D/incorrect/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/cpychecker/Py_BuildValue/code_upper_D/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/Py_BuildValue/code_upper_D/incorrect/input.c:25:nn: warning: Mismatching type in call to Py_BuildValue with format code \"D\" [enabled by default]\n  argument 2 (\"d\") had type\n    \"double\"\n  but was expecting\n    \"struct Py_complex *\"\n  for format code \"D\"\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of various arithmetic operations\n*/\n\nextern void __cpychecker_dump(int);\n\nint\ntest(void)\n{\n    int i = 0;\n\n    __cpychecker_dump(i++);\n    __cpychecker_dump(i++);\n    __cpychecker_dump(i--);\n    __cpychecker_dump(i * 2);\n    __cpychecker_dump(i / 2);\n    __cpychecker_dump(i % 2);\n    __cpychecker_dump(-i);\n\n    __cpychecker_dump(abs(i));\n    __cpychecker_dump(abs(-i));\n\n    /* Bitwise: */\n    i |= 0xf0f0;\n    i &= 0xaaaa;\n    i ^= 0xaaaa;\n    __cpychecker_dump(i);\n\n\n    i = ~i;\n    __cpychecker_dump(i);\n\n    /* Bit shifting */\n    i <<= 2;\n    i >>= 1;\n\n    return i;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((int)0 from tests/cpychecker/absinterp/arithmetic/correct/input.c:31)'\n    '__dump((int)1 from tests/cpychecker/absinterp/arithmetic/correct/input.c:33)'\n    '__dump((int)2 from tests/cpychecker/absinterp/arithmetic/correct/input.c:34)'\n    '__dump((int)2 from tests/cpychecker/absinterp/arithmetic/correct/input.c:36)'\n    '__dump((int)0 from tests/cpychecker/absinterp/arithmetic/correct/input.c:37)'\n    '__dump((int)1 from tests/cpychecker/absinterp/arithmetic/correct/input.c:38)'\n    '__dump((int)-1 from tests/cpychecker/absinterp/arithmetic/correct/input.c:39)'\n    '__dump((int)1 from tests/cpychecker/absinterp/arithmetic/correct/input.c:41)'\n    '__dump((int)1 from tests/cpychecker/absinterp/arithmetic/correct/input.c:42)'\n    '__dump((int)2570 from tests/cpychecker/absinterp/arithmetic/correct/input.c:47)'\n    '__dump((int)-2571 from tests/cpychecker/absinterp/arithmetic/correct/input.c:51)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/arithmetic/correct/input.c', line=56), value=-5142)\n    str(): (int)-5142 from tests/cpychecker/absinterp/arithmetic/correct/input.c:56\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that division-by-zero doesn't lead to a Python traceback:\n    https://fedorahosted.org/gcc-python-plugin/ticket/25\n*/\n\nint\ntest(int i)\n{\n    return i % 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c:30:nn: warning: division by zero [-Wdiv-by-zero]\ntests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c:30:nn: warning: integer division or modulo by zero with right-hand-side (int)0 from tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c:30 [enabled by default]\ntests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: PredictedArithmeticError()\n  error: integer division or modulo by zero with right-hand-side (int)0 from tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c:30\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/division-by-zero/definite/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that possible division-by-zero doesn't lead to a Python traceback:\n    https://fedorahosted.org/gcc-python-plugin/ticket/25\n*/\n\nint\ntest(int i, unsigned int j)\n{\n    return i % j;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering j == (unsigned int)0 from tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/input.c:28'\n  error: PredictedArithmeticError()\n  error: possible integer division or modulo by zero with right-hand-side (unsigned int)0 from tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/input.c:28\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/input.c:29\n\nTrace 1:\n  Transitions:\n    'when considering range: 1 <= j <= 0xffffffff'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='unsigned int', loc=gcc.Location(file='tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/input.c', line=30), minvalue=0, maxvalue=0x7fffffff)\n    str(): (unsigned int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/input.c:30\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/division-by-zero/possible/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/fix-trunc-expr/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of gcc.FixTruncExpr\n*/\n\nint\ntest(float x)\n{\n    return (int)x;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/fix-trunc-expr/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/fix-trunc-expr/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/arithmetic/fix-trunc-expr/input.c', line=29), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/arithmetic/fix-trunc-expr/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/fix-trunc-expr/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that a definite negative shift doesn't lead to a Python\n  traceback:\n    https://fedorahosted.org/gcc-python-plugin/ticket/14\n*/\n\nint\ntest(int i)\n{\n    return i << -3;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/definite/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/definite/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/definite/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c:31:nn: warning: left shift count is negative [enabled by default]\ntests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c:31:nn: warning: negative shift count with right-hand-side (int)-3 from tests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c:31 [enabled by default]\ntests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/definite/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: PredictedArithmeticError()\n  error: negative shift count with right-hand-side (int)-3 from tests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c:31\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/negative-shift/definite/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/possible/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the possibility of a negative shifts don't lead to a Python\n  traceback:\n    https://fedorahosted.org/gcc-python-plugin/ticket/14\n*/\n\nint\ntest(int i, int j)\n{\n    return i << j;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/possible/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arithmetic/negative-shift/possible/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= j <= -1'\n  error: PredictedArithmeticError()\n  error: possible negative shift count with right-hand-side (int)val [-0x80000000 <= val <= -1] from tests/cpychecker/absinterp/arithmetic/negative-shift/possible/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/negative-shift/possible/input.c:30\n\nTrace 1:\n  Transitions:\n    'when considering range: 0 <= j <= 0x7fffffff'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/arithmetic/negative-shift/possible/input.c', line=31), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/arithmetic/negative-shift/possible/input.c:31\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arithmetic/negative-shift/possible/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/fully-checked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading from an array where the read can be proven to be within\n  the correct region\n*/\n\nextern void __cpychecker_dump(int);\n\nstatic char array[12] = {2, 2, 2, 2, 8, 1, 8, 1, 8, 2, 8, 2};    \n\nint\ntest(int i)\n{\n    __cpychecker_dump(i);\n\n    if (i < 0) {\n        /* Explicit check against lower bound: */\n        __cpychecker_dump(i);\n        return 0;\n    }\n\n    __cpychecker_dump(i);\n\n    if (i >= 12) {\n        /* Explicit check against upper bound: */\n        __cpychecker_dump(i);\n        return 1;\n    }\n\n    __cpychecker_dump(i);\n\n    /* This read is now provably within the array bounds: */\n    if (array[i] == 8) {\n        return 2;\n    }\n    return 3;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/fully-checked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/fully-checked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    '__dump((int)val [-0x80000000 <= val <= -1] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:33\n\nTrace 1:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 0 <= value <= 11'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 11] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: -128 <= value <= 7'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked/input.c', line=56), value=3)\n    str(): (int)3 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:56\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:33\n\nTrace 2:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 0 <= value <= 11'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 11] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering value == (char)8 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:53'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked/input.c', line=54), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:54\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:33\n\nTrace 3:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 0 <= value <= 11'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 11] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 9 <= value <= 127'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked/input.c', line=56), value=3)\n    str(): (int)3 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:56\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:33\n\nTrace 4:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'when considering range: 12 <= value <= 0x7fffffff'\n    'taking True path'\n    '__dump((int)val [12 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked/input.c:32)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked/input.c', line=47), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:47\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading from an array where the read can be proven to be within\n  the correct region\n*/\n\nextern void __cpychecker_dump(int);\n\nint\ntest(int i)\n{\n    char array[12] = {2, 2, 2, 2, 8, 1, 8, 1, 8, 2, 8, 2};\n    \n    __cpychecker_dump(i);\n\n    if (i < 0) {\n        /* Explicit check against lower bound: */\n        __cpychecker_dump(i);\n        return 0;\n    }\n\n    __cpychecker_dump(i);\n\n    if (i >= 12) {\n        /* Explicit check against upper bound: */\n        __cpychecker_dump(i);\n        return 1;\n    }\n\n    __cpychecker_dump(i);\n\n\n    /*\n      This read is now provably within the array bounds.\n\n      However, array has been initialized element-by-element.\n      We need the checker to be smart enough to know that every element\n      that could be accessed is initialized, rather than falling back to\n      the default \"uninitialized\" value for the whole of the array region\n\n      See what the checker is able to determine about 'array[i]'\n      It ought to be able to determine that it is the range [1-8], based on\n      the initializations of 'array' above:\n     */\n    __cpychecker_dump(array[i]);\n    if (array[i] == 8) {\n        /*\n          In theory we could also figure out that for this to be the case,\n          'i' must be in the range [4-10].  However, the checker doesn't\n          do this yet.\n        */\n        return 2;\n    }\n    return 3;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/fully-checked-on-stack/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/fully-checked-on-stack/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    '__dump((int)val [-0x80000000 <= val <= -1] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:31\n\nTrace 1:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'when considering range: 0 <= value <= 11'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 11] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    '__dump((char)val [1 <= val <= 8] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:32)'\n    'when considering range: 1 <= value <= 7'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c', line=74), value=3)\n    str(): (int)3 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:74\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:31\n\nTrace 2:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'when considering range: 0 <= value <= 11'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 11] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    '__dump((char)val [1 <= val <= 8] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:32)'\n    'when considering value == (char)8 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:32'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c', line=72), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:72\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:31\n\nTrace 3:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [0 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'when considering range: 12 <= value <= 0x7fffffff'\n    'taking True path'\n    '__dump((int)val [12 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:30)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c', line=47), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:47\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/fully-checked-on-stack/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/implicitly-correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading from an array where the read can be proven to be within\n  the array bounds, where the proof requires knowledge of bit operations\n*/\n\nextern void __cpychecker_dump(int);\n\nchar array[12] = {2, 2, 2, 2, 8, 1, 8, 1, 8, 2, 8, 2};\n\nint\ntest(int i)\n{\n    __cpychecker_dump(i);\n\n    /* This ought to constrain i to within [0-255]: */\n    i = i & 0xff;\n    __cpychecker_dump(i);\n\n    /* and this ought to constrain it to within [0-7]: */\n    i = i >> 5;\n    __cpychecker_dump(i);\n\n    /* and hence this read is within the array bounds: */\n    if (array[i] == 8) {\n        return 1;\n    }\n    return 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/implicitly-correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/implicitly-correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:32)'\n    '__dump((int)val [0 <= val <= 255] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:37)'\n    '__dump((int)val [0 <= val <= 7] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:41)'\n    'when considering range: -128 <= value <= 7'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/implicitly-correct/input.c', line=48), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:48\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:33\n\nTrace 1:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:32)'\n    '__dump((int)val [0 <= val <= 255] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:37)'\n    '__dump((int)val [0 <= val <= 7] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:41)'\n    'when considering value == (char)8 from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:45'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/implicitly-correct/input.c', line=46), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:46\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:33\n\nTrace 2:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:32)'\n    '__dump((int)val [0 <= val <= 255] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:37)'\n    '__dump((int)val [0 <= val <= 7] from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:41)'\n    'when considering range: 9 <= value <= 127'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/implicitly-correct/input.c', line=48), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:48\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/implicitly-correct/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/off-by-one/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading from an array where the index is checked, but has an\n  off-by-one error\n*/\n\nextern void __cpychecker_dump(int);\n\nchar array[12] = {2, 2, 2, 2, 8, 1, 8, 1, 8, 2, 8, 2};\n\nint\ntest(int i)\n{\n    __cpychecker_dump(i);\n\n    /* \n       This boundary check has an off-by-one error: it checks\n         <= sizeof(array)\n       when it should check:\n         < sizeof(array)\n\n       Hence when i == 12 there's a read of one past the end of the array\n    */\n    if (i <= 12) {\n\n        __cpychecker_dump(i);\n\n        if (array[i] == 8) {\n            return 0;\n        }\n        return 1;\n    }\n\n    __cpychecker_dump(i);\n\n    return 2;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/off-by-one/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/off-by-one/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'when considering range: -0x80000000 <= value <= 12'\n    'taking True path'\n    '__dump((int)val [-0x80000000 <= val <= 12] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'when considering range: -128 <= value <= 7'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/off-by-one/input.c', line=51), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:51\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:33\n\nTrace 1:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'when considering range: -0x80000000 <= value <= 12'\n    'taking True path'\n    '__dump((int)val [-0x80000000 <= val <= 12] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'when considering value == (char)8 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:48'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/off-by-one/input.c', line=49), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:49\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:33\n\nTrace 2:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'when considering range: -0x80000000 <= value <= 12'\n    'taking True path'\n    '__dump((int)val [-0x80000000 <= val <= 12] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'when considering range: 9 <= value <= 127'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/off-by-one/input.c', line=51), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:51\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:33\n\nTrace 3:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'when considering range: 13 <= value <= 0x7fffffff'\n    'taking False path'\n    '__dump((int)val [13 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/off-by-one/input.c:32)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/off-by-one/input.c', line=56), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:56\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/off-by-one/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading from an array where the read can be proven to be within\n  the correct region, but the array has only a subrange of explicit initial\n  values, with implicit zero initialization, as per K&R 2nd edn, p86.\n\n  This is handled internally using a gcc.Constructor() expression.\n*/\n\nextern void __cpychecker_dump(int);\n\nvoid\ntest(int i)\n{\n    /*\n      This initialization doesn't list explicit values for all items, leading\n      to a gcc.Constructor() for the implicit zero-fill of the others.\n    */\n    short array[9] = {42};\n\n    __cpychecker_dump(array[0]); /* should be 42 */\n    __cpychecker_dump(array[11]); /* should be 0 */\n\n    __cpychecker_dump(i);\n\n    i = (i & 0x7) + 1;\n    /* i should now be provably in the range [1-8]: */\n    __cpychecker_dump(i);\n\n    /* array[i] should provably be 0: */\n    __cpychecker_dump(array[i]);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((short int)42 from tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/input.c:39)'\n    '__dump((short int)0 from tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/input.c:42)'\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/input.c:33)'\n    '__dump((int)val [1 <= val <= 8] from tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/input.c:46)'\n    '__dump((short int)0 from tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/input.c:51)'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/partial-initialization-on-stack/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/unchecked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading from an array where the read might be from outside\n  the array bounds\n*/\n\nextern void __cpychecker_dump(int);\n\nstatic char array[12] = {2, 2, 2, 2, 8, 1, 8, 1, 8, 2, 8, 2};\n\nint\ntest(int i)\n{\n    __cpychecker_dump(i);\n\n    if (array[i] == 8) {\n        return 1;\n    }\n    return 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/unchecked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/unchecked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/unchecked/input.c:32)'\n    'when considering range: -128 <= value <= 7'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/unchecked/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/unchecked/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/unchecked/input.c:33\n\nTrace 1:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/unchecked/input.c:32)'\n    'when considering value == (char)8 from tests/cpychecker/absinterp/array-range/unchecked/input.c:36'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/unchecked/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/unchecked/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/unchecked/input.c:33\n\nTrace 2:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/array-range/unchecked/input.c:32)'\n    'when considering range: 9 <= value <= 127'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/unchecked/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/unchecked/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/unchecked/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/upper-checked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading from an array where the index is only checked against the\n  size of the array, not against >= 0\n*/\n\nextern char array[12];\n\nint\ntest(signed int i)\n{\n    if (i < 12) {\n        /* \n           At this point we know we're within the upper bound of the array\n           However, i could still be negative:\n        */\n        if (array[i] == 8) {\n            return 0;\n        } else {\n            return 1;\n        }\n    }\n\n    return 2;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/upper-checked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/array-range/upper-checked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= 11'\n    'taking True path'\n    'when considering range: -128 <= value <= 7'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/upper-checked/input.c', line=40), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:40\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:31\n\nTrace 1:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= 11'\n    'taking True path'\n    'when considering value == (char)8 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:37'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/upper-checked/input.c', line=38), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:38\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:31\n\nTrace 2:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= 11'\n    'taking True path'\n    'when considering range: 9 <= value <= 127'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/upper-checked/input.c', line=40), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:40\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:31\n\nTrace 3:\n  Transitions:\n    'when considering range: 12 <= value <= 0x7fffffff'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/array-range/upper-checked/input.c', line=44), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:44\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/array-range/upper-checked/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading and writing simple arrays\n*/\nint test_arrays(void)\n{\n    int arr[10];\n    int *ptr = &arr[5];\n\n    *ptr = 41;\n    arr[5] += 1;\n\n    /*\n      The analyser ought to be able to figure out that there's a single trace\n      with return value 42 (rather than uninitialized data):\n    */\n    return arr[5];\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/arrays/input.c', line=31), value=42)\n    str(): (int)42 from tests/cpychecker/absinterp/arrays/input.c:31\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays2/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading and writing simple arrays via pointers\n*/\nint test_arrays2(void)\n{\n    int arr[10];\n    int *ptr = arr;\n\n    ptr[0] = 1;\n    ptr[1] = 2;\n    ptr[2] = 3;\n\n    /*\n      The analyser ought to be able to figure out that there's a single trace\n      with return value 6 (rather than \"unknown\", or uninitialized data):\n    */\n    return arr[0] + arr[1] + arr[2];\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays2/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays2/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/arrays2/input.c', line=38), value=6)\n    str(): (int)6 from tests/cpychecker/absinterp/arrays2/input.c:38\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays2/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays3/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of handling a pointer like an array\n*/\n\ntypedef struct foo\n{\n    const char *fieldA;\n    const char *fieldB;\n} Foo;\n\nextern Foo *foo_array;\n\nstatic const char*\ntest(int i)\n{\n    return foo_array[i].fieldA;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays3/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays3/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/arrays3/input.c:37 as non-NULL'\n    'returning'\n  Return value:\n    repr(): UnknownValue(gcctype=gcc.PointerType(dereference=gcc.IntegerType(name=gcc.TypeDecl('char'))), loc=gcc.Location(file='tests/cpychecker/absinterp/arrays3/input.c', line=37))\n    str(): unknown const char * from tests/cpychecker/absinterp/arrays3/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays3/input.c:36\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/arrays3/input.c:37 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (D.nnnnn->fieldA) at tests/cpychecker/absinterp/arrays3/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays3/input.c:36\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays4/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of handling an array with an unknown index\n*/\n\ntypedef struct foo\n{\n    const char *fieldA;\n    const char *fieldB;\n} Foo;\n\nextern Foo foo_array[10];\n\nstatic const char*\ntest(int i)\n{\n    return foo_array[i].fieldA;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays4/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays4/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): UnknownValue(gcctype=gcc.PointerType(dereference=gcc.IntegerType(name=gcc.TypeDecl('char'))), loc=gcc.Location(file='tests/cpychecker/absinterp/arrays4/input.c', line=37))\n    str(): unknown const char * from tests/cpychecker/absinterp/arrays4/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays4/input.c:36\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays5/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading and writing simple arrays via pointers\n*/\nint test_arrays5(void)\n{\n    int arr[10];\n    int *ptr = arr + 3;\n\n    ptr[0] = 1;\n    ptr[1] = 2;\n    ptr[2] = 3;\n\n    /*\n      The analyser ought to be able to figure out that there's a single trace\n      with return value 6 (rather than \"unknown\", or uninitialized data):\n    */\n    return arr[3] + arr[4] + arr[5];\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays5/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays5/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/arrays5/input.c', line=38), value=6)\n    str(): (int)6 from tests/cpychecker/absinterp/arrays5/input.c:38\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays5/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays6/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reading and writing simple arrays via pointers\n*/\nint test_arrays6(void)\n{\n    int arr[10];\n    int *ptr = arr;\n\n    ptr[0] = 42;\n\n    /*\n      The analyser ought to figure out that arr[1] is still uninitialized:\n    */\n    return arr[0] + arr[1];\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays6/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays6/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays6/stderr.txt",
    "content": "In function 'test_arrays6':\ntests/cpychecker/absinterp/arrays6/input.c:35:nn: warning: usage of uninitialized data (D.nnnnn) on right-hand side of + at tests/cpychecker/absinterp/arrays6/input.c:35 [enabled by default]\ntests/cpychecker/absinterp/arrays6/input.c:26:nn: note: graphical error report for function 'test_arrays6' written out to 'tests/cpychecker/absinterp/arrays6/input.c.test_arrays6-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays6/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: UsageOfUninitializedData()\n  error: usage of uninitialized data (D.nnnnn) on right-hand side of + at tests/cpychecker/absinterp/arrays6/input.c:35\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays6/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays7/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that we can retrieve an array element using a computed index of 0:\n*/\n\nchar *\ntest(char **arr)\n{\n    int i = 0;\n\n    /* store using a int constant: */\n    arr[0] = \"foo\";  /* this writes *arr = \"foo\" */\n\n    /* retrive using a variable lookup: */\n    return arr[i];   /* this reads *(arr + (0 * 8)) */\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays7/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/arrays7/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown char * * from tests/cpychecker/absinterp/arrays7/input.c:27 as non-NULL'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='char[4] *', loc=gcc.Location(file='tests/cpychecker/absinterp/arrays7/input.c', line=32), region=ArrayElementRegion('foo[0]'))\n    str(): (char[4] *)&ArrayElementRegion('foo[0]') from tests/cpychecker/absinterp/arrays7/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays7/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown char * * from tests/cpychecker/absinterp/arrays7/input.c:27 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (*arr) at tests/cpychecker/absinterp/arrays7/input.c:35\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/arrays7/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/absinterp/asm/empty/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Test that the checker can cope with an empty fragment of inline\n  assembler (as seen e.g. in curl's typecheck-gcc.h , as used by\n  pycurl)\n*/\n\nvoid\ntest(void)\n{\n    /* Empty assembler fragment:  */\n    __asm__(\"\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/asm/empty/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False,\n     only_on_python_code=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/asm/empty/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/assignment-from-string-const/input.c",
    "content": "/*\n   Copyright 2014 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2014 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nchar test_string(const char *src)\n{\n    char buf[256]=\"\";\n    strncpy(buf, src, 256);\n    return buf[0];\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/assignment-from-string-const/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/assignment-from-string-const/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): UnknownValue(gcctype=gcc.PointerType(dereference=<gcc.ArrayType object at 0xdeadbeef>), loc=gcc.Location(file='tests/cpychecker/absinterp/assignment-from-string-const/input.c', line=25))\n    str(): unknown char[256] * from tests/cpychecker/absinterp/assignment-from-string-const/input.c:25\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/assignment-from-string-const/input.c:23\n"
  },
  {
    "path": "tests/cpychecker/absinterp/bitfields/reading/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Test of reading from a bitfield\n*/\nstruct Foo {\n    int a : 4;\n    int b : 2;\n    int c : 1;\n};\n\nextern void __cpychecker_dump(int);\n\nint test(struct Foo *foo)\n{\n    if (foo->a == 3) {\n        return 0;\n    }\n    __cpychecker_dump(foo->a);\n\n    __cpychecker_dump(foo->b);\n\n    if (foo->c) {\n        return 1;\n    } else {\n        return 2;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/bitfields/reading/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     only_on_python_code=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/bitfields/reading/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: 0 <= value <= 2'\n    'taking False path'\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/bitfields/reading/input.c:31 as non-NULL'\n    'when considering value == (unsigned char)0 from tests/cpychecker/absinterp/bitfields/reading/input.c:40'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/bitfields/reading/input.c', line=43), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/bitfields/reading/input.c:43\n\nTrace 1:\n  Transitions:\n    'when considering range: 0 <= value <= 2'\n    'taking False path'\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/bitfields/reading/input.c:31 as non-NULL'\n    'when considering range: 1 <= value <= 64'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/bitfields/reading/input.c', line=41), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/bitfields/reading/input.c:41\n\nTrace 2:\n  Transitions:\n    'when considering range: 0 <= value <= 2'\n    'taking False path'\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/bitfields/reading/input.c:31 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (foo->a) at tests/cpychecker/absinterp/bitfields/reading/input.c:36\n\nTrace 3:\n  Transitions:\n    'when considering value == (unsigned char)3 from tests/cpychecker/absinterp/bitfields/reading/input.c:33'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/bitfields/reading/input.c', line=34), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/bitfields/reading/input.c:34\n\nTrace 4:\n  Transitions:\n    'when considering range: 4 <= value <= 15'\n    'taking False path'\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/bitfields/reading/input.c:31 as non-NULL'\n    'when considering value == (unsigned char)0 from tests/cpychecker/absinterp/bitfields/reading/input.c:40'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/bitfields/reading/input.c', line=43), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/bitfields/reading/input.c:43\n\nTrace 5:\n  Transitions:\n    'when considering range: 4 <= value <= 15'\n    'taking False path'\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/bitfields/reading/input.c:31 as non-NULL'\n    'when considering range: 1 <= value <= 64'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/bitfields/reading/input.c', line=41), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/bitfields/reading/input.c:41\n\nTrace 6:\n  Transitions:\n    'when considering range: 4 <= value <= 15'\n    'taking False path'\n    'when treating unknown struct Foo * from tests/cpychecker/absinterp/bitfields/reading/input.c:31 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (foo->a) at tests/cpychecker/absinterp/bitfields/reading/input.c:36\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-with-extraction/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correctly truncating from an int to a char\n*/\n\nextern void __cpychecker_dump(char);\n\nextern int foo(int);\n\nint\ntest(int i)\n{\n    char ch;\n    int j;\n\n    j = foo(i);\n\n    /* \n       This implicitly truncates from int to char, but the range ought to be\n       OK:\n    */\n    ch = j & 0xff;\n\n    __cpychecker_dump(ch);\n\n    /* and this implicitly expands from char back to int: */\n    return ch;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-with-extraction/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-with-extraction/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((char)val [-128 <= val <= 127] from tests/cpychecker/absinterp/casts/int-to-char-with-extraction/input.c:42)'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='char', loc=gcc.Location(file='tests/cpychecker/absinterp/casts/int-to-char-with-extraction/input.c', line=42), minvalue=-128, maxvalue=127)\n    str(): (char)val [-128 <= val <= 127] from tests/cpychecker/absinterp/casts/int-to-char-with-extraction/input.c:42\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/casts/int-to-char-with-extraction/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of implicitly truncating from an int to a char, and back again\n*/\n\nextern void __cpychecker_dump(char);\n\nextern int foo(int);\n\nint\ntest(int i)\n{\n    char ch;\n\n    /* This implicitly truncates from int to char: */\n    ch = foo(i);\n\n    __cpychecker_dump(ch);\n\n    /* and this implicitly expands from char back to int: */\n    return ch;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((char)val [-128 <= val <= 127] from tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation/input.c:36)'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='char', loc=gcc.Location(file='tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation/input.c', line=36), minvalue=-128, maxvalue=127)\n    str(): (char)val [-128 <= val <= 127] from tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation/input.c:36\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/casts/int-to-char-with-implicit-truncation/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-within-range/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correctly truncating from an int to a char\n*/\n\nextern void __cpychecker_dump(int);\n\nextern int foo(int);\n\nchar\ntest(int i)\n{\n    char ch;\n    int j;\n\n    __cpychecker_dump(i);\n\n    j = foo(i);\n    __cpychecker_dump(j);\n\n    /* After this point, j should be known to be in the range [0-15] */\n    j = j & 0xf;\n    __cpychecker_dump(j);\n\n    /*\n       This implicitly truncates from int to char, but the known range ought\n       to be preserved within the narrower type, i.e. it ought to know ch is\n       in [0-15] rather than [0-255]:\n    */\n    ch = j;\n\n    /* The return value thus ought to be provably in the range [0-15]: */\n    return ch;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-within-range/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-char-within-range/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/casts/int-to-char-within-range/input.c:31)'\n    '__dump((int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/casts/int-to-char-within-range/input.c:38)'\n    '__dump((int)val [0 <= val <= 15] from tests/cpychecker/absinterp/casts/int-to-char-within-range/input.c:42)'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='char', loc=gcc.Location(file='tests/cpychecker/absinterp/casts/int-to-char-within-range/input.c', line=50), minvalue=0, maxvalue=15)\n    str(): (char)val [0 <= val <= 15] from tests/cpychecker/absinterp/casts/int-to-char-within-range/input.c:50\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/casts/int-to-char-within-range/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-float/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Regression test for:\n     NotImplementedError: Don't know how to cope with exprcode: <type 'gcc.FloatExpr'> (<type 'gcc.FloatExpr'>) at pyalsa/alsaseq.c:1762\n  seen in many places\n*/\nfloat\ntest(int i)\n{\n    return i / 42.0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-float/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-pointer/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Regression test for:\n     AttributeError: 'gcc.PointerType' object has no attribute 'min_value'\n  seen compiling SWIG_ConvertPtr\n*/\n\nvoid\ntest(void **ptr)\n{\n    unsigned long p;\n\n    p = 0;\n    *ptr = (void *) p;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-pointer/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-pointer/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-pointer2/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Regression test for:\n     AttributeError: 'gcc.PointerType' object has no attribute 'min_value'\n  seen compiling SWIG_NewPointerObj\n*/\n\nlong foo(void);\n\nvoid\ntest(void **ptr)\n{\n    *ptr = (void*)foo();\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/int-to-pointer2/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/pointer-to-long/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of casting from a pointer to a long\n*/\n\nlong\ntest(void *ptr)\n{\n    return (long)ptr;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/pointer-to-long/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/pointer-to-long/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='long int', loc=gcc.Location(file='tests/cpychecker/absinterp/casts/pointer-to-long/input.c', line=29), minvalue=-0x8000000000000000, maxvalue=0x7fffffffffffffff)\n    str(): (long int)val [-0x8000000000000000 <= val <= 0x7fffffffffffffff] from tests/cpychecker/absinterp/casts/pointer-to-long/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/casts/pointer-to-long/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/pyobjectptr-to-long/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of casting from a PyObject* to a long\n*/\n\nlong\ntest(PyObject *obj)\n{\n    return (long)obj;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/pyobjectptr-to-long/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/casts/pyobjectptr-to-long/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='long int', loc=gcc.Location(file='tests/cpychecker/absinterp/casts/pyobjectptr-to-long/input.c', line=29), minvalue=-0x8000000000000000, maxvalue=0x7fffffffffffffff)\n    str(): (long int)val [-0x8000000000000000 <= val <= 0x7fffffffffffffff] from tests/cpychecker/absinterp/casts/pyobjectptr-to-long/input.c:29\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/absinterp/casts/pyobjectptr-to-long/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/casts/pyobjectptr-to-long/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    unsigned int i = UINT_MAX;\n\n    /*\n      Test of:\n         ConcreteValue(UINT_MAX) == WithinRange(0, UINT_MAX)\n      Either branch is possible, the actual value of the WithinRange could be:\n        (a) in the subrange (0, UINT_MAX-1) -> FALSE, or could be\n        (b) == its max (UINT_MAX) -> TRUE\n    */\n    if (i == j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: 0 <= j.0 <= 0xfffffffe'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering j.0 == (const unsigned int)0xffffffff from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c:22'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-max-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    int i = 0;\n\n    /*\n      Test of:\n         ConcreteValue(0) == WithinRange(0, UINT_MAX)\n      Either branch is possible, the actual value of the WithinRange could be:\n        (a) == its min (0) -> TRUE, or could be\n        (b) in subrange (1, UINT_MAX) -> FALSE\n    */\n    if (i == j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering j.1 == (const unsigned int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c:22'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering range: 1 <= j.1 <= 0xffffffff'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-eq-min-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-max-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    unsigned int i = UINT_MAX;\n\n    /*\n      Test of:\n         ConcreteValue(UINT_MAX) >= WithinRange(0, UINT_MAX)\n      It must be true: it's >= every value in the range\n    */\n    if (i >= j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-max-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-max-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-max-of-WithinRange/input.c', line=35), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-max-of-WithinRange/input.c:35\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-max-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    int i = 0;\n\n    /*\n      Test of:\n         ConcreteValue(0) >= WithinRange(0, UINT_MAX)\n      Either branch is possible, the actual value of the WithinRange could be:\n        (a) == 0 (-> TRUE), or could be\n        (b) in subrange (1, UINT_MAX) -> FALSE\n    */\n    if (i >= j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering j.1 == (const unsigned int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c:22'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering range: 1 <= j.1 <= 0xffffffff'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-ge-min-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    unsigned int i = UINT_MAX;\n\n    /*\n      Test of:\n         ConcreteValue(UINT_MAX) > WithinRange(0, UINT_MAX)\n      Either branch is possible, the actual value of the WithinRange could be:\n        (a) in the subrange (0, UINT_MAX-1) -> TRUE, or could be\n        (b) == UINT_MAX -> FALSE\n    */\n    if (i > j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: 0 <= j.0 <= 0xfffffffe'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering j.0 == (const unsigned int)0xffffffff from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c:22'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-max-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-min-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    int i = 0;\n\n    /*\n      Test of:\n         ConcreteValue(0) > WithinRange(0, UINT_MAX)\n      It must be false: every value in the range is >= 0\n      FIXME: it's erroneously thinking both paths are possible\n    */\n    if (i > j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-min-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-min-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-min-of-WithinRange/input.c', line=38), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-min-of-WithinRange/input.c:38\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-gt-min-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    unsigned int i = UINT_MAX;\n\n    /*\n      Test of:\n         ConcreteValue(UINT_MAX) <= WithinRange(0, UINT_MAX)\n      Either branch is possible, the actual value of the WithinRange could be:\n        (a) in the subrange 0..UINT_MAX-1 -> FALSE, or could be\n        (b) == UINT_MAX -> TRUE\n    */\n    if (i <= j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: 0 <= j.0 <= 0xfffffffe'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering j.0 == (const unsigned int)0xffffffff from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c:22'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-max-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    int i = 0;\n\n    /*\n      Test of:\n         ConcreteValue(0) < WithinRange(0, UINT_MAX)\n      Either branch is possible, the actual value of the WithinRange could be:\n        (a) == 0 -> FALSE, or could be\n        (b) in the subrange [1, UINT_MAX] -> TRUE\n    */\n    if (i < j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering j.1 == (const unsigned int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c:22'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering range: 1 <= j.1 <= 0xffffffff'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-le-min-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-max-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    unsigned int i = UINT_MAX;\n\n    /*\n      Test of:\n         UINT_MAX < WithinRange(0, UINT_MAX)\n      It must be false: it is >= every value in the range\n    */\n    if (i < j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-max-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-max-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-max-of-WithinRange/input.c', line=37), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-max-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-max-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int j;\n\nint\ntest(void)\n{\n    int i = 0;\n\n    /*\n      Test of:\n         ConcreteValue(0) < WithinRange(0, UINT_MAX)\n      Either branch is possible, the actual value of the WithinRange could be:\n        (a) == 0 -> FALSE, or could be\n        (b) in subrange [1, UINT_MAX] -> TRUE\n    */\n    if (i < j) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering j.1 == (const unsigned int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c:22'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c', line=39), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering range: 1 <= j.1 <= 0xffffffff'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c', line=37), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-min-of-WithinRange/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nint\ntest(int j)\n{\n    int i = 0;\n    if (j < 0) {\n        return 0;\n    }\n    if (j >= 2) {\n        return 1;\n    }\n\n    /*\n      OK, j should now be WithinRange(0, 1)\n\n      Test of:\n         ConcreteValue(0) < WithinRange(0, 1)\n      Either branch is possible:\n    */\n    if (i < j) {\n        return 2; /* j should provably be 1 */\n    } else {\n        return 3; /* j should provably be 0 */\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c', line=27), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:27\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:24\n\nTrace 1:\n  Transitions:\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    'when considering range: 0 <= value <= 1'\n    'taking False path'\n    'when considering j == (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:23'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c', line=43), value=3)\n    str(): (int)3 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:43\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:24\n\nTrace 2:\n  Transitions:\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    'when considering range: 0 <= value <= 1'\n    'taking False path'\n    'when considering j == (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:23'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c', line=41), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:41\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:24\n\nTrace 3:\n  Transitions:\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    'when considering range: 2 <= value <= 0x7fffffff'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c', line=30), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:30\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/ConcreteValue-lt-two-value-range/input.c:24\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nint\ntest(int i)\n{\n    /*\n      Test of:\n         WithinRange(INT_MIN, UINT_MAX) == ConcreteValue(0)\n      Either branch is possible\n    */\n    if (i == 0) {\n        return 1;\n    } else {\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c', line=33), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c:33\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c:24\n\nTrace 1:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c:23'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c', line=31), value=1)\n    str(): (int)1 from tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c:31\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c:24\n\nTrace 2:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c', line=33), value=0)\n    str(): (int)0 from tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c:33\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/boundaries/WithinRange-eq-ConcreteValue-in-middle/input.c:24\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/conditionals/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we can cope with various kinds of comparisons\n*/\n\nextern void should_not_be_reached(void);\nextern void should_be_reached(void);\n\nextern void __cpychecker_log(const char *);\n\nint test_conditionals(void)\n{\n    /*\n       Force the absinterp code to run various comparisons\n\n       All of these comparisons should be fully deterministic, and thus\n       there should be just a single trace through the function, with\n       a particular pattern of \"true\" and \"false\" branches taken\n    */\n    int one;\n    int other_one;\n    int two;\n\n    one = 1;\n    /* we need a second copy to stop GCC optimizing away some comparisons: */\n    other_one = 1;\n    two = 2;\n\n    __cpychecker_log(\"Comparing 1 with 1\");\n    if (one < other_one) {\n        should_not_be_reached();\n    }\n    if (one <= other_one) {\n        should_be_reached();\n    }\n    if (one == other_one) {\n        should_be_reached();\n    }\n    if (one != other_one) {\n        should_not_be_reached();\n    }\n    if (one >= other_one) {\n        should_be_reached();\n    }\n    if (one > other_one) {\n        should_not_be_reached();\n    }\n\n    __cpychecker_log(\"Comparing 1 with 2\");\n    if (one < two) {\n        should_be_reached();\n    }\n    if (one <= two) {\n        should_be_reached();\n    }\n    if (one == two) {\n        should_not_be_reached();\n    }\n    if (one != two) {\n        should_be_reached();\n    }\n    if (one >= two) {\n        should_be_reached();\n    }\n    if (one > two) {\n        should_not_be_reached();\n    }\n\n    __cpychecker_log(\"Comparing 2 with 1\");\n    if (two < one) {\n        should_not_be_reached();\n    }\n    if (two <= one) {\n        should_not_be_reached();\n    }\n    if (two == one) {\n        should_not_be_reached();\n    }\n    if (two != one) {\n        should_be_reached();\n    }\n    if (two >= one) {\n        should_be_reached();\n    }\n    if (two > one) {\n        should_be_reached();\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/conditionals/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/conditionals/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'Comparing 1 with 1'\n    'taking False path'\n    'taking True path'\n    'taking True path'\n    'taking False path'\n    'taking True path'\n    'taking False path'\n    'Comparing 1 with 2'\n    'taking True path'\n    'taking True path'\n    'taking False path'\n    'taking True path'\n    'taking False path'\n    'taking False path'\n    'Comparing 2 with 1'\n    'taking False path'\n    'taking False path'\n    'taking False path'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/conditionals/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/expressions/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we can cope with various kinds of comparisons\n*/\n\nextern void __cpychecker_log(const char *);\nextern void __cpychecker_assert_equal(int, int);\n\nint test_comparison_expressions(void)\n{\n    /*\n       Force the absinterp code to evaluate various boolean expressions,\n       checking the results\n    */\n    int one;\n    int other_one;\n    int two;\n\n    one = 1;\n    /* we need a second copy to stop GCC optimizing away some comparisons: */\n    other_one = 1;\n    two = 2;\n\n    __cpychecker_log(\"Comparing 1 with 1\");\n    __cpychecker_assert_equal(one < other_one, 0);\n    __cpychecker_assert_equal(one <= other_one, 1);\n    __cpychecker_assert_equal(one == other_one, 1);\n    __cpychecker_assert_equal(one != other_one, 0);\n    __cpychecker_assert_equal(one >= other_one, 1);\n    __cpychecker_assert_equal(one > other_one, 0);\n\n    __cpychecker_log(\"Comparing 1 with 2\");\n    __cpychecker_assert_equal(one < two, 1);\n    __cpychecker_assert_equal(one <= two, 1);\n    __cpychecker_assert_equal(one == two, 0);\n    __cpychecker_assert_equal(one != two, 1);\n    __cpychecker_assert_equal(one >= two, 0);\n    __cpychecker_assert_equal(one > two, 0);\n\n    __cpychecker_log(\"Comparing 2 with 1\");\n    __cpychecker_assert_equal(two < one, 0);\n    __cpychecker_assert_equal(two <= one, 0);\n    __cpychecker_assert_equal(two == one, 0);\n    __cpychecker_assert_equal(two != one, 1);\n    __cpychecker_assert_equal(two >= one, 1);\n    __cpychecker_assert_equal(two > one, 1);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/expressions/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/expressions/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'Comparing 1 with 1'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:45,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:45)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:46,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:46)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:47,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:47)'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:48,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:48)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:49,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:49)'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:50,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:50)'\n    'Comparing 1 with 2'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:53,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:53)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:54,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:54)'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:55,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:55)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:56,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:56)'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:57,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:57)'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:58,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:58)'\n    'Comparing 2 with 1'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:61,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:61)'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:62,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:62)'\n    '__cpychecker_assert_equal((int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:63,(int)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:63)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:64,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:64)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:65,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:65)'\n    '__cpychecker_assert_equal((int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:66,(int)1 from tests/cpychecker/absinterp/comparisons/expressions/input.c:66)'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/comparisons/expressions/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/pointers/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Regression test for:\n     NotImplementedError: Don't know how to cope with exprcode: <type 'gcc.ExactDivExpr'> (<type 'gcc.ExactDivExpr'>)\n  seen in many places\n*/\nint\ntest(int *p, int *q)\n{\n    return p - q;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/comparisons/pointers/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that we can cope with a strdup function, with a custom allocator.\n\n   Verifying this function exercises various aspects of idiomatic C code.\n\n   Use non-standard allocation and strlen, so that the analyzer can't know\n   anything about the results:\n*/\nextern void *custom_allocator(size_t size);\nextern size_t custom_strlen(const char *str);\n\n/*\n  The analyser has no way of knowing whether \"str\" can be NULL or non-NULL\n  and thus complains about a possible read through NULL in the \"while\" loop\n*/\nchar *\ntest_strdup(const char *str)\n{\n    char *result;\n    char *dst;\n\n    result = (char*)custom_allocator(custom_strlen(str) + 1);\n\n    if (!result) {\n        return NULL;\n    }\n\n    dst = result;\n    while (*str) {\n        *(dst++) = *(str++);\n    }\n    *dst = '\\0';\n\n    return result;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_possible_null_derefs=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup/stderr.txt",
    "content": "In function 'test_strdup':\ntests/cpychecker/absinterp/custom-strdup/input.c:50:nn: warning: possibly dereferencing NULL (*str) at tests/cpychecker/absinterp/custom-strdup/input.c:50 [enabled by default]\ntests/cpychecker/absinterp/custom-strdup/input.c:45:nn: note: when treating unknown void * from tests/cpychecker/absinterp/custom-strdup/input.c:43 as non-NULL at:     if (!result) {\ntests/cpychecker/absinterp/custom-strdup/input.c:45:nn: note: taking False path at:     if (!result) {\ntests/cpychecker/absinterp/custom-strdup/input.c:49:nn: note: reaching:     dst = result;\ntests/cpychecker/absinterp/custom-strdup/input.c:50:nn: note: when treating unknown const char * from tests/cpychecker/absinterp/custom-strdup/input.c:38 as NULL at:     while (*str) {\ntests/cpychecker/absinterp/custom-strdup/input.c:39:nn: note: graphical error report for function 'test_strdup' written out to 'tests/cpychecker/absinterp/custom-strdup/input.c.test_strdup-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup/input.c:43 as non-NULL'\n    'taking False path'\n    'when treating unknown const char * from tests/cpychecker/absinterp/custom-strdup/input.c:38 as non-NULL'\n    'when considering range: -128 <= value <= -1'\n    'taking True path'\n    'when considering value == (const char)0 from tests/cpychecker/absinterp/custom-strdup/input.c:50'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='void *', loc=gcc.Location(file='tests/cpychecker/absinterp/custom-strdup/input.c', line=45), region=Region('heap-region-0'))\n    str(): (void *)&Region('heap-region-0') from tests/cpychecker/absinterp/custom-strdup/input.c:45\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup/input.c:39\n\nTrace 1:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup/input.c:43 as non-NULL'\n    'taking False path'\n    'when treating unknown const char * from tests/cpychecker/absinterp/custom-strdup/input.c:38 as non-NULL'\n    'when considering value == (const char)0 from tests/cpychecker/absinterp/custom-strdup/input.c:50'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='void *', loc=gcc.Location(file='tests/cpychecker/absinterp/custom-strdup/input.c', line=45), region=Region('heap-region-0'))\n    str(): (void *)&Region('heap-region-0') from tests/cpychecker/absinterp/custom-strdup/input.c:45\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup/input.c:39\n\nTrace 2:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup/input.c:43 as non-NULL'\n    'taking False path'\n    'when treating unknown const char * from tests/cpychecker/absinterp/custom-strdup/input.c:38 as non-NULL'\n    'when considering range: 1 <= value <= 127'\n    'taking True path'\n    'when considering value == (const char)0 from tests/cpychecker/absinterp/custom-strdup/input.c:50'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='void *', loc=gcc.Location(file='tests/cpychecker/absinterp/custom-strdup/input.c', line=45), region=Region('heap-region-0'))\n    str(): (void *)&Region('heap-region-0') from tests/cpychecker/absinterp/custom-strdup/input.c:45\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup/input.c:39\n\nTrace 3:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup/input.c:43 as non-NULL'\n    'taking False path'\n    'when treating unknown const char * from tests/cpychecker/absinterp/custom-strdup/input.c:38 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (*str) at tests/cpychecker/absinterp/custom-strdup/input.c:50\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup/input.c:39\n\nTrace 4:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup/input.c:43 as NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='char *', loc=gcc.Location(file='tests/cpychecker/absinterp/custom-strdup/input.c', line=46), value=0)\n    str(): (char *)0 from tests/cpychecker/absinterp/custom-strdup/input.c:46\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup/input.c:39\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup-with-attr/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that we can cope with a strdup function, with a custom allocator.\n\n   Verifying this function exercises various aspects of idiomatic C code.\n\n   Use non-standard allocation and strlen, so that the analyzer can't know\n   anything about the results:\n*/\nextern void *custom_allocator(size_t size);\nextern size_t custom_strlen(const char *str);\n\n/*\n  This version of test_strdup has the \"nonnull\" attribute, so the checker\n  ought not to complain about possibly reads through NULL \"str\":\n*/\nchar *\ntest_strdup(const char *str) __attribute__((nonnull));\n\nchar *\ntest_strdup(const char *str)\n{\n    char *result;\n    char *dst;\n\n    result = (char*)custom_allocator(custom_strlen(str) + 1);\n\n    if (!result) {\n        return NULL;\n    }\n\n    dst = result;\n    while (*str) {\n        *(dst++) = *(str++);\n    }\n    *dst = '\\0';\n\n    return result;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup-with-attr/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/custom-strdup-with-attr/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:46 as non-NULL'\n    'taking False path'\n    'when taking True path'\n    'when considering value == (const char)0 from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:53'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='void *', loc=gcc.Location(file='tests/cpychecker/absinterp/custom-strdup-with-attr/input.c', line=48), region=Region('heap-region-0'))\n    str(): (void *)&Region('heap-region-0') from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:48\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:42\n\nTrace 1:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:46 as non-NULL'\n    'taking False path'\n    'when taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='void *', loc=gcc.Location(file='tests/cpychecker/absinterp/custom-strdup-with-attr/input.c', line=48), region=Region('heap-region-0'))\n    str(): (void *)&Region('heap-region-0') from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:48\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:42\n\nTrace 2:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:46 as NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='char *', loc=gcc.Location(file='tests/cpychecker/absinterp/custom-strdup-with-attr/input.c', line=49), value=0)\n    str(): (char *)0 from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:49\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/custom-strdup-with-attr/input.c:42\n"
  },
  {
    "path": "tests/cpychecker/absinterp/exceptions/getopts.py",
    "content": "print('-fexceptions')\n"
  },
  {
    "path": "tests/cpychecker/absinterp/exceptions/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n */\n#include <Python.h>\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyFloat_FromDouble(1.0);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/exceptions/script.py",
    "content": "#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/exit/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a function that calls \"exit\"\n*/\nint test_exit(void)\n{\n    exit(13);\n\n    /* Checker should figure out that this can't happen: */\n    return 42;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/exit/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/exit/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'not returning from exit'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/exit/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/function-pointers/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Test of handling function pointers\n*/\n#include <stdlib.h>\n\nint foo(int);\n\nint test(int i, int j)\n{\n    int (*fn_ptr)(int);\n\n    if (i) {\n        fn_ptr = foo;\n    } else {\n        if (j) {\n            /*\n              Check that we can detect a  call through a NULL function\n              pointer:\n            */\n            fn_ptr = NULL;\n        }\n    }\n\n    /* otherwise fn_ptr is still uninitialized (which should be detected) */\n\n    return fn_ptr(i);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/function-pointers/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/function-pointers/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     only_on_python_code=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/function-pointers/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/absinterp/function-pointers/input.c:45:nn: warning: call of NULL function pointer at tests/cpychecker/absinterp/function-pointers/input.c:45: (int (*<Tnnn>) (int))0 from tests/cpychecker/absinterp/function-pointers/input.c:39 [enabled by default]\ntests/cpychecker/absinterp/function-pointers/input.c:31:nn: note: when considering value == (int)0 from tests/cpychecker/absinterp/function-pointers/input.c:27 at:     if (i) {\ntests/cpychecker/absinterp/function-pointers/input.c:31:nn: note: taking False path at:     if (i) {\ntests/cpychecker/absinterp/function-pointers/input.c:34:nn: note: reaching:         if (j) {\ntests/cpychecker/absinterp/function-pointers/input.c:34:nn: note: when considering range: -0x80000000 <= value <= -1 at:         if (j) {\ntests/cpychecker/absinterp/function-pointers/input.c:34:nn: note: taking True path at:         if (j) {\ntests/cpychecker/absinterp/function-pointers/input.c:39:nn: note: reaching:             fn_ptr = NULL;\ntests/cpychecker/absinterp/function-pointers/input.c:45:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/absinterp/function-pointers/input.c:45:nn: warning: call of uninitialized function pointer at tests/cpychecker/absinterp/function-pointers/input.c:45: uninitialized data at tests/cpychecker/absinterp/function-pointers/input.c:28 [enabled by default]\ntests/cpychecker/absinterp/function-pointers/input.c:31:nn: note: when considering value == (int)0 from tests/cpychecker/absinterp/function-pointers/input.c:27 at:     if (i) {\ntests/cpychecker/absinterp/function-pointers/input.c:31:nn: note: taking False path at:     if (i) {\ntests/cpychecker/absinterp/function-pointers/input.c:34:nn: note: reaching:         if (j) {\ntests/cpychecker/absinterp/function-pointers/input.c:34:nn: note: when considering value == (int)0 from tests/cpychecker/absinterp/function-pointers/input.c:27 at:         if (j) {\ntests/cpychecker/absinterp/function-pointers/input.c:34:nn: note: taking False path at:         if (j) {\ntests/cpychecker/absinterp/function-pointers/input.c:45:nn: note: reaching:     return fn_ptr(i);\ntests/cpychecker/absinterp/function-pointers/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/absinterp/function-pointers/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/function-pointers/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    \"calling (int (*<Tnnn>) (int))&RegionForGlobal(gcc.FunctionDecl('foo')) from tests/cpychecker/absinterp/function-pointers/input.c:32\"\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/function-pointers/input.c', line=45), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/function-pointers/input.c:45\n\nTrace 1:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/absinterp/function-pointers/input.c:27'\n    'taking False path'\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n  error: CallOfNullFunctionPtr()\n  error: call of NULL function pointer at tests/cpychecker/absinterp/function-pointers/input.c:45: (int (*<Tnnn>) (int))0 from tests/cpychecker/absinterp/function-pointers/input.c:39\n\nTrace 2:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/absinterp/function-pointers/input.c:27'\n    'taking False path'\n    'when considering value == (int)0 from tests/cpychecker/absinterp/function-pointers/input.c:27'\n    'taking False path'\n  error: CallOfUninitializedFunctionPtr()\n  error: call of uninitialized function pointer at tests/cpychecker/absinterp/function-pointers/input.c:45: uninitialized data at tests/cpychecker/absinterp/function-pointers/input.c:28\n\nTrace 3:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/absinterp/function-pointers/input.c:27'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n  error: CallOfNullFunctionPtr()\n  error: call of NULL function pointer at tests/cpychecker/absinterp/function-pointers/input.c:45: (int (*<Tnnn>) (int))0 from tests/cpychecker/absinterp/function-pointers/input.c:39\n\nTrace 4:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    \"calling (int (*<Tnnn>) (int))&RegionForGlobal(gcc.FunctionDecl('foo')) from tests/cpychecker/absinterp/function-pointers/input.c:32\"\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/function-pointers/input.c', line=45), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/function-pointers/input.c:45\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we can cope with nested structures\n*/\nstruct FooType {\n    int i;\n};\n\nstruct BarType {\n    struct FooType foo;\n    int j;\n};\n\nstruct BazType {\n    struct BarType bar;\n    int k;\n};\n\nint test_nested(void)\n{\n    struct BazType baz;\n\n    baz.bar.foo.i = 10;\n    baz.bar.j = 100;\n    baz.k = 1000;\n\n    /*\n      The analyser ought to be able to figure out that the return value is 1110\n    */\n    return baz.bar.foo.i + baz.bar.j + baz.k;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/nested-fields/input.c', line=50), value=1110)\n    str(): (int)1110 from tests/cpychecker/absinterp/nested-fields/input.c:50\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/nested-fields/input.c:40\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields2/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we can cope with nested structures with unknown value\n*/\nstruct FooType {\n    int field;\n};\n\nstruct BarType {\n    struct FooType *ptr;\n};\n\nint test_nested(struct BarType bar)\n{\n    /*\n       \"bar\" has an UnknownValue of type \"struct BarType\"\n       \"bar.ptr\" inherits the fact that the value is unknown, but must\n       have type \"struct FooType*\": the UnknownValue must be cast to the\n       correct type.\n    */\n    return bar.ptr->field;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields2/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields2/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct FooType * from tests/cpychecker/absinterp/nested-fields2/input.c:41 as non-NULL'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/nested-fields2/input.c', line=41), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/nested-fields2/input.c:41\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/nested-fields2/input.c:34\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct FooType * from tests/cpychecker/absinterp/nested-fields2/input.c:41 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (D.nnnnn->field) at tests/cpychecker/absinterp/nested-fields2/input.c:41\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/nested-fields2/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields3/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we can cope with nested structures with an uninialized value\n*/\nstruct FooType {\n    int field;\n};\n\nstruct BarType {\n    struct FooType *ptr;\n};\n\nint test_nested(void)\n{\n    struct BarType bar;\n    /*\n       \"bar\" has an UninitializedValue of type \"struct BarType\"\n       \"bar.ptr\" inherits the fact that the value is unitialized, but must\n       have type \"struct FooType*\": the UninitializedValue must be cast to the\n       correct type.\n    */\n    return bar.ptr->field;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields3/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields3/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields3/stderr.txt",
    "content": "In function 'test_nested':\ntests/cpychecker/absinterp/nested-fields3/input.c:42:nn: warning: dereferencing uninitialized pointer (D.nnnnn->field) at tests/cpychecker/absinterp/nested-fields3/input.c:42 [enabled by default]\ntests/cpychecker/absinterp/nested-fields3/input.c:34:nn: note: graphical error report for function 'test_nested' written out to 'tests/cpychecker/absinterp/nested-fields3/input.c.test_nested-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nested-fields3/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: UsageOfUninitializedData()\n  error: dereferencing uninitialized pointer (D.nnnnn->field) at tests/cpychecker/absinterp/nested-fields3/input.c:42\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/nested-fields3/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nonnull-attribute/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that we handle the GCC nonnull attribute.\n*/\nstruct coord {\n    int x;\n    int y;\n};\n\n/*\n  The checker ought to pick up on the \"nonnull\" attribute, and thus treat\n  \"coord_ptr\" as being non-NULL, and thus not report a possible read through\n  NULL.\n*/\nint test_function(struct coord *coord_ptr) __attribute__((nonnull));\n\nint test_function(struct coord *coord_ptr)\n{\n    return coord_ptr->x;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nonnull-attribute/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/nonnull-attribute/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/nonnull-attribute/input.c', line=39), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/nonnull-attribute/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/nonnull-attribute/input.c:38\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that we can cope with a read through a global ptr, where\n   the code explicitly checks for NULL:\n*/\nstruct coord {\n    int x;\n    int y;\n};\n\nextern struct coord *coord_ptr;\n\nint test_read_through_global_with_check(void)\n{\n    if (coord_ptr) {\n        return coord_ptr->x;\n    } else {\n        return 42;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-checked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-checked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c:31 as non-NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c', line=36), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c:36\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c:34\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c:31 as NULL'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c', line=38), value=42)\n    str(): (int)42 from tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c:38\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/read-through-global-ptr-checked/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that we can cope with a read through a global ptr, where\n   we can't know anything about the value:\n*/\nstruct coord {\n    int x;\n    int y;\n};\n\nextern struct coord *coord_ptr;\n\nint test_read_through_global_without_check(void)\n{\n    return coord_ptr->x;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-unchecked/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-unchecked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_possible_null_derefs=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-unchecked/stderr.txt",
    "content": "In function 'test_read_through_global_without_check':\ntests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:35:nn: warning: possibly dereferencing NULL (coord_ptr.0->x) at tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:35 [enabled by default]\ntests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:35:nn: note: when treating unknown struct coord * from tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:31 as NULL at:     return coord_ptr->x;\ntests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:34:nn: note: graphical error report for function 'test_read_through_global_without_check' written out to 'tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c.test_read_through_global_without_check-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-global-ptr-unchecked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:31 as non-NULL'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c', line=35), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:35\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:34\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:31 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (coord_ptr.0->x) at tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:35\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/read-through-global-ptr-unchecked/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-uninitialized-ptr/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that the checker complains about reads through uninitialized\n   pointers\n*/\nstruct coord {\n    int x;\n    int y;\n};\n\nint test_read_through_uninitialized_pointer(void)\n{\n    struct coord *coord_ptr;\n\n    return coord_ptr->x;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-uninitialized-ptr/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-uninitialized-ptr/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_possible_null_derefs=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-uninitialized-ptr/stderr.txt",
    "content": "In function 'test_read_through_uninitialized_pointer':\ntests/cpychecker/absinterp/read-through-uninitialized-ptr/input.c:35:nn: warning: dereferencing uninitialized pointer (coord_ptr->x) at tests/cpychecker/absinterp/read-through-uninitialized-ptr/input.c:35 [enabled by default]\ntests/cpychecker/absinterp/read-through-uninitialized-ptr/input.c:32:nn: note: graphical error report for function 'test_read_through_uninitialized_pointer' written out to 'tests/cpychecker/absinterp/read-through-uninitialized-ptr/input.c.test_read_through_uninitialized_pointer-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/read-through-uninitialized-ptr/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: UsageOfUninitializedData()\n  error: dereferencing uninitialized pointer (coord_ptr->x) at tests/cpychecker/absinterp/read-through-uninitialized-ptr/input.c:35\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/read-through-uninitialized-ptr/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/absinterp/real-cst/regular/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  https://fedorahosted.org/gcc-python-plugin/ticket/23\n\n  Cope with a gcc.RealCst()\n*/\ndouble\ntest(void)\n{\n    double d = 42;\n\n    return d;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/real-cst/regular/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/real-cst/regular/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='double', loc=gcc.Location(file='tests/cpychecker/absinterp/real-cst/regular/input.c', line=30), value=42.0)\n    str(): (double)42.0 from tests/cpychecker/absinterp/real-cst/regular/input.c:30\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/real-cst/regular/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/absinterp/result-decl/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of returning a struct containing pointers, which seems\n  to gimple containing an assignment to a gcc.ResultDecl;\n  in the pretty-printed gimple it looks like:\n    assign to fields of a tmp value\n    <returnval> = tmp\n    return <returnval>\n  (this seems to only happen if there are 3 or more fields, and at least two\n  are pointers; not sure of exact conditions)\n*/\n\nstruct foo {\n    void *x;\n    void *y;\n    int z;\n};\n\nstruct foo\ntest(void *x, void *y, int z)\n{\n    struct foo result;\n\n    result.x = x;\n    result.y = y;\n    result.z = z;\n\n    return result;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/result-decl/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/result-decl/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): UninitializedData(gcctype='struct foo', loc=gcc.Location(file='tests/cpychecker/absinterp/result-decl/input.c', line=41))\n    str(): uninitialized data at tests/cpychecker/absinterp/result-decl/input.c:41\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/result-decl/input.c:41\n"
  },
  {
    "path": "tests/cpychecker/absinterp/static-data/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Test of handling functions with static data:\n*/\nint test(void)\n{\n    static int i;\n\n    /*\n      i is implicitly zero-initialized before the first time the function\n      is entered, and its state persists between calls to the function.\n\n      The analyzer isn't yet smart enough to determine that i is never\n      written to, and so believes that both paths are possible:\n    */\n    if (i) {\n        return 42;\n    } else {\n        return 43;\n    }\n}\n\n/*\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/static-data/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     only_on_python_code=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/static-data/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/static-data/input.c', line=35), value=42)\n    str(): (int)42 from tests/cpychecker/absinterp/static-data/input.c:35\n\nTrace 1:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/absinterp/static-data/input.c:24'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/static-data/input.c', line=37), value=43)\n    str(): (int)43 from tests/cpychecker/absinterp/static-data/input.c:37\n\nTrace 2:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/static-data/input.c', line=35), value=42)\n    str(): (int)42 from tests/cpychecker/absinterp/static-data/input.c:35\n"
  },
  {
    "path": "tests/cpychecker/absinterp/string-constants/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of string constants\n*/\nconst char* test_string(int i)\n{\n    if (i) {\n        return \"Hello\";\n    } else {\n        return \"Goodbye\";\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/string-constants/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/string-constants/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='char[6] *', loc=gcc.Location(file='tests/cpychecker/absinterp/string-constants/input.c', line=28), region=ArrayElementRegion('Hello[0]'))\n    str(): (char[6] *)&ArrayElementRegion('Hello[0]') from tests/cpychecker/absinterp/string-constants/input.c:28\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/string-constants/input.c:26\n\nTrace 1:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/absinterp/string-constants/input.c:25'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='char[8] *', loc=gcc.Location(file='tests/cpychecker/absinterp/string-constants/input.c', line=30), region=ArrayElementRegion('Goodbye[0]'))\n    str(): (char[8] *)&ArrayElementRegion('Goodbye[0]') from tests/cpychecker/absinterp/string-constants/input.c:30\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/string-constants/input.c:26\n\nTrace 2:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='char[6] *', loc=gcc.Location(file='tests/cpychecker/absinterp/string-constants/input.c', line=28), region=ArrayElementRegion('Hello[0]'))\n    str(): (char[6] *)&ArrayElementRegion('Hello[0]') from tests/cpychecker/absinterp/string-constants/input.c:28\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/string-constants/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/switch/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of switch statement\n*/\nconst char* test_switch(int i)\n{\n    switch (i) {\n    case 0:\n        return \"Red\";\n    default:\n    case 1:\n        return \"Green\";\n    case 2:\n        return \"Blue\";\n\n    case 3:\n    case 4:\n    case 5:\n        return NULL;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/switch/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/switch/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when following default'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='char[6] *', loc=gcc.Location(file='tests/cpychecker/absinterp/switch/input.c', line=32), region=ArrayElementRegion('Green[0]'))\n    str(): (char[6] *)&ArrayElementRegion('Green[0]') from tests/cpychecker/absinterp/switch/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/switch/input.c:26\n\nTrace 1:\n  Transitions:\n    'when following case 0'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='char[4] *', loc=gcc.Location(file='tests/cpychecker/absinterp/switch/input.c', line=29), region=ArrayElementRegion('Red[0]'))\n    str(): (char[4] *)&ArrayElementRegion('Red[0]') from tests/cpychecker/absinterp/switch/input.c:29\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/switch/input.c:26\n\nTrace 2:\n  Transitions:\n    'when following case 2'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='char[5] *', loc=gcc.Location(file='tests/cpychecker/absinterp/switch/input.c', line=34), region=ArrayElementRegion('Blue[0]'))\n    str(): (char[5] *)&ArrayElementRegion('Blue[0]') from tests/cpychecker/absinterp/switch/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/switch/input.c:26\n\nTrace 3:\n  Transitions:\n    'when following cases 3...5'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='const char *', loc=gcc.Location(file='tests/cpychecker/absinterp/switch/input.c', line=39), value=0)\n    str(): (const char *)0 from tests/cpychecker/absinterp/switch/input.c:39\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/switch/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/two-loops/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Reproducer for a traceback seen in a function with two loops\n*/\n\nvoid\ntest(int len)\n{\n    int i;\n\n    for (i = 0; i < len; i++) {\n    }\n\n    for (i = 0; i < len; i++) {\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/two-loops/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/two-loops/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= len <= 0'\n    'taking False path'\n    'taking False path'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/two-loops/input.c:28\n\nTrace 1:\n  Transitions:\n    'when considering range: 1 <= len <= 0x7fffffff'\n    'taking True path'\n    'when considering len == (int)1 from tests/cpychecker/absinterp/two-loops/input.c:27'\n    'taking False path'\n    'taking True path'\n    'taking False path'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/two-loops/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/absinterp/uninitialized-data/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Test of handling uninitialized data\n*/\n\nextern void fn_that_could_write_back_a_value(int *dst);\n\nint test_void(int i)\n{\n    int j; /* not initialized */\n\n    if (i == 0) {\n        /*\n          A comparison against uninitialized data (\"j\") ought to trigger a\n          warning:\n        */\n        if (i < j) {\n            return 0;\n        } else {\n            return 1;\n        }\n    } else {\n\n        /*\n           Exposing \"j\" to a function for writing ought to suppress\n           the warning:\n        */\n        fn_that_could_write_back_a_value(&j);\n\n        /*\n          A comparison against uninitialized data ought to trigger a warning,\n          but \"j\" is no longer known to be uninitialized, so there should be\n          no warning here:\n        */\n        if (i < j) {\n            return 2;\n        } else {\n            /*\n              This should be recorded as an unknown value, from the function\n              call:\n            */\n            return j;\n        }\n    }\n}\n\n/*\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/uninitialized-data/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/uninitialized-data/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     only_on_python_code=False)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/uninitialized-data/stderr.txt",
    "content": "In function 'test_void':\ntests/cpychecker/absinterp/uninitialized-data/input.c:35:nn: warning: comparison against uninitialized data (j.0) at tests/cpychecker/absinterp/uninitialized-data/input.c:35 [enabled by default]\ntests/cpychecker/absinterp/uninitialized-data/input.c:30:nn: note: when considering value == (int)0 from tests/cpychecker/absinterp/uninitialized-data/input.c:26 at:     if (i == 0) {\ntests/cpychecker/absinterp/uninitialized-data/input.c:30:nn: note: taking True path at:     if (i == 0) {\ntests/cpychecker/absinterp/uninitialized-data/input.c:35:nn: note: reaching:         if (i < j) {\ntests/cpychecker/absinterp/uninitialized-data/input.c:27:nn: note: graphical error report for function 'test_void' written out to 'tests/cpychecker/absinterp/uninitialized-data/input.c.test_void-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/uninitialized-data/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/uninitialized-data/input.c', line=54), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/uninitialized-data/input.c:54\n\nTrace 1:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking False path'\n    'when taking False path'\n    'returning'\n  Return value:\n    repr(): UnknownValue(gcctype=gcc.PointerType(dereference=gcc.IntegerType(name=gcc.TypeDecl('int'))), loc=gcc.Location(file='tests/cpychecker/absinterp/uninitialized-data/input.c', line=46))\n    str(): unknown int * from tests/cpychecker/absinterp/uninitialized-data/input.c:46\n\nTrace 2:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/absinterp/uninitialized-data/input.c:26'\n    'taking True path'\n  error: UsageOfUninitializedData()\n  error: comparison against uninitialized data (j.0) at tests/cpychecker/absinterp/uninitialized-data/input.c:35\n\nTrace 3:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/absinterp/uninitialized-data/input.c', line=54), value=2)\n    str(): (int)2 from tests/cpychecker/absinterp/uninitialized-data/input.c:54\n\nTrace 4:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking False path'\n    'when taking False path'\n    'returning'\n  Return value:\n    repr(): UnknownValue(gcctype=gcc.PointerType(dereference=gcc.IntegerType(name=gcc.TypeDecl('int'))), loc=gcc.Location(file='tests/cpychecker/absinterp/uninitialized-data/input.c', line=46))\n    str(): unknown int * from tests/cpychecker/absinterp/uninitialized-data/input.c:46\n"
  },
  {
    "path": "tests/cpychecker/absinterp/void-return/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of handling functions with \"void\" return type:\n*/\nvoid test_void(void)\n{\n    /* Explicit return: */\n    return;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/void-return/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/void-return/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/void-return/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-arg-unchecked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of writing through a pointer as an array:\n*/\n\nvoid\ntest(char *out)\n{\n    out[0] = '\\0';\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-arg-unchecked/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-arg-unchecked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False,\n     show_possible_null_derefs=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-arg-unchecked/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/absinterp/write-through-arg-unchecked/input.c:29:nn: warning: possibly dereferencing NULL (*out) at tests/cpychecker/absinterp/write-through-arg-unchecked/input.c:30 [enabled by default]\ntests/cpychecker/absinterp/write-through-arg-unchecked/input.c:29:nn: note: when treating unknown char * from tests/cpychecker/absinterp/write-through-arg-unchecked/input.c:27 as NULL at:     out[0] = '\\0';\ntests/cpychecker/absinterp/write-through-arg-unchecked/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/absinterp/write-through-arg-unchecked/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-arg-unchecked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown char * from tests/cpychecker/absinterp/write-through-arg-unchecked/input.c:27 as non-NULL'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/write-through-arg-unchecked/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown char * from tests/cpychecker/absinterp/write-through-arg-unchecked/input.c:27 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (*out) at tests/cpychecker/absinterp/write-through-arg-unchecked/input.c:30\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/write-through-arg-unchecked/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-checked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that we can cope with a write through a global ptr, where\n   the code explicitly checks for NULL:\n*/\nstruct coord {\n    int x;\n    int y;\n};\n\nextern struct coord *coord_ptr;\n\nvoid test_write_through_global_with_check(int x)\n{\n    if (coord_ptr) {\n        coord_ptr->x = x;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-checked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-checked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/write-through-global-ptr-checked/input.c:31 as non-NULL'\n    'taking True path'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/write-through-global-ptr-checked/input.c:34\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/write-through-global-ptr-checked/input.c:31 as NULL'\n    'taking False path'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/write-through-global-ptr-checked/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Ensure that we can cope with a write through a global ptr, where\n   we can't know anything about the value:\n*/\nstruct coord {\n    int x;\n    int y;\n};\n\nextern struct coord *coord_ptr;\n\nvoid test_write_through_global_without_check(int x)\n{\n    coord_ptr->x = x;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-unchecked/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-unchecked/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_possible_null_derefs=True)\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-unchecked/stderr.txt",
    "content": "In function 'test_write_through_global_without_check':\ntests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:35:nn: warning: possibly dereferencing NULL (coord_ptr.0->x) at tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:36 [enabled by default]\ntests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:35:nn: note: when treating unknown struct coord * from tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:31 as NULL at:     coord_ptr->x = x;\ntests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:34:nn: note: graphical error report for function 'test_write_through_global_without_check' written out to 'tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c.test_write_through_global_without_check-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/absinterp/write-through-global-ptr-unchecked/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:31 as non-NULL'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:34\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct coord * from tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:31 as NULL'\n  error: NullPtrDereference()\n  error: possibly dereferencing NULL (coord_ptr.0->x) at tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:36\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/absinterp/write-through-global-ptr-unchecked/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/fileptr-missing-error-check/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdio.h>\n\nvoid\nmissing_error_check(const char *filename)\n{\n    FILE *f = fopen(filename, \"r\");\n\n    /* This code doesn't check to see if fopen succeeded */\n    fclose(f);\n}\n"
  },
  {
    "path": "tests/cpychecker/fileptr-missing-error-check/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=False)\n"
  },
  {
    "path": "tests/cpychecker/fileptr-missing-error-check/stderr.txt",
    "content": ""
  },
  {
    "path": "tests/cpychecker/refcounts/GIL/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correctly releasing and reacquiring the GIL\n*/\n\nextern void foo(const char *txt);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    const char *txt = PyString_AsString(self);\n\n    Py_BEGIN_ALLOW_THREADS\n\n    foo(txt);\n\n    Py_END_ALLOW_THREADS\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/GIL/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/GIL/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_AsString() succeeds'\n    'releasing the GIL by calling PyEval_SaveThread()'\n    'reacquiring the GIL by calling PyEval_RestoreThread()'\n    'returning'\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/GIL/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/GIL/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/GIL/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'when PyString_AsString() fails'\n    'releasing the GIL by calling PyEval_SaveThread()'\n    'reacquiring the GIL by calling PyEval_RestoreThread()'\n    'returning'\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/GIL/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/GIL/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/GIL/correct/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyArg_Parse\n  that uses simple format codes that don't affect reference counting\n*/\n\nextern void foo(int i, const char *msg, Py_UNICODE *unicode, int size);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    int i;\n    const char *msg;\n    Py_UNICODE *unicode;\n    int size;\n\n    if (!PyArg_Parse(args, \"isu#:test\",\n                     &i, &msg, &unicode, &size)) {\n        return NULL;\n    }\n\n    foo(i, msg, unicode, size);\n\n    Py_RETURN_NONE;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_OLDARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_Parse/correct_simple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_Parse/correct_simple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_Parse() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c:44\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c:31\n\nTrace 1:\n  Transitions:\n    'when PyArg_Parse() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_Parse/correct_simple/input.c:37\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyArg_ParseTuple\n  that uses the \"O\" format code\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *obj;\n\n    if (!PyArg_ParseTuple(args, \"O:test\",\n                          &obj)) {\n        return NULL;\n    }\n\n    /*\n      We now have a borrowed non-NULL ref to \"obj\".\n\n      To correctly use it as the return value, we need to INCREF it:\n    */\n    Py_INCREF(obj);\n    return obj;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=32), region=RegionOnHeap('object from arg \"O\"', gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('object from arg \"O\"', gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=32)) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c:32\n    r->ob_refcnt: (Py_ssize_t)val [-0x7fffffffffffffff <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c:42\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyArg_ParseTuple() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyArg_ParseTuple\n  that uses the \"O!\" format code, with a type that we don't know about\n*/\n\nstruct FooObject {\n    PyObject_HEAD\n    char *msg;\n};\n\nextern PyTypeObject foo_type;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    struct FooObject *foo_obj;\n\n    if (!PyArg_ParseTuple(args, \"O!:test\",\n                          &foo_type, &foo_obj)) {\n        return NULL;\n    }\n\n    /*\n      We now have a borrowed non-NULL ref to the FooObject; the checker\n      ought not to complain.\n\n      (It doesn't know that msg is non-NULL or not, but should not issue\n      a message about that)\n    */\n\n    return PyString_FromString(foo_obj->msg);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\n# The purpose of this test is to verify O! with the refcount checker.\n#\n# Currently the format checker issues a false positive for the O!, so we\n# turn off verify_pyargs for this test:\nmain(verify_pyargs=False,\n     verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when treating unknown char * from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:52 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=52), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=52)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=52)) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:52\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=52), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:36\n\nTrace 1:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when treating unknown char * from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:52 as non-NULL'\n    'when PyString_FromString() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=52), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:52\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:52\n\nTrace 2:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when treating unknown char * from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:52 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_FromString with NULL as argument 1 (D.nnnnn) at tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:52\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:36\n\nTrace 3:\n  Transitions:\n    'when PyArg_ParseTuple() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=41), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:41\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_O_bang/input.c:39\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Adapted from Python's Objects/listobject.c:listindex */\nPyObject *\ncorrect_usage_of_converter(PyObject *self, PyObject *args)\n{\n    Py_ssize_t start, stop;\n    if (!PyArg_ParseTuple(args, \"O&O&\",\n                          _PyEval_SliceIndex, &start,\n                          _PyEval_SliceIndex, &stop)) {\n        return NULL;\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c:33\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c', line=24), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c', line=24), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c:25\n\nTrace 1:\n  Transitions:\n    'when PyArg_ParseTuple() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c:30\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c', line=24), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c', line=24), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_converter/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyArg_ParseTuple\n  that uses simple format codes that don't affect reference counting\n*/\n\nextern void foo(int i, const char *msg, Py_UNICODE *unicode, int size);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    int i;\n    const char *msg;\n    Py_UNICODE *unicode;\n    int size;\n\n    if (!PyArg_ParseTuple(args, \"isu#:test\",\n                          &i, &msg, &unicode, &size)) {\n        return NULL;\n    }\n\n    foo(i, msg, unicode, size);\n\n    Py_RETURN_NONE;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c:44\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c:31\n\nTrace 1:\n  Transitions:\n    'when PyArg_ParseTuple() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_ParseTuple/correct_simple/input.c:37\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyArg_ParseTupleAndKeywords\n  that uses the \"O\" format code\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args, PyObject *kwargs)\n{\n    PyObject *obj;\n    char *keywords[] = {\"object\", NULL};\n\n    if (!PyArg_ParseTupleAndKeywords(args, kwargs,\n                                     \"O:test\", keywords,\n                                     &obj)) {\n        return NULL;\n    }\n\n    /*\n      We now have a borrowed non-NULL ref to \"obj\".\n\n      To correctly use it as the return value, we need to INCREF it:\n    */\n    Py_INCREF(obj);\n    return obj;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  (PyCFunction)test, (METH_VARARGS | METH_KEYWORDS), NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_ParseTupleAndKeywords() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=33), region=RegionOnHeap('object from arg \"O\"', gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('object from arg \"O\"', gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=33)) from tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c:33\n    r->ob_refcnt: (Py_ssize_t)val [-0x7fffffffffffffff <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c:44\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  region for gcc.ParmDecl('kwargs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('kwargs')\")\n    str(): region for gcc.ParmDecl('kwargs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('kwargs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyArg_ParseTupleAndKeywords() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=36), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  region for gcc.ParmDecl('kwargs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('kwargs')\")\n    str(): region for gcc.ParmDecl('kwargs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('kwargs')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_ParseTupleAndKeywords/correct_O/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct usage of PyArg_UnpackTuple\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *a;\n    PyObject *b = Py_None;\n    PyObject *c = Py_None;\n\n    if (!PyArg_UnpackTuple(args, \"test\", 1, 3, &a, &b, &c)) {\n        return NULL;\n    }\n\n    return PyTuple_Pack(3, a, b, c);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_UnpackTuple() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n\nTrace 1:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 1 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37)) from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 1'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 1 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 1'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n\nTrace 3:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 2 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37)) from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 1'))\n  argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 2', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 2'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:28\n\nTrace 4:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 2 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 1'))\n  argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 2', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 2'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n\nTrace 5:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 3 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37)) from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 1'))\n  argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 2', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 2'))\n  argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 3', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 3'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:28\n\nTrace 6:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 3 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 1'))\n  argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 2', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 2'))\n  argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33:\n    repr(): RegionOnHeap('argument 3', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33))\n    str(): argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c', line=33), region=Region('PyTypeObject for argument 3'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyArg_UnpackTuple/correct/input.c:37\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect usage of PyArg_UnpackTuple\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *a;\n    /* These locals are not initialized: */\n    PyObject *b;\n    PyObject *c;\n\n    /*\n      If the user passes in less than 3 arguments, the optional arguments\n      won't get initialized:\n    */\n    if (!PyArg_UnpackTuple(args, \"test\", 1, 3, &a, &b, &c)) {\n        return NULL;\n    }\n\n    return PyTuple_Pack(3, a, b, c);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42:nn: warning: passing uninitialized data (b.1) as argument 3 to function at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42 [enabled by default]\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:nn: note: when PyArg_UnpackTuple() successfully unpacks 1 argument(s) at:     if (!PyArg_UnpackTuple(args, \"test\", 1, 3, &a, &b, &c)) {\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:nn: note: taking False path at:     if (!PyArg_UnpackTuple(args, \"test\", 1, 3, &a, &b, &c)) {\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42:nn: note: reaching:     return PyTuple_Pack(3, a, b, c);\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42:nn: warning: passing uninitialized data (c.0) as argument 4 to function at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42 [enabled by default]\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:nn: note: when PyArg_UnpackTuple() successfully unpacks 2 argument(s) at:     if (!PyArg_UnpackTuple(args, \"test\", 1, 3, &a, &b, &c)) {\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:nn: note: taking False path at:     if (!PyArg_UnpackTuple(args, \"test\", 1, 3, &a, &b, &c)) {\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42:nn: note: reaching:     return PyTuple_Pack(3, a, b, c);\ntests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_UnpackTuple() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n\nTrace 1:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 1 argument(s)'\n    'taking False path'\n  error: UsageOfUninitializedData()\n  error: passing uninitialized data (b.1) as argument 3 to function at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 1'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 2 argument(s)'\n    'taking False path'\n  error: UsageOfUninitializedData()\n  error: passing uninitialized data (c.0) as argument 4 to function at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 1'))\n  argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 2', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 2'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:28\n\nTrace 3:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 3 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=42), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=42)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=42)) from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=42), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 1'))\n  argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 2', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 2'))\n  argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 3', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 3'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:28\n\nTrace 4:\n  Transitions:\n    'when PyArg_UnpackTuple() successfully unpacks 3 argument(s)'\n    'taking False path'\n    'when PyTuple_Pack() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 1', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 1 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 1'))\n  argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 2', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 2 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 2'))\n  argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38:\n    repr(): RegionOnHeap('argument 3', gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38))\n    str(): argument 3 allocated at tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:38\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c', line=38), region=Region('PyTypeObject for argument 3'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyArg_UnpackTuple/missing-initialization/input.c:42\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect usage of PyArg_UnpackTuple, where the argument count\n  is incorrect\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *a;\n    PyObject *b = Py_None;\n\n    /*\n      This call has the wrong number of varargs: 2, where 3 is specified\n      as the maximum:\n    */\n    if (!PyArg_UnpackTuple(args, \"test\", 1, 3, &a, &b)) {\n        return NULL;\n    }\n\n    return PyTuple_Pack(2, a, b);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/input.c:37:nn: warning: expected 3 vararg pointer(s); got 2 [enabled by default]\ntests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: WrongNumberOfVarargs()\n  error: expected 3 vararg pointer(s); got 2\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')):\n    repr(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    str(): RegionForGlobal(gcc.VarDecl('_Py_NoneStruct'))\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyArg_UnpackTuple/wrong-number-of-varargs/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyBool_FromLong\n*/\nextern long some_global;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyBool_FromLong(some_global);\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyBool_FromLong/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyBool_FromLong/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c', line=30), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c', line=30), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyBool_FromLong/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we detect a call to PyCObject_FromVoidPtr that doesn't handle\n  e.g. deprecation failure\n*/\n\nstruct foo\n{\n    int i;\n    int j;\n};\n\nstruct foo some_foo;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *obj = PyCObject_FromVoidPtr(&some_foo, NULL);\n\n    /*\n      This is incorrect: there's no error handling for if the call above\n      fails, and there's a reference leak on \"obj\" even if it succeeds:\n    */\n    return PyTuple_Pack(2, self, obj);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: warning: memory leak: ob_refcnt of '*obj' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38:nn: note: '*obj' was allocated at:     PyObject *obj = PyCObject_FromVoidPtr(&some_foo, NULL);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: note: was expecting final owned ob_refcnt of '*obj' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38:nn: note: when PyCObject_FromVoidPtr() succeeds at:     PyObject *obj = PyCObject_FromVoidPtr(&some_foo, NULL);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: note: when PyTuple_Pack() succeeds at:     return PyTuple_Pack(2, self, obj);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: note: returning at:     return PyTuple_Pack(2, self, obj);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: warning: calling PyTuple_Pack with NULL as argument 3 (obj) at tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44 [enabled by default]\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38:nn: note: when PyCObject_FromVoidPtr() fails (when py3k deprecation warnings are enabled and configured to raise exceptions) at:     PyObject *obj = PyCObject_FromVoidPtr(&some_foo, NULL);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: note: PyTuple_Pack() invokes Py_INCREF() on the pointer, thus accessing (NULL)->ob_refcnt\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:37:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyCObject_FromVoidPtr() succeeds'\n    'when PyTuple_Pack() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=44), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=44)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=44)) from tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyCObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=38))\n    str(): PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyCObject_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:37\n\nTrace 1:\n  Transitions:\n    'when PyCObject_FromVoidPtr() succeeds'\n    'when PyTuple_Pack() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyCObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=38))\n    str(): PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyCObject_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44\n\nTrace 2:\n  Transitions:\n    'when PyCObject_FromVoidPtr() fails (when py3k deprecation warnings are enabled and configured to raise exceptions)'\n  error: NullPtrArgument()\n  error: calling PyTuple_Pack with NULL as argument 3 (obj) at tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38\n\nTrace 3:\n  Transitions:\n    'when PyCObject_FromVoidPtr() fails'\n  error: NullPtrArgument()\n  error: calling PyTuple_Pack with NULL as argument 3 (obj) at tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyCObject_FromVoidPtr/incorrect/input.c:38\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we detect a call to PyCObject_FromVoidPtrAndDesc that doesn't\n  handle e.g. deprecation failure\n*/\n\nstruct foo\n{\n    int i;\n    int j;\n};\n\nstruct foo some_foo;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *obj = PyCObject_FromVoidPtrAndDesc(&some_foo, \"struct foo\", NULL);\n\n    /*\n      This is incorrect: there's no error handling for if the call above\n      fails, and there's a reference leak on \"obj\" even if it succeeds:\n    */\n    return PyTuple_Pack(2, self, obj);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: warning: memory leak: ob_refcnt of '*obj' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38:nn: note: '*obj' was allocated at:     PyObject *obj = PyCObject_FromVoidPtrAndDesc(&some_foo, \"struct foo\", NULL);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: note: was expecting final owned ob_refcnt of '*obj' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38:nn: note: when PyCObject_FromVoidPtrAndDesc() succeeds at:     PyObject *obj = PyCObject_FromVoidPtrAndDesc(&some_foo, \"struct foo\", NULL);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: note: when PyTuple_Pack() succeeds at:     return PyTuple_Pack(2, self, obj);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: note: returning at:     return PyTuple_Pack(2, self, obj);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: warning: calling PyTuple_Pack with NULL as argument 3 (obj) at tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44 [enabled by default]\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38:nn: note: when PyCObject_FromVoidPtrAndDesc() fails (when py3k deprecation warnings are enabled and configured to raise exceptions) at:     PyObject *obj = PyCObject_FromVoidPtrAndDesc(&some_foo, \"struct foo\", NULL);\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: note: PyTuple_Pack() invokes Py_INCREF() on the pointer, thus accessing (NULL)->ob_refcnt\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:37:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyCObject_FromVoidPtrAndDesc() succeeds'\n    'when PyTuple_Pack() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=44), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=44)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=44)) from tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyCObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=38))\n    str(): PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyCObject_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:37\n\nTrace 1:\n  Transitions:\n    'when PyCObject_FromVoidPtrAndDesc() succeeds'\n    'when PyTuple_Pack() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyCObject', gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=38))\n    str(): PyCObject allocated at tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyCObject_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44\n\nTrace 2:\n  Transitions:\n    'when PyCObject_FromVoidPtrAndDesc() fails (when py3k deprecation warnings are enabled and configured to raise exceptions)'\n  error: NullPtrArgument()\n  error: calling PyTuple_Pack with NULL as argument 3 (obj) at tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38\n\nTrace 3:\n  Transitions:\n    'when PyCObject_FromVoidPtrAndDesc() fails'\n  error: NullPtrArgument()\n  error: calling PyTuple_Pack with NULL as argument 3 (obj) at tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyCObject_FromVoidPtrAndDesc/incorrect/input.c:38\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Basic test coverage for our handler for PyCapsule_GetPointer\n*/\n\nvoid*\ntest(PyObject *capsule, const char *name)\n{\n    return PyCapsule_GetPointer(capsule, name);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyCapsule_GetPointer() succeeds'\n    'returning'\n  Return value:\n    repr(): UnknownValue(gcctype=gcc.PointerType(dereference=<gcc.VoidType object at 0xdeadbeef>), loc=gcc.Location(file='tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c', line=29))\n    str(): unknown void * from tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c:29\n  region for gcc.ParmDecl('capsule') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('capsule')\")\n    str(): region for gcc.ParmDecl('capsule') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('capsule')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyCapsule_GetPointer() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='void *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c', line=29), value=0)\n    str(): (void *)0 from tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c:29\n  region for gcc.ParmDecl('capsule') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('capsule')\")\n    str(): region for gcc.ParmDecl('capsule') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('capsule')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_ValueError')) from tests/cpychecker/refcounts/PyCapsule_GetPointer/basic/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyDict_GetItem\n*/\n\nextern PyObject *some_dict;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *item;\n    item = PyDict_GetItem(some_dict, args);\n    if (item) {\n        /*\n          If it succeeds, it only returns a borrowed ref, so we must incref\n          it:\n        */\n        Py_INCREF(item);\n        return item;\n    }\n    PyErr_SetString(PyExc_KeyError, \"item not found\");\n    return NULL;\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:26 as non-NULL'\n    'when PyDict_GetItem() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=32), region=RegionOnHeap('borrowed reference returned by PyDict_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyDict_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=32), region=Region('PyTypeObject for borrowed reference returned by PyDict_GetItem()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:26 as non-NULL'\n    'when PyDict_GetItem does not find item'\n    'taking False path'\n    'calling PyErr_SetString()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:26 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyDict_GetItem with NULL as argument 1 (some_dict.0) at tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItem/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PyDict_GetItem\n*/\n\nextern PyObject *some_dict;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n      This is incorrect: if the call succeeds, it only returns a borrowed ref,\n      so this will leave it with too low a reference count:\n    */\n    return PyDict_GetItem(some_dict, args);\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: return value was allocated at:     return PyDict_GetItem(some_dict, args);\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:26 as non-NULL at:     return PyDict_GetItem(some_dict, args);\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: when PyDict_GetItem() succeeds at:     return PyDict_GetItem(some_dict, args);\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: returning at:     return PyDict_GetItem(some_dict, args);\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:26 as non-NULL at:     return PyDict_GetItem(some_dict, args);\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: when PyDict_GetItem does not find item at:     return PyDict_GetItem(some_dict, args);\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35:nn: note: returning at:     return PyDict_GetItem(some_dict, args);\ntests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItem/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:26 as non-NULL'\n    'when PyDict_GetItem() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=35), region=RegionOnHeap('borrowed reference returned by PyDict_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=35)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyDict_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=35)) from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=35), region=Region('PyTypeObject for borrowed reference returned by PyDict_GetItem()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:26 as non-NULL'\n    'when PyDict_GetItem does not find item'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:30\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:26 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyDict_GetItem with NULL as argument 1 (some_dict.0) at tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItem/incorrect/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyDict_GetItemString\n*/\n\nextern PyObject *some_dict;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *item;\n    item = PyDict_GetItemString(some_dict, \"item\");\n    if (item) {\n        /*\n          If it succeeds, it only returns a borrowed ref, so we must incref\n          it:\n        */\n        Py_INCREF(item);\n        return item;\n    }\n    PyErr_SetString(PyExc_KeyError, \"item not found\");\n    return NULL;\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:26 as non-NULL'\n    'when PyDict_GetItemString() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=32), region=RegionOnHeap('borrowed reference returned by PyDict_GetItemString()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyDict_GetItemString()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=32), region=Region('PyTypeObject for borrowed reference returned by PyDict_GetItemString()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:26 as non-NULL'\n    'PyDict_GetItemString does not find string'\n    'taking False path'\n    'calling PyErr_SetString()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:26 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyDict_GetItemString with NULL as argument 1 (some_dict.0) at tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItemString/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PyDict_GetItemString\n*/\n\nextern PyObject *some_dict;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n      This is incorrect: if the call succeeds, it only returns a borrowed ref,\n      so this will leave it with too low a reference count:\n    */\n    return PyDict_GetItemString(some_dict, \"item\");\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: return value was allocated at:     return PyDict_GetItemString(some_dict, \"item\");\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:26 as non-NULL at:     return PyDict_GetItemString(some_dict, \"item\");\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: when PyDict_GetItemString() succeeds at:     return PyDict_GetItemString(some_dict, \"item\");\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: returning at:     return PyDict_GetItemString(some_dict, \"item\");\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:26 as non-NULL at:     return PyDict_GetItemString(some_dict, \"item\");\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: PyDict_GetItemString does not find string at:     return PyDict_GetItemString(some_dict, \"item\");\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35:nn: note: returning at:     return PyDict_GetItemString(some_dict, \"item\");\ntests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:26 as non-NULL'\n    'when PyDict_GetItemString() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=35), region=RegionOnHeap('borrowed reference returned by PyDict_GetItemString()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=35)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyDict_GetItemString()', gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=35)) from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=35), region=Region('PyTypeObject for borrowed reference returned by PyDict_GetItemString()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:26 as non-NULL'\n    'PyDict_GetItemString does not find string'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:30\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:26 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyDict_GetItemString with NULL as argument 1 (some_dict.0) at tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_GetItemString/incorrect/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_New/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyDict_New\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *dict;\n    dict = PyDict_New();\n    if (!dict) {\n        return NULL;\n    }\n\n    /* \"dict\" should now have an ob_refcnt of 1 */\n    return dict;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_New/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_New/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=30), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyDict_New/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_New/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_New/correct/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_New/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_New/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyDict_SetItem\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *dict = NULL;\n    PyObject *key = NULL;\n    PyObject *value = NULL;\n\n    dict = PyDict_New();\n    if (!dict) {\n\tgoto error;\n    }\n\n    key = PyLong_FromLong(500);\n    if (!key) {\n        goto error;\n    }\n\n    value = PyLong_FromLong(1000);\n    if (!value) {\n        goto error;\n    }\n\n    if (-1 == PyDict_SetItem(dict, key, value)) {\n        goto error;\n    }\n    /*\n       The successful call added refs on both \"key\" and \"value\", owned by the\n       dictionary.\n       We must now drop our references on them:\n    */\n    Py_DECREF(key);\n    Py_DECREF(value);\n\n    return dict;\n\n error:\n    Py_XDECREF(dict);\n    Py_XDECREF(key);\n    Py_XDECREF(value);\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() succeeds'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33)) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33)) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 3:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 4:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 5:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 6:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 7:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 8:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 9:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:48\n\nTrace 10:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n\nTrace 11:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n\nTrace 12:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n\nTrace 13:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:43\n\nTrace 14:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n\nTrace 15:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:38\n\nTrace 16:\n  Transitions:\n    'when PyDict_New() fails'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=65), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:65\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/correct/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect call to PyDict_SetItem\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *dict = NULL;\n    PyObject *key = NULL;\n    PyObject *value = NULL;\n\n    dict = PyDict_New();\n    if (!dict) {\n\tgoto error;\n    }\n\n    key = PyLong_FromLong(500);\n    value = PyLong_FromLong(1000);\n\n    /*\n      This code doesn't check that key or value are non-NULL \n      PyDict_SetItem will assert/segfault with NULL key/values:\n    */\n    if (-1 == PyDict_SetItem(dict, key, value)) {\n        goto error;\n    }\n    /*\n       The successful call added refs on both \"key\" and \"value\", owned by the\n       dictionary.\n\n       We must now drop our references on them:\n    */\n    Py_DECREF(key);\n    Py_DECREF(value);\n\n    return dict;\n\n error:\n    Py_XDECREF(dict);\n    Py_XDECREF(key);\n    Py_XDECREF(value);\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45:nn: warning: calling PyDict_SetItem with NULL as argument 3 (value) at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45 [enabled by default]\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:nn: note: when PyDict_New() succeeds at:     dict = PyDict_New();\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:34:nn: note: taking False path at:     if (!dict) {\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:nn: note: reaching:     key = PyLong_FromLong(500);\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:nn: note: when PyLong_FromLong() succeeds at:     key = PyLong_FromLong(500);\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:nn: note: when PyLong_FromLong() fails at:     value = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45:nn: note: PyDict_SetItem() invokes Py_INCREF() on the pointer, thus accessing (NULL)->ob_refcnt\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45:nn: warning: calling PyDict_SetItem with NULL as argument 2 (key) at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45 [enabled by default]\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:nn: note: when PyDict_New() succeeds at:     dict = PyDict_New();\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:34:nn: note: taking False path at:     if (!dict) {\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:nn: note: reaching:     key = PyLong_FromLong(500);\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:nn: note: when PyLong_FromLong() fails at:     key = PyLong_FromLong(500);\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:nn: note: when PyLong_FromLong() succeeds at:     value = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45:nn: note: PyDict_SetItem() invokes Py_TYPE() on the pointer via the PyString_CheckExact() macro, thus accessing (NULL)->ob_type\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItem/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() succeeds'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33)) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33)) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 3:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 4:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 5:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 6:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 7:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 8:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 9:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() succeeds'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n\nTrace 10:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'when PyLong_FromLong() fails'\n  error: NullPtrArgument()\n  error: calling PyDict_SetItem with NULL as argument 3 (value) at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n\nTrace 11:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'when PyLong_FromLong() succeeds'\n  error: NullPtrArgument()\n  error: calling PyDict_SetItem with NULL as argument 2 (key) at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:38\n\nTrace 12:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'when PyLong_FromLong() fails'\n  error: NullPtrArgument()\n  error: calling PyDict_SetItem with NULL as argument 2 (key) at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:39\n\nTrace 13:\n  Transitions:\n    'when PyDict_New() fails'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=63), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:63\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItem/incorrect/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyDict_SetItemString\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *dict = NULL;\n    PyObject *value = NULL;\n\n    dict = PyDict_New();\n    if (!dict) {\n\tgoto error;\n    }\n\n    value = PyLong_FromLong(1000);\n    if (!value) {\n        goto error;\n    }\n\n    if (-1 == PyDict_SetItemString(dict, \"key\", value)) {\n        goto error;\n    }\n    /*\n       The successful call added a ref on \"value\", owned by the dictionary.\n       We must now drop our reference on in:\n    */\n    Py_DECREF(value);\n\n    return dict;\n\n error:\n    Py_XDECREF(dict);\n    Py_XDECREF(value);\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() succeeds'\n    'taking False path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:42\n\nTrace 2:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:42\n\nTrace 3:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:42\n\nTrace 4:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:42\n\nTrace 5:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37\n\nTrace 6:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:37\n\nTrace 7:\n  Transitions:\n    'when PyDict_New() fails'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=56), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:56\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/correct/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PyDict_SetItemString\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *dict = NULL;\n    PyObject *value = NULL;\n\n    dict = PyDict_New();\n    if (!dict) {\n\tgoto error;\n    }\n\n    value = PyLong_FromLong(1000);\n    if (!value) {\n        goto error;\n    }\n\n    if (-1 == PyDict_SetItemString(dict, \"key\", value)) {\n        goto error;\n    }\n    /*\n      The successful call added a ref on \"value\", owned by the dictionary.\n\n      However, we still hold another reference on \"value\", and this code\n      erroneously fails to call Py_DECREF on it, which will be a leak.\n     */\n\n    return dict;\n\n error:\n    Py_XDECREF(dict);\n    Py_XDECREF(value);\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:52:nn: warning: memory leak: ob_refcnt of '*value' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:nn: note: '*value' was allocated at:     value = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:52:nn: note: was expecting final owned ob_refcnt of '*value' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned, 1 borrowed\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:nn: note: when PyDict_New() succeeds at:     dict = PyDict_New();\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:33:nn: note: taking False path at:     if (!dict) {\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:nn: note: reaching:     value = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:nn: note: when PyLong_FromLong() succeeds at:     value = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:38:nn: note: taking False path at:     if (!value) {\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:nn: note: reaching:     if (-1 == PyDict_SetItemString(dict, \"key\", value)) {\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:nn: note: when PyDict_SetItemString() succeeds at:     if (-1 == PyDict_SetItemString(dict, \"key\", value)) {\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:nn: note: ob_refcnt is now refs: 1 owned, 1 borrowed\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42:nn: note: taking False path at:     if (-1 == PyDict_SetItemString(dict, \"key\", value)) {\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:52:nn: note: reaching:     return dict;\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:52:nn: note: returning\ntests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32)) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42\n\nTrace 2:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42\n\nTrace 3:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42\n\nTrace 4:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_SetItemString() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=37))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:42\n\nTrace 5:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37\n\nTrace 6:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:37\n\nTrace 7:\n  Transitions:\n    'when PyDict_New() fails'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=57), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:57\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyDict_SetItemString/incorrect/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_Size/simple/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Exercise the checker's handling of calls to PyDict_Size\n*/\n\nPy_ssize_t\ntest(void *obj)\n{\n    return PyDict_Size((PyObject *)obj);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_Size/simple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyDict_Size/simple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/refcounts/PyDict_Size/simple/input.c:27 as non-NULL'\n    'when PyDict_Size() returns ma_used'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_Size/simple/input.c', line=29), minvalue=-0x8000000000000000, maxvalue=0x7fffffffffffffff)\n    str(): (Py_ssize_t)val [-0x8000000000000000 <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/PyDict_Size/simple/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyDict_Size/simple/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/refcounts/PyDict_Size/simple/input.c:27 as NULL'\n    'when PyDict_Size raises SystemError (via PyErr_BadInternalCall) due to NULL as argument 1 at tests/cpychecker/refcounts/PyDict_Size/simple/input.c:29'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyDict_Size/simple/input.c', line=29), value=-1)\n    str(): (Py_ssize_t)-1 from tests/cpychecker/refcounts/PyDict_Size/simple/input.c:29\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyDict_Size/simple/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_Clear/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of checker's handling of PyErr_Clear\n*/\n\nPyObject *\ntest(void)\n{\n    PyErr_Clear();\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_Clear/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_Clear/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyErr_Clear()'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_Clear/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyErr_Clear/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_Clear/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_Format/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct usage of PyErr_Format\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /* \n       It's more idiomatic to do a \"return PyErr_Format\".\n       However, this approach exercises this case, and verifies that the\n       checker doesn't erroneously think that it returns an object:\n    */\n    PyErr_Format(PyExc_RuntimeError,\n                 \"This test method always fails\");\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_Format/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_Format/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'PyErr_Format()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_Format/correct/input.c', line=36), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_Format/correct/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_Format/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_Format/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_NewException/basic/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyErr_NewException\n*/\n\nPyObject *\ntest(char *name, PyObject *base, PyObject *dict)\n{\n    return PyErr_NewException(name, base, dict);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_NewException/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_NewException/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown char * from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:27 as non-NULL'\n    'when PyErr_NewException() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=29), region=RegionOnHeap('new exception object from PyErr_NewException', gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new exception object from PyErr_NewException', gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=29), region=Region('PyTypeObject for new exception object from PyErr_NewException'))\n  region for gcc.ParmDecl('base') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('base')\")\n    str(): region for gcc.ParmDecl('base') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('base')\"))\n  region for gcc.ParmDecl('dict') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('dict')\")\n    str(): region for gcc.ParmDecl('dict') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('dict')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown char * from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:27 as non-NULL'\n    'when PyErr_NewException() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:29\n  region for gcc.ParmDecl('base') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('base')\")\n    str(): region for gcc.ParmDecl('base') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('base')\"))\n  region for gcc.ParmDecl('dict') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('dict')\")\n    str(): region for gcc.ParmDecl('dict') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('dict')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:29\n\nTrace 2:\n  Transitions:\n    'when treating unknown char * from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyErr_NewException with NULL as argument 1 (name) at tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:29\n  region for gcc.ParmDecl('base') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('base')\")\n    str(): region for gcc.ParmDecl('base') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('base')\"))\n  region for gcc.ParmDecl('dict') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('dict')\")\n    str(): region for gcc.ParmDecl('dict') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NewException/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('dict')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_NewException/basic/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_NoMemory/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyErr_NoMemory\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyErr_NoMemory();\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_NoMemory/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_NoMemory/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'PyErr_NoMemory() returns NULL, raising MemoryError'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NoMemory/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_NoMemory/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NoMemory/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_NoMemory/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyErr_NoMemory/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_PrintEx/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of invocation of PyErr_PrintEx\n*/\n\nPyObject*\ntest(void)\n{\n    /* Set the exception: */\n    PyErr_SetString(PyExc_RuntimeError,\n                    \"This function always fails\");\n\n    /* This ought to clear it: */\n    PyErr_PrintEx(1);\n\n    /* ...and this will be an error: the exception has been cleared: */\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_PrintEx/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_PrintEx/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_PrintEx/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyErr_PrintEx/input.c:37:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyErr_PrintEx/input.c:30:nn: note: calling PyErr_SetString() at:     PyErr_SetString(PyExc_RuntimeError,\ntests/cpychecker/refcounts/PyErr_PrintEx/input.c:30:nn: note: thread-local exception state now has value: unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\ntests/cpychecker/refcounts/PyErr_PrintEx/input.c:34:nn: note: calling PyErr_PrintEx() at:     PyErr_PrintEx(1);\ntests/cpychecker/refcounts/PyErr_PrintEx/input.c:34:nn: note: thread-local exception state now has value: (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_PrintEx/input.c:34\ntests/cpychecker/refcounts/PyErr_PrintEx/input.c:37:nn: note: returning at:     return NULL;\ntests/cpychecker/refcounts/PyErr_PrintEx/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyErr_PrintEx/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_PrintEx/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyErr_SetString()'\n    'calling PyErr_PrintEx()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_PrintEx/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_PrintEx/input.c:37\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_PrintEx/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetFromErrno/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct usage of PyErr_SetFromErrno\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyErr_SetFromErrno(PyExc_IOError);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetFromErrno/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetFromErrno/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyErr_SetFromErrno()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetFromErrno/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_SetFromErrno/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetFromErrno/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetFromErrno/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetNone/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct usage of PyErr_SetNone\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyErr_SetNone(PyExc_RuntimeError);\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetNone/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetNone/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyErr_SetNone()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetNone/correct/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_SetNone/correct/input.c:30\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetNone/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetNone/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetObject/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct usage of PyErr_SetObject\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyErr_SetObject(PyExc_RuntimeError,\n                    self);\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetObject/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetObject/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyErr_SetObject()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetObject/correct/input.c', line=31), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_SetObject/correct/input.c:31\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 2 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetObject/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetObject/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetString/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct usage of PyErr_SetString\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyErr_SetString(PyExc_RuntimeError,\n                    \"This test method always fails\");\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetString/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyErr_SetString/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyErr_SetString()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetString/correct/input.c', line=31), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyErr_SetString/correct/input.c:31\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyErr_SetString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyEval_CallMethod\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyEval_CallMethod(self, \"method_name\",\n                             \"(s, s, s, s)\",\n                             \"fee\", \"fi\", \"fo\", \"fum\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyEval_CallMethod() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=29), region=RegionOnHeap('new ref from call to PyEval_CallMethod', gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyEval_CallMethod', gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to PyEval_CallMethod'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyEval_CallMethod() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyEval_CallMethod/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of handling of a call to PyEval_CallMethod with bad arguments\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /* BUG: 1st argument can't be NULL: */\n    return PyEval_CallMethod(NULL, \"method_name\",\n                             \"(s, s, s, s)\",\n                             \"fee\", \"fi\", \"fo\", \"fum\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c:30:nn: warning: calling PyEval_CallMethod with NULL as argument 1 (0B) at tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c:30 [enabled by default]\ntests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c:30:nn: note: PyEval_CallMethod() invokes Py_TYPE() on the pointer within PyObject_GetAttrString(), thus accessing (NULL)->ob_type\ntests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: NullPtrArgument()\n  error: calling PyEval_CallMethod with NULL as argument 1 (0B) at tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c:30\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyEval_CallMethod/incorrect/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that PyFloat_AsDouble works for the case where we know\n  it's a PyFloatObject\n*/\n\ndouble\ntest(void)\n{\n    PyObject *float_obj;\n    double double_val;\n\n    float_obj = PyFloat_FromDouble(42.0);\n\n    /* Verify that we can roundtrip the underlying double: */\n    double_val = PyFloat_AsDouble(float_obj);\n    Py_XDECREF(float_obj);\n\n    return double_val;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyFloat_FromDouble() succeeds'\n    'PyFloat_AsDouble() returns ob_fval'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='double', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c', line=33), value=42.0)\n    str(): (double)42.0 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:33\n  PyFloatObject allocated at tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:33:\n    repr(): RegionOnHeap('PyFloatObject', gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c', line=33))\n    str(): PyFloatObject allocated at tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyFloat_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyFloat_FromDouble() succeeds'\n    'PyFloat_AsDouble() returns ob_fval'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyFloatObject allocated at tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='double', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c', line=33), value=42.0)\n    str(): (double)42.0 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:33\n  PyFloatObject allocated at tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:33:\n    repr(): RegionOnHeap('PyFloatObject', gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c', line=33))\n    str(): PyFloatObject allocated at tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyFloat_FromDouble() fails'\n    'PyFloat_AsDouble() fails due to NULL argument'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='double', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c', line=36), value=-1)\n    str(): (double)-1 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:36\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_PyFloatObject/input.c:36\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that PyFloat_AsDouble works for the case where we don't know if it's\n  a PyFloatObject\n*/\n\nextern void __cpychecker_dump(double val);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    double double_val;\n\n    double_val = PyFloat_AsDouble(self);\n    if (-1 == double_val) {\n        if (PyErr_Occurred()) {\n            /* Unsuccessful coercion to \"double\": */\n            return NULL;\n        } else {\n            /* Successful coercion to \"double\";\n               it just happened to be -1: */\n            __cpychecker_dump(double_val);\n        }\n    } else {\n        /* Successful coercion to \"double\": */\n        __cpychecker_dump(double_val);\n    }\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyFloat_AsDouble() succeeds'\n    'when taking True path'\n    'PyErr_Occurred()'\n    'taking False path'\n    '__dump(unknown double from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:34)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=49), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:49\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:31\n\nTrace 1:\n  Transitions:\n    'when PyFloat_AsDouble() succeeds'\n    'when taking False path'\n    '__dump(unknown double from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:34)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=49), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:49\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:31\n\nTrace 2:\n  Transitions:\n    'when PyFloat_AsDouble() fails'\n    'taking True path'\n    'PyErr_Occurred()'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyFloat_AsDouble/correct_cast/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_FromDouble/simple/#input.c#",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n\n*/\n\nPyObject *\ntest(double d)\n{\n    return PyFloat_FromDouble(d);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of handling of PyFloat_FromDouble\n*/\n\nPyObject *\ntest(double d)\n{\n    return PyFloat_FromDouble(d);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_FromDouble/simple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyFloat_FromDouble/simple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyFloat_FromDouble() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c', line=29), region=RegionOnHeap('PyFloatObject', gcc.Location(file='tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyFloatObject', gcc.Location(file='tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c', line=29)) from tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyFloat_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyFloat_FromDouble() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c:29\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyFloat_FromDouble/simple/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyGILState_Ensure/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct usage of PyGILState_{Ensure,Release}\n*/\n\nvoid\ntest(void)\n{\n    PyGILState_STATE state = PyGILState_Ensure();\n    \n    /* do things */\n\n    PyGILState_Release(state);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyGILState_Ensure/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyGILState_Ensure/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'PyGILState_Ensure'\n    'calling PyGILState_Release()'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyGILState_Ensure/correct/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that PyInt_AsLong works for the case where we know it's a PyIntObject\n*/\n\nextern void __cpychecker_dump(long val);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *int_obj;\n    long long_val;\n\n    /* This call can't fail, since we're in the interval [-5..257) */\n    int_obj = PyInt_FromLong(42);\n\n    /* Verify that we can roundtrip the underlying int: */\n    long_val = PyInt_AsLong(int_obj);\n    __cpychecker_dump(long_val);\n\n    return int_obj;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyInt_FromLong() succeeds'\n    'PyInt_AsLong() returns ob_ival'\n    '__dump((long int)42 from tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c:35)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c', line=35), region=RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c', line=35)))\n    str(): (struct PyObject *)&RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c', line=35)) from tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c:35\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c', line=35), region=RegionForGlobal(gcc.VarDecl('PyInt_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_AsLong/correct_PyIntObject/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that PyInt_AsLong works for the case where we don't know if it's\n  a PyIntObject\n*/\n\nextern void __cpychecker_dump(long val);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    long long_val;\n\n    long_val = PyInt_AsLong(self);\n    if (-1 == long_val) {\n        if (PyErr_Occurred()) {\n            /* Unsuccessful coercion to \"long\": */\n            return NULL;\n        } else {\n            /* Successful coercion to \"long\";\n               it just happened to be -1: */\n            __cpychecker_dump(long_val);\n        }\n    } else {\n        /* Successful coercion to \"long\": */\n        __cpychecker_dump(long_val);\n    }\n\n    Py_RETURN_NONE;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyInt_AsLong() succeeds'\n    'when considering range: -0x8000000000000000 <= value <= -2'\n    'taking False path'\n    '__dump((long int)val [-0x8000000000000000 <= val <= -2] from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:34)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=49), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:49\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:31\n\nTrace 1:\n  Transitions:\n    'when PyInt_AsLong() succeeds'\n    'when considering value == (long int)-1 from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:34'\n    'taking True path'\n    'PyErr_Occurred()'\n    'taking False path'\n    '__dump((long int)-1 from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:34)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=49), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:49\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:31\n\nTrace 2:\n  Transitions:\n    'when PyInt_AsLong() succeeds'\n    'when considering range: 0 <= value <= 0x7fffffffffffffff'\n    'taking False path'\n    '__dump((long int)val [0 <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:34)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=49), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:49\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:31\n\nTrace 3:\n  Transitions:\n    'when PyInt_AsLong() fails'\n    'taking True path'\n    'PyErr_Occurred()'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyInt_AsLong/correct_cast/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyInt_FromLong for the\n  case where the int is large\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /* \n       This call could fail, since we're outside the interval [-5..257) \n       257 is the first value not to be in the \"small_ints\" array\n    */\n    return PyInt_FromLong(257);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyInt_FromLong() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=34), region=RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=34)) from tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyInt_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyInt_FromLong() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyInt_FromLong/correct_large_int/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyInt_FromLong for\n  the case where the int is small\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /* This call can't fail, since we're in the interval [-5..257) */\n    return PyInt_FromLong(0);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyInt_FromLong() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c', line=31), region=RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c', line=31)))\n    str(): (struct PyObject *)&RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c', line=31)) from tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c:31\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyInt_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyInt_FromLong/correct_small_int/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyIter_Next/simple/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Basic test coverage for checker's handling of PyIter_Next\n*/\n\nPyObject *\ntest(PyObject *iter)\n{\n    return PyIter_Next(iter);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyIter_Next/simple/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyIter_Next/simple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyIter_Next/simple/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyIter_Next/simple/input.c:29:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyIter_Next/simple/input.c:29:nn: note: when PyIter_Next() returns NULL without setting an exception (end of iteration) at:     return PyIter_Next(iter);\ntests/cpychecker/refcounts/PyIter_Next/simple/input.c:29:nn: note: returning at:     return PyIter_Next(iter);\ntests/cpychecker/refcounts/PyIter_Next/simple/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyIter_Next/simple/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyIter_Next/simple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyIter_Next() retrieves a value (new ref)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=29), region=RegionOnHeap('new ref returned by PyIter_Next()', gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref returned by PyIter_Next()', gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=29)) from tests/cpychecker/refcounts/PyIter_Next/simple/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=29), region=Region('PyTypeObject for new ref returned by PyIter_Next()'))\n  region for gcc.ParmDecl('iter') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('iter')\")\n    str(): region for gcc.ParmDecl('iter') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('iter')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyIter_Next/simple/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyIter_Next() returns NULL without setting an exception (end of iteration)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyIter_Next/simple/input.c:29\n  region for gcc.ParmDecl('iter') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('iter')\")\n    str(): region for gcc.ParmDecl('iter') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('iter')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyIter_Next/simple/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyIter_Next() returns NULL setting an exception (error occurred)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyIter_Next/simple/input.c:29\n  region for gcc.ParmDecl('iter') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('iter')\")\n    str(): region for gcc.ParmDecl('iter') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyIter_Next/simple/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('iter')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyIter_Next/simple/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyList_Append\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    PyObject *item;\n\n    list = PyList_New(0);\n    if (!list) {\n        return NULL;\n    }\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(list);\n        return NULL;\n    }\n\n    if (-1 == PyList_Append(list, item)) {\n        Py_DECREF(list);\n        Py_DECREF(item);\n        return NULL;\n    }\n\n    /* FIXME: perhaps append it multiple times? */\n\n    /* PyList_Append adds a ref to item, reflecting its reference\n       within the list's ob_item array */\n\n    /* \"item\" is going out of scope, so we must DECREF our reference: */\n    Py_DECREF(item);\n\n    /* \"item\" should now have an ob_refcnt of 1 */\n\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() succeeds'\n    'taking False path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:42\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:42\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:42\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:36\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:42\n\nTrace 5:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:36\n\nTrace 6:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:36\n\nTrace 7:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/correct/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/correct/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PyList_Append\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    PyObject *item;\n\n    list = PyList_New(0);\n    if (!list) {\n        return NULL;\n    }\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(list);\n        return NULL;\n    }\n\n    if (-1 == PyList_Append(list, item)) {\n        Py_DECREF(list);\n        Py_DECREF(item);\n        return NULL;\n    }\n\n    /* \n       PyList_Append adds a ref to the item, but we still own a reference to\n       it, so this path through the function leaks the reference.\n     */\n\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:53:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:nn: note: '*item' was allocated at:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:53:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:nn: note: when PyList_New() succeeds at:     list = PyList_New(0);\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:33:nn: note: taking False path at:     if (!list) {\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:nn: note: reaching:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:nn: note: when PyLong_FromLong() succeeds at:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:37:nn: note: taking False path at:     if (!item) {\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42:nn: note: reaching:     if (-1 == PyList_Append(list, item)) {\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42:nn: note: when PyList_Append() succeeds at:     if (-1 == PyList_Append(list, item)) {\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42:nn: note: ob_refcnt is now refs: 2 owned\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42:nn: note: '*item' is now referenced by 1 non-stack value(s): PyListObject.ob_item[0]\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42:nn: note: taking False path at:     if (-1 == PyList_Append(list, item)) {\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:53:nn: note: reaching:     return list;\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:53:nn: note: returning\ntests/cpychecker/refcounts/PyList_Append/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyList_Append/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32)) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=36))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:42\n\nTrace 5:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36\n\nTrace 6:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:36\n\nTrace 7:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PyList_Append within\n  a loop\n*/\nextern PyObject *item_ctor(void);\n\nPyObject *\ntest(int n)\n{\n    PyObject *list;\n    int i;\n\n    list = PyList_New(0);\n    if (!list) {\n        return NULL;\n    }\n    for (i = 0; i < n; i++) {\n        PyObject *item;\n\n        item = item_ctor();\n        if (!item) {\n            Py_DECREF(list);\n            return NULL;\n        }\n\n        if (PyList_Append(list, item)) {\n            Py_DECREF(list);\n            Py_DECREF(item);\n            return NULL;\n        }\n\n        /*\n           PyList_Append adds a ref to the item, but we still own a reference to\n           it, so each time through the loop leaks a reference to the item\n        */\n    }\n\n    return list;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect-loop/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect-loop/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect-loop/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:59:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:nn: note: '*item' was allocated at:         item = item_ctor();\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:59:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:nn: note: when PyList_New() succeeds at:     list = PyList_New(0);\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:35:nn: note: taking False path at:     if (!list) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: reaching:     for (i = 0; i < n; i++) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: when considering range: 1 <= n <= 0x7fffffff at:     for (i = 0; i < n; i++) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: taking True path at:     for (i = 0; i < n; i++) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:nn: note: reaching:         item = item_ctor();\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:nn: note: when item_ctor() succeeds at:         item = item_ctor();\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:42:nn: note: taking False path at:         if (!item) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47:nn: note: reaching:         if (PyList_Append(list, item)) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47:nn: note: when PyList_Append() succeeds at:         if (PyList_Append(list, item)) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47:nn: note: ob_refcnt is now refs: 2 owned\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47:nn: note: '*item' is now referenced by 1 non-stack value(s): PyListObject.ob_item[0]\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47:nn: note: taking False path at:         if (PyList_Append(list, item)) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: reaching:     for (i = 0; i < n; i++) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: when considering n == (int)1 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:29 at:     for (i = 0; i < n; i++) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:38:nn: note: taking False path at:     for (i = 0; i < n; i++) {\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:59:nn: note: reaching:     return list;\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:59:nn: note: returning\ntests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/incorrect-loop/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: -0x80000000 <= n <= 0'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34)) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:30\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= n <= 0x7fffffff'\n    'taking True path'\n    'when item_ctor() succeeds'\n    'taking False path'\n    'when PyList_Append() succeeds'\n    'taking False path'\n    'when considering n == (int)1 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:29'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34)) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:\n    repr(): RegionOnHeap('new ref from (unknown) item_ctor', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41))\n    str(): new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41), region=Region('PyTypeObject for new ref from (unknown) item_ctor'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:30\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= n <= 0x7fffffff'\n    'taking True path'\n    'when item_ctor() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=50), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:50\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:\n    repr(): RegionOnHeap('new ref from (unknown) item_ctor', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41))\n    str(): new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41), region=Region('PyTypeObject for new ref from (unknown) item_ctor'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= n <= 0x7fffffff'\n    'taking True path'\n    'when item_ctor() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=50), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:50\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:\n    repr(): RegionOnHeap('new ref from (unknown) item_ctor', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41))\n    str(): new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= n <= 0x7fffffff'\n    'taking True path'\n    'when item_ctor() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=50), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:50\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:\n    repr(): RegionOnHeap('new ref from (unknown) item_ctor', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41))\n    str(): new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41), region=Region('PyTypeObject for new ref from (unknown) item_ctor'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47\n\nTrace 5:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= n <= 0x7fffffff'\n    'taking True path'\n    'when item_ctor() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=50), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:50\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41:\n    repr(): RegionOnHeap('new ref from (unknown) item_ctor', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=41))\n    str(): new ref from (unknown) item_ctor allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:47\n\nTrace 6:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= n <= 0x7fffffff'\n    'taking True path'\n    'when item_ctor() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:44\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41\n\nTrace 7:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= n <= 0x7fffffff'\n    'taking True path'\n    'when item_ctor() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:44\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:41\n\nTrace 8:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c', line=36), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:36\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/incorrect-loop/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage of handling of PyList_Append(list, NULL);\n*/\n\nint\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    int tmp;\n\n    list = PyList_New(0);\n    if (!list) {\n        return 42;\n    }\n\n    tmp = PyList_Append(list, NULL);\n\n    Py_DECREF(list);\n\n    return tmp;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/null-newitem/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/null-newitem/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'returning -1 from PyList_Append() due to NULL item'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=37), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:37\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'returning -1 from PyList_Append() due to NULL item'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:32'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=37), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:32:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=32))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:37\n\nTrace 2:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=34), value=42)\n    str(): (int)42 from tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/null-newitem/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  https://fedorahosted.org/gcc-python-plugin/ticket/19\n  Test of:\n     PyList_Append(list, item)\n  where list is an UnknownValue\n*/\n\nint\ntest(void *arg, PyObject *item)\n{\n    PyObject *list = arg;\n    return PyList_Append(list, item);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/ticket-19/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/ticket-19/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:30 as non-NULL'\n    'when treating ob_size as 0'\n    'when PyList_Append() succeeds'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c', line=33), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:33\n  region for gcc.ParmDecl('item') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('item')\")\n    str(): region for gcc.ParmDecl('item') on stack\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('item')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:31\n\nTrace 1:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:30 as non-NULL'\n    'when treating ob_size as 0'\n    'when PyList_Append() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c', line=33), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:33\n  region for gcc.ParmDecl('item') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('item')\")\n    str(): region for gcc.ParmDecl('item') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('item')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:33\n\nTrace 2:\n  Transitions:\n    'when treating unknown void * from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:30 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyList_Append with NULL as argument 1 (list) at tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:33\n  region for gcc.ParmDecl('item') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('item')\")\n    str(): region for gcc.ParmDecl('item') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('item')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-19/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  https://fedorahosted.org/gcc-python-plugin/ticket/22\n  Test of:\n     PyList_Append(list, item)\n  where item is an UnknownValue\n*/\n\nextern PyObject *ptr;\n\nPyObject *\ntest(PyObject *self)\n{\n    PyObject *list;\n    PyObject *item;\n\n    list = PyList_New(0);\n    if (!list) {\n        return NULL;\n    }\n\n    if (-1 == PyList_Append(list, ptr)) {\n        Py_DECREF(list);\n        return NULL;\n    }\n\n    return list;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/ticket-22/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Append/ticket-22/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:29 as non-NULL'\n    'when PyList_Append() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37)) from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:33\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:29 as non-NULL'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:42\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:29 as non-NULL'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:42\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:29 as NULL'\n    'returning -1 from PyList_Append() due to NULL item'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:42\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:29 as NULL'\n    'returning -1 from PyList_Append() due to NULL item'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=44), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:44\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=37))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:42\n\nTrace 5:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Append/ticket-22/input.c:37\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_GetItem/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyList_GetItem\n*/\n\nextern PyObject *some_list;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *item;\n    item = PyList_GetItem(some_list, 3);\n    if (item) {\n        /*\n          If it succeeds, it only returns a borrowed ref, so we must incref\n          it:\n        */\n        Py_INCREF(item);\n        return item;\n    }\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_GetItem/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_GetItem/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyList_GetItem/correct/input.c:26 as non-NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=32), region=RegionOnHeap('borrowed reference returned by PyList_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyList_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyList_GetItem/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=32), region=Region('PyTypeObject for borrowed reference returned by PyList_GetItem()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_GetItem/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyList_GetItem/correct/input.c:26 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyList_GetItem with NULL as argument 1 (some_list.0) at tests/cpychecker/refcounts/PyList_GetItem/correct/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_GetItem/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SET_ITEM_macro(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    PyObject *item;\n    list = PyList_New(1);\n    if (!list) {\n        return NULL;\n    }\n\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(list);\n        return NULL;\n    }\n    \n    /*\n      Set the item in the list via the PyList_SET_ITEM macro.\n\n      The checker ought to figure out that the macro has stolen the reference\n      to \"item\", and that this function is thus _not_ leaking a reference to\n      \"item\".\n    */\n    PyList_SET_ITEM(list, 0, item);\n\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SET_ITEM_macro, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=27), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=27)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=27)) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:27\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:32:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=32))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:27:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=27))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:27\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:32\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:27'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:27:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=27))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:27\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:32\n\nTrace 3:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SET_ITEM_macro(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    /* \n       The checker must not get confused by this temporary array:\n       the borrowed refs that it stores do not persist beyond the\n       lifetime of the function:\n    */\n    PyObject *items[3];\n\n    list = PyList_New(3);\n    if (!list) {\n        return NULL;\n    }\n\n    /* Construct 3 new references: */\n    items[0] = PyLong_FromLong(1000);\n    if (!items[0]) {\n        Py_DECREF(list);\n        return NULL;\n    }\n    items[1] = PyLong_FromLong(2000);\n    if (!items[1]) {\n        Py_DECREF(items[0]);\n        Py_DECREF(list);\n        return NULL;\n    }\n    items[2] = PyLong_FromLong(3000);\n    if (!items[2]) {\n        Py_DECREF(items[1]);\n        Py_DECREF(items[0]);\n        Py_DECREF(list);\n        return NULL;\n    }\n    \n    /*\n      Set each item in the list via the PyList_SET_ITEM macro.\n\n      The checker ought to figure out that the macro has stolen the reference\n      to \"item\", and that this function is thus _not_ leaking a reference to\n      \"item\".\n    */\n    PyList_SET_ITEM(list, 0, items[0]);\n    PyList_SET_ITEM(list, 1, items[1]);\n    PyList_SET_ITEM(list, 2, items[2]);\n\n    /* This isn't a leak: the 3 new references are owned by the list: */\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SET_ITEM_macro, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33)) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=50))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=50), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 5:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 6:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 7:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 8:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 9:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 10:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 11:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 12:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 13:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n\nTrace 14:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:39\n\nTrace 15:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/correct_multiple/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SET_ITEM_macro(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    /* \n       The checker must not get confused by this temporary array:\n       the borrowed refs that it stores do not persist beyond the\n       lifetime of the function:\n    */\n    PyObject *items[3];\n\n    list = PyList_New(3);\n    if (!list) {\n        return NULL;\n    }\n\n    /* Construct 3 new references: */\n    items[0] = PyLong_FromLong(1000);\n    if (!items[0]) {\n        Py_DECREF(list);\n        return NULL;\n    }\n    items[1] = PyLong_FromLong(2000);\n    if (!items[1]) {\n        Py_DECREF(items[0]);\n        Py_DECREF(list);\n        return NULL;\n    }\n    items[2] = PyLong_FromLong(3000);\n    if (!items[2]) {\n        Py_DECREF(items[1]);\n        Py_DECREF(items[0]);\n        Py_DECREF(list);\n        return NULL;\n    }\n    \n    /*\n      Set each item in the list via the PyList_SET_ITEM macro.\n\n      These are stolen references, so at this point the reference counts for\n      the PyLongObjects are balanced.\n    */\n    PyList_SET_ITEM(list, 0, items[0]);\n    PyList_SET_ITEM(list, 1, items[1]);\n    PyList_SET_ITEM(list, 2, items[2]);\n\n    /*\n      Now erroneously increment the reference count on one of them:\n    */\n    Py_INCREF(items[2]);\n\n    /* This is a leak of items[2]: the 3 new references are owned by the list\n       but the extra incref above is a leak: */\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SET_ITEM_macro, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/stderr.txt",
    "content": "In function 'handle_SET_ITEM_macro':\ncc1: warning: memory leak: ob_refcnt of PyLongObject is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: PyLongObject was allocated at:     items[2] = PyLong_FromLong(3000);\ncc1: note: was expecting final owned ob_refcnt of PyLongObject to be 1 due to object being referenced by: ob_item array for PyListObject[2] but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:nn: note: when PyList_New() succeeds at:     list = PyList_New(3);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:34:nn: note: taking False path at:     if (!list) {\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:nn: note: reaching:     items[0] = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:nn: note: when PyLong_FromLong() succeeds at:     items[0] = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:40:nn: note: taking False path at:     if (!items[0]) {\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:nn: note: reaching:     items[1] = PyLong_FromLong(2000);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:nn: note: when PyLong_FromLong() succeeds at:     items[1] = PyLong_FromLong(2000);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:45:nn: note: taking False path at:     if (!items[1]) {\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: reaching:     items[2] = PyLong_FromLong(3000);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: when PyLong_FromLong() succeeds at:     items[2] = PyLong_FromLong(3000);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:51:nn: note: taking False path at:     if (!items[2]) {\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:64:nn: note: reaching:     PyList_SET_ITEM(list, 0, items[0]);\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:66:nn: note: PyLongObject is now referenced by 1 non-stack value(s): ob_item array for PyListObject[2]\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:71:nn: note: ob_refcnt is now refs: 2 owned\ncc1: note: returning\ntests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:24:nn: note: graphical error report for function 'handle_SET_ITEM_macro' written out to 'tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c.handle_SET_ITEM_macro-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33)) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=50))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=50), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 5:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 6:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 7:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 8:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 9:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 10:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 11:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 12:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 13:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n\nTrace 14:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:39\n\nTrace 15:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_SET_ITEM_macro/incorrect_multiple/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Size/known-size/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a call to PyList_Size where we know the size\n*/\n\nint\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *list = PyList_New(42);\n    int tmp;\n\n    if (!list) {\n        return -1;\n    }\n    \n    tmp = PyList_Size(list);\n    Py_DECREF(list);\n    return tmp; /* the checker ought to know that this value is 42 */\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Size/known-size/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Size/known-size/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyList_Size() returns ob_size'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=36), value=42)\n    str(): (int)42 from tests/cpychecker/refcounts/PyList_Size/known-size/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Size/known-size/input.c:29:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=29))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Size/known-size/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Size/known-size/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyList_Size() returns ob_size'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PyList_Size/known-size/input.c:29'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=36), value=42)\n    str(): (int)42 from tests/cpychecker/refcounts/PyList_Size/known-size/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PyList_Size/known-size/input.c:29:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=29))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PyList_Size/known-size/input.c:29\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Size/known-size/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=33), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/PyList_Size/known-size/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/known-size/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyList_Size/known-size/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Size/unknown-size/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a call to PyList_Size where we don't know the size\n*/\n\nPy_ssize_t\ntest(PyObject *list)\n{\n    Py_ssize_t tmpA, tmpB;\n    tmpA = PyList_Size(list);\n    tmpB = PyList_Size(list);\n    if (tmpA == tmpB) {\n        /* they ought to be provably the same */\n        return 42;\n    } else {\n        /* this should not occur */\n        return -1;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Size/unknown-size/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyList_Size/unknown-size/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_Size() returns ob_size'\n    'when PyList_Size() returns ob_size'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/unknown-size/input.c', line=34), value=42)\n    str(): (Py_ssize_t)42 from tests/cpychecker/refcounts/PyList_Size/unknown-size/input.c:34\n  region for gcc.ParmDecl('list') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('list')\")\n    str(): region for gcc.ParmDecl('list') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyList_Size/unknown-size/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('list')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyList_Size/unknown-size/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMapping_Size/basic/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Basic test coverage for our handler for PyMapping_Size\n*/\n\nPy_ssize_t\ntest(PyObject *obj)\n{\n    return PyMapping_Size(obj);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMapping_Size/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMapping_Size/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyMapping_Size() succeeds'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMapping_Size/basic/input.c', line=29), minvalue=-0x8000000000000000, maxvalue=0x7fffffffffffffff)\n    str(): (Py_ssize_t)val [-0x8000000000000000 <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/PyMapping_Size/basic/input.c:29\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMapping_Size/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyMapping_Size/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyMapping_Size() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMapping_Size/basic/input.c', line=29), value=-1)\n    str(): (Py_ssize_t)-1 from tests/cpychecker/refcounts/PyMapping_Size/basic/input.c:29\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMapping_Size/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PyMapping_Size/basic/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a correct call to PyMem_Malloc (and PyMem_Free)\n*/\n\nextern void foo(char *buf, size_t n);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    char *buf = PyMem_New(char, 4096);\n\n    if (!buf) {\n        return PyErr_NoMemory();\n    }\n\n    foo(buf, 4096);\n\n    PyMem_Free(buf);\n    \n    Py_RETURN_NONE;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyMem_Malloc() succeeds'\n    'taking False path'\n    'calling PyMem_Free on PyMem_Malloc allocated at tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c:31'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c', line=41), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c:41\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c:30\n\nTrace 1:\n  Transitions:\n    'when PyMem_Malloc() fails'\n    'taking True path'\n    'PyErr_NoMemory() returns NULL, raising MemoryError'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyMem_Malloc/correct/alloc-and-free/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a correct call to PyMem_Free(NULL)\n*/\n\nextern void foo(char *buf, size_t n);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyMem_Free(NULL);\n\n    Py_RETURN_NONE;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyMem_Free on NULL'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/input.c:33\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyMem_Malloc/correct/free-NULL/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Reproducer for traceback seen when analyzing psycopg\n*/\n\nextern PyTypeObject fooType;\n\nint\ntest(PyObject *module)\n{\n    return PyModule_AddObject(module,\n                              \"foo\",\n                              (PyObject*)&fooType);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31:nn: warning: future use-after-free: ob_refcnt of fooType is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31:nn: note: was expecting final owned ob_refcnt of fooType to be 0 since nothing references it but final ob_refcnt is refs: -1 owned, 2 borrowed\ntests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31:nn: note: when PyModule_AddObject() succeeds at:     return PyModule_AddObject(module,\ntests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31:nn: note: ob_refcnt is now refs: -1 owned, 2 borrowed\ntests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31:nn: note: returning at:     return PyModule_AddObject(module,\ntests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c', line=31), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31\n  region for gcc.ParmDecl('module') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('module')\")\n    str(): region for gcc.ParmDecl('module') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('module')\"))\n  RegionForGlobal(gcc.VarDecl('fooType')):\n    repr(): RegionForGlobal(gcc.VarDecl('fooType'))\n    str(): RegionForGlobal(gcc.VarDecl('fooType'))\n    r->ob_refcnt: refs: -1 owned, 2 borrowed\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:30\n\nTrace 1:\n  Transitions:\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c', line=31), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31\n  region for gcc.ParmDecl('module') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('module')\")\n    str(): region for gcc.ParmDecl('module') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('module')\"))\n  RegionForGlobal(gcc.VarDecl('fooType')):\n    repr(): RegionForGlobal(gcc.VarDecl('fooType'))\n    str(): RegionForGlobal(gcc.VarDecl('fooType'))\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyModule_AddObject/incorrect-with-cast/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_CallFunction\n*/\n\nPyObject *\ntest(PyObject *callable, int i)\n{\n    return PyObject_CallFunction(callable,\n                                 \"(s, s, s, s, i)\",\n                                 \"fee\", \"fi\", \"fo\", \"fum\", i);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunction/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunction/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_CallFunction() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c', line=29), region=RegionOnHeap('new ref from call to PyObject_CallFunction', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallFunction', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to PyObject_CallFunction'))\n  region for gcc.ParmDecl('callable') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('callable')\")\n    str(): region for gcc.ParmDecl('callable') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('callable')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_CallFunction() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c:29\n  region for gcc.ParmDecl('callable') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('callable')\")\n    str(): region for gcc.ParmDecl('callable') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('callable')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallFunction/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_CallFunctionObjArgs\n*/\n\nstruct FooObject {\n    PyObject_HEAD\n    int i;\n};\n\nPyObject *\ntest(PyObject *callable, PyObject *a, struct FooObject *b)\n{\n    return PyObject_CallFunctionObjArgs(callable, a, b, NULL);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_CallFunctionObjArgs() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=34), region=RegionOnHeap('new ref from call to PyObject_CallFunctionObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallFunctionObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=34)) from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=34), region=Region('PyTypeObject for new ref from call to PyObject_CallFunctionObjArgs'))\n  region for gcc.ParmDecl('callable') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('callable')\")\n    str(): region for gcc.ParmDecl('callable') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('callable')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c:33\n\nTrace 1:\n  Transitions:\n    'when PyObject_CallFunctionObjArgs() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c:34\n  region for gcc.ParmDecl('callable') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('callable')\")\n    str(): region for gcc.ParmDecl('callable') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('callable')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/correct/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of detection of bogus types/lack of NULL termination in a call to\n  PyObject_CallFunctionObjArgs\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /* BUG: these types are completely wrong:\n       the function expects a NULL-terminated sequence of (PyObject*)\n    */\n    return PyObject_CallFunctionObjArgs(self, \"method_name\",\n                               \"(s, s, s, s)\",\n                               \"fee\", \"fi\", \"fo\", \"fum\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33:nn: warning: argument 2 had type char[12] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33:nn: warning: argument 3 had type char[13] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33:nn: warning: argument 4 had type char[4] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33:nn: warning: argument 5 had type char[3] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33:nn: warning: argument 6 had type char[3] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33:nn: warning: argument 7 had type char[4] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33:nn: warning: arguments to PyObject_CallFunctionObjArgs were not NULL-terminated [enabled by default]\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_CallFunctionObjArgs() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=33), region=RegionOnHeap('new ref from call to PyObject_CallFunctionObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallFunctionObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=33)) from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=33), region=Region('PyTypeObject for new ref from call to PyObject_CallFunctionObjArgs'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyObject_CallFunctionObjArgs() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallFunctionObjArgs/incorrect/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_CallMethod\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyObject_CallMethod(self, \"method_name\",\n                               \"(s, s, s, s)\",\n                               \"fee\", \"fi\", \"fo\", \"fum\");\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethod/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethod/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_CallMethod() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=29), region=RegionOnHeap('new ref from call to PyObject_CallMethod', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallMethod', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to PyObject_CallMethod'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_CallMethod() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethod/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_CallMethod\n  with the \"N\" format unit\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyObject_CallMethod(self, \"method_name\",\n                               \"(s, s, s, N)\",\n                               \"fee\", \"fi\", \"fo\", PyLong_FromLong(0x1000));\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when PyObject_CallMethod() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30), region=RegionOnHeap('new ref from call to PyObject_CallMethod', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallMethod', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30)) from tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30), region=Region('PyTypeObject for new ref from call to PyObject_CallMethod'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when PyObject_CallMethod() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'when PyObject_CallMethod() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethod/correct-code-N/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_CallMethodObjArgs\n*/\n\nstruct FooObject {\n    PyObject_HEAD\n    int i;\n};\n\nPyObject *\ntest(PyObject *obj, PyObject *a, struct FooObject *b)\n{\n    PyObject *name = PyString_FromString(\"some_method\");\n    PyObject *result;\n    if (!name) {\n        return NULL;\n    }\n    result = PyObject_CallMethodObjArgs(obj, name, a, b, NULL);\n    Py_DECREF(name);\n    return result;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() succeeds'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39), region=RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39)) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39), region=Region('PyTypeObject for new ref from call to PyObject_CallMethodObjArgs'))\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=34))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:33\n\nTrace 1:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() succeeds'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39), region=RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39)) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39), region=Region('PyTypeObject for new ref from call to PyObject_CallMethodObjArgs'))\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=34))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:33\n\nTrace 2:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() fails'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:39\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=34))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:39\n\nTrace 3:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() fails'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:39\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=34))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:39\n\nTrace 4:\n  Transitions:\n    'when PyString_FromString() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:37\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/correct/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of detection of bogus types/lack of NULL termination in a call to\n  PyObject_CallMethodObjArgs\n*/\n\nstruct FooObject {\n    PyObject_HEAD\n    int i;\n};\n\nPyObject *\ntest(PyObject *obj, PyObject *a, struct FooObject *b)\n{\n    PyObject *name = PyString_FromString(\"some_method\");\n    PyObject *result;\n    if (!name) {\n        return NULL;\n    }\n    /* BUG: these types are completely wrong:\n       the function expects a NULL-terminated sequence of (PyObject*)\n    */\n    result = PyObject_CallMethodObjArgs(obj, name,\n                                        \"(s, s, s, s)\",\n                                        \"fee\", \"fi\", \"fo\", \"fum\");\n    Py_DECREF(name);\n    return result;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43:nn: warning: argument 3 had type char[13] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43:nn: warning: argument 4 had type char[4] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43:nn: warning: argument 5 had type char[3] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43:nn: warning: argument 6 had type char[3] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43:nn: warning: argument 7 had type char[4] * but was expecting a PyObject* (or subclass) [enabled by default]\ntests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43:nn: warning: arguments to PyObject_CallMethodObjArgs were not NULL-terminated [enabled by default]\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() succeeds'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43), region=RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43)) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43), region=Region('PyTypeObject for new ref from call to PyObject_CallMethodObjArgs'))\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=35))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=35), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:34\n\nTrace 1:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() succeeds'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43), region=RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallMethodObjArgs', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43)) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43), region=Region('PyTypeObject for new ref from call to PyObject_CallMethodObjArgs'))\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=35))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:34\n\nTrace 2:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() fails'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=35))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=35), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43\n\nTrace 3:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PyObject_CallMethodObjArgs() fails'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=43), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=35))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:43\n\nTrace 4:\n  Transitions:\n    'when PyString_FromString() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:38\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c', line=33), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallMethodObjArgs/incorrect/input.c:35\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_CallObject\n*/\n\nPyObject *\ntest(PyObject *callable, PyObject *args)\n{\n    return PyObject_CallObject(callable, args);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallObject/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_CallObject/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_CallObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=29), region=RegionOnHeap('new ref from call to PyObject_CallObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_CallObject', gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to PyObject_CallObject'))\n  region for gcc.ParmDecl('callable') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('callable')\")\n    str(): region for gcc.ParmDecl('callable') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('callable')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_CallObject() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c:29\n  region for gcc.ParmDecl('callable') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('callable')\")\n    str(): region for gcc.ParmDecl('callable') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('callable')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_CallObject/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyObject_GenericGetAttr\n*/\n\nPyObject *\ntest(PyObject *o, PyObject *name)\n{\n    return PyObject_GenericGetAttr(o, name);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_GenericGetAttr() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=29), region=RegionOnHeap('new ref from PyObject_GenericGetAttr()', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from PyObject_GenericGetAttr()', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=29), region=Region('PyTypeObject for new ref from PyObject_GenericGetAttr()'))\n  region for gcc.ParmDecl('o') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('o')\")\n    str(): region for gcc.ParmDecl('o') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('o')\"))\n  region for gcc.ParmDecl('name') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('name')\")\n    str(): region for gcc.ParmDecl('name') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('name')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_GenericGetAttr() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c:29\n  region for gcc.ParmDecl('o') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('o')\")\n    str(): region for gcc.ParmDecl('o') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('o')\"))\n  region for gcc.ParmDecl('name') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('name')\")\n    str(): region for gcc.ParmDecl('name') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('name')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_GenericGetAttr/basic/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyObject_GenericSetAttr\n*/\n\nint\ntest(PyObject *o, PyObject *name, PyObject *value)\n{\n    return PyObject_GenericSetAttr(o, name, value);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_GenericSetAttr() succeeds'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=29), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c:29\n  region for gcc.ParmDecl('o') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('o')\")\n    str(): region for gcc.ParmDecl('o') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('o')\"))\n  region for gcc.ParmDecl('name') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('name')\")\n    str(): region for gcc.ParmDecl('name') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('name')\"))\n  region for gcc.ParmDecl('value') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('value')\")\n    str(): region for gcc.ParmDecl('value') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('value')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_GenericSetAttr() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=29), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c:29\n  region for gcc.ParmDecl('o') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('o')\")\n    str(): region for gcc.ParmDecl('o') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('o')\"))\n  region for gcc.ParmDecl('name') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('name')\")\n    str(): region for gcc.ParmDecl('name') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('name')\"))\n  region for gcc.ParmDecl('value') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('value')\")\n    str(): region for gcc.ParmDecl('value') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('value')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_AttributeError')) from tests/cpychecker/refcounts/PyObject_GenericSetAttr/basic/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_GetAttr\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *attrname)\n{\n    return PyObject_GetAttr(self, attrname);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_GetAttr() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=29), region=RegionOnHeap('new ref from call to PyObject_GetAttr', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_GetAttr', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to PyObject_GetAttr'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('attrname') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('attrname')\")\n    str(): region for gcc.ParmDecl('attrname') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('attrname')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_GetAttr() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('attrname') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('attrname')\")\n    str(): region for gcc.ParmDecl('attrname') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('attrname')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_GetAttr/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a NULL argument in a call to PyObject_GetAttr\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyObject_GetAttr(self, NULL);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c:29:nn: warning: calling PyObject_GetAttr with NULL as argument 2 (0B) at tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c:29 [enabled by default]\ntests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c:29:nn: note: PyObject_GetAttr() invokes Py_TYPE() on the pointer via the PyString_Check() macro, thus accessing (NULL)->ob_type\ntests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: NullPtrArgument()\n  error: calling PyObject_GetAttr with NULL as argument 2 (0B) at tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetAttr/incorrect/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_GetAttrString\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyObject_GetAttrString(self, \"name\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_GetAttrString() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=29), region=RegionOnHeap('new ref from call to PyObject_GetAttrString', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_GetAttrString', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to PyObject_GetAttrString'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_GetAttrString() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_GetAttrString/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a NULL argument in a call to PyObject_GetAttrString\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyObject_GetAttrString(self, NULL);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c:29:nn: warning: calling PyObject_GetAttrString with NULL as argument 2 (0B) at tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c:29 [enabled by default]\ntests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c:29:nn: note: PyObject_GetAttrString() can call PyString_InternFromString(), which calls PyString_FromString(), which requires a non-NULL pointer\ntests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: NullPtrArgument()\n  error: calling PyObject_GetAttrString with NULL as argument 2 (0B) at tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetAttrString/incorrect/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_GetItem\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *key)\n{\n    return PyObject_GetItem(self, key);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_GetItem() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=29), region=RegionOnHeap('new ref from call to PyObject_GetItem', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_GetItem', gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to PyObject_GetItem'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('key') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('key')\")\n    str(): region for gcc.ParmDecl('key') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('key')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_GetItem() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('key') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('key')\")\n    str(): region for gcc.ParmDecl('key') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('key')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_GetItem/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a NULL argument in a call to PyObject_GetItem\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyObject_GetItem(self, NULL);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/incorrect/stderr.txt",
    "content": ""
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_GetItem/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_GetItem raises SystemError due to NULL as argument 2 at tests/cpychecker/refcounts/PyObject_GetItem/incorrect/input.c:29'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/incorrect/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_GetItem/incorrect/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_GetItem/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyObject_GetItem/incorrect/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_HasAttrString\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    int has_name = PyObject_HasAttrString(self, \"name\");\n    return PyBool_FromLong(has_name);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_HasAttrString() returns 1 (true)'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_HasAttrString() returns 0 (false)'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=30), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_HasAttrString/correct/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a NULL argument in a call to PyObject_HasAttrString\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return PyBool_FromLong(PyObject_HasAttrString(self, NULL));\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c:29:nn: warning: calling PyObject_HasAttrString with NULL as argument 2 (0B) at tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c:29 [enabled by default]\ntests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: NullPtrArgument()\n  error: calling PyObject_HasAttrString with NULL as argument 2 (0B) at tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_HasAttrString/incorrect/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyObject_IsTrue\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    int is_true = PyObject_IsTrue(self);\n\n    return PyBool_FromLong(is_true);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_IsTrue/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_IsTrue/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_IsTrue() returns 1 (true)'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31)) from tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c:31\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyObject_IsTrue() returns 0 (false)'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31)) from tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c:31\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyObject_IsTrue() returns -1 (failure)'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31)) from tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c:31\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=31), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyObject_IsTrue/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_SetAttrString/ignored-lhs/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Regression test for:\n     AttributeError: 'NoneType' object has no attribute 'type'\n  seen compiling pychm-0.8.4/chm/swig_chm.c:SWIG_NewPointerObj:576\n*/\nvoid\ntest(PyObject *self, PyObject *value)\n{\n    /* return value is ignored: */\n    PyObject_SetAttrString(self, \"key\", value);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyObject_SetAttrString/ignored-lhs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SetItem(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    PyObject *item;\n    int rv;\n\n    list = PyList_New(1);\n    if (!list) {\n        return NULL;\n    }\n\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(list);\n        return NULL;\n    }\n\n    /* Set the item in the list via PySequence_SetItem() */\n    rv = PySequence_SetItem(list, 0, item);\n    if (rv != 0) {\n        Py_DECREF(list);\n        Py_DECREF(item);\n        return NULL;\n    }\n\n    /* the function doesn't steal a ref, so leaving item here would be a leak */\n    Py_DECREF(item);\n\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SetItem, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'PySequence_SetItem() succeeds'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29)) from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:34:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=34))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'PySequence_SetItem() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:34'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29)) from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:34:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=34))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:24\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:34\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=29))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:34\n\nTrace 4:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=31), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:31\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySequence_SetItem/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SetItem(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    PyObject *item;\n    int rv;\n\n    list = PyList_New(1);\n    if (!list) {\n        return NULL;\n    }\n\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(list);\n        return NULL;\n    }\n\n    /* Set the item in the list via PySequence_SetItem() */\n    rv = PySequence_SetItem(list, 0, item);\n    if (rv != 0) {\n        Py_DECREF(list);\n        Py_DECREF(item);\n        return NULL;\n    }\n\n    /* ERROR: we are still keeping a reference on item */\n\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SetItem, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/incorrect/stderr.txt",
    "content": "In function 'handle_SetItem':\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:50:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34:nn: note: '*item' was allocated at:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:50:nn: note: was expecting final owned ob_refcnt of '*item' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29:nn: note: when PyList_New() succeeds at:     list = PyList_New(1);\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:30:nn: note: taking False path at:     if (!list) {\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34:nn: note: reaching:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34:nn: note: when PyLong_FromLong() succeeds at:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:35:nn: note: taking False path at:     if (!item) {\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:41:nn: note: reaching:     rv = PySequence_SetItem(list, 0, item);\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:41:nn: note: PySequence_SetItem() succeeds at:     rv = PySequence_SetItem(list, 0, item);\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:42:nn: note: taking False path at:     if (rv != 0) {\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:50:nn: note: reaching:     return list;\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:50:nn: note: returning\ntests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:24:nn: note: graphical error report for function 'handle_SetItem' written out to 'tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c.handle_SetItem-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_SetItem/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'PySequence_SetItem() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=29), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=29)) from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=34))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=29))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=29))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:34\n\nTrace 3:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=31), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:31\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySequence_SetItem/incorrect/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_Size/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_PySequence_Size(PyObject *self, PyObject *args)\n{\n    PyObject *list = NULL;\n    PyObject *rv = NULL;\n\n    list = PyList_New(1);\n    if (!list) {\n        goto exit;\n    }\n\n    if (PySequence_Size(list) >= 0) {\n        /* success */\n        Py_INCREF(Py_None);\n        rv = Py_None;\n    }\n    /* on failure, an exception is set */\n\nexit:\n    Py_XDECREF(list);\n    return rv;\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_PySequence_Size, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_Size/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_Size/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PySequence_Size() succeeds'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:36\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=28))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=28), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PySequence_Size() succeeds'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:36\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=28))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:24\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PySequence_Size() fails'\n    'taking False path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=26), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:26\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=28))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=28), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:33\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PySequence_Size() fails'\n    'taking False path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=26), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:26\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=28))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:33\n\nTrace 4:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=26), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:26\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySequence_Size/correct/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_Size/null/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_PySequence_Size_NULL(PyObject *self, PyObject *args)\n{\n    PyObject *list = NULL;\n    PyObject *rv = NULL;\n\n    /* OUCH: list is null: expect a TypeError */\n    if (PySequence_Size(list) >= 0) {\n        /* success */\n        Py_INCREF(Py_None);\n        rv = Py_None;\n    }\n    /* on failure, an exception is set */\n\nexit:\n    Py_XDECREF(list);\n    return rv;\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_PySequence_Size_NULL, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_Size/null/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySequence_Size/null/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PySequence_Size raises SystemError due to NULL as argument 1 at tests/cpychecker/refcounts/PySequence_Size/null/input.c:29'\n    'taking False path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/null/input.c', line=26), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySequence_Size/null/input.c:26\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/null/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySequence_Size/null/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PySequence_Size/null/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct call to PyString_AsString\n*/\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *repr_args = NULL;\n    PyObject *result = NULL;\n\n    repr_args = PyObject_Repr(args);\n    if (!repr_args) {\n        return NULL;\n    }\n\n    result = PyString_FromFormat(\"test(args=%s)\",\n                                 PyString_AsString(repr_args));\n    Py_DECREF(repr_args);\n    return result;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'taking False path'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() succeeds'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36)) from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:36\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:27\n\nTrace 1:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'taking False path'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() succeeds'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36)) from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:36\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:27\n\nTrace 2:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'taking False path'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() fails'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:36\n\nTrace 3:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'taking False path'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() fails'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=36), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:36\n\nTrace 4:\n  Transitions:\n    'when PyObject_Repr() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/correct/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect call to PyString_AsString\n*/\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *repr_args = NULL;\n    PyObject *result = NULL;\n\n    repr_args = PyObject_Repr(args);\n    /*\n       This code fails to check that the call to PyObject_Repr succeeded;\n       the checker ought to detect that a NULL ptr deref can happen inside\n       PyString_AsString:\n     */\n\n    result = PyString_FromFormat(\"test(args=%s)\",\n                                 PyString_AsString(repr_args));\n    Py_DECREF(repr_args);\n    return result;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38:nn: warning: calling PyString_AsString with NULL as argument 1 (repr_args) at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38 [enabled by default]\ntests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31:nn: note: when PyObject_Repr() fails at:     repr_args = PyObject_Repr(args);\ntests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38:nn: note: PyString_AsString() invokes Py_TYPE() on the pointer via the PyString_Check() macro, thus accessing (NULL)->ob_type\ntests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:27:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() succeeds'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38)) from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:27\n\nTrace 1:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() succeeds'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38)) from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:27\n\nTrace 2:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() fails'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38\n\nTrace 3:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'PyString_AsString() returns ob_sval'\n    'when PyString_FromFormat() fails'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38\n\nTrace 4:\n  Transitions:\n    'when PyObject_Repr() fails'\n  error: NullPtrArgument()\n  error: calling PyString_AsString with NULL as argument 1 (repr_args) at tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/incorrect/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/unknown/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a call to PyString_AsString where we can't know whether or not\n  it's a PyStringObject\n*/\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *result = NULL;\n\n    /* (ultimately we ought to detect when PyString_FromFormat is passed\n       a NULL for a %s format code) */\n    result = PyString_FromFormat(\"test(args=%s)\",\n                                 PyString_AsString(args));\n    return result;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/unknown/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_AsString/unknown/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_AsString() succeeds'\n    'when PyString_FromFormat() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33)) from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyString_AsString() succeeds'\n    'when PyString_FromFormat() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:33\n\nTrace 2:\n  Transitions:\n    'when PyString_AsString() fails'\n    'when PyString_FromFormat() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33)) from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:33\n\nTrace 3:\n  Transitions:\n    'when PyString_AsString() fails'\n    'when PyString_FromFormat() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_AsString/unknown/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_AsString/unknown/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/basic/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_Concat\n*/\n\nPyObject *\ntest(PyObject **lhs, PyObject *rhs)\n{\n    PyString_Concat(lhs, rhs);\n    return *lhs;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/basic/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/basic/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:29:nn: note: return value was allocated at:     PyString_Concat(lhs, rhs);\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: note: was expecting final owned ob_refcnt of return value to be 2 due to object being referenced by: return value, heap-region-0 but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:29:nn: note: when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as non-NULL at:     PyString_Concat(lhs, rhs);\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:29:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29 as non-NULL at:     PyString_Concat(lhs, rhs);\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: note: when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) at:     return *lhs;\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: note: return value is now referenced by 1 non-stack value(s): heap-region-0\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: note: returning at:     return *lhs;\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:29:nn: note: when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as non-NULL at:     PyString_Concat(lhs, rhs);\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:29:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29 as NULL at:     PyString_Concat(lhs, rhs);\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:29:nn: note: when PyString_Concat() does nothing due to NULL *lhs at:     PyString_Concat(lhs, rhs);\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:30:nn: note: returning at:     return *lhs;\ntests/cpychecker/refcounts/PyString_Concat/basic/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_Concat/basic/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29), region=Region('PyTypeObject for result of PyString_Concat'))\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() succeeds (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29), region=Region('PyTypeObject for result of PyString_Concat'))\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:28\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() fails (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n\nTrace 3:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() fails (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n\nTrace 4:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29 as NULL'\n    'when PyString_Concat() does nothing due to NULL *lhs'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:28\n\nTrace 5:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_Concat with NULL as argument 1 (lhs) at tests/cpychecker/refcounts/PyString_Concat/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/basic/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_Concat\n*/\n\nPyObject *\ntest(const char *msg0, const char *msg1)\n{\n    PyObject *result = PyString_FromString(msg0);\n\n    /* this leaks a reference to the 2nd argument if it's non-NULL: */\n    PyString_Concat(&result, PyString_FromString(msg1));\n\n    return result;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:34:nn: warning: memory leak: ob_refcnt of PyStringObject is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:nn: note: PyStringObject was allocated at:     PyString_Concat(&result, PyString_FromString(msg1));\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:34:nn: note: was expecting final owned ob_refcnt of PyStringObject to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:nn: note: when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL at:     PyObject *result = PyString_FromString(msg0);\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:nn: note: when PyString_FromString() succeeds at:     PyObject *result = PyString_FromString(msg0);\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:nn: note: when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL at:     PyString_Concat(&result, PyString_FromString(msg1));\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:nn: note: when PyString_FromString() succeeds at:     PyString_Concat(&result, PyString_FromString(msg1));\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:34:nn: note: when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) at:     return result;\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:34:nn: note: returning at:     return result;\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:34:nn: note: found 4 similar trace(s) to this\ntests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32)) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=Region('PyTypeObject for result of PyString_Concat'))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() succeeds (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32)) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=Region('PyTypeObject for result of PyString_Concat'))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:28\n\nTrace 2:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() fails (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n\nTrace 3:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() fails (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n\nTrace 4:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n\nTrace 5:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n\nTrace 6:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_FromString with NULL as argument 1 (msg1) at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:28\n\nTrace 7:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() does nothing due to NULL *lhs'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n\nTrace 8:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when PyString_Concat() does nothing due to NULL *lhs'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n\nTrace 9:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_FromString with NULL as argument 1 (msg1) at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:32\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n\nTrace 10:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_FromString with NULL as argument 1 (msg0) at tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/leak-of-rhs/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_Concat\n*/\n\nvoid\ntest(void)\n{\n    PyString_Concat(NULL, NULL);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-lhs/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-lhs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-lhs/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c:29:nn: warning: calling PyString_Concat with NULL as argument 1 (0B) at tests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c:29 [enabled by default]\ntests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c:29:nn: note: PyString_Concat unconditionally dereferences its first argument\ntests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-lhs/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: NullPtrArgument()\n  error: calling PyString_Concat with NULL as argument 1 (0B) at tests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-lhs/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_Concat\n*/\n\nPyObject *\ntest(PyObject **str)\n{\n    PyString_Concat(str, NULL);\n    /* an exception should have been raised to get the NULL here, which\n       is missing; the checker correctly complains about this */\n    return *str;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-rhs/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-rhs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-rhs/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:32:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29:nn: note: when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:27 as non-NULL at:     PyString_Concat(str, NULL);\ntests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29 as non-NULL at:     PyString_Concat(str, NULL);\ntests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:32:nn: note: when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() without deallocation on *LHS) at:     return *str;\ntests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:32:nn: note: returning at:     return *str;\ntests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:32:nn: note: found 2 similar trace(s) to this\ntests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Concat/null-rhs/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29 as non-NULL'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29 as non-NULL'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:28\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29 as NULL'\n    'when PyString_Concat() does nothing due to NULL *lhs'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:28\n\nTrace 3:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_Concat with NULL as argument 1 (str) at tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Concat/null-rhs/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_ConcatAndDel\n*/\n\nPyObject *\ntest(PyObject **lhs, PyObject *rhs)\n{\n    PyString_ConcatAndDel(lhs, rhs);\n    /* \n       There are 3 expected errors:\n         - it steals a reference to rhs when it succeeds\n         - when rhs is NULL, an exception ought to have been set\n         - when it succeeds, *lhs has a refcount of 1, but is referenced in\n           two places (return value and *lhs)\n    */\n    return *lhs;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: warning: future use-after-free: ob_refcnt of '*rhs' is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: was expecting final owned ob_refcnt of '*rhs' to be 0 since nothing references it but final ob_refcnt is refs: -1 owned, 1 borrowed\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29:nn: note: when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL at:     PyString_ConcatAndDel(lhs, rhs);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL at:     PyString_ConcatAndDel(lhs, rhs);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) (Py_DECREF() without deallocation on RHS) at:     return *lhs;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: ob_refcnt is now refs: -1 owned, 1 borrowed\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: returning at:     return *lhs;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: found 9 similar trace(s) to this\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29:nn: note: return value was allocated at:     PyString_ConcatAndDel(lhs, rhs);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: was expecting final owned ob_refcnt of return value to be 2 due to object being referenced by: return value, heap-region-0 but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29:nn: note: when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL at:     PyString_ConcatAndDel(lhs, rhs);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL at:     PyString_ConcatAndDel(lhs, rhs);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) (Py_DECREF() without deallocation on RHS) at:     return *lhs;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: returning at:     return *lhs;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: found 3 similar trace(s) to this\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29:nn: note: when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL at:     PyString_ConcatAndDel(lhs, rhs);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as NULL at:     PyString_ConcatAndDel(lhs, rhs);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: when PyString_Concat() does nothing due to NULL *lhs (Py_DECREF() without deallocation on RHS) at:     return *lhs;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: returning at:     return *lhs;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:37:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=Region('PyTypeObject for result of PyString_Concat'))\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=Region('PyTypeObject for result of PyString_Concat'))\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() succeeds (Py_DECREF() with deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=Region('PyTypeObject for result of PyString_Concat'))\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28\n\nTrace 3:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() succeeds (Py_DECREF() with deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), region=Region('PyTypeObject for result of PyString_Concat'))\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28\n\nTrace 4:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() fails (Py_DECREF() without deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n\nTrace 5:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() fails (Py_DECREF() without deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n\nTrace 6:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() fails (Py_DECREF() with deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n\nTrace 7:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as non-NULL'\n    'when PyString_Concat() fails (Py_DECREF() with deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n\nTrace 8:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as NULL'\n    'when PyString_Concat() does nothing due to NULL *lhs (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28\n\nTrace 9:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29 as NULL'\n    'when PyString_Concat() does nothing due to NULL *lhs (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28\n\nTrace 10:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_ConcatAndDel with NULL as argument 1 (lhs) at tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:29\n  region for gcc.ParmDecl('rhs') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('rhs')\")\n    str(): region for gcc.ParmDecl('rhs') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('rhs')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/basic/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_ConcatAndDel\n*/\n\nPyObject *\ntest(const char *msg0, const char *msg1)\n{\n    PyObject *result = PyString_FromString(msg0);\n    PyString_ConcatAndDel(&result, PyString_FromString(msg1));\n    return result;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=Region('PyTypeObject for result of PyString_Concat'))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() succeeds (Py_DECREF() without deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=Region('PyTypeObject for result of PyString_Concat'))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:28\n\nTrace 2:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() succeeds (Py_DECREF() with deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=Region('PyTypeObject for result of PyString_Concat'))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:28\n\nTrace 3:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() succeeds (Py_DECREF() with deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('result of PyString_Concat', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30)) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=Region('PyTypeObject for result of PyString_Concat'))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:28\n\nTrace 4:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() fails (Py_DECREF() without deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n\nTrace 5:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() fails (Py_DECREF() without deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n\nTrace 6:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() fails (Py_DECREF() with deallocation on *LHS) (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n\nTrace 7:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() fails (Py_DECREF() with deallocation on *LHS) (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n\nTrace 8:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n\nTrace 9:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n\nTrace 10:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_FromString with NULL as argument 1 (msg1) at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:28\n\nTrace 11:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() does nothing due to NULL *lhs (Py_DECREF() without deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n\nTrace 12:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() succeeds'\n    'when PyString_Concat() does nothing due to NULL *lhs (Py_DECREF() with deallocation on RHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n  PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n\nTrace 13:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when PyString_Concat() does nothing due to NULL *lhs'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n\nTrace 14:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as non-NULL'\n    'when PyString_FromString() fails'\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_FromString with NULL as argument 1 (msg1) at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:30\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n\nTrace 15:\n  Transitions:\n    'when treating unknown const char * from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_FromString with NULL as argument 1 (msg0) at tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/correct/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_ConcatAndDel\n*/\n\nvoid test(void)\n{\n    PyString_ConcatAndDel(NULL, NULL);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c:28:nn: warning: calling PyString_ConcatAndDel with NULL as argument 1 (0B) at tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c:28 [enabled by default]\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c:28:nn: note: dereferences it unconditionally within PyString_Concat\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c:27:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: NullPtrArgument()\n  error: calling PyString_ConcatAndDel with NULL as argument 1 (0B) at tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c:28\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-lhs/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyString_ConcatAndDel\n*/\n\nPyObject *\ntest(PyObject **str)\n{\n    PyString_ConcatAndDel(str, NULL);\n    /* an exception should have been raised to get the NULL here, which\n       is missing; the checker correctly complains about this */\n    return *str;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:32:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29:nn: note: when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:27 as non-NULL at:     PyString_ConcatAndDel(str, NULL);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29 as non-NULL at:     PyString_ConcatAndDel(str, NULL);\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:32:nn: note: when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() without deallocation on *LHS) at:     return *str;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:32:nn: note: returning at:     return *str;\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:32:nn: note: found 2 similar trace(s) to this\ntests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29 as non-NULL'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() without deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:28\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29 as non-NULL'\n    'when PyString_Concat() cleans up due to NULL right-hand side (Py_DECREF() with deallocation on *LHS)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:28\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:27 as non-NULL'\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29 as NULL'\n    'when PyString_Concat() does nothing due to NULL *lhs'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:28\n\nTrace 3:\n  Transitions:\n    'when treating unknown struct PyObject * * from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:27 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyString_ConcatAndDel with NULL as argument 1 (str) at tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_ConcatAndDel/null-rhs/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct call to PyString_FromStringAndSize\n*/\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *result;\n    result = PyString_FromStringAndSize(\"foo\", 3);\n    return result;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_FromStringAndSize() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=29), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=29)) from tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c:27\n\nTrace 1:\n  Transitions:\n    'when PyString_FromStringAndSize() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_FromStringAndSize/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Size/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a call to PyString_Size\n*/\n\nPy_ssize_t\ntest(PyObject *obj)\n{\n    return PyString_Size(obj);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Size/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyString_Size/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_Size() succeeds'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Size/correct/input.c', line=29), minvalue=0, maxvalue=0x7fffffffffffffff)\n    str(): (Py_ssize_t)val [0 <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/PyString_Size/correct/input.c:29\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Size/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyString_Size/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyString_Size() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Size/correct/input.c', line=29), value=-1)\n    str(): (Py_ssize_t)-1 from tests/cpychecker/refcounts/PyString_Size/correct/input.c:29\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyString_Size/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyString_Size/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyStructSequence/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Test of correct reference-handling in usage of the PyStructSequence API\n*/\n\n#include <Python.h>\n#include <structseq.h> /* not pulled in by Python.h */\n\nstatic struct PyStructSequence_Field coord_fields[] = {\n    {\"x\", NULL},\n    {\"y\", NULL},\n    {0}\n};\n\nstatic struct PyStructSequence_Desc coord_desc = {\n    \"Coord\", /* name */\n    NULL, /* doc */\n    coord_fields,\n    2\n};\n\nPyTypeObject CoordType;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n       FWIW, this assumes that we called:\n         PyStructSequence_InitType(&CoordType, &coord_desc);\n       when initializing the module:\n    */\n    PyObject *obj = PyStructSequence_New(&CoordType);\n    if (!obj) {\n        return NULL;\n    }\n\n    /*\n       These PyInt_ calls can't fail; the SET_ITEM macros steal the new ref\n       they give us, so this is correct:\n    */\n    PyStructSequence_SET_ITEM(obj, 0, PyInt_FromLong(0));\n    PyStructSequence_SET_ITEM(obj, 1, PyInt_FromLong(0));\n    return obj;\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyStructSequence/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyStructSequence/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyStructSequence_New() succeeds'\n    'taking False path'\n    'when PyInt_FromLong() succeeds'\n    'when PyInt_FromLong() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=50), region=RegionOnHeap('PyStructSequence_New', gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=50)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStructSequence_New', gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=50)) from tests/cpychecker/refcounts/PyStructSequence/correct/input.c:50\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=50), region=RegionForGlobal(gcc.VarDecl('CoordType')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=43), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=43), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyIntObject allocated at tests/cpychecker/refcounts/PyStructSequence/correct/input.c:59:\n    repr(): RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=59))\n    str(): PyIntObject allocated at tests/cpychecker/refcounts/PyStructSequence/correct/input.c:59\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=59), region=RegionForGlobal(gcc.VarDecl('PyInt_Type')))\n  PyIntObject allocated at tests/cpychecker/refcounts/PyStructSequence/correct/input.c:60:\n    repr(): RegionOnHeap('PyIntObject', gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=60))\n    str(): PyIntObject allocated at tests/cpychecker/refcounts/PyStructSequence/correct/input.c:60\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=60), region=RegionForGlobal(gcc.VarDecl('PyInt_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyStructSequence/correct/input.c:44\n\nTrace 1:\n  Transitions:\n    'when PyStructSequence_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=52), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyStructSequence/correct/input.c:52\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=43), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyStructSequence/correct/input.c', line=43), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyStructSequence/correct/input.c:50\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PySys_GetObject\n*/\n\nPyObject *\ntest(void)\n{\n    return PySys_GetObject(\"foo\");\n    /* BUG: only a borrowed reference */\n    /* BUG: if it fails, doesn't set exception */\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_GetObject/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_GetObject/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_GetObject/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: note: return value was allocated at:     return PySys_GetObject(\"foo\");\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: note: when PySys_GetObject() succeeds at:     return PySys_GetObject(\"foo\");\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: note: returning at:     return PySys_GetObject(\"foo\");\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: note: PySys_GetObject does not find string at:     return PySys_GetObject(\"foo\");\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29:nn: note: returning at:     return PySys_GetObject(\"foo\");\ntests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_GetObject/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PySys_GetObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c', line=29), region=RegionOnHeap('borrowed reference returned by PySys_GetObject()', gcc.Location(file='tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PySys_GetObject()', gcc.Location(file='tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c', line=29)) from tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c', line=29), region=Region('PyTypeObject for borrowed reference returned by PySys_GetObject()'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:28\n\nTrace 1:\n  Transitions:\n    'PySys_GetObject does not find string'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:29\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySys_GetObject/incorrect/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_SetObject/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PySys_SetObject\n  with a non-NULL argument\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *str;\n    str = PyString_FromString(\"hello world\");\n    if (!str) {\n        return NULL;\n    }\n    /* we own a ref on the string */\n    /* if successful, this adds a ref on the string: */\n    PySys_SetObject(\"greeting\", str);\n    /* get rid of our ref on the string: */\n    Py_DECREF(str);\n    Py_RETURN_NONE;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_SetObject/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PySys_SetObject/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PySys_SetObject() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=40), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:40\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PySys_SetObject() fails'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=40), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:40\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:37\n\nTrace 2:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'taking False path'\n    'when PySys_SetObject() fails'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=40), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:40\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=31))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:37\n\nTrace 3:\n  Transitions:\n    'when PyString_FromString() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PySys_SetObject/correct/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PySys_SetObject/correct/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyTuple_GetItem\n*/\n\nextern PyObject *some_tuple;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *item;\n    item = PyTuple_GetItem(some_tuple, 3);\n    if (item) {\n        /*\n          If it succeeds, it only returns a borrowed ref, so we must incref\n          it:\n        */\n        Py_INCREF(item);\n        return item;\n    }\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c:26 as non-NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=32), region=RegionOnHeap('borrowed reference returned by PyTuple_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyTuple_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=32), region=Region('PyTypeObject for borrowed reference returned by PyTuple_GetItem()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c:26 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyTuple_GetItem with NULL as argument 1 (some_tuple.0) at tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_GetItem/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PyTuple_GetItem\n*/\n\nextern PyObject *some_tuple;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *item;\n    item = PyTuple_GetItem(some_tuple, 3);\n    if (item) {\n        /* BUG: this is only a borrowed ref; we ought to INCREF it: */\n        return item;\n    }\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:35:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:32:nn: note: return value was allocated at:     item = PyTuple_GetItem(some_tuple, 3);\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:35:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:32:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:26 as non-NULL at:     item = PyTuple_GetItem(some_tuple, 3);\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:32:nn: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:33:nn: note: taking True path at:     if (item) {\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:35:nn: note: reaching:         return item;\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:35:nn: note: returning\ntests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:26 as non-NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=32), region=RegionOnHeap('borrowed reference returned by PyTuple_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyTuple_GetItem()', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=32)) from tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=32), region=Region('PyTypeObject for borrowed reference returned by PyTuple_GetItem()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:26 as NULL'\n  error: NullPtrArgument()\n  error: possibly calling PyTuple_GetItem with NULL as argument 1 (some_tuple.0) at tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_GetItem/incorrect/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_New/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyTuple_New\n*/\n\nextern void __cpychecker_dump(Py_ssize_t s);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *tuple;\n    tuple = PyTuple_New(0);\n    if (!tuple) {\n        return NULL;\n    }\n\n    __cpychecker_dump(PyTuple_Size(tuple));\n\n    /* \"tuple\" should now have an ob_refcnt of 1 */\n    return tuple;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_New/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_New/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyTuple_Size() returns ob_size'\n    '__dump((Py_ssize_t)0 from tests/cpychecker/refcounts/PyTuple_New/correct/input.c:32)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=32), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyTuple_New/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_New/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'when PyTuple_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_New/correct/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_New/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_New/correct/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of detection of incorect argument-count in a call to PyTuple_Pack\n*/\n\nPyObject *\ntest(PyObject *a, PyObject *b)\n{\n    /* BUG: the argument counts don't match */\n    return PyTuple_Pack(3, a, b);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/input.c:30:nn: warning: mismatching argument count in call to PyTuple_Pack [enabled by default]\ntests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n  error: WrongArgCount()\n  error: mismatching argument count in call to PyTuple_Pack\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  region for gcc.ParmDecl('b') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('b')\")\n    str(): region for gcc.ParmDecl('b') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('b')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_Pack/incorrect-arg-count/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SET_ITEM_macro(PyObject *self, PyObject *args)\n{\n    PyObject *tuple;\n    PyObject *item;\n    tuple = PyTuple_New(1);\n    if (!tuple) {\n        return NULL;\n    }\n\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    \n    /*\n      Set the item in the tuple via the PyTuple_SET_ITEM macro.\n\n      The checker ought to figure out that the macro has stolen the reference\n      to \"item\", and that this function is thus _not_ leaking a reference to\n      \"item\".\n    */\n    PyTuple_SET_ITEM(tuple, 0, item);\n\n    return tuple;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SET_ITEM_macro, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=27), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=27)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=27)) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:27\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:32:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=32))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:27:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=27))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:27\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:32\n\nTrace 2:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:27'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:27:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=27))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:27\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:32\n\nTrace 3:\n  Transitions:\n    'when PyTuple_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SET_ITEM_macro(PyObject *self, PyObject *args)\n{\n    PyObject *tuple;\n    /* \n       The checker must not get confused by this temporary array:\n       the borrowed refs that it stores do not persist beyond the\n       lifetime of the function:\n    */\n    PyObject *items[3];\n\n    tuple = PyTuple_New(3);\n    if (!tuple) {\n        return NULL;\n    }\n\n    /* Construct 3 new references: */\n    items[0] = PyLong_FromLong(1000);\n    if (!items[0]) {\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[1] = PyLong_FromLong(2000);\n    if (!items[1]) {\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[2] = PyLong_FromLong(3000);\n    if (!items[2]) {\n        Py_DECREF(items[1]);\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    \n    /*\n      Set each item in the tuple via the PyTuple_SET_ITEM macro.\n\n      The checker ought to figure out that the macro has stolen the reference\n      to \"item\", and that this function is thus _not_ leaking a reference to\n      \"item\".\n    */\n    PyTuple_SET_ITEM(tuple, 0, items[0]);\n    PyTuple_SET_ITEM(tuple, 1, items[1]);\n    PyTuple_SET_ITEM(tuple, 2, items[2]);\n\n    /* This isn't a leak: the 3 new references are owned by the tuple: */\n    return tuple;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SET_ITEM_macro, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33)) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=50))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=50), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 2:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 3:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 4:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 5:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 6:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 7:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 8:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:50\n\nTrace 9:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 10:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 11:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 12:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:44\n\nTrace 13:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n\nTrace 14:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:39\n\nTrace 15:\n  Transitions:\n    'when PyTuple_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/correct_multiple/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SET_ITEM_macro(PyObject *self, PyObject *args)\n{\n    PyObject *tuple;\n    /* \n       The checker must not get confused by this temporary array:\n       the borrowed refs that it stores do not persist beyond the\n       lifetime of the function:\n    */\n    PyObject *items[3];\n\n    tuple = PyTuple_New(3);\n    if (!tuple) {\n        return NULL;\n    }\n\n    /* Construct 3 new references: */\n    items[0] = PyLong_FromLong(1000);\n    if (!items[0]) {\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[1] = PyLong_FromLong(2000);\n    if (!items[1]) {\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[2] = PyLong_FromLong(3000);\n    if (!items[2]) {\n        Py_DECREF(items[1]);\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    \n    /*\n      Set each item in the tuple via the PyTuple_SET_ITEM macro.\n\n      These are stolen references, so at this point the reference counts for\n      the PyLongObjects are balanced.\n    */\n    PyTuple_SET_ITEM(tuple, 0, items[0]);\n    PyTuple_SET_ITEM(tuple, 1, items[1]);\n    PyTuple_SET_ITEM(tuple, 2, items[2]);\n\n    /*\n      Now erroneously increment the reference count on one of them:\n    */\n    Py_INCREF(items[2]);\n\n    /* This is a leak of items[2]: the 3 new references are owned by the tuple\n       but the extra incref above is a leak: */\n    return tuple;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SET_ITEM_macro, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/stderr.txt",
    "content": "In function 'handle_SET_ITEM_macro':\ncc1: warning: memory leak: ob_refcnt of PyLongObject is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: PyLongObject was allocated at:     items[2] = PyLong_FromLong(3000);\ncc1: note: was expecting final owned ob_refcnt of PyLongObject to be 1 due to object being referenced by: PyTupleObject.ob_item[2] but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:nn: note: when PyTuple_New() succeeds at:     tuple = PyTuple_New(3);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:34:nn: note: taking False path at:     if (!tuple) {\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:nn: note: reaching:     items[0] = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:nn: note: when PyLong_FromLong() succeeds at:     items[0] = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:40:nn: note: taking False path at:     if (!items[0]) {\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:nn: note: reaching:     items[1] = PyLong_FromLong(2000);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:nn: note: when PyLong_FromLong() succeeds at:     items[1] = PyLong_FromLong(2000);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:45:nn: note: taking False path at:     if (!items[1]) {\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: reaching:     items[2] = PyLong_FromLong(3000);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: when PyLong_FromLong() succeeds at:     items[2] = PyLong_FromLong(3000);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:51:nn: note: taking False path at:     if (!items[2]) {\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:64:nn: note: reaching:     PyTuple_SET_ITEM(tuple, 0, items[0]);\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:66:nn: note: PyLongObject is now referenced by 1 non-stack value(s): PyTupleObject.ob_item[2]\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:71:nn: note: ob_refcnt is now refs: 2 owned\ncc1: note: returning\ntests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:24:nn: note: graphical error report for function 'handle_SET_ITEM_macro' written out to 'tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c.handle_SET_ITEM_macro-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33)) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=50))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=50), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 2:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 3:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 4:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 5:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 6:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 7:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 8:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:50\n\nTrace 9:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 10:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 11:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 12:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:44\n\nTrace 13:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n\nTrace 14:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:39\n\nTrace 15:\n  Transitions:\n    'when PyTuple_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SET_ITEM_macro/incorrect_multiple/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SetItem(PyObject *self, PyObject *args)\n{\n    PyObject *tuple;\n    PyObject *item;\n    tuple = PyTuple_New(1);\n    if (!tuple) {\n        return NULL;\n    }\n\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    \n    /*\n      Set the item in the tuple via PyTuple_SetItem()\n\n      The checker ought to figure out that the macro has stolen the reference\n      to \"item\", and that this function is thus _not_ leaking a reference to\n      \"item\".\n    */\n    PyTuple_SetItem(tuple, 0, item);\n\n    return tuple;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SetItem, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyTuple_SetItem() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=27), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=27)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=27)) from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:27\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:32:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=32))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:27:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=27))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:27\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:32\n\nTrace 2:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:27'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:27:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=27))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:27\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:32\n\nTrace 3:\n  Transitions:\n    'when PyTuple_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SetItem(PyObject *self, PyObject *args)\n{\n    PyObject *tuple;\n    /* \n       The checker must not get confused by this temporary array:\n       the borrowed refs that it stores do not persist beyond the\n       lifetime of the function:\n    */\n    PyObject *items[3];\n\n    tuple = PyTuple_New(3);\n    if (!tuple) {\n        return NULL;\n    }\n\n    /* Construct 3 new references: */\n    items[0] = PyLong_FromLong(1000);\n    if (!items[0]) {\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[1] = PyLong_FromLong(2000);\n    if (!items[1]) {\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[2] = PyLong_FromLong(3000);\n    if (!items[2]) {\n        Py_DECREF(items[1]);\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    \n    /*\n      Set each item in the tuple via PyTuple_SetItem()\n\n      The checker ought to figure out that the macro has stolen the reference\n      to \"item\", and that this function is thus _not_ leaking a reference to\n      \"item\".\n    */\n    PyTuple_SetItem(tuple, 0, items[0]);\n    PyTuple_SetItem(tuple, 1, items[1]);\n    PyTuple_SetItem(tuple, 2, items[2]);\n\n    /* This isn't a leak: the 3 new references are owned by the tuple: */\n    return tuple;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SetItem, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyTuple_SetItem() succeeds'\n    'when PyTuple_SetItem() succeeds'\n    'when PyTuple_SetItem() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33)) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=50))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=50), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 2:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 3:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 4:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 5:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 6:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 7:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 8:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:50\n\nTrace 9:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n\nTrace 10:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n\nTrace 11:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n\nTrace 12:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:44\n\nTrace 13:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n\nTrace 14:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:39\n\nTrace 15:\n  Transitions:\n    'when PyTuple_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/correct_multiple/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nhandle_SetItem(PyObject *self, PyObject *args)\n{\n    PyObject *tuple;\n    /* \n       The checker must not get confused by this temporary array:\n       the borrowed refs that it stores do not persist beyond the\n       lifetime of the function:\n    */\n    PyObject *items[3];\n\n    tuple = PyTuple_New(3);\n    if (!tuple) {\n        return NULL;\n    }\n\n    /* Construct 3 new references: */\n    items[0] = PyLong_FromLong(1000);\n    if (!items[0]) {\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[1] = PyLong_FromLong(2000);\n    if (!items[1]) {\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    items[2] = PyLong_FromLong(3000);\n    if (!items[2]) {\n        Py_DECREF(items[1]);\n        Py_DECREF(items[0]);\n        Py_DECREF(tuple);\n        return NULL;\n    }\n    \n    /*\n      Set each item in the tuple via PyTuple_SetItem()\n\n      These are stolen references, so at this point the reference counts for\n      the PyLongObjects are balanced.\n    */\n    PyTuple_SetItem(tuple, 0, items[0]);\n    PyTuple_SetItem(tuple, 1, items[1]);\n    PyTuple_SetItem(tuple, 2, items[2]);\n\n    /*\n      Now erroneously increment the reference count on one of them:\n    */\n    Py_INCREF(items[2]);\n\n    /* This is a leak of items[2]: the 3 new references are owned by the tuple\n       but the extra incref above is a leak: */\n    return tuple;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  handle_SetItem, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/stderr.txt",
    "content": "In function 'handle_SetItem':\ncc1: warning: memory leak: ob_refcnt of PyLongObject is 1 too high [enabled by default]\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50:nn: note: PyLongObject was allocated at:     items[2] = PyLong_FromLong(3000);\ncc1: note: was expecting final owned ob_refcnt of PyLongObject to be 1 due to object being referenced by: PyTupleObject.ob_item[2] but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:nn: note: when PyTuple_New() succeeds at:     tuple = PyTuple_New(3);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:34:nn: note: taking False path at:     if (!tuple) {\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:nn: note: reaching:     items[0] = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:nn: note: when PyLong_FromLong() succeeds at:     items[0] = PyLong_FromLong(1000);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:40:nn: note: taking False path at:     if (!items[0]) {\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:nn: note: reaching:     items[1] = PyLong_FromLong(2000);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:nn: note: when PyLong_FromLong() succeeds at:     items[1] = PyLong_FromLong(2000);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:45:nn: note: taking False path at:     if (!items[1]) {\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50:nn: note: reaching:     items[2] = PyLong_FromLong(3000);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50:nn: note: when PyLong_FromLong() succeeds at:     items[2] = PyLong_FromLong(3000);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:51:nn: note: taking False path at:     if (!items[2]) {\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:64:nn: note: reaching:     PyTuple_SetItem(tuple, 0, items[0]);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:64:nn: note: when PyTuple_SetItem() succeeds at:     PyTuple_SetItem(tuple, 0, items[0]);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:65:nn: note: when PyTuple_SetItem() succeeds at:     PyTuple_SetItem(tuple, 1, items[1]);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:66:nn: note: when PyTuple_SetItem() succeeds at:     PyTuple_SetItem(tuple, 2, items[2]);\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:66:nn: note: PyLongObject is now referenced by 1 non-stack value(s): PyTupleObject.ob_item[2]\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:71:nn: note: ob_refcnt is now refs: 2 owned\ncc1: note: returning\ntests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:24:nn: note: graphical error report for function 'handle_SetItem' written out to 'tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c.handle_SetItem-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyTuple_SetItem() succeeds'\n    'when PyTuple_SetItem() succeeds'\n    'when PyTuple_SetItem() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33)) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=50))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=50), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 2:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 3:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 4:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 5:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 6:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 7:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 8:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=44))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:50\n\nTrace 9:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n\nTrace 10:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n\nTrace 11:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n\nTrace 12:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:48\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:44\n\nTrace 13:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyTuple_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n\nTrace 14:\n  Transitions:\n    'when PyTuple_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33:\n    repr(): RegionOnHeap('PyTupleObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=33))\n    str(): PyTupleObject allocated at tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:39\n\nTrace 15:\n  Transitions:\n    'when PyTuple_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_SetItem/incorrect_multiple/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect call to PyTuple_Size\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *dict;\n    dict = PyDict_New();\n\n    /*\n      This can go wrong in two ways:\n      - if the allocation failed, then we have a read through NULL\n      - it the allocation succeeded, it's a dict, not a tuple\n    */\n    PyTuple_Size(dict);\n\n    /* \"dict\" should either be NULL or have an ob_refcnt of 1 */\n    return dict;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:37:nn: warning: calling PyTuple_Size with NULL as argument 1 (dict) at tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:37 [enabled by default]\ntests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:30:nn: note: when PyDict_New() fails at:     dict = PyDict_New();\ntests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:37:nn: note: PyTuple_Size() invokes Py_TYPE() on the pointer via the PyTuple_Check() macro, thus accessing (NULL)->ob_type\ntests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:28:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'when PyTuple_Size() returns ob_size'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30)) from tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'when PyTuple_Size() fails (not a tuple)'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30)) from tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:37\n\nTrace 2:\n  Transitions:\n    'when PyDict_New() fails'\n  error: NullPtrArgument()\n  error: calling PyTuple_Size with NULL as argument 1 (dict) at tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyTuple_Size/incorrect/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Reproducer for https://fedorahosted.org/gcc-python-plugin/ticket/24\n*/\n\nPy_ssize_t\ntest(PyObject *obj)\n{\n    return PyTuple_Size(obj);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/ticket-24/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyTuple_Size/ticket-24/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyTuple_Size() returns ob_size'\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c', line=29), minvalue=-0x8000000000000000, maxvalue=0x7fffffffffffffff)\n    str(): (Py_ssize_t)val [-0x8000000000000000 <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c:29\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyTuple_Size() fails (not a tuple)'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='Py_ssize_t', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c', line=29), value=-1)\n    str(): (Py_ssize_t)-1 from tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c:29\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyTuple_Size/ticket-24/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyType_IsSubtype\n*/\n\nextern PyTypeObject some_type;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n       PyObject_TypeCheck is a macro, which can call PyType_IsSubtype if\n       the pointers aren't equal\n    */\n    return PyBool_FromLong(PyObject_TypeCheck(self, &some_type));\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyType_IsSubtype/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyType_IsSubtype/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'taking False path'\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35)) from tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c:35\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'taking False path'\n    'when considering value == (int)0 from tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c:35'\n    'taking False path'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35)) from tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c:35\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c:30\n\nTrace 2:\n  Transitions:\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'PyBool_FromLong() returns'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35), region=RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35)))\n    str(): (struct PyObject *)&RegionOnHeap('PyBool_FromLong', gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35)) from tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c:35\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=35), region=Region('PyTypeObject for PyBool_FromLong'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyType_IsSubtype/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test coverage for our handler for PyUnicode_AsUTF8String\n*/\n\nPyObject *\ntest(PyObject *unicode)\n{\n    return PyUnicode_AsUTF8String(unicode);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyUnicode_AsUTF8String() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c', line=29), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c', line=29)) from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('unicode') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('unicode')\")\n    str(): region for gcc.ParmDecl('unicode') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('unicode')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyUnicode_AsUTF8String() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c:29\n  region for gcc.ParmDecl('unicode') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('unicode')\")\n    str(): region for gcc.ParmDecl('unicode') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('unicode')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/PyUnicode_AsUTF8String/basic/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/NULL/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of handling of in  call to PyWeakref_GetObject(NULL)\n*/\n\nPyObject *\ntest(void)\n{\n    return PyWeakref_GetObject(NULL);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/NULL/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/NULL/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'PyWeakref_GetObject() fails due to NULL argument'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/NULL/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyWeakref_GetObject/NULL/input.c:29\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyWeakref_GetObject/NULL/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to PyWeakref_GetObject\n*/\n\nextern PyObject *some_ref;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *item;\n    item = PyWeakref_GetObject(some_ref);\n    if (item) {\n        /*\n          If it succeeds, it only returns a borrowed ref, so we must incref\n          it:\n        */\n        Py_INCREF(item);\n        return item;\n    }\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c:26 as non-NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=32), region=RegionOnHeap('borrowed reference returned by PyWeakref_GetObject()', gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyWeakref_GetObject()', gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=32)) from tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c:32\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=32), region=Region('PyTypeObject for borrowed reference returned by PyWeakref_GetObject()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c:26 as NULL'\n    'PyWeakref_GetObject() fails due to NULL argument'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=41), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c:41\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyWeakref_GetObject/correct/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of incorrect reference-handling in a call to PyWeakref_GetObject\n*/\n\nextern PyObject *some_ref;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *item;\n    item = PyWeakref_GetObject(some_ref);\n    if (item) {\n        /* BUG: this is only a borrowed ref; we ought to INCREF it: */\n        return item;\n    }\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:35:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:32:nn: note: return value was allocated at:     item = PyWeakref_GetObject(some_ref);\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:35:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:32:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:26 as non-NULL at:     item = PyWeakref_GetObject(some_ref);\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:32:nn: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:33:nn: note: taking True path at:     if (item) {\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:35:nn: note: reaching:         return item;\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:35:nn: note: returning\ntests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:30:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:26 as non-NULL'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=32), region=RegionOnHeap('borrowed reference returned by PyWeakref_GetObject()', gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by PyWeakref_GetObject()', gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=32)) from tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:32\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=32), region=Region('PyTypeObject for borrowed reference returned by PyWeakref_GetObject()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:30\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:26 as NULL'\n    'PyWeakref_GetObject() fails due to NULL argument'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_SystemError')) from tests/cpychecker/refcounts/PyWeakref_GetObject/incorrect/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that Py_BuildValue(\"O\") can cope with a PyObject* for which the\n  ob_refcnt is unknown.  This happens with PyTypeObject instances.\n*/\n\nPyObject *\ntest(PyObject *a)\n{\n    return Py_BuildValue(\"O\", Py_TYPE(a));\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when Py_BuildValue() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c', line=30), region=RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c', line=30)) from tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c', line=30), region=Region('PyTypeObject for new ref from call to Py_BuildValue'))\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c:29\n\nTrace 1:\n  Transitions:\n    'when Py_BuildValue() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c', line=30), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c:30\n  region for gcc.ParmDecl('a') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('a')\")\n    str(): region for gcc.ParmDecl('a') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('a')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/Py_TYPE/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling in a call to Py_BuildValue\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    return Py_BuildValue(\"(s (s s) s)\",\n                         \"foo\",\n                         \"bar\", \"baz\",\n                         \"quux\");\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when Py_BuildValue() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=29), region=RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=29)) from tests/cpychecker/refcounts/Py_BuildValue/correct/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=29), region=Region('PyTypeObject for new ref from call to Py_BuildValue'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct/input.c:28\n\nTrace 1:\n  Transitions:\n    'when Py_BuildValue() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reference-handling in a call to Py_BuildValue with \"N\" in which\n  there's a possibly-failing call\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    PyObject *tmp;\n\n    tmp = PyLong_FromLong(1024);\n    list = Py_BuildValue(\"(s N s)\",\n                         \"foo\", tmp, \"bar\");\n    if (!list) {\n        Py_XDECREF(tmp);\n    }\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when Py_BuildValue() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=34), region=RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=34)) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=34), region=Region('PyTypeObject for new ref from call to Py_BuildValue'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:33:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=33))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:33\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when Py_BuildValue() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:33:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=33))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:34\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when Py_BuildValue() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:33:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=33))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:34\n\nTrace 3:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'when Py_BuildValue() fails'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-N/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of reference-handling in a call to Py_BuildValue with \"O\" in which\n  there's a possibly-failing call\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *result;\n    PyObject *tmp;\n\n    /* This call can fail: */\n    tmp = PyLong_FromLong(1024);\n\n    /* and Py_BuildValue with a O should gracefully handle it: */\n    result = Py_BuildValue(\"(s O s)\",\n                           \"foo\", tmp, \"bar\");\n    Py_XDECREF(tmp);\n    return result;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when Py_BuildValue() succeeds'\n    'taking False path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=37), region=RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=37)) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=37), region=Region('PyTypeObject for new ref from call to Py_BuildValue'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:34:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=34))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:34\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when Py_BuildValue() fails'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:34:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=34))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:37\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'when Py_BuildValue() fails'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:34'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:34:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=34))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:37\n\nTrace 3:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'when Py_BuildValue() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:37\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-O/input.c:37\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of type-checking in a correct call to Py_BuildValue with code \"s\"\n*/\n\nPyObject *\ntest(const char *foo, char *bar)\n{\n    return Py_BuildValue(\"(s, s)\",\n                         foo, bar);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when Py_BuildValue() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c', line=29), region=RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to Py_BuildValue', gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c', line=29)) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c:29\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c', line=29), region=Region('PyTypeObject for new ref from call to Py_BuildValue'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c:28\n\nTrace 1:\n  Transitions:\n    'when Py_BuildValue() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c:29\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/Py_BuildValue/correct-code-s/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_FatalError/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of call to Py_FatalError:\n*/\n\nvoid\ntest(const char *message)\n{\n    Py_FatalError(message);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_FatalError/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_FatalError/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling Py_FatalError() and exiting'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/Py_FatalError/correct/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_Finalize/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct call to Py_Finalize:\n*/\n\nvoid\ntest(void)\n{\n    Py_Finalize();\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_Finalize/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/Py_Finalize/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling Py_Finalize()'\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/Py_Finalize/correct/input.c:28\n"
  },
  {
    "path": "tests/cpychecker/refcounts/SWIG_Python_ErrorType/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of call to SWIG_Python_ErrorType:\n*/\nextern PyObject*\nSWIG_Python_ErrorType(int code);\n\nPyObject *\ntest(int code)\n{\n    return SWIG_Python_ErrorType(code);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/SWIG_Python_ErrorType/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/SWIG_Python_ErrorType/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'SWIG_Python_ErrorType()'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/SWIG_Python_ErrorType/correct/input.c', line=31), region=RegionForGlobal(gcc.VarDecl('PyExc_TypeError')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/SWIG_Python_ErrorType/correct/input.c:31\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/SWIG_Python_ErrorType/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/SWIG_Python_SetErrorMsg/correct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of call to SWIG_Python_SetErrorMsg:\n*/\n\nvoid\ntest(PyObject *errtype, const char *msg)\n{\n    SWIG_Python_SetErrorMsg(errtype, msg);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/SWIG_Python_SetErrorMsg/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/SWIG_Python_SetErrorMsg/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling SWIG_Python_SetErrorMsg()'\n    'returning'\n  region for gcc.ParmDecl('errtype') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('errtype')\")\n    str(): region for gcc.ParmDecl('errtype') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/SWIG_Python_SetErrorMsg/correct/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('errtype')\"))\n  Exception:\n    (struct PyObject *)&RegionOnStack(\"region for gcc.ParmDecl('errtype')\") from tests/cpychecker/refcounts/SWIG_Python_SetErrorMsg/correct/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/_PyObject_New/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of a correct call to _PyObject_New\n*/\n\nstruct FooObject {\n    PyObject_HEAD\n    int x;\n    int y;\n    int z;\n};\n\nextern PyTypeObject FooType;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    struct FooObject *obj;\n\n    obj = PyObject_New(struct FooObject, &FooType);\n    if (!obj) {\n        return NULL;\n    }\n    obj->x = 0;\n    obj->y = 0;\n    obj->z = 0;\n    return (PyObject*)obj;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  test, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/_PyObject_New/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/_PyObject_New/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when _PyObject_New() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct FooObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=40), region=RegionOnHeap('_PyObject_New', gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=40)))\n    str(): (struct FooObject *)&RegionOnHeap('_PyObject_New', gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=40)) from tests/cpychecker/refcounts/_PyObject_New/correct/input.c:40\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=40), region=RegionForGlobal(gcc.VarDecl('FooType')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/_PyObject_New/correct/input.c:37\n\nTrace 1:\n  Transitions:\n    'when _PyObject_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/_PyObject_New/correct/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/_PyObject_New/correct/input.c', line=36), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/_PyObject_New/correct/input.c:40\n"
  },
  {
    "path": "tests/cpychecker/refcounts/__builtin_expect/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Reproducer for false-positive read-through-NULL warnings reported for\n  Cython-generated code (lxml)\n\n  For modern GCCs, Cython defines likely() and unlikely() macros in terms\n  of __builtin_expect().  This was confusing our checker, which regarded it\n  as an unknown function, and thus regarded the return value as unknown.\n\n  Specifically, within the code generated for a call to:\n     python.PyErr_NoMemory()\n  within:\n     lxml-2.3/src/lxml/apihelpers.pxi\n  the generated C code contained:\n\n    __pyx_t_5 = PyErr_NoMemory(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}\n    __Pyx_GOTREF(__pyx_t_5);\n\n  and the checker was erroneously considering both possible outcomes of:\n\n     if (unlikely(!__pyx_t_5)) ...\n\n  despite knowing that __pyx_t_5 is NULL (due to the semantics of\n  PyErr_NoMemory), thus erroneously reporting:\n\n    dereferencing NULL (__pyx_t_5->ob_refcnt) at src/lxml/lxml.etree.c:19587\n\n  for the unreachable next line:  __Pyx_GOTREF(__pyx_t_5);\n*/\n\n#define unlikely(x) __builtin_expect(!!(x), 0)\n\nvoid\ntest(void)\n{\n    PyObject *obj = PyErr_NoMemory();\n\n    /*\n       The checker should know that the result of unlikely() is equal to that\n       the conditional, rather than an UnknownValue\n    */\n    if (unlikely(!obj)) {\n        return;\n    }\n\n    /* if obj == NULL, we shouldn't get here: */\n    Py_DECREF(obj);\n    return;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/__builtin_expect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/__builtin_expect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'PyErr_NoMemory() returns NULL, raising MemoryError'\n    'taking True path'\n    'returning'\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/__builtin_expect/input.c:56\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been (correctly) marked as returning\n  a borrowed reference\n*/\n\n#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)\n  #define CPYCHECKER_RETURNS_BORROWED_REF() \\\n     __attribute__((cpychecker_returns_borrowed_ref))\n#else\n  #define CPYCHECKER_RETURNS_BORROWED_REF()\n  #error (This should have been defined)\n#endif\n\nextern PyObject *test(PyObject *self, PyObject *args)\n  CPYCHECKER_RETURNS_BORROWED_REF();\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n      This code returns a borrowed reference:\n    */\n    return self;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/input.c', line=39), region=RegionOnStack(\"region for gcc.ParmDecl('self')\"))\n    str(): (struct PyObject *)&RegionOnStack(\"region for gcc.ParmDecl('self')\") from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/input.c:39\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-marking/input.c:40\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correctly calling a function that's been marked as returning a\n  borrowed reference\n*/\n\n#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)\n  #define CPYCHECKER_RETURNS_BORROWED_REF() \\\n     __attribute__((cpychecker_returns_borrowed_ref))\n#else\n  #define CPYCHECKER_RETURNS_BORROWED_REF()\n  #error (This should have been defined)\n#endif\n\nextern PyObject *foo(void)\n  CPYCHECKER_RETURNS_BORROWED_REF();\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *obj = foo(); /* we now have a borrowed ref, or NULL */\n    Py_XINCREF(obj); /* we now have a new ref, or NULL */\n\n    return obj;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when foo() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=41), region=RegionOnHeap('borrowed reference returned by foo()', gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=41)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by foo()', gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=41)) from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c:41\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=41), region=Region('PyTypeObject for borrowed reference returned by foo()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c:40\n\nTrace 1:\n  Transitions:\n    'when foo() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=41), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c:41\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/correct-usage/input.c:41\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been incorrectly marked as returning\n  a borrowed reference, when it in fact returns a new reference\n*/\n\n#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)\n  #define CPYCHECKER_RETURNS_BORROWED_REF() \\\n     __attribute__((cpychecker_returns_borrowed_ref))\n#else\n  #define CPYCHECKER_RETURNS_BORROWED_REF()\n  #error (This should have been defined)\n#endif\n\nextern PyObject *test(PyObject *self, PyObject *args)\n  CPYCHECKER_RETURNS_BORROWED_REF();\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n      This code returns a new reference, but the function has been marked\n      as returning a borrowed reference:\n    */\n    return PyLong_FromLong(42);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45:nn: warning: memory leak: ob_refcnt of return value is 1 too high [enabled by default]\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45:nn: note: return value was allocated at:     return PyLong_FromLong(42);\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45:nn: note: was expecting final owned ob_refcnt of return value to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45:nn: note: when PyLong_FromLong() succeeds at:     return PyLong_FromLong(42);\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45:nn: note: returning at:     return PyLong_FromLong(42);\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:40:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=45), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=45)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=45)) from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:40\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-marking/input.c:45\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of calling a function that's been marked as returning a borrowed\n  reference, but incorrectly treating it as returning a new ref\n*/\n\n#if defined(WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE)\n  #define CPYCHECKER_RETURNS_BORROWED_REF() \\\n     __attribute__((cpychecker_returns_borrowed_ref))\n#else\n  #define CPYCHECKER_RETURNS_BORROWED_REF()\n  #error (This should have been defined)\n#endif\n\nextern PyObject *foo(void)\n  CPYCHECKER_RETURNS_BORROWED_REF();\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n      This code is incorrect: foo() returns a borrowed ref (or NULL), so the\n      returned refcount will be one too low:\n    */\n    PyObject *obj = foo();\n    return obj;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:46:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:45:nn: note: return value was allocated at:     PyObject *obj = foo();\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:46:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:45:nn: note: when foo() succeeds at:     PyObject *obj = foo();\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:45:nn: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:46:nn: note: returning at:     return obj;\ntests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:40:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when foo() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=45), region=RegionOnHeap('borrowed reference returned by foo()', gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=45)))\n    str(): (struct PyObject *)&RegionOnHeap('borrowed reference returned by foo()', gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=45)) from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:45\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=45), region=Region('PyTypeObject for borrowed reference returned by foo()'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:40\n\nTrace 1:\n  Transitions:\n    'when foo() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/attributes/returns-borrowed-ref/incorrect-usage/input.c:45\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/correct-marking/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been (correctly) marked as setting\n  an exception\n*/\n\n#if defined(WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE)\n  #define CPYCHECKER_SETS_EXCEPTION \\\n     __attribute__((cpychecker_sets_exception))\n#else\n  #define CPYCHECKER_SETS_EXCEPTION\n  #error (This should have been defined)\n#endif\n\nextern void test(const char *msg)\n  CPYCHECKER_SETS_EXCEPTION;\n\nextern void test(const char *msg)\n{\n    PyErr_SetString(PyExc_RuntimeError, msg);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/correct-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/correct-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'calling PyErr_SetString()'\n    'returning'\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that (correctly) uses a function that's been\n  marked as setting an exception\n*/\n\n#if defined(WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE)\n  #define CPYCHECKER_SETS_EXCEPTION \\\n     __attribute__((cpychecker_sets_exception))\n#else\n  #define CPYCHECKER_SETS_EXCEPTION\n  #error (This should have been defined)\n#endif\n\nextern int foo(void)\n  CPYCHECKER_SETS_EXCEPTION;\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    foo();\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/attributes/sets-exception/correct-usage/input.c:41\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been (incorrectly) marked as setting\n  an exception\n*/\n\n#if defined(WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE)\n  #define CPYCHECKER_SETS_EXCEPTION \\\n     __attribute__((cpychecker_sets_exception))\n#else\n  #define CPYCHECKER_SETS_EXCEPTION\n  #error (This should have been defined)\n#endif\n\nextern int test(void)\n  CPYCHECKER_SETS_EXCEPTION;\n\nextern int test(void)\n{\n    /* \n       Erroneously, doesn't set an exception on this path,\n       despite having been marked as such:\n    */\n    return 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c:44:nn: warning: function is marked with __attribute__((cpychecker_sets_exception)) but can return without setting an exception [enabled by default]\ntests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c:44:nn: note: returning at:     return 0;\ntests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c:39:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c', line=44), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c:44\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception/incorrect-marking/input.c:39\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been (correctly) marked as setting\n  an exception on a negative return value\n*/\n\n#if defined(WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE)\n  #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION() \\\n     __attribute__((cpychecker_negative_result_sets_exception))\n#else\n  #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION()\n  #error (This should have been defined)\n#endif\n\nextern int test(int i)\n  CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION();\n\nextern int test(int i)\n{\n    if (i == 42) {\n        return 0; /* success */\n    } else {\n        PyErr_SetString(PyExc_RuntimeError, \"an error occurred\");\n        return -1; /* failure */\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= 41'\n    'taking False path'\n    'calling PyErr_SetString()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c', line=44), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c:44\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n\nTrace 1:\n  Transitions:\n    'when considering value == (int)42 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c:38'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c', line=41), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c:41\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c:39\n\nTrace 2:\n  Transitions:\n    'when considering range: 43 <= value <= 0x7fffffff'\n    'taking False path'\n    'calling PyErr_SetString()'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c', line=44), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-marking/input.c:44\n  Exception:\n    unknown struct PyObject * from /usr/include/python?.?/pyerrors.h:nn\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that (correctly) uses a function that's been\n  marked as setting an exception when it returns a negative value.\n*/\n\n#if defined(WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE)\n  #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION() \\\n     __attribute__((cpychecker_negative_result_sets_exception))\n#else\n  #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION()\n  #error (This should have been defined)\n#endif\n\nextern int foo(void)\n  CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION();\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    int i;\n\n    i = foo();\n    if (i < 0) {\n        /*\n          This shouldn't lead to a \"returning NULL w/o setting exception\"\n          error, given that foo() has been marked as setting an exception\n          on negative:\n        */\n        return NULL;\n    }\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c', line=50), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c:50\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c:43\n\nTrace 1:\n  Transitions:\n    'when considering range: 0 <= value <= 0x7fffffff'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c', line=52), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c:52\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/correct-usage/input.c:40\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been (correctly) marked as setting\n  an exception on a negative return value\n*/\n\n#if defined(WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE)\n  #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION() \\\n     __attribute__((cpychecker_negative_result_sets_exception))\n#else\n  #define CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION()\n  #error (This should have been defined)\n#endif\n\nextern int test(int i)\n  CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION();\n\nextern int test(int i)\n{\n    if (i == 42) {\n        return 0; /* success */\n    } else {\n        /* \n           Erroneously, doesn't set an exception on this path,\n           despite having been marked as such:\n        */\n        return -1; /* failure */\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:47:nn: warning: function is marked with __attribute__((cpychecker_negative_result_sets_exception)) but can return -1 without setting an exception [enabled by default]\ntests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:40:nn: note: when considering range: -0x80000000 <= value <= 41 at:     if (i == 42) {\ntests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:40:nn: note: taking False path at:     if (i == 42) {\ntests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:47:nn: note: reaching:         return -1; /* failure */\ntests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:47:nn: note: returning\ntests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:47:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:39:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= 41'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c', line=47), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:47\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:39\n\nTrace 1:\n  Transitions:\n    'when considering value == (int)42 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:38'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c', line=41), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:41\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:39\n\nTrace 2:\n  Transitions:\n    'when considering range: 43 <= value <= 0x7fffffff'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c', line=47), value=-1)\n    str(): (int)-1 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:47\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/sets-exception-on-nonzero-return/incorrect-marking/input.c:39\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been (correctly) marked as stealing\n  a reference\n*/\n\n#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \\\n    __attribute__((cpychecker_steals_reference_to_arg(n)))\n#else\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)\n  #error (This should have been defined)\n#endif\n\nextern PyObject *test(PyObject *foo, PyObject *bar)\n  CPYCHECKER_STEALS_REFERENCE_TO_ARG(1)\n  CPYCHECKER_STEALS_REFERENCE_TO_ARG(2);\n\nPyObject *saved_objA;\nPyObject *saved_objB;\n\nPyObject *\ntest(PyObject *foo, PyObject *bar)\n{\n    /*\n      This code steals references to both of its arguments\n    */\n    saved_objA = foo;\n    saved_objB = bar;\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/input.c', line=51), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/input.c:51\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('foo') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('foo')\")\n    str(): region for gcc.ParmDecl('foo') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/input.c', line=43), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('foo')\"))\n  region for gcc.ParmDecl('bar') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('bar')\")\n    str(): region for gcc.ParmDecl('bar') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/input.c', line=43), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('bar')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-marking/input.c:44\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correctly calling a function that's been marked as stealing a\n  reference to its arguments\n*/\n\n#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \\\n    __attribute__((cpychecker_steals_reference_to_arg(n)))\n#else\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)\n  #error (This should have been defined)\n#endif\n\nextern void foo(PyObject *obj)\n  CPYCHECKER_STEALS_REFERENCE_TO_ARG(1);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *obj;\n\n    obj = PyLong_FromLong(42);\n    if (!obj) {\n        return NULL;\n    }\n\n    /*\n      We now own a reference to \"obj\"\n\n      Pass it to foo(), which steals it.\n\n      Given that foo has been marked with\n        __attribute__((cpychecker_steals_reference_to_arg(1)))\n      the checker should not complain.\n     */\n    foo(obj);\n    \n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=59), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c:59\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c:43:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=43))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c:43\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=43), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c:40\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c', line=39), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/correct-usage/input.c:43\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of compiling a function that's been incorrectly marked as stealing\n  a reference, when it does not.\n*/\n\n#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \\\n    __attribute__((cpychecker_steals_reference_to_arg(n)))\n#else\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)\n  #error (This should have been defined)\n#endif\n\nextern PyObject *test(PyObject *foo, PyObject *bar)\n  CPYCHECKER_STEALS_REFERENCE_TO_ARG(1)\n  CPYCHECKER_STEALS_REFERENCE_TO_ARG(2);\n\nPyObject *\ntest(PyObject *foo, PyObject *bar)\n{\n    /*\n      This code doesn't steals references to its arguments; the marking is\n      incorrect, and this should be flagged by the checker.\n    */\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:46:nn: warning: memory leak: ob_refcnt of '*foo' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:46:nn: note: was expecting final owned ob_refcnt of '*foo' to be -1 since nothing references it but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:46:nn: note: returning at:     Py_RETURN_NONE;\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:46:nn: warning: memory leak: ob_refcnt of '*bar' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:46:nn: note: was expecting final owned ob_refcnt of '*bar' to be -1 since nothing references it but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:46:nn: note: returning at:     Py_RETURN_NONE;\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:41:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c', line=46), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:46\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('foo') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('foo')\")\n    str(): region for gcc.ParmDecl('foo') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c', line=40), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('foo')\"))\n  region for gcc.ParmDecl('bar') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('bar')\")\n    str(): region for gcc.ParmDecl('bar') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c', line=40), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('bar')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-marking/input.c:41\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of calling a function that's been marked as stealing a\n  reference to its arguments, but incorrectly treating the argument as\n  still being owned by us.\n*/\n\n#if defined(WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE)\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n) \\\n    __attribute__((cpychecker_steals_reference_to_arg(n)))\n#else\n  #define CPYCHECKER_STEALS_REFERENCE_TO_ARG(n)\n  #error (This should have been defined)\n#endif\n\nextern void foo(PyObject *obj)\n  CPYCHECKER_STEALS_REFERENCE_TO_ARG(1);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *obj;\n\n    obj = PyLong_FromLong(42);\n    if (!obj) {\n        return NULL;\n    }\n\n    /*\n      We now own a reference to \"obj\"\n\n      Pass it to foo(), which steals it.\n\n     */\n    foo(obj);\n\n    /*\n      Given that foo has been marked with\n        __attribute__((cpychecker_steals_reference_to_arg(1)))\n      this is an error: we no longer own the reference to \"obj\"\n      that's expected of us when returning a non-NULL PyObject*:\n    */\n    return obj;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:63:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:44:nn: note: return value was allocated at:     obj = PyLong_FromLong(42);\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:63:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:44:nn: note: when PyLong_FromLong() succeeds at:     obj = PyLong_FromLong(42);\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:44:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:45:nn: note: taking False path at:     if (!obj) {\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:55:nn: note: reaching:     foo(obj);\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:55:nn: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:63:nn: note: returning\ntests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:41:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=44), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=44)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=44)) from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:44\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=44), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=40), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=40), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:41\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=46), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:46\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=40), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c', line=40), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/attributes/steals-reference-to-arg/incorrect-usage/input.c:44\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the refcount checker can cope with a combinatorial explosion\n\n  Each function call below can have two possible outcomes on the refcount\n  of the object.\n*/\n\nPyObject *\ntest_adding_module_objects(PyObject *m)\n{\n    PyObject *item = PyLong_FromLong(4096);\n    if (!item) {\n        return NULL;\n    }\n\n    /*\n      Each of these function calls steals a reference to the object if it\n      succeeds, but can fail.\n\n      Hence the expected reference count can change at each function call, so\n      that (in theory) there are 2^N possible outcomes.\n\n      The point of the test is to verify that the checker doesn't take O(2^N)\n      time for such a case.\n    */\n\n    if (0 == PyModule_AddObject(m, \"item_001\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_002\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_003\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_004\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_005\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_006\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_007\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_008\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_009\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_010\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_011\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_012\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_013\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_014\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_015\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_016\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_017\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_018\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_019\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_020\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_021\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_022\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_023\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_024\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_025\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_026\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_027\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_028\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_029\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_030\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_031\", item)) {\n        Py_INCREF(item);\n    }\n\n    if (0 == PyModule_AddObject(m, \"item_032\", item)) {\n        Py_INCREF(item);\n    }\n\n    return item;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion/metadata.ini",
    "content": "[ExpectedBehavior]\n# This test case should succeed, whilst emitting a note on stderr;\n# don't treat the stderr output as leading to an expected failure:\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion/stderr.txt",
    "content": "tests/cpychecker/refcounts/combinatorial-explosion/input.c: In function 'test_adding_module_objects':\ntests/cpychecker/refcounts/combinatorial-explosion/input.c:31:1: note: this function is too complicated for the reference-count checker to fully analyze: not all paths were analyzed\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:160\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:172\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:168\n\nTrace 3:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 29\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:172\n\nTrace 4:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 32\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/combinatorial-explosion/input.c:31\n\nTrace 5:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:172\n\nTrace 6:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:168\n\nTrace 7:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:172\n\nTrace 8:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:164\n\nTrace 9:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:172\n\nTrace 10:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:168\n\nTrace 11:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() succeeds'\n    'taking True path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'when PyModule_AddObject() fails'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32)) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:32\n    r->ob_refcnt: refs: 1 + N where N >= 29\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion/input.c:172\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the refcount checker can detect some errors even in the face\n  of a cope with a combinatorial explosion: specifically, it should at\n  least be able to check reference counts on the \"success\" paths.\n\n  Each function call below can have two possible outcomes on the refcount\n  of the object.\n*/\n\nPyObject *\ntest_adding_module_objects(PyObject *m)\n{\n    PyObject *item = PyLong_FromLong(4096);\n    PyObject *leaky;\n    if (!item) {\n        return NULL;\n    }\n\n    /*\n      BUG: deliberately leak a reference to this object, in the \"success\" path\n\n      The reference-count checker ought to warn us about this leak\n     */\n    leaky = PyDict_New();\n\n    /*\n      Each of these function calls steals a reference to the object if it\n      succeeds, but can fail.\n\n      Hence the expected ereference count can change at each function call, so\n      that (in theory) there are 2^N possible outcomes.\n\n      The point of the test is to verify that the checker doesn't take O(2^N)\n      time for such a case.\n    */\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_001\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_002\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_003\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_004\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_005\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_006\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_007\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_008\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_009\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_010\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_011\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_012\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_013\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_014\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_015\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_016\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_017\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_018\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_019\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_020\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_021\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_022\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_023\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_024\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_025\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_026\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_027\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_028\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_029\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_030\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_031\", item);\n\n    Py_INCREF(item);\n    PyModule_AddObject(m, \"item_032\", item);\n\n    return item;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion-with-error/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion-with-error/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion-with-error/stderr.txt",
    "content": "tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c: In function 'test_adding_module_objects':\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:33:1: note: this function is too complicated for the reference-count checker to fully analyze: not all paths were analyzed\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: warning: ob_refcnt of return value is 1 too high [enabled by default]\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: was expecting final ob_refcnt to be N + 1 (for some unknown N)\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: due to object being referenced by: return value\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: but final ob_refcnt is N + 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: PyLongObject allocated at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: when PyLong_FromLong() succeeds at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: ob_refcnt is now refs: 1 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:36:8: note: taking False path at:     if (!item) {\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: reaching:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: when PyDict_New() succeeds at:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:58:5: note: ob_refcnt is now refs: 2 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_001\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: ob_refcnt is now refs: 1 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:61:5: note: ob_refcnt is now refs: 2 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_002\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: ob_refcnt is now refs: 1 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:64:5: note: ob_refcnt is now refs: 2 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_003\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: ob_refcnt is now refs: 1 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:67:5: note: ob_refcnt is now refs: 2 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_004\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: ob_refcnt is now refs: 1 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:70:5: note: ob_refcnt is now refs: 2 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_005\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: ob_refcnt is now refs: 1 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:73:5: note: ob_refcnt is now refs: 2 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_006\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: ob_refcnt is now refs: 1 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:76:5: note: ob_refcnt is now refs: 2 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_007\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: ob_refcnt is now refs: 1 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:79:5: note: ob_refcnt is now refs: 2 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_008\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: ob_refcnt is now refs: 1 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:82:5: note: ob_refcnt is now refs: 2 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_009\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: ob_refcnt is now refs: 1 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:85:5: note: ob_refcnt is now refs: 2 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_010\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: ob_refcnt is now refs: 1 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:88:5: note: ob_refcnt is now refs: 2 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_011\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: ob_refcnt is now refs: 1 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:91:5: note: ob_refcnt is now refs: 2 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_012\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: ob_refcnt is now refs: 1 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:94:5: note: ob_refcnt is now refs: 2 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_013\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: ob_refcnt is now refs: 1 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:97:5: note: ob_refcnt is now refs: 2 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_014\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: ob_refcnt is now refs: 1 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:100:5: note: ob_refcnt is now refs: 2 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_015\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: ob_refcnt is now refs: 1 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:103:5: note: ob_refcnt is now refs: 2 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_016\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: ob_refcnt is now refs: 1 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:106:5: note: ob_refcnt is now refs: 2 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_017\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: ob_refcnt is now refs: 1 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:109:5: note: ob_refcnt is now refs: 2 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_018\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: ob_refcnt is now refs: 1 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:112:5: note: ob_refcnt is now refs: 2 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_019\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: ob_refcnt is now refs: 1 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:115:5: note: ob_refcnt is now refs: 2 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_020\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: ob_refcnt is now refs: 1 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:118:5: note: ob_refcnt is now refs: 2 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_021\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: ob_refcnt is now refs: 1 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:121:5: note: ob_refcnt is now refs: 2 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_022\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: ob_refcnt is now refs: 1 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:124:5: note: ob_refcnt is now refs: 2 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_023\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: ob_refcnt is now refs: 1 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:127:5: note: ob_refcnt is now refs: 2 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_024\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: ob_refcnt is now refs: 1 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:130:5: note: ob_refcnt is now refs: 2 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_025\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: ob_refcnt is now refs: 1 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:133:5: note: ob_refcnt is now refs: 2 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_026\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: ob_refcnt is now refs: 1 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:136:5: note: ob_refcnt is now refs: 2 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_027\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: ob_refcnt is now refs: 1 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:139:5: note: ob_refcnt is now refs: 2 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:140:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_028\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:142:5: note: ob_refcnt is now refs: 3 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_029\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: ob_refcnt is now refs: 2 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:145:5: note: ob_refcnt is now refs: 3 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_030\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: ob_refcnt is now refs: 2 + N where N >= 29\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:148:5: note: ob_refcnt is now refs: 3 + N where N >= 29\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_031\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149:23: note: ob_refcnt is now refs: 2 + N where N >= 30\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:151:5: note: ob_refcnt is now refs: 3 + N where N >= 30\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_032\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152:23: note: ob_refcnt is now refs: 2 + N where N >= 31\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: returning\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: found 4 similar trace(s) to this\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: warning: ob_refcnt of '*leaky' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: was expecting final ob_refcnt to be N + 0 (for some unknown N)\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: but final ob_refcnt is N + 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: PyDictObject allocated at:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: when PyLong_FromLong() succeeds at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:36:8: note: taking False path at:     if (!item) {\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: reaching:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: when PyDict_New() succeeds at:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: ob_refcnt is now refs: 1 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_001\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_002\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_003\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_004\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_005\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_006\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_007\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_008\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_009\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_010\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_011\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_012\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_013\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_014\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_015\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_016\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_017\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_018\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_019\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_020\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_021\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_022\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_023\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_024\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_025\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_026\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_027\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:140:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_028\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_029\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_030\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_031\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_032\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: returning\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: found 19 similar trace(s) to this\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: warning: ob_refcnt of return value is 2 too high [enabled by default]\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: was expecting final ob_refcnt to be N + 1 (for some unknown N)\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: due to object being referenced by: return value\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: but final ob_refcnt is N + 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: PyLongObject allocated at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: when PyLong_FromLong() succeeds at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: ob_refcnt is now refs: 1 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:36:8: note: taking False path at:     if (!item) {\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: reaching:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: when PyDict_New() succeeds at:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:58:5: note: ob_refcnt is now refs: 2 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_001\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: ob_refcnt is now refs: 1 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:61:5: note: ob_refcnt is now refs: 2 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_002\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: ob_refcnt is now refs: 1 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:64:5: note: ob_refcnt is now refs: 2 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_003\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: ob_refcnt is now refs: 1 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:67:5: note: ob_refcnt is now refs: 2 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_004\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: ob_refcnt is now refs: 1 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:70:5: note: ob_refcnt is now refs: 2 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_005\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: ob_refcnt is now refs: 1 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:73:5: note: ob_refcnt is now refs: 2 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_006\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: ob_refcnt is now refs: 1 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:76:5: note: ob_refcnt is now refs: 2 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_007\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: ob_refcnt is now refs: 1 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:79:5: note: ob_refcnt is now refs: 2 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_008\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: ob_refcnt is now refs: 1 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:82:5: note: ob_refcnt is now refs: 2 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_009\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: ob_refcnt is now refs: 1 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:85:5: note: ob_refcnt is now refs: 2 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_010\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: ob_refcnt is now refs: 1 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:88:5: note: ob_refcnt is now refs: 2 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_011\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: ob_refcnt is now refs: 1 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:91:5: note: ob_refcnt is now refs: 2 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_012\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: ob_refcnt is now refs: 1 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:94:5: note: ob_refcnt is now refs: 2 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_013\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: ob_refcnt is now refs: 1 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:97:5: note: ob_refcnt is now refs: 2 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_014\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: ob_refcnt is now refs: 1 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:100:5: note: ob_refcnt is now refs: 2 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_015\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: ob_refcnt is now refs: 1 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:103:5: note: ob_refcnt is now refs: 2 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_016\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: ob_refcnt is now refs: 1 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:106:5: note: ob_refcnt is now refs: 2 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_017\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: ob_refcnt is now refs: 1 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:109:5: note: ob_refcnt is now refs: 2 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_018\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: ob_refcnt is now refs: 1 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:112:5: note: ob_refcnt is now refs: 2 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_019\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: ob_refcnt is now refs: 1 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:115:5: note: ob_refcnt is now refs: 2 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_020\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: ob_refcnt is now refs: 1 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:118:5: note: ob_refcnt is now refs: 2 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_021\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: ob_refcnt is now refs: 1 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:121:5: note: ob_refcnt is now refs: 2 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_022\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: ob_refcnt is now refs: 1 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:124:5: note: ob_refcnt is now refs: 2 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_023\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: ob_refcnt is now refs: 1 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:127:5: note: ob_refcnt is now refs: 2 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_024\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: ob_refcnt is now refs: 1 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:130:5: note: ob_refcnt is now refs: 2 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_025\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: ob_refcnt is now refs: 1 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:133:5: note: ob_refcnt is now refs: 2 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_026\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: ob_refcnt is now refs: 1 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:136:5: note: ob_refcnt is now refs: 2 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_027\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: ob_refcnt is now refs: 1 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:139:5: note: ob_refcnt is now refs: 2 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:140:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_028\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:142:5: note: ob_refcnt is now refs: 3 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_029\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: ob_refcnt is now refs: 2 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:145:5: note: ob_refcnt is now refs: 3 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_030\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: ob_refcnt is now refs: 2 + N where N >= 29\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:148:5: note: ob_refcnt is now refs: 3 + N where N >= 29\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_031\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149:23: note: ob_refcnt is now refs: 2 + N where N >= 30\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:151:5: note: ob_refcnt is now refs: 3 + N where N >= 30\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_032\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: returning\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: found 7 similar trace(s) to this\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: warning: ob_refcnt of return value is 3 too high [enabled by default]\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: was expecting final ob_refcnt to be N + 1 (for some unknown N)\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: due to object being referenced by: return value\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: but final ob_refcnt is N + 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: PyLongObject allocated at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: when PyLong_FromLong() succeeds at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: ob_refcnt is now refs: 1 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:36:8: note: taking False path at:     if (!item) {\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: reaching:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: when PyDict_New() succeeds at:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:58:5: note: ob_refcnt is now refs: 2 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_001\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: ob_refcnt is now refs: 1 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:61:5: note: ob_refcnt is now refs: 2 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_002\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: ob_refcnt is now refs: 1 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:64:5: note: ob_refcnt is now refs: 2 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_003\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: ob_refcnt is now refs: 1 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:67:5: note: ob_refcnt is now refs: 2 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_004\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: ob_refcnt is now refs: 1 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:70:5: note: ob_refcnt is now refs: 2 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_005\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: ob_refcnt is now refs: 1 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:73:5: note: ob_refcnt is now refs: 2 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_006\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: ob_refcnt is now refs: 1 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:76:5: note: ob_refcnt is now refs: 2 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_007\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: ob_refcnt is now refs: 1 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:79:5: note: ob_refcnt is now refs: 2 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_008\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: ob_refcnt is now refs: 1 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:82:5: note: ob_refcnt is now refs: 2 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_009\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: ob_refcnt is now refs: 1 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:85:5: note: ob_refcnt is now refs: 2 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_010\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: ob_refcnt is now refs: 1 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:88:5: note: ob_refcnt is now refs: 2 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_011\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: ob_refcnt is now refs: 1 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:91:5: note: ob_refcnt is now refs: 2 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_012\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: ob_refcnt is now refs: 1 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:94:5: note: ob_refcnt is now refs: 2 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_013\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: ob_refcnt is now refs: 1 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:97:5: note: ob_refcnt is now refs: 2 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_014\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: ob_refcnt is now refs: 1 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:100:5: note: ob_refcnt is now refs: 2 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_015\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: ob_refcnt is now refs: 1 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:103:5: note: ob_refcnt is now refs: 2 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_016\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: ob_refcnt is now refs: 1 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:106:5: note: ob_refcnt is now refs: 2 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_017\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: ob_refcnt is now refs: 1 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:109:5: note: ob_refcnt is now refs: 2 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_018\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: ob_refcnt is now refs: 1 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:112:5: note: ob_refcnt is now refs: 2 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_019\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: ob_refcnt is now refs: 1 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:115:5: note: ob_refcnt is now refs: 2 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_020\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: ob_refcnt is now refs: 1 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:118:5: note: ob_refcnt is now refs: 2 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_021\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: ob_refcnt is now refs: 1 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:121:5: note: ob_refcnt is now refs: 2 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_022\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: ob_refcnt is now refs: 1 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:124:5: note: ob_refcnt is now refs: 2 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_023\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: ob_refcnt is now refs: 1 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:127:5: note: ob_refcnt is now refs: 2 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_024\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: ob_refcnt is now refs: 1 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:130:5: note: ob_refcnt is now refs: 2 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_025\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: ob_refcnt is now refs: 1 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:133:5: note: ob_refcnt is now refs: 2 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_026\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: ob_refcnt is now refs: 1 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:136:5: note: ob_refcnt is now refs: 2 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_027\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: ob_refcnt is now refs: 1 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:139:5: note: ob_refcnt is now refs: 2 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:140:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_028\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:142:5: note: ob_refcnt is now refs: 3 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_029\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: ob_refcnt is now refs: 2 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:145:5: note: ob_refcnt is now refs: 3 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_030\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: ob_refcnt is now refs: 2 + N where N >= 29\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:148:5: note: ob_refcnt is now refs: 3 + N where N >= 29\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_031\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:151:5: note: ob_refcnt is now refs: 4 + N where N >= 29\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_032\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: returning\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: found 4 similar trace(s) to this\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: warning: ob_refcnt of return value is 4 too high [enabled by default]\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: was expecting final ob_refcnt to be N + 1 (for some unknown N)\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: due to object being referenced by: return value\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: but final ob_refcnt is N + 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: PyLongObject allocated at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: when PyLong_FromLong() succeeds at:     PyObject *item = PyLong_FromLong(4096);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34:15: note: ob_refcnt is now refs: 1 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:36:8: note: taking False path at:     if (!item) {\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: reaching:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:11: note: when PyDict_New() succeeds at:     leaky = PyDict_New();\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:58:5: note: ob_refcnt is now refs: 2 + N where N >= 0\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_001\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:59:23: note: ob_refcnt is now refs: 1 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:61:5: note: ob_refcnt is now refs: 2 + N where N >= 1\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_002\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:62:23: note: ob_refcnt is now refs: 1 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:64:5: note: ob_refcnt is now refs: 2 + N where N >= 2\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_003\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:65:23: note: ob_refcnt is now refs: 1 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:67:5: note: ob_refcnt is now refs: 2 + N where N >= 3\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_004\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:68:23: note: ob_refcnt is now refs: 1 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:70:5: note: ob_refcnt is now refs: 2 + N where N >= 4\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_005\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:71:23: note: ob_refcnt is now refs: 1 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:73:5: note: ob_refcnt is now refs: 2 + N where N >= 5\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_006\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:74:23: note: ob_refcnt is now refs: 1 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:76:5: note: ob_refcnt is now refs: 2 + N where N >= 6\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_007\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:77:23: note: ob_refcnt is now refs: 1 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:79:5: note: ob_refcnt is now refs: 2 + N where N >= 7\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_008\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:80:23: note: ob_refcnt is now refs: 1 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:82:5: note: ob_refcnt is now refs: 2 + N where N >= 8\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_009\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:83:23: note: ob_refcnt is now refs: 1 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:85:5: note: ob_refcnt is now refs: 2 + N where N >= 9\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_010\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:86:23: note: ob_refcnt is now refs: 1 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:88:5: note: ob_refcnt is now refs: 2 + N where N >= 10\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_011\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:89:23: note: ob_refcnt is now refs: 1 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:91:5: note: ob_refcnt is now refs: 2 + N where N >= 11\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_012\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:92:23: note: ob_refcnt is now refs: 1 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:94:5: note: ob_refcnt is now refs: 2 + N where N >= 12\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_013\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:95:23: note: ob_refcnt is now refs: 1 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:97:5: note: ob_refcnt is now refs: 2 + N where N >= 13\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_014\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:98:23: note: ob_refcnt is now refs: 1 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:100:5: note: ob_refcnt is now refs: 2 + N where N >= 14\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_015\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:101:23: note: ob_refcnt is now refs: 1 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:103:5: note: ob_refcnt is now refs: 2 + N where N >= 15\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_016\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:104:23: note: ob_refcnt is now refs: 1 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:106:5: note: ob_refcnt is now refs: 2 + N where N >= 16\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_017\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:107:23: note: ob_refcnt is now refs: 1 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:109:5: note: ob_refcnt is now refs: 2 + N where N >= 17\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_018\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:110:23: note: ob_refcnt is now refs: 1 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:112:5: note: ob_refcnt is now refs: 2 + N where N >= 18\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_019\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:113:23: note: ob_refcnt is now refs: 1 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:115:5: note: ob_refcnt is now refs: 2 + N where N >= 19\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_020\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:116:23: note: ob_refcnt is now refs: 1 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:118:5: note: ob_refcnt is now refs: 2 + N where N >= 20\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_021\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:119:23: note: ob_refcnt is now refs: 1 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:121:5: note: ob_refcnt is now refs: 2 + N where N >= 21\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_022\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:122:23: note: ob_refcnt is now refs: 1 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:124:5: note: ob_refcnt is now refs: 2 + N where N >= 22\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_023\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:125:23: note: ob_refcnt is now refs: 1 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:127:5: note: ob_refcnt is now refs: 2 + N where N >= 23\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_024\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:128:23: note: ob_refcnt is now refs: 1 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:130:5: note: ob_refcnt is now refs: 2 + N where N >= 24\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_025\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:131:23: note: ob_refcnt is now refs: 1 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:133:5: note: ob_refcnt is now refs: 2 + N where N >= 25\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_026\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:134:23: note: ob_refcnt is now refs: 1 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:136:5: note: ob_refcnt is now refs: 2 + N where N >= 26\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_027\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:137:23: note: ob_refcnt is now refs: 1 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:139:5: note: ob_refcnt is now refs: 2 + N where N >= 27\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:140:23: note: when PyModule_AddObject() succeeds at:     PyModule_AddObject(m, \"item_028\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:140:23: note: ob_refcnt is now refs: 1 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:142:5: note: ob_refcnt is now refs: 2 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_029\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:145:5: note: ob_refcnt is now refs: 3 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_030\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:148:5: note: ob_refcnt is now refs: 4 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_031\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:151:5: note: ob_refcnt is now refs: 5 + N where N >= 28\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152:23: note: when PyModule_AddObject() fails at:     PyModule_AddObject(m, \"item_032\", item);\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:155:1: note: returning\ntests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:33:1: note: graphical error report for function 'test_adding_module_objects' written out to 'tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c.test_adding_module_objects-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/combinatorial-explosion-with-error/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 2 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:140\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149\n\nTrace 3:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 4 + N where N >= 29\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 4:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 1 + N where N >= 32\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:33\n\nTrace 5:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 2 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 6:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 2 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149\n\nTrace 7:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 8:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 2 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146\n\nTrace 9:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 10:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149\n\nTrace 11:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 4 + N where N >= 29\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 12:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 2 + N where N >= 31\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:143\n\nTrace 13:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 14:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149\n\nTrace 15:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 4 + N where N >= 29\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 16:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 3 + N where N >= 30\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:146\n\nTrace 17:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 4 + N where N >= 29\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n\nTrace 18:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 4 + N where N >= 29\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:149\n\nTrace 19:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() succeeds'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'when PyModule_AddObject() fails'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34)) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:34\n    r->ob_refcnt: refs: 5 + N where N >= 28\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('m') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('m')\")\n    str(): region for gcc.ParmDecl('m') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=32), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('m')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:45\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c', line=45), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/combinatorial-explosion-with-error/input.c:152\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_decref/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can cope with a Py_DECREF that is provably not\n  acting on the final reference on the object.\n*/\nPyObject *\ncorrect_decref(PyObject *self, PyObject *args)\n{\n    /* Create an object: */\n    PyObject *tmp = PyLong_FromLong(0x1000);\n\n    if (!tmp) {\n        return NULL;\n    }\n\n    /* Incref it so that we can safely decref it: */\n    Py_INCREF(tmp);\n\n    /*\n      Now decref it: the verifier ought to figure out that it can't\n      tp_dealloc the object, as the refcount can't reach 0:\n    */\n    Py_DECREF(tmp);\n\n    return tmp;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  correct_decref, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_decref/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_decref/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=30), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=30)) from tests/cpychecker/refcounts/correct_decref/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/correct_decref/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/correct_decref/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_decref/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/correct_decref/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_object_ctor/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\ncorrect_object_ctor(PyObject *self, PyObject *args)\n{\n    /* This code is correct: the API call returns a\n       new reference (or a NULL for MemoryError).  Use some temporaries\n       to make things more difficult for the checker: */\n    PyObject *tmpA;\n    PyObject *tmpB;\n    tmpA = PyLong_FromLong(0x1000);\n    tmpB = tmpA;\n    return tmpB;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  correct_object_ctor, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_object_ctor/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main, get_traces\n\ndef verify_traces(optpass, fun):\n    # Only run in one pass\n    # FIXME: should we be adding our own pass for this?\n    if optpass.name == '*warn_function_return':\n        if fun:\n            traces = get_traces(fun)\n\n            # We should have two traces\n            # print('traces: %r' % traces)\n            assert len(traces) == 2\n\n            # Verify the \"success\" trace:\n            state = traces[0].states[-1]\n            print('Trace 0:')\n            r = state.return_rvalue\n            print('  returned: %r' %r)\n            print('  r->ob_refcnt: %r' % state.get_value_of_field_by_region(r.region, 'ob_refcnt'))\n\n            # Verify the \"fail\" trace:\n            state = traces[1].states[-1]\n            print('Trace 1:')\n            print('  returned: %r' % state.return_rvalue)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      verify_traces)\n\n#main(verify_refcounting=True)\n\n#main(verify_refcounting=True,\n#     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_object_ctor/stdout.txt",
    "content": "Trace 0:\n  returned: PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_object_ctor/input.c', line=30), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/correct_object_ctor/input.c', line=30)))\n  r->ob_refcnt: RefcountValue(1, 0)\nTrace 1:\n  returned: ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_object_ctor/input.c', line=30), value=0)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_py_none/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\ncorrect_none(PyObject *self, PyObject *args)\n{\n    Py_RETURN_NONE;\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  correct_none, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_py_none/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/correct_py_none/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_py_none/input.c', line=25), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/correct_py_none/input.c:25\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_py_none/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/correct_py_none/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/correct_py_none/input.c:24\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/destructor/input.cc",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n\n/* Verify that the checker can cope with a C++ destructor */\n#include <Python.h>\n\nclass Foo\n{\npublic:\n    virtual ~Foo();\n};\n\nclass Bar : public Foo\n{\npublic:\n    ~Bar() {}\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/destructor/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/destructor/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'taking False path'\n    'returning'\n  Exception:\n    (struct PyObject *)0\nTrace 0:\n  Transitions:\n    'returning'\n  Exception:\n    (struct PyObject *)0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/empty-function/input.cc",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Verify that the checker can cope with an empty C++ virtual function\n  (this contains a gcc.GimpleNop, in gcc-4.6 at least)\n */\n#include <Python.h>\n\nclass Test\n{\npublic:\n    virtual void foo() {}\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/empty-function/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/empty-function/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Exception:\n    (struct PyObject *)0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/method/input.cc",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Verify that the checker will run on a C++ method */\n#include <Python.h>\n\nclass Foo\n{\npublic:\n    PyObject * test(int i);\n};\n\nPyObject *\nFoo::test(int i)\n{\n    if (i) {\n        /*\n           Verify that C++ frontend can locate globals\n           for types (\"PyDict_Type\") and exceptions (PyExc_MemoryError)\n        */\n        return PyDict_New();\n    } else {\n        /* Verify that bugs are reported:\n           this code is missing a Py_INCREF on Py_None */\n        return Py_None;\n    }\n}\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/method/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/method/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/method/stderr.txt",
    "content": "tests/cpychecker/refcounts/cplusplus/method/input.cc: In member function 'PyObject* Foo::test(int)':\ntests/cpychecker/refcounts/cplusplus/method/input.cc:41:16: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/cplusplus/method/input.cc:41:16: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/cplusplus/method/input.cc:32:5: note: when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:30 at:     if (i) {\ntests/cpychecker/refcounts/cplusplus/method/input.cc:32:5: note: taking False path at:     if (i) {\ntests/cpychecker/refcounts/cplusplus/method/input.cc:41:16: note: reaching:         return Py_None;\ntests/cpychecker/refcounts/cplusplus/method/input.cc:32:5: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/cplusplus/method/input.cc:41:16: note: returning\ntests/cpychecker/refcounts/cplusplus/method/input.cc:41:16: note: consider using \"Py_RETURN_NONE;\"\ntests/cpychecker/refcounts/cplusplus/method/input.cc:31:1: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/cplusplus/method/input.cc.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/method/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'when PyDict_New() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:31\n\nTrace 1:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'when PyDict_New() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:37\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37\n\nTrace 2:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:30'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=41), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/cplusplus/method/input.cc:41\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:31\n\nTrace 3:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when PyDict_New() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37)) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:31\n\nTrace 4:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when PyDict_New() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/method/input.cc', line=37), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/method/input.cc:37\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/method/input.cc:37\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/reference/input.cc",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Verify that the checker can cope references in C++\n */\n#include <Python.h>\n\nvoid test(int &i)\n{\n    i += 1;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/reference/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/reference/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/reference/input.cc:26\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/simple/input.cc",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/* Verify that the checker will run on C++ code */\n\nPyObject *\ntest(int i)\n{\n    if (i) {\n        /* \n           Verify that C++ frontend can locate globals\n           for types (\"PyDict_Type\") and exceptions (PyExc_MemoryError)\n        */\n        return PyDict_New();\n    } else {\n        /* Verify that bugs are reported: \n           this code is missing a Py_INCREF on Py_None */\n        return Py_None;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/simple/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/simple/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/simple/stderr.txt",
    "content": "In function 'PyObject* test(int)':\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:36:16: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:36:16: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:27:5: note: when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:25 at:     if (i) {\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:27:5: note: taking False path at:     if (i) {\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:36:16: note: reaching:         return Py_None;\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:27:5: note: ob_refcnt is now refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:36:16: note: returning\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:36:16: note: consider using \"Py_RETURN_NONE;\"\ntests/cpychecker/refcounts/cplusplus/simple/input.cc:26:1: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/cplusplus/simple/input.cc.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/simple/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'when PyDict_New() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:26\n\nTrace 1:\n  Transitions:\n    'when considering range: -0x80000000 <= value <= -1'\n    'taking True path'\n    'when PyDict_New() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32\n\nTrace 2:\n  Transitions:\n    'when considering value == (int)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:25'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=36), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:36\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:26\n\nTrace 3:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when PyDict_New() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32)) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:26\n\nTrace 4:\n  Transitions:\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when PyDict_New() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/simple/input.cc', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/cplusplus/simple/input.cc:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/this/input.cc",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n\n/* Verify that the checker can handle \"this\" in C++ code */\n#include <Python.h>\n\nclass Foo\n{\n    int x;\n\npublic:\n    int\n    get_x();\n};\n\nint Foo::get_x()\n{\n    /* the checker should assume that \"this\" is non-NULL */\n    return this->x;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/this/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/cplusplus/this/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): WithinRange(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/cplusplus/this/input.cc', line=36), minvalue=-0x80000000, maxvalue=0x7fffffff)\n    str(): (int)val [-0x80000000 <= val <= 0x7fffffff] from tests/cpychecker/refcounts/cplusplus/this/input.cc:36\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/cplusplus/this/input.cc:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/fold_conditional/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nfold_conditional(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    list = PyList_New(5);\n    if (!list) {\n        return NULL;\n    }\n\n    /*\n       Try a useless conditional to verify that the analyser knows it's\n       false:\n    */\n    if (PyList_GET_SIZE(list) != 5) {\n        /* The analyser should figure out that we can never get here: */\n        return list;\n    }\n\n    /*\n      Try another useless conditional, to verify that the analyser knows\n      it's false:\n    */\n    if (Py_TYPE(list) != &PyList_Type) {\n        /*\n\t  Likewise, the analyser should figure out that we can never get\n\t  here:\n\t*/\n        return list;\n    }\n\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  fold_conditional, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n"
  },
  {
    "path": "tests/cpychecker/refcounts/fold_conditional/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/fold_conditional/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'taking False path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=26), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=26)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=26)) from tests/cpychecker/refcounts/fold_conditional/input.c:26\n    r->ob_refcnt: refs: 1 + N where N >= 0\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=26), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/fold_conditional/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=28), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/fold_conditional/input.c:28\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 + N where N >= 1\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/fold_conditional/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/fold_conditional/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/refcounts/function-that-exits/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker doesn't erroneously report leaks for a function\n  that calls exit\n*/\n\nvoid\ntest(PyObject *obj)\n{\n    PyObject *repr;\n    const char *msg;\n\n    repr = PyObject_Repr(obj);\n    if (repr) {\n        msg = PyString_AsString(repr);\n    } else {\n        msg = \"(repr() failed)\";\n    }\n\n    fprintf(stderr, \"error: %s\\n\", msg);\n\n    /*\n      The checker shouldn't report that \"repr\" has leaked, as\n      the call to exit() makes it irrelevant:\n    */\n    exit(1);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/function-that-exits/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/function-that-exits/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyObject_Repr() succeeds'\n    'taking True path'\n    'PyString_AsString() returns ob_sval'\n    'not returning from exit'\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/function-that-exits/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/function-that-exits/input.c:33:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/function-that-exits/input.c', line=33))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/function-that-exits/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/function-that-exits/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/function-that-exits/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyObject_Repr() fails'\n    'taking False path'\n    'not returning from exit'\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/function-that-exits/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/function-that-exits/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/getter/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the analyser can cope with getters for\n  PyObject subclasses\n*/\n\nstruct MySubclass {\n    PyObject_HEAD\n    struct foo *f;\n};\n\nextern PyObject *make_wrapper(struct foo *f);\n\nstatic PyObject *\nsimple_getter(struct MySubclass *self, void *closure)\n{\n    /*\n      The analyser should assume that self is non-NULL\n      and thus not report a NULL ptr dereference below:\n    */\n\n    return make_wrapper(self->f);\n}\n\nstatic PyGetSetDef gcc_Variable_getset_table[] = {\n    {\"test_attrib\",\n     (getter)simple_getter,\n     (setter)NULL,\n     NULL,\n     NULL},\n    {NULL}  /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/getter/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/getter/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when make_wrapper() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/getter/input.c', line=42), region=RegionOnHeap('new ref from (unknown) make_wrapper', gcc.Location(file='tests/cpychecker/refcounts/getter/input.c', line=42)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from (unknown) make_wrapper', gcc.Location(file='tests/cpychecker/refcounts/getter/input.c', line=42)) from tests/cpychecker/refcounts/getter/input.c:42\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/getter/input.c', line=42), region=Region('PyTypeObject for new ref from (unknown) make_wrapper'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/getter/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/getter/input.c:36\n\nTrace 1:\n  Transitions:\n    'when make_wrapper() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/getter/input.c', line=42), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/getter/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/getter/input.c', line=35), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/getter/input.c:42\n"
  },
  {
    "path": "tests/cpychecker/refcounts/handle_null_error/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of handling of Objects/abstract.c's null_error()\n*/\n\nPyObject *\ntest(PyObject *mapping)\n{\n    PyObject *key;\n    PyObject *value;\n\n    /* This could fail (e.g. MemoryError): */\n    key = PyString_FromString(\"some_key\");\n\n    /* PyObject_GetItem uses null_error() on both arguments, and thus ought\n       to gracefully handle the above call failing, without overriding the\n       original exception: */\n    value = PyObject_GetItem(mapping, key);\n    Py_XDECREF(key);\n    return value;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/handle_null_error/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/handle_null_error/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'when PyObject_GetItem() succeeds'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38), region=RegionOnHeap('new ref from call to PyObject_GetItem', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_GetItem', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38)) from tests/cpychecker/refcounts/handle_null_error/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38), region=Region('PyTypeObject for new ref from call to PyObject_GetItem'))\n  region for gcc.ParmDecl('mapping') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('mapping')\")\n    str(): region for gcc.ParmDecl('mapping') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('mapping')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=33))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/handle_null_error/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'when PyObject_GetItem() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38), region=RegionOnHeap('new ref from call to PyObject_GetItem', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from call to PyObject_GetItem', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38)) from tests/cpychecker/refcounts/handle_null_error/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38), region=Region('PyTypeObject for new ref from call to PyObject_GetItem'))\n  region for gcc.ParmDecl('mapping') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('mapping')\")\n    str(): region for gcc.ParmDecl('mapping') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('mapping')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=33))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/handle_null_error/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'when PyObject_GetItem() fails'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/handle_null_error/input.c:38\n  region for gcc.ParmDecl('mapping') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('mapping')\")\n    str(): region for gcc.ParmDecl('mapping') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('mapping')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=33))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/handle_null_error/input.c:38\n\nTrace 3:\n  Transitions:\n    'when PyString_FromString() succeeds'\n    'when PyObject_GetItem() fails'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/handle_null_error/input.c:38\n  region for gcc.ParmDecl('mapping') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('mapping')\")\n    str(): region for gcc.ParmDecl('mapping') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('mapping')\"))\n  PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33:\n    repr(): RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=33))\n    str(): PyStringObject allocated at tests/cpychecker/refcounts/handle_null_error/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/handle_null_error/input.c:38\n\nTrace 4:\n  Transitions:\n    'when PyString_FromString() fails'\n    'when PyObject_GetItem fails due to NULL as argument 2 at tests/cpychecker/refcounts/handle_null_error/input.c:38'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/handle_null_error/input.c:38\n  region for gcc.ParmDecl('mapping') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('mapping')\")\n    str(): region for gcc.ParmDecl('mapping') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/handle_null_error/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('mapping')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/handle_null_error/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/incorrect_py_none/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nlosing_refcnt_of_none(PyObject *self, PyObject *args)\n{\n    /* Bug: this code is missing a Py_INCREF on Py_None */\n    return Py_None;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  losing_refcnt_of_none, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n"
  },
  {
    "path": "tests/cpychecker/refcounts/incorrect_py_none/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/incorrect_py_none/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main, get_traces\n\ndef verify_traces(optpass, fun):\n    # Only run in one pass\n    # FIXME: should we be adding our own pass for this?\n    if optpass.name == '*warn_function_return':\n        if fun:\n            traces = get_traces(fun)\n\n            # We should have a single trace\n            #print('traces: %r' % traces)\n            assert len(traces) == 1\n            state = traces[0].states[-1]\n            print('_Py_NoneStruct.ob_refcnt: %s'\n                  % state.get_value_of_field_by_varname('_Py_NoneStruct', 'ob_refcnt'))\n            print('state.return_rvalue: %r' % state.return_rvalue)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      verify_traces)\n\nmain(verify_refcounting=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/incorrect_py_none/stderr.txt",
    "content": "In function 'losing_refcnt_of_none':\ntests/cpychecker/refcounts/incorrect_py_none/input.c:26:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/incorrect_py_none/input.c:26:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned, 1 borrowed\ntests/cpychecker/refcounts/incorrect_py_none/input.c:26:nn: note: returning at:     return Py_None;\ntests/cpychecker/refcounts/incorrect_py_none/input.c:26:nn: note: consider using \"Py_RETURN_NONE;\"\ntests/cpychecker/refcounts/incorrect_py_none/input.c:24:nn: note: graphical error report for function 'losing_refcnt_of_none' written out to 'tests/cpychecker/refcounts/incorrect_py_none/input.c.losing_refcnt_of_none-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/incorrect_py_none/stdout.txt",
    "content": "_Py_NoneStruct.ob_refcnt: refs: 0 owned, 1 borrowed\nstate.return_rvalue: PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/incorrect_py_none/input.c', line=26), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n"
  },
  {
    "path": "tests/cpychecker/refcounts/json/basic/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nlosing_refcnt_of_none(PyObject *self, PyObject *args)\n{\n    /* Bug: this code is missing a Py_INCREF on Py_None */\n    return Py_None;\n}\n"
  },
  {
    "path": "tests/cpychecker/refcounts/json/basic/script.py",
    "content": "#   Copyright 2012, 2019 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012, 2019 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that the JSON serialization of error reports is working\n\nimport gcc\nfrom libcpychecker.refcounts import impl_check_refcounts\n\nfrom gccutils.selftests import assertEqual, assertEndsWith\n\ndef verify_json(optpass, fun):\n    # Only run in one pass\n    # FIXME: should we be adding our own pass for this?\n    if optpass.name == '*warn_function_return':\n        if fun:\n            rep = impl_check_refcounts(fun)\n            js = rep.to_json(fun)\n            if 0:\n                from json import dumps\n                print(dumps(js, sort_keys=True, indent=4))\n\n            # Verify the top-level JSON that's emitted:\n            assertEndsWith(js['filename'], 'tests/cpychecker/refcounts/json/basic/input.c')\n            assertEqual(js['function']['name'], 'losing_refcnt_of_none')\n            assertEqual(js['function']['lines'][0], 22)\n            assertEqual(js['function']['lines'][1], 28)\n\n            # Verify the JSON for the single error report:\n            assertEqual(len(js['reports']), 1)\n            r = js['reports'][0]\n            assertEqual(r['severity'], \"warning\")\n            assertEqual(r['message'],\n                        \"future use-after-free: ob_refcnt of return value is 1 too low\")\n            assertEqual(len(r['notes']), 2)\n            assertEqual(r['notes'][0]['message'],\n                        'was expecting final owned ob_refcnt of return value to be 1'\n                        ' due to object being referenced by: return value'\n                        ' but final ob_refcnt is refs: 0 owned, 1 borrowed')\n            assertEqual(r['notes'][1]['message'],\n                        \"consider using \\\"Py_RETURN_NONE;\\\"\")\n\n            # Verify the JSON serialization of the endstate within the report:\n            statejs = r['states'][-1]\n\n            if 0:\n                from json import dumps\n                print(dumps(statejs, sort_keys=True, indent=4))\n\n            # Verify that we have a location:\n            for i in range(2):\n                assert statejs['location'][i]['column'] > 0\n                assertEqual(statejs['location'][i]['line'], 26)\n\n            assertEqual(statejs['message'], None)\n\n            vars = statejs['variables']\n\n            # Verify that the bug in the handling of Py_None's ob_refcnt\n            # is described within the JSON:\n            none_refcnt = vars['_Py_NoneStruct.ob_refcnt']\n            assertEqual(none_refcnt['gcctype'], \"Py_ssize_t\")\n            assertEqual(none_refcnt['kind'], \"RefcountValue\")\n            assertEqual(none_refcnt['actual_ob_refcnt']['refs_we_own'], 0)\n            assertEqual(none_refcnt['expected_ob_refcnt']['pointers_to_this'],\n                        ['return value'])\n\n            # Verify \"self\":\n            selfjs = vars['self']\n            assertEqual(selfjs['gcctype'], 'struct PyObject *')\n            assertEqual(selfjs['kind'], 'PointerToRegion')\n            assertEqual(selfjs['value_comes_from'][0]['line'], 23)\n\n            ob_refcnt = vars['self->ob_refcnt']\n            assertEqual(ob_refcnt['gcctype'], 'Py_ssize_t')\n            assertEqual(ob_refcnt['kind'], 'RefcountValue')\n            assertEqual(ob_refcnt['value_comes_from'][0]['line'], 23)\n\n            ob_type = vars['self->ob_type']\n            assertEqual(ob_type['gcctype'], 'struct PyTypeObject *')\n            assertEqual(ob_type['kind'], 'PointerToRegion')\n            assertEqual(ob_type['value_comes_from'][0]['line'], 23)\n\n            # Ensure that this testing code actually got run (stdout is\n            # checked):\n            print('GOT HERE')\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      verify_json)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/json/basic/stdout.txt",
    "content": "GOT HERE\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loop_n_times/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can cope with a loop where we can't know\n  the limit at analysis time\n*/\n\nPyObject *\nloop_n_times(PyObject *self, PyObject *args)\n{\n    int i, count;\n    PyObject *list;\n    PyObject *item;\n\n    if (!PyArg_ParseTuple(args, \"i\", &count)) {\n        return NULL;\n    }\n\n    list = PyList_New(count);\n    if (!list) {\n        return NULL;\n    }\n    item = PyLong_FromLong(42);\n    if (!item) {\n        Py_DECREF(list);\n        return NULL;\n    }\n\n    /* We can't know the value of \"count\" at this point: */\n    for (i = 0; i < count; i++) {\n        /* This steals a reference to item, so we need to INCREF it: */\n        Py_INCREF(item);\n        PyList_SetItem(list, 0, item);\n    }\n    Py_DECREF(item);\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  loop_n_times, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loop_n_times/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loop_n_times/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when considering range: -0x80000000 <= count.1 <= 0'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38)) from tests/cpychecker/refcounts/loop_n_times/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:42:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=42))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:42\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=42), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/loop_n_times/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when considering range: -0x80000000 <= count.1 <= 0'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:42'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38)) from tests/cpychecker/refcounts/loop_n_times/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:42:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=42))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:42\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/loop_n_times/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when considering range: 1 <= count.1 <= 0x7fffffff'\n    'taking True path'\n    'PyList_SetItem() succeeds'\n    'when considering count.1 == (int)1 from tests/cpychecker/refcounts/loop_n_times/input.c:34'\n    'taking False path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38)) from tests/cpychecker/refcounts/loop_n_times/input.c:38\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:42:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=42))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:42\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=42), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/loop_n_times/input.c:29\n\nTrace 3:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loop_n_times/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:38:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:38\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loop_n_times/input.c:42\n\nTrace 4:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:38'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=45), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loop_n_times/input.c:45\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:38:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=38))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loop_n_times/input.c:38\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loop_n_times/input.c:42\n\nTrace 5:\n  Transitions:\n    'when PyArg_ParseTuple() succeeds'\n    'taking False path'\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=40), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loop_n_times/input.c:40\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loop_n_times/input.c:38\n\nTrace 6:\n  Transitions:\n    'when PyArg_ParseTuple() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=35), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loop_n_times/input.c:35\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loop_n_times/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_TypeError')) from tests/cpychecker/refcounts/loop_n_times/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nconst unsigned int unknown_unsigned_val;\n\nextern PyObject*\nmake_item(int i);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *result;\n    int i = 0;\n\n    result = PyList_New(0);\n    if (!result) {\n\tgoto error;\n    }\n\n    for (i = 0; i < unknown_unsigned_val; i++) {\n\tPyObject *item = make_item(i);\n\tif (!item) {\n\t    goto error;\n\t}\n\tif (-1 == PyList_Append(result, item)) {\n\t    Py_DECREF(item);\n\t    goto error;\n\t}\n        /* BUG: leak of item here */\n        /* Was seeing no traces in which PyList_Append succeeds, due to\n           over-aggressive loop-detection.\n           The comparison in the loop is 3 statements long:\nloc: block 12 stmt:0 :   gcc.GimpleAssign() : i.0 = (unsigned int) i;\nloc: block 12 stmt:1 :   gcc.GimpleAssign() : unknown_unsigned_val.1 = unknown_unsigned_val;\nloc: block 12 stmt:2 :     gcc.GimpleCond() : if (i.0 < unknown_unsigned_val.1)\n        */\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-1/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-1/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-1/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:57:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:nn: note: '*item' was allocated at: \tPyObject *item = make_item(i);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:57:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33:nn: note: when PyList_New() succeeds at:     result = PyList_New(0);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:34:nn: note: taking False path at:     if (!result) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:38:nn: note: reaching:     for (i = 0; i < unknown_unsigned_val; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:38:nn: note: when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff at:     for (i = 0; i < unknown_unsigned_val; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:38:nn: note: taking True path at:     for (i = 0; i < unknown_unsigned_val; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:nn: note: reaching: \tPyObject *item = make_item(i);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:nn: note: when make_item() succeeds at: \tPyObject *item = make_item(i);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:40:nn: note: taking False path at: \tif (!item) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43:nn: note: reaching: \tif (-1 == PyList_Append(result, item)) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43:nn: note: when PyList_Append() succeeds at: \tif (-1 == PyList_Append(result, item)) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43:nn: note: ob_refcnt is now refs: 2 owned\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43:nn: note: '*item' is now referenced by 1 non-stack value(s): PyListObject.ob_item[0]\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43:nn: note: taking False path at: \tif (-1 == PyList_Append(result, item)) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:38:nn: note: reaching:     for (i = 0; i < unknown_unsigned_val; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:38:nn: note: when considering unknown_unsigned_val.1 == (const unsigned int)1 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:22 at:     for (i = 0; i < unknown_unsigned_val; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:38:nn: note: taking False path at:     for (i = 0; i < unknown_unsigned_val; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:57:nn: note: reaching:     return result;\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:57:nn: note: returning\ntests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-1/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering unknown_unsigned_val.1 == (const unsigned int)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:22'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33)) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() succeeds'\n    'taking False path'\n    'when considering unknown_unsigned_val.1 == (const unsigned int)1 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:22'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33)) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39), region=Region('PyTypeObject for new ref from (unknown) make_item'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=61), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:61\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39), region=Region('PyTypeObject for new ref from (unknown) make_item'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=61), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:61\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39), region=Region('PyTypeObject for new ref from (unknown) make_item'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=61), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:61\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43\n\nTrace 5:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=61), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:61\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=39))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:43\n\nTrace 6:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff'\n    'taking True path'\n    'when make_item() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=61), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:61\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39\n\nTrace 7:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= unknown_unsigned_val.1 <= 0xffffffff'\n    'taking True path'\n    'when make_item() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=61), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:61\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:39\n\nTrace 8:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=61), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:61\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-1/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nextern PyObject*\nmake_item(int i);\n\nextern int get_limit(void);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *result;\n    int i = 0;\n\n    result = PyList_New(0);\n    if (!result) {\n\tgoto error;\n    }\n\n    /* This loop has a multi-statement conditional: */\n    for (i = 0; i < (2 * get_limit()) + 42; i++) {\n\tPyObject *item = make_item(i);\n\tif (!item) {\n\t    goto error;\n\t}\n\tif (-1 == PyList_Append(result, item)) {\n\t    Py_DECREF(item);\n\t    goto error;\n\t}\n        /* BUG: leak of \"item\" */\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-2/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-2/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-2/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:51:nn: warning: memory leak: ob_refcnt of '*item' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:nn: note: '*item' was allocated at: \tPyObject *item = make_item(i);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:51:nn: note: was expecting final owned ob_refcnt of '*item' to be 1 due to object being referenced by: PyListObject.ob_item[0] but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33:nn: note: when PyList_New() succeeds at:     result = PyList_New(0);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:34:nn: note: taking False path at:     if (!result) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:39:nn: note: reaching:     for (i = 0; i < (2 * get_limit()) + 42; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:39:nn: note: when considering range: 1 <= value <= 0x7fffffff at:     for (i = 0; i < (2 * get_limit()) + 42; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:39:nn: note: taking True path at:     for (i = 0; i < (2 * get_limit()) + 42; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:nn: note: reaching: \tPyObject *item = make_item(i);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:nn: note: when make_item() succeeds at: \tPyObject *item = make_item(i);\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:41:nn: note: taking False path at: \tif (!item) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44:nn: note: reaching: \tif (-1 == PyList_Append(result, item)) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44:nn: note: when PyList_Append() succeeds at: \tif (-1 == PyList_Append(result, item)) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44:nn: note: ob_refcnt is now refs: 2 owned\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44:nn: note: '*item' is now referenced by 1 non-stack value(s): PyListObject.ob_item[0]\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44:nn: note: taking False path at: \tif (-1 == PyList_Append(result, item)) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:39:nn: note: reaching:     for (i = 0; i < (2 * get_limit()) + 42; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:39:nn: note: when considering range: -0x80000000 <= value <= 1 at:     for (i = 0; i < (2 * get_limit()) + 42; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:39:nn: note: taking False path at:     for (i = 0; i < (2 * get_limit()) + 42; i++) {\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:51:nn: note: reaching:     return result;\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:51:nn: note: returning\ntests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/loops/complex-loop-conditional-2/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: -0x80000000 <= value <= 0'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33)) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() succeeds'\n    'taking False path'\n    'when considering range: -0x80000000 <= value <= 1'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33)) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40), region=Region('PyTypeObject for new ref from (unknown) make_item'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40), region=Region('PyTypeObject for new ref from (unknown) make_item'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44\n\nTrace 3:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40), region=Region('PyTypeObject for new ref from (unknown) make_item'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44\n\nTrace 4:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44\n\nTrace 5:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when make_item() succeeds'\n    'taking False path'\n    'when PyList_Append() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40:\n    repr(): RegionOnHeap('new ref from (unknown) make_item', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=40))\n    str(): new ref from (unknown) make_item allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:44\n\nTrace 6:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when make_item() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40\n\nTrace 7:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= value <= 0x7fffffff'\n    'taking True path'\n    'when make_item() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=33))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:40\n\nTrace 8:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=55), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:55\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/loops/complex-loop-conditional-2/input.c:33\n"
  },
  {
    "path": "tests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Regression test for:\n     TypeError: (struct PyObject *)0 from tests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35 / ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c', line=35), value=0) is not an instance of <class 'libcpychecker.absinterp.PointerToRegion'>\n*/\n\nvoid\ntest(PyObject *callable, PyObject *args)\n{\n    /*\n      This is bogus code: Py_XDECREF expands its argument multiple times,\n      so the function is actually called up to 4 times\n      (assuming a non pydebug build of CPython).\n    */\n    Py_XDECREF(PyObject_CallObject(callable, args));\n\n    /* Seen in the wild in:\n       python-alsa-1.0.25-1.fc17:\n         pyalsa/alsamixer.c:179\n         pyalsa/alsahcontrol.c:190\n         pyalsa/alsaseq.c:3277\n\n       python-4Suite-XML-1.0.2-14.fc17:\n         Ft/Xml/src/domlette/refcounts.c:80\n    */\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/macros/Py_XDECREF/crash/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/macros/Py_XDECREF/crash/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/macros/Py_XDECREF/crash/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:46:nn: warning: memory leak: ob_refcnt of new ref from call to PyObject_CallObject is 1 too high [enabled by default]\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: new ref from call to PyObject_CallObject was allocated at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:46:nn: note: was expecting final owned ob_refcnt of new ref from call to PyObject_CallObject to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when PyObject_CallObject() succeeds at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: taking False path at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: reaching:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when PyObject_CallObject() succeeds at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when taking True path at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:46:nn: note: reaching: }\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:46:nn: note: returning at: }\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:46:nn: note: found 4 similar trace(s) to this\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: warning: dereferencing NULL (D.nnnnn->ob_type) at tests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35 [enabled by default]\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when PyObject_CallObject() succeeds at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: taking False path at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: reaching:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when PyObject_CallObject() succeeds at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when taking False path at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: reaching:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when PyObject_CallObject() fails at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: warning: dereferencing NULL (D.nnnnn->ob_refcnt) at tests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35 [enabled by default]\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when PyObject_CallObject() succeeds at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: taking False path at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: reaching:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:35:nn: note: when PyObject_CallObject() fails at:     Py_XDECREF(PyObject_CallObject(callable, args));\ntests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/macros/Py_XDECREF/crash/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/macros/Py_XDECREF/crash/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/cpychecker/refcounts/missing_decref/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nmissing_decref(PyObject *self, PyObject *args)\n{\n    PyObject *list;\n    PyObject *item;\n    list = PyList_New(1);\n    if (!list)\n        return NULL;\n    item = PyLong_FromLong(42);\n    /* This error handling is incorrect: it's missing an\n       invocation of Py_DECREF(list): */\n    if (!item)\n        return NULL;\n    /* This steals a reference to item; item is not leaked when we get here: */\n    PyList_SetItem(list, 0, item);\n    return list;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  missing_decref, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n"
  },
  {
    "path": "tests/cpychecker/refcounts/missing_decref/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/missing_decref/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/missing_decref/stderr.txt",
    "content": "In function 'missing_decref':\ntests/cpychecker/refcounts/missing_decref/input.c:34:nn: warning: memory leak: ob_refcnt of '*list' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/missing_decref/input.c:27:nn: note: '*list' was allocated at:     list = PyList_New(1);\ntests/cpychecker/refcounts/missing_decref/input.c:34:nn: note: was expecting final owned ob_refcnt of '*list' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/missing_decref/input.c:27:nn: note: when PyList_New() succeeds at:     list = PyList_New(1);\ntests/cpychecker/refcounts/missing_decref/input.c:27:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/missing_decref/input.c:28:nn: note: taking False path at:     if (!list)\ntests/cpychecker/refcounts/missing_decref/input.c:30:nn: note: reaching:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/missing_decref/input.c:30:nn: note: when PyLong_FromLong() fails at:     item = PyLong_FromLong(42);\ntests/cpychecker/refcounts/missing_decref/input.c:33:nn: note: taking True path at:     if (!item)\ntests/cpychecker/refcounts/missing_decref/input.c:34:nn: note: reaching:         return NULL;\ntests/cpychecker/refcounts/missing_decref/input.c:34:nn: note: returning\ntests/cpychecker/refcounts/missing_decref/input.c:24:nn: note: graphical error report for function 'missing_decref' written out to 'tests/cpychecker/refcounts/missing_decref/input.c.missing_decref-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/missing_decref/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'PyList_SetItem() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=27), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=27)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=27)) from tests/cpychecker/refcounts/missing_decref/input.c:27\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/missing_decref/input.c:30:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=30))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/missing_decref/input.c:30\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/missing_decref/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=34), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/missing_decref/input.c:34\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyListObject allocated at tests/cpychecker/refcounts/missing_decref/input.c:27:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=27))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/missing_decref/input.c:27\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=27), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/missing_decref/input.c:30\n\nTrace 2:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=29), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/missing_decref/input.c:29\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/missing_decref/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/missing_decref/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/module_handling/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can cope with module creation\n*/\nstatic PyMethodDef ExampleMethods[] = {\n    /* Sentinel: */\n    {NULL, NULL, 0, NULL}\n};\n\n#if PY_MAJOR_VERSION == 3\nstatic struct PyModuleDef example_module_def = {\n    PyModuleDef_HEAD_INIT,\n    \"example\",   /* name of module */\n    NULL,\n    -1,\n    ExampleMethods\n};\n#endif\n\n#define MY_INT_MACRO     (42)\n#define MY_STRING_MACRO  (\"Arthur\")\n\nstatic PyMODINIT_FUNC PyInit_example(void)\n{\n    PyObject *m;\n    PyObject *obj;\n#if PY_MAJOR_VERSION == 3\n    m = PyModule_Create(&example_module_def);\n#else\n    m = Py_InitModule(\"example\", ExampleMethods);\n#endif\n\n    if (!m) {\n        goto error;\n    }\n\n    /* Exercise the various PyModule_Add* entrypoints: */\n    obj = PyDict_New();\n    if (!obj) {\n        goto error;\n    }\n\n    /* We now own a ref on \"obj\", which PyModule_AddObject steals: */\n    if (-1 == PyModule_AddObject(m, \"obj\", obj)) {\n        Py_DECREF(obj);\n        goto error;\n    }\n\n    PyModule_AddIntConstant(m, \"int_constant\", 42);\n    PyModule_AddStringConstant(m, \"string_constant\", \"Marvin\");\n    PyModule_AddIntMacro(m, MY_INT_MACRO);\n    PyModule_AddStringMacro(m, MY_STRING_MACRO);\n\n    error:\n#if PY_MAJOR_VERSION == 3\n    return m;\n#else\n    (void)0; /* to avoid \"label at end of compound statement\" error */\n#endif\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/module_handling/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/module_handling/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/module_handling/input.c:44\n\nTrace 1:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 2:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:71\n\nTrace 3:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 4:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:70\n\nTrace 5:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 6:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:71\n\nTrace 7:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 8:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:69\n\nTrace 9:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 10:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:71\n\nTrace 11:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 12:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:70\n\nTrace 13:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() succeeds'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 14:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() succeeds'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:71\n\nTrace 15:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() succeeds'\n    'taking False path'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'when PyModule_AddIntConstant() fails'\n    'when PyModule_AddStringConstant() fails'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:72\n\nTrace 16:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() fails'\n    'taking True path'\n    'when taking True path'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:64\n\nTrace 17:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyModule_AddObject() fails'\n    'taking True path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=58))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/module_handling/input.c:58\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:64\n\nTrace 18:\n  Transitions:\n    'when Py_InitModule4_64() succeeds'\n    'taking False path'\n    'when PyDict_New() fails'\n    'taking True path'\n    'returning'\n  borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50:\n    repr(): RegionOnHeap('borrowed reference returned by Py_InitModule4_64()', gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50))\n    str(): borrowed reference returned by Py_InitModule4_64() allocated at tests/cpychecker/refcounts/module_handling/input.c:50\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/module_handling/input.c', line=50), region=Region('PyTypeObject for borrowed reference returned by Py_InitModule4_64()'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:58\n\nTrace 19:\n  Transitions:\n    'when Py_InitModule4_64() fails'\n    'taking True path'\n    'returning'\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/module_handling/input.c:50\n"
  },
  {
    "path": "tests/cpychecker/refcounts/multiple-returns/input.c",
    "content": "/*\n   Copyright 2014 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2014 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test that we report a sane return location when returning prematurely\n  from a function, at the source location of the \"return\"\n*/\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    PyObject *dictA;\n    PyObject *dictB;\n    dictA = PyDict_New();\n    if (!dictA) return NULL;\n\n    /* dictA now has a refcnt of 1 */\n\n    dictB = PyDict_New();\n    if (!dictB) return NULL;\n\n    /* the above error-handling code leaks the ref on dictA */\n\n    Py_DECREF(dictA);\n\n    return dictB;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/multiple-returns/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/multiple-returns/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/multiple-returns/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/multiple-returns/input.c:38:nn: warning: memory leak: ob_refcnt of '*dictA' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/multiple-returns/input.c:32:nn: note: '*dictA' was allocated at:     dictA = PyDict_New();\ntests/cpychecker/refcounts/multiple-returns/input.c:38:nn: note: was expecting final owned ob_refcnt of '*dictA' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/multiple-returns/input.c:32:nn: note: when PyDict_New() succeeds at:     dictA = PyDict_New();\ntests/cpychecker/refcounts/multiple-returns/input.c:32:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/multiple-returns/input.c:33:nn: note: taking False path at:     if (!dictA) return NULL;\ntests/cpychecker/refcounts/multiple-returns/input.c:37:nn: note: reaching:     dictB = PyDict_New();\ntests/cpychecker/refcounts/multiple-returns/input.c:37:nn: note: when PyDict_New() fails at:     dictB = PyDict_New();\ntests/cpychecker/refcounts/multiple-returns/input.c:38:nn: note: taking True path at:     if (!dictB) return NULL;\ntests/cpychecker/refcounts/multiple-returns/input.c:38:nn: note: reaching:     if (!dictB) return NULL;\ntests/cpychecker/refcounts/multiple-returns/input.c:38:nn: note: returning\ntests/cpychecker/refcounts/multiple-returns/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/multiple-returns/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/multiple-returns/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37)) from tests/cpychecker/refcounts/multiple-returns/input.c:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/multiple-returns/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/multiple-returns/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/multiple-returns/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/multiple-returns/input.c:32'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37)) from tests/cpychecker/refcounts/multiple-returns/input.c:37\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=37), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/multiple-returns/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/multiple-returns/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/multiple-returns/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyDict_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/multiple-returns/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyDictObject allocated at tests/cpychecker/refcounts/multiple-returns/input.c:32:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=32))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/multiple-returns/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/multiple-returns/input.c:37\n\nTrace 3:\n  Transitions:\n    'when PyDict_New() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/multiple-returns/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/multiple-returns/input.c', line=28), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/multiple-returns/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/not_setting_exception/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n   Verify that the checker detects returning NULL without setting an exception\n*/\nPyObject *\nnot_setting_exception(PyObject *self, PyObject *args)\n{\n    /*\n       This is an error: we're returning NULL without the thread-local\n       exception state being set:\n    */\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  not_setting_exception, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/not_setting_exception/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/not_setting_exception/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/not_setting_exception/stderr.txt",
    "content": "In function 'not_setting_exception':\ntests/cpychecker/refcounts/not_setting_exception/input.c:32:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/not_setting_exception/input.c:32:nn: note: returning at:     return NULL;\ntests/cpychecker/refcounts/not_setting_exception/input.c:27:nn: note: graphical error report for function 'not_setting_exception' written out to 'tests/cpychecker/refcounts/not_setting_exception/input.c.not_setting_exception-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/not_setting_exception/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/not_setting_exception/input.c', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/not_setting_exception/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/not_setting_exception/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/not_setting_exception/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/not_setting_exception/input.c:27\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_from_callback/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Test of correct reference-handling when dealing with a callback that\n  constructs an object\n*/\n\nPyObject *\ntest(PyObject *(*ctor)(void))\n{\n    PyObject *dict = NULL;\n    PyObject *key = NULL;\n    PyObject *value = NULL;\n\n    dict = PyDict_New();\n    if (!dict) {\n\tgoto error;\n    }\n\n    key = PyLong_FromLong(500);\n    if (!key) {\n        goto error;\n    }\n\n    /*\n      Invoke the callback; the checker will assume that it follows normal\n      object ownership rules:\n    */\n    value = (*ctor)();\n    if (!value) {\n        /* should have set an exception */\n        goto error;\n    }\n\n    if (-1 == PyDict_SetItem(dict, key, value)) {\n        goto error;\n    }\n    /*\n       The successful call added refs on both \"key\" and \"value\", owned by the\n       dictionary.\n       We must now drop our references on them:\n    */\n    Py_DECREF(key);\n    Py_DECREF(value);\n\n    return dict;\n\n error:\n    Py_XDECREF(dict);\n    Py_XDECREF(key);\n    Py_XDECREF(value);\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_from_callback/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_from_callback/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() succeeds'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34)) from tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48), region=Region('PyTypeObject for new ref from call through function pointer'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34)) from tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48), region=Region('PyTypeObject for new ref from call through function pointer'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48), region=Region('PyTypeObject for new ref from call through function pointer'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 3:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 4:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48), region=Region('PyTypeObject for new ref from call through function pointer'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 5:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 6:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48), region=Region('PyTypeObject for new ref from call through function pointer'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 7:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 8:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48), region=Region('PyTypeObject for new ref from call through function pointer'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 9:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call succeeds'\n    'taking False path'\n    'when PyDict_SetItem() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48:\n    repr(): RegionOnHeap('new ref from call through function pointer', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=48))\n    str(): new ref from call through function pointer allocated at tests/cpychecker/refcounts/object_from_callback/input.c:48\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:54\n\nTrace 10:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:48\n\nTrace 11:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:48\n\nTrace 12:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:48\n\nTrace 13:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when call fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=39))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:39\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:48\n\nTrace 14:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyDict_Type')))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:39\n\nTrace 15:\n  Transitions:\n    'when PyDict_New() succeeds'\n    'taking False path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34:\n    repr(): RegionOnHeap('PyDictObject', gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=34))\n    str(): PyDictObject allocated at tests/cpychecker/refcounts/object_from_callback/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:39\n\nTrace 16:\n  Transitions:\n    'when PyDict_New() fails'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_from_callback/input.c', line=71), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/object_from_callback/input.c:71\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/object_from_callback/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_leak/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\nobject_leak(PyObject *self, PyObject *args)\n{\n    /* Buggy code: create an object: */\n    PyObject *tmp = PyLong_FromLong(0x1000);\n\n    /* Then throw it away, leaking the object (assuming the call succeeds) */\n    return NULL;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  object_leak, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_leak/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_leak/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main, get_traces\n\ndef verify_traces(optpass, fun):\n    # Only run in one pass\n    # FIXME: should we be adding our own pass for this?\n    if optpass.name == '*warn_function_return':\n        if fun:\n            traces = get_traces(fun)\n\n            # We should have two traces\n            # print('traces: %r' % traces)\n            assert len(traces) == 2\n\n            # Verify the \"success\" trace:\n            state = traces[0].states[-1]\n            print('Trace 0:')\n            print('  returned: %r' % state.return_rvalue)\n\n            # Verify the \"fail\" trace:\n            state = traces[1].states[-1]\n            print('Trace 1:')\n            print('  returned: %r' % state.return_rvalue)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      verify_traces)\n\nmain(verify_refcounting=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_leak/stderr.txt",
    "content": "In function 'object_leak':\ntests/cpychecker/refcounts/object_leak/input.c:29:nn: warning: memory leak: ob_refcnt of '*tmp' is 1 too high [enabled by default]\ntests/cpychecker/refcounts/object_leak/input.c:26:nn: note: '*tmp' was allocated at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/object_leak/input.c:29:nn: note: was expecting final owned ob_refcnt of '*tmp' to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/object_leak/input.c:26:nn: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/object_leak/input.c:26:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/object_leak/input.c:29:nn: note: returning at:     return NULL;\ntests/cpychecker/refcounts/object_leak/input.c:29:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/object_leak/input.c:26:nn: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/object_leak/input.c:29:nn: note: returning at:     return NULL;\ntests/cpychecker/refcounts/object_leak/input.c:24:nn: note: graphical error report for function 'object_leak' written out to 'tests/cpychecker/refcounts/object_leak/input.c.object_leak-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/object_leak/stdout.txt",
    "content": "Trace 0:\n  returned: ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_leak/input.c', line=29), value=0)\nTrace 1:\n  returned: ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/object_leak/input.c', line=29), value=0)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/passing_dead_object/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker warns about function calls that are passed\n  deallocated objects:\n*/\nextern void foo(PyObject *);\n\nvoid\npassing_dead_object_to_function(PyObject *self, PyObject *args)\n{\n    /* Create an object: */\n    PyObject *tmp = PyLong_FromLong(0x1000);\n\n    if (!tmp) {\n        return;\n    }\n\n    /*\n      Now decref the object.  Depending on what other references are owned\n      on the object, it can reach a refcount of zero, and thus be deallocated.\n    */\n    Py_DECREF(tmp);\n\n    /* This is an error: the object being returned may have been deallocated */\n    foo(tmp);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/passing_dead_object/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/passing_dead_object/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/passing_dead_object/stderr.txt",
    "content": "In function 'passing_dead_object_to_function':\ntests/cpychecker/refcounts/passing_dead_object/input.c:45:nn: warning: passing pointer to deallocated memory as argument 1 of function at tests/cpychecker/refcounts/passing_dead_object/input.c:45: memory deallocated at tests/cpychecker/refcounts/passing_dead_object/input.c:42 [enabled by default]\ntests/cpychecker/refcounts/passing_dead_object/input.c:32:nn: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/passing_dead_object/input.c:34:nn: note: taking False path at:     if (!tmp) {\ntests/cpychecker/refcounts/passing_dead_object/input.c:42:nn: note: reaching:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/passing_dead_object/input.c:42:nn: note: when taking False path at:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/passing_dead_object/input.c:42:nn: note: reaching:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/passing_dead_object/input.c:42:nn: note: calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/passing_dead_object/input.c:32 at:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/passing_dead_object/input.c:45:nn: note: reaching:     foo(tmp);\ntests/cpychecker/refcounts/passing_dead_object/input.c:30:nn: note: graphical error report for function 'passing_dead_object_to_function' written out to 'tests/cpychecker/refcounts/passing_dead_object/input.c.passing_dead_object_to_function-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/passing_dead_object/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/passing_dead_object/input.c:32:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=32))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/passing_dead_object/input.c:32\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=32), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/passing_dead_object/input.c:30\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/passing_dead_object/input.c:32'\n  error: PassingPointerToDeallocatedMemory()\n  error: passing pointer to deallocated memory as argument 1 of function at tests/cpychecker/refcounts/passing_dead_object/input.c:45: memory deallocated at tests/cpychecker/refcounts/passing_dead_object/input.c:42\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/passing_dead_object/input.c:32:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=32))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/passing_dead_object/input.c:32\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/passing_dead_object/input.c:30\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/passing_dead_object/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/passing_dead_object/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/returning_dead_object/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker warns about functions that return deallocated objects\n*/\nPyObject *\nreturning_dead_object(PyObject *self, PyObject *args)\n{\n    /* Create an object: */\n    PyObject *tmp = PyLong_FromLong(0x1000);\n\n    if (!tmp) {\n        return NULL;\n    }\n\n    /*\n      Now decref the object.  Depending on what other references are owned\n      on the object, it can reach a refcount of zero, and thus be deallocated.\n    */\n    Py_DECREF(tmp);\n\n    /* This is an error: the object being returned may have been deallocated */\n    return tmp;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  returning_dead_object, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/returning_dead_object/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/returning_dead_object/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/returning_dead_object/stderr.txt",
    "content": "In function 'returning_dead_object':\ntests/cpychecker/refcounts/returning_dead_object/input.c:42:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/returning_dead_object/input.c:29:nn: note: return value was allocated at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/returning_dead_object/input.c:42:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 0 owned\ntests/cpychecker/refcounts/returning_dead_object/input.c:29:nn: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/returning_dead_object/input.c:29:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/returning_dead_object/input.c:31:nn: note: taking False path at:     if (!tmp) {\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: reaching:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: ob_refcnt is now refs: 0 owned\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: when taking True path at:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/returning_dead_object/input.c:42:nn: note: reaching:     return tmp;\ntests/cpychecker/refcounts/returning_dead_object/input.c:42:nn: note: returning\ntests/cpychecker/refcounts/returning_dead_object/input.c:42:nn: warning: returning pointer to deallocated memory [enabled by default]\ntests/cpychecker/refcounts/returning_dead_object/input.c:29:nn: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/returning_dead_object/input.c:31:nn: note: taking False path at:     if (!tmp) {\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: reaching:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: when taking False path at:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: reaching:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/returning_dead_object/input.c:29 at:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/returning_dead_object/input.c:42:nn: note: reaching:     return tmp;\ntests/cpychecker/refcounts/returning_dead_object/input.c:42:nn: note: returning\ntests/cpychecker/refcounts/returning_dead_object/input.c:39:nn: note: memory deallocated here\ntests/cpychecker/refcounts/returning_dead_object/input.c:27:nn: note: graphical error report for function 'returning_dead_object' written out to 'tests/cpychecker/refcounts/returning_dead_object/input.c.returning_dead_object-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/returning_dead_object/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=29), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=29)) from tests/cpychecker/refcounts/returning_dead_object/input.c:29\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=29), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/returning_dead_object/input.c:27\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/returning_dead_object/input.c:29'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=29), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=29)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=29)) from tests/cpychecker/refcounts/returning_dead_object/input.c:29\n    r->ob_refcnt: None\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/returning_dead_object/input.c:27\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=32), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/returning_dead_object/input.c:32\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/returning_dead_object/input.c', line=26), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/returning_dead_object/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n      Test of a static local PyObject*\n    */\n    static PyObject *cache;\n\n    if (!cache) {\n        /*\n          This code is correct: if the call succeeds, we own a reference,\n          and that corresponds to the permanently stored ptr in \"cache\"\n          (permanent because it's \"static\")\n        */\n        cache = PyLong_FromLong(0x1000);\n        if (!cache) {\n            return NULL;\n        }\n    }\n\n    /* \n       Return a new reference to the cached value (which can't be NULL at this\n       point:\n    */\n    Py_INCREF(cache);\n    return cache;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:24 as non-NULL'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=30), region=Region('heap-region-0'))\n    str(): (struct PyObject *)&Region('heap-region-0') from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:30\n    r->ob_refcnt: (Py_ssize_t)val [-0x7fffffffffffffff <= val <= 0x7fffffffffffffff] from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:46\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:24\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:24 as NULL'\n    'taking True path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=36), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=36)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=36)) from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:36\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Region('heap-region-0'):\n    repr(): Region('heap-region-0')\n    str(): Region('heap-region-0')\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:24\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:24 as NULL'\n    'taking True path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/correct/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Region('heap-region-0'):\n    repr(): Region('heap-region-0')\n    str(): Region('heap-region-0')\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/storage_regions/static/correct/input.c:36\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    /*\n      Test of a static local PyObject*\n    */\n    static PyObject *cache;\n\n    if (!cache) {\n        /*\n          If the call succeeds, we own a reference, and that corresponds to\n          the permanently stored ptr in \"cache\" (permanent because it's\n          \"static\")\n        */\n        cache = PyLong_FromLong(0x1000);\n        if (!cache) {\n            return NULL;\n        }\n    }\n\n    /* \n       Return a new reference to the cached value which can't be NULL at this\n       point.\n\n       However, this code is incorrect: it doesn't Py_INCREF(cache), and thus\n       the refcount is too low:\n    */\n    return cache;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/incorrect/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/incorrect/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/incorrect/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:49:nn: warning: future use-after-free: ob_refcnt of return value is 1 too low [enabled by default]\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:36:nn: note: return value was allocated at:         cache = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:49:nn: note: was expecting final owned ob_refcnt of return value to be 2 due to object being referenced by: return value, cache but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:30:nn: note: when treating unknown struct PyObject * from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:24 as NULL at:     if (!cache) {\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:30:nn: note: taking True path at:     if (!cache) {\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:36:nn: note: reaching:         cache = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:36:nn: note: when PyLong_FromLong() succeeds at:         cache = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:36:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:36:nn: note: return value is now referenced by 1 non-stack value(s): cache\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:37:nn: note: taking False path at:         if (!cache) {\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:49:nn: note: reaching:     return cache;\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:49:nn: note: returning\ntests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:24:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/storage_regions/static/incorrect/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:24 as non-NULL'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=30), region=Region('heap-region-0'))\n    str(): (struct PyObject *)&Region('heap-region-0') from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:30\n    r->ob_refcnt: None\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:24\n\nTrace 1:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:24 as NULL'\n    'taking True path'\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=36), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=36)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=36)) from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:36\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=36), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:24\n\nTrace 2:\n  Transitions:\n    'when treating unknown struct PyObject * from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:24 as NULL'\n    'taking True path'\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/storage_regions/static/incorrect/input.c:36\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/detection/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can detect PyObject subclasses\n*/\n\n/* The checker should treat this as a PyObject subclass */\nstruct FooObject {\n    PyObject_HEAD\n    int i;\n};\n\n/* Likewise */\nstruct BarObject {\n    PyObject_VAR_HEAD\n    char *str;\n};\n\n/* Likewise */\nstruct BazObject {\n    struct FooObject baz_head;\n    int baz_int;\n};\n\n/* This isn't one: */\nstruct NotAnObject {\n    PyObject *array[10];\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/detection/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import get_global_typedef\n\n# Verify that this function works:\nfrom libcpychecker.refcounts import type_is_pyobjptr_subclass\n\ndef get_struct(tagname):\n    for u in gcc.get_translation_units():\n        for v in u.block.vars:\n            if isinstance(v, gcc.TypeDecl):\n                if isinstance(v.type, gcc.RecordType):\n                    if isinstance(v.type.name, gcc.IdentifierNode):\n                        if v.type.name.name == tagname:\n                            return v.type\n\ndef check_type(t):\n    print('type: %s' % t)\n    print('  is PyObject* subclass?: %s\\n' % type_is_pyobjptr_subclass(t))\n\ndef check_typedef(typedef):\n    print('typedef: %r' % typedef)\n    decl = get_global_typedef(typedef)\n    ptr_type = decl.type.pointer\n    print('  ptr_type: %s' % ptr_type)\n    print('  is PyObject* subclass?: %s\\n' % type_is_pyobjptr_subclass(ptr_type))\n\ndef check_struct(typename):\n    print('typename: %r' % typename)\n    struct_type = get_struct(typename)\n    print('  struct_type: %s' % struct_type)\n    ptr_type = struct_type.pointer\n    print('  ptr_type: %s' % ptr_type)\n    print('  is PyObject* subclass?: %s\\n' % type_is_pyobjptr_subclass(ptr_type))\n\ndef on_pass_execution(p, fn):\n    if p.name == '*free_lang_data':\n        # The '*free_lang_data' pass is called once, rather than per-function,\n        # and occurs immediately after \"*build_cgraph_edges\", which is the\n        # pass that initially builds the callgraph\n        #\n        # So at this point we're likely to get a good view of the types:\n        check_type(gcc.Type.int())\n        check_type(gcc.Type.char().pointer)\n        check_typedef('PyObject')\n        check_typedef('PyTypeObject')\n        check_struct('FooObject')\n        check_struct('BarObject')\n        check_struct('BazObject')\n        check_struct('NotAnObject')\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/detection/stdout.txt",
    "content": "type: int\n  is PyObject* subclass?: False\n\ntype: char *\n  is PyObject* subclass?: False\n\ntypedef: 'PyObject'\n  ptr_type: struct PyObject *\n  is PyObject* subclass?: True\n\ntypedef: 'PyTypeObject'\n  ptr_type: struct PyTypeObject *\n  is PyObject* subclass?: True\n\ntypename: 'FooObject'\n  struct_type: struct FooObject\n  ptr_type: struct FooObject *\n  is PyObject* subclass?: True\n\ntypename: 'BarObject'\n  struct_type: struct BarObject\n  ptr_type: struct BarObject *\n  is PyObject* subclass?: True\n\ntypename: 'BazObject'\n  struct_type: struct BazObject\n  ptr_type: struct BazObject *\n  is PyObject* subclass?: True\n\ntypename: 'NotAnObject'\n  struct_type: struct NotAnObject\n  ptr_type: struct NotAnObject *\n  is PyObject* subclass?: False\n\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/handling/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can cope with PyObject subclasses\n*/\n\n/* The checker should treat this as a PyObject subclass */\nstruct FooObject {\n    PyObject_HEAD\n    int i;\n};\n\n/*\n  The checker should make assumptions that \"self\" is sane\n  i.e. non-NULL, has a sane ob_type, etc:\n*/\nPyObject *\ntest_function(struct FooObject *self, PyObject *args)\n{\n    return PyString_FromFormat(\"%s()\",\n                               Py_TYPE(self)->tp_name);\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  (PyCFunction)test_function, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/handling/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/handling/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyString_FromFormat() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=39), region=RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=39)))\n    str(): (struct PyObject *)&RegionOnHeap('PyStringObject', gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=39)) from tests/cpychecker/refcounts/subclass/handling/input.c:39\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=39), region=RegionForGlobal(gcc.VarDecl('PyString_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=37), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=37), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/subclass/handling/input.c:38\n\nTrace 1:\n  Transitions:\n    'when PyString_FromFormat() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=39), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/subclass/handling/input.c:39\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=37), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/handling/input.c', line=37), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/subclass/handling/input.c:39\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker detects reference-count errors on PyObject\n  subclasses where the object is referred to via a subclass pointer,\n  and where the subclass embeds ob_refcnt and ob_type only indirectly\n*/\n\n/* The checker should treat this as a PyObject subclass */\nstruct FooObject {\n    PyObject_HEAD\n    int i;\n};\n\n/* The checker should treat this as a PyObject subclass also: */\nstruct BarObject {\n    struct FooObject ba_head;\n    int  ba_int;\n    char ba_char;\n};\n\nvoid\ntest_function(struct BarObject *self)\n{\n    /*\n      The checker ought to check the refcount of self, and complain that it\n      erroneously gains 5 references:\n    */\n    Py_INCREF(self);\n    Py_INCREF(self);\n    Py_INCREF(self);\n    Py_INCREF(self);\n    Py_INCREF(self);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/stderr.txt",
    "content": "In function 'test_function':\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:53:nn: warning: memory leak: ob_refcnt of '*self' is 5 too high [enabled by default]\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:53:nn: note: was expecting final owned ob_refcnt of '*self' to be 0 since nothing references it but final ob_refcnt is refs: 5 owned, 1 borrowed\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:48:nn: note: ob_refcnt is now refs: 1 owned, 1 borrowed\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:49:nn: note: ob_refcnt is now refs: 2 owned, 1 borrowed\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:50:nn: note: ob_refcnt is now refs: 3 owned, 1 borrowed\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:51:nn: note: ob_refcnt is now refs: 4 owned, 1 borrowed\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:52:nn: note: ob_refcnt is now refs: 5 owned, 1 borrowed\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:53:nn: note: returning at: }\ntests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:43:nn: note: graphical error report for function 'test_function' written out to 'tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c.test_function-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 5 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c', line=42), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/subclass/incorrect-subclass-ptr/input.c:43\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/opaque-struct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can cope with an opaque struct\n*/\ntypedef struct _sometype SomeType;\n\nvoid\ntest(SomeType *foo)\n{\n    /* empty */\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/opaque-struct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/subclass/opaque-struct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/subclass/opaque-struct/input.c:29\n"
  },
  {
    "path": "tests/cpychecker/refcounts/ticket-20/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n\n/*\n  https://fedorahosted.org/gcc-python-plugin/ticket/20\n\n  Traceback occurs when a function has a PyObject* with too low a refcount,\n  when returning a non-PyObject*:\n*/\nint\ntest(PyObject *self)\n{\n    /* this leads to the reference count being to low: */\n    Py_DECREF(self);\n\n    /* not a PyObject*, triggering the traceback */\n    return 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/ticket-20/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/ticket-20/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/ticket-20/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/ticket-20/input.c:36:nn: warning: future use-after-free: ob_refcnt of '*self' is 1 too low [enabled by default]\ntests/cpychecker/refcounts/ticket-20/input.c:36:nn: note: was expecting final owned ob_refcnt of '*self' to be 0 since nothing references it but final ob_refcnt is refs: -1 owned, 1 borrowed\ntests/cpychecker/refcounts/ticket-20/input.c:33:nn: note: ob_refcnt is now refs: -1 owned, 1 borrowed\ntests/cpychecker/refcounts/ticket-20/input.c:33:nn: note: when taking True path at:     Py_DECREF(self);\ntests/cpychecker/refcounts/ticket-20/input.c:36:nn: note: reaching:     return 0;\ntests/cpychecker/refcounts/ticket-20/input.c:36:nn: note: returning at:     return 0;\ntests/cpychecker/refcounts/ticket-20/input.c:36:nn: note: found 1 similar trace(s) to this\ntests/cpychecker/refcounts/ticket-20/input.c:31:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/ticket-20/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/ticket-20/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/ticket-20/input.c', line=36), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/ticket-20/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/ticket-20/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/ticket-20/input.c:31\n\nTrace 1:\n  Transitions:\n    'when taking False path'\n    'calling unknown void (*destructor) (struct PyObject *) from tests/cpychecker/refcounts/ticket-20/input.c:33'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/ticket-20/input.c', line=36), value=0)\n    str(): (int)0 from tests/cpychecker/refcounts/ticket-20/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: -1 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/ticket-20/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/ticket-20/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/too_many_increfs/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\nPyObject *\ntoo_many_increfs(PyObject *self, PyObject *args)\n{\n    PyObject *tmp;\n    tmp = PyLong_FromLong(0x1000);\n\n    /* This INCREF is redundant, and introduces a leak (or a read through\n       NULL): */\n    Py_INCREF(tmp);\n    return tmp;\n}\n\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  too_many_increfs, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n"
  },
  {
    "path": "tests/cpychecker/refcounts/too_many_increfs/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/too_many_increfs/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/too_many_increfs/stderr.txt",
    "content": "In function 'too_many_increfs':\ntests/cpychecker/refcounts/too_many_increfs/input.c:31:nn: warning: memory leak: ob_refcnt of return value is 1 too high [enabled by default]\ntests/cpychecker/refcounts/too_many_increfs/input.c:26:nn: note: return value was allocated at:     tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/too_many_increfs/input.c:31:nn: note: was expecting final owned ob_refcnt of return value to be 1 due to object being referenced by: return value but final ob_refcnt is refs: 2 owned\ntests/cpychecker/refcounts/too_many_increfs/input.c:26:nn: note: when PyLong_FromLong() succeeds at:     tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/too_many_increfs/input.c:26:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/too_many_increfs/input.c:30:nn: note: ob_refcnt is now refs: 2 owned\ntests/cpychecker/refcounts/too_many_increfs/input.c:31:nn: note: returning at:     return tmp;\ntests/cpychecker/refcounts/too_many_increfs/input.c:30:nn: warning: dereferencing NULL (tmp->ob_refcnt) at tests/cpychecker/refcounts/too_many_increfs/input.c:30 [enabled by default]\ntests/cpychecker/refcounts/too_many_increfs/input.c:26:nn: note: when PyLong_FromLong() fails at:     tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/too_many_increfs/input.c:24:nn: note: graphical error report for function 'too_many_increfs' written out to 'tests/cpychecker/refcounts/too_many_increfs/input.c.too_many_increfs-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/too_many_increfs/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=26), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=26)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=26)) from tests/cpychecker/refcounts/too_many_increfs/input.c:26\n    r->ob_refcnt: refs: 2 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=26), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/too_many_increfs/input.c:24\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() fails'\n  error: NullPtrDereference()\n  error: dereferencing NULL (tmp->ob_refcnt) at tests/cpychecker/refcounts/too_many_increfs/input.c:30\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/too_many_increfs/input.c', line=23), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/too_many_increfs/input.c:26\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  tp_iternext callbacks are allowed to returns NULL without setting an\n  exception.\n\n  Verify that the checker doesn't warn about such a case\n*/\nPyObject *\ntest(PyObject *iter)\n{\n    return NULL;\n}\n\nstatic PyTypeObject test_type = {\n    .tp_iternext = test,\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/correct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/correct/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/tp_iternext/correct/input.c', line=31), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/tp_iternext/correct/input.c:31\n  region for gcc.ParmDecl('iter') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('iter')\")\n    str(): region for gcc.ParmDecl('iter') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/tp_iternext/correct/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('iter')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/tp_iternext/correct/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  tp_iternext callbacks are allowed to returns NULL without setting an\n  exception.\n\n  Verify that the logic for this doesn't croak on a PyTypeObject that\n  doesn't have an initializer for tp_iternext\n*/\nPyObject *\ntest(PyObject *obj)\n{\n    /* The checker ought to report on the lack of an exception: */\n    return NULL;\n}\n\nstatic PyTypeObject test_type = {\n    /*\n      empty initializer; in particular, lacking an initializer\n      for tp_iternext\n    */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/partial-type-object/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/partial-type-object/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/partial-type-object/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c:33:nn: warning: returning (PyObject*)NULL without setting an exception [enabled by default]\ntests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c:33:nn: note: returning at:     return NULL;\ntests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c:31:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/tp_iternext/partial-type-object/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c:33\n  region for gcc.ParmDecl('obj') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('obj')\")\n    str(): region for gcc.ParmDecl('obj') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c', line=30), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('obj')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/tp_iternext/partial-type-object/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/comparison/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can cope with various incorrect actions on an\n  uninitialized pointer\n*/\n\nPyObject *\ntest(int len)\n{\n    PyObject *result = NULL;\n    PyObject *item; /* never initialized */\n    int i;\n    \n    result = PyList_New(len);\n    if (!result) {\n\tgoto error;\n    }\n\n    for (i = 0; i < len; i++) {\n        /* Erroneous comparison against uninitialized data: */\n\tif (!item) {\n\t    goto error;\n\t}\n        /* Erroneous call using uninitialized data: */\n\tPyList_SetItem(result, i, item);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/comparison/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/comparison/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/comparison/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:41:nn: warning: comparison against uninitialized data (item) at tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:41 [enabled by default]\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:34:nn: note: when PyList_New() succeeds at:     result = PyList_New(len);\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:35:nn: note: taking False path at:     if (!result) {\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:39:nn: note: reaching:     for (i = 0; i < len; i++) {\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:39:nn: note: when considering range: 1 <= len <= 0x7fffffff at:     for (i = 0; i < len; i++) {\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:39:nn: note: taking True path at:     for (i = 0; i < len; i++) {\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:41:nn: note: reaching: \tif (!item) {\ntests/cpychecker/refcounts/uninitialized_data/comparison/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/uninitialized_data/comparison/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/comparison/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: -0x80000000 <= len <= 0'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/comparison/input.c', line=34), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/comparison/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/comparison/input.c', line=34)) from tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/comparison/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= len <= 0x7fffffff'\n    'taking True path'\n  error: UsageOfUninitializedData()\n  error: comparison against uninitialized data (item) at tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:41\n  PyListObject allocated at tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/comparison/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/comparison/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/comparison/input.c', line=52), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:52\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/uninitialized_data/comparison/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker can cope with various incorrect actions on an\n  uninitialized pointer\n*/\n\nPyObject *\ntest(int len)\n{\n    PyObject *result = NULL;\n    PyObject *item; /* never initialized */\n    int i;\n    \n    result = PyList_New(len);\n    if (!result) {\n\tgoto error;\n    }\n\n    for (i = 0; i < len; i++) {\n        /* Erroneous call using uninitialized data: */\n\tPyList_SetItem(result, i, item);\n    }\n\n    return result;\n\n error:\n    Py_XDECREF(result);\n    return NULL;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/function_arg/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/function_arg/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/function_arg/stderr.txt",
    "content": "In function 'test':\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:41:nn: warning: passing uninitialized data (item) as argument 3 to function at tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:41 [enabled by default]\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:34:nn: note: when PyList_New() succeeds at:     result = PyList_New(len);\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:35:nn: note: taking False path at:     if (!result) {\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:39:nn: note: reaching:     for (i = 0; i < len; i++) {\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:39:nn: note: when considering range: 1 <= len <= 0x7fffffff at:     for (i = 0; i < len; i++) {\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:39:nn: note: taking True path at:     for (i = 0; i < len; i++) {\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:41:nn: note: reaching: \tPyList_SetItem(result, i, item);\ntests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:29:nn: note: graphical error report for function 'test' written out to 'tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c.test-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/uninitialized_data/function_arg/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: -0x80000000 <= len <= 0'\n    'taking False path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c', line=34), region=RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c', line=34)))\n    str(): (struct PyObject *)&RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c', line=34)) from tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:29\n\nTrace 1:\n  Transitions:\n    'when PyList_New() succeeds'\n    'taking False path'\n    'when considering range: 1 <= len <= 0x7fffffff'\n    'taking True path'\n  error: UsageOfUninitializedData()\n  error: passing uninitialized data (item) as argument 3 to function at tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:41\n  PyListObject allocated at tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:34:\n    repr(): RegionOnHeap('PyListObject', gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c', line=34))\n    str(): PyListObject allocated at tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:34\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c', line=34), region=RegionForGlobal(gcc.VarDecl('PyList_Type')))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:29\n\nTrace 2:\n  Transitions:\n    'when PyList_New() fails'\n    'taking True path'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c', line=48), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:48\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/uninitialized_data/function_arg/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Ensure that the checker can cope with calls to a function that it doesn't\n  recognize:\n*/\nextern PyObject *foo(int i);\n\nPyObject *\ncall_to_unrecognized_function(PyObject *self, PyObject *args)\n{\n    PyObject *result = foo(42);\n    return result;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  call_to_unrecognized_function, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when foo() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=31), region=RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=31)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=31)) from tests/cpychecker/refcounts/unrecognized_function/input.c:31\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=31), region=Region('PyTypeObject for new ref from (unknown) foo'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function/input.c:30\n\nTrace 1:\n  Transitions:\n    'when foo() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=31), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function/input.c:31\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/unrecognized_function/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function2/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Ensure that the checker can cope with calls to a function that it doesn't\n  recognize:\n*/\nextern PyObject *foo(int i);\n\nPyObject *\ncall_to_unrecognized_function(PyObject *self, PyObject *args)\n{\n    PyObject *tmp;\n\n    /* Call an unrecognized function: */\n    tmp = foo(42);\n    if (!tmp) {\n        return NULL;\n    }\n\n    /* Verify that tp_dealloc is sane: */\n    Py_DECREF(tmp);\n\n    /* Now do it again, to get a sane return value: */\n    return foo(42);\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  call_to_unrecognized_function, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function2/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function2/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when foo() succeeds'\n    'taking False path'\n    'when taking True path'\n    'when foo() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43), region=RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43)) from tests/cpychecker/refcounts/unrecognized_function2/input.c:43\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43), region=Region('PyTypeObject for new ref from (unknown) foo'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34:\n    repr(): RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=34))\n    str(): new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=34), region=Region('PyTypeObject for new ref from (unknown) foo'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function2/input.c:30\n\nTrace 1:\n  Transitions:\n    'when foo() succeeds'\n    'taking False path'\n    'when taking True path'\n    'when foo() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function2/input.c:43\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34:\n    repr(): RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=34))\n    str(): new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=34), region=Region('PyTypeObject for new ref from (unknown) foo'))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/unrecognized_function2/input.c:43\n\nTrace 2:\n  Transitions:\n    'when foo() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34'\n    'when foo() succeeds'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43), region=RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43)))\n    str(): (struct PyObject *)&RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43)) from tests/cpychecker/refcounts/unrecognized_function2/input.c:43\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43), region=Region('PyTypeObject for new ref from (unknown) foo'))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34:\n    repr(): RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=34))\n    str(): new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function2/input.c:30\n\nTrace 3:\n  Transitions:\n    'when foo() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34'\n    'when foo() fails'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=43), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function2/input.c:43\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34:\n    repr(): RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=34))\n    str(): new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function2/input.c:34\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/unrecognized_function2/input.c:43\n\nTrace 4:\n  Transitions:\n    'when foo() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=36), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function2/input.c:36\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function2/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/unrecognized_function2/input.c:34\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function3/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Ensure that the checker can cope with calls to a function that it doesn't\n  recognize, in which the return value is discarded:\n*/\nextern PyObject *foo(int i);\n\nvoid\ncall_to_unrecognized_function(PyObject *self, PyObject *args)\n{\n    /* Discard the result (leaking it if the call succeeds): */\n    foo(42);\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function3/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function3/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function3/stderr.txt",
    "content": "In function 'call_to_unrecognized_function':\ntests/cpychecker/refcounts/unrecognized_function3/input.c:33:nn: warning: memory leak: ob_refcnt of new ref from (unknown) foo is 1 too high [enabled by default]\ntests/cpychecker/refcounts/unrecognized_function3/input.c:32:nn: note: new ref from (unknown) foo was allocated at:     foo(42);\ntests/cpychecker/refcounts/unrecognized_function3/input.c:33:nn: note: was expecting final owned ob_refcnt of new ref from (unknown) foo to be 0 since nothing references it but final ob_refcnt is refs: 1 owned\ntests/cpychecker/refcounts/unrecognized_function3/input.c:32:nn: note: when foo() succeeds at:     foo(42);\ntests/cpychecker/refcounts/unrecognized_function3/input.c:32:nn: note: ob_refcnt is now refs: 1 owned\ntests/cpychecker/refcounts/unrecognized_function3/input.c:33:nn: note: returning at: }\ntests/cpychecker/refcounts/unrecognized_function3/input.c:30:nn: note: graphical error report for function 'call_to_unrecognized_function' written out to 'tests/cpychecker/refcounts/unrecognized_function3/input.c.call_to_unrecognized_function-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function3/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when foo() succeeds'\n    'returning'\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function3/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function3/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function3/input.c:32:\n    repr(): RegionOnHeap('new ref from (unknown) foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function3/input.c', line=32))\n    str(): new ref from (unknown) foo allocated at tests/cpychecker/refcounts/unrecognized_function3/input.c:32\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function3/input.c', line=32), region=Region('PyTypeObject for new ref from (unknown) foo'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function3/input.c:30\n\nTrace 1:\n  Transitions:\n    'when foo() fails'\n    'returning'\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function3/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function3/input.c', line=29), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/unrecognized_function3/input.c:32\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function4/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Ensure that the checker can cope with calls to a function that it doesn't\n  recognize that returns a PyObject subclass:\n*/\ntypedef struct FooObject {\n    PyObject_HEAD\n    int i;\n} FooObject;\n\nextern FooObject *make_foo(int i);\n\nPyObject *\ntest(PyObject *self, PyObject *args)\n{\n    FooObject *f = make_foo(42);\n    if (NULL == f) {\n        return NULL; /* we assume an exception was set by make_foo() */\n    }\n    Py_DECREF(f);\n\n    Py_RETURN_NONE;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function4/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain(verify_refcounting=True,\n     dump_traces=True,\n     show_traces=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/unrecognized_function4/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when make_foo() succeeds'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=42), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/unrecognized_function4/input.c:42\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=34), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=34), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) make_foo allocated at tests/cpychecker/refcounts/unrecognized_function4/input.c:36:\n    repr(): RegionOnHeap('new ref from (unknown) make_foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=36))\n    str(): new ref from (unknown) make_foo allocated at tests/cpychecker/refcounts/unrecognized_function4/input.c:36\n    r->ob_refcnt: refs: 0 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=36), region=Region('PyTypeObject for new ref from (unknown) make_foo'))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function4/input.c:35\n\nTrace 1:\n  Transitions:\n    'when make_foo() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on new ref from (unknown) make_foo allocated at tests/cpychecker/refcounts/unrecognized_function4/input.c:36'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=42), region=RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')))\n    str(): (struct PyObject *)&RegionForGlobal(gcc.VarDecl('_Py_NoneStruct')) from tests/cpychecker/refcounts/unrecognized_function4/input.c:42\n    r->ob_refcnt: refs: 1 owned, 1 borrowed\n    r->ob_type: None\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=34), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=34), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  new ref from (unknown) make_foo allocated at tests/cpychecker/refcounts/unrecognized_function4/input.c:36:\n    repr(): RegionOnHeap('new ref from (unknown) make_foo', gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=36))\n    str(): new ref from (unknown) make_foo allocated at tests/cpychecker/refcounts/unrecognized_function4/input.c:36\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function4/input.c:35\n\nTrace 2:\n  Transitions:\n    'when make_foo() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=38), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/unrecognized_function4/input.c:38\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=34), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/unrecognized_function4/input.c', line=34), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/unrecognized_function4/input.c:36\n"
  },
  {
    "path": "tests/cpychecker/refcounts/use_after_dealloc/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <Python.h>\n\n/*\n  Verify that the checker warns about attempts to use an object\n  after it might have been deallocated\n*/\nPyObject *\nuse_after_dealloc(PyObject *self, PyObject *args)\n{\n    /* Create an object: */\n    PyObject *tmp = PyLong_FromLong(0x1000);\n\n    if (!tmp) {\n        return NULL;\n    }\n\n    /*\n      Now decref then incref the object.  The object reaches a refcount\n      of zero, and thus is deallocated; and the subsequent INCREF is\n      accessing that deallocated memory:\n    */\n    Py_DECREF(tmp);\n    Py_INCREF(tmp);\n\n    /* This is an error: the object being returned has been deallocated */\n    return tmp;\n}\nstatic PyMethodDef test_methods[] = {\n    {\"test_method\",  use_after_dealloc, METH_VARARGS, NULL},\n    {NULL, NULL, 0, NULL} /* Sentinel */\n};\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/use_after_dealloc/metadata.ini",
    "content": "[ExpectedBehavior]\n# We expect only compilation *warnings*, so we expect a 0 exit code\nexitcode = 0\n"
  },
  {
    "path": "tests/cpychecker/refcounts/use_after_dealloc/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     show_traces=False,\n     dump_traces=True)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/use_after_dealloc/stderr.txt",
    "content": "In function 'use_after_dealloc':\ntests/cpychecker/refcounts/use_after_dealloc/input.c:42:nn: warning: reading from deallocated memory at tests/cpychecker/refcounts/use_after_dealloc/input.c:42: memory deallocated at tests/cpychecker/refcounts/use_after_dealloc/input.c:41 [enabled by default]\ntests/cpychecker/refcounts/use_after_dealloc/input.c:30:nn: note: when PyLong_FromLong() succeeds at:     PyObject *tmp = PyLong_FromLong(0x1000);\ntests/cpychecker/refcounts/use_after_dealloc/input.c:32:nn: note: taking False path at:     if (!tmp) {\ntests/cpychecker/refcounts/use_after_dealloc/input.c:41:nn: note: reaching:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/use_after_dealloc/input.c:41:nn: note: when taking False path at:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/use_after_dealloc/input.c:41:nn: note: reaching:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/use_after_dealloc/input.c:41:nn: note: calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/use_after_dealloc/input.c:30 at:     Py_DECREF(tmp);\ntests/cpychecker/refcounts/use_after_dealloc/input.c:42:nn: note: reaching:     Py_INCREF(tmp);\ntests/cpychecker/refcounts/use_after_dealloc/input.c:28:nn: note: graphical error report for function 'use_after_dealloc' written out to 'tests/cpychecker/refcounts/use_after_dealloc/input.c.use_after_dealloc-refcount-errors.html'\n"
  },
  {
    "path": "tests/cpychecker/refcounts/use_after_dealloc/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): PointerToRegion(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=30), region=RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=30)))\n    str(): (struct PyObject *)&RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=30)) from tests/cpychecker/refcounts/use_after_dealloc/input.c:30\n    r->ob_refcnt: refs: 1 owned\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=30), region=RegionForGlobal(gcc.VarDecl('PyLong_Type')))\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/use_after_dealloc/input.c:28\n\nTrace 1:\n  Transitions:\n    'when PyLong_FromLong() succeeds'\n    'taking False path'\n    'when taking False path'\n    'calling tp_dealloc on PyLongObject allocated at tests/cpychecker/refcounts/use_after_dealloc/input.c:30'\n  error: ReadFromDeallocatedMemory()\n  error: reading from deallocated memory at tests/cpychecker/refcounts/use_after_dealloc/input.c:42: memory deallocated at tests/cpychecker/refcounts/use_after_dealloc/input.c:41\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  PyLongObject allocated at tests/cpychecker/refcounts/use_after_dealloc/input.c:30:\n    repr(): RegionOnHeap('PyLongObject', gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=30))\n    str(): PyLongObject allocated at tests/cpychecker/refcounts/use_after_dealloc/input.c:30\n    r->ob_refcnt: None\n    r->ob_type: None\n  Exception:\n    (struct PyObject *)0 from tests/cpychecker/refcounts/use_after_dealloc/input.c:28\n\nTrace 2:\n  Transitions:\n    'when PyLong_FromLong() fails'\n    'taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='struct PyObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=33), value=0)\n    str(): (struct PyObject *)0 from tests/cpychecker/refcounts/use_after_dealloc/input.c:33\n  region for gcc.ParmDecl('self') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('self')\")\n    str(): region for gcc.ParmDecl('self') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('self')\"))\n  region for gcc.ParmDecl('args') on stack:\n    repr(): RegionOnStack(\"region for gcc.ParmDecl('args')\")\n    str(): region for gcc.ParmDecl('args') on stack\n    r->ob_refcnt: refs: 0 owned, 1 borrowed\n    r->ob_type: PointerToRegion(gcctype='struct PyTypeObject *', loc=gcc.Location(file='tests/cpychecker/refcounts/use_after_dealloc/input.c', line=27), region=Region(\"region-for-type-of-arg-gcc.ParmDecl('args')\"))\n  Exception:\n    (struct PyObject *)&RegionForGlobal(gcc.VarDecl('PyExc_MemoryError')) from tests/cpychecker/refcounts/use_after_dealloc/input.c:30\n"
  },
  {
    "path": "tests/cpychecker/refcounts/without-python-headers/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Verify that the cpychecker code can successfully run on code that doesn't\n  include Python's headers\n*/\n\nint\ntest(int i, int j)\n{\n    if (i < j) {\n        return 42;\n    } else {\n        return 43;\n    }\n}\n\n/*\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/cpychecker/refcounts/without-python-headers/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\n\nmain(verify_refcounting=True,\n     dump_traces=True,\n     only_on_python_code=False)\n"
  },
  {
    "path": "tests/cpychecker/refcounts/without-python-headers/stdout.txt",
    "content": "Trace 0:\n  Transitions:\n    'when taking True path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/without-python-headers/input.c', line=29), value=42)\n    str(): (int)42 from tests/cpychecker/refcounts/without-python-headers/input.c:29\n\nTrace 1:\n  Transitions:\n    'when taking False path'\n    'returning'\n  Return value:\n    repr(): ConcreteValue(gcctype='int', loc=gcc.Location(file='tests/cpychecker/refcounts/without-python-headers/input.c', line=31), value=43)\n    str(): (int)43 from tests/cpychecker/refcounts/without-python-headers/input.c:31\n"
  },
  {
    "path": "tests/cpychecker/unknown-function/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nextern int bar(int);\n\nint foo(int i)\n{\n    if (bar(i)) {\n        return i;\n    } else {\n        return -i;\n    }\n}\n"
  },
  {
    "path": "tests/cpychecker/unknown-function/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nfrom libcpychecker import main\nmain()\n"
  },
  {
    "path": "tests/examples/attributes/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Test of adding custom attributes */\n\n/* Function declarations with custom attributes: */\nextern some_function(void) __attribute__((claims_mutex(\"io\")));\n\nextern some_other_function(void) __attribute__((releases_mutex(\"io\")));\n\nextern yet_another_function(void) __attribute__((claims_mutex(\"db\"),\n                                                 claims_mutex(\"io\"),\n                                                 releases_mutex(\"io\")));\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/examples/attributes/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Verify that we can register custom attributes:\n\ndef attribute_callback_for_claims_mutex(*args):\n    print('attribute_callback_for_claims_mutex called: args: %s' % (args, ))\n\ndef attribute_callback_for_releases_mutex(*args):\n    print('attribute_callback_for_releases_mutex called: args: %s' % (args, ))\n\ndef register_our_attributes():\n    gcc.register_attribute('claims_mutex',\n                           1, 1,\n                           False, False, False,\n                           attribute_callback_for_claims_mutex)\n    gcc.register_attribute('releases_mutex',\n                           1, 1,\n                           False, False, False,\n                           attribute_callback_for_releases_mutex)\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_ATTRIBUTES,\n                      register_our_attributes)\n\n"
  },
  {
    "path": "tests/examples/attributes/stdout.txt",
    "content": "attribute_callback_for_claims_mutex called: args: (gcc.FunctionDecl('some_function'), gcc.StringCst('io'))\nattribute_callback_for_releases_mutex called: args: (gcc.FunctionDecl('some_other_function'), gcc.StringCst('io'))\nattribute_callback_for_claims_mutex called: args: (gcc.FunctionDecl('yet_another_function'), gcc.StringCst('db'))\nattribute_callback_for_claims_mutex called: args: (gcc.FunctionDecl('yet_another_function'), gcc.StringCst('io'))\nattribute_callback_for_releases_mutex called: args: (gcc.FunctionDecl('yet_another_function'), gcc.StringCst('io'))\n"
  },
  {
    "path": "tests/examples/attributes-with-macros/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Test of adding custom attributes */\n\n#if defined(WITH_ATTRIBUTE_CLAIMS_MUTEX)\n #define CLAIMS_MUTEX(x) __attribute__((claims_mutex(x)))\n#else\n #define CLAIMS_MUTEX(x)\n#endif\n\n#if defined(WITH_ATTRIBUTE_RELEASES_MUTEX)\n #define RELEASES_MUTEX(x) __attribute__((releases_mutex(x)))\n#else\n #define RELEASES_MUTEX(x)\n#endif\n\n\n/* Function declarations with custom attributes: */\nextern void some_function(void)\n    CLAIMS_MUTEX(\"io\");\n\nextern void some_other_function(void)\n    RELEASES_MUTEX(\"io\");\n\nextern void yet_another_function(void)\n    CLAIMS_MUTEX(\"db\")\n    CLAIMS_MUTEX(\"io\")\n    RELEASES_MUTEX(\"io\");\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/examples/attributes-with-macros/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\ndef attribute_callback_for_claims_mutex(*args):\n    print('attribute_callback_for_claims_mutex called: args: %s' % (args, ))\n\ndef attribute_callback_for_releases_mutex(*args):\n    print('attribute_callback_for_releases_mutex called: args: %s' % (args, ))\n\ndef register_our_attributes():\n    gcc.register_attribute('claims_mutex',\n                           1, 1,\n                           False, False, False,\n                           attribute_callback_for_claims_mutex)\n    gcc.define_macro('WITH_ATTRIBUTE_CLAIMS_MUTEX')\n\n    gcc.register_attribute('releases_mutex',\n                           1, 1,\n                           False, False, False,\n                           attribute_callback_for_releases_mutex)\n    gcc.define_macro('WITH_ATTRIBUTE_RELEASES_MUTEX')\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_ATTRIBUTES,\n                      register_our_attributes)\n\n"
  },
  {
    "path": "tests/examples/attributes-with-macros/stdout.txt",
    "content": "attribute_callback_for_claims_mutex called: args: (gcc.FunctionDecl('some_function'), gcc.StringCst('io'))\nattribute_callback_for_releases_mutex called: args: (gcc.FunctionDecl('some_other_function'), gcc.StringCst('io'))\nattribute_callback_for_claims_mutex called: args: (gcc.FunctionDecl('yet_another_function'), gcc.StringCst('db'))\nattribute_callback_for_claims_mutex called: args: (gcc.FunctionDecl('yet_another_function'), gcc.StringCst('io'))\nattribute_callback_for_releases_mutex called: args: (gcc.FunctionDecl('yet_another_function'), gcc.StringCst('io'))\n"
  },
  {
    "path": "tests/examples/c/struct/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Example of a struct: */\nstruct test_struct {\n    int a;\n    char b;\n    float c;\n};\n\nvoid foo()\n{\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/examples/c/struct/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Demonstration of how to look up a struct's declaration from Python\n\nimport gcc\n\nclass TestPass(gcc.GimplePass):\n    def execute(self, fn):\n        print('fn: %r' % fn)\n        for u in gcc.get_translation_units():\n            for decl in u.block.vars:\n                if isinstance(decl, gcc.TypeDecl):\n                    # \"decl\" is a gcc.TypeDecl\n                    # \"decl.type\" is a gcc.RecordType:\n                    print('  type(decl): %s' % type(decl))\n                    print('  type(decl.type): %s' % type(decl.type))\n                    print('  decl.type.name: %r' % decl.type.name)\n                    for f in decl.type.fields:\n                        print('    type(f): %s' % type(f))\n                        print('      f.name: %r' % f.name)\n                        print('      f.type: %s' % f.type)\n                        print('      type(f.type): %s' % type(f.type))\n\ntest_pass = TestPass(name='test-pass')\ntest_pass.register_after('cfg')\n"
  },
  {
    "path": "tests/examples/c/struct/stdout.txt",
    "content": "fn: gcc.Function('foo')\n  type(decl): <type 'gcc.TypeDecl'>\n  type(decl.type): <type 'gcc.RecordType'>\n  decl.type.name: gcc.IdentifierNode(name='test_struct')\n    type(f): <type 'gcc.FieldDecl'>\n      f.name: 'a'\n      f.type: int\n      type(f.type): <type 'gcc.IntegerType'>\n    type(f): <type 'gcc.FieldDecl'>\n      f.name: 'b'\n      f.type: char\n      type(f.type): <type 'gcc.IntegerType'>\n    type(f): <type 'gcc.FieldDecl'>\n      f.name: 'c'\n      f.type: float\n      type(f.type): <type 'gcc.RealType'>\n"
  },
  {
    "path": "tests/examples/cplusplus/classes/input.cc",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Examples of various aspects of C++ syntax */\nnamespace Example {\n    struct Coord {\n        int x;\n        int y;\n    };\n\n    class Widget {\n    protected:\n        Widget() {\n        }\n    public:\n        virtual ~Widget() {\n        }\n\n        /* Example of a pure virtual method */\n        virtual int get_width() = 0;\n\n        /* Reference: */\n        void set_location(const struct Coord& coord);\n\n    private:\n        struct Coord m_location;\n    };\n\n    class Dialog : public Widget {\n    public:\n        Dialog(): Widget() {\n        }\n\n        ~Dialog() {}\n\n        int get_width() { return 400; }\n    };\n};\n\n/* Example of a method definition, outside of the body of the class */\nvoid Example::Widget::set_location(const struct Coord& coord)\n{\n    this->m_location = coord;\n}\n\n/* Examples of overloaded functions: */\nvoid foo()\n{\n}\n\nvoid foo(const char *str)\n{\n}\n\nvoid foo(const Example::Coord& coord)\n{\n    /* Example of a call to a non-virtual method: */\n    Example::Widget *dlg = new Example::Dialog();\n    dlg->set_location(coord);\n    delete dlg;\n\n}\n\n\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/examples/cplusplus/classes/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\nclass TestPass(gcc.GimplePass):\n    def execute(self, fn):\n        print('fn: %r' % fn)\n        print('  fn.decl.name: %r' % fn.decl.name)\n        print('  fn.decl.fullname: %r' % fn.decl.fullname)\n        print('  str(fn.decl): %s' % fn.decl)\n        print('    type(fn): %r' % type(fn))\n        print('    type(fn.decl): %r' % type(fn.decl))\n        print('    type(fn.decl.type): %r' % type(fn.decl.type))\n\n        for attr in ('public', 'private', 'protected', 'static'):\n            print('  fn.decl.is_%s: %r' % (attr, getattr(fn.decl, 'is_%s' % attr)))\n\n        #fn.decl.debug()\n\n        # fn.decl is an instance of gcc.FunctionDecl:\n        print('  return type: %r' % str(fn.decl.type.type))\n        # fn.decl.type is an instance of gcc.MethodType for the methods:\n        print('  argument types: %r' % [str(t) for t in fn.decl.type.argument_types])\n\n        assert isinstance(fn.cfg, gcc.Cfg) # None for some early passes\n        assert fn.cfg.basic_blocks[0] == fn.cfg.entry\n        assert fn.cfg.basic_blocks[1] == fn.cfg.exit\n        for blockidx, bb in enumerate(fn.cfg.basic_blocks):\n            if bb.gimple:\n                print('  block %i' % blockidx)\n                for i,stmt in enumerate(bb.gimple):\n                    print('    gimple[%i]:' % i)\n                    print('      str(stmt): %r' % str(stmt))\n                    print('      repr(stmt): %r' % repr(stmt))\n                    if isinstance(stmt, gcc.GimpleCall):\n                        print('    type(stmt.fn): %r' % type(stmt.fn))\n                        print('    str(stmt.fn): %r' % str(stmt.fn))\n                        print('    stmt.fn: %r' % stmt.fn)\n                        if isinstance(stmt.fn, gcc.AddrExpr):\n                            print('      stmt.fn.operand: %r' % stmt.fn.operand)\n                            print('      stmt.fn.operand.fullname: %r' % stmt.fn.operand.fullname)\n                        for i, arg in enumerate(stmt.args):\n                            print('    str(stmt.args[%i]): %r' % (i, str(stmt.args[i])))\n                        print('    str(stmt.lhs): %s' % str(stmt.lhs))\n\ntest_pass = TestPass(name='test-pass')\ntest_pass.register_after('cfg')\n"
  },
  {
    "path": "tests/examples/cplusplus/classes/stdout.txt",
    "content": "fn: gcc.Function('__base_dtor ')\n  fn.decl.name: '__base_dtor '\n  fn.decl.fullname: 'Example::Widget::~Widget()'\n  str(fn.decl): __base_dtor \n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['struct Widget *']\n  block 2\n    gimple[0]:\n      str(stmt): 'this->_vptr.Widget = &_ZTVN7Example6WidgetE[2];'\n      repr(stmt): 'gcc.GimpleAssign()'\n  block 3\n    gimple[0]:\n      str(stmt): '<L0>:'\n      repr(stmt): 'gcc.GimpleLabel()'\n    gimple[1]:\n      str(stmt): 'D.nnnnn = 0 & 1;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[2]:\n      str(stmt): 'D.nnnnn = (bool) D.nnnnn;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[3]:\n      str(stmt): 'if (D.nnnnn != 0)'\n      repr(stmt): 'gcc.GimpleCond()'\n  block 4\n    gimple[0]:\n      str(stmt): 'operator delete (this);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): 'operator delete'\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('operator delete')\n      stmt.fn.operand.fullname: 'void operator delete(void*) throw ()'\n    str(stmt.args[0]): 'this'\n    str(stmt.lhs): None\n  block 5\n    gimple[0]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('__base_dtor ')\n  fn.decl.name: '__base_dtor '\n  fn.decl.fullname: 'Example::Dialog::~Dialog()'\n  str(fn.decl): __base_dtor \n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['struct Dialog *']\n  block 2\n    gimple[0]:\n      str(stmt): 'this->D.nnnnn._vptr.Widget = &_ZTVN7Example6DialogE[2];'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[1]:\n      str(stmt): 'Example::Widget::~Widget (this);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): '__base_dtor '\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('__base_dtor ')\n      stmt.fn.operand.fullname: 'Example::Widget::~Widget()'\n    str(stmt.args[0]): 'this'\n    str(stmt.lhs): None\n  block 3\n    gimple[0]:\n      str(stmt): '<L0>:'\n      repr(stmt): 'gcc.GimpleLabel()'\n    gimple[1]:\n      str(stmt): 'D.nnnnn = 0 & 1;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[2]:\n      str(stmt): 'D.nnnnn = (bool) D.nnnnn;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[3]:\n      str(stmt): 'if (D.nnnnn != 0)'\n      repr(stmt): 'gcc.GimpleCond()'\n  block 4\n    gimple[0]:\n      str(stmt): 'operator delete (this);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): 'operator delete'\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('operator delete')\n      stmt.fn.operand.fullname: 'void operator delete(void*) throw ()'\n    str(stmt.args[0]): 'this'\n    str(stmt.lhs): None\n  block 5\n    gimple[0]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('foo')\n  fn.decl.name: 'foo'\n  fn.decl.fullname: 'void foo(const Example::Coord&)'\n  str(fn.decl): foo\n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.FunctionType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['const struct Coord &']\n  block 2\n    gimple[0]:\n      str(stmt): 'D.nnnnn = operator new (16);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): 'operator new'\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('operator new')\n      stmt.fn.operand.fullname: 'void* operator new(long unsigned int) throw (std::bad_alloc)'\n    str(stmt.args[0]): '16'\n    str(stmt.lhs): D.nnnnn\n    gimple[1]:\n      str(stmt): 'dlg.0 = D.nnnnn;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[2]:\n      str(stmt): 'Example::Dialog::Dialog (dlg.0);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): '__comp_ctor '\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('__comp_ctor ')\n      stmt.fn.operand.fullname: 'Example::Dialog::Dialog()'\n    str(stmt.args[0]): 'dlg.0'\n    str(stmt.lhs): None\n    gimple[3]:\n      str(stmt): 'dlg = dlg.0;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[4]:\n      str(stmt): 'Example::Widget::set_location (dlg, coord);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): 'set_location'\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('set_location')\n      stmt.fn.operand.fullname: 'void Example::Widget::set_location(const Example::Coord&)'\n    str(stmt.args[0]): 'dlg'\n    str(stmt.args[1]): 'coord'\n    str(stmt.lhs): None\n    gimple[5]:\n      str(stmt): 'if (dlg != 0B)'\n      repr(stmt): 'gcc.GimpleCond()'\n  block 3\n    gimple[0]:\n      str(stmt): 'D.nnnnn = dlg->_vptr.Widget;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[1]:\n      str(stmt): 'D.nnnnn = D.nnnnn + 8;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[2]:\n      str(stmt): 'D.nnnnn = *D.nnnnn;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[3]:\n      str(stmt): 'OBJ_TYPE_REF(D.nnnnn;dlg->1) (dlg);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.ObjTypeRef'>\n    str(stmt.fn): 'OBJ_TYPE_REF(D.nnnnn;dlg->1)'\n    stmt.fn: <gcc.ObjTypeRef object at 0xdeadbeef>\n    str(stmt.args[0]): 'dlg'\n    str(stmt.lhs): None\n  block 4\n    gimple[0]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('__base_ctor ')\n  fn.decl.name: '__base_ctor '\n  fn.decl.fullname: 'Example::Dialog::Dialog()'\n  str(fn.decl): __base_ctor \n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['struct Dialog *']\n  block 2\n    gimple[0]:\n      str(stmt): 'D.nnnnn = &this->D.nnnnn;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[1]:\n      str(stmt): 'Example::Widget::Widget (D.nnnnn);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): '__base_ctor '\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('__base_ctor ')\n      stmt.fn.operand.fullname: 'Example::Widget::Widget()'\n    str(stmt.args[0]): 'D.nnnnn'\n    str(stmt.lhs): None\n    gimple[2]:\n      str(stmt): 'this->D.nnnnn._vptr.Widget = &_ZTVN7Example6DialogE[2];'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[3]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('__base_ctor ')\n  fn.decl.name: '__base_ctor '\n  fn.decl.fullname: 'Example::Widget::Widget()'\n  str(fn.decl): __base_ctor \n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: True\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['struct Widget *']\n  block 2\n    gimple[0]:\n      str(stmt): 'this->_vptr.Widget = &_ZTVN7Example6WidgetE[2];'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[1]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('foo')\n  fn.decl.name: 'foo'\n  fn.decl.fullname: 'void foo(const char*)'\n  str(fn.decl): foo\n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.FunctionType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['const char *']\n  block 2\n    gimple[0]:\n      str(stmt): 'GIMPLE_NOP'\n      repr(stmt): 'gcc.GimpleNop()'\n    gimple[1]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('foo')\n  fn.decl.name: 'foo'\n  fn.decl.fullname: 'void foo()'\n  str(fn.decl): foo\n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.FunctionType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: []\n  block 2\n    gimple[0]:\n      str(stmt): 'GIMPLE_NOP'\n      repr(stmt): 'gcc.GimpleNop()'\n    gimple[1]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('set_location')\n  fn.decl.name: 'set_location'\n  fn.decl.fullname: 'void Example::Widget::set_location(const Example::Coord&)'\n  str(fn.decl): set_location\n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['struct Widget *', 'const struct Coord &']\n  block 2\n    gimple[0]:\n      str(stmt): 'this->m_location = *coord;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[1]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('get_width')\n  fn.decl.name: 'get_width'\n  fn.decl.fullname: 'virtual int Example::Dialog::get_width()'\n  str(fn.decl): get_width\n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'int'\n  argument types: ['struct Dialog *']\n  block 2\n    gimple[0]:\n      str(stmt): 'D.nnnnn = 400;'\n      repr(stmt): 'gcc.GimpleAssign()'\n    gimple[1]:\n      str(stmt): 'return D.nnnnn;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('__deleting_dtor ')\n  fn.decl.name: '__deleting_dtor '\n  fn.decl.fullname: 'virtual Example::Dialog::~Dialog()'\n  str(fn.decl): __deleting_dtor \n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['struct Dialog *']\n  block 2\n    gimple[0]:\n      str(stmt): 'Example::Dialog::~Dialog (this);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): '__comp_dtor '\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('__comp_dtor ')\n      stmt.fn.operand.fullname: 'virtual Example::Dialog::~Dialog()'\n    str(stmt.args[0]): 'this'\n    str(stmt.lhs): None\n  block 3\n    gimple[0]:\n      str(stmt): '<L0>:'\n      repr(stmt): 'gcc.GimpleLabel()'\n    gimple[1]:\n      str(stmt): 'operator delete (this);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): 'operator delete'\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('operator delete')\n      stmt.fn.operand.fullname: 'void operator delete(void*) throw ()'\n    str(stmt.args[0]): 'this'\n    str(stmt.lhs): None\n    gimple[2]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\nfn: gcc.Function('__deleting_dtor ')\n  fn.decl.name: '__deleting_dtor '\n  fn.decl.fullname: 'virtual Example::Widget::~Widget()'\n  str(fn.decl): __deleting_dtor \n    type(fn): <type 'gcc.Function'>\n    type(fn.decl): <type 'gcc.FunctionDecl'>\n    type(fn.decl.type): <type 'gcc.MethodType'>\n  fn.decl.is_public: True\n  fn.decl.is_private: False\n  fn.decl.is_protected: False\n  fn.decl.is_static: True\n  return type: 'void'\n  argument types: ['struct Widget *']\n  block 2\n    gimple[0]:\n      str(stmt): 'Example::Widget::~Widget (this);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): '__comp_dtor '\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('__comp_dtor ')\n      stmt.fn.operand.fullname: 'virtual Example::Widget::~Widget()'\n    str(stmt.args[0]): 'this'\n    str(stmt.lhs): None\n  block 3\n    gimple[0]:\n      str(stmt): '<L0>:'\n      repr(stmt): 'gcc.GimpleLabel()'\n    gimple[1]:\n      str(stmt): 'operator delete (this);'\n      repr(stmt): 'gcc.GimpleCall()'\n    type(stmt.fn): <type 'gcc.AddrExpr'>\n    str(stmt.fn): 'operator delete'\n    stmt.fn: <gcc.AddrExpr object at 0xdeadbeef>\n      stmt.fn.operand: gcc.FunctionDecl('operator delete')\n      stmt.fn.operand.fullname: 'void operator delete(void*) throw ()'\n    str(stmt.args[0]): 'this'\n    str(stmt.lhs): None\n    gimple[2]:\n      str(stmt): 'return;'\n      repr(stmt): 'gcc.GimpleReturn()'\n"
  },
  {
    "path": "tests/examples/cplusplus/methods/getopts.py",
    "content": "print('-std=c++98')\n"
  },
  {
    "path": "tests/examples/cplusplus/methods/input.cc",
    "content": "/*\n   Copyright 2014 Philip Herron <redbrain@gcc.gnu.org>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nclass test {\n    int a, b;\npublic:\n    test (int, int);\n    int somefunc (void);\n};\n\ntest::test (int x, int y)\n{\n    a = x;\n    b = y;\n}\n\nint test::somefunc (void)\n{\n    return a * b;\n}\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/examples/cplusplus/methods/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2014 Philip Herron <redbrain@gcc.gnu.org>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nimport pprint\n\ndef gccPassHook(passname, _):\n    if passname.name == '*free_lang_data':\n        for i in gcc.get_translation_units ():\n            gns = gcc.get_global_namespace ()\n            for decl in gns.declarations:\n                if decl.is_builtin is False:\n                    pp = pprint.PrettyPrinter(indent=4)\n                    pp.pprint (str (decl.type))\n                    pp.pprint (decl.type.fields)\n                    pp.pprint (decl.type.methods)\n\ngcc.register_callback (gcc.PLUGIN_PASS_EXECUTION, gccPassHook)\n"
  },
  {
    "path": "tests/examples/cplusplus/methods/stdout.txt",
    "content": "'struct test'\n[gcc.FieldDecl('a'), gcc.FieldDecl('b'), gcc.TypeDecl('test')]\n[   gcc.FunctionDecl('test'),\n    gcc.FunctionDecl('__base_ctor '),\n    gcc.FunctionDecl('__comp_ctor '),\n    gcc.FunctionDecl('test'),\n    gcc.FunctionDecl('__base_ctor '),\n    gcc.FunctionDecl('__comp_ctor '),\n    gcc.FunctionDecl('somefunc')]\n"
  },
  {
    "path": "tests/examples/find-global-state/input.c",
    "content": "/*\n   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdio.h>\n\nstatic int a_global;\n\nstruct {\n  int f;\n} bar;\n\nextern int foo;\n\nint test(int j)\n{\n  /* A local variable, which should *not* be reported: */\n  int i;\n  i = j * 4;\n  return i + 1;\n}\n\nint test2(int p)\n{\n  static int q = 0;\n  q += p;\n  return p * q;\n}\n\nint test3(int k)\n{\n  /* We should *not* report about __FUNCTION__ here: */\n  printf(\"%s:%i:%s\\n\", __FILE__, __LINE__, __FUNCTION__);\n}\n\nint test4()\n{\n  return foo;\n}\n\nint test6()\n{\n  return bar.f;\n}\n\nstruct banana {\n  int f;\n};\n\nconst struct banana a_banana;\n\nint test7()\n{\n  return a_banana.f;\n}\n"
  },
  {
    "path": "tests/examples/find-global-state/metadata.ini",
    "content": "[ExpectedBehavior]\n# This test case emits warnings on stderr;\n# don't treat the stderr output as leading to an expected failure:\nexitcode = 0\n"
  },
  {
    "path": "tests/examples/find-global-state/script.py",
    "content": "#   Copyright 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import get_src_for_loc\n\nDEBUG=0\n\ndef is_const(type_):\n    if DEBUG:\n        type_.debug()\n\n    if hasattr(type_, 'const'):\n        if type_.const:\n            return True\n\n    # Don't bother warning about an array of const e.g.\n    # const char []\n    if isinstance(type_, gcc.ArrayType):\n        item_type = type_.dereference\n        if is_const(item_type):\n            return True\n\n\nclass StateFinder:\n    def __init__(self):\n        # Locate all declarations of variables holding \"global\" state:\n        self.global_decls = set()\n\n        for var in gcc.get_variables():\n            type_ = var.decl.type\n\n            if DEBUG:\n                print('var.decl: %r' % var.decl)\n                print(type_)\n\n            # Don't bother warning about const data:\n            if is_const(type_):\n                continue\n\n            self.global_decls.add(var.decl)\n        if DEBUG:\n            print('self.global_decls: %r' % self.global_decls)\n\n        self.state_users = set()\n\n    def find_state_users(self, node, loc):\n        if isinstance(node, gcc.VarDecl):\n            if node in self.global_decls:\n                # store the state users for later replay, so that\n                # we can eliminate duplicates\n                #   e.g. two references to \"q\" in \"q += p\"\n                # and replay in source-location order:\n                self.state_users.add( (loc, node) )\n\n    def flush(self):\n        # Emit warnings, sorted by source location:\n        for loc, node in sorted(self.state_users,\n                                key=lambda pair:pair[0]):\n            gcc.inform(loc,\n                       'use of global state \"%s %s\" here'\n                       % (node.type, node))\n\ndef on_pass_execution(p, fn):\n    if p.name == '*free_lang_data':\n        sf = StateFinder()\n\n        # Locate uses of such variables:\n        for node in gcc.get_callgraph_nodes():\n            fun = node.decl.function\n            if fun:\n                cfg = fun.cfg\n                if cfg:\n                    for bb in cfg.basic_blocks:\n                        stmts = bb.gimple\n                        if stmts:\n                            for stmt in stmts:\n                                stmt.walk_tree(sf.find_state_users,\n                                               stmt.loc)\n\n        # Flush the data that was found:\n        sf.flush()\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/examples/find-global-state/stderr.txt",
    "content": "tests/examples/find-global-state/input.c:41:nn: note: use of global state \"int q\" here\ntests/examples/find-global-state/input.c:41:nn: note: use of global state \"int q\" here\ntests/examples/find-global-state/input.c:42:nn: note: use of global state \"int q\" here\ntests/examples/find-global-state/input.c:53:nn: note: use of global state \"int foo\" here\ntests/examples/find-global-state/input.c:58:nn: note: use of global state \"struct \n{\n  int f;\n} bar\" here\n"
  },
  {
    "path": "tests/examples/hello-world/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdio.h>\n\nint main(int argc, char *argv[])\n{\n    printf(\"Hello, python\\n\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/examples/hello-world/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Here's a callback.  We will wire it up below:\ndef on_pass_execution(p, fn):\n    # This pass is called fairly early on, per-function, after the\n    # CFG has been built:\n    if p.name == '*warn_function_return':\n        # For this pass, \"fn\" will be an instance of gcc.Function:\n        print('fn: %r' % fn)\n        print('fn.decl.name: %r' % fn.decl.name)\n\n        # fn.decl is an instance of gcc.FunctionDecl:\n        print('return type: %r' % str(fn.decl.type.type))\n        print('argument types: %r' % [str(t) for t in fn.decl.type.argument_types])\n\n        assert isinstance(fn.cfg, gcc.Cfg) # None for some early passes\n        assert len(fn.cfg.basic_blocks) == 3\n        assert fn.cfg.basic_blocks[0] == fn.cfg.entry\n        assert fn.cfg.basic_blocks[1] == fn.cfg.exit\n        bb = fn.cfg.basic_blocks[2]\n        for i,stmt in enumerate(bb.gimple):\n            print('gimple[%i]:' % i)\n            print('  str(stmt): %r' % str(stmt))\n            print('  repr(stmt): %r' % repr(stmt))\n            if isinstance(stmt, gcc.GimpleCall):\n                from gccutils import pprint\n                print('  type(stmt.fn): %r' % type(stmt.fn))\n                print('  str(stmt.fn): %r' % str(stmt.fn))\n                for i, arg in enumerate(stmt.args):\n                    print('  str(stmt.args[%i]): %r' % (i, str(stmt.args[i])))\n                print('  str(stmt.lhs): %s' % str(stmt.lhs))\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n\n"
  },
  {
    "path": "tests/examples/hello-world/stdout.txt",
    "content": "fn: gcc.Function('main')\nfn.decl.name: 'main'\nreturn type: 'int'\nargument types: ['int', 'char * *']\ngimple[0]:\n  str(stmt): '__builtin_puts (&\"Hello, python\"[0]);'\n  repr(stmt): 'gcc.GimpleCall()'\n  type(stmt.fn): <type 'gcc.AddrExpr'>\n  str(stmt.fn): '__builtin_puts'\n  str(stmt.args[0]): '&\"Hello, python\"[0]'\n  str(stmt.lhs): None\ngimple[1]:\n  str(stmt): 'return;'\n  repr(stmt): 'gcc.GimpleReturn()'\n"
  },
  {
    "path": "tests/examples/lto/input-f.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdlib.h>\n#include <string.h>\n\n#include \"test.h\"\n\nvoid *f(int a)\n{\n  if (a) {\n    void *p = malloc(4096);\n    return p;\n  } else {\n    return NULL;\n  }\n}\n\n"
  },
  {
    "path": "tests/examples/lto/input-g.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdlib.h>\n#include <string.h>\n\n#include \"test.h\"\n\nvoid g(int b, void *q)\n{\n  if (b==2) {\n    g(b, q); /* contrived infinite recursion */\n  }\n  free(q);\n}\n"
  },
  {
    "path": "tests/examples/lto/input-main.c",
    "content": "/*\n   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012, 2013 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdlib.h>\n#include <string.h>\n\n#include \"test.h\"\n\nint main(int argc, char **argv)\n{\n  int *r = (int*)f(argc);\n  r[0] = 42; /* BUG: the malloc in f could have failed */\n  g(argc, r);\n  free(r); /* BUG: doublefree here, given that g frees the ptr */\n}\n"
  },
  {
    "path": "tests/examples/lto/script.py",
    "content": "#   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012, 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Sample python script, to be run by our gcc plugin\n# Show the \"supergraph\": the CFG of all functions, linked by\n# interproceduraledges:\nimport gcc\nfrom gccutils.graph.supergraph import Supergraph\nfrom gccutils import invoke_dot\n\n# We'll implement this as a custom pass, to be called directly before\n# 'whole-program'\n\nclass ShowSupergraph(gcc.IpaPass):\n    def execute(self):\n        # (the callgraph should be set up by this point)\n        if gcc.is_lto():\n            sg = Supergraph(split_phi_nodes=False,\n                            add_fake_entry_node=False)\n            dot = sg.to_dot('supergraph')\n            if 0:\n                invoke_dot(dot)\n\nps = ShowSupergraph(name='show-supergraph')\nps.register_before('whole-program')\n"
  },
  {
    "path": "tests/examples/lto/test.h",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nextern void *f(int a);\nextern void g(int b, void *q);\nextern void h(int c);\n"
  },
  {
    "path": "tests/examples/spelling-checker/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdio.h>\n\nint main(int argc, char *argv[])\n{\n    const char *p = argc ? \"correctly spelled\" : \"not so korectly speled\";\n\n    printf(\"The quick brown fox jumps over the lazy dog\\n\");\n\n    printf(\"Ths s n xmple f spllng mstke\\n\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/examples/spelling-checker/metadata.ini",
    "content": "[ExpectedBehavior]\n# This test case emits warnings on stderr;\n# don't treat the stderr output as leading to an expected failure:\nexitcode = 0\n"
  },
  {
    "path": "tests/examples/spelling-checker/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Use the Python bindings to the \"enchant\" spellchecker:\nimport enchant\nspellingdict = enchant.Dict(\"en_US\")\n\nclass SpellcheckingPass(gcc.GimplePass):\n    def execute(self, fun):\n        # This is called per-function during compilation:\n        for bb in fun.cfg.basic_blocks:\n            if bb.gimple:\n                for stmt in bb.gimple:\n                    stmt.walk_tree(self.spellcheck_node, stmt.loc)\n\n    def spellcheck_node(self, node, loc):\n        # Spellcheck any textual constants found within the node:\n        if isinstance(node, gcc.StringCst):\n            words = node.constant.split()\n            for word in words:\n                if not spellingdict.check(word):\n                    # Warn about the spelling error (controlling the warning\n                    # with the -Wall command-line option):\n                    if gcc.warning(loc,\n                                   'Possibly misspelt word in string constant: %r' % word,\n                                   gcc.Option('-Wall')):\n                        # and, if the warning was not suppressed at the command line, emit\n                        # suggested respellings:\n                        suggestions = spellingdict.suggest(word)\n                        if suggestions:\n                            gcc.inform(loc, 'Suggested respellings: %r' % ', '.join(suggestions))\n\nps = SpellcheckingPass(name='spellchecker')\nps.register_after('cfg')\n"
  },
  {
    "path": "tests/examples/spelling-checker/stderr.txt",
    "content": "tests/examples/spelling-checker/input.c: In function 'main':\ntests/examples/spelling-checker/input.c:24:48: warning: Possibly misspelt word in string constant: 'korectly' [-Wall]\ntests/examples/spelling-checker/input.c:24:48: note: Suggested respellings: 'correctly'\ntests/examples/spelling-checker/input.c:24:48: warning: Possibly misspelt word in string constant: 'speled' [-Wall]\ntests/examples/spelling-checker/input.c:24:48: note: Suggested respellings: 'speed, spieled, spelled, spewed, speckled, peeled, sped'\ntests/examples/spelling-checker/input.c:28:11: warning: Possibly misspelt word in string constant: 'Ths' [-Wall]\ntests/examples/spelling-checker/input.c:28:11: note: Suggested respellings: \"Th, Th's, Ohs, Thu, TVs, T's, Th s, Ts, This, Thus, The, Tho, Tbs, Thy, Goths\"\ntests/examples/spelling-checker/input.c:28:11: warning: Possibly misspelt word in string constant: 'xmple' [-Wall]\ntests/examples/spelling-checker/input.c:28:11: note: Suggested respellings: 'ample'\ntests/examples/spelling-checker/input.c:28:11: warning: Possibly misspelt word in string constant: 'spllng' [-Wall]\ntests/examples/spelling-checker/input.c:28:11: note: Suggested respellings: 'spelling'\ntests/examples/spelling-checker/input.c:28:11: warning: Possibly misspelt word in string constant: 'mstke' [-Wall]\ntests/examples/spelling-checker/input.c:28:11: note: Suggested respellings: 'mistake'\n"
  },
  {
    "path": "tests/examples/spelling-checker/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/gccutils/graph/input.c",
    "content": "\n"
  },
  {
    "path": "tests/gccutils/graph/metadata.ini",
    "content": "[ExpectedBehavior]\n# This test case emits warnings on stderr;\n# don't treat the stderr output as leading to an expected failure:\nexitcode = 0\n"
  },
  {
    "path": "tests/gccutils/graph/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Note: the line diagrams in the comments use the\n# Unicode \"Box Drawing\" characters:\n#   ─ : U+2500 BOX DRAWINGS LIGHT HORIZONTAL\n#   │ : U+2502 BOX DRAWINGS LIGHT VERTICAL\n#   ┐ : U+2510 BOX DRAWINGS LIGHT DOWN AND LEFT\n#   └ : U+2514 BOX DRAWINGS LIGHT UP AND RIGHT\n#   ┘ : U+2518 BOX DRAWINGS LIGHT UP AND LEFT\n# (the arrows are the greater than/less than and the letters A and V)\n\nimport unittest\n\nfrom gccutils.graph import Graph, Node, Edge\n\nclass NamedNode(Node):\n    def __init__(self, name=None):\n        Node.__init__(self)\n        self.name = name\n\n    def __str__(self):\n        if self.name:\n            return self.name\n        return 'node'\n\n    def __repr__(self):\n        return '%r' % self.name\n\ndef make_trivial_graph():\n    \"\"\"\n    Construct a trivial graph:\n       a ─> b\n    \"\"\"\n    g = Graph()\n    a = g.add_node(NamedNode('a'))\n    b = g.add_node(NamedNode('b'))\n    ab = g.add_edge(a, b)\n    return g, a, b, ab\n\ndef add_long_path(g, length):\n    \"\"\"\n    Construct a path of the form:\n        first -> n0 -> n1 -> .... -> last\n    where there are \"length\" edges\n    \"\"\"\n    first = g.add_node(Node())\n    last = first\n    cur = first\n    for i in range(length):\n        last = g.add_node(Node())\n        g.add_edge(cur, last)\n        cur = last\n    return first, last\n\ndef add_cycle(g, length):\n    \"\"\"\n    Construct a cycle of the form\n        first ─> n0 ─> n1 ─> ... ─> nN ┐\n          A                            │\n          └────────────────────────────┘\n    where there are \"length\" edges\n    \"\"\"\n    assert length > 0\n    first, last = add_long_path(g, length - 1)\n    g.add_edge(last, first)\n    return first\n\nclass GraphTests(unittest.TestCase):\n    def test_to_dot(self):\n        g, a, b, ab = make_trivial_graph()\n        dot = g.to_dot('example')\n\n    def test_long_path(self):\n        LENGTH = 1000\n        g = Graph()\n        first, last = add_long_path(g, LENGTH)\n        self.assertEqual(len(g.edges), LENGTH)\n        self.assertEqual(len(g.nodes), LENGTH + 1)\n        dot = g.to_dot('example')\n\n    def test_cycle(self):\n        LENGTH = 5\n        g = Graph()\n        first = add_cycle(g, LENGTH)\n        self.assertEqual(len(g.edges), LENGTH)\n        self.assertEqual(len(g.nodes), LENGTH)\n        dot = g.to_dot('example')\n\nclass PathfindingTests(unittest.TestCase):\n    def test_no_path(self):\n        g = Graph()\n        a = g.add_node(Node())\n        b = g.add_node(Node())\n        # no edges between them\n        path = g.get_shortest_path(a, b)\n        self.assertEqual(path, []) # FIXME: shouldn't this be None?\n\n    def test_trivial_path(self):\n        g, a, b, ab = make_trivial_graph()\n        path = g.get_shortest_path(a, b)\n        self.assertEqual(path, [ab])\n\n    def test_long_path(self):\n        LENGTH = 100\n        g = Graph()\n        first, last = add_long_path(g, LENGTH)\n        path = g.get_shortest_path(first, last)\n        self.assertEqual(len(path), LENGTH)\n        self.assertEqual(path[0].srcnode, first)\n        self.assertEqual(path[-1].dstnode, last)\n\n    def test_cycles(self):\n        LENGTH = 5\n        g = Graph()\n        a = add_cycle(g, LENGTH)\n        b = add_cycle(g, LENGTH)\n        c = add_cycle(g, LENGTH)\n        ab = g.add_edge(a, b)\n        bc = g.add_edge(b, c)\n        path = g.get_shortest_path(a, c)\n        self.assertEqual(len(path), 2)\n        p0, p1 = path\n        self.assertEqual(p0, ab)\n        self.assertEqual(p1, bc)\n\n    def test_fork(self):\n        # Verify that it figures out the shortest path for:\n        #  a ─> b─┬─> c ─> d ─┬─> f\n        #         └─> e ──────┘\n        g, a, b, ab = make_trivial_graph()\n\n        c = g.add_node(NamedNode('c'))\n        bc = g.add_edge(b, c)\n\n        d = g.add_node(NamedNode('d'))\n        cd = g.add_edge(c, d)\n\n        e = g.add_node(NamedNode('e'))\n        be = g.add_edge(b, e)\n\n        f = g.add_node(NamedNode('f'))\n        df = g.add_edge(d, f)\n        ef = g.add_edge(e, f)\n\n        path = g.get_shortest_path(a, f)\n        self.assertEqual(len(path), 3)\n        p0, p1, p2 = path\n        self.assertEqual(p0, ab)\n        self.assertEqual(p1, be)\n        self.assertEqual(p2, ef)\n\nimport sys\nsys.argv = ['foo', '-v']\n\nunittest.main()\n"
  },
  {
    "path": "tests/gccutils/graph/stderr.txt",
    "content": "test_cycle (__main__.GraphTests) ... ok\ntest_long_path (__main__.GraphTests) ... ok\ntest_to_dot (__main__.GraphTests) ... ok\ntest_cycles (__main__.PathfindingTests) ... ok\ntest_fork (__main__.PathfindingTests) ... ok\ntest_long_path (__main__.PathfindingTests) ... ok\ntest_no_path (__main__.PathfindingTests) ... ok\ntest_trivial_path (__main__.PathfindingTests) ... ok\n\n----------------------------------------------------------------------\nRan 8 tests in #s\n\nOK\n"
  },
  {
    "path": "tests/gccutils/topological-sort/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n   Verify that the topological sort code in gccutils works\n*/\n\nint a(int);\nint b(int);\nint c(int);\nint d(int);\nint e(int);\nint f(int);\nint g(int);\nint h(int);\nint j(int);\nint k(int);\n\nint a(int i)\n{\n    return e(i) + c(i);\n}\n\nint b(int i)\n{\n    return 42 - i;\n}\n\nint c(int i)\n{\n    return i * i;\n}\n\nint d(int i)\n{\n    return a(i) + b(c(i));\n}\n\n/* Directly recursive (actually factorial) */\nint e(int i)\n{\n    if (i>1) {\n        return i * e(i-1);\n    } else {\n        return 1;\n    }\n}\n\n/* f and g are mutually recursive */\nint f(int i)\n{\n    return g(i) + b(i);\n}\n\nint g(int i)\n{\n    return f(i) + c(i) + k(i);\n}\n\n/* h is entirely disjoint from the rest of the graph */\nint h(int i)\n{\n    return i;\n}\n\nint j(int i)\n{\n    return 2 * f(i);\n}\n\n/* k is not defined */\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/gccutils/topological-sort/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012, 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that the topological sort code in gccutils works\nimport gcc\n\ndef on_pass_execution(p, fn):\n    if p.name == '*free_lang_data':\n        from gccutils import sorted_callgraph\n        index = {}\n        for i, cgn in enumerate(sorted_callgraph()):\n            index[cgn.decl.name] = i\n        assert index['a'] < index['e']\n        assert index['a'] < index['c']\n\n        assert index['d'] < index['a']\n        assert index['d'] < index['b']\n        assert index['d'] < index['c']\n\n        assert index['g'] < index['c']\n\n        assert index['j'] < index['f']\n\n\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/gccutils/topological-sort/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/plugin/array-type/input.c",
    "content": "/*\n   Copyright 2012 Tom Tromey <tromey@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Test some array attributes.  */\n\nint arr[37];\n\nextern int arr2[];\n\nint function(void)\n{\n  return 23;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/array-type/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 Tom Tromey <tromey@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import pprint\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        assert isinstance(fn, gcc.Function)\n\n        for u in gcc.get_translation_units():\n            for v in u.block.vars:\n                if v.name == 'arr':\n                    print('arr-range-min:%s' % v.type.range.min_value)\n                    print('arr-range-max:%s' % v.type.range.max_value)\n                if v.name == 'arr2':\n                    print('arr2-range:%s' % v.type.range)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n\n"
  },
  {
    "path": "tests/plugin/array-type/stdout.txt",
    "content": "arr-range-min:0\narr-range-max:36\narr2-range:None\n"
  },
  {
    "path": "tests/plugin/arrays/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Test of reading and writing simple arrays */\nint test_arrays(void)\n{\n    int arr[10];\n    int *ptr = &arr[5];\n\n    *ptr = 42;\n\n    return arr[5];\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/arrays/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import pprint\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        assert isinstance(fn, gcc.Function)\n        print('fn: %r' % fn)\n\n        assert isinstance(fn.cfg, gcc.Cfg) # None for some early passes\n        for bb in fn.cfg.basic_blocks:\n            if bb.gimple:\n                for i,stmt in enumerate(bb.gimple):\n                    print('gimple[%i]:' % i)\n                    print('  stmt.str_no_uid: %r' % stmt.str_no_uid)\n                    print('  repr(stmt): %r' % repr(stmt))\n                    if isinstance(stmt, gcc.GimpleAssign):\n                        print('  stmt.lhs.str_no_uid: %r' % stmt.lhs.str_no_uid)\n                        print('  [str(stmt.rhs)]: %r' % [str(item) for item in stmt.rhs])\n                        print('  [type(stmt.rhs)]: %r' % [type(item) for item in stmt.rhs])\n                        if isinstance(stmt.rhs[0], gcc.AddrExpr):\n                            operand = stmt.rhs[0].operand\n                            print('    operand: %s' % operand)\n                            print('    type(operand): %s' % type(operand))\n                            assert isinstance(operand, gcc.ArrayRef)\n\n                            # Verify properties of gcc.ArrayRef:\n                            print('    operand.array: %r' % operand.array)\n                            assert isinstance(operand.index, gcc.IntegerCst)\n                            print('    operand.index: %s' % operand.index)\n\n                        if isinstance(stmt.rhs[0], gcc.ArrayRef):\n                            # Verify properties of gcc.ArrayRef:\n                            print('    stmt.rhs[0].array: %r' % stmt.rhs[0].array)\n                            assert isinstance(stmt.rhs[0].index, gcc.IntegerCst)\n                            print('    stmt.rhs[0].index: %s' % stmt.rhs[0].index)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n\n"
  },
  {
    "path": "tests/plugin/arrays/stdout.txt",
    "content": "fn: gcc.Function('test_arrays')\ngimple[0]:\n  stmt.str_no_uid: 'ptr = &arr[5];'\n  repr(stmt): 'gcc.GimpleAssign()'\n  stmt.lhs.str_no_uid: 'ptr'\n  [str(stmt.rhs)]: ['&arr[5]']\n  [type(stmt.rhs)]: [<type 'gcc.AddrExpr'>]\n    operand: arr[5]\n    type(operand): <type 'gcc.ArrayRef'>\n    operand.array: gcc.VarDecl('arr')\n    operand.index: 5\ngimple[1]:\n  stmt.str_no_uid: '*ptr = 42;'\n  repr(stmt): 'gcc.GimpleAssign()'\n  stmt.lhs.str_no_uid: '*ptr'\n  [str(stmt.rhs)]: ['42']\n  [type(stmt.rhs)]: [<type 'gcc.IntegerCst'>]\ngimple[2]:\n  stmt.str_no_uid: 'D.xxxx = arr[5];'\n  repr(stmt): 'gcc.GimpleAssign()'\n  stmt.lhs.str_no_uid: 'D.xxxx'\n  [str(stmt.rhs)]: ['arr[5]']\n  [type(stmt.rhs)]: [<type 'gcc.ArrayRef'>]\n    stmt.rhs[0].array: gcc.VarDecl('arr')\n    stmt.rhs[0].index: 5\ngimple[3]:\n  stmt.str_no_uid: 'return D.xxxx;'\n  repr(stmt): 'gcc.GimpleReturn()'\n"
  },
  {
    "path": "tests/plugin/attributes/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Test of adding custom attributes */\n\n/* Function declaration with custom attribs: */\nint main(int argc, char *argv[])\n    __attribute__((custom_attribute_without_args,\n                   custom_attribute_with_one_arg(1066),\n                   custom_attribute_with_one_or_two_args(\"secret agent\"),\n                   custom_attribute_with_one_or_two_args(\"elephant\", \"giraffe\") ));\n\n/* Global var declaration with custom attribs: */\nint test_global  __attribute__((custom_attribute_without_args,\n                                custom_attribute_with_one_arg(1492),\n                                custom_attribute_with_one_or_two_args(\"private investigator\"),\n                                custom_attribute_with_one_or_two_args(\"cow\", \"hedgehog\") ));\n\nint main(int argc, char *argv[])\n{\n    /* Local var declaration with custom attribs: */\n    int i __attribute__((custom_attribute_without_args,\n                         custom_attribute_with_one_arg(1776),\n                         custom_attribute_with_one_or_two_args(\"haberdasher\"),\n                         custom_attribute_with_one_or_two_args(\"turtle\", \"bear\") ));\n    return 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/attributes/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Verify that we can register custom attributes:\n\ndef my_attribute_callback_A(*args):\n    print('my_attribute_callback_A called: args: %s' % (args, ))\n\ndef my_attribute_callback_B(*args):\n    print('my_attribute_callback_B called: args: %s' % (args, ))\n\ndef my_attribute_callback_C(*args):\n    print('my_attribute_callback_C called: args: %s' % (args, ))\n\ndef register_our_attributes():\n    gcc.register_attribute('custom_attribute_without_args',\n                           0, 0,\n                           False, False, False,\n                           my_attribute_callback_A)\n    gcc.register_attribute('custom_attribute_with_one_arg',\n                           1, 1,\n                           False, False, False,\n                           my_attribute_callback_B)\n    gcc.register_attribute('custom_attribute_with_one_or_two_args',\n                           1, 2,\n                           False, False, False,\n                           my_attribute_callback_C)\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_ATTRIBUTES,\n                      register_our_attributes)\n\n"
  },
  {
    "path": "tests/plugin/attributes/stdout.txt",
    "content": "my_attribute_callback_A called: args: (gcc.FunctionDecl('main'),)\nmy_attribute_callback_B called: args: (gcc.FunctionDecl('main'), gcc.IntegerCst(1066))\nmy_attribute_callback_C called: args: (gcc.FunctionDecl('main'), gcc.StringCst('secret agent'))\nmy_attribute_callback_C called: args: (gcc.FunctionDecl('main'), gcc.StringCst('elephant'), gcc.StringCst('giraffe'))\nmy_attribute_callback_A called: args: (gcc.VarDecl('test_global'),)\nmy_attribute_callback_B called: args: (gcc.VarDecl('test_global'), gcc.IntegerCst(1492))\nmy_attribute_callback_C called: args: (gcc.VarDecl('test_global'), gcc.StringCst('private investigator'))\nmy_attribute_callback_C called: args: (gcc.VarDecl('test_global'), gcc.StringCst('cow'), gcc.StringCst('hedgehog'))\nmy_attribute_callback_A called: args: (gcc.VarDecl('i'),)\nmy_attribute_callback_B called: args: (gcc.VarDecl('i'), gcc.IntegerCst(1776))\nmy_attribute_callback_C called: args: (gcc.VarDecl('i'), gcc.StringCst('haberdasher'))\nmy_attribute_callback_C called: args: (gcc.VarDecl('i'), gcc.StringCst('turtle'), gcc.StringCst('bear'))\n"
  },
  {
    "path": "tests/plugin/callback-FINISH_DECL/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nextern int ext_int;\n\nextern int ext_fn(char);\n\nstruct test_struct {\n  int field;\n};\n\ntypedef struct test_struct test_typedef;\n\nint test_fn(int i)\n{\n    int j = i;\n    return j;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n\n"
  },
  {
    "path": "tests/plugin/callback-FINISH_DECL/metadata.ini",
    "content": "[WhenToRun]\nrequired_features=GCC_PYTHON_PLUGIN_CONFIG_has_PLUGIN_FINISH_DECL\n"
  },
  {
    "path": "tests/plugin/callback-FINISH_DECL/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Test case for gcc.PLUGIN_FINISH_DECL (only present in gcc 4.7 onwards)\n\nimport gcc\n\ndef finish_decl_cb(*args, **kwargs):\n    print('finish_decl_cb(*args=%r, **kwargs=%r)' % (args, kwargs))\n\ngcc.register_callback(gcc.PLUGIN_FINISH_DECL, finish_decl_cb,\n                      ('foo', ), bar='baz')\n"
  },
  {
    "path": "tests/plugin/callback-FINISH_DECL/stdout.txt",
    "content": "finish_decl_cb(*args=(gcc.VarDecl('ext_int'), None, 'foo'), **kwargs={'bar': 'baz'})\nfinish_decl_cb(*args=(gcc.ParmDecl(nnnn), None, 'foo'), **kwargs={'bar': 'baz'})\nfinish_decl_cb(*args=(gcc.FunctionDecl('ext_fn'), None, 'foo'), **kwargs={'bar': 'baz'})\nfinish_decl_cb(*args=(gcc.FieldDecl('field'), None, 'foo'), **kwargs={'bar': 'baz'})\nfinish_decl_cb(*args=(gcc.TypeDecl('test_typedef'), None, 'foo'), **kwargs={'bar': 'baz'})\nfinish_decl_cb(*args=(gcc.ParmDecl('i'), None, 'foo'), **kwargs={'bar': 'baz'})\nfinish_decl_cb(*args=(gcc.VarDecl('j'), gcc.Function('test_fn'), 'foo'), **kwargs={'bar': 'baz'})\n"
  },
  {
    "path": "tests/plugin/callbacks/PLUGIN_FINISH/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n"
  },
  {
    "path": "tests/plugin/callbacks/PLUGIN_FINISH/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Callback without any args:\ndef my_callback(*args, **kwargs):\n    print('my_callback:')\n    print('  args: %r' % (args,))\n    print('  kwargs: %r' % (kwargs,))\n\nfor i in range(3):\n    gcc.register_callback(gcc.PLUGIN_FINISH,\n                          my_callback,\n                          order=i)\n# (They seem to get invoked in reverse order)\n\n"
  },
  {
    "path": "tests/plugin/callbacks/PLUGIN_FINISH/stdout.txt",
    "content": "my_callback:\n  args: ()\n  kwargs: {'order': 2}\nmy_callback:\n  args: ()\n  kwargs: {'order': 1}\nmy_callback:\n  args: ()\n  kwargs: {'order': 0}\n"
  },
  {
    "path": "tests/plugin/callbacks/args/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n"
  },
  {
    "path": "tests/plugin/callbacks/args/script.py",
    "content": "#   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import sorted_dict_repr\n\n# Callback without any args:\ndef my_callback(*args, **kwargs):\n    print('my_callback:')\n    print('  args: %r' % (args,))\n    print('  kwargs: %s' % (sorted_dict_repr(kwargs),))\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      my_callback)\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      my_callback,\n                      (1, 2, 3))\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      my_callback,\n                      foo='bar',\n                      baz='qux')\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      my_callback,\n                      (1, 2, 3),\n                      foo='bar',\n                      baz='qux')\n\n# (They seem to get invoked in reverse order)\n\n"
  },
  {
    "path": "tests/plugin/callbacks/args/stdout.txt",
    "content": "my_callback:\n  args: (1, 2, 3)\n  kwargs: {'baz': 'qux', 'foo': 'bar'}\nmy_callback:\n  args: ()\n  kwargs: {'baz': 'qux', 'foo': 'bar'}\nmy_callback:\n  args: (1, 2, 3)\n  kwargs: {}\nmy_callback:\n  args: ()\n  kwargs: {}\n"
  },
  {
    "path": "tests/plugin/callbacks/exception/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nint nonempty;\n"
  },
  {
    "path": "tests/plugin/callbacks/exception/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# A callback that raises an exception:\ndef my_callback(*args, **kwargs):\n    raise RuntimeError(\"This is a test of raising an exception\")\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      my_callback)\n"
  },
  {
    "path": "tests/plugin/callbacks/exception/stderr.txt",
    "content": "tests/plugin/callbacks/exception/input.c:20:nn: error: Unhandled Python exception raised within callback\nTraceback (most recent call last):\n  File \"tests/plugin/callbacks/exception/script.py\", line 22, in my_callback\n    raise RuntimeError(\"This is a test of raising an exception\")\nRuntimeError: This is a test of raising an exception\n"
  },
  {
    "path": "tests/plugin/callbacks/refs/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n"
  },
  {
    "path": "tests/plugin/callbacks/refs/script.py",
    "content": "# Crash reproducer from:\n#  https://fedorahosted.org/pipermail/gcc-python-plugin/2011-October/000121.html\n\nimport gcc\n\nclass Whatever:\n    def doit(self, optpass, fun, *args, **kwargs):\n        print(\"hi bob\")\n\ndef main(**kwargs):\n    w = Whatever()\n    gcc.register_callback(gcc.PLUGIN_PASS_EXECUTION, w.doit)\n\nmain()\n"
  },
  {
    "path": "tests/plugin/callbacks/refs/stdout.txt",
    "content": "hi bob\nhi bob\nhi bob\nhi bob\nhi bob\n"
  },
  {
    "path": "tests/plugin/callgraph/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nvoid foo()\n{\n}\n\nvoid bar(void)\n{\n    foo();\n    foo();\n    foo();\n}\n\nvoid baz(void)\n{\n    bar();\n    bar();\n    bar();\n}\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/callgraph/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify examining details of functions\n\nimport gcc\nfrom gccutils import pprint\n\nhelp(gcc.CallgraphNode)\nhelp(gcc.CallgraphEdge)\n\nfrom gccutils import callgraph_to_dot, invoke_dot\n\ndef on_pass_execution(p, fn):\n    #if p.name == '*warn_function_return':\n    if p.name == '*free_lang_data':\n        if 0:\n            dot = callgraph_to_dot()\n            invoke_dot(dot)\n\n        for cgn in gcc.get_callgraph_nodes():\n            print('cgn:')\n            # print(dir(cgn))\n            print('  cgn.decl: %r' % cgn.decl)\n            print('  cgn.decl.location.in_system_header: %r'\n                  % cgn.decl.location.in_system_header)\n            print('  cgn.callers: %r' % cgn.callers)\n            print('  cgn.callees: %r' % cgn.callees)\n            for e in cgn.callers:\n                print(e)\n                print('e.caller: %r' % e.caller)\n                print('e.callee: %r' % e.callee)\n                print('e.call_stmt: %r %s' % (e.call_stmt, e.call_stmt))\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/callgraph/stdout.txt",
    "content": "Help on class CallgraphNode in module gcc:\n\nclass CallgraphNode(__builtin__.object)\n |  Methods defined here:\n |  \n |  __repr__(...)\n |      x.__repr__() <==> repr(x)\n |  \n |  __str__(...)\n |      x.__str__() <==> str(x)\n |  \n |  ----------------------------------------------------------------------\n |  Data descriptors defined here:\n |  \n |  callees\n |      The function calls made by this function, as a list of gcc.CallgraphEdge\n |  \n |  callers\n |      The places that call this function, as a list of gcc.CallgraphEdge\n |  \n |  decl\n |      The gcc.FunctionDecl for this node\n |  \n |  ----------------------------------------------------------------------\n |  Data and other attributes defined here:\n |  \n |  __new__ = <built-in method __new__ of gcc.WrapperMeta object>\n |      T.__new__(S, ...) -> a new object with type S, a subtype of T\n\nHelp on class CallgraphEdge in module gcc:\n\nclass CallgraphEdge(__builtin__.object)\n |  Methods defined here:\n |  \n |  __repr__(...)\n |      x.__repr__() <==> repr(x)\n |  \n |  __str__(...)\n |      x.__str__() <==> str(x)\n |  \n |  ----------------------------------------------------------------------\n |  Data descriptors defined here:\n |  \n |  call_stmt\n |      The gcc.GimpleCall statememt for the function call\n |  \n |  callee\n |      The function that is called here, as a gcc.CallgraphNode\n |  \n |  caller\n |      The function that makes this call, as a gcc.CallgraphNode\n |  \n |  ----------------------------------------------------------------------\n |  Data and other attributes defined here:\n |  \n |  __new__ = <built-in method __new__ of gcc.WrapperMeta object>\n |      T.__new__(S, ...) -> a new object with type S, a subtype of T\n\ncgn:\n  cgn.decl: gcc.FunctionDecl('baz')\n  cgn.decl.location.in_system_header: False\n  cgn.callers: []\n  cgn.callees: [gcc.CallgraphEdge(), gcc.CallgraphEdge(), gcc.CallgraphEdge()]\ncgn:\n  cgn.decl: gcc.FunctionDecl('bar')\n  cgn.decl.location.in_system_header: False\n  cgn.callers: [gcc.CallgraphEdge(), gcc.CallgraphEdge(), gcc.CallgraphEdge()]\n  cgn.callees: [gcc.CallgraphEdge(), gcc.CallgraphEdge(), gcc.CallgraphEdge()]\ngcc.CallgraphEdge()\ne.caller: gcc.CallgraphNode()\ne.callee: gcc.CallgraphNode()\ne.call_stmt: gcc.GimpleCall() bar ();\ngcc.CallgraphEdge()\ne.caller: gcc.CallgraphNode()\ne.callee: gcc.CallgraphNode()\ne.call_stmt: gcc.GimpleCall() bar ();\ngcc.CallgraphEdge()\ne.caller: gcc.CallgraphNode()\ne.callee: gcc.CallgraphNode()\ne.call_stmt: gcc.GimpleCall() bar ();\ncgn:\n  cgn.decl: gcc.FunctionDecl('foo')\n  cgn.decl.location.in_system_header: False\n  cgn.callers: [gcc.CallgraphEdge(), gcc.CallgraphEdge(), gcc.CallgraphEdge()]\n  cgn.callees: []\ngcc.CallgraphEdge()\ne.caller: gcc.CallgraphNode()\ne.callee: gcc.CallgraphNode()\ne.call_stmt: gcc.GimpleCall() foo ();\ngcc.CallgraphEdge()\ne.caller: gcc.CallgraphNode()\ne.callee: gcc.CallgraphNode()\ne.call_stmt: gcc.GimpleCall() foo ();\ngcc.CallgraphEdge()\ne.caller: gcc.CallgraphNode()\ne.callee: gcc.CallgraphNode()\ne.call_stmt: gcc.GimpleCall() foo ();\n"
  },
  {
    "path": "tests/plugin/compound-locations/input.c",
    "content": "/*\n   Copyright 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* { dg-do compile } */\n/* { dg-options \"-fdiagnostics-show-caret\" } */\n\nint test (int foo, int bar)\n{ return foo + bar; }\n/* { dg-message \"14: compound location\" \"\" { target *-*-* } .-1 } */\n/* { dg-begin-multiline-output \"\" }\n { return foo + bar; }\n          ~~~~^~~~~\n   { dg-end-multiline-output \"\" } */\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/compound-locations/script.py",
    "content": "#   Copyright 2017 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2017 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport sys\n\nimport gcc\n\n# Verify that various aspects of gcc.Location work\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        caret = fn.start.offset_column(13)\n        start = fn.start.offset_column(9)\n        finish = fn.start.offset_column(17)\n        compound = gcc.Location(caret, start, finish)\n        gcc.inform(compound, \"compound location\")\n        assert compound.caret == caret\n        assert compound.start == start\n        assert compound.finish == finish\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n\n"
  },
  {
    "path": "tests/plugin/constants/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Various integer values */\nint i000 = 0;\n\nint i001 = 1;\n\nsigned int i002 = -1;\n\n/* 2^32 - 1 */\nunsigned long i003 = 0xffffffff;\n\n/* 2^32 - 1 */\nsigned long long i004 = 0xffffffff;\n\n/* 2^64 - 1  */\nunsigned long long i005 = 0xffffffffffffffff;\n\n/* -2^32 */\nsigned long long i006 = -0x100000000;\n\n/* Various float values */\nfloat f000 = 0;\nfloat f001 = 1;\nfloat f002 = -1;\n\n/* Various double values */\ndouble d000 = 0;\ndouble d001 = 1;\ndouble d002 = -1;\n"
  },
  {
    "path": "tests/plugin/constants/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that we can extract constants correctly back to python\n\nimport gcc\nimport gccutils\n\ndef on_finish_unit():\n    vars = gccutils.get_variables_as_dict()\n    for name in sorted(vars):\n        var = vars[name]\n        if name.startswith('i'):\n            assert isinstance(var.decl.initial, gcc.IntegerCst)\n            print('%s: %s' % (name, hex(var.decl.initial.constant)))\n            assert int(var.decl.initial) == var.decl.initial.constant\n            assert hash(var.decl.initial) == hash(var.decl.initial.constant)\n            # Verify that rich comparisons between gcc.IntegerCst and int are sane:\n            assert var.decl.initial == var.decl.initial.constant\n            assert var.decl.initial >= var.decl.initial.constant\n            assert var.decl.initial <= var.decl.initial.constant\n            assert var.decl.initial != var.decl.initial.constant + 1\n            # and the other way around:\n            assert var.decl.initial.constant == var.decl.initial\n            assert var.decl.initial.constant >= var.decl.initial\n            assert var.decl.initial.constant <= var.decl.initial\n            assert var.decl.initial.constant + 1 != var.decl.initial\n        elif name.startswith('f') or name.startswith('d'):\n            assert isinstance(var.decl.initial, gcc.RealCst)\n            print('%s: %r %s' % (name,\n                                 var.decl.initial,\n                                 var.decl.initial.constant))\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      on_finish_unit)\n"
  },
  {
    "path": "tests/plugin/constants/stdout.txt",
    "content": "d000: gcc.RealCst(0.0) 0.0\nd001: gcc.RealCst(1.0e+0) 1.0\nd002: gcc.RealCst(-1.0e+0) -1.0\nf000: gcc.RealCst(0.0) 0.0\nf001: gcc.RealCst(1.0e+0) 1.0\nf002: gcc.RealCst(-1.0e+0) -1.0\ni000: 0x0\ni001: 0x1\ni002: -0x1\ni003: 0xffffffff\ni004: 0xffffffff\ni005: 0xffffffffffffffffL\ni006: -0x100000000\n"
  },
  {
    "path": "tests/plugin/diagnostics/getopts.py",
    "content": "# Suppress one of the warnings:\nprint('-Wno-format')\n"
  },
  {
    "path": "tests/plugin/diagnostics/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdio.h>\n\nint main(int argc, char *argv[])\n{\n    return 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/diagnostics/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport sys\n\nimport gcc\n\n# Verify that the various error and warning methods work:\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        gcc.error(fn.start, 'this is an error (with positional args)')\n        gcc.error(location=fn.start,\n                  message='this is an error (with keyword args)')\n        gcc.warning(fn.end, 'this is a warning (with positional args)',\n                    gcc.Option('-Wdiv-by-zero'))\n        gcc.warning(location=fn.end,\n                    message='this is a warning (with keyword args)',\n                    option=gcc.Option('-Wdiv-by-zero'))\n        gcc.error(fn.start,\n                  # These should be passed through, without triggering errors:\n                  'a warning with some embedded format strings %s and %i')\n\n        # Verify that -Wno-format was honored\n        # The behavior of these flags changed in 4.8, so skip this part\n        # on gcc 4.8 onwards:\n        if gcc.GCC_VERSION <= 4007:\n            gcc.warning(fn.end,\n                        'this warning ought not to appear',\n                        gcc.Option('-Wformat'))\n\n        # Verify that we can issue an unconditional warning, with no option\n        # (as per https://fedorahosted.org/gcc-python-plugin/ticket/8 ):\n        gcc.warning(fn.end, 'this is an unconditional warning')\n        gcc.warning(fn.end, 'this is another unconditional warning', None)\n\n        # Verify that gcc.warning handles an object of the wrong type by\n        # raising a TypeError\n        try:\n            gcc.warning(fn.end, 'this is another unconditional warning',\n                        'this should have been a gcc.Option instance, or None')\n        except TypeError:\n            err = sys.exc_info()[1]\n            sys.stderr.write('expected error was found: %s\\n' % err)\n        else:\n            raise RuntimeError('expected exception was not raised')\n\n        # Exercise gcc.inform:\n        gcc.inform(fn.start, 'This is the start of the function')\n        gcc.inform(fn.end, 'This is the end of the function')\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n\n"
  },
  {
    "path": "tests/plugin/diagnostics/stderr.txt",
    "content": "In function 'main':\ntests/plugin/diagnostics/input.c:23:nn: error: this is an error (with positional args)\ntests/plugin/diagnostics/input.c:23:nn: error: this is an error (with keyword args)\ntests/plugin/diagnostics/input.c:25:nn: warning: this is a warning (with positional args) [-Wdiv-by-zero]\ntests/plugin/diagnostics/input.c:25:nn: warning: this is a warning (with keyword args) [-Wdiv-by-zero]\ntests/plugin/diagnostics/input.c:23:nn: error: a warning with some embedded format strings %s and %i\ntests/plugin/diagnostics/input.c:25:nn: warning: this is an unconditional warning [enabled by default]\ntests/plugin/diagnostics/input.c:25:nn: warning: this is another unconditional warning [enabled by default]\nexpected error was found: option must be either None, or of type gcc.Option\ntests/plugin/diagnostics/input.c:23:nn: note: This is the start of the function\ntests/plugin/diagnostics/input.c:25:nn: note: This is the end of the function\n"
  },
  {
    "path": "tests/plugin/dumpfiles/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nint foo(const char *str)\n{\n    if (str) {\n        return 42;\n    } else {\n        return 0;\n    }\n}\n\nint bar(const char *str)\n{\n    if (str) {\n        return 0;\n    } else {\n        return 42;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/dumpfiles/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n\n# Verify working with GCC's dump files\n\nimport gcc\n\nprint('gcc.get_dump_base_name(): %r' % gcc.get_dump_base_name())\n\npass_dumpfile = None\nclass TestPass(gcc.GimplePass):\n    def execute(self, fun):\n        global pass_dumpfile\n        print('within TestPass.execute, for %r' % fun)\n        pass_dumpfile = gcc.get_dump_file_name()\n        if 0:\n            print('pass_dumpfile: %r' % pass_dumpfile)\n\n        # Dumping of strings:\n        gcc.dump('hello world')\n\n        # Dumping of other objects:\n        gcc.dump(42)\n\nps = TestPass(name='test-pass')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\nassert isinstance(ps.static_pass_number, int)\nprint('ps.dump_enabled: %r' % ps.dump_enabled)\nprint('Manually enabling dump for our pass:')\nps.dump_enabled = True\nprint('ps.dump_enabled: %r' % ps.dump_enabled)\n\n# Now register another pass afterwards, to inspect the dumpfile\n# for the previous pass:\nclass VerifyPass(gcc.GimplePass):\n    def execute(self, fun):\n        global pass_dumpfile\n        print('within VerifyPass.execute, for %r' % fun)\n        if 0:\n            print('pass_dumpfile: %r' % pass_dumpfile)\n        with open(pass_dumpfile) as f:\n            content = f.read()\n        print('--CONTENT OF DUMPFILE--')\n        print(content)\n        print('--END OF DUMPFILE--')\n\nps = VerifyPass(name='verify-pass')\nprint('registering: %r' % ps)\nps.register_after('test-pass')\n"
  },
  {
    "path": "tests/plugin/dumpfiles/stdout.txt",
    "content": "gcc.get_dump_base_name(): 'tests/plugin/dumpfiles/input.c'\nregistering: TestPass(name='test-pass')\nps.dump_enabled: False\nManually enabling dump for our pass:\nps.dump_enabled: True\nregistering: VerifyPass(name='verify-pass')\nwithin TestPass.execute, for gcc.Function('bar')\nwithin VerifyPass.execute, for gcc.Function('bar')\n--CONTENT OF DUMPFILE--\n\n;; Function bar (bar)\n\nhello world42\n--END OF DUMPFILE--\nwithin TestPass.execute, for gcc.Function('foo')\nwithin VerifyPass.execute, for gcc.Function('foo')\n--CONTENT OF DUMPFILE--\n\n;; Function bar (bar)\n\nhello world42\n;; Function foo (foo)\n\nhello world42\n--END OF DUMPFILE--\n"
  },
  {
    "path": "tests/plugin/enum-type/input.c",
    "content": "/*\n   Copyright 2015 Tom Tromey <tom@tromey.com>\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nenum the_enum\n{\n  ONE = 1,\n  TWO = 2,\n  MINUS_ONE = -1\n};\n\n/* We need a variable because some versions of gcc don't call\n   PLUGIN_FINISH_TYPE for an enum.  */\nenum the_enum variable;\n"
  },
  {
    "path": "tests/plugin/enum-type/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2015 Tom Tromey <tom@tromey.com>\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\ndef on_decl(v, *args, **kwargs):\n    if v.name != 'variable':\n        return\n\n    t = v.type\n    print(t.name)\n    print('length = %d' % len(t.values))\n    for (name, value) in t.values:\n        print('%s = %s' % (name, value))\n\ngcc.register_callback(gcc.PLUGIN_FINISH_DECL, on_decl)\n"
  },
  {
    "path": "tests/plugin/enum-type/stdout.txt",
    "content": "the_enum\nlength = 3\nONE = 1\nTWO = 2\nMINUS_ONE = -1\n"
  },
  {
    "path": "tests/plugin/expressions/get_symbol/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* empty */\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/expressions/get_symbol/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\nfrom gccutils import Table\n\nt = Table(['Class', 'get_symbol()'],\n          sepchar='=')\n\nfor name in sorted(dir(gcc)):\n    obj = getattr(gcc, name)\n    if hasattr(obj, 'get_symbol'):\n        try:\n            sym = obj.get_symbol()\n        except TypeError:\n            continue\n        if sym != '<<< ??? >>>':\n            t.add_row((':py:class:`gcc.%s`' % name,\n                       '`%s`' % sym.strip()))\n\nfrom six import StringIO\ns = StringIO()\nt.write(s)\n\nfor line in s.getvalue().splitlines():\n    print('   ' + line.rstrip())\nprint('\\n')\n"
  },
  {
    "path": "tests/plugin/expressions/get_symbol/stdout.txt",
    "content": "   =================================  ============\n   Class                              get_symbol()\n   =================================  ============\n   :py:class:`gcc.AddrExpr`           `&`\n   :py:class:`gcc.BitAndExpr`         `&`\n   :py:class:`gcc.BitIorExpr`         `|`\n   :py:class:`gcc.BitNotExpr`         `~`\n   :py:class:`gcc.BitXorExpr`         `^`\n   :py:class:`gcc.CeilDivExpr`        `/[cl]`\n   :py:class:`gcc.CeilModExpr`        `%[cl]`\n   :py:class:`gcc.EqExpr`             `==`\n   :py:class:`gcc.ExactDivExpr`       `/[ex]`\n   :py:class:`gcc.FloorDivExpr`       `/[fl]`\n   :py:class:`gcc.FloorModExpr`       `%[fl]`\n   :py:class:`gcc.GeExpr`             `>=`\n   :py:class:`gcc.GtExpr`             `>`\n   :py:class:`gcc.IndirectRef`        `*`\n   :py:class:`gcc.LeExpr`             `<=`\n   :py:class:`gcc.LrotateExpr`        `r<<`\n   :py:class:`gcc.LshiftExpr`         `<<`\n   :py:class:`gcc.LtExpr`             `<`\n   :py:class:`gcc.LtgtExpr`           `<>`\n   :py:class:`gcc.MaxExpr`            `max`\n   :py:class:`gcc.MinExpr`            `min`\n   :py:class:`gcc.MinusExpr`          `-`\n   :py:class:`gcc.ModifyExpr`         `=`\n   :py:class:`gcc.MultExpr`           `*`\n   :py:class:`gcc.NeExpr`             `!=`\n   :py:class:`gcc.NegateExpr`         `-`\n   :py:class:`gcc.OrderedExpr`        `ord`\n   :py:class:`gcc.PlusExpr`           `+`\n   :py:class:`gcc.PointerPlusExpr`    `+`\n   :py:class:`gcc.PostdecrementExpr`  `--`\n   :py:class:`gcc.PostincrementExpr`  `++`\n   :py:class:`gcc.PredecrementExpr`   `--`\n   :py:class:`gcc.PreincrementExpr`   `++`\n   :py:class:`gcc.RdivExpr`           `/`\n   :py:class:`gcc.ReducPlusExpr`      `r+`\n   :py:class:`gcc.RoundDivExpr`       `/[rd]`\n   :py:class:`gcc.RoundModExpr`       `%[rd]`\n   :py:class:`gcc.RrotateExpr`        `r>>`\n   :py:class:`gcc.RshiftExpr`         `>>`\n   :py:class:`gcc.TruncDivExpr`       `/`\n   :py:class:`gcc.TruncModExpr`       `%`\n   :py:class:`gcc.TruthAndExpr`       `&&`\n   :py:class:`gcc.TruthAndifExpr`     `&&`\n   :py:class:`gcc.TruthNotExpr`       `!`\n   :py:class:`gcc.TruthOrExpr`        `||`\n   :py:class:`gcc.TruthOrifExpr`      `||`\n   :py:class:`gcc.TruthXorExpr`       `^`\n   :py:class:`gcc.UneqExpr`           `u==`\n   :py:class:`gcc.UngeExpr`           `u>=`\n   :py:class:`gcc.UngtExpr`           `u>`\n   :py:class:`gcc.UnleExpr`           `u<=`\n   :py:class:`gcc.UnltExpr`           `u<`\n   :py:class:`gcc.UnorderedExpr`      `unord`\n   :py:class:`gcc.VecLshiftExpr`      `v<<`\n   :py:class:`gcc.VecRshiftExpr`      `v>>`\n   :py:class:`gcc.WidenMultExpr`      `w*`\n   :py:class:`gcc.WidenSumExpr`       `w+`\n   =================================  ============\n\n\n"
  },
  {
    "path": "tests/plugin/function-types/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\ntypedef int (example_fn_type)(char, float);\n\ntypedef int (example_variadic_fn_type)(char, float, ...);\n"
  },
  {
    "path": "tests/plugin/function-types/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nimport gccutils\n\ndef check_fn_type(name):\n    fn_type_decl = gccutils.get_global_typedef(name)\n    assert isinstance(fn_type_decl, gcc.TypeDecl)\n\n    print('fn_type_decl.name: %r' % fn_type_decl.name)\n\n    fn_type = fn_type_decl.type\n    assert isinstance(fn_type, gcc.FunctionType)\n    print('str(fn_type): %r' % str(fn_type))\n    print('str(fn_type.type): %r' % str(fn_type.type))\n    assert isinstance(fn_type.argument_types, tuple)\n    print('argument_types: %r' % [str(t) for t in fn_type.argument_types])\n    print('is_variadic: %r' % fn_type.is_variadic)\n    try:\n        fn_type.sizeof\n        assert 0 # an exception should have been raised\n    except:\n        err = sys.exc_info()[1]\n        print('err: %s' % err)\n\n\ndef on_finish_unit():\n    check_fn_type('example_fn_type')\n    check_fn_type('example_variadic_fn_type')\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      on_finish_unit)\n"
  },
  {
    "path": "tests/plugin/function-types/stdout.txt",
    "content": "fn_type_decl.name: 'example_fn_type'\nstr(fn_type): 'int example_fn_type (char, float)'\nstr(fn_type.type): 'int'\nargument_types: ['char', 'float']\nis_variadic: False\nerr: type \"int example_fn_type (char, float)\" does not have a \"sizeof\"\nfn_type_decl.name: 'example_variadic_fn_type'\nstr(fn_type): 'int example_variadic_fn_type (char, float, ...)'\nstr(fn_type.type): 'int'\nargument_types: ['char', 'float']\nis_variadic: True\nerr: type \"int example_variadic_fn_type (char, float, ...)\" does not have a \"sizeof\"\n"
  },
  {
    "path": "tests/plugin/functions/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdio.h>\n\nvoid foo(int a, int b)\n{\n    float f, g;\n    float h = 1.0f;\n    static int i = 42;\n    char *keywords[] = {\"bar\", NULL};\n    const double d = 2.0;\n\n    /* empty */\n}\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/functions/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify examining details of functions\n\nimport gcc\nfrom gccutils import pprint\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        assert isinstance(fn, gcc.Function)\n        print('fn: %r' % fn)\n\n        assert isinstance(fn.decl, gcc.FunctionDecl)\n        print('fn.decl.name: %r' % fn.decl.name)\n\n        assert isinstance(fn.decl, gcc.FunctionDecl)\n        #print(fn.decl.type)\n        #print(fn.decl.type.argument_types)\n        #pprint(fn.decl)\n\n        print('len(fn.local_decls): %r' % len(fn.local_decls))\n        for i, local in enumerate(fn.local_decls):\n            print('local_decls[%i]' % i)\n            print('  type(local): %r' % type(local))\n            print('  local.name: %r' % local.name)\n            # The \"initial\" only seems to be present for static variables\n            # with initializers.  Other variables seem to get initialized\n            # in explicit gimple statements (see below)\n            if local.initial:\n                print('  local.initial.constant: %r' % local.initial.constant)\n            else:\n                print('  local.initial: %r' % local.initial)\n            print('  str(local.type): %r' % str(local.type))\n            #pprint(local)\n            #local.debug()\n\n        print('fn.funcdef_no: %r' % fn.funcdef_no)\n        print('fn.start: %r' % fn.start)\n        print('fn.end: %r' % fn.end)\n\n        assert isinstance(fn.cfg, gcc.Cfg) # None for some early passes\n        assert len(fn.cfg.basic_blocks) == 3\n        assert fn.cfg.basic_blocks[0] == fn.cfg.entry\n        assert fn.cfg.basic_blocks[1] == fn.cfg.exit\n        bb = fn.cfg.basic_blocks[2]\n        # We only show some of the gimple:\n        # later versions of GCC added this stmt:\n        #    gimple[4]:\n        #      str(stmt): 'keywords = {CLOBBER};'\n        #      repr(stmt): 'gcc.GimpleAssign()'\n        #      str(stmt.lhs): 'keywords'\n        #      [str(stmt.rhs)]: ['{CLOBBER}']\n        # so we avoid going too far into the statements\n        for i,stmt in enumerate(bb.gimple[:3]):\n            print('gimple[%i]:' % i)\n            print('  str(stmt): %r' % str(stmt))\n            print('  repr(stmt): %r' % repr(stmt))\n            if isinstance(stmt, gcc.GimpleAssign):\n                print('  str(stmt.lhs): %r' % str(stmt.lhs))\n                print('  [str(stmt.rhs)]: %r' % [str(item) for item in stmt.rhs])\n            #print(dir(stmt))\n            #pprint(stmt)\n\n\n        print('fn.decl.arguments: %r' % fn.decl.arguments)\n        for i, arg in enumerate(fn.decl.arguments):\n            print('  arg[%i]:' % i)\n            print('    arg.name: %r' % arg.name)\n            print('    str(arg.type): %r' % str(arg.type))\n        print('type(fn.decl.result): %r' % type(fn.decl.result))\n        print('  str(fn.decl.result.type): %r' % str(fn.decl.result.type))\n\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/functions/stdout.txt",
    "content": "fn: gcc.Function('foo')\nfn.decl.name: 'foo'\nlen(fn.local_decls): 6\nlocal_decls[0]\n  type(local): <type 'gcc.VarDecl'>\n  local.name: 'f'\n  local.initial: None\n  str(local.type): 'float'\nlocal_decls[1]\n  type(local): <type 'gcc.VarDecl'>\n  local.name: 'g'\n  local.initial: None\n  str(local.type): 'float'\nlocal_decls[2]\n  type(local): <type 'gcc.VarDecl'>\n  local.name: 'h'\n  local.initial: None\n  str(local.type): 'float'\nlocal_decls[3]\n  type(local): <type 'gcc.VarDecl'>\n  local.name: 'i'\n  local.initial.constant: 42\n  str(local.type): 'int'\nlocal_decls[4]\n  type(local): <type 'gcc.VarDecl'>\n  local.name: 'keywords'\n  local.initial: None\n  str(local.type): 'char *[2]'\nlocal_decls[5]\n  type(local): <type 'gcc.VarDecl'>\n  local.name: 'd'\n  local.initial: None\n  str(local.type): 'const double'\nfn.funcdef_no: 0\nfn.start: gcc.Location(file='tests/plugin/functions/input.c', line=23)\nfn.end: gcc.Location(file='tests/plugin/functions/input.c', line=31)\ngimple[0]:\n  str(stmt): 'h = 1.0e+0;'\n  repr(stmt): 'gcc.GimpleAssign()'\n  str(stmt.lhs): 'h'\n  [str(stmt.rhs)]: ['1.0e+0']\ngimple[1]:\n  str(stmt): 'keywords[0] = \"bar\";'\n  repr(stmt): 'gcc.GimpleAssign()'\n  str(stmt.lhs): 'keywords[0]'\n  [str(stmt.rhs)]: ['\"bar\"']\ngimple[2]:\n  str(stmt): 'keywords[1] = 0B;'\n  repr(stmt): 'gcc.GimpleAssign()'\n  str(stmt.lhs): 'keywords[1]'\n  [str(stmt.rhs)]: ['0B']\nfn.decl.arguments: [gcc.ParmDecl('a'), gcc.ParmDecl('b')]\n  arg[0]:\n    arg.name: 'a'\n    str(arg.type): 'int'\n  arg[1]:\n    arg.name: 'b'\n    str(arg.type): 'int'\ntype(fn.decl.result): <type 'gcc.ResultDecl'>\n  str(fn.decl.result.type): 'void'\n"
  },
  {
    "path": "tests/plugin/gc/_force_garbage_collection/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* empty */\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gc/_force_garbage_collection/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that we can forcibly invoke GCC's garbage collector,\n# (for selftest purposes)\n\nimport gcc\n\n# Count the number of garbage collections:\nnum_ggc_collections = 0\ndef on_ggc_start():\n    global num_ggc_collections\n    num_ggc_collections += 1\n\ngcc.register_callback(gcc.PLUGIN_GGC_START,\n                      on_ggc_start)\n\ndef on_finish():\n    # Now traverse all of the data seen at every previous pass\n    print('on_finish')\n\n    if 0:\n        print('num_ggc_collections: %i ' % num_ggc_collections)\n\n    # Call gcc._force_garbage_collection(), and verify that on_ggc_start\n    # gets called:\n    old_collections = num_ggc_collections\n    gcc._force_garbage_collection()\n\n    # num_ggc_collections should have increased by 1:\n    assert num_ggc_collections > 0\n    assert num_ggc_collections == old_collections + 1\n    print('num_ggc_collections: new - old: %i '\n          % (num_ggc_collections - old_collections))\n\n    if 0:\n        print('num_ggc_collections: %i ' % num_ggc_collections)\n\ngcc.register_callback(gcc.PLUGIN_FINISH,\n                      on_finish)\n\n"
  },
  {
    "path": "tests/plugin/gc/_force_garbage_collection/stdout.txt",
    "content": "on_finish\nnum_ggc_collections: new - old: 1 \n"
  },
  {
    "path": "tests/plugin/gc/_gc_selftest/input.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Trivial example code to be compiled, for testing purposes\n */\n\n#include <stdio.h>\n\nint\nhelper_function(void)\n{\n    printf(\"I am a helper function\\n\");\n    return 42;\n}\n\nint\nmain(int argc, char **argv)\n{\n    int i;\n\n    printf(\"argc: %i\\n\", argc);\n\n    for (i = 0; i < argc; i++) {\n        printf(\"argv[%i]: %s\\n\", i, argv[i]);\n    }\n\n    helper_function();\n\n    return 0;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gc/_gc_selftest/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Invoke C-based selftest of integration with GCC's garbage collector\nimport gcc\n\ndef on_finish():\n    gcc._gc_selftest()\n\ngcc.register_callback(gcc.PLUGIN_FINISH,\n                      on_finish)\n"
  },
  {
    "path": "tests/plugin/gc/_gc_selftest/stdout.txt",
    "content": "gcc._gc_selftest() starting\ncreating test GCC objects\n  PyGccWrapper_Track: gcc.IntegerCst\n  PyGccWrapper_Track: gcc.StringCst\nforcing a garbage collection:\n  walking the live PyGccWrapper objects\n    marking inner object for: gcc.IntegerCst(42)\n    marking inner object for: gcc.StringCst('I am only referenced via a python wrapper')\n  finished walking the live PyGccWrapper objects\ncompleted the forced garbage collection\nverifying that the underlying GCC objects were marked\nall of the underlying GCC objects were indeed marked\ninvoking DECREF on Python wrapper objects\n  PyGccWrapper_Dealloc: gcc.IntegerCst\n    PyGcc_wrapper_untrack: gcc.IntegerCst\n  PyGccWrapper_Dealloc: gcc.StringCst\n    PyGcc_wrapper_untrack: gcc.StringCst\ngcc._gc_selftest() complete\n"
  },
  {
    "path": "tests/plugin/gc/segfault-on-instance-of-pass-subclass/input.c",
    "content": "/* empty */\n"
  },
  {
    "path": "tests/plugin/gc/segfault-on-instance-of-pass-subclass/script.py",
    "content": "import gcc\n\nclass UnusedArg(gcc.GimplePass):\n    def execute(self, fun):\n        pass\n\nps = UnusedArg(name='UnusedArg')\nps.register_after('lower')\n\ngcc._force_garbage_collection()\n"
  },
  {
    "path": "tests/plugin/gimple-asm/input.c",
    "content": "/*\n   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nvoid\nhelper_function(void)\n{\n    long i, j;\n\n    /* Empty assembler (as seen e.g. in curl's typecheck-gcc.h */\n    __asm__(\"\");\n\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gimple-asm/script.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify examining details of functions\n\nimport gcc\nfrom gccutils import pprint\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        assert isinstance(fn, gcc.Function)\n        print('fn: %r' % fn)\n\n        if fn.cfg: # None for some early passes\n            print('CFG:')\n            for bb in fn.cfg.basic_blocks:\n                print('  BLOCK %i' % bb.index)\n                if bb.gimple:\n                    for i,stmt in enumerate(bb.gimple):\n                        print('  gimple[%i]:' % i)\n                        print('    str(stmt): %r' % str(stmt))\n                        print('    repr(stmt): %r' % repr(stmt))\n                        if isinstance(stmt, gcc.GimpleAsm):\n                            # (see dump_gimple_asm in gcc/gimple-pretty-print.c)\n                            print('     stmt.string: %r' % stmt.string)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/gimple-asm/stdout.txt",
    "content": "fn: gcc.Function('helper_function')\nCFG:\n  BLOCK 0\n  BLOCK 1\n  BLOCK 2\n  gimple[0]:\n    str(stmt): '__asm__ __volatile__(\"\");'\n    repr(stmt): 'gcc.GimpleAsm()'\n     stmt.string: ''\n  gimple[1]:\n    str(stmt): 'return;'\n    repr(stmt): 'gcc.GimpleReturn()'\n"
  },
  {
    "path": "tests/plugin/gimple-cond/explicit-comparison/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Trivial example code to be compiled, for testing purposes\n */\n\nint\nhelper_function(int a, int b)\n{\n    /* This should lead to a GimpleCond statement: */\n    if (a < b) {\n        return 42;\n    } else {\n        return a - b;\n    }\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gimple-cond/explicit-comparison/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify examining details of functions\n\nimport gcc\nfrom gccutils import pprint\n\ndef on_pass_execution(p, fn):\n    if p.name in '*warn_function_return':\n        assert isinstance(fn, gcc.Function)\n        print('fn: %r' % fn)\n\n        assert isinstance(fn.decl, gcc.FunctionDecl)\n        print('fn.decl.name: %r' % fn.decl.name)\n\n        if fn.cfg: # None for some early passes\n            print('CFG:')\n            for bb in fn.cfg.basic_blocks:\n                print('  BLOCK %i' % bb.index)\n                if bb.gimple:\n                    for i,stmt in enumerate(bb.gimple):\n                        print('  gimple[%i]:' % i)\n                        print('    str(stmt): %r' % str(stmt))\n                        print('    repr(stmt): %r' % repr(stmt))\n                        if isinstance(stmt, gcc.GimpleCond):\n                            print('    stmt.lhs: %r' % stmt.lhs)\n                            print('    stmt.exprcode: %r' % stmt.exprcode)\n                            print('    stmt.rhs: %r' % stmt.rhs)\n                            print('    stmt.true_label: %r' % stmt.true_label)\n                            print('    stmt.false_label: %r' % stmt.false_label)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/gimple-cond/explicit-comparison/stdout.txt",
    "content": "fn: gcc.Function('helper_function')\nfn.decl.name: 'helper_function'\nCFG:\n  BLOCK 0\n  BLOCK 1\n  BLOCK 2\n  gimple[0]:\n    str(stmt): 'if (a < b)'\n    repr(stmt): 'gcc.GimpleCond()'\n    stmt.lhs: gcc.ParmDecl('a')\n    stmt.exprcode: <type 'gcc.LtExpr'>\n    stmt.rhs: gcc.ParmDecl('b')\n    stmt.true_label: None\n    stmt.false_label: None\n  BLOCK 3\n  gimple[0]:\n    str(stmt): 'D.nnnnn = 42;'\n    repr(stmt): 'gcc.GimpleAssign()'\n  BLOCK 4\n  gimple[0]:\n    str(stmt): 'D.nnnnn = a - b;'\n    repr(stmt): 'gcc.GimpleAssign()'\n  BLOCK 5\n  gimple[0]:\n    str(stmt): 'return D.nnnnn;'\n    repr(stmt): 'gcc.GimpleReturn()'\n"
  },
  {
    "path": "tests/plugin/gimple-cond/implicit-comparison/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Trivial example code to be compiled, for testing purposes\n */\n\nint\nhelper_function(int a, int b)\n{\n    /* This should lead to a GimpleCond statement: */\n    if (a) {\n        return 42;\n    } else {\n        return b;\n    }\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gimple-cond/implicit-comparison/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify examining details of functions\n\nimport gcc\nfrom gccutils import pprint\n\ndef on_pass_execution(p, fn):\n    if p.name in '*warn_function_return':\n        assert isinstance(fn, gcc.Function)\n        print('fn: %r' % fn)\n\n        assert isinstance(fn.decl, gcc.FunctionDecl)\n        print('fn.decl.name: %r' % fn.decl.name)\n\n        if fn.cfg: # None for some early passes\n            print('CFG:')\n            for bb in fn.cfg.basic_blocks:\n                print('  BLOCK %i' % bb.index)\n                if bb.gimple:\n                    for i,stmt in enumerate(bb.gimple):\n                        print('  gimple[%i]:' % i)\n                        print('    str(stmt): %r' % str(stmt))\n                        print('    repr(stmt): %r' % repr(stmt))\n                        if isinstance(stmt, gcc.GimpleCond):\n                            print('    stmt.lhs: %r' % stmt.lhs)\n                            print('    stmt.exprcode: %r' % stmt.exprcode)\n                            print('    stmt.rhs: %r' % stmt.rhs)\n                            print('    stmt.true_label: %r' % stmt.true_label)\n                            print('    stmt.false_label: %r' % stmt.false_label)\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/gimple-cond/implicit-comparison/stdout.txt",
    "content": "fn: gcc.Function('helper_function')\nfn.decl.name: 'helper_function'\nCFG:\n  BLOCK 0\n  BLOCK 1\n  BLOCK 2\n  gimple[0]:\n    str(stmt): 'if (a != 0)'\n    repr(stmt): 'gcc.GimpleCond()'\n    stmt.lhs: gcc.ParmDecl('a')\n    stmt.exprcode: <type 'gcc.NeExpr'>\n    stmt.rhs: gcc.IntegerCst(0)\n    stmt.true_label: None\n    stmt.false_label: None\n  BLOCK 3\n  gimple[0]:\n    str(stmt): 'D.nnnnn = 42;'\n    repr(stmt): 'gcc.GimpleAssign()'\n  BLOCK 4\n  gimple[0]:\n    str(stmt): 'D.nnnnn = b;'\n    repr(stmt): 'gcc.GimpleAssign()'\n  BLOCK 5\n  gimple[0]:\n    str(stmt): 'return D.nnnnn;'\n    repr(stmt): 'gcc.GimpleReturn()'\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/dump-all/input.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Trivial example code to be compiled, for testing purposes\n */\n\n#include <stdio.h>\n\nint\nhelper_function(void)\n{\n    printf(\"I am a helper function\\n\");\n    return 42;\n}\n\nint\nmain(int argc, char **argv)\n{\n    int i;\n\n    printf(\"argc: %i\\n\", argc);\n\n    for (i = 0; i < argc; i++) {\n        printf(\"argv[%i]: %s\\n\", i, argv[i]);\n    }\n\n    helper_function();\n\n    return 0;\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/dump-all/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Selftest for gcc.Gimple.walk_tree\nimport gcc\n\nclass DumpTreeNodesPass(gcc.GimplePass):\n    def execute(self, fun):\n        # This is called per-function during compilation:\n        print('fun: %s' % fun)\n        for bb in fun.cfg.basic_blocks:\n            if bb.gimple:\n                for stmt in bb.gimple:\n                    print('  stmt: %s' % stmt)\n                    stmt.walk_tree(self.dump_node, stmt.loc)\n\n    def dump_node(self, node, loc):\n        print('    node: %r (%s)' % (node, node))\n\nps = DumpTreeNodesPass(name='dump-tree-nodes')\nps.register_after('cfg')\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/dump-all/stdout.txt",
    "content": "fun: gcc.Function('main')\n  stmt: D.nnnnn = (const char * restrict) &\"argc: %i\\n\"[0];\n    node: <gcc.AddrExpr object at 0xdeadbeef> (&\"argc: %i\\n\"[0])\n    node: <gcc.ArrayRef object at 0xdeadbeef> (\"argc: %i\\n\"[0])\n    node: gcc.StringCst('argc: %i\\n') (\"argc: %i\\n\")\n    node: gcc.IntegerCst(0) (0)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: printf (D.nnnnn, argc);\n    node: <gcc.AddrExpr object at 0xdeadbeef> (printf)\n    node: gcc.FunctionDecl('printf') (printf)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n    node: gcc.ParmDecl('argc') (argc)\n  stmt: i = 0;\n    node: gcc.IntegerCst(0) (0)\n    node: gcc.VarDecl('i') (i)\n  stmt: D.nnnnn = (long unsigned int) i;\n    node: gcc.VarDecl('i') (i)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: D.nnnnn = D.nnnnn * 8;\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n    node: gcc.IntegerCst(8) (8)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: D.nnnnn = argv + D.nnnnn;\n    node: gcc.ParmDecl('argv') (argv)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: D.nnnnn = *D.nnnnn;\n    node: <gcc.MemRef object at 0xdeadbeef> (*D.nnnnn)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n    node: gcc.IntegerCst(0) (0B)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: D.nnnnn = (const char * restrict) &\"argv[%i]: %s\\n\"[0];\n    node: <gcc.AddrExpr object at 0xdeadbeef> (&\"argv[%i]: %s\\n\"[0])\n    node: <gcc.ArrayRef object at 0xdeadbeef> (\"argv[%i]: %s\\n\"[0])\n    node: gcc.StringCst('argv[%i]: %s\\n') (\"argv[%i]: %s\\n\")\n    node: gcc.IntegerCst(0) (0)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: printf (D.nnnnn, i, D.nnnnn);\n    node: <gcc.AddrExpr object at 0xdeadbeef> (printf)\n    node: gcc.FunctionDecl('printf') (printf)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n    node: gcc.VarDecl('i') (i)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: i = i + 1;\n    node: gcc.VarDecl('i') (i)\n    node: gcc.IntegerCst(1) (1)\n    node: gcc.VarDecl('i') (i)\n  stmt: if (i < argc)\n    node: gcc.VarDecl('i') (i)\n    node: gcc.ParmDecl('argc') (argc)\n  stmt: helper_function ();\n    node: <gcc.AddrExpr object at 0xdeadbeef> (helper_function)\n    node: gcc.FunctionDecl('helper_function') (helper_function)\n  stmt: D.nnnnn = 0;\n    node: gcc.IntegerCst(0) (0)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: return D.nnnnn;\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\nfun: gcc.Function('helper_function')\n  stmt: __builtin_puts (&\"I am a helper function\"[0]);\n    node: <gcc.AddrExpr object at 0xdeadbeef> (__builtin_puts)\n    node: gcc.FunctionDecl('__builtin_puts') (__builtin_puts)\n    node: <gcc.AddrExpr object at 0xdeadbeef> (&\"I am a helper function\"[0])\n    node: <gcc.ArrayRef object at 0xdeadbeef> (\"I am a helper function\"[0])\n    node: gcc.StringCst('I am a helper function') (\"I am a helper function\")\n    node: gcc.IntegerCst(0) (0)\n  stmt: D.nnnnn = 42;\n    node: gcc.IntegerCst(42) (42)\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n  stmt: return D.nnnnn;\n    node: gcc.VarDecl(nnnn) (D.nnnnn)\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/exceptions/input.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Trivial example code to be compiled, for testing purposes\n */\n\n#include <stdio.h>\n\nint\nhelper_function(void)\n{\n    printf(\"I am a helper function\\n\");\n    return 42;\n}\n\nint\nmain(int argc, char **argv)\n{\n    int i;\n\n    printf(\"argc: %i\\n\", argc);\n\n    for (i = 0; i < argc; i++) {\n        printf(\"argv[%i]: %s\\n\", i, argv[i]);\n    }\n\n    helper_function();\n\n    return 0;\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/exceptions/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Selftest for gcc.Gimple.walk_tree\nimport gcc\n\nclass WalkTreeNodesPass(gcc.GimplePass):\n    def execute(self, fun):\n        # This is called per-function during compilation:\n        print('fun: %s' % fun)\n        for bb in fun.cfg.basic_blocks:\n            if bb.gimple:\n                for stmt in bb.gimple:\n                    print('  stmt: %s' % stmt)\n                    stmt.walk_tree(self.dump_node, stmt.loc)\n\n    def dump_node(self, node, loc):\n        raise RuntimeError('this is a test error')\n\nps = WalkTreeNodesPass(name='walk-tree-nodes')\nps.register_after('cfg')\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/exceptions/stderr.txt",
    "content": "tests/plugin/gimple-walk-tree/exceptions/input.c: In function 'main':\ntests/plugin/gimple-walk-tree/exceptions/input.c:35:1: error: Unhandled Python exception raised calling 'execute' method\nTraceback (most recent call last):\n  File \"tests/plugin/gimple-walk-tree/exceptions/script.py\", line 30, in execute\n    stmt.walk_tree(self.dump_node, stmt.loc)\n  File \"tests/plugin/gimple-walk-tree/exceptions/script.py\", line 33, in dump_node\n    raise RuntimeError('this is a test error')\nRuntimeError: this is a test error\ntests/plugin/gimple-walk-tree/exceptions/input.c: In function 'helper_function':\ntests/plugin/gimple-walk-tree/exceptions/input.c:28:1: error: Unhandled Python exception raised calling 'execute' method\nTraceback (most recent call last):\n  File \"tests/plugin/gimple-walk-tree/exceptions/script.py\", line 30, in execute\n    stmt.walk_tree(self.dump_node, stmt.loc)\n  File \"tests/plugin/gimple-walk-tree/exceptions/script.py\", line 33, in dump_node\n    raise RuntimeError('this is a test error')\nRuntimeError: this is a test error\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/exceptions/stdout.txt",
    "content": "fun: gcc.Function('main')\n  stmt: D.nnnnn = (const char * restrict) &\"argc: %i\\n\"[0];\nfun: gcc.Function('helper_function')\n  stmt: __builtin_puts (&\"I am a helper function\"[0]);\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/find-one/input.c",
    "content": "/*\n   Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011, 2012 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Trivial example code to be compiled, for testing purposes\n */\n\n#include <stdio.h>\n\nint\nhelper_function(void)\n{\n    printf(\"I am a helper function\\n\");\n    return 42;\n}\n\nint\nmain(int argc, char **argv)\n{\n    int i;\n\n    printf(\"argc: %i\\n\", argc);\n\n    for (i = 0; i < argc; i++) {\n        printf(\"argv[%i]: %s\\n\", i, argv[i]);\n    }\n\n    helper_function();\n\n    return 0;\n}\n\n/*\n  PEP-7  \nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/find-one/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Selftest for gcc.Gimple.walk_tree\nimport gcc\n\nclass FindTreeNodesPass(gcc.GimplePass):\n    def execute(self, fun):\n        # This is called per-function during compilation:\n        print('fun: %s' % fun)\n        for bb in fun.cfg.basic_blocks:\n            if bb.gimple:\n                for stmt in bb.gimple:\n                    print('  stmt: %s' % stmt)\n                    node = stmt.walk_tree(self.find_node)\n                    if node:\n                        print('    node: %r (%s)' % (node, node))\n\n    def find_node(self, node):\n        # Locate the first string constant in each statement:\n        if isinstance(node, gcc.StringCst):\n            return True\n\nps = FindTreeNodesPass(name='find-tree-nodes')\nps.register_after('cfg')\n"
  },
  {
    "path": "tests/plugin/gimple-walk-tree/find-one/stdout.txt",
    "content": "fun: gcc.Function('main')\n  stmt: D.nnnnn = (const char * restrict) &\"argc: %i\\n\"[0];\n    node: gcc.StringCst('argc: %i\\n') (\"argc: %i\\n\")\n  stmt: printf (D.nnnnn, argc);\n  stmt: i = 0;\n  stmt: D.nnnnn = (long unsigned int) i;\n  stmt: D.nnnnn = D.nnnnn * 8;\n  stmt: D.nnnnn = argv + D.nnnnn;\n  stmt: D.nnnnn = *D.nnnnn;\n  stmt: D.nnnnn = (const char * restrict) &\"argv[%i]: %s\\n\"[0];\n    node: gcc.StringCst('argv[%i]: %s\\n') (\"argv[%i]: %s\\n\")\n  stmt: printf (D.nnnnn, i, D.nnnnn);\n  stmt: i = i + 1;\n  stmt: if (i < argc)\n  stmt: helper_function ();\n  stmt: D.nnnnn = 0;\n  stmt: return D.nnnnn;\nfun: gcc.Function('helper_function')\n  stmt: __builtin_puts (&\"I am a helper function\"[0]);\n    node: gcc.StringCst('I am a helper function') (\"I am a helper function\")\n  stmt: D.nnnnn = 42;\n  stmt: return D.nnnnn;\n"
  },
  {
    "path": "tests/plugin/identifiers/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nstruct foo {\n  int first_field;\n  char *second_field;\n};\n\n"
  },
  {
    "path": "tests/plugin/identifiers/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that we can lookup identifiers by name\n\nimport gcc\n\ndef on_pass_execution(p, data):\n    if p.name == 'visibility':\n        foo = gcc.maybe_get_identifier('foo')\n        print('str(foo): %s' % foo)\n        print('type(foo): %s' % type(foo))\n\n        bar = gcc.maybe_get_identifier('bar')\n        print('str(bar): %s' % bar)\n        print('type(bar): %s' % type(bar))\n\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/identifiers/stdout.txt",
    "content": "str(foo): foo\ntype(foo): <type 'gcc.IdentifierNode'>\nstr(bar): None\ntype(bar): <type 'NoneType'>\n"
  },
  {
    "path": "tests/plugin/initializers/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nstruct foo {\n  int first_field;\n  char *second_field;\n};\n\nstruct foo f[] = {\n  {42, \"giraffe\"},\n  {37, \"elephant\"},\n  {72, \"sea otter\"},\n};\n\nstruct foo g[0];\n\nstruct foo h[] = {\n  {89, \"turtle\"},\n  {37, \"lion\"},\n};\n\n"
  },
  {
    "path": "tests/plugin/initializers/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that we can inspect the initialization of arrays of structures.\n\nimport gcc\n\ndef on_pass_execution(p, data):\n    if p.name == 'visibility':\n        \n        vars = gcc.get_variables()\n        print('len(gcc.get_variables()) is %i' % len(gcc.get_variables()))\n        for i, var in enumerate(vars):\n            print('%i: var.decl.name = %r' % (i, var.decl.name))\n\n            assert isinstance(var.decl, gcc.VarDecl)\n            print('   var.decl.type: %s' % var.decl.type)\n\n            assert isinstance(var.decl.type, gcc.ArrayType)\n            print('   var.decl.type.type: %s' % var.decl.type.type)\n        \n            if var.decl.initial:\n                assert isinstance(var.decl.initial, gcc.Constructor)\n                print('   len(var.decl.initial.elements): %s' % len(var.decl.initial.elements))\n                assert isinstance(var.decl.initial.elements, list)\n                for j, (idx, value) in enumerate(var.decl.initial.elements):\n                    assert isinstance(idx, gcc.IntegerCst) # FIXME: value ought to be j\n                    print('     elements[%i]:' % j)\n                    print('       value: %s' % value)\n                    for k, (idx2, value2) in enumerate(value.elements):\n                        print('       elements[%i].elements[%i]:' % (j, k))\n                        print('         idx2: %r' % idx2)\n                        print('         value2: %s' % value2)\n                        if isinstance(idx2, gcc.Declaration):\n                            print('         idx2.name: %r' % idx2.name)\n                                    \n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/initializers/stdout.txt",
    "content": "len(gcc.get_variables()) is 3\n0: var.decl.name = 'h'\n   var.decl.type: struct foo[2]\n   var.decl.type.type: struct foo\n   len(var.decl.initial.elements): 2\n     elements[0]:\n       value: {.first_field=89, .second_field=(char *) \"turtle\"}\n       elements[0].elements[0]:\n         idx2: gcc.FieldDecl('first_field')\n         value2: 89\n         idx2.name: 'first_field'\n       elements[0].elements[1]:\n         idx2: gcc.FieldDecl('second_field')\n         value2: (char *) \"turtle\"\n         idx2.name: 'second_field'\n     elements[1]:\n       value: {.first_field=37, .second_field=(char *) \"lion\"}\n       elements[1].elements[0]:\n         idx2: gcc.FieldDecl('first_field')\n         value2: 37\n         idx2.name: 'first_field'\n       elements[1].elements[1]:\n         idx2: gcc.FieldDecl('second_field')\n         value2: (char *) \"lion\"\n         idx2.name: 'second_field'\n1: var.decl.name = 'g'\n   var.decl.type: struct foo[0:]\n   var.decl.type.type: struct foo\n2: var.decl.name = 'f'\n   var.decl.type: struct foo[3]\n   var.decl.type.type: struct foo\n   len(var.decl.initial.elements): 3\n     elements[0]:\n       value: {.first_field=42, .second_field=(char *) \"giraffe\"}\n       elements[0].elements[0]:\n         idx2: gcc.FieldDecl('first_field')\n         value2: 42\n         idx2.name: 'first_field'\n       elements[0].elements[1]:\n         idx2: gcc.FieldDecl('second_field')\n         value2: (char *) \"giraffe\"\n         idx2.name: 'second_field'\n     elements[1]:\n       value: {.first_field=37, .second_field=(char *) \"elephant\"}\n       elements[1].elements[0]:\n         idx2: gcc.FieldDecl('first_field')\n         value2: 37\n         idx2.name: 'first_field'\n       elements[1].elements[1]:\n         idx2: gcc.FieldDecl('second_field')\n         value2: (char *) \"elephant\"\n         idx2.name: 'second_field'\n     elements[2]:\n       value: {.first_field=72, .second_field=(char *) \"sea otter\"}\n       elements[2].elements[0]:\n         idx2: gcc.FieldDecl('first_field')\n         value2: 72\n         idx2.name: 'first_field'\n       elements[2].elements[1]:\n         idx2: gcc.FieldDecl('second_field')\n         value2: (char *) \"sea otter\"\n         idx2.name: 'second_field'\n"
  },
  {
    "path": "tests/plugin/language-specific-errors/fullname/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nvoid foo(int x, int y)\n{\n}\n\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/language-specific-errors/fullname/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that an attempt to use the \"fullname\" attribute outside of C++\n# is gracefully handled\n\nimport gcc\n\nclass TestPass(gcc.GimplePass):\n    def execute(self, fn):\n        print('fn: %r' % fn)\n        print('  fn.decl.name: %r' % fn.decl.name)\n        # This ought to raise a RuntimeError\n        print('  fn.decl.fullname: %r' % fn.decl.fullname)\n\ntest_pass = TestPass(name='test-pass')\ntest_pass.register_after('cfg')\n"
  },
  {
    "path": "tests/plugin/language-specific-errors/fullname/stderr.txt",
    "content": "In function 'foo':\ntests/plugin/language-specific-errors/fullname/input.c:21:nn: error: Unhandled Python exception raised calling 'execute' method\nTraceback (most recent call last):\n  File \"tests/plugin/language-specific-errors/fullname/script.py\", line 29, in execute\n    print('  fn.decl.fullname: %r' % fn.decl.fullname)\nRuntimeError: attribute 'fullname' is only available when compiling C++ code\n"
  },
  {
    "path": "tests/plugin/language-specific-errors/fullname/stdout.txt",
    "content": "fn: gcc.Function('foo')\n  fn.decl.name: 'foo'\n"
  },
  {
    "path": "tests/plugin/macros/correct/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Test of adding custom preprocessor macros */\n\n#ifndef FOO\n  /* We should not get here: */\n  #error FOO is not defined\n#endif\n\n#ifndef BAR\n  /* We should not get here: */\n  #error BAR is not defined\n#endif\n\n#if BAR != 42\n  /* We should not get here: */\n  #error BAR is not 42\n#endif\n\nint main(int argc, char *argv[])\n{\n    return BAR;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/macros/correct/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Verify that we can register custom preprocessor macros:\n\ndef register_our_macros():\n    gcc.define_macro('FOO')\n    gcc.define_macro('BAR=42')\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_ATTRIBUTES,\n                      register_our_macros)\n"
  },
  {
    "path": "tests/plugin/macros/correct/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/plugin/macros/too-early/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* Test of adding custom preprocessor macros */\n\n#ifndef FOO\n  /* We should not get here: */\n  #error FOO is not defined\n#endif\n\n#ifndef BAR\n  /* We should not get here: */\n  #error BAR is not defined\n#endif\n\n#if BAR != 42\n  /* We should not get here: */\n  #error BAR is not 42\n#endif\n\nint main(int argc, char *argv[])\n{\n    return BAR;\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/macros/too-early/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Verify that we gracefully handle an attempt to register a custom\n# preprocessor macros at the wrong time:\n\ngcc.define_macro('THIS_IS_TOO_EARLY')\n"
  },
  {
    "path": "tests/plugin/macros/too-early/stderr.txt",
    "content": "Traceback (most recent call last):\n  File \"tests/plugin/macros/too-early/script.py\", line 23, in <module>\n    gcc.define_macro('THIS_IS_TOO_EARLY')\nValueError: gcc.define_macro(\"THIS_IS_TOO_EARLY\") called from outside an event callback\n"
  },
  {
    "path": "tests/plugin/macros/too-early/stdout.txt",
    "content": ""
  },
  {
    "path": "tests/plugin/namespace/input.cc",
    "content": "namespace top {\n  union top_union{\n    int i;\n    char c;\n    float f;\n  };\n  namespace sub {\n     int subs_int;\n     void subs_function(void);\n     void *foo;\n     namespace sub_sub {\n\tvoid foo();\n     }\n  }\n  namespace sub_alias = sub;\n  namespace sub_alias_alias = sub_alias;\n  namespace foo {\n    namespace bar {\n    }\n  }\n};\nnamespace top_alias_of_alias = top::sub;\n"
  },
  {
    "path": "tests/plugin/namespace/script.py",
    "content": "#   Copyright 2012 Matt Rice <ratmice@gmail.com>\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Test case for gcc.NamespaceDecl\n\nimport gcc\n\ndef indent_print(depth, thing):\n  print(\"%s%s\" % (\"   \" * depth, thing))\n\ndef print_namespace(ns, depth):\n  attributes = (\"name\", \"alias_of\", \"declarations\", \"namespaces\")\n  # [(method, arg),...]\n  methods = [(gcc.NamespaceDecl.unalias, None),\n\t     (gcc.NamespaceDecl.lookup, \"foo\")]\n\n  for attr in attributes:\n    try:\n      indent_print(depth, (attr, ns.__getattribute__(attr)))\n    except Exception as e:\n      indent_print(depth, (attr, e))\n\n  for t in methods:\n    method_name = t[0].__name__\n    method = t[0]\n    try:\n      indent_print(depth, (method_name, method(ns, t[1])))\n    except Exception as e:\n      indent_print(depth, (method_name, e))\n\n  print('')\n\ndef dump_namespaces(ns, depth):\n\n  # ignore builtin's they would just make stdout.txt painful.\n  if ns.is_builtin == False:\n    print_namespace(ns, depth)\n\n  # aliases of namespaces in particular will occur\n  # within declarations, but we don't want to call\n  # declarations on them (here).\n  if ns.alias_of == None:\n    for decl in ns.declarations:\n      if type(decl) == gcc.NamespaceDecl:\n        dump_namespaces(decl, depth + 1)\n\n    # nested namespaces..\n    for namespace in ns.namespaces:\n      dump_namespaces(namespace, depth + 1)\n\ndef finish_unit_cb(*args, **kwargs):\n  # depth of -1 to ignore the global namespace itself (because its a builtin).\n  dump_namespaces(gcc.get_global_namespace(), -1)\n\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT, finish_unit_cb)\n"
  },
  {
    "path": "tests/plugin/namespace/stdout.txt",
    "content": "('name', 'top_alias_of_alias')\n('alias_of', gcc.NamespaceDecl('sub'))\n('declarations', RuntimeError('gcc.NamespaceDecl.declarations is not valid for an alias',))\n('namespaces', RuntimeError('gcc.NamespaceDecl.namespaces is not valid for an alias',))\n('unalias', gcc.NamespaceDecl('sub'))\n('lookup', gcc.VarDecl('foo'))\n\n('name', 'top')\n('alias_of', None)\n('declarations', [gcc.NamespaceDecl('sub_alias_alias'), gcc.NamespaceDecl('sub_alias'), gcc.TypeDecl('top_union')])\n('namespaces', [gcc.NamespaceDecl('foo'), gcc.NamespaceDecl('sub')])\n('unalias', gcc.NamespaceDecl('top'))\n('lookup', gcc.NamespaceDecl('foo'))\n\n   ('name', 'sub_alias_alias')\n   ('alias_of', gcc.NamespaceDecl('sub'))\n   ('declarations', RuntimeError('gcc.NamespaceDecl.declarations is not valid for an alias',))\n   ('namespaces', RuntimeError('gcc.NamespaceDecl.namespaces is not valid for an alias',))\n   ('unalias', gcc.NamespaceDecl('sub'))\n   ('lookup', gcc.VarDecl('foo'))\n\n   ('name', 'sub_alias')\n   ('alias_of', gcc.NamespaceDecl('sub'))\n   ('declarations', RuntimeError('gcc.NamespaceDecl.declarations is not valid for an alias',))\n   ('namespaces', RuntimeError('gcc.NamespaceDecl.namespaces is not valid for an alias',))\n   ('unalias', gcc.NamespaceDecl('sub'))\n   ('lookup', gcc.VarDecl('foo'))\n\n   ('name', 'foo')\n   ('alias_of', None)\n   ('declarations', [])\n   ('namespaces', [gcc.NamespaceDecl('bar')])\n   ('unalias', gcc.NamespaceDecl('foo'))\n   ('lookup', None)\n\n      ('name', 'bar')\n      ('alias_of', None)\n      ('declarations', [])\n      ('namespaces', [])\n      ('unalias', gcc.NamespaceDecl('bar'))\n      ('lookup', None)\n\n   ('name', 'sub')\n   ('alias_of', None)\n   ('declarations', [gcc.VarDecl('foo'), gcc.FunctionDecl('subs_function'), gcc.VarDecl('subs_int')])\n   ('namespaces', [gcc.NamespaceDecl('sub_sub')])\n   ('unalias', gcc.NamespaceDecl('sub'))\n   ('lookup', gcc.VarDecl('foo'))\n\n      ('name', 'sub_sub')\n      ('alias_of', None)\n      ('declarations', [gcc.FunctionDecl('foo')])\n      ('namespaces', [])\n      ('unalias', gcc.NamespaceDecl('sub_sub'))\n      ('lookup', gcc.FunctionDecl('foo'))\n\n"
  },
  {
    "path": "tests/plugin/new-passes/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\nint foo(const char *str)\n{\n    if (str) {\n        return 42;\n    } else {\n        return 0;\n    }\n}\n\nint bar(const char *str)\n{\n    if (str) {\n        return 0;\n    } else {\n        return 42;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/new-passes/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\n\n# Verify that we can lookup passes by name:\nprint(\"gcc.Pass.get_by_name('*build_cgraph_edges'): %r\"\n      % gcc.Pass.get_by_name('*build_cgraph_edges'))\n\n# Verify that we can create new gcc.Pass subclasses\n\n# Verify various forms of \"gate\" behavior:\nclass GimplePassWithoutGate(gcc.GimplePass):\n    def execute(*args):\n        print('within %s.execute%r' % (args[0].__class__.__name__, args))\nps = GimplePassWithoutGate(name='gimple-pass-without-gate')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\n\nclass GimplePassWithFalseGate(gcc.GimplePass):\n    def gate(*args):\n        print('within %s.gate%r' % (args[0].__class__.__name__, args))\n        return False\n\n    def execute(*args):\n        # This shouldn't get called, since the gate returns False\n        print('within %s.execute%r' % (args[0].__class__.__name__, args))\n\nps = GimplePassWithFalseGate(name='gimple-pass-with-false-gate')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\n\nclass GimplePassWithTrueGate(gcc.GimplePass):\n    def gate(*args):\n        print('within %s.gate%r' % (args[0].__class__.__name__, args))\n        return True\n\n    def execute(*args):\n        print('within %s.execute%r' % (args[0].__class__.__name__, args))\n\nps = GimplePassWithTrueGate(name='gimple-pass-with-true-gate')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\n\nclass GimplePassWithErrorInGate(gcc.GimplePass):\n    def gate(*args):\n        print('within %s.gate%r' % (args[0].__class__.__name__, args))\n        raise ValueError('example of a gate method raising an exception')\n\n    def execute(*args):\n        print('within %s.execute%r' % (args[0].__class__.__name__, args))\n\nps = GimplePassWithErrorInGate(name='gimple-pass-with-error-in-gate')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\n# Verify \"execute\" behavior:\n\nclass GimplePassWithErrorInExecute(gcc.GimplePass):\n    def execute(*args):\n        print('within %s.execute%r' % (args[0].__class__.__name__, args))\n        raise ValueError('example of an execute method raising an exception')\n\nps = GimplePassWithErrorInExecute(name='gimple-pass-with-error-in-exception')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\n\nclass GimplePassWithBadReturnFromExecute(gcc.GimplePass):\n    def execute(*args):\n        print('within %s.execute%r' % (args[0].__class__.__name__, args))\n        return('hello world')\n\nps = GimplePassWithBadReturnFromExecute(name='gimple-pass-with-bad-return-from-execute')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\n\n# Verify that we can create new subclasses of the other subclasses of gcc.Pass:\nclass MyRtlPass(gcc.RtlPass):\n    def execute(*args):\n        print('within MyRtlPass.execute%r' % (args, ))\n\nps = MyRtlPass(name='my-rtl-pass')\nprint('registering: %r' % ps)\nps.register_after('expand')\n\n\nclass MySimpleIpaPass(gcc.SimpleIpaPass):\n    def execute(*args):\n        print('within MySimpleIpaPass.execute%r' % (args, ))\n\nps = MySimpleIpaPass(name='my-simple-ipa-pass')\nprint('registering: %r' % ps)\nps.register_before('early_local_cleanups') # looks like we can only register within the top-level\n\n\nclass MyIpaPass(gcc.IpaPass):\n    def execute(*args):\n        print('within MyIpaPass.execute%r' % (args, ))\n\nps = MyIpaPass(name='my-ipa-pass')\nprint('registering: %r' % ps)\nps.replace('ipa-profile')\n\n\nclass GimplePassSettingLocation(gcc.GimplePass):\n    def execute(*args):\n        print('within %s.execute%r' % (args[0].__class__.__name__, args))\n        gcc.set_location(args[1].end)\n        raise ValueError('this should be at the end of the function')\n\nps = GimplePassSettingLocation(name='gimple-pass-setting-location')\nprint('registering: %r' % ps)\nps.register_after('cfg')\n\n# Verify that the plugin doesn't crash when constructing a pass with\n# an unrecognized kwarg:\nclass TestBogusKwargs(gcc.GimplePass):\n    def __init__(self):\n        gcc.GimplePass.__init__(self, 'test-bogus-kwargs')\n\ntry:\n    ps = TestBogusKwargs(this_is_not_a_valid_kwarg=42)\nexcept:\n    pass\n"
  },
  {
    "path": "tests/plugin/new-passes/stderr.txt",
    "content": "tests/plugin/new-passes/input.c: In function 'bar':\ntests/plugin/new-passes/input.c:36:1: error: Unhandled Python exception raised calling 'execute' method\nTraceback (most recent call last):\n  File \"tests/plugin/new-passes/script.py\", line 128, in execute\n    raise ValueError('this should be at the end of the function')\nValueError: this should be at the end of the function\ntests/plugin/new-passes/input.c:30:1: error: Unhandled Python exception raised calling 'execute' method\nTypeError: execute returned a non-integer(type str)\ntests/plugin/new-passes/input.c:30:1: error: Unhandled Python exception raised calling 'execute' method\nTraceback (most recent call last):\n  File \"tests/plugin/new-passes/script.py\", line 79, in execute\n    raise ValueError('example of an execute method raising an exception')\nValueError: example of an execute method raising an exception\ntests/plugin/new-passes/input.c:30:1: error: Unhandled Python exception raised calling 'gate' method\nTraceback (most recent call last):\n  File \"tests/plugin/new-passes/script.py\", line 65, in gate\n    raise ValueError('example of a gate method raising an exception')\nValueError: example of a gate method raising an exception\ntests/plugin/new-passes/input.c: In function 'foo':\ntests/plugin/new-passes/input.c:27:1: error: Unhandled Python exception raised calling 'execute' method\nTraceback (most recent call last):\n  File \"tests/plugin/new-passes/script.py\", line 128, in execute\n    raise ValueError('this should be at the end of the function')\nValueError: this should be at the end of the function\ntests/plugin/new-passes/input.c:21:1: error: Unhandled Python exception raised calling 'execute' method\nTypeError: execute returned a non-integer(type str)\ntests/plugin/new-passes/input.c:21:1: error: Unhandled Python exception raised calling 'execute' method\nTraceback (most recent call last):\n  File \"tests/plugin/new-passes/script.py\", line 79, in execute\n    raise ValueError('example of an execute method raising an exception')\nValueError: example of an execute method raising an exception\ntests/plugin/new-passes/input.c:21:1: error: Unhandled Python exception raised calling 'gate' method\nTraceback (most recent call last):\n  File \"tests/plugin/new-passes/script.py\", line 65, in gate\n    raise ValueError('example of a gate method raising an exception')\nValueError: example of a gate method raising an exception\n"
  },
  {
    "path": "tests/plugin/new-passes/stdout.txt",
    "content": "gcc.Pass.get_by_name('*build_cgraph_edges'): gcc.GimplePass(name='*build_cgraph_edges')\nregistering: GimplePassWithoutGate(name='gimple-pass-without-gate')\nregistering: GimplePassWithFalseGate(name='gimple-pass-with-false-gate')\nregistering: GimplePassWithTrueGate(name='gimple-pass-with-true-gate')\nregistering: GimplePassWithErrorInGate(name='gimple-pass-with-error-in-gate')\nregistering: GimplePassWithErrorInExecute(name='gimple-pass-with-error-in-exception')\nregistering: GimplePassWithBadReturnFromExecute(name='gimple-pass-with-bad-return-from-execute')\nregistering: MyRtlPass(name='my-rtl-pass')\nregistering: MySimpleIpaPass(name='my-simple-ipa-pass')\nregistering: MyIpaPass(name='my-ipa-pass')\nregistering: GimplePassSettingLocation(name='gimple-pass-setting-location')\nwithin GimplePassSettingLocation.execute(GimplePassSettingLocation(name='gimple-pass-setting-location'), gcc.Function('bar'))\nwithin GimplePassWithBadReturnFromExecute.execute(GimplePassWithBadReturnFromExecute(name='gimple-pass-with-bad-return-from-execute'), gcc.Function('bar'))\nwithin GimplePassWithErrorInExecute.execute(GimplePassWithErrorInExecute(name='gimple-pass-with-error-in-exception'), gcc.Function('bar'))\nwithin GimplePassWithErrorInGate.gate(GimplePassWithErrorInGate(name='gimple-pass-with-error-in-gate'), gcc.Function('bar'))\nwithin GimplePassWithTrueGate.gate(GimplePassWithTrueGate(name='gimple-pass-with-true-gate'), gcc.Function('bar'))\nwithin GimplePassWithTrueGate.execute(GimplePassWithTrueGate(name='gimple-pass-with-true-gate'), gcc.Function('bar'))\nwithin GimplePassWithFalseGate.gate(GimplePassWithFalseGate(name='gimple-pass-with-false-gate'), gcc.Function('bar'))\nwithin GimplePassWithoutGate.execute(GimplePassWithoutGate(name='gimple-pass-without-gate'), gcc.Function('bar'))\nwithin GimplePassSettingLocation.execute(GimplePassSettingLocation(name='gimple-pass-setting-location'), gcc.Function('foo'))\nwithin GimplePassWithBadReturnFromExecute.execute(GimplePassWithBadReturnFromExecute(name='gimple-pass-with-bad-return-from-execute'), gcc.Function('foo'))\nwithin GimplePassWithErrorInExecute.execute(GimplePassWithErrorInExecute(name='gimple-pass-with-error-in-exception'), gcc.Function('foo'))\nwithin GimplePassWithErrorInGate.gate(GimplePassWithErrorInGate(name='gimple-pass-with-error-in-gate'), gcc.Function('foo'))\nwithin GimplePassWithTrueGate.gate(GimplePassWithTrueGate(name='gimple-pass-with-true-gate'), gcc.Function('foo'))\nwithin GimplePassWithTrueGate.execute(GimplePassWithTrueGate(name='gimple-pass-with-true-gate'), gcc.Function('foo'))\nwithin GimplePassWithFalseGate.gate(GimplePassWithFalseGate(name='gimple-pass-with-false-gate'), gcc.Function('foo'))\nwithin GimplePassWithoutGate.execute(GimplePassWithoutGate(name='gimple-pass-without-gate'), gcc.Function('foo'))\n"
  },
  {
    "path": "tests/plugin/options/getopts.py",
    "content": "# Amongst other things, this test verifies that gcc.Option.is_enabled works\n\n# Set the options that we'll test to some specific values, giving a mixture of\n# true and false values:\nprint('-fno-unroll-loops')\nprint('-fjump-tables')\nprint('-Wno-format')\n"
  },
  {
    "path": "tests/plugin/options/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n"
  },
  {
    "path": "tests/plugin/options/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify behavior of the gcc.Option class\nimport gcc\nhelp(gcc.Option)\n\nfrom pprint import pprint\n\ndef print_option(option):\n    print(option)\n    for attr in ('text',\n                 'help',\n                 'is_enabled',\n                 'is_warning',\n                 'is_optimization',\n                 'is_driver',\n                 'is_target'):\n        print('    option.%s: %r' % (attr, getattr(option, attr)))\n\n# Test direct construction:\noption = gcc.Option('-funroll-loops')\nprint_option(option)\n\n# Test gcc.get_option_list():\noptions = gcc.get_option_list()\nassert isinstance(options, list)\nfor i, option in enumerate(options):\n    assert isinstance(option, gcc.Option)\n    # (Turn this on to dump all options in order of gcc's enum opt_code)\n    if 0:\n        print('option[%i]:' % i)\n        print_option(option)\n\n# Test gcc.get_option_dict():\noptions = gcc.get_option_dict()\nassert isinstance(options, dict)\n\n# Verify various options, including one we disabled (-Wformat):\nfor optname in ('-fjump-tables', '-Wuninitialized', '-Wformat'):\n    option = options[optname]\n    print_option(option)\n\n# Verify the option-not-found case:\noption = gcc.Option('-foptimize-for-web-scale')\n"
  },
  {
    "path": "tests/plugin/options/stderr.txt",
    "content": "Traceback (most recent call last):\n  File \"tests/plugin/options/script.py\", line 59, in <module>\n    option = gcc.Option('-foptimize-for-web-scale')\nValueError: Could not find command line argument with text '-foptimize-for-web-scale'\n"
  },
  {
    "path": "tests/plugin/options/stdout.txt",
    "content": "Help on class Option in module gcc:\n\nclass Option(__builtin__.object)\n |  Methods defined here:\n |  \n |  __init__(...)\n |      x.__init__(...) initializes x; see help(type(x)) for signature\n |  \n |  __repr__(...)\n |      x.__repr__() <==> repr(x)\n |  \n |  ----------------------------------------------------------------------\n |  Data descriptors defined here:\n |  \n |  help\n |      (string) The help text shown for this option\n |  \n |  is_driver\n |      (bool) Is this a driver option?\n |  \n |  is_enabled\n |      True/False for whether or not this option is enabled, raising a NotImplementedError for options for which the plugin cannot tell\n |  \n |  is_optimization\n |      (bool) Does this option control an optimization?\n |  \n |  is_target\n |      (bool) Is this a target-specific option?\n |  \n |  is_warning\n |      (bool) Does this option control a warning message?\n |  \n |  text\n |      (string) The command-line text used to set this option\n |  \n |  ----------------------------------------------------------------------\n |  Data and other attributes defined here:\n |  \n |  __new__ = <built-in method __new__ of gcc.WrapperMeta object>\n |      T.__new__(S, ...) -> a new object with type S, a subtype of T\n\ngcc.Option('-funroll-loops')\n    option.text: '-funroll-loops'\n    option.help: 'Perform loop unrolling when iteration count is known'\n    option.is_enabled: False\n    option.is_warning: False\n    option.is_optimization: True\n    option.is_driver: False\n    option.is_target: False\ngcc.Option('-fjump-tables')\n    option.text: '-fjump-tables'\n    option.help: 'Use jump tables for sufficiently large switch statements'\n    option.is_enabled: True\n    option.is_warning: False\n    option.is_optimization: True\n    option.is_driver: False\n    option.is_target: False\ngcc.Option('-Wuninitialized')\n    option.text: '-Wuninitialized'\n    option.help: 'Warn about uninitialized automatic variables'\n    option.is_enabled: True\n    option.is_warning: True\n    option.is_optimization: False\n    option.is_driver: False\n    option.is_target: False\ngcc.Option('-Wformat')\n    option.text: '-Wformat'\n    option.help: 'Warn about printf/scanf/strftime/strfmon format string anomalies'\n    option.is_enabled: False\n    option.is_warning: True\n    option.is_optimization: False\n    option.is_driver: False\n    option.is_target: False\n"
  },
  {
    "path": "tests/plugin/parameters/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n"
  },
  {
    "path": "tests/plugin/parameters/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify behavior of the gcc.Parameter class\nimport gcc\nhelp(gcc.Parameter)\n\nparams = gcc.get_parameters()\nassert isinstance(params, dict)\n\ndef print_param_named(name):\n    print(name)\n    param = params[name]\n    assert isinstance(param, gcc.Parameter)\n    for attr in ('option',\n                 'current_value', 'default_value',  'max_value', 'min_value',\n                 'help'):\n        print('  param.%s: %r' % (attr, getattr(param, attr)))\n\nprint_param_named('struct-reorg-cold-struct-ratio')\nprint_param_named('predictable-branch-outcome')\n\n# Verify that paramters can be set via \"current_value\":\np = params['predictable-branch-outcome']\nassert p.current_value > 0\np.current_value = 0\nassert p.current_value == 0\n"
  },
  {
    "path": "tests/plugin/parameters/stdout.txt",
    "content": "Help on class Parameter in module gcc:\n\nclass Parameter(__builtin__.object)\n |  Data descriptors defined here:\n |  \n |  current_value\n |      (int/long)\n |  \n |  default_value\n |      (int/long)\n |  \n |  help\n |      (string) A short description of the option.\n |  \n |  max_value\n |      (int/long) The maximum acceptable value, if greater than min_value\n |  \n |  min_value\n |      (int/long) The minimum acceptable value\n |  \n |  option\n |      (string) The name used with the `--param <name>=<value>' switch to set this value\n |  \n |  ----------------------------------------------------------------------\n |  Data and other attributes defined here:\n |  \n |  __new__ = <built-in method __new__ of gcc.WrapperMeta object>\n |      T.__new__(S, ...) -> a new object with type S, a subtype of T\n\nstruct-reorg-cold-struct-ratio\n  param.option: 'struct-reorg-cold-struct-ratio'\n  param.current_value: 10\n  param.default_value: 10\n  param.max_value: 100\n  param.min_value: 0\n  param.help: 'The threshold ratio between current and hottest structure counts'\npredictable-branch-outcome\n  param.option: 'predictable-branch-outcome'\n  param.current_value: 2\n  param.default_value: 2\n  param.max_value: 50\n  param.min_value: 0\n  param.help: 'Maximal estimated outcome of branch considered predictable'\n"
  },
  {
    "path": "tests/plugin/rich-location/input.c",
    "content": "/*\n   Copyright 2017 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2017 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* { dg-do compile } */\n\nvoid test_1 (void)\n{ /* { dg-message \"1: this is the start of the function\" } */\n} /* { dg-message \"1: this is the end of the function\" } */\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/rich-location/script.py",
    "content": "#   Copyright 2017 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2017 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport sys\n\nimport gcc\n\n# Verify that the various error and warning methods work:\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        # Exercise gcc.inform with gcc.RichLocation:\n        gcc.inform(gcc.RichLocation(fn.start),\n                   'this is the start of the function')\n        gcc.inform(gcc.RichLocation(fn.end),\n                   'this is the end of the function')\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n\n"
  },
  {
    "path": "tests/plugin/rtl/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n#include <stdio.h>\n\nint main(int argc, char *argv[])\n{\n    printf(\"Hello, python\\n\");\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/rtl/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nhelp(gcc.Rtl)\n\ndef on_pass_execution(p, fn):\n    if p.properties_provided & gcc.PROP_rtl:\n        # For this pass, \"fn\" will be an instance of gcc.Function:\n        if not fn:\n            return\n\n        if fn.cfg:\n            for bb in fn.cfg.basic_blocks:\n                if bb.rtl:\n                    for i,stmt in enumerate(bb.rtl):\n                        assert isinstance(stmt, gcc.Rtl)\n                        # Ensure that we can evaluate the \"operands\" attribute\n                        # on every stmt we see:\n                        stmt.operands\n                        # print('    rtl[%i]:' % i)\n\n# Wire up our callback:\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n\n"
  },
  {
    "path": "tests/plugin/rtl/stdout.txt",
    "content": "Help on class Rtl in module gcc:\n\nclass Rtl(__builtin__.object)\n |  Methods defined here:\n |  \n |  __repr__(...)\n |      x.__repr__() <==> repr(x)\n |  \n |  __str__(...)\n |      x.__str__() <==> str(x)\n |  \n |  ----------------------------------------------------------------------\n |  Data descriptors defined here:\n |  \n |  loc\n |      Source code location of this expression, as a gcc.Location\n |  \n |  operands\n |      Operands of this expression, as a tuple\n |  \n |  ----------------------------------------------------------------------\n |  Data and other attributes defined here:\n |  \n |  __new__ = <built-in method __new__ of gcc.WrapperMeta object>\n |      T.__new__(S, ...) -> a new object with type S, a subtype of T\n\n"
  },
  {
    "path": "tests/plugin/switch/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/*\n  Test of switch statement\n*/\nint test_switch(int i)\n{\n    switch (i) {\n    case 1:\n    case 2:\n    case 4:\n    case 8:\n        return 1;\n\n    default:\n        return 0;\n    }\n}\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/switch/script.py",
    "content": "# -*- coding: utf-8 -*-\n#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nfrom gccutils import pprint\n\ndef on_pass_execution(p, fn):\n    if p.name == '*warn_function_return':\n        assert isinstance(fn, gcc.Function)\n        print('fn: %r' % fn)\n        assert isinstance(fn.decl, gcc.FunctionDecl)\n        print('fn.decl.name: %r' % fn.decl.name)\n\n        assert isinstance(fn.cfg, gcc.Cfg) # None for some early passes\n        assert fn.cfg.basic_blocks[0] == fn.cfg.entry\n        assert fn.cfg.basic_blocks[1] == fn.cfg.exit\n        for bb in fn.cfg.basic_blocks:\n            if bb.gimple:\n                for i,stmt in enumerate(bb.gimple):\n                    print('gimple[%i]:' % i)\n                    print('  str(stmt): %r' % str(stmt))\n                    print('  repr(stmt): %r' % repr(stmt))\n                    if isinstance(stmt, gcc.GimpleSwitch):\n                        print('    stmt.indexvar: %r' % stmt.indexvar)\n                        print('    stmt.labels: %r' % stmt.labels)\n                        for j, label in enumerate(stmt.labels):\n                            print('      label[%i].low: %r' % (j, label.low))\n                            print('      label[%i].high: %r' % (j, label.high))\n                            print('      label[%i].target: %r' % (j, label.target))\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/switch/stdout.txt",
    "content": "fn: gcc.Function('test_switch')\nfn.decl.name: 'test_switch'\ngimple[0]:\n  str(stmt): 'switch (i) <default: <L4>, case 1 ... 2: <L0>, case 4: <L0>, case 8: <L0>>'\n  repr(stmt): 'gcc.GimpleSwitch()'\n    stmt.indexvar: gcc.ParmDecl('i')\n    stmt.labels: [<gcc.CaseLabelExpr object at 0xdeadbeef>, <gcc.CaseLabelExpr object at 0xdeadbeef>, <gcc.CaseLabelExpr object at 0xdeadbeef>, <gcc.CaseLabelExpr object at 0xdeadbeef>]\n      label[0].low: None\n      label[0].high: None\n      label[0].target: gcc.LabelDecl(nnnn)\n      label[1].low: gcc.IntegerCst(1)\n      label[1].high: gcc.IntegerCst(2)\n      label[1].target: gcc.LabelDecl(nnnn)\n      label[2].low: gcc.IntegerCst(4)\n      label[2].high: None\n      label[2].target: gcc.LabelDecl(nnnn)\n      label[3].low: gcc.IntegerCst(8)\n      label[3].high: None\n      label[3].target: gcc.LabelDecl(nnnn)\ngimple[0]:\n  str(stmt): '<L0>:'\n  repr(stmt): 'gcc.GimpleLabel()'\ngimple[1]:\n  str(stmt): 'D.nnnnn = 1;'\n  repr(stmt): 'gcc.GimpleAssign()'\ngimple[0]:\n  str(stmt): '<L4>:'\n  repr(stmt): 'gcc.GimpleLabel()'\ngimple[1]:\n  str(stmt): 'D.nnnnn = 0;'\n  repr(stmt): 'gcc.GimpleAssign()'\ngimple[0]:\n  str(stmt): 'return D.nnnnn;'\n  repr(stmt): 'gcc.GimpleReturn()'\n"
  },
  {
    "path": "tests/plugin/syntax-error/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n"
  },
  {
    "path": "tests/plugin/syntax-error/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nTest handling of Python syntax errors.\n\nThis file is not valid Python syntax.\n"
  },
  {
    "path": "tests/plugin/syntax-error/stderr.txt",
    "content": "  File \"tests/plugin/syntax-error/script.py\", line 18\n    Test handling of Python syntax errors.\n                ^\nSyntaxError: invalid syntax\n"
  },
  {
    "path": "tests/plugin/sys/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n"
  },
  {
    "path": "tests/plugin/sys/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify the things the plugin exposes within the sys module\nimport sys\nimport os\n\nassert hasattr(sys, 'plugin_full_name')\nassert os.path.exists(sys.plugin_full_name)\n\nassert hasattr(sys, 'plugin_base_name')\nassert sys.plugin_base_name.startswith('python') # for now\n\n# Verify that the plugin's directory is in sys.path, as an absolute path:\nplugin_dir = os.path.abspath(os.path.dirname(sys.plugin_full_name))\nassert plugin_dir in sys.path\n"
  },
  {
    "path": "tests/plugin/translation-units/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\ntypedef int test_typedef;\ntest_typedef test_var;\n\n"
  },
  {
    "path": "tests/plugin/translation-units/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify that we can use gcc.get_translation_units()\nimport gcc\n\nfrom gccutils import get_global_typedef\n\ndef on_pass_execution(p, data):\n    if p.name == 'visibility':\n        print('len(gcc.get_translation_units()): %i' % len(gcc.get_translation_units()))\n        u = gcc.get_translation_units()[0]\n        print('type(u): %s' % type(u))\n        print('u.language: %r' % u.language)\n        print('type(u.block): %s' % type(u.block))\n        for v in u.block.vars:\n            if v.name == 'test_typedef':\n                print('v.name: %r' % v.name)\n                print('type(v): %r' % v)\n\n            if v.name == 'test_var':\n                print('v.name: %r' % v.name)\n                print('type(v): %r' % v)\n        #print 'u.block: %s' % u.block\n        #u.block.debug()\n\n        td = get_global_typedef('test_typedef')\n        print('td: %r' % td)\n        print('td.name: %r' % td.name)\n        print('type(td.type): %s' % type(td.type))\n\n\n\ngcc.register_callback(gcc.PLUGIN_PASS_EXECUTION,\n                      on_pass_execution)\n"
  },
  {
    "path": "tests/plugin/translation-units/stdout.txt",
    "content": "len(gcc.get_translation_units()): 1\ntype(u): <type 'gcc.TranslationUnitDecl'>\nu.language: 'GNU C'\ntype(u.block): <type 'gcc.Block'>\nv.name: 'test_typedef'\ntype(v): gcc.TypeDecl('test_typedef')\nv.name: 'test_var'\ntype(v): gcc.VarDecl('test_var')\ntd: gcc.TypeDecl('test_typedef')\ntd.name: 'test_typedef'\ntype(td.type): <type 'gcc.IntegerType'>\n"
  },
  {
    "path": "tests/plugin/type-attributes/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\n/* No nonnull attribute on this one: */\ntypedef int (example0)(const char *, const char *, const char *);\n\n/* Blanket nonnull attribute on this one: */\ntypedef int (example1)(const char *, const char *, const char *)\n  __attribute__((nonnull));\n\n/* nonnull attribute on args 1 and 3: */\ntypedef int (example2)(const char *, const char *, const char *)\n  __attribute__((nonnull(1, 3)));\n\n/* Repeated nonnull attribute (it's not clear that gcc itself copes with\n   this): */\ntypedef int (example3)(const char *, const char *, const char *)\n  __attribute__((nonnull(1)))\n  __attribute__((nonnull(3)));\n\n/*\n  PEP-7\nLocal variables:\nc-basic-offset: 4\nindent-tabs-mode: nil\nEnd:\n*/\n"
  },
  {
    "path": "tests/plugin/type-attributes/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\nimport gcc\nimport gccutils\n\ndef on_finish_unit():\n    for i in range(0, 4):\n        fn_type_decl = gccutils.get_global_typedef('example%i' % i)\n        assert isinstance(fn_type_decl, gcc.TypeDecl)\n        print('fn_type_decl.name: %r' % fn_type_decl.name)\n        fn_type = fn_type_decl.type\n        assert isinstance(fn_type, gcc.FunctionType)\n        print('str(fn_type): %r' % str(fn_type))\n        print('str(fn_type.type): %r' % str(fn_type.type))\n        assert isinstance(fn_type.argument_types, tuple)\n        print('argument_types: %r' % [str(t) for t in fn_type.argument_types])\n        print('fn_type.attributes: %r' % fn_type.attributes)\n        print('gccutils.get_nonnull_arguments(fn_type): %r' % gccutils.get_nonnull_arguments(fn_type))\n        print('-----------------------------------------------------\\n')\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      on_finish_unit)\n"
  },
  {
    "path": "tests/plugin/type-attributes/stdout.txt",
    "content": "fn_type_decl.name: 'example0'\nstr(fn_type): 'int example0 (const char *, const char *, const char *)'\nstr(fn_type.type): 'int'\nargument_types: ['const char *', 'const char *', 'const char *']\nfn_type.attributes: {}\ngccutils.get_nonnull_arguments(fn_type): frozenset()\n-----------------------------------------------------\n\nfn_type_decl.name: 'example1'\nstr(fn_type): 'int example1 (const char *, const char *, const char *)'\nstr(fn_type.type): 'int'\nargument_types: ['const char *', 'const char *', 'const char *']\nfn_type.attributes: {'nonnull': []}\ngccutils.get_nonnull_arguments(fn_type): frozenset({0, 1, 2})\n-----------------------------------------------------\n\nfn_type_decl.name: 'example2'\nstr(fn_type): 'int example2 (const char *, const char *, const char *)'\nstr(fn_type.type): 'int'\nargument_types: ['const char *', 'const char *', 'const char *']\nfn_type.attributes: {'nonnull': [gcc.IntegerCst(1), gcc.IntegerCst(3)]}\ngccutils.get_nonnull_arguments(fn_type): frozenset({0, 2})\n-----------------------------------------------------\n\nfn_type_decl.name: 'example3'\nstr(fn_type): 'int example3 (const char *, const char *, const char *)'\nstr(fn_type.type): 'int'\nargument_types: ['const char *', 'const char *', 'const char *']\nfn_type.attributes: {'nonnull': [gcc.IntegerCst(1)]}\ngccutils.get_nonnull_arguments(fn_type): frozenset({0})\n-----------------------------------------------------\n\n"
  },
  {
    "path": "tests/plugin/types/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n\ntypedef int mytype;\ntypedef mytype nestedtype;\n"
  },
  {
    "path": "tests/plugin/types/script.py",
    "content": "#   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify the behavior of gcc.Type\n\nimport gcc\nimport gccutils\n\ndef on_finish_unit():\n    def dump_integer_type(t):\n        print('gcc.Type: %r' % str(t))\n        print('  t.const: %r' % t.const)\n        print('  t.unsigned: %r' % t.unsigned)\n        print('  t.precision: %r' % t.precision)\n        assert isinstance(t.min_value, gcc.IntegerCst)\n        assert isinstance(t.max_value, gcc.IntegerCst)\n        print('  t.min_value.constant: %r' % t.min_value.constant)\n        print('  t.max_value.constant: %r' % t.max_value.constant)\n        assert isinstance(t.sizeof, int)\n        print('  t.sizeof: %r' % t.sizeof)\n        # gccutils.pprint(t)\n\n    # Pick some types that ought to be arch-independent and thus suitable\n    # for a unit test\n    dump_integer_type(gcc.Type.unsigned_char())\n    dump_integer_type(gcc.Type.signed_char())\n\n    print(gcc.Type.char().const)\n    print(gcc.Type.char().const_equivalent.const)\n    print(gcc.Type.char().const_equivalent.restrict_equivalent.const)\n    print(gcc.Type.char().const_equivalent.volatile_equivalent.const)\n    print(gcc.Type.char().const_equivalent.volatile_equivalent.unqualified_equivalent.const)\n\n    def dump_real_type(t):\n        print('gcc.Type: %r' % str(t))\n        print('  t.const: %r' % t.const)\n        print('  t.precision: %r' % t.precision)\n        assert isinstance(t.sizeof, int)\n        print('  t.sizeof: %r' % t.sizeof)\n\n    dump_real_type(gcc.Type.float())\n    dump_real_type(gcc.Type.double())\n\n    def dump_typedef(td):\n        t = td.type\n        print('gcc.TypeDecl: %r' % str(td))\n        print('  td.original_type: %r' % td.original_type)\n        print('  td.original_type is gcc.Type.int(): %r' % (td.original_type is gcc.Type.int()))\n        mytype = gccutils.get_global_typedef('mytype')\n        print('  td.original_type.name: %r' % td.original_type.name)\n        print('  td.original_type.name is mytype: %r' % (td.original_type.name is mytype))\n        dump_integer_type(t)\n\n    dump_typedef(gccutils.get_global_typedef('mytype'))\n    dump_typedef(gccutils.get_global_typedef('nestedtype'))\n\ngcc.register_callback(gcc.PLUGIN_FINISH_UNIT,\n                      on_finish_unit)\n"
  },
  {
    "path": "tests/plugin/types/stdout.txt",
    "content": "gcc.Type: 'unsigned char'\n  t.const: False\n  t.unsigned: True\n  t.precision: 8\n  t.min_value.constant: 0\n  t.max_value.constant: 255\n  t.sizeof: 1\ngcc.Type: 'signed char'\n  t.const: False\n  t.unsigned: False\n  t.precision: 8\n  t.min_value.constant: -128\n  t.max_value.constant: 127\n  t.sizeof: 1\nFalse\nTrue\nTrue\nTrue\nFalse\ngcc.Type: 'float'\n  t.const: False\n  t.precision: 32\n  t.sizeof: 4\ngcc.Type: 'double'\n  t.const: False\n  t.precision: 64\n  t.sizeof: 8\ngcc.TypeDecl: 'mytype'\n  td.original_type: gcc.IntegerType(name=gcc.TypeDecl('int'))\n  td.original_type is gcc.Type.int(): True\n  td.original_type.name: gcc.TypeDecl('int')\n  td.original_type.name is mytype: False\ngcc.Type: 'mytype'\n  t.const: False\n  t.unsigned: False\n  t.precision: 32\n  t.min_value.constant: -2147483648\n  t.max_value.constant: 2147483647\n  t.sizeof: 4\ngcc.TypeDecl: 'nestedtype'\n  td.original_type: gcc.IntegerType(name=gcc.TypeDecl('mytype'))\n  td.original_type is gcc.Type.int(): False\n  td.original_type.name: gcc.TypeDecl('mytype')\n  td.original_type.name is mytype: True\ngcc.Type: 'nestedtype'\n  t.const: False\n  t.unsigned: False\n  t.precision: 32\n  t.min_value.constant: -2147483648\n  t.max_value.constant: 2147483647\n  t.sizeof: 4\n"
  },
  {
    "path": "tests/plugin/version/input.c",
    "content": "/*\n   Copyright 2011 David Malcolm <dmalcolm@redhat.com>\n   Copyright 2011 Red Hat, Inc.\n\n   This is free software: you can redistribute it and/or modify it\n   under the terms of the GNU General Public License as published by\n   the Free Software Foundation, either version 3 of the License, or\n   (at your option) any later version.\n\n   This program is distributed in the hope that it will be useful, but\n   WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received a copy of the GNU General Public License\n   along with this program.  If not, see\n   <http://www.gnu.org/licenses/>.\n*/\n"
  },
  {
    "path": "tests/plugin/version/script.py",
    "content": "#   Copyright 2011, 2013 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2011, 2013 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Verify behavior of the gcc.get_*gcc_version() methods\nimport gcc\n\ndef test_version(name, v):\n    print(name)\n    # print(v)\n    # print(tuple(v))\n    assert hasattr(v, 'basever')\n    assert hasattr(v, 'datestamp')\n    assert hasattr(v, 'devphase')\n    assert hasattr(v, 'revision')\n    assert hasattr(v, 'configuration_arguments')\n\ntest_version('gcc.get_gcc_version()',\n             gcc.get_gcc_version())\n\ntest_version('gcc.get_plugin_gcc_version()',\n             gcc.get_plugin_gcc_version())\n\nassert isinstance(gcc.GCC_VERSION, int)\nassert gcc.GCC_VERSION >= 4006\n"
  },
  {
    "path": "tests/plugin/version/stdout.txt",
    "content": "gcc.get_gcc_version()\ngcc.get_plugin_gcc_version()\n"
  },
  {
    "path": "tree-types.txt.in",
    "content": "#define DEFTREECODE(SYM, STRING, TYPE, NARGS)   \\\n   SYM, STRING, TYPE, NARGS\n#define END_OF_BASE_TREE_CODES\n#include \"all-tree.def\"\n#undef DEFTREECODE\n"
  },
  {
    "path": "wrapperbuilder.py",
    "content": "#   Copyright 2012 David Malcolm <dmalcolm@redhat.com>\n#   Copyright 2012 Red Hat, Inc.\n#\n#   This is free software: you can redistribute it and/or modify it\n#   under the terms of the GNU General Public License as published by\n#   the Free Software Foundation, either version 3 of the License, or\n#   (at your option) any later version.\n#\n#   This program is distributed in the hope that it will be useful, but\n#   WITHOUT ANY WARRANTY; without even the implied warranty of\n#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n#   General Public License for more details.\n#\n#   You should have received a copy of the GNU General Public License\n#   along with this program.  If not, see\n#   <http://www.gnu.org/licenses/>.\n\n# Shared code for gcc-python-plugin's generate-*-c.py, where the code\n# is specific to gcc-python-plugin\n\nfrom cpybuilder import PyTypeObject, with_gcc_extensions\n\ndef indent(lines):\n    return '\\n'.join('    %s' % line for line in lines.splitlines())\n\nclass PyGccWrapperTypeObject(PyTypeObject):\n    \"\"\"\n    A PyTypeObject that's also a PyGccWrapperTypeObject\n    (with metaclass PyGccWrapperMeta_TypeObj)\n    \"\"\"\n    def __init__(self, *args, **kwargs):\n        PyTypeObject.__init__(self, *args, **kwargs)\n        self.ob_type = '&PyGccWrapperMeta_TypeObj'\n\n    def c_defn(self):\n        result = '\\n'\n        result += 'PyGccWrapperTypeObject %(identifier)s = {\\n' % self.__dict__\n        result += self.c_src_field_value('wrtp_base',\n                                         '{\\n        .ht_type = {\\n%s}' % indent(indent(self.c_initializer())))\n        result += '    },\\n'\n        result += self.c_src_field_value('wrtp_mark',\n                                         'PyGcc_WrtpMarkFor%s' % self.struct_name,\n                                         cast='wrtp_marker')\n        result += '};\\n'\n        result +='\\n'\n        return result\n\n\n"
  }
]