GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 3 / 0 / 3
Functions: 100.0% 2 / 0 / 2
Branches: 50.0% 1 / 0 / 2

src/symboltablebuilder/SymbolTableEntry.h
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <stack>
6 #include <string>
7 #include <utility>
8
9 #include <symboltablebuilder/Lifecycle.h>
10 #include <symboltablebuilder/QualType.h>
11
12 #include "../../lib/json/json.hpp"
13
14 // Forward declarations
15 namespace llvm {
16 class Value;
17 } // namespace llvm
18
19 namespace spice::compiler {
20
21 // Forward declarations
22 class Scope;
23 class ASTNode;
24 struct CodeLoc;
25
26 /**
27 * Entry of a symbol table, representing an individual symbol with all its properties
28 */
29 class SymbolTableEntry final {
30 public:
31 // Constructors
32 60965 SymbolTableEntry(std::string name, const QualType &qualType, Scope *scope, ASTNode *declNode, size_t orderIndex, bool global)
33
1/2
✓ Branch 4 → 5 taken 60965 times.
✗ Branch 4 → 7 not taken.
60965 : name(std::move(name)), scope(scope), declNode(declNode), orderIndex(orderIndex), global(global), qualType(qualType) {}
34
35 // Public methods
36 [[nodiscard]] const QualType &getQualType() const;
37 void updateType(const QualType &newType, bool overwriteExistingType);
38 void updateState(const LifecycleState &newState, const ASTNode *node);
39 [[nodiscard]] const CodeLoc &getDeclCodeLoc() const;
40 [[nodiscard]] llvm::Value *getAddress() const;
41 void updateAddress(llvm::Value *address);
42 void pushAddress(llvm::Value *address);
43 void popAddress();
44 [[nodiscard]] bool isField() const;
45 6741 [[nodiscard]] const Lifecycle &getLifecycle() const { return lifecycle; }
46 [[nodiscard]] bool isInitialized() const { return lifecycle.isInitialized(); }
47 [[nodiscard]] nlohmann::ordered_json toJSON() const;
48
49 // Public members
50 const std::string name;
51 Scope *scope;
52 ASTNode *declNode;
53 const size_t orderIndex;
54 const bool global;
55 bool isVolatile = false;
56 bool isParam = false;
57 bool anonymous = false;
58 bool used = false;
59 bool omitDtorCall = false;
60 bool isImplicitField = false;
61
62 private:
63 // Members
64 QualType qualType;
65 std::stack<llvm::Value *> memAddress;
66 Lifecycle lifecycle;
67 };
68
69 } // namespace spice::compiler
70