This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add a concept AST nodes.
AbandonedPublic

Authored by massberg on Aug 2 2023, 2:30 AM.

Details

Reviewers
shafik
Summary

(note this patch is not be ready to be submitted. The current version should work as a base
for discussion and later be changed to a submittable version.
Also note that there is a draft version of this patch containing some comments, see https://reviews.llvm.org/D155858)

This patch adds a concept AST node (ConceptLoc) and uses it at the corresponding places.

There are three objects that might have constraints via concepts:
TypeConstraint, ConceptSpecializationExpr and AutoTypeLoc.
The first two inherit from ConceptReference while the latter has
the information about a possible constraint directly stored in AutoTypeLocInfo. It would be nice if the concept information would be stored the same way in all three cases.

Moreover the current structure makes it difficult to deal with these concepts. For example in Clangd accessing the locations of constraints of a AutoTypeLoc can only be done with quite ugly hacks.

So we think that it makes sense to create a new AST node for such concepts.

In details we propose the following:

  • Rename ConceptReference to ConceptLoc (or something else what is approriate)

and make it the new AST node.

  • TypeConstraint and ConceptSpecializationExpr do not longer inherit from ConceptReference but store a pointer to a ConceptLoc.
  • AutoTypeLoc stores a pointer to ConceptLoc instead of storing the concept info in AutoTypeLocInfo.

This patch implements a first version of this idea which compiles and where the existing tests pass.
To make this patch as small as possible we keep the existing member functions to access concept data. Later these can be replaced by directly calling the corresponding functions of the ConceptLocs.

Diff Detail

Event Timeline

massberg created this revision.Aug 2 2023, 2:30 AM
Herald added a project: Restricted Project. · View Herald Transcript
massberg requested review of this revision.Aug 2 2023, 2:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2023, 2:30 AM
massberg retitled this revision from Add a concept AST nodes. to [clang] Add a concept AST nodes..Aug 2 2023, 2:34 AM

@erichkeane Hi Erich, we would like to add an AST node for concepts (see description above) and we are interested in your opinion on the high level design..
This patch is a draft of what the new AST node could look like and how it would be part of the existing infrastructure.

Also note that there is a draft version of this patch (https://reviews.llvm.org/D155858), which also contains some comments (I wasn't able to change the draft version to a regular patch so that people get notified, so I have to create a new one).

massberg abandoned this revision.Aug 2 2023, 3:54 AM

Abandon this revision in favor of https://reviews.llvm.org/D155858