Coverage Report

Created: 2023-12-11 06:17

/proc/self/cwd/src/ir/storage.h
Line
Count
Source (jump to first uncovered line)
1
//-----------------------------------------------------------------------------
2
// Copyright 2021 Google LLC
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
//     https://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
//----------------------------------------------------------------------------
16
#ifndef SRC_IR_STORAGE_H_
17
#define SRC_IR_STORAGE_H_
18
19
#include "absl/container/flat_hash_set.h"
20
#include "absl/strings/str_format.h"
21
#include "src/ir/types/type.h"
22
#include "src/ir/value.h"
23
24
namespace raksha::ir {
25
26
// A class that represents a storage node.
27
class Storage {
28
 public:
29
  Storage(absl::string_view name, types::Type type)
30
124k
      : name_(name), type_(std::move(type)) {}
31
32
  // Disable copy semantics.
33
  Storage(const Storage&) = delete;
34
  Storage& operator=(const Storage&) = delete;
35
  Storage(Storage&&) = default;
36
  Storage& operator=(Storage&&) = default;
37
124k
  ~Storage() = default;
38
39
947
  void AddInputValue(Value value) { input_values_.insert(value); }
40
41
107k
  absl::string_view name() const { return name_; }
42
0
  const types::Type& type() const { return type_; }
43
20.9k
  const absl::flat_hash_set<Value>& input_values() const {
44
20.9k
    return input_values_;
45
20.9k
  }
46
47
0
  std::string ToString() const {
48
0
    // TODO(#335): When types have a ToString use that to print types.
49
0
    return absl::StrFormat("store:%s:type", name_);
50
0
  }
51
52
 private:
53
  std::string name_;
54
  types::Type type_;
55
  absl::flat_hash_set<Value> input_values_;
56
};
57
58
}  // namespace raksha::ir
59
60
#endif  // SRC_IR_STORAGE_H_