MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / HasConflictingMemberOffsets

Function HasConflictingMemberOffsets

source/val/validate_memory.cpp:122–158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

120}
121
122bool HasConflictingMemberOffsets(
123 const std::set<Decoration>& type1_decorations,
124 const std::set<Decoration>& type2_decorations) {
125 {
126 // We are interested in conflicting decoration. If a decoration is in one
127 // list but not the other, then we will assume the code is correct. We are
128 // looking for things we know to be wrong.
129 //
130 // We do not have to traverse type2_decoration because, after traversing
131 // type1_decorations, anything new will not be found in
132 // type1_decoration. Therefore, it cannot lead to a conflict.
133 for (const Decoration& decoration : type1_decorations) {
134 switch (decoration.dec_type()) {
135 case spv::Decoration::Offset: {
136 // Since these affect the layout of the struct, they must be present
137 // in both structs.
138 auto compare = [&decoration](const Decoration& rhs) {
139 if (rhs.dec_type() != spv::Decoration::Offset) return false;
140 return decoration.struct_member_index() ==
141 rhs.struct_member_index();
142 };
143 auto i = std::find_if(type2_decorations.begin(),
144 type2_decorations.end(), compare);
145 if (i != type2_decorations.end() &&
146 decoration.params().front() != i->params().front()) {
147 return true;
148 }
149 } break;
150 default:
151 // This decoration does not affect the layout of the structure, so
152 // just moving on.
153 break;
154 }
155 }
156 }
157 return false;
158}
159
160// If |skip_builtin| is true, returns true if |storage| contains bool within
161// it and no storage that contains the bool is builtin.

Callers 1

Calls 5

dec_typeMethod · 0.80
struct_member_indexMethod · 0.80
frontMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected