I am interested in Cling and have tried it. But I have a question regarding the development and future of Cling. I notice that Cling has extended Clang by modifying parts of the latter’s source codes, and such a modification is not based on the latest release or development version of Clang.
Therefore, will it be a problem for Cling to use the latest version of Clang in the future? If yes, will you then maintain your own version of Clang that might become diverged against the Clang development by Apple Inc. and others?
Thank you. I am sorry for the duplicated posting, and will not do it again
Now I have a few further questions regarding the design of Cling. One important question is why Cling needs to implement its own interpreter and other components that Clang (seems to) already have them. I can not find the answer by looking through the documentation on Cling’s website. Does Cling have some special things to treat that Clang does not have?
Moreover, if possible, could you please recommend some materials regarding the design of Cling that can help me understand Cling and how it works? Thank you very much.
Well, it is just my first impression. For instance, there is a Clang interpreter example in its release, although which is quite simple and just for illustration, and not as good as Cling.
My question is actually the design idea of Cling, and if it is possible to develop Cling just based on APIs of LLVM and Clang, but without modifying their source codes. I feel the answer is not, i.e. such modifications on LLVM and Clang are necessary for Cling, but could anyone provide some details on it, or where I can find such documentation? Thank you.
Look - clang has many elements (e.g. tools) that required API changes in the core of clang - there is nothing special here. While we try to keep the patches to a minimum we also need to be efficient: sometimes it’s much easier to patch than to work around. That said, there are a few patches (the more intrusive ones) that I hope to be able to get into clang.
The main difference between cling and the llvm and clang-provided interpreters is that cling behaves more like an interpreter - while the clang version requires “proper” C++ code, I believe even including a main(), i.e. you can’t just call functions, add #includes etc. That’s the last time I checked - this might have changed.
Cling OTOH has an incremental approach to parsing: it can continue working away on code coming in piece by piece. That’s absolutely awkward for C++ compilers and part of “the magic” of cling.