standardese / cppast

Library to parse and work with the C++ AST
Other
1.69k stars 163 forks source link

Concept support (minimal functionality) #144

Closed waitingtocompile closed 2 years ago

waitingtocompile commented 2 years ago

This brings concepts up to the bare minimum functionality, with a few notable limitations

1 - concept-constraints on templates are not recorded in any way, the data is lost currently 2 - concepts themselves behave oddly, due to limitations in libclang we can't actually enumerate their template parameters like other templates 3 - codegen can't generate code with concept constraints, and can't generate concepts in general.

Issues 1 and 3 I hope to resolve in the future as I continue working on this. Issue 2 is going to be dependant on libclang properly exposing concept definitions.

waitingtocompile commented 2 years ago

Concept constraint information is now being partially recorded. In-parameter constraints are recorded and generated correctly, however constraints between the template and the actual entity are not, as I've found them difficult to parse reliably

Concepts themselves are now fully generatable. In general I'm really running up against the limits of what information I can actually reliably extract given the lack of libclang support for concepts. Still, it's almost all of the way to the functionality that I want for my purposes, so unless I can figure out a solution for parsing constraints, I'm going to call this "done" beyond any stylistic/formatting changes you want.

Tests are passing properly on my machine, sadly the CI server seems to be running a fairly old version of clang.

foonathan commented 2 years ago

Tests are passing properly on my machine, sadly the CI server seems to be running a fairly old version of clang.

You can use a check for the clang version in the test, e.g. as done here: https://github.com/foonathan/cppast/blob/f3e399573f0dc192625de083afdab05f56d8cba3/test/cpp_function.cpp#L278

I'll see whether I can update CI.

foonathan commented 2 years ago

Again, thank you very much.