Coverage Report

Created: 2023-09-30 09:22

/Users/buildslave/jenkins/workspace/coverage/llvm-project/lldb/source/Plugins/ExpressionParser/Clang/ClangASTMetadata.h
Line
Count
Source (jump to first uncovered line)
1
//===-- ClangASTMetadata.h --------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H
10
#define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H
11
12
#include "lldb/Core/dwarf.h"
13
#include "lldb/lldb-defines.h"
14
#include "lldb/lldb-enumerations.h"
15
16
namespace lldb_private {
17
18
class ClangASTMetadata {
19
public:
20
  ClangASTMetadata()
21
228k
      : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false),
22
228k
        m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true),
23
228k
        m_is_forcefully_completed(false) {}
24
25
477
  bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; }
26
27
11.2k
  void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; }
28
29
112k
  void SetUserID(lldb::user_id_t user_id) {
30
112k
    m_user_id = user_id;
31
112k
    m_union_is_user_id = true;
32
112k
    m_union_is_isa_ptr = false;
33
112k
  }
34
35
313k
  lldb::user_id_t GetUserID() const {
36
313k
    if (m_union_is_user_id)
37
312k
      return m_user_id;
38
232
    else
39
232
      return LLDB_INVALID_UID;
40
313k
  }
41
42
561
  void SetISAPtr(uint64_t isa_ptr) {
43
561
    m_isa_ptr = isa_ptr;
44
561
    m_union_is_user_id = false;
45
561
    m_union_is_isa_ptr = true;
46
561
  }
47
48
357
  uint64_t GetISAPtr() const {
49
357
    if (m_union_is_isa_ptr)
50
357
      return m_isa_ptr;
51
0
    else
52
0
      return 0;
53
357
  }
54
55
6
  void SetObjectPtrName(const char *name) {
56
6
    m_has_object_ptr = true;
57
6
    if (strcmp(name, "self") == 0)
58
4
      m_is_self = true;
59
2
    else if (strcmp(name, "this") == 0)
60
2
      m_is_self = false;
61
0
    else
62
0
      m_has_object_ptr = false;
63
6
  }
64
65
21
  lldb::LanguageType GetObjectPtrLanguage() const {
66
21
    if (m_has_object_ptr) {
67
14
      if (m_is_self)
68
8
        return lldb::eLanguageTypeObjC;
69
6
      else
70
6
        return lldb::eLanguageTypeC_plus_plus;
71
14
    }
72
7
    return lldb::eLanguageTypeUnknown;
73
21
  }
74
75
0
  const char *GetObjectPtrName() const {
76
0
    if (m_has_object_ptr) {
77
0
      if (m_is_self)
78
0
        return "self";
79
0
      else
80
0
        return "this";
81
0
    } else
82
0
      return nullptr;
83
0
  }
84
85
7.45k
  bool HasObjectPtr() const { return m_has_object_ptr; }
86
87
  /// A type is "forcefully completed" if it was declared complete to satisfy an
88
  /// AST invariant (e.g. base classes must be complete types), but in fact we
89
  /// were not able to find a actual definition for it.
90
41.4k
  bool IsForcefullyCompleted() const { return m_is_forcefully_completed; }
91
92
62
  void SetIsForcefullyCompleted(bool value = true) {
93
62
    m_is_forcefully_completed = true;
94
62
  }
95
96
  void Dump(Stream *s);
97
98
private:
99
  union {
100
    lldb::user_id_t m_user_id;
101
    uint64_t m_isa_ptr;
102
  };
103
104
  bool m_union_is_user_id : 1, m_union_is_isa_ptr : 1, m_has_object_ptr : 1,
105
      m_is_self : 1, m_is_dynamic_cxx : 1, m_is_forcefully_completed : 1;
106
};
107
108
} // namespace lldb_private
109
110
#endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGASTMETADATA_H