[cfe-dev] Dealing with clang API changes in a plugin

Joshua Cranmer 🐧 Pidgeot18 at gmail.com
Mon Dec 8 11:27:44 PST 2014


On 12/8/2014 10:58 AM, Ehsan Akhgari wrote:
> Hi all,
>
> I have a clang-plugin that overrides the 
> PluginASTAction::CreateASTConsumer function.  The return type of this 
> function was changed in trunk (r215323) from ASTConsumer* to 
> std::unique_ptr<ASTConsumer>.  I'd like to keep the plugin working for 
> both clang 3.5 and older, and trunk and newer, which means that I 
> somehow need to detect the version of clang from the headers using a 
> preprocessor macro.
>
> Is there a macro supported for this purpose that I can use?

If you include clang/Basic/Version.h, you can use CLANG_VERSION_MAJOR 
and CLANG_VERSION_MINOR. However, I do believe that Apple's clang uses 
different version numbers from everybody else.

-- 
Joshua Cranmer
Thunderbird and DXR developer
Source code archæologist






More information about the cfe-dev mailing list