Adding the new architecture to the Triple class – The Target Description

An instance of the Triple class represents the target platform LLVM is producing code for. To support a new architecture, the first task is to extend the Triple class. In the llvm/include/llvm/TargetParser/Triple.h file, add a member to the ArchType enumeration along with a new predicate:class Triple {public:enum ArchType {// Many more membersm88k, // M88000 (big endian): m88k};/// Tests whether the …

Creating your own clang-based tool – Debugging Using LLVM Tools-3

On Windows, the plugin support is different from Unix, and the required LLVM and clang libraries must be linked in. The following code ensures this:if(WIN32 OR CYGWIN)set(LLVM_LINK_COMPONENTS Support)clang_target_link_libraries(NamingPlugin PRIVATEclangAST clangBasic clangFrontend clangLex)endif() Now, we can configure and build the plugin, assuming that the CMAKE_GENERATOR and CMAKE_BUILD_TYPE environment variables are set:$ cmake -DLLVM_DIR=~/LLVM/llvm-17/lib/cmake/llvm \-DClang_DIR=~/LLVM/llvm-17/lib/cmake/clang \-B build$ cmake –build build These steps …

Adding a new checker to the clang static analyzer – Debugging Using LLVM Tools-5

This finishes the implementation of the new checker. To build the plugin, we also need to create a build description in the CMakeLists.txt file which lives in the same directory as IconvChecker.cpp: Now, we can configure and build the plugin, assuming that the CMAKE_GENERATOR and CMAKE_BUILD_TYPE environment variables are set:$ cmake -DLLVM_DIR=~/LLVM/llvm-17/lib/cmake/llvm \-DClang_DIR=~/LLVM/llvm-17/lib/cmake/clang \-B build$ cmake –build build You can …