Warning, /JETSCAPE/external_packages/googletest/googlemock/scripts/generator/README.cppclean is written in an unsupported language. File is not indexed.
0001 Goal:
0002 -----
0003 CppClean attempts to find problems in C++ source that slow development
0004 in large code bases, for example various forms of unused code.
0005 Unused code can be unused functions, methods, data members, types, etc
0006 to unnecessary #include directives. Unnecessary #includes can cause
0007 considerable extra compiles increasing the edit-compile-run cycle.
0008
0009 The project home page is: http://code.google.com/p/cppclean/
0010
0011
0012 Features:
0013 ---------
0014 * Find and print C++ language constructs: classes, methods, functions, etc.
0015 * Find classes with virtual methods, no virtual destructor, and no bases
0016 * Find global/static data that are potential problems when using threads
0017 * Unnecessary forward class declarations
0018 * Unnecessary function declarations
0019 * Undeclared function definitions
0020 * (planned) Find unnecessary header files #included
0021 - No direct reference to anything in the header
0022 - Header is unnecessary if classes were forward declared instead
0023 * (planned) Source files that reference headers not directly #included,
0024 ie, files that rely on a transitive #include from another header
0025 * (planned) Unused members (private, protected, & public) methods and data
0026 * (planned) Store AST in a SQL database so relationships can be queried
0027
0028 AST is Abstract Syntax Tree, a representation of parsed source code.
0029 http://en.wikipedia.org/wiki/Abstract_syntax_tree
0030
0031
0032 System Requirements:
0033 --------------------
0034 * Python 2.4 or later (2.3 probably works too)
0035 * Works on Windows (untested), Mac OS X, and Unix
0036
0037
0038 How to Run:
0039 -----------
0040 For all examples, it is assumed that cppclean resides in a directory called
0041 /cppclean.
0042
0043 To print warnings for classes with virtual methods, no virtual destructor and
0044 no base classes:
0045
0046 /cppclean/run.sh nonvirtual_dtors.py file1.h file2.h file3.cc ...
0047
0048 To print all the functions defined in header file(s):
0049
0050 /cppclean/run.sh functions.py file1.h file2.h ...
0051
0052 All the commands take multiple files on the command line. Other programs
0053 include: find_warnings, headers, methods, and types. Some other programs
0054 are available, but used primarily for debugging.
0055
0056 run.sh is a simple wrapper that sets PYTHONPATH to /cppclean and then
0057 runs the program in /cppclean/cpp/PROGRAM.py. There is currently
0058 no equivalent for Windows. Contributions for a run.bat file
0059 would be greatly appreciated.
0060
0061
0062 How to Configure:
0063 -----------------
0064 You can add a siteheaders.py file in /cppclean/cpp to configure where
0065 to look for other headers (typically -I options passed to a compiler).
0066 Currently two values are supported: _TRANSITIVE and GetIncludeDirs.
0067 _TRANSITIVE should be set to a boolean value (True or False) indicating
0068 whether to transitively process all header files. The default is False.
0069
0070 GetIncludeDirs is a function that takes a single argument and returns
0071 a sequence of directories to include. This can be a generator or
0072 return a static list.
0073
0074 def GetIncludeDirs(filename):
0075 return ['/some/path/with/other/headers']
0076
0077 # Here is a more complicated example.
0078 def GetIncludeDirs(filename):
0079 yield '/path1'
0080 yield os.path.join('/path2', os.path.dirname(filename))
0081 yield '/path3'
0082
0083
0084 How to Test:
0085 ------------
0086 For all examples, it is assumed that cppclean resides in a directory called
0087 /cppclean. The tests require
0088
0089 cd /cppclean
0090 make test
0091 # To generate expected results after a change:
0092 make expected
0093
0094
0095 Current Status:
0096 ---------------
0097 The parser works pretty well for header files, parsing about 99% of Google's
0098 header files. Anything which inspects structure of C++ source files should
0099 work reasonably well. Function bodies are not transformed to an AST,
0100 but left as tokens. Much work is still needed on finding unused header files
0101 and storing an AST in a database.
0102
0103
0104 Non-goals:
0105 ----------
0106 * Parsing all valid C++ source
0107 * Handling invalid C++ source gracefully
0108 * Compiling to machine code (or anything beyond an AST)
0109
0110
0111 Contact:
0112 --------
0113 If you used cppclean, I would love to hear about your experiences
0114 cppclean@googlegroups.com. Even if you don't use cppclean, I'd like to
0115 hear from you. :-) (You can contact me directly at: nnorwitz@gmail.com)