@@ -192,91 +192,6 @@ std::optional<HighlightingKind> kindForType(const Type *TP,
192
192
return std::nullopt;
193
193
}
194
194
195
- // Whether T is const in a loose sense - is a variable with this type readonly?
196
- bool isConst (QualType T) {
197
- if (T.isNull ())
198
- return false ;
199
- T = T.getNonReferenceType ();
200
- if (T.isConstQualified ())
201
- return true ;
202
- if (const auto *AT = T->getAsArrayTypeUnsafe ())
203
- return isConst (AT->getElementType ());
204
- if (isConst (T->getPointeeType ()))
205
- return true ;
206
- return false ;
207
- }
208
-
209
- // Whether D is const in a loose sense (should it be highlighted as such?)
210
- // FIXME: This is separate from whether *a particular usage* can mutate D.
211
- // We may want V in V.size() to be readonly even if V is mutable.
212
- bool isConst (const Decl *D) {
213
- if (llvm::isa<EnumConstantDecl>(D) || llvm::isa<NonTypeTemplateParmDecl>(D))
214
- return true ;
215
- if (llvm::isa<FieldDecl>(D) || llvm::isa<VarDecl>(D) ||
216
- llvm::isa<MSPropertyDecl>(D) || llvm::isa<BindingDecl>(D)) {
217
- if (isConst (llvm::cast<ValueDecl>(D)->getType ()))
218
- return true ;
219
- }
220
- if (const auto *OCPD = llvm::dyn_cast<ObjCPropertyDecl>(D)) {
221
- if (OCPD->isReadOnly ())
222
- return true ;
223
- }
224
- if (const auto *MPD = llvm::dyn_cast<MSPropertyDecl>(D)) {
225
- if (!MPD->hasSetter ())
226
- return true ;
227
- }
228
- if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D)) {
229
- if (CMD->isConst ())
230
- return true ;
231
- }
232
- return false ;
233
- }
234
-
235
- // "Static" means many things in C++, only some get the "static" modifier.
236
- //
237
- // Meanings that do:
238
- // - Members associated with the class rather than the instance.
239
- // This is what 'static' most often means across languages.
240
- // - static local variables
241
- // These are similarly "detached from their context" by the static keyword.
242
- // In practice, these are rarely used inside classes, reducing confusion.
243
- //
244
- // Meanings that don't:
245
- // - Namespace-scoped variables, which have static storage class.
246
- // This is implicit, so the keyword "static" isn't so strongly associated.
247
- // If we want a modifier for these, "global scope" is probably the concept.
248
- // - Namespace-scoped variables/functions explicitly marked "static".
249
- // There the keyword changes *linkage* , which is a totally different concept.
250
- // If we want to model this, "file scope" would be a nice modifier.
251
- //
252
- // This is confusing, and maybe we should use another name, but because "static"
253
- // is a standard LSP modifier, having one with that name has advantages.
254
- bool isStatic (const Decl *D) {
255
- if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D))
256
- return CMD->isStatic ();
257
- if (const VarDecl *VD = llvm::dyn_cast<VarDecl>(D))
258
- return VD->isStaticDataMember () || VD->isStaticLocal ();
259
- if (const auto *OPD = llvm::dyn_cast<ObjCPropertyDecl>(D))
260
- return OPD->isClassProperty ();
261
- if (const auto *OMD = llvm::dyn_cast<ObjCMethodDecl>(D))
262
- return OMD->isClassMethod ();
263
- return false ;
264
- }
265
-
266
- bool isAbstract (const Decl *D) {
267
- if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D))
268
- return CMD->isPureVirtual ();
269
- if (const auto *CRD = llvm::dyn_cast<CXXRecordDecl>(D))
270
- return CRD->hasDefinition () && CRD->isAbstract ();
271
- return false ;
272
- }
273
-
274
- bool isVirtual (const Decl *D) {
275
- if (const auto *CMD = llvm::dyn_cast<CXXMethodDecl>(D))
276
- return CMD->isVirtual ();
277
- return false ;
278
- }
279
-
280
195
bool isDependent (const Decl *D) {
281
196
if (isa<UnresolvedUsingValueDecl>(D))
282
197
return true ;
0 commit comments