[clang] [llvm] [Offload][SYCL] Refactoring: get rid of newline separators (PR #180274)

Nick Sarnie via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 6 12:00:08 PST 2026


================
@@ -916,14 +916,19 @@ class SYCLWrapper {
   std::pair<Constant *, Constant *>
   initOffloadEntriesPerImage(StringRef Entries, const Twine &OffloadKindTag) {
     SmallVector<Constant *> EntriesInits;
-    std::unique_ptr<MemoryBuffer> MB = MemoryBuffer::getMemBuffer(
-        Entries, /*BufferName*/ "", /*RequiresNullTerminator*/ false);
-    for (line_iterator LI(*MB); !LI.is_at_eof(); ++LI) {
-      GlobalVariable *GV =
-          emitOffloadingEntry(M, /*Kind*/ OffloadKind::OFK_SYCL,
-                              Constant::getNullValue(PointerType::getUnqual(C)),
-                              /*Name*/ *LI, /*Size*/ 0,
-                              /*Flags*/ 0, /*Data*/ 0);
+    const char *Current = Entries.data();
+    const char *End = Current + Entries.size();
+    while (Current < End) {
+      StringRef Name(Current);
+      Current += Name.size() + 1;
----------------
sarnex wrote:

Is the trick here just relying on the null terminator inbetween names as a delimiter?  Or am I misunderstanding?

https://github.com/llvm/llvm-project/pull/180274


More information about the cfe-commits mailing list