[llvm] [ObjectYAML][NFC] Hoist ContiguousBlobAccumulator into a shared header (PR #207306)
Haohai Wen via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 2 19:35:13 PDT 2026
================
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file implements the ContiguousBlobAccumulator methods declared in
+/// ContiguousBlobAccumulator.h.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/ObjectYAML/ContiguousBlobAccumulator.h"
+#include "llvm/ObjectYAML/YAML.h"
+#include "llvm/Support/Errc.h"
+#include "llvm/Support/LEB128.h"
+#include "llvm/Support/MathExtras.h"
+#include <cassert>
+#include <cstring>
+
+using namespace llvm;
+using namespace llvm::yaml;
+
+bool ContiguousBlobAccumulator::checkLimit(uint64_t Size) {
+ if (!ReachedLimitErr && getOffset() + Size <= MaxSize)
+ return true;
+ if (!ReachedLimitErr)
+ ReachedLimitErr = createStringError(errc::invalid_argument,
+ "reached the output size limit");
+ return false;
+}
----------------
HaohaiWen wrote:
Off must be <= MaxSize.
Just need to be if (!ReachedLimitErr && Size <= MaxSize - Off)
https://github.com/llvm/llvm-project/pull/207306
More information about the llvm-commits
mailing list