@@ -138,6 +138,19 @@ predicate isCIdentifier(
138138 )
139139}
140140
141+ Macro getGeneratedFrom ( Element e ) {
142+ isCIdentifier ( e , _, _, _, _) and
143+ exists ( MacroInvocation mi |
144+ mi = result .getAnInvocation ( ) and
145+ mi .getAGeneratedElement ( ) = e and
146+ mi .getLocation ( ) .getStartColumn ( ) = e .getLocation ( ) .getStartColumn ( ) and
147+ not exists ( MacroInvocation child |
148+ child .getParentInvocation ( ) = mi and
149+ child .getAGeneratedElement ( ) = e
150+ )
151+ )
152+ }
153+
141154module TargetedCLibrary = CStandardLibrary:: C11;
142155
143156query predicate problems ( Element m , string message ) {
@@ -146,6 +159,8 @@ query predicate problems(Element m, string message) {
146159 string name , Scope scope , CNameSpace cNameSpace , string reason , string identifierDescription
147160 |
148161 isCIdentifier ( m , name , scope , cNameSpace , identifierDescription ) and
162+ // Exclude cases generated from library macros, because the user does not control them
163+ not getGeneratedFrom ( m ) instanceof LibraryMacro and
149164 message = identifierDescription + " '" + name + "' " + reason + "."
150165 |
151166 // C11 7.1.3/1
0 commit comments