Using Clang To Auto-Convert Qt 4 To Qt 5
There's new work underway to take advantage of LLVM's Clang tooling to auto-convert most Qt 4.x code into being Qt 5.0-compatible.
A developer at KDAB has been working on automated porting from Qt 4 to Qt 5 C++ code using Clang, as mentioned in this blog post. "While porting KDE code from Qt 4 to Qt 5, I initially wrote some sed scripts to assist with porting, but then started investigating semantic tooling to help with the task. The result is a tool which can automate with precision some of the boring API renames which are a necessary part of any Qt 4 to 5 port. Initially I called it ‘Captcha’ for ‘Clang Assisted Porting Tool using Compilation, Heuristics and Algorithms’, and because it makes the computer do a better porting job than humans."
This Clang code supports renaming class methods, enums, and functions to become compatible with Qt5 while still maintaining backwards compatibility, etc.
Check out the KDAB blog post for more technical details about this work. The blog post ends with, "This clang based tooling was fun to write and the porting API in clang is certainly interesting (the subject of a future blog post). A tool like this is capable doing many boring parts of what is required in porting, such as renaming methods, and it works quite well, but it will never port from QtWidgets to QML for example. The automatable part of a Qt 4 to 5 port will always be the a subset of the same possibilities. Some existing code will use QRegion::intersect, while others will not. The tool can test the codebase for what is required though of course, so it can be used in a ‘fire and forget’ manner."
This Clang-based automatic code re-factoring is similar to how Google is trying to make C++ more fun.
Latest Articles & Reviews
Latest Linux News
Most Viewed News This Week