================
@@ -0,0 +1,62 @@
+//===- SerializationFormat.h ------------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Abstract SerializationFormat interface for reading and writing
+// TUSummary and LinkUnitResolution data.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef CLANG_ANALYSIS_SCALABLE_SERIALIZATION_SERIALIZATION_FORMAT_H
+#define CLANG_ANALYSIS_SCALABLE_SERIALIZATION_SERIALIZATION_FORMAT_H
+
+#include "clang/Analysis/Scalable/Model/BuildNamespace.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringRef.h"
+#include <vector>
+
+namespace clang::ssaf {
+
+class TUSummary;
+class EntityIdTable;
+class EntityName;
+class EntityId;
+class TUSummaryData;
+
+/// Abstract base class for serialization formats.
+class SerializationFormat {
+protected:
+ // Helpers providing access to implementation details of basic data
structures
+ // for efficient serialization/deserialization.
+ static EntityIdTable &getIdTableForDeserialization(TUSummary &S);
+ static NestedBuildNamespace &
+ getCommonNamespaceForDeserialization(TUSummary &S);
+ static const EntityIdTable &getIdTable(const TUSummary &S);
+ static const NestedBuildNamespace &getCommonNamespace(const TUSummary &S);
+
+ static BuildNamespaceKind getBuildNamespaceKind(const BuildNamespace &BN);
+ static llvm::StringRef getBuildNamespaceName(const BuildNamespace &BN);
+ static const std::vector<BuildNamespace> &
+ getNestedBuildNamespaces(const NestedBuildNamespace &NBN);
+
+ static llvm::StringRef getEntityNameUSR(const EntityName &EN);
+ static const llvm::SmallString<16> &getEntityNameSuffix(const EntityName
&EN);
+ static const NestedBuildNamespace &
+ getEntityNameNamespace(const EntityName &EN);
----------------
steakhal wrote:
I was thinking of ways to reduce the syntactic noise of these lines; especially
the types.
My idea was to provide these accessors in a table-like format, so that it's
easier to interpret.
Something like this:
```c++
// Accessors for TUSummary:
template <class T> static auto &IdTableOf(T &X) { return X.IdTable; }
template <class T> static auto &TUNamespaceOf(T &X) { return X.TUNamespace; }
// Accessors for BuildNamespace:
template <class T> static auto &KindOf(T &X) { return X.Kind; }
template <class T> static auto &NameOf(T &X) { return X.Name; }
// Accessors for NestedBuildNamespace:
template <class T> static auto &NamespacesOf(T &X) { return X.Namespaces; }
// Accessors for EntityName:
template <class T> static auto &USROf(T &X) { return X.USR; }
template <class T> static auto &SuffixOf(T &X) { return X.Suffix; }
template <class T> static auto &NamespaceOf(T &X) { return X.Namespace; }
```
This looks better, at the expense of auto types everywhere. Each of these work
for const and non-const parameters by forwarding to the relevant field. I find
this marginally better, but still very ugly. I don't think its worth changing
this for now.
https://github.com/llvm/llvm-project/pull/177719
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits