mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-17 04:48:15 +00:00
This does some more work to the run_clang_tidy.py wrapper script, and runs an example pass. "again" because it's really the proto fuzzer changes that broke it, it had been working before. "mostly" because there's still an issue within the proto fuzzer that it can't find "port/protobuf.h", i.e. https://github.com/google/libprotobuf-mutator/tree/master/port, but I'm still hesitant to add an include path there.
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
#ifndef CARBON_TOOLCHAIN_SEMANTICS_NODE_REF_H_
|
|
#define CARBON_TOOLCHAIN_SEMANTICS_NODE_REF_H_
|
|
|
|
#include <cstdint>
|
|
|
|
#include "common/ostream.h"
|
|
#include "toolchain/semantics/node_kind.h"
|
|
|
|
namespace Carbon::Semantics {
|
|
|
|
// Type-safe storage of NodeStore indices.
|
|
struct NodeStoreIndex {
|
|
explicit NodeStoreIndex(int32_t index) : index(index) {}
|
|
|
|
explicit operator int32_t() const { return index; }
|
|
|
|
int32_t index;
|
|
};
|
|
|
|
// The standard structure for nodes.
|
|
//
|
|
// This flyweight pattern is used so that each subtype can be stored in its own
|
|
// vector, minimizing memory consumption and heap fragmentation when large
|
|
// quantities are being created.
|
|
class NodeRef {
|
|
public:
|
|
NodeRef() : NodeRef(NodeKind::Invalid, NodeStoreIndex(-1)) {}
|
|
|
|
auto kind() -> NodeKind { return kind_; }
|
|
|
|
private:
|
|
template <typename... StoredNodeT>
|
|
friend class NodeStoreBase;
|
|
|
|
NodeRef(NodeKind kind, NodeStoreIndex index) : kind_(kind), index_(index) {}
|
|
|
|
NodeKind kind_;
|
|
|
|
// The index of the named entity within its list.
|
|
NodeStoreIndex index_;
|
|
};
|
|
|
|
} // namespace Carbon::Semantics
|
|
|
|
#endif // CARBON_TOOLCHAIN_SEMANTICS_NODE_REF_H_
|