Skip to content

Commit e91f643

Browse files
committed
Disallow conflicting include headers
Signed-off-by: Larsen, Steffen <[email protected]>
1 parent 17ca3a9 commit e91f643

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sycl/source/detail/device_image_impl.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ struct KernelCompilerBinaryInfo {
169169
Merge(const std::vector<const std::optional<KernelCompilerBinaryInfo> *>
170170
&RTCInfos) {
171171
std::optional<KernelCompilerBinaryInfo> Result = std::nullopt;
172+
std::map<std::string, std::string> IncludePairMap;
172173
for (const std::optional<KernelCompilerBinaryInfo> *RTCInfoPtr : RTCInfos) {
173174
if (!RTCInfoPtr || !(*RTCInfoPtr))
174175
continue;
@@ -196,6 +197,20 @@ struct KernelCompilerBinaryInfo {
196197
Result->MMangledKernelNames.insert(RTCInfo->MMangledKernelNames.begin(),
197198
RTCInfo->MMangledKernelNames.end());
198199

200+
// Assumption is that there are no duplicates, but in the case we let
201+
// duplicates through it should be alright to pay for the minimal extra
202+
// space allocated.
203+
Result->MIncludePairs.reserve(RTCInfo->MIncludePairs.size());
204+
for (const auto &IncludePair : RTCInfo->MIncludePairs) {
205+
auto Inserted = IncludePairMap.insert(IncludePair);
206+
if (!Inserted.second) {
207+
if (Inserted.first->second != IncludePair.second)
208+
throw sycl::exception(make_error_code(errc::invalid),
209+
"Conflicting include files.");
210+
} else {
211+
Result->MIncludePairs.push_back(IncludePair);
212+
}
213+
}
199214
Result->MIncludePairs.insert(Result->MIncludePairs.end(),
200215
RTCInfo->MIncludePairs.begin(),
201216
RTCInfo->MIncludePairs.end());

0 commit comments

Comments
 (0)