Adding custom driver flags
In the previous section, we explained the role of the driver and toolchains in Clang. In this section, we are going to learn how Clang's driver does this translation by adding a custom driver flag to Clang. Again, we will go through the overview for this example project first before demonstrating the detailed steps in a separate section.
Project overview
The example project we will be using for this section is going to add a new driver flag so that when that flag is given by users, a header file will be implicitly included in the input code.
To be more specific, here, we have a header file – simple_log.h
– shown in the following code that defines some simple APIs to print log messages:
#ifndef SIMPLE_LOG_H #define SIMPLE_LOG_H #include <iostream> #include <string> #ifdef SLG_ENABLE_DEBUG inline void print_debug(const std::string &M) { std::cout << "[DEBUG] " << M << std...