@@ -124,7 +124,7 @@ class Declaration extends Locatable, @declaration {
124
124
* To test whether this declaration has a particular name in the global
125
125
* namespace, use `hasGlobalName`.
126
126
*/
127
- abstract string getName ( ) ;
127
+ string getName ( ) { none ( ) } // overridden in subclasses
128
128
129
129
/** Holds if this declaration has the given name. */
130
130
predicate hasName ( string name ) { name = this .getName ( ) }
@@ -140,7 +140,7 @@ class Declaration extends Locatable, @declaration {
140
140
}
141
141
142
142
/** Gets a specifier of this declaration. */
143
- abstract Specifier getASpecifier ( ) ;
143
+ Specifier getASpecifier ( ) { none ( ) } // overridden in subclasses
144
144
145
145
/** Holds if this declaration has a specifier with the given name. */
146
146
predicate hasSpecifier ( string name ) { this .getASpecifier ( ) .hasName ( name ) }
@@ -156,7 +156,7 @@ class Declaration extends Locatable, @declaration {
156
156
* Gets the location of a declaration entry corresponding to this
157
157
* declaration.
158
158
*/
159
- abstract Location getADeclarationLocation ( ) ;
159
+ Location getADeclarationLocation ( ) { none ( ) } // overridden in subclasses
160
160
161
161
/**
162
162
* Gets the declaration entry corresponding to this declaration that is a
@@ -165,7 +165,7 @@ class Declaration extends Locatable, @declaration {
165
165
DeclarationEntry getDefinition ( ) { none ( ) }
166
166
167
167
/** Gets the location of the definition, if any. */
168
- abstract Location getDefinitionLocation ( ) ;
168
+ Location getDefinitionLocation ( ) { none ( ) } // overridden in subclasses
169
169
170
170
/** Holds if the declaration has a definition. */
171
171
predicate hasDefinition ( ) { exists ( this .getDefinition ( ) ) }
@@ -289,6 +289,8 @@ class Declaration extends Locatable, @declaration {
289
289
}
290
290
}
291
291
292
+ private class TDeclarationEntry = @var_decl or @type_decl or @fun_decl;
293
+
292
294
/**
293
295
* A C/C++ declaration entry. For example the following code contains five
294
296
* declaration entries:
@@ -304,9 +306,9 @@ class Declaration extends Locatable, @declaration {
304
306
* See the comment above `Declaration` for an explanation of the relationship
305
307
* between `Declaration` and `DeclarationEntry`.
306
308
*/
307
- abstract class DeclarationEntry extends Locatable {
309
+ class DeclarationEntry extends Locatable , TDeclarationEntry {
308
310
/** Gets a specifier associated with this declaration entry. */
309
- abstract string getASpecifier ( ) ;
311
+ string getASpecifier ( ) { none ( ) } // overridden in subclasses
310
312
311
313
/**
312
314
* Gets the name associated with the corresponding definition (where
@@ -329,10 +331,10 @@ abstract class DeclarationEntry extends Locatable {
329
331
* `I.getADeclarationEntry()` returns `D`
330
332
* but `D.getDeclaration()` only returns `C`
331
333
*/
332
- abstract Declaration getDeclaration ( ) ;
334
+ Declaration getDeclaration ( ) { none ( ) } // overridden in subclasses
333
335
334
336
/** Gets the name associated with this declaration entry, if any. */
335
- abstract string getName ( ) ;
337
+ string getName ( ) { none ( ) } // overridden in subclasses
336
338
337
339
/**
338
340
* Gets the type associated with this declaration entry.
@@ -341,7 +343,7 @@ abstract class DeclarationEntry extends Locatable {
341
343
* For function declarations, get the return type of the function.
342
344
* For type declarations, get the type being declared.
343
345
*/
344
- abstract Type getType ( ) ;
346
+ Type getType ( ) { none ( ) } // overridden in subclasses
345
347
346
348
/**
347
349
* Gets the type associated with this declaration entry after specifiers
@@ -359,7 +361,7 @@ abstract class DeclarationEntry extends Locatable {
359
361
predicate hasSpecifier ( string specifier ) { getASpecifier ( ) = specifier }
360
362
361
363
/** Holds if this declaration entry is a definition. */
362
- abstract predicate isDefinition ( ) ;
364
+ predicate isDefinition ( ) { none ( ) } // overridden in subclasses
363
365
364
366
override string toString ( ) {
365
367
if isDefinition ( )
@@ -371,6 +373,8 @@ abstract class DeclarationEntry extends Locatable {
371
373
}
372
374
}
373
375
376
+ private class TAccessHolder = @function or @usertype;
377
+
374
378
/**
375
379
* A declaration that can potentially have more C++ access rights than its
376
380
* enclosing element. This comprises `Class` (they have access to their own
@@ -392,7 +396,7 @@ abstract class DeclarationEntry extends Locatable {
392
396
* the informal phrase "_R_ occurs in a member or friend of class C", where
393
397
* `AccessHolder` corresponds to this _R_.
394
398
*/
395
- abstract class AccessHolder extends Declaration {
399
+ class AccessHolder extends Declaration , TAccessHolder {
396
400
/**
397
401
* Holds if `this` can access private members of class `c`.
398
402
*
@@ -410,7 +414,7 @@ abstract class AccessHolder extends Declaration {
410
414
/**
411
415
* Gets the nearest enclosing `AccessHolder`.
412
416
*/
413
- abstract AccessHolder getEnclosingAccessHolder ( ) ;
417
+ AccessHolder getEnclosingAccessHolder ( ) { none ( ) } // overridden in subclasses
414
418
415
419
/**
416
420
* Holds if a base class `base` of `derived` _is accessible at_ `this` (N4140
0 commit comments