@@ -470,7 +470,7 @@ class ByteSliceType extends SliceType {
470470// by unpacking the first 5 fields and tags, allowing a single join
471471// to strongly constrain the available candidates.
472472private predicate hasComponentTypeAndTag ( StructType s , int i , string name , Type tp , string tag ) {
473- component_types ( s , i , name , tp ) and struct_tags ( s , i , tag )
473+ component_types ( s , i , name , tp ) and tag = getStructTag ( s , i )
474474}
475475
476476private newtype TOptStructComponent =
@@ -554,6 +554,14 @@ private predicate unpackAndUnaliasStructType(
554554 )
555555}
556556
557+ bindingset [ i]
558+ pragma [ inline]
559+ private string getStructTag ( StructType st , int i ) {
560+ struct_tags ( st , i , result )
561+ or
562+ not struct_tags ( st , i , _) and result = ""
563+ }
564+
557565/** A struct type. */
558566class StructType extends @structtype, CompositeType {
559567 /**
@@ -582,12 +590,7 @@ class StructType extends @structtype, CompositeType {
582590 * Note that this predicate does not take promoted fields into account.
583591 */
584592 predicate hasOwnFieldWithTag ( int i , string name , Type tp , boolean isEmbedded , string tag ) {
585- this .hasOwnField ( i , name , tp , isEmbedded ) and
586- (
587- struct_tags ( this , i , tag )
588- or
589- not struct_tags ( this , i , _) and tag = ""
590- )
593+ this .hasOwnField ( i , name , tp , isEmbedded ) and tag = getStructTag ( this , i )
591594 }
592595
593596 /**
0 commit comments