MDN wants to talk to developers like you:

Pork Tool Development

Files and locations

Most tools are in the "oink" directory. The "renamer" tool is used as an example; tests are in the "oink/renamer_tests" subdirectory.


For the "renamer" tool, a diff file is generated as the AST is traversed, using the visitor pattern. The diff file is generated using the "Patcher" class.

source locations AST nodes have a location associated with them; SourceLoc is defined to be an integer corresponding to an string offset. This can be translated to an UnboxedLoc, which has a line and column offset (see

macro expansion This section refers to macro expansion when using mcpp (see Installing Pork). For the rename_class.cpp test, generate the file with "gcc -E -Wp,-W0,-K rename_class.cpp >" and run the renamer with "../renamer -rename Foo Bar".

For terminology, suppose "MY_FOO" --> "Foo". Then any post-location variables refer to "Foo" and pre-location variables refer to "MY_FOO". CPPSourceLoc wraps SourceLoc, providing information about macro expansion. CPPSourceLoc will change the previously provided location information (in variable cpp_source_loc._loc) from post-location to pre-location. All values from the AST refer to the post-location.


The #static channel on is for discussion of Pork, Dehydra, and other static analysis tools.

Document Tags and Contributors

 Contributors to this page: teoli, gatoatigrado
 Last updated by: gatoatigrado,