Skip to main content
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

  • (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)

Release files for cppclean 0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cppclean 0.6
File Size Uploaded
cppclean-0.6.tar.gz 29.7 kB Details

Release files / cppclean-0.6.tar.gz

Download URL cppclean-0.6.tar.gz
Size 29.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d55b540a3ef5885df985cc1321650b6454c01fc4f25e3385f211daccde275fce
BLAKE2b-256 checksum
How to use checksums
8793a8fe36b1fd6b2e37414cab4c0503b93e84f0ba9a5a2dffbaaf0bb088a628
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

0.13

1 release file

0.12

1 release file

0.11

1 release file

0.10

1 release file

0.9

1 release file

0.8

1 release file

0.7

1 release file

This release

0.6 This release

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2.6

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page