Finds problems in C++ source that slow development of large code bases

Overview

cppclean

Build status

Goal

cppclean attempts to find problems in C++ source that slow development in large code bases, for example various forms of unused code. Unused code can be unused functions, methods, data members, types, etc to unnecessary #include directives. Unnecessary #includes can cause considerable extra compiles increasing the edit-compile-run cycle.

This is a fork of the original cppclean project. The original project home page, which no longer contains code, is at https://code.google.com/p/cppclean/.

Features

cppclean finds the following:

  • Classes with virtual methods, no virtual destructor, and no bases
  • Global/static data that are potential problems when using threads
  • Functions that are declared but not defined
  • Unnecessary forward class declarations
  • Unnecessary function declarations
  • Undeclared function definitions
  • Unnecessary #includes in header files
    • No direct reference to anything in the header
    • Header is unnecessary if classes were forward declared instead
  • Inconsistent case in #includes (foo.h versus Foo.h)
  • (planned) Unnecessary #includes in source files
  • (planned) Source files that reference headers not directly #included, ie, files that rely on a transitive #include from another header
  • (planned) Unused members (private, protected, & public) methods and data
  • (planned) using namespace std in header files
  • (planned) Methods that are declared but not defined

AST is Abstract Syntax Tree, a representation of parsed source code (https://en.wikipedia.org/wiki/Abstract_syntax_tree).

Installation

$ pip install --upgrade cppclean

Run

$ cppclean <path>

Multiple include paths can be specified:

$ cppclean --include-path=directory1 --include-path=directory2 <path>

Current status

The parser works pretty well for header files, parsing about 99% of Google's header files. Anything which inspects structure of C++ source files should work reasonably well. Function bodies are not transformed to an AST, but left as tokens.

Non-goals

  • Parsing all valid C++ source
  • Handling invalid C++ source gracefully
  • Compiling to machine code (or anything beyond an AST)

Links

Comments
  • Error in _add_use

    Error in _add_use

    Running 793bd4420531ade18cb3b9c8b2eab5929461592f on my 64bit cygwin I get an error somewhere in the middle of a run (--verbose is active):

    Processing ./PlatformSupport/numerictypeinfo.h
    Traceback (most recent call last):
      File "/usr/bin/cppclean", line 145, in <module>
        sys.exit(main())
      File "/usr/bin/cppclean", line 138, in main
        quiet=args.quiet):
      File "/usr/lib/python2.7/site-packages/cpp/find_warnings.py", line 524, in run
        hunter.find_warnings()
      File "/usr/lib/python2.7/site-packages/cpp/find_warnings.py", line 119, in find_warnings
        self._find_header_warnings()
      File "/usr/lib/python2.7/site-packages/cpp/find_warnings.py", line 396, in _find_header_warnings
        self._find_unused_warnings(included_files, forward_declarations)
      File "/usr/lib/python2.7/site-packages/cpp/find_warnings.py", line 387, in _find_unused_warnings
        forward_declarations)
      File "/usr/lib/python2.7/site-packages/cpp/find_warnings.py", line 354, in _determine_uses
        _process_function_body(node, node.namespace)
      File "/usr/lib/python2.7/site-packages/cpp/find_warnings.py", line 323, in _process_function_body
        _add_use(t.name, namespace)
      File "/usr/lib/python2.7/site-packages/cpp/find_warnings.py", line 276, in _add_use
        name = file_use_node[1].filename
    KeyError: 1
    
    opened by amai2012 12
  • KeyError raised

    KeyError raised

    Hi,

    I have a python KeyError raised when running cppclean, it is in a big project then I'm not sure when exactly it happens. End of traceback is: File "/usr/local/lib/python2.7/site-packages/cpp/find_warnings.py", line 260, in _add_reference name = file_use_node[1].filename KeyError: 1

    Note that, I had first installed cppclean through "pip install --upgrade cppclean", and had the same issue in "add_use(name, namespace)" that is, now that I installed from cppclean-master, fixed with (lines with + are lines that fixed the problem):

            def _add_use(name, namespace):
                [...]
                + if isinstance(file_use_node, dict):
                +    return
                # TODO(nnorwitz): do proper check for ref/pointer/symbol.
                name = file_use_node[1].filename
                if name in file_uses:
                    file_uses[name] |= USES_DECLARATION
                [...]
    

    I then added the same "if isinstance return" in _add_reference(name, namespace) before calling "name = file_use_node[1].filename" an it seems to do the job, but since I'm not sure if this is the right thing to do I prefer filing a new issue, anyway, if you need more information to track this issue do not hesitate to ask.

    Thanks and best regards.

    opened by gluttony38 7
  • cppclean crash on specific header

    cppclean crash on specific header

    Hi,

    Not sure if you really want bug reports about specific files here, but in trying to run cppclean on this particular header I get a crash with the following stack trace:

    Traceback (most recent call last):
      File "/opt/miniconda/bin/cppclean", line 140, in <module>
        sys.exit(main())
      File "/opt/miniconda/bin/cppclean", line 133, in main
        quiet=args.quiet):
      File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 518, in run
        hunter.find_warnings()
      File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 119, in find_warnings
        self._find_header_warnings()
      File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 390, in _find_header_warnings
        self._find_unused_warnings(included_files, forward_declarations)
      File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 381, in _find_unused_warnings
        self._determine_uses(included_files, forward_declarations)
      File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 348, in _determine_uses
        _process_function_body(node, node.namespace)
      File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 318, in _process_function_body
        _add_use(t.name, namespace)
      File "/opt/miniconda/lib/python2.7/site-packages/cpp/find_warnings.py", line 274, in _add_use
        name = file_use_node[1].filename
    KeyError: 1
    
    bug 
    opened by jwpeterson 7
  • UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 12: ordinal not in range(128)

    UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 12: ordinal not in range(128)

    cppclean 0.6 tells me UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 12: ordinal not in range(128)

    How can I find out the problem - e.g. which file is triggering the message?

    opened by amai2012 6
  • Unexpected token parsing errors for C++11 code

    Unexpected token parsing errors for C++11 code

    Cppclean used to work before transitioning to C++11. Running on valid C++11 code causes parsing errors of the form: Token(u'return', 3189, 3195)

    There are no line numbers in error messages to see what is wrong. Header code in https://github.com/rakhimov/scram can be used to get the errors.

    opened by rakhimov 6
  • Cppclean crashes on specific token (Got invalid token in ? @ 1710 token:@: u'SION_10_6\n@interface')

    Cppclean crashes on specific token (Got invalid token in ? @ 1710 token:@: u'SION_10_6\[email protected]')

    Hey all,

    I am running Cppclean on 2 Ogre3d based projects and both segfault on a specific token:

    Got invalid token in ? @ 1710 token:@: u'SION_10_6\[email protected]'

    This can be reproduced when running on a fresh download from the ogre website. The file that causes this seems to be: OgrePrerequisites.h which gets called quite a lot. Running just on that file seems to do no harm.

    Thanks

    Traceback (most recent call last): File "/usr/local/bin/cppclean", line 135, in sys.exit(main()) File "/usr/local/bin/cppclean", line 127, in main quiet=args.quiet) File "/usr/local/lib/python2.7/dist-packages/cpp/find_warnings.py", line 533, in run hunter.find_warnings() File "/usr/local/lib/python2.7/dist-packages/cpp/find_warnings.py", line 124, in find_warnings self._find_header_warnings() File "/usr/local/lib/python2.7/dist-packages/cpp/find_warnings.py", line 396, in _find_header_warnings self._find_unused_warnings() File "/usr/local/lib/python2.7/dist-packages/cpp/find_warnings.py", line 387, in _find_unused_warnings included_files, forward_declarations = self._read_and_parse_includes() File "/usr/local/lib/python2.7/dist-packages/cpp/find_warnings.py", line 171, in _read_and_parse_includes module = self._get_module(node) File "/usr/local/lib/python2.7/dist-packages/cpp/find_warnings.py", line 149, in _get_module [_f for _f in builder.generate() if _f]) File "/usr/local/lib/python2.7/dist-packages/cpp/ast.py", line 698, in generate token = self._get_next_token() File "/usr/local/lib/python2.7/dist-packages/cpp/ast.py", line 916, in _get_next_token return next(self.tokens) File "/usr/local/lib/python2.7/dist-packages/cpp/tokenize.py", line 276, in get_tokens raise TokenError('unexpected token') cpp.tokenize.TokenError: unexpected token

    opened by TheOnlyJoey 6
  • Crash in  _get_method on invalid/incomplete code

    Crash in _get_method on invalid/incomplete code

    Running cppclean on this invalid/incomplete code

    #define FOO
    
    extern void foo(
    

    triggers a crash:

    Traceback (most recent call last):
      File "/usr/bin/cppclean", line 145, in <module>
        sys.exit(main())
      File "/usr/bin/cppclean", line 120, in main
        entire_ast = list([_f for _f in builder.generate() if _f])
      File "/usr/lib/python2.7/site-packages/cpp/ast.py", line 668, in generate
        result = self._generate_one(token)
      File "/usr/lib/python2.7/site-packages/cpp/ast.py", line 757, in _generate_one
        return self._get_method(temp_tokens, 0, None, False)
      File "/usr/lib/python2.7/site-packages/cpp/ast.py", line 989, in _get_method
        last_token = parameters.pop()    # Remove trailing ')'.
    IndexError: pop from empty list
    
    opened by amai2012 5
  • Python errors while using cppclean

    Python errors while using cppclean

    Hi,

    I've tried today to run Cppclean on my code base, mostly for the header related feature. It didn't work well though; I had to modify slightly the Python sources so that it can go until the end.

    These modifications are far from being clean (I'm far to be a Python expert!) but should point out some cases that might fail while using your software; the point where they fail in my code were clean (it might be due to new C++11 feature, such as alias with using or '= default' for class special members).

    Best regards,

    S├ębastien

    opened by srpgilles 5
  • inferring system includes

    inferring system includes

    For projects that use #include <someInclude.h> rather than #include "someInclude.h" for non-system includes, cppclean will print

    filename:line: 'Func' not found in any directly #included header
    

    The logic is found in ast.py here. (If there is < then it is a system include). It looks like whether a include is system or not is used in find_warnings.py here. Removing this logic (making all includes non-system includes) removes the false positive described above but introduces a new false positive:

    filename:line: unable to find 'cmath'
    

    This may be obvious but can you help me understand why system includes aren't being checked in the same way?

    Assuming system includes do need to be differentiated, a solution to the above problem is to have users distinguish system includes on the cppclean call (e.g., using -I for system includes and -i for non-system includes.). It would then be a simple check in ast.py for whether a given include is in one of those sets of paths. If it is in neither, system could be assumed.

    I am happy to submit a pull request if desired.

    A practical example can be found from cloning SCRIMMAGE here and running the following:

    cppclean -I src/proto_conversions/ProtoConversions.cpp
    
    opened by esquires 4
  • Preprocessor macros in Ctor initializer list.

    Preprocessor macros in Ctor initializer list.

    Skip the preprocessor tokens when parsing initializer lists instead of crashing. Reworks the parsing loop with a single call to self._get_next_token() instead of self.get_name(), in order to detect preprocessor tokens.

    opened by Gugli 3
  • Implement basic support for ctor initializer lists and exporting defines with values

    Implement basic support for ctor initializer lists and exporting defines with values

    For now, the ctor initializer lists are only supported when they are defined inline. Please see the commit messages for more detail.

    I have an idea on how to support them when defined outside the class, but it requires keeping state of which class has already been processed and if that ctor (method) belongs to that class. Not to mention the possibility of nested classes. Any help / guidance is greatly appreciated.

    This fixes issue #56.

    opened by christarazi 3
  • False positive when calling a macro from within another macro

    False positive when calling a macro from within another macro

    If I have a file with MACRO_B calling MACRO_A - which is defined in header-a.h, cppclean will complain that header-a.h doesn't need to be included:

    Three files to reproduce:

    • main.c
    #include "macro-a.h"
    #include <stdio.h>
    
    int main( )
    {
        int result = MY_RESULT(3);
        printf("result is %d\n", result);
        
        return 0;
    }
    
    • macro-b.h
    #include "macro-a.h"
    
    #define MY_RESULT(c) {          \
        ( MY_REPLACE_MACRO - (c))   \
    }
    
    
    • macro-a.h
    #define MY_REPLACE_MACRO 345
    

    Program compiles as runs as expected, but running cppclean gives a false positive:

    cppclean macro-b.h 
    macro-b.h:1: 'macro-a.h' does not need to be #included
    

    Removing the macro-a.h include leads to a compilation error:

    main.c:6:18: error: use of undeclared identifier 'MY_REPLACE_MACRO'
        int result = MY_RESULT(3);
                     ^
    ./macro-b.h:4:7: note: expanded from macro 'MY_RESULT'
        ( MY_REPLACE_MACRO - (c))   \
    
    opened by jufajardini 0
  • False positive :  does not need to be #included with fields of structure

    False positive : does not need to be #included with fields of structure

    Reproducer is 3 files

    • lol.c :
    #include "toto.h"
    #include <stdio.h>
    
    int main() {
    	toto p;
    	p.t = 3;
    	printf("loli %llx\n", p.t);
    	return 0;
    }
    
    • toto.h :
    #include "tata.h"
    
    typedef struct toto {
    	tata t;
    } toto;
    
    • tata.h :
    #include <stdint.h>
    
    typedef int64_t tata;
    

    Program compiles and behaves as expected cf :

    clang lol.c
    ./a.out 
    

    But running cppclean gives a false positive

    cppclean toto.h 
    toto.h:1: 'tata.h' does not need to be #included
    

    Removing the include fives compilation error :

    clang lol.c
    In file included from lol.c:1:
    ./toto.h:4:2: error: unknown type name 'tata'
            tata t;
            ^
    1 error generated.
    
    opened by catenacyber 0
  • 0.13: pytest is failing in 7 units

    0.13: pytest is failing in 7 units

    I'm trying to package your module as an rpm package. So I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.

    • python3 -sBm build -w --no-isolation
    • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
    • install .whl file in </install/prefix>
    • run pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

    Here is pytest output:

    + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-cppclean-0.13-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-cppclean-0.13-2.fc35.x86_64/usr/lib/python3.8/site-packages
    + /usr/bin/pytest -ra
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.13, pytest-7.1.2, pluggy-1.0.0
    rootdir: /home/tkloczko/rpmbuild/BUILD/cppclean-0.13
    plugins: anyio-3.5.0, tornasync-0.6.0.post2, timeout-2.1.0, cov-3.0.0, black-0.3.12
    collected 153 items
    
    test_ast.py .............F.............................F......F..............................FFF....F........................                                        [ 73%]
    test_find_warnings.py ..                                                                                                                                             [ 75%]
    test_symbols.py ..........                                                                                                                                           [ 81%]
    test_tokenize.py ............................                                                                                                                        [100%]
    
    ================================================================================= FAILURES =================================================================================
    _______________________________________________________ TypeConverterToParametersTest.test_simple_with_initializers ________________________________________________________
    
    self = <test_ast.TypeConverterToParametersTest testMethod=test_simple_with_initializers>
    
        def test_simple_with_initializers(self):
            tokens = get_tokens('Fool* data = NULL')
            results = self.converter.to_parameters(list(tokens))
            self.assertEqual(1, len(results), repr(results))
    
            self.assertEqual([], results[0].type.modifiers)
            self.assertEqual('Fool', results[0].type.name)
            self.assertEqual([], results[0].type.templated_types)
            self.assertEqual(True, results[0].type.pointer)
            self.assertEqual(False, results[0].type.reference)
            self.assertEqual(False, results[0].type.array)
            self.assertEqual('data', results[0].name)
    >       self.assertEqual([Token('NULL')], results[0].default)
    E       AssertionError: Lists differ: [Token('NULL', 0, 0)] != [Token('NULL', 13, 17)]
    E
    E       First differing element 0:
    E       Token('NULL', 0, 0)
    E       Token('NULL', 13, 17)
    E
    E       - [Token('NULL', 0, 0)]
    E       ?                ^  ^
    E
    E       + [Token('NULL', 13, 17)]
    E       ?                ^^  ^^
    
    test_ast.py:370: AssertionError
    _____________________________________________ ASTBuilderIntegrationTest.test_class_colon_separated_class_name_and_inline_dtor ______________________________________________
    
    self = <test_ast.ASTBuilderIntegrationTest testMethod=test_class_colon_separated_class_name_and_inline_dtor>
    
        def test_class_colon_separated_class_name_and_inline_dtor(self):
            method_body = 'XXX(1) << "should work";'
            code = 'class Foo::Bar { ~Bar() { %s } };' % method_body
            nodes = list(MakeBuilder(code).generate())
            self.assertEqual(1, len(nodes), repr(nodes))
            function = nodes[0].body[0]
            expected = Function('Bar', [], [], body=list(get_tokens(method_body)),
                                modifiers=ast.FUNCTION_DTOR)
            self.assertEqual(expected.return_type, function.return_type)
    >       self.assertEqual(expected, function)
    E       AssertionError: Function(0, 0, None Bar([]), 0x10, [Token('XXX', 0[126 chars]24)]) != Function(18, 21, None Bar([]), 0x10, [Token('XXX',[138 chars]50)])
    
    test_ast.py:954: AssertionError
    ________________________________________________________ ASTBuilderIntegrationTest.test_class_handles_struct_rebind ________________________________________________________
    
    self = <test_ast.ASTBuilderIntegrationTest testMethod=test_class_handles_struct_rebind>
    
        def test_class_handles_struct_rebind(self):
            code = """
            template <typename T, typename Alloc = std::allocator<T> >
            class AnotherAllocator : public Alloc {
                template <class U> struct rebind {
                };
            };
            """
            types1 = {}
            types1['Alloc'] = (None, list(get_tokens('std::allocator<T>')))
            types1['T'] = (None, None)
            types2 = {}
            types2['U'] = (None, None)
    
            nodes = list(MakeBuilder(code).generate())
            self.assertEqual(1, len(nodes), repr(nodes))
    >       self.assertEqual(Class('AnotherAllocator', bases=[Type('Alloc')],
                                   body=[Struct('rebind', body=[],
                                                templated_types=types2)],
                                   templated_types=types1,),
                             nodes[0])
    E       AssertionError: Class(0, 0, AnotherAllocator<Alloc,T>, [Type(0,[44 chars][])]) != Class(82, 98, AnotherAllocator<T,Alloc>, [Type([54 chars][])])
    
    test_ast.py:973: AssertionError
    ________________________________________________ ASTBuilderIntegrationTest.test_method_with_template_class_with2args_works _________________________________________________
    
    self = <test_ast.ASTBuilderIntegrationTest testMethod=test_method_with_template_class_with2args_works>
    
        def test_method_with_template_class_with2args_works(self):
            code = """
            template <class T, typename U>
            inline void EVM::VH<T, U>::Write() {
            }
            """
            nodes = list(MakeBuilder(code).generate())
            self.assertEqual(1, len(nodes), repr(nodes))
            expected = Method('Write', list(get_tokens('EVM::VH<T, U>')),
                              list(get_tokens('inline void')), [],
                              templated_types={'T': (None, None),
                                               'U': (None, None)},
                              body=[])
            self.assertEqual(expected.return_type, nodes[0].return_type)
    >       self.assertEqual(expected.in_class, nodes[0].in_class)
    E       AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), Token('VH', 5, [93 chars] 13)] != [Token('EVM', 60, 63), Token('::', 63, 65), Token('VH',[104 chars] 73)]
    E
    E       First differing element 0:
    E       Token('EVM', 0, 3)
    E       Token('EVM', 60, 63)
    E
    E       - [Token('EVM', 0, 3),
    E       + [Token('EVM', 60, 63),
    E       ?               +   +
    E
    E       -  Token('::', 3, 5),
    E       +  Token('::', 63, 65),
    E       ?              +   +
    E
    E       -  Token('VH', 5, 7),
    E       +  Token('VH', 65, 67),
    E       ?              +   +
    E
    E       -  Token('<', 7, 8),
    E       +  Token('<', 67, 68),
    E       ?             +   +
    E
    E       -  Token('T', 8, 9),
    E       +  Token('T', 68, 69),
    E       ?             +   +
    E
    E       -  Token(',', 9, 10),
    E       ?                ^
    E
    E       +  Token(',', 69, 70),
    E       ?             +   ^
    E
    E       -  Token('U', 11, 12),
    E       ?             ^   ^
    E
    E       +  Token('U', 71, 72),
    E       ?             ^   ^
    E
    E       -  Token('>', 12, 13)]
    E       ?             ^   ^
    E
    E       +  Token('>', 72, 73)]
    E       ?             ^   ^
    
    test_ast.py:1100: AssertionError
    ________________________________________________ ASTBuilderIntegrationTest.test_method_with_template_class_with3args_works _________________________________________________
    
    self = <test_ast.ASTBuilderIntegrationTest testMethod=test_method_with_template_class_with3args_works>
    
        def test_method_with_template_class_with3args_works(self):
            code = """
            template <class CT, class IT, class DT>
            DT* Worker<CT, IT, DT>::Create() {
            }
            """
            nodes = list(MakeBuilder(code).generate())
            self.assertEqual(1, len(nodes), repr(nodes))
            tt = (None, None)
            expected = Method('Create', list(get_tokens('Worker<CT, IT, DT>')),
                              list(get_tokens('DT*')), [],
                              templated_types={'CT': tt, 'IT': tt, 'DT': tt},
                              body=[])
            self.assertEqual(expected.return_type, nodes[0].return_type)
    >       self.assertEqual(expected.in_class, nodes[0].in_class)
    E       AssertionError: Lists differ: [Token('Worker', 0, 6), Token('<', 6, 7), Token('CT', 7, 9[98 chars] 18)] != [Token('Worker', 61, 67), Token('<', 67, 68), Token('CT', [105 chars] 79)]
    E
    E       First differing element 0:
    E       Token('Worker', 0, 6)
    E       Token('Worker', 61, 67)
    E
    E       Diff is 733 characters long. Set self.maxDiff to None to see it.
    
    test_ast.py:1118: AssertionError
    _____________________________________________________ ASTBuilderIntegrationTest.test_method_with_template_class_works ______________________________________________________
    
    self = <test_ast.ASTBuilderIntegrationTest testMethod=test_method_with_template_class_works>
    
        def test_method_with_template_class_works(self):
            code = """
            template <class T>
            inline void EVM::VH<T>::Write() {
            }
            """
            nodes = list(MakeBuilder(code).generate())
            self.assertEqual(1, len(nodes), repr(nodes))
            expected = Method('Write', list(get_tokens('EVM::VH<T>')),
                              list(get_tokens('inline void')), [],
                              templated_types={'T': (None, None)},
                              body=[])
            self.assertEqual(expected.return_type, nodes[0].return_type)
    >       self.assertEqual(expected.in_class, nodes[0].in_class)
    E       AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), Token('VH', 5, [53 chars] 10)] != [Token('EVM', 48, 51), Token('::', 51, 53), Token('VH',[64 chars] 58)]
    E
    E       First differing element 0:
    E       Token('EVM', 0, 3)
    E       Token('EVM', 48, 51)
    E
    E       - [Token('EVM', 0, 3),
    E       ?               ^  ^
    E
    E       + [Token('EVM', 48, 51),
    E       ?               ^^  ^^
    E
    E       -  Token('::', 3, 5),
    E       ?               ---
    E
    E       +  Token('::', 51, 53),
    E       ?              +++++
    E
    E       -  Token('VH', 5, 7),
    E       ?                 ^
    E
    E       +  Token('VH', 53, 55),
    E       ?               +  ^^
    E
    E       -  Token('<', 7, 8),
    E       ?             ^  ^
    E
    E       +  Token('<', 55, 56),
    E       ?             ^^  ^^
    E
    E       -  Token('T', 8, 9),
    E       ?             ^  ^
    E
    E       +  Token('T', 56, 57),
    E       ?             ^^  ^^
    E
    E       -  Token('>', 9, 10)]
    E       ?             ^  ^^
    E
    E       +  Token('>', 57, 58)]
    E       ?             ^^  ^^
    
    test_ast.py:1082: AssertionError
    _________________________________________________________________ ASTBuilderIntegrationTest.test_operators _________________________________________________________________
    
    self = <test_ast.ASTBuilderIntegrationTest testMethod=test_operators>
    
        def test_operators(self):
            for operator in ('=', '+=', '-=', '*=', '==', '!=', '()', '[]', '<',
                             '>', '^=', '<<=', '>>='):
                code = 'void Foo::operator%s();' % operator
                nodes = list(MakeBuilder(code).generate())
                self.assertEqual(1, len(nodes), repr(nodes))
    >           self.assertEqual(Method(('operator%s' % operator),
                                        list(get_tokens('Foo')),
                                        list(get_tokens('void')), []), nodes[0])
    E           AssertionError: Method(0, 0, Type(0, 4, void) operator=([]), 0x00, None) != Method(0, 4, Type(0, 4, void) operator=([]), 0x00, None)
    
    test_ast.py:883: AssertionError
    ========================================================================= short test summary info ==========================================================================
    FAILED test_ast.py::TypeConverterToParametersTest::test_simple_with_initializers - AssertionError: Lists differ: [Token('NULL', 0, 0)] != [Token('NULL', 13, 17)]
    FAILED test_ast.py::ASTBuilderIntegrationTest::test_class_colon_separated_class_name_and_inline_dtor - AssertionError: Function(0, 0, None Bar([]), 0x10, [Token('XXX', 0...
    FAILED test_ast.py::ASTBuilderIntegrationTest::test_class_handles_struct_rebind - AssertionError: Class(0, 0, AnotherAllocator<Alloc,T>, [Type(0,[44 chars][])]) != Class...
    FAILED test_ast.py::ASTBuilderIntegrationTest::test_method_with_template_class_with2args_works - AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), To...
    FAILED test_ast.py::ASTBuilderIntegrationTest::test_method_with_template_class_with3args_works - AssertionError: Lists differ: [Token('Worker', 0, 6), Token('<', 6, 7), ...
    FAILED test_ast.py::ASTBuilderIntegrationTest::test_method_with_template_class_works - AssertionError: Lists differ: [Token('EVM', 0, 3), Token('::', 3, 5), Token('VH', ...
    FAILED test_ast.py::ASTBuilderIntegrationTest::test_operators - AssertionError: Method(0, 0, Type(0, 4, void) operator=([]), 0x00, None) != Method(0, 4, Type(0, 4, void)...
    ====================================================================== 7 failed, 146 passed in 0.60s =======================================================================
    
    opened by kloczek 0
  • Do I use the program correctly? (Windows)

    Do I use the program correctly? (Windows)

    I use the following command: python .\cppclean --include-path pathToMyProject\ pathToACppFilesWithToMuchHeader\myfile.cpp and I have the following output: pathToACppFilesWithToMuchHeader\myfile.cpp: should #include header file 'FullPath\myfile.h' but in myfile.cpp I include this file in the following way: #include <folder1/myfile.h> with folder1 in pathToMyProject\

    and that doesn't mention any unused header in the file

    What do I do wrong?

    opened by stephane-archer 0
Owner
Steven Myint
Mars rover flight software developer
Steven Myint
Slops (SLow OPerating System) | An hobby OS written in C and assembly

slops: SLow OPerating System slops is a simple unix-like operating system, written in assembly and C. BUILD ISO IMAGE 1. sync limine git submodule upd

Slops 5 Dec 22, 2021
Slops (SLow OPerating System) An hobby OS written in C and assembly

slops: SLow OPerating System slops is a simple unix-like operating system, written in assembly and C. How to use Build iso image 1. build the toolchai

null 3 Jan 20, 2022
Rmaxcut finds an approximate solution to a weighted max-cut problem via random perturbation.

Rmaxcut finds an approximate solution to a weighted max-cut problem via random perturbation. Each line in an input file consists of the first nodeID, the second nodeID and an integer weight.

Heng Li 11 Apr 28, 2021
Smart Robot that avoids obstacles and finds a way to move

ObstacleAvoider Obstacle Avoider is an intelligent device which can automatically sense the obstacle in front of it and avoid them by turning itself.

IEEE VIT Student Chapter 13 Mar 7, 2022
A web application which finds the shortest or quickest path from two points in the city of Rio de Janeiro.

A web application which finds the shortest or quickest path from two points in the city of Rio de Janeiro. Obviously not Waze. (final project for EDA @ EMAp, 2021)

null 2 Nov 17, 2021
Here it is! SRB2 Final Demo 1.09 (in development) source code!

Here it is! SRB2 Final Demo 1.09 (in development) source code!

Sonic Robo Blast: 20 Years Ago 1 Jan 23, 2022
Learn open source contribution by adding your coding problems solutions here!

Hacktoberfest-2021 Repository created for Hacktoberfest event where beginners can learn to contribute to open-source source. How to contribute Check t

Developer Student Clubs, Vishwakarma Institute of Technology, Pune 12 Nov 2, 2021
Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem-CP-M This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so ev

null 11 Aug 31, 2022
Project is to port original Zmodem for Unix to CP/M and provide binaries and source code for platform specific modification as needed. Based on 1986 C source code by Chuck Forsberg

Zmodem4CPM This repository is intended to foster a RetroBrewComputers community effort to port the original Zmodem source code for Unix to CP/M so eve

null 11 Aug 31, 2022
A C++11 large integer library with effective high performance, simplistic in nature and also clean in the eyes.

BigIntegerCPP BigIntegerCPP is a C++11 port of large integer library used in CryptoLib4Pascal. It allows mostly parsing of numbers as strings in diffe

Telepati 26 Sep 12, 2022
A large mechanical 7-segment clock using cheap stepper motors.

mechanical-7-segment-clock A large mechanical 7-segment clock using cheap stepper motors. Each digit requires its own controller board. The seconds di

null 45 Aug 11, 2022
weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

weggli is a fast and robust semantic search tool for C and C++ codebases. It is designed to help security researchers identify interesting functionality in large codebases.

Google Project Zero 1.9k Sep 27, 2022
Hierarchical Engine for Large-scale Infrastructure Co-Simulation (HELICS)

A multi-language, cross-platform library that enables different simulators to easily exchange data and stay synchronized in time. Scalable from two si

GMLC-TDC 81 Jul 21, 2022
Large LED Heart PCB Pendant

Large LED Heart PCB Pendant A large heart with 20 individually controllable LEDS using 4 pins on an ATtiny 45 with Charlieplexing This is an easy to s

null 5 Mar 18, 2022
Some hypervisor research notes. There is also a useful exploit template that you can use to verify / falsify any assumptions you may make while auditing code, and for exploit development.

Introduction Over the past few weeks, I've been doing some hypervisor research here and there, with most of my focus being on PCI device emulation cod

Faith 127 Sep 14, 2022
Latest driver development code for Focusrite Scarlett on Linux

Development To actually try modifying the driver source code, and build your modification against your current running kernel, do this (don't worry -

null 70 Sep 27, 2022
A C++ library with all the online array problems and etc which I get online

cpp-Library A C++ library with all the online array problems and etc which I get online. Setup To setup it simply just download the repo and then move

Padmashree Jha 6 Dec 6, 2021
Fix some extrinsic parameter importing problems. 6-axis IMU works now. Lidar without ring works now.

LVI-SAM-MODIFIED This repository is a modified version of LVI-SAM. Modification Add function to get extrinsic parameters.The original code assumes the

null 77 Sep 28, 2022
QPEP (Quadratic Pose Estimation Problems) Enhanced VINS-Mono SLAM System

VINS-Mono-QPEP The QPEP (Quadratic Pose Estimation Problems) Enhanced VINS-Mono

Jin Wu 32 Oct 4, 2022