@@ -7,9 +7,11 @@ class Namespace extends @namespace {
77
88 string getQualifiedName ( ) {
99 if namespacembrs ( _, this )
10- then exists ( Namespace ns |
11- namespacembrs ( ns , this ) and
12- result = ns .getQualifiedName ( ) + "::" + this .getName ( ) )
10+ then
11+ exists ( Namespace ns |
12+ namespacembrs ( ns , this ) and
13+ result = ns .getQualifiedName ( ) + "::" + this .getName ( )
14+ )
1315 else result = this .getName ( )
1416 }
1517
@@ -31,68 +33,81 @@ abstract class Declaration extends @declaration {
3133 Namespace getNamespace ( ) {
3234 // Top level declaration in a namespace ...
3335 result .getADeclaration ( ) = this
34- // ... or nested in another structure.
3536 or
36- exists ( Declaration m
37- | m = this and result = m .getDeclaringType ( ) .getNamespace ( ) )
37+ // ... or nested in another structure.
38+ exists ( Declaration m | m = this and result = m .getDeclaringType ( ) .getNamespace ( ) )
3839 }
3940
4041 string getQualifiedName ( ) {
4142 // MemberFunction, MemberVariable, MemberType
42- exists ( Declaration m
43- | m = this and
44- result = m .getDeclaringType ( ) .getQualifiedName ( ) + "::" + m .getName ( ) )
43+ exists ( Declaration m |
44+ m = this and
45+ result = m .getDeclaringType ( ) .getQualifiedName ( ) + "::" + m .getName ( )
46+ )
4547 or
46- exists ( EnumConstant c
47- | c = this and
48- result = c .getDeclaringEnum ( ) .getQualifiedName ( ) + "::" + c .getName ( ) )
48+ exists ( EnumConstant c |
49+ c = this and
50+ result = c .getDeclaringEnum ( ) .getQualifiedName ( ) + "::" + c .getName ( )
51+ )
4952 or
50- exists ( GlobalOrNamespaceVariable v , string s1 , string s2
51- | v = this and
53+ exists ( GlobalOrNamespaceVariable v , string s1 , string s2 |
54+ v = this and
5255 s2 = v .getNamespace ( ) .getQualifiedName ( ) and
5356 s1 = v .getName ( )
54- | ( s2 != "" and result = s2 + "::" + s1 ) or ( s2 = "" and result = s1 ) )
57+ |
58+ s2 != "" and result = s2 + "::" + s1
59+ or
60+ s2 = "" and result = s1
61+ )
5562 or
56- exists ( Function f , string s1 , string s2
57- | f = this and f .isTopLevel ( ) and
63+ exists ( Function f , string s1 , string s2 |
64+ f = this and
65+ f .isTopLevel ( ) and
5866 s2 = f .getNamespace ( ) .getQualifiedName ( ) and
5967 s1 = f .getName ( )
60- | ( s2 != "" and result = s2 + "::" + s1 ) or ( s2 = "" and result = s1 ) )
68+ |
69+ s2 != "" and result = s2 + "::" + s1
70+ or
71+ s2 = "" and result = s1
72+ )
6173 or
62- exists ( UserType t , string s1 , string s2
63- | t = this and t .isTopLevel ( ) and
74+ exists ( UserType t , string s1 , string s2 |
75+ t = this and
76+ t .isTopLevel ( ) and
6477 s2 = t .getNamespace ( ) .getQualifiedName ( ) and
6578 s1 = t .getName ( )
66- | ( s2 != "" and result = s2 + "::" + s1 ) or ( s2 = "" and result = s1 ) )
79+ |
80+ s2 != "" and result = s2 + "::" + s1
81+ or
82+ s2 = "" and result = s1
83+ )
6784 }
6885
6986 predicate isTopLevel ( ) {
70- not ( this .isMember ( ) or
71- this instanceof FriendDecl or
72- this instanceof EnumConstant or
73- this instanceof Parameter or
74- this instanceof ProxyClass or
75- this instanceof LocalVariable or
76- this instanceof TemplateParameter or
77- this .( UserType ) .isLocal ( ) )
87+ not (
88+ this .isMember ( ) or
89+ this instanceof FriendDecl or
90+ this instanceof EnumConstant or
91+ this instanceof Parameter or
92+ this instanceof ProxyClass or
93+ this instanceof LocalVariable or
94+ this instanceof TemplateParameter or
95+ this .( UserType ) .isLocal ( )
96+ )
7897 }
7998
8099 /** Holds if this declaration is a member of a class/struct/union. */
81100 predicate isMember ( ) { this .hasDeclaringType ( ) }
82101
83102 /** Holds if this declaration is a member of a class/struct/union. */
84- predicate hasDeclaringType ( ) {
85- exists ( this .getDeclaringType ( ) )
86- }
103+ predicate hasDeclaringType ( ) { exists ( this .getDeclaringType ( ) ) }
87104
88105 /**
89106 * Gets the class where this member is declared, if it is a member.
90107 * For templates, both the template itself and all instantiations of
91108 * the template are considered to have the same declaring class.
92109 */
93- Class getDeclaringType ( ) {
94- this = result .getAMember ( )
95- }
110+ Class getDeclaringType ( ) { this = result .getAMember ( ) }
96111}
97112
98113class Variable extends Declaration , @variable {
@@ -105,7 +120,7 @@ class TemplateVariable extends Variable {
105120 Variable getAnInstantiation ( ) { variable_instantiation ( result , this ) }
106121}
107122
108- class LocalScopeVariable extends Variable , @localscopevariable { }
123+ class LocalScopeVariable extends Variable , @localscopevariable { }
109124
110125class LocalVariable extends LocalScopeVariable , @localvariable {
111126 override string getName ( ) { localvariables ( this , _, result ) }
@@ -122,15 +137,13 @@ class GlobalOrNamespaceVariable extends Variable, @globalvariable {
122137}
123138
124139class MemberVariable extends Variable , @membervariable {
125- MemberVariable ( ) {
126- this .isMember ( )
127- }
140+ MemberVariable ( ) { this .isMember ( ) }
128141
129142 override string getName ( ) { membervariables ( this , _, result ) }
130143}
131144
132145class EnumConstant extends Declaration , @enumconstant {
133- override string getName ( ) { enumconstants ( this , _, _, _, result , _) }
146+ override string getName ( ) { enumconstants ( this , _, _, _, result , _) }
134147
135148 UserType getDeclaringEnum ( ) { enumconstants ( this , result , _, _, _, _) }
136149}
@@ -140,23 +153,18 @@ class Function extends Declaration, @function {
140153}
141154
142155class TemplateFunction extends Function {
143- TemplateFunction ( ) {
144- is_function_template ( this ) and function_template_argument ( this , _, _)
145- }
156+ TemplateFunction ( ) { is_function_template ( this ) and function_template_argument ( this , _, _) }
146157
147158 Function getAnInstantiation ( ) {
148- function_instantiation ( result , this )
149- and not exists ( @fun_decl fd |
150- fun_decls ( fd , this , _, _, _) and fun_specialized ( fd ) )
159+ function_instantiation ( result , this ) and
160+ not exists ( @fun_decl fd | fun_decls ( fd , this , _, _, _) and fun_specialized ( fd ) )
151161 }
152162}
153163
154164class UserType extends Declaration , @usertype {
155165 override string getName ( ) { usertypes ( this , result , _) }
156166
157- predicate isLocal ( ) {
158- enclosingfunction ( this , _)
159- }
167+ predicate isLocal ( ) { enclosingfunction ( this , _) }
160168}
161169
162170class ProxyClass extends UserType {
@@ -171,11 +179,12 @@ class Class extends UserType {
171179 Class ( ) { ResolveClass:: isClass ( this ) }
172180
173181 Declaration getAMember ( ) {
174- exists ( Declaration d | member ( this , _ , d ) |
182+ exists ( Declaration d | member ( this , _, d ) |
175183 result = d or
176184 result = d .( TemplateClass ) .getAnInstantiation ( ) or
177185 result = d .( TemplateFunction ) .getAnInstantiation ( ) or
178- result = d .( TemplateVariable ) .getAnInstantiation ( ) )
186+ result = d .( TemplateVariable ) .getAnInstantiation ( )
187+ )
179188 }
180189}
181190
@@ -195,9 +204,7 @@ deprecated class Property extends Declaration {
195204}
196205
197206class FriendDecl extends Declaration , @frienddecl {
198- override string getName ( ) {
199- result = this .getDeclaringClass ( ) .getName ( ) + "'s friend"
200- }
207+ override string getName ( ) { result = this .getDeclaringClass ( ) .getName ( ) + "'s friend" }
201208
202209 Class getDeclaringClass ( ) { frienddecls ( this , result , _, _) }
203210}
0 commit comments