[clang] [analyzer][NFC] Introduce APSIntPtr, a safe wrapper of APSInt (1/4) (PR #120435)
Gábor Horváth via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 18 07:59:02 PST 2024
================
@@ -0,0 +1,64 @@
+//== APSIntPtr.h - Wrapper for APSInt objects owned separately -*- C++ -*--==//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_APSIntPtr_H
+#define LLVM_CLANG_STATICANALYZER_CORE_PATHSENSITIVE_APSIntPtr_H
+
+#include "llvm/ADT/APSInt.h"
+
+namespace clang::ento {
+class BasicValueFactory;
+
+/// A safe wrapper around APSInt objects allocated and owned by
+/// \c BasicValueFactory. This just wraps a common llvm::APSInt.
+class APSIntPtr {
+ using APSInt = llvm::APSInt;
+
+public:
+ APSIntPtr() = delete;
+ APSIntPtr(const APSIntPtr &) = default;
+ APSIntPtr &operator=(const APSIntPtr &) & = default;
+ ~APSIntPtr() = default;
+
+ /// You should not use this API.
+ /// If do, ensure that the \p Ptr not going to dangle.
+ /// Prefer using \c BasicValueFactory::getValue() to get an APSIntPtr object.
----------------
Xazax-hun wrote:
Is it possible to make this private and make `BasicValueFactory` a friend of this class?
https://github.com/llvm/llvm-project/pull/120435
More information about the cfe-commits
mailing list