Coverage Report

Created: 2022-01-18 06:27

/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
      : m_user_id(0), m_union_is_user_id(false), m_union_is_isa_ptr(false),
22
        m_has_object_ptr(false), m_is_self(false), m_is_dynamic_cxx(true),
23
318k
        m_is_forcefully_completed(false) {}
24
25
102
  bool GetIsDynamicCXXType() const { return m_is_dynamic_cxx; }
26
27
13.8k
  void SetIsDynamicCXXType(bool b) { m_is_dynamic_cxx = b; }
28
29
155k
  void SetUserID(lldb::user_id_t user_id) {
30
155k
    m_user_id = user_id;
31
155k
    m_union_is_user_id = true;
32
155k
    m_union_is_isa_ptr = false;
33
155k
  }
34
35
442k
  lldb::user_id_t GetUserID() const {
36
442k
    if (m_union_is_user_id)
37
442k
      return m_user_id;
38
254
    else
39
254
      return LLDB_INVALID_UID;
40
442k
  }
41
42
621
  void SetISAPtr(uint64_t isa_ptr) {
43
621
    m_isa_ptr = isa_ptr;
44
621
    m_union_is_user_id = false;
45
621
    m_union_is_isa_ptr = true;
46
621
  }
47
48
442
  uint64_t GetISAPtr() const {
49
442
    if (m_union_is_isa_ptr)
50
442
      return m_isa_ptr;
51
0
    else
52
0
      return 0;
53
442
  }
54
55
17
  void SetObjectPtrName(const char *name) {
56
17
    m_has_object_ptr = true;
57
17
    if (strcmp(name, "self") == 0)
58
6
      m_is_self = true;
59
11
    else if (strcmp(name, "this") == 0)
60
11
      m_is_self = false;
61
0
    else
62
0
      m_has_object_ptr = false;
63
17
  }
64
65
15
  lldb::LanguageType GetObjectPtrLanguage() const {
66
15
    if (m_has_object_ptr) {
67
15
      if (m_is_self)
68
9
        return lldb::eLanguageTypeObjC;
69
6
      else
70
6
        return lldb::eLanguageTypeC_plus_plus;
71
15
    }
72
0
    return lldb::eLanguageTypeUnknown;
73
15
  }
74
75
3
  const char *GetObjectPtrName() const {
76
3
    if (m_has_object_ptr) {
77
3
      if (m_is_self)
78
3
        return "self";
79
0
      else
80
0
        return "this";
81
3
    } else
82
0
      return nullptr;
83
3
  }
84
85
9.73k
  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
45.5k
  bool IsForcefullyCompleted() const { return m_is_forcefully_completed; }
91
92
54
  void SetIsForcefullyCompleted(bool value = true) {
93
54
    m_is_forcefully_completed = true;
94
54
  }
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