Skip to content

Extract/split functions as separate files for c/c++ files

Notifications You must be signed in to change notification settings

Robin-Y-Ding/PureFunction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PureFunction

Extract functions as separate files from c/c++ files

Usage

Step-1: clang installation

Install clang from the instructions here

Step-2: Integrate FindFunction.cpp into clang as a tool

Create a new folder clang-split-function inside folder llvm-project/clang/tools/ and put the provided CMakeLists.txt and FindFunction.cpp in the new folder. Edit llvm-project/clang/tools/CMakeLists.txt and add the following content into the file.

add_clang_subdirectory(clang-split-function)

Return to the llvm-project/build folder and run make. After it finishes, you can test the example tool by running the following command.

clang-split-function anyfile.c/cpp

Step-3: Run splitFunctions.py

python3 splitFunctions.py <source_file_dir>

The output of splitFunctions.py is a json file containing the path for all available functions.

Referred links:

  1. Clang Tutorial: Finding declarations. https://xinhuang.github.io/posts/2014-10-19-clang-tutorial-finding-declarations.html
  2. clang-tutorial. https://github.com/loarabia/Clang-tutorial
  3. How to write RecursiveASTVisitor based ASTFrontendActions. https://clang.llvm.org/docs/RAVFrontendAction.html

About

Extract/split functions as separate files for c/c++ files

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published