[llvm] [SYCL][LLVM] Adding property set I/O library for SYCL (PR #110771)
Chris B via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 14:12:44 PDT 2024
================
@@ -0,0 +1,207 @@
+//= SYCLPropertySetIO.cpp - models a sequence of property sets and their I/O =//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/SYCLPropertySetIO.h"
+
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/Base64.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/LineIterator.h"
+
+#include <memory>
+#include <string>
+
+using namespace llvm::util;
+using namespace llvm;
+
+namespace {
+
+::llvm::Error makeError(const Twine &Msg) {
+ return createStringError(std::error_code{}, Msg);
+}
+
+} // anonymous namespace
+
+Expected<std::unique_ptr<SYCLPropertySetRegistry>>
+SYCLPropertySetRegistry::read(const MemoryBuffer *Buf) {
+ auto Res = std::make_unique<SYCLPropertySetRegistry>();
+ SYCLPropertySet *CurPropSet = nullptr;
+
+ for (line_iterator LI(*Buf); !LI.is_at_end(); LI++) {
+ // See if this line starts a new property set
+ if (LI->starts_with("[")) {
+ // Parse the category (property name)
+ auto EndPos = LI->rfind(']');
----------------
llvm-beanz wrote:
nit:
```suggestion
size_t EndPos = LI->rfind(']');
```
LLVM coding style is more of an "almost never auto". If the type isn't apparent from the expression you should generally prefer the explicit type: https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
This problem repeats a bunch in your code and I won't call out each occurrence, please do a pass yourself.
https://github.com/llvm/llvm-project/pull/110771
More information about the llvm-commits
mailing list