@@ -124,7 +124,7 @@ class Declaration extends Locatable, @declaration {
124124 * To test whether this declaration has a particular name in the global
125125 * namespace, use `hasGlobalName`.
126126 */
127- abstract string getName ( ) ;
127+ string getName ( ) { none ( ) } // overridden in subclasses
128128
129129 /** Holds if this declaration has the given name. */
130130 predicate hasName ( string name ) { name = this .getName ( ) }
@@ -140,7 +140,7 @@ class Declaration extends Locatable, @declaration {
140140 }
141141
142142 /** Gets a specifier of this declaration. */
143- abstract Specifier getASpecifier ( ) ;
143+ Specifier getASpecifier ( ) { none ( ) } // overridden in subclasses
144144
145145 /** Holds if this declaration has a specifier with the given name. */
146146 predicate hasSpecifier ( string name ) { this .getASpecifier ( ) .hasName ( name ) }
@@ -156,7 +156,7 @@ class Declaration extends Locatable, @declaration {
156156 * Gets the location of a declaration entry corresponding to this
157157 * declaration.
158158 */
159- abstract Location getADeclarationLocation ( ) ;
159+ Location getADeclarationLocation ( ) { none ( ) } // overridden in subclasses
160160
161161 /**
162162 * Gets the declaration entry corresponding to this declaration that is a
@@ -165,7 +165,7 @@ class Declaration extends Locatable, @declaration {
165165 DeclarationEntry getDefinition ( ) { none ( ) }
166166
167167 /** Gets the location of the definition, if any. */
168- abstract Location getDefinitionLocation ( ) ;
168+ Location getDefinitionLocation ( ) { none ( ) } // overridden in subclasses
169169
170170 /** Holds if the declaration has a definition. */
171171 predicate hasDefinition ( ) { exists ( this .getDefinition ( ) ) }
@@ -289,6 +289,8 @@ class Declaration extends Locatable, @declaration {
289289 }
290290}
291291
292+ private class TDeclarationEntry = @var_decl or @type_decl or @fun_decl;
293+
292294/**
293295 * A C/C++ declaration entry. For example the following code contains five
294296 * declaration entries:
@@ -304,9 +306,9 @@ class Declaration extends Locatable, @declaration {
304306 * See the comment above `Declaration` for an explanation of the relationship
305307 * between `Declaration` and `DeclarationEntry`.
306308 */
307- abstract class DeclarationEntry extends Locatable {
309+ class DeclarationEntry extends Locatable , TDeclarationEntry {
308310 /** Gets a specifier associated with this declaration entry. */
309- abstract string getASpecifier ( ) ;
311+ string getASpecifier ( ) { none ( ) } // overridden in subclasses
310312
311313 /**
312314 * Gets the name associated with the corresponding definition (where
@@ -329,10 +331,10 @@ abstract class DeclarationEntry extends Locatable {
329331 * `I.getADeclarationEntry()` returns `D`
330332 * but `D.getDeclaration()` only returns `C`
331333 */
332- abstract Declaration getDeclaration ( ) ;
334+ Declaration getDeclaration ( ) { none ( ) } // overridden in subclasses
333335
334336 /** Gets the name associated with this declaration entry, if any. */
335- abstract string getName ( ) ;
337+ string getName ( ) { none ( ) } // overridden in subclasses
336338
337339 /**
338340 * Gets the type associated with this declaration entry.
@@ -341,7 +343,7 @@ abstract class DeclarationEntry extends Locatable {
341343 * For function declarations, get the return type of the function.
342344 * For type declarations, get the type being declared.
343345 */
344- abstract Type getType ( ) ;
346+ Type getType ( ) { none ( ) } // overridden in subclasses
345347
346348 /**
347349 * Gets the type associated with this declaration entry after specifiers
@@ -359,7 +361,7 @@ abstract class DeclarationEntry extends Locatable {
359361 predicate hasSpecifier ( string specifier ) { getASpecifier ( ) = specifier }
360362
361363 /** Holds if this declaration entry is a definition. */
362- abstract predicate isDefinition ( ) ;
364+ predicate isDefinition ( ) { none ( ) } // overridden in subclasses
363365
364366 override string toString ( ) {
365367 if isDefinition ( )
@@ -371,6 +373,8 @@ abstract class DeclarationEntry extends Locatable {
371373 }
372374}
373375
376+ private class TAccessHolder = @function or @usertype;
377+
374378/**
375379 * A declaration that can potentially have more C++ access rights than its
376380 * enclosing element. This comprises `Class` (they have access to their own
@@ -392,7 +396,7 @@ abstract class DeclarationEntry extends Locatable {
392396 * the informal phrase "_R_ occurs in a member or friend of class C", where
393397 * `AccessHolder` corresponds to this _R_.
394398 */
395- abstract class AccessHolder extends Declaration {
399+ class AccessHolder extends Declaration , TAccessHolder {
396400 /**
397401 * Holds if `this` can access private members of class `c`.
398402 *
@@ -410,7 +414,7 @@ abstract class AccessHolder extends Declaration {
410414 /**
411415 * Gets the nearest enclosing `AccessHolder`.
412416 */
413- abstract AccessHolder getEnclosingAccessHolder ( ) ;
417+ AccessHolder getEnclosingAccessHolder ( ) { none ( ) } // overridden in subclasses
414418
415419 /**
416420 * Holds if a base class `base` of `derived` _is accessible at_ `this` (N4140
0 commit comments