================
@@ -0,0 +1,96 @@
+//===------- unittests/Analysis/Scalable/UnsafeBufferUsageTest.cpp
--------===//
+//
+// 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
"clang/Analysis/Scalable/Analyses/UnsafeBufferUsage/UnsafeBufferUsage.h"
+#include
"clang/Analysis/Scalable/Analyses/UnsafeBufferUsage/UnsafeBufferUsageBuilder.h"
+#include "clang/Analysis/Scalable/Model/EntityId.h"
+#include "clang/Analysis/Scalable/Model/EntityIdTable.h"
+#include "gtest/gtest.h"
+
+using namespace clang;
+using namespace ssaf;
+
+namespace {
+
+class UnsafeBufferUsageTest : public testing::Test {
+protected:
+ EntityIdTable Table;
+ UnsafeBufferUsageTUSummaryBuilder Builder;
----------------
steakhal wrote:
Given that `UnsafeBufferUsageTUSummaryBuilder` has only static methods, we
don't need this object and it's also somewhat confusing.
You could have at the top of the TU something like this, basically bringing in
these two names to our scope.
```c++
constexpr inline auto buildPointerKindVariable =
UnsafeBufferUsageTUSummaryBuilder::buildPointerKindVariable;
constexpr inline auto buildUnsafeBufferUsageEntitySummary =
UnsafeBufferUsageTUSummaryBuilder::buildUnsafeBufferUsageEntitySummary;
```
Then use it like this:
```c++
EntityId E1 = Table.getId({"c:@F@foo", "", {}});
EntityId E2 = Table.getId({"c:@F@bar", "", {}});
auto P1 = buildPointerKindVariable(E1, 2); // <- no verbose qualification, no
confusion that it mutates "Builder"
auto P2 = buildPointerKindVariable(E1, 2);
auto P3 = buildPointerKindVariable(E1, 1);
auto P4 = buildPointerKindVariable(E2, 2);
```
https://github.com/llvm/llvm-project/pull/181067
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits