Today, I managed to switch C++ Insights to Clang 17!
You can now use the first C++26 features Clang supports and try them out in C++ Insights. I haven't had the time to implement the already-supported papers, so don't be surprised if you don't see many of the mechanics.
Overall, this update was easier than the switch from 15 to 16.
Let me briefly describe the process of upgrading to a new Clang version. I assume that many other Clang tools have similar steps and challenges.
1. Compile Clang from source
I'm very unhappy about this step, but yes, I have to compile Clang for macOS and Windows if I re-add support for this operating system.
It is also true that for macOS ARM currently LLVM ships binaries. Well, since I have been doing that dance for a longer time, I'm not sure how long that remains true. For now, I use an Intel Mac for development, so I have no benefit.
For Windows, the case is a little different; LLVM ships binaries but without
libClang, which C++ Insights needs.
2. Get C++ Insights compiled with the new Clang version
The next step is to try compile C++ Insights with the new Clang version. I think that step failed each and every time because LLVM/Clang does internal refactorings. I have to figure out renaming or entire replacements of functions or types. Depending on the nature of the change, this step varies in time. But so far, I always managed this step.
3. Fixing the tests
Now, I'm in a position where I can run the C++ Insights test suite, which, of course, always fails. There are three main reasons why that's the case. As with their internal API, Clang also updates error or warning messages. Some of the C++ Insights test cases are expected to fail but with a certain error. The pattern matching then no longer matches with the new output. Usually, an easy-to-fix situation.
The second issue with the tests is that the C++ Insights output changes. Once again, this is due to Clang's internal refactorings. Fixing these issues is hard as I first need to track down what change leads to that error.
The third issue that occurs is that C++ Insights crashes. Sometimes, I did not understand Clang's API well enough, or it was changed, so C++ Insights triggered an assertion in Clang. The issue itself is then easy to find, a fix, not necessarily.
Well, what should I say? After 5 years of maintaining C++ Insights and after dozens of updates to new Clang versions, I thought that it. That I had seen everything.
Turns out that's not the case.
During the update to Clang 17, as usual, one of the C++ Insights test cases led to a crash. While I first assumed it was a C++ Insights crash, a closer look revealed that it was a crash in the Clang front-end. To my surprise, C++ Insights now helps find regressions in Clang #67317. Apparently, one of the nasty tests C++ Insights has crashed the constexpr evaluator. Well, a lot of the test code isn't the best, but this is usually the code we want to understand.
Well, I have two or three larger updates in the pipeline. I plan to get rid of the matchers. With that change, C++ Insights would transform even more code, and some current deficits would be gone, like #500.
Then, there is another transformation I've been working on for a while now, which brings a Cfront mode to C++ Insights. But one step at a time.
Support the project