21
21
#include < string>
22
22
#include < utility>
23
23
namespace clang {
24
+ class ConceptDecl ;
24
25
25
26
// / \brief The result of a constraint satisfaction check, containing the
26
27
// / necessary information to diagnose an unsatisfied constraint.
@@ -75,6 +76,102 @@ struct ASTConstraintSatisfaction final :
75
76
Create (const ASTContext &C, const ConstraintSatisfaction &Satisfaction);
76
77
};
77
78
79
+ // / \brief Common data class for constructs that reference concepts with
80
+ // / template arguments.
81
+ class ConceptReference {
82
+ protected:
83
+ // \brief The optional nested name specifier used when naming the concept.
84
+ NestedNameSpecifierLoc NestedNameSpec;
85
+
86
+ // / \brief The ___location of the template keyword, if specified when naming the
87
+ // / concept.
88
+ SourceLocation TemplateKWLoc;
89
+
90
+ // / \brief The concept name used.
91
+ DeclarationNameInfo ConceptName;
92
+
93
+ // / \brief The declaration found by name lookup when the expression was
94
+ // / created.
95
+ // / Can differ from NamedConcept when, for example, the concept was found
96
+ // / through a UsingShadowDecl.
97
+ NamedDecl *FoundDecl;
98
+
99
+ // / \brief The concept named.
100
+ ConceptDecl *NamedConcept;
101
+
102
+ // / \brief The template argument list source info used to specialize the
103
+ // / concept.
104
+ const ASTTemplateArgumentListInfo *ArgsAsWritten;
105
+
106
+ public:
107
+
108
+ ConceptReference (NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc,
109
+ DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl,
110
+ ConceptDecl *NamedConcept,
111
+ const ASTTemplateArgumentListInfo *ArgsAsWritten) :
112
+ NestedNameSpec (NNS), TemplateKWLoc(TemplateKWLoc),
113
+ ConceptName (ConceptNameInfo), FoundDecl(FoundDecl),
114
+ NamedConcept (NamedConcept), ArgsAsWritten(ArgsAsWritten) {}
115
+
116
+ ConceptReference () : NestedNameSpec(), TemplateKWLoc(), ConceptName(),
117
+ FoundDecl (nullptr ), NamedConcept(nullptr ), ArgsAsWritten(nullptr ) {}
118
+
119
+ const NestedNameSpecifierLoc &getNestedNameSpecifierLoc () const {
120
+ return NestedNameSpec;
121
+ }
122
+
123
+ const DeclarationNameInfo &getConceptNameInfo () const { return ConceptName; }
124
+
125
+ SourceLocation getConceptNameLoc () const {
126
+ return getConceptNameInfo ().getLoc ();
127
+ }
128
+
129
+ SourceLocation getTemplateKWLoc () const { return TemplateKWLoc; }
130
+
131
+ NamedDecl *getFoundDecl () const {
132
+ return FoundDecl;
133
+ }
134
+
135
+ ConceptDecl *getNamedConcept () const {
136
+ return NamedConcept;
137
+ }
138
+
139
+ const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten () const {
140
+ return ArgsAsWritten;
141
+ }
142
+
143
+ // / \brief Whether or not template arguments were explicitly specified in the
144
+ // / concept reference (they might not be in type constraints, for example)
145
+ bool hasExplicitTemplateArgs () const {
146
+ return ArgsAsWritten != nullptr ;
147
+ }
148
+ };
149
+
150
+ class TypeConstraint : public ConceptReference {
151
+ // / \brief The immediately-declared constraint expression introduced by this
152
+ // / type-constraint.
153
+ Expr *ImmediatelyDeclaredConstraint = nullptr ;
154
+
155
+ public:
156
+ TypeConstraint (NestedNameSpecifierLoc NNS,
157
+ DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl,
158
+ ConceptDecl *NamedConcept,
159
+ const ASTTemplateArgumentListInfo *ArgsAsWritten,
160
+ Expr *ImmediatelyDeclaredConstraint) :
161
+ ConceptReference (NNS, /* TemplateKWLoc=*/ SourceLocation(), ConceptNameInfo,
162
+ FoundDecl, NamedConcept, ArgsAsWritten),
163
+ ImmediatelyDeclaredConstraint (ImmediatelyDeclaredConstraint) {}
164
+
165
+ // / \brief Get the immediately-declared constraint expression introduced by
166
+ // / this type-constraint, that is - the constraint expression that is added to
167
+ // / the associated constraints of the enclosing declaration in practice.
168
+ Expr *getImmediatelyDeclaredConstraint () const {
169
+ return ImmediatelyDeclaredConstraint;
170
+ }
171
+
172
+ void print (llvm::raw_ostream &OS, PrintingPolicy Policy) const ;
173
+ };
174
+
78
175
} // clang
79
176
80
177
#endif // LLVM_CLANG_AST_ASTCONCEPT_H
0 commit comments