@@ -203,55 +203,40 @@ class File extends Container, @file, Documentable, ExprParent, GoModExprParent,
203203 pragma [ noinline]
204204 predicate hasBuildConstraints ( ) { exists ( BuildConstraintComment bc | this = bc .getFile ( ) ) }
205205
206- /**
207- * Gets an architecture that is valid in a build constraint with bit
208- * size `bitSize`.
209- *
210- * Information obtained from
211- * https://github.com/golang/go/blob/98cbf45cfc6a5a50cc6ac2367f9572cb198b57c7/src/go/types/gccgosizes.go
212- * where the first field of the struct is 4 for 32-bit architectures
213- * and 8 for 64-bit architectures.
214- */
215- private string getAnArchitecture ( int bitSize ) {
216- bitSize = 32 and
217- result in [ "386" , "amd64p32" , "arm" , "armbe" , "mips" , "mipsle" , "mips64p32" , "mips64p32le" ,
218- "ppc" , "s390" , "sparc" ]
219- or
220- bitSize = 64 and
221- result in [ "amd64" , "arm64" , "arm64be" , "ppc64" , "ppc64le" , "mips64" , "mips64le" , "s390x" ,
222- "sparc64" ]
223- }
224-
225206 /**
226207 * Holds if this file contains build constraints that ensure that it
227- * is only built on architectures of bit size `bitSize`.
208+ * is only built on architectures of bit size `bitSize`, which can be
209+ * 32 or 64.
228210 */
229- predicate hasConstrainedIntBitSize ( int bitSize ) {
230- hasExplicitBuildConstraintsForArchitectures ( bitSize ) or
231- hasImplicitBuildConstraintForAnArchitecture ( bitSize )
211+ predicate constrainsIntBitSize ( int bitSize ) {
212+ explicitlyConstrainsIntBitSize ( bitSize ) or
213+ implicitlyConstrainsIntBitSize ( bitSize )
232214 }
233215
234216 /**
235217 * Holds if this file contains explicit build constraints that ensure
236- * that it is only built on an architecture of bit size `bitSize`.
218+ * that it is only built on an architecture of bit size `bitSize`,
219+ * which can be 32 or 64.
237220 */
238- predicate hasExplicitBuildConstraintsForArchitectures ( int bitSize ) {
221+ predicate explicitlyConstrainsIntBitSize ( int bitSize ) {
239222 exists ( BuildConstraintComment bcc , string bc |
240223 this = bcc .getFile ( ) and bc = bcc .getText ( ) .splitAt ( "+build " , 1 )
241224 |
242- forex ( string disjunct | disjunct = bc . splitAt ( " " ) |
243- disjunct .splitAt ( "," ) .matches ( getAnArchitecture ( bitSize ) )
225+ forex ( string disjunct | disjunct = bcc . getADisjunct ( ) |
226+ disjunct .splitAt ( "," ) .( Architecture ) . getBitSize ( ) = bitSize
244227 )
245228 )
246229 }
247230
248231 /**
249232 * Holds if this file has a name which acts as an implicit build
250233 * constraint that ensures that it is only built on an
251- * architecture of bit size `bitSize`.
234+ * architecture of bit size `bitSize`, which can be 32 or 64 .
252235 */
253- predicate hasImplicitBuildConstraintForAnArchitecture ( int bitSize ) {
254- this .getStem ( ) .regexpMatch ( ".*_" + getAnArchitecture ( bitSize ) + "(_test)?" )
236+ predicate implicitlyConstrainsIntBitSize ( int bitSize ) {
237+ this
238+ .getStem ( )
239+ .regexpMatch ( ".*_" + any ( Architecture arch | arch .getBitSize ( ) = bitSize ) + "(_test)?" )
255240 }
256241
257242 override string toString ( ) { result = Container .super .toString ( ) }
0 commit comments