object-introspection/oi/type_graph/TypeIdentifier.h
Jake Hillion d009f02ecb name contained types properly in treebuilder v2
Types within containers were previously named TODO. This sorts it out so
they're named as their most resolved type. The current implementation
skips Typedef names.
2023-08-25 16:25:14 +01:00

65 lines
1.7 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <functional>
#include <unordered_map>
#include <vector>
#include "NodeTracker.h"
#include "PassManager.h"
#include "Types.h"
#include "Visitor.h"
#include "oi/ContainerInfo.h"
namespace oi::detail::type_graph {
class TypeGraph;
/*
* TODO Pass Name
*
* TODO description
*/
class TypeIdentifier : public RecursiveVisitor {
public:
static Pass createPass(const std::vector<ContainerInfo>& passThroughTypes);
static bool isAllocator(Type& t);
TypeIdentifier(NodeTracker& tracker,
TypeGraph& typeGraph,
const std::vector<ContainerInfo>& passThroughTypes)
: tracker_(tracker),
typeGraph_(typeGraph),
passThroughTypes_(passThroughTypes) {
}
using RecursiveVisitor::accept;
void accept(Type& type) override;
void visit(Container& c) override;
private:
NodeTracker& tracker_;
TypeGraph& typeGraph_;
const std::vector<ContainerInfo>& passThroughTypes_;
std::unordered_map<NodeId, std::reference_wrapper<Container>>
passThroughTypeDummys_;
};
} // namespace oi::detail::type_graph