Coverage Report

Created: 2021-09-21 08:58

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/AST/Redeclarable.h
Line
Count
Source (jump to first uncovered line)
1
//===- Redeclarable.h - Base for Decls that can be redeclared --*- 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
//  This file defines the Redeclarable interface.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CLANG_AST_REDECLARABLE_H
14
#define LLVM_CLANG_AST_REDECLARABLE_H
15
16
#include "clang/AST/ExternalASTSource.h"
17
#include "llvm/ADT/DenseMapInfo.h"
18
#include "llvm/ADT/PointerUnion.h"
19
#include "llvm/ADT/iterator_range.h"
20
#include "llvm/Support/Casting.h"
21
#include <cassert>
22
#include <cstddef>
23
#include <iterator>
24
25
namespace clang {
26
27
class ASTContext;
28
class Decl;
29
30
// Some notes on redeclarables:
31
//
32
//  - Every redeclarable is on a circular linked list.
33
//
34
//  - Every decl has a pointer to the first element of the chain _and_ a
35
//    DeclLink that may point to one of 3 possible states:
36
//      - the "previous" (temporal) element in the chain
37
//      - the "latest" (temporal) element in the chain
38
//      - the "uninitialized-latest" value (when newly-constructed)
39
//
40
//  - The first element is also often called the canonical element. Every
41
//    element has a pointer to it so that "getCanonical" can be fast.
42
//
43
//  - Most links in the chain point to previous, except the link out of
44
//    the first; it points to latest.
45
//
46
//  - Elements are called "first", "previous", "latest" or
47
//    "most-recent" when referring to temporal order: order of addition
48
//    to the chain.
49
//
50
//  - It's easiest to just ignore the implementation of DeclLink when making
51
//    sense of the redeclaration chain.
52
//
53
//  - There's also a "definition" link for several types of
54
//    redeclarable, where only one definition should exist at any given
55
//    time (and the defn pointer is stored in the decl's "data" which
56
//    is copied to every element on the chain when it's changed).
57
//
58
//    Here is some ASCII art:
59
//
60
//      "first"                                     "latest"
61
//      "canonical"                                 "most recent"
62
//      +------------+         first                +--------------+
63
//      |            | <--------------------------- |              |
64
//      |            |                              |              |
65
//      |            |                              |              |
66
//      |            |       +--------------+       |              |
67
//      |            | first |              |       |              |
68
//      |            | <---- |              |       |              |
69
//      |            |       |              |       |              |
70
//      | @class A   |  link | @interface A |  link | @class A     |
71
//      | seen first | <---- | seen second  | <---- | seen third   |
72
//      |            |       |              |       |              |
73
//      +------------+       +--------------+       +--------------+
74
//      | data       | defn  | data         |  defn | data         |
75
//      |            | ----> |              | <---- |              |
76
//      +------------+       +--------------+       +--------------+
77
//        |                     |     ^                  ^
78
//        |                     |defn |                  |
79
//        | link                +-----+                  |
80
//        +-->-------------------------------------------+
81
82
/// Provides common interface for the Decls that can be redeclared.
83
template<typename decl_type>
84
class Redeclarable {
85
protected:
86
  class DeclLink {
87
    /// A pointer to a known latest declaration, either statically known or
88
    /// generationally updated as decls are added by an external source.
89
    using KnownLatest =
90
        LazyGenerationalUpdatePtr<const Decl *, Decl *,
91
                                  &ExternalASTSource::CompleteRedeclChain>;
92
93
    /// We store a pointer to the ASTContext in the UninitializedLatest
94
    /// pointer, but to avoid circular type dependencies when we steal the low
95
    /// bits of this pointer, we use a raw void* here.
96
    using UninitializedLatest = const void *;
97
98
    using Previous = Decl *;
99
100
    /// A pointer to either an uninitialized latest declaration (where either
101
    /// we've not yet set the previous decl or there isn't one), or to a known
102
    /// previous declaration.
103
    using NotKnownLatest = llvm::PointerUnion<Previous, UninitializedLatest>;
104
105
    mutable llvm::PointerUnion<NotKnownLatest, KnownLatest> Link;
106
107
  public:
108
    enum PreviousTag { PreviousLink };
109
    enum LatestTag { LatestLink };
110
111
    DeclLink(LatestTag, const ASTContext &Ctx)
112
158M
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
4.23M
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
103k
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::VarDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::VarDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
107M
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::FunctionDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::FunctionDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
36.1M
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::TagDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::TagDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
7.27M
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
360
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::NamespaceDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
978k
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
195k
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
293k
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
26.0k
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::LatestTag, clang::ASTContext const&)
Line
Count
Source
112
1.72M
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
113
3.69M
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::PreviousTag, clang::TranslationUnitDecl*)
Line
Count
Source
113
45
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::FunctionDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::FunctionDecl>::DeclLink::PreviousTag, clang::FunctionDecl*)
Line
Count
Source
113
404k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::PreviousTag, clang::RedeclarableTemplateDecl*)
Line
Count
Source
113
223k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::TagDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::TagDecl>::DeclLink::PreviousTag, clang::TagDecl*)
Line
Count
Source
113
1.87M
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::NamespaceDecl>::DeclLink::PreviousTag, clang::NamespaceDecl*)
Line
Count
Source
113
923k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::PreviousTag, clang::ObjCInterfaceDecl*)
Line
Count
Source
113
166k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::PreviousTag, clang::ObjCProtocolDecl*)
Line
Count
Source
113
5.67k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::PreviousTag, clang::TypedefNameDecl*)
Line
Count
Source
113
24.4k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::VarDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::VarDecl>::DeclLink::PreviousTag, clang::VarDecl*)
Line
Count
Source
113
70.8k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::PreviousTag, clang::NamespaceAliasDecl*)
Line
Count
Source
113
15
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::DeclLink(clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::PreviousTag, clang::UsingShadowDecl*)
Line
Count
Source
113
3.70k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
114
115
562M
    bool isFirst() const {
116
562M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
562M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()297M
;
120
562M
    }
clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::isFirst() const
Line
Count
Source
115
49.8k
    bool isFirst() const {
116
49.8k
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
49.8k
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()66
;
120
49.8k
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::isFirst() const
Line
Count
Source
115
46.8M
    bool isFirst() const {
116
46.8M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
46.8M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()12.3M
;
120
46.8M
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::isFirst() const
Line
Count
Source
115
110M
    bool isFirst() const {
116
110M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
110M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()28.8M
;
120
110M
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::isFirst() const
Line
Count
Source
115
4.34M
    bool isFirst() const {
116
4.34M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
4.34M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()3.81M
;
120
4.34M
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::isFirst() const
Line
Count
Source
115
63.3M
    bool isFirst() const {
116
63.3M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
63.3M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()21.2M
;
120
63.3M
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::isFirst() const
Line
Count
Source
115
551k
    bool isFirst() const {
116
551k
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
551k
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()372k
;
120
551k
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::isFirst() const
Line
Count
Source
115
5.27M
    bool isFirst() const {
116
5.27M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
5.27M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()3.65M
;
120
5.27M
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::isFirst() const
Line
Count
Source
115
329M
    bool isFirst() const {
116
329M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
329M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()226M
;
120
329M
    }
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::isFirst() const
Line
Count
Source
115
418
    bool isFirst() const {
116
418
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
418
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()393
;
120
418
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::isFirst() const
Line
Count
Source
115
1.26M
    bool isFirst() const {
116
1.26M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
1.26M
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()785k
;
120
1.26M
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::isFirst() const
Line
Count
Source
115
116k
    bool isFirst() const {
116
116k
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
116k
             
Link.get<NotKnownLatest>().template is<UninitializedLatest>()61.0k
;
120
116k
    }
121
122
878M
    decl_type *getPrevious(const decl_type *D) const {
123
878M
      if (Link.is<NotKnownLatest>()) {
124
161M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
161M
        if (NKL.is<Previous>())
126
29.4M
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
132M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
132M
                               NKL.get<UninitializedLatest>()),
131
132M
                           const_cast<decl_type *>(D));
132
132M
      }
133
134
849M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
878M
    }
clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::getPrevious(clang::TranslationUnitDecl const*) const
Line
Count
Source
122
115M
    decl_type *getPrevious(const decl_type *D) const {
123
115M
      if (Link.is<NotKnownLatest>()) {
124
103k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
103k
        if (NKL.is<Previous>())
126
21
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
103k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
103k
                               NKL.get<UninitializedLatest>()),
131
103k
                           const_cast<decl_type *>(D));
132
103k
      }
133
134
115M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
115M
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::getPrevious(clang::VarDecl const*) const
Line
Count
Source
122
272M
    decl_type *getPrevious(const decl_type *D) const {
123
272M
      if (Link.is<NotKnownLatest>()) {
124
100M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
100M
        if (NKL.is<Previous>())
126
3.72M
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
96.8M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
96.8M
                               NKL.get<UninitializedLatest>()),
131
96.8M
                           const_cast<decl_type *>(D));
132
96.8M
      }
133
134
268M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
272M
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::getPrevious(clang::FunctionDecl const*) const
Line
Count
Source
122
110M
    decl_type *getPrevious(const decl_type *D) const {
123
110M
      if (Link.is<NotKnownLatest>()) {
124
35.2M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
35.2M
        if (NKL.is<Previous>())
126
1.22M
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
34.0M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
34.0M
                               NKL.get<UninitializedLatest>()),
131
34.0M
                           const_cast<decl_type *>(D));
132
34.0M
      }
133
134
109M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
110M
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::getPrevious(clang::TypedefNameDecl const*) const
Line
Count
Source
122
1.88M
    decl_type *getPrevious(const decl_type *D) const {
123
1.88M
      if (Link.is<NotKnownLatest>()) {
124
474k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
474k
        if (NKL.is<Previous>())
126
26.5k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
447k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
447k
                               NKL.get<UninitializedLatest>()),
131
447k
                           const_cast<decl_type *>(D));
132
447k
      }
133
134
1.85M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
1.88M
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::getPrevious(clang::TagDecl const*) const
Line
Count
Source
122
333M
    decl_type *getPrevious(const decl_type *D) const {
123
333M
      if (Link.is<NotKnownLatest>()) {
124
6.78M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
6.78M
        if (NKL.is<Previous>())
126
6.78M
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
0
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
0
                               NKL.get<UninitializedLatest>()),
131
0
                           const_cast<decl_type *>(D));
132
0
      }
133
134
326M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
333M
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::getPrevious(clang::UsingShadowDecl const*) const
Line
Count
Source
122
622k
    decl_type *getPrevious(const decl_type *D) const {
123
622k
      if (Link.is<NotKnownLatest>()) {
124
11.6k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
11.6k
        if (NKL.is<Previous>())
126
11.5k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
25
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
25
                               NKL.get<UninitializedLatest>()),
131
25
                           const_cast<decl_type *>(D));
132
25
      }
133
134
610k
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
622k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::getPrevious(clang::ObjCProtocolDecl const*) const
Line
Count
Source
122
250k
    decl_type *getPrevious(const decl_type *D) const {
123
250k
      if (Link.is<NotKnownLatest>()) {
124
14.7k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
14.7k
        if (NKL.is<Previous>())
126
14.7k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
0
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
0
                               NKL.get<UninitializedLatest>()),
131
0
                           const_cast<decl_type *>(D));
132
0
      }
133
134
235k
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
250k
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::getPrevious(clang::ObjCInterfaceDecl const*) const
Line
Count
Source
122
1.13M
    decl_type *getPrevious(const decl_type *D) const {
123
1.13M
      if (Link.is<NotKnownLatest>()) {
124
344k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
344k
        if (NKL.is<Previous>())
126
344k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
0
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
0
                               NKL.get<UninitializedLatest>()),
131
0
                           const_cast<decl_type *>(D));
132
0
      }
133
134
791k
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
1.13M
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::getPrevious(clang::RedeclarableTemplateDecl const*) const
Line
Count
Source
122
19.4M
    decl_type *getPrevious(const decl_type *D) const {
123
19.4M
      if (Link.is<NotKnownLatest>()) {
124
1.13M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
1.13M
        if (NKL.is<Previous>())
126
458k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
680k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
680k
                               NKL.get<UninitializedLatest>()),
131
680k
                           const_cast<decl_type *>(D));
132
680k
      }
133
134
18.9M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
19.4M
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::getPrevious(clang::NamespaceDecl const*) const
Line
Count
Source
122
23.2M
    decl_type *getPrevious(const decl_type *D) const {
123
23.2M
      if (Link.is<NotKnownLatest>()) {
124
16.8M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
16.8M
        if (NKL.is<Previous>())
126
16.8M
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
0
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
0
                               NKL.get<UninitializedLatest>()),
131
0
                           const_cast<decl_type *>(D));
132
0
      }
133
134
6.44M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
23.2M
    }
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::getPrevious(clang::NamespaceAliasDecl const*) const
Line
Count
Source
122
233
    decl_type *getPrevious(const decl_type *D) const {
123
233
      if (Link.is<NotKnownLatest>()) {
124
79
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
79
        if (NKL.is<Previous>())
126
14
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
65
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
65
                               NKL.get<UninitializedLatest>()),
131
65
                           const_cast<decl_type *>(D));
132
65
      }
133
134
219
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
233
    }
136
137
2.00M
    void setPrevious(decl_type *D) {
138
2.00M
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
2.00M
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::setPrevious(clang::VarDecl*)
Line
Count
Source
137
7.64k
    void setPrevious(decl_type *D) {
138
7.64k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
7.64k
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::setPrevious(clang::FunctionDecl*)
Line
Count
Source
137
111k
    void setPrevious(decl_type *D) {
138
111k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
111k
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::setPrevious(clang::NamespaceDecl*)
Line
Count
Source
137
705k
    void setPrevious(decl_type *D) {
138
705k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
705k
    }
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::setPrevious(clang::NamespaceAliasDecl*)
Line
Count
Source
137
3
    void setPrevious(decl_type *D) {
138
3
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
3
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::setPrevious(clang::ObjCInterfaceDecl*)
Line
Count
Source
137
42.1k
    void setPrevious(decl_type *D) {
138
42.1k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
42.1k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::setPrevious(clang::ObjCProtocolDecl*)
Line
Count
Source
137
647
    void setPrevious(decl_type *D) {
138
647
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
647
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::setPrevious(clang::RedeclarableTemplateDecl*)
Line
Count
Source
137
119k
    void setPrevious(decl_type *D) {
138
119k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
119k
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::setPrevious(clang::TagDecl*)
Line
Count
Source
137
996k
    void setPrevious(decl_type *D) {
138
996k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
996k
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::setPrevious(clang::TypedefNameDecl*)
Line
Count
Source
137
18.1k
    void setPrevious(decl_type *D) {
138
18.1k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
18.1k
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::setPrevious(clang::UsingShadowDecl*)
Line
Count
Source
137
181
    void setPrevious(decl_type *D) {
138
181
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
0
      Link = Previous(D);
140
181
    }
Unexecuted instantiation: clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::setPrevious(clang::TranslationUnitDecl*)
141
142
13.7M
    void setLatest(decl_type *D) {
143
13.7M
      assert(isFirst() && "decl became canonical unexpectedly");
144
13.7M
      if (Link.is<NotKnownLatest>()) {
145
10.7M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
10.7M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
10.7M
                               NKL.get<UninitializedLatest>()),
148
10.7M
                           D);
149
10.7M
      } else {
150
3.00M
        auto Latest = Link.get<KnownLatest>();
151
3.00M
        Latest.set(D);
152
3.00M
        Link = Latest;
153
3.00M
      }
154
13.7M
    }
clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::setLatest(clang::TranslationUnitDecl*)
Line
Count
Source
142
47
    void setLatest(decl_type *D) {
143
47
      assert(isFirst() && "decl became canonical unexpectedly");
144
47
      if (Link.is<NotKnownLatest>()) {
145
0
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
0
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
0
                               NKL.get<UninitializedLatest>()),
148
0
                           D);
149
47
      } else {
150
47
        auto Latest = Link.get<KnownLatest>();
151
47
        Latest.set(D);
152
47
        Link = Latest;
153
47
      }
154
47
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::setLatest(clang::FunctionDecl*)
Line
Count
Source
142
1.03M
    void setLatest(decl_type *D) {
143
1.03M
      assert(isFirst() && "decl became canonical unexpectedly");
144
1.03M
      if (Link.is<NotKnownLatest>()) {
145
742k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
742k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
742k
                               NKL.get<UninitializedLatest>()),
148
742k
                           D);
149
742k
      } else {
150
293k
        auto Latest = Link.get<KnownLatest>();
151
293k
        Latest.set(D);
152
293k
        Link = Latest;
153
293k
      }
154
1.03M
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::setLatest(clang::RedeclarableTemplateDecl*)
Line
Count
Source
142
718k
    void setLatest(decl_type *D) {
143
718k
      assert(isFirst() && "decl became canonical unexpectedly");
144
718k
      if (Link.is<NotKnownLatest>()) {
145
612k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
612k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
612k
                               NKL.get<UninitializedLatest>()),
148
612k
                           D);
149
612k
      } else {
150
105k
        auto Latest = Link.get<KnownLatest>();
151
105k
        Latest.set(D);
152
105k
        Link = Latest;
153
105k
      }
154
718k
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::setLatest(clang::TagDecl*)
Line
Count
Source
142
8.56M
    void setLatest(decl_type *D) {
143
8.56M
      assert(isFirst() && "decl became canonical unexpectedly");
144
8.56M
      if (Link.is<NotKnownLatest>()) {
145
6.40M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
6.40M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
6.40M
                               NKL.get<UninitializedLatest>()),
148
6.40M
                           D);
149
6.40M
      } else {
150
2.16M
        auto Latest = Link.get<KnownLatest>();
151
2.16M
        Latest.set(D);
152
2.16M
        Link = Latest;
153
2.16M
      }
154
8.56M
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::setLatest(clang::NamespaceDecl*)
Line
Count
Source
142
988k
    void setLatest(decl_type *D) {
143
988k
      assert(isFirst() && "decl became canonical unexpectedly");
144
988k
      if (Link.is<NotKnownLatest>()) {
145
760k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
760k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
760k
                               NKL.get<UninitializedLatest>()),
148
760k
                           D);
149
760k
      } else {
150
228k
        auto Latest = Link.get<KnownLatest>();
151
228k
        Latest.set(D);
152
228k
        Link = Latest;
153
228k
      }
154
988k
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::setLatest(clang::ObjCInterfaceDecl*)
Line
Count
Source
142
301k
    void setLatest(decl_type *D) {
143
301k
      assert(isFirst() && "decl became canonical unexpectedly");
144
301k
      if (Link.is<NotKnownLatest>()) {
145
169k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
169k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
169k
                               NKL.get<UninitializedLatest>()),
148
169k
                           D);
149
169k
      } else {
150
132k
        auto Latest = Link.get<KnownLatest>();
151
132k
        Latest.set(D);
152
132k
        Link = Latest;
153
132k
      }
154
301k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::setLatest(clang::ObjCProtocolDecl*)
Line
Count
Source
142
28.0k
    void setLatest(decl_type *D) {
143
28.0k
      assert(isFirst() && "decl became canonical unexpectedly");
144
28.0k
      if (Link.is<NotKnownLatest>()) {
145
20.9k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
20.9k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
20.9k
                               NKL.get<UninitializedLatest>()),
148
20.9k
                           D);
149
20.9k
      } else {
150
7.06k
        auto Latest = Link.get<KnownLatest>();
151
7.06k
        Latest.set(D);
152
7.06k
        Link = Latest;
153
7.06k
      }
154
28.0k
    }
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::setLatest(clang::NamespaceAliasDecl*)
Line
Count
Source
142
32
    void setLatest(decl_type *D) {
143
32
      assert(isFirst() && "decl became canonical unexpectedly");
144
32
      if (Link.is<NotKnownLatest>()) {
145
17
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
17
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
17
                               NKL.get<UninitializedLatest>()),
148
17
                           D);
149
17
      } else {
150
15
        auto Latest = Link.get<KnownLatest>();
151
15
        Latest.set(D);
152
15
        Link = Latest;
153
15
      }
154
32
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::setLatest(clang::TypedefNameDecl*)
Line
Count
Source
142
261k
    void setLatest(decl_type *D) {
143
261k
      assert(isFirst() && "decl became canonical unexpectedly");
144
261k
      if (Link.is<NotKnownLatest>()) {
145
253k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
253k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
253k
                               NKL.get<UninitializedLatest>()),
148
253k
                           D);
149
253k
      } else {
150
7.95k
        auto Latest = Link.get<KnownLatest>();
151
7.95k
        Latest.set(D);
152
7.95k
        Link = Latest;
153
7.95k
      }
154
261k
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::setLatest(clang::UsingShadowDecl*)
Line
Count
Source
142
186k
    void setLatest(decl_type *D) {
143
186k
      assert(isFirst() && "decl became canonical unexpectedly");
144
186k
      if (Link.is<NotKnownLatest>()) {
145
182k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
182k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
182k
                               NKL.get<UninitializedLatest>()),
148
182k
                           D);
149
182k
      } else {
150
3.54k
        auto Latest = Link.get<KnownLatest>();
151
3.54k
        Latest.set(D);
152
3.54k
        Link = Latest;
153
3.54k
      }
154
186k
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::setLatest(clang::VarDecl*)
Line
Count
Source
142
1.64M
    void setLatest(decl_type *D) {
143
1.64M
      assert(isFirst() && "decl became canonical unexpectedly");
144
1.64M
      if (Link.is<NotKnownLatest>()) {
145
1.58M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
1.58M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
1.58M
                               NKL.get<UninitializedLatest>()),
148
1.58M
                           D);
149
1.58M
      } else {
150
64.0k
        auto Latest = Link.get<KnownLatest>();
151
64.0k
        Latest.set(D);
152
64.0k
        Link = Latest;
153
64.0k
      }
154
1.64M
    }
155
156
487k
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
2
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
Unexecuted instantiation: clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::markIncomplete()
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
7.34k
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
2
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
Unexecuted instantiation: clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::markIncomplete()
clang::Redeclarable<clang::TagDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
12.1k
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
41
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
Unexecuted instantiation: clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::markIncomplete()
clang::Redeclarable<clang::FunctionDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
447k
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
clang::Redeclarable<clang::VarDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
26
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
19.8k
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
157
158
431k
    Decl *getLatestNotUpdated() const {
159
431k
      assert(isFirst() && "expected a canonical decl");
160
431k
      if (Link.is<NotKnownLatest>())
161
1.70k
        return nullptr;
162
430k
      return Link.get<KnownLatest>().getNotUpdated();
163
431k
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
2.18k
    Decl *getLatestNotUpdated() const {
159
2.18k
      assert(isFirst() && "expected a canonical decl");
160
2.18k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
2.18k
      return Link.get<KnownLatest>().getNotUpdated();
163
2.18k
    }
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
3
    Decl *getLatestNotUpdated() const {
159
3
      assert(isFirst() && "expected a canonical decl");
160
3
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
3
      return Link.get<KnownLatest>().getNotUpdated();
163
3
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
7.43k
    Decl *getLatestNotUpdated() const {
159
7.43k
      assert(isFirst() && "expected a canonical decl");
160
7.43k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
7.43k
      return Link.get<KnownLatest>().getNotUpdated();
163
7.43k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
2.01k
    Decl *getLatestNotUpdated() const {
159
2.01k
      assert(isFirst() && "expected a canonical decl");
160
2.01k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
2.01k
      return Link.get<KnownLatest>().getNotUpdated();
163
2.01k
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
367k
    Decl *getLatestNotUpdated() const {
159
367k
      assert(isFirst() && "expected a canonical decl");
160
367k
      if (Link.is<NotKnownLatest>())
161
9
        return nullptr;
162
367k
      return Link.get<KnownLatest>().getNotUpdated();
163
367k
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
47.3k
    Decl *getLatestNotUpdated() const {
159
47.3k
      assert(isFirst() && "expected a canonical decl");
160
47.3k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
47.3k
      return Link.get<KnownLatest>().getNotUpdated();
163
47.3k
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
3.42k
    Decl *getLatestNotUpdated() const {
159
3.42k
      assert(isFirst() && "expected a canonical decl");
160
3.42k
      if (Link.is<NotKnownLatest>())
161
1.70k
        return nullptr;
162
1.72k
      return Link.get<KnownLatest>().getNotUpdated();
163
3.42k
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
24
    Decl *getLatestNotUpdated() const {
159
24
      assert(isFirst() && "expected a canonical decl");
160
24
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
24
      return Link.get<KnownLatest>().getNotUpdated();
163
24
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
1.35k
    Decl *getLatestNotUpdated() const {
159
1.35k
      assert(isFirst() && "expected a canonical decl");
160
1.35k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
1.35k
      return Link.get<KnownLatest>().getNotUpdated();
163
1.35k
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
867
    Decl *getLatestNotUpdated() const {
159
867
      assert(isFirst() && "expected a canonical decl");
160
867
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
867
      return Link.get<KnownLatest>().getNotUpdated();
163
867
    }
Unexecuted instantiation: clang::Redeclarable<clang::TranslationUnitDecl>::DeclLink::getLatestNotUpdated() const
164
  };
165
166
3.69M
  static DeclLink PreviousDeclLink(decl_type *D) {
167
3.69M
    return DeclLink(DeclLink::PreviousLink, D);
168
3.69M
  }
clang::Redeclarable<clang::TranslationUnitDecl>::PreviousDeclLink(clang::TranslationUnitDecl*)
Line
Count
Source
166
45
  static DeclLink PreviousDeclLink(decl_type *D) {
167
45
    return DeclLink(DeclLink::PreviousLink, D);
168
45
  }
clang::Redeclarable<clang::FunctionDecl>::PreviousDeclLink(clang::FunctionDecl*)
Line
Count
Source
166
404k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
404k
    return DeclLink(DeclLink::PreviousLink, D);
168
404k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::PreviousDeclLink(clang::RedeclarableTemplateDecl*)
Line
Count
Source
166
223k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
223k
    return DeclLink(DeclLink::PreviousLink, D);
168
223k
  }
clang::Redeclarable<clang::TagDecl>::PreviousDeclLink(clang::TagDecl*)
Line
Count
Source
166
1.87M
  static DeclLink PreviousDeclLink(decl_type *D) {
167
1.87M
    return DeclLink(DeclLink::PreviousLink, D);
168
1.87M
  }
clang::Redeclarable<clang::NamespaceDecl>::PreviousDeclLink(clang::NamespaceDecl*)
Line
Count
Source
166
923k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
923k
    return DeclLink(DeclLink::PreviousLink, D);
168
923k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::PreviousDeclLink(clang::ObjCInterfaceDecl*)
Line
Count
Source
166
166k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
166k
    return DeclLink(DeclLink::PreviousLink, D);
168
166k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::PreviousDeclLink(clang::ObjCProtocolDecl*)
Line
Count
Source
166
5.67k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
5.67k
    return DeclLink(DeclLink::PreviousLink, D);
168
5.67k
  }
clang::Redeclarable<clang::TypedefNameDecl>::PreviousDeclLink(clang::TypedefNameDecl*)
Line
Count
Source
166
24.4k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
24.4k
    return DeclLink(DeclLink::PreviousLink, D);
168
24.4k
  }
clang::Redeclarable<clang::VarDecl>::PreviousDeclLink(clang::VarDecl*)
Line
Count
Source
166
70.8k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
70.8k
    return DeclLink(DeclLink::PreviousLink, D);
168
70.8k
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::PreviousDeclLink(clang::NamespaceAliasDecl*)
Line
Count
Source
166
15
  static DeclLink PreviousDeclLink(decl_type *D) {
167
15
    return DeclLink(DeclLink::PreviousLink, D);
168
15
  }
clang::Redeclarable<clang::UsingShadowDecl>::PreviousDeclLink(clang::UsingShadowDecl*)
Line
Count
Source
166
3.70k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
3.70k
    return DeclLink(DeclLink::PreviousLink, D);
168
3.70k
  }
169
170
158M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
158M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
158M
  }
clang::Redeclarable<clang::TypedefNameDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
4.23M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
4.23M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
4.23M
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
360
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
360
    return DeclLink(DeclLink::LatestLink, Ctx);
172
360
  }
clang::Redeclarable<clang::TranslationUnitDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
103k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
103k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
103k
  }
clang::Redeclarable<clang::VarDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
107M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
107M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
107M
  }
clang::Redeclarable<clang::FunctionDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
36.1M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
36.1M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
36.1M
  }
clang::Redeclarable<clang::TagDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
7.27M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
7.27M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
7.27M
  }
clang::Redeclarable<clang::NamespaceDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
978k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
978k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
978k
  }
clang::Redeclarable<clang::UsingShadowDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
195k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
195k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
195k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
293k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
293k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
293k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
26.0k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
26.0k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
26.0k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
1.72M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
1.72M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
1.72M
  }
173
174
  /// Points to the next redeclaration in the chain.
175
  ///
176
  /// If isFirst() is false, this is a link to the previous declaration
177
  /// of this same Decl. If isFirst() is true, this is the first
178
  /// declaration and Link points to the latest declaration. For example:
179
  ///
180
  ///  #1 int f(int x, int y = 1); // <pointer to #3, true>
181
  ///  #2 int f(int x = 0, int y); // <pointer to #1, false>
182
  ///  #3 int f(int x, int y) { return x + y; } // <pointer to #2, false>
183
  ///
184
  /// If there is only one declaration, it is <pointer to self, true>
185
  DeclLink RedeclLink;
186
187
  decl_type *First;
188
189
878M
  decl_type *getNextRedeclaration() const {
190
878M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
878M
  }
clang::Redeclarable<clang::TranslationUnitDecl>::getNextRedeclaration() const
Line
Count
Source
189
115M
  decl_type *getNextRedeclaration() const {
190
115M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
115M
  }
clang::Redeclarable<clang::VarDecl>::getNextRedeclaration() const
Line
Count
Source
189
272M
  decl_type *getNextRedeclaration() const {
190
272M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
272M
  }
clang::Redeclarable<clang::FunctionDecl>::getNextRedeclaration() const
Line
Count
Source
189
110M
  decl_type *getNextRedeclaration() const {
190
110M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
110M
  }
clang::Redeclarable<clang::TypedefNameDecl>::getNextRedeclaration() const
Line
Count
Source
189
1.88M
  decl_type *getNextRedeclaration() const {
190
1.88M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
1.88M
  }
clang::Redeclarable<clang::TagDecl>::getNextRedeclaration() const
Line
Count
Source
189
333M
  decl_type *getNextRedeclaration() const {
190
333M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
333M
  }
clang::Redeclarable<clang::UsingShadowDecl>::getNextRedeclaration() const
Line
Count
Source
189
622k
  decl_type *getNextRedeclaration() const {
190
622k
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
622k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getNextRedeclaration() const
Line
Count
Source
189
250k
  decl_type *getNextRedeclaration() const {
190
250k
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
250k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getNextRedeclaration() const
Line
Count
Source
189
1.13M
  decl_type *getNextRedeclaration() const {
190
1.13M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
1.13M
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getNextRedeclaration() const
Line
Count
Source
189
19.4M
  decl_type *getNextRedeclaration() const {
190
19.4M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
19.4M
  }
clang::Redeclarable<clang::NamespaceDecl>::getNextRedeclaration() const
Line
Count
Source
189
23.2M
  decl_type *getNextRedeclaration() const {
190
23.2M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
23.2M
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getNextRedeclaration() const
Line
Count
Source
189
233
  decl_type *getNextRedeclaration() const {
190
233
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
233
  }
192
193
public:
194
  friend class ASTDeclReader;
195
  friend class ASTDeclWriter;
196
  friend class IncrementalParser;
197
198
  Redeclarable(const ASTContext &Ctx)
199
      : RedeclLink(LatestDeclLink(Ctx)),
200
158M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::TypedefNameDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
4.23M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::TranslationUnitDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
103k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::VarDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
107M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::FunctionDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
36.1M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::TagDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
7.27M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::NamespaceAliasDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
360
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::NamespaceDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
978k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::UsingShadowDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
195k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::ObjCInterfaceDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
293k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::ObjCProtocolDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
26.0k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::RedeclarableTemplateDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
200
1.72M
        First(static_cast<decl_type *>(this)) {}
201
202
  /// Return the previous declaration of this declaration or NULL if this
203
  /// is the first declaration.
204
87.3M
  decl_type *getPreviousDecl() {
205
87.3M
    if (!RedeclLink.isFirst())
206
4.12M
      return getNextRedeclaration();
207
83.2M
    return nullptr;
208
87.3M
  }
clang::Redeclarable<clang::TranslationUnitDecl>::getPreviousDecl()
Line
Count
Source
204
49.6k
  decl_type *getPreviousDecl() {
205
49.6k
    if (!RedeclLink.isFirst())
206
21
      return getNextRedeclaration();
207
49.6k
    return nullptr;
208
49.6k
  }
clang::Redeclarable<clang::VarDecl>::getPreviousDecl()
Line
Count
Source
204
11.1M
  decl_type *getPreviousDecl() {
205
11.1M
    if (!RedeclLink.isFirst())
206
26.5k
      return getNextRedeclaration();
207
11.0M
    return nullptr;
208
11.1M
  }
clang::Redeclarable<clang::FunctionDecl>::getPreviousDecl()
Line
Count
Source
204
59.1M
  decl_type *getPreviousDecl() {
205
59.1M
    if (!RedeclLink.isFirst())
206
333k
      return getNextRedeclaration();
207
58.7M
    return nullptr;
208
59.1M
  }
clang::Redeclarable<clang::TypedefNameDecl>::getPreviousDecl()
Line
Count
Source
204
3.81M
  decl_type *getPreviousDecl() {
205
3.81M
    if (!RedeclLink.isFirst())
206
18.5k
      return getNextRedeclaration();
207
3.79M
    return nullptr;
208
3.81M
  }
clang::Redeclarable<clang::TagDecl>::getPreviousDecl()
Line
Count
Source
204
9.34M
  decl_type *getPreviousDecl() {
205
9.34M
    if (!RedeclLink.isFirst())
206
2.91M
      return getNextRedeclaration();
207
6.43M
    return nullptr;
208
9.34M
  }
clang::Redeclarable<clang::UsingShadowDecl>::getPreviousDecl()
Line
Count
Source
204
174k
  decl_type *getPreviousDecl() {
205
174k
    if (!RedeclLink.isFirst())
206
4.10k
      return getNextRedeclaration();
207
170k
    return nullptr;
208
174k
  }
clang::Redeclarable<clang::NamespaceDecl>::getPreviousDecl()
Line
Count
Source
204
328k
  decl_type *getPreviousDecl() {
205
328k
    if (!RedeclLink.isFirst())
206
268k
      return getNextRedeclaration();
207
60.7k
    return nullptr;
208
328k
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getPreviousDecl()
Line
Count
Source
204
340
  decl_type *getPreviousDecl() {
205
340
    if (!RedeclLink.isFirst())
206
12
      return getNextRedeclaration();
207
328
    return nullptr;
208
340
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getPreviousDecl()
Line
Count
Source
204
344k
  decl_type *getPreviousDecl() {
205
344k
    if (!RedeclLink.isFirst())
206
204k
      return getNextRedeclaration();
207
139k
    return nullptr;
208
344k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getPreviousDecl()
Line
Count
Source
204
29.4k
  decl_type *getPreviousDecl() {
205
29.4k
    if (!RedeclLink.isFirst())
206
8.02k
      return getNextRedeclaration();
207
21.3k
    return nullptr;
208
29.4k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getPreviousDecl()
Line
Count
Source
204
3.01M
  decl_type *getPreviousDecl() {
205
3.01M
    if (!RedeclLink.isFirst())
206
343k
      return getNextRedeclaration();
207
2.66M
    return nullptr;
208
3.01M
  }
209
4.08M
  const decl_type *getPreviousDecl() const {
210
4.08M
    return const_cast<decl_type *>(
211
4.08M
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
4.08M
  }
clang::Redeclarable<clang::VarDecl>::getPreviousDecl() const
Line
Count
Source
209
1.21M
  const decl_type *getPreviousDecl() const {
210
1.21M
    return const_cast<decl_type *>(
211
1.21M
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
1.21M
  }
clang::Redeclarable<clang::FunctionDecl>::getPreviousDecl() const
Line
Count
Source
209
1.78M
  const decl_type *getPreviousDecl() const {
210
1.78M
    return const_cast<decl_type *>(
211
1.78M
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
1.78M
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getPreviousDecl() const
Line
Count
Source
209
32.7k
  const decl_type *getPreviousDecl() const {
210
32.7k
    return const_cast<decl_type *>(
211
32.7k
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
32.7k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getPreviousDecl() const
Line
Count
Source
209
1.04M
  const decl_type *getPreviousDecl() const {
210
1.04M
    return const_cast<decl_type *>(
211
1.04M
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
1.04M
  }
clang::Redeclarable<clang::NamespaceDecl>::getPreviousDecl() const
Line
Count
Source
209
169
  const decl_type *getPreviousDecl() const {
210
169
    return const_cast<decl_type *>(
211
169
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
169
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getPreviousDecl() const
Line
Count
Source
209
5
  const decl_type *getPreviousDecl() const {
210
5
    return const_cast<decl_type *>(
211
5
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
5
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getPreviousDecl() const
Line
Count
Source
209
26
  const decl_type *getPreviousDecl() const {
210
26
    return const_cast<decl_type *>(
211
26
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
26
  }
clang::Redeclarable<clang::TagDecl>::getPreviousDecl() const
Line
Count
Source
209
3.92k
  const decl_type *getPreviousDecl() const {
210
3.92k
    return const_cast<decl_type *>(
211
3.92k
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
3.92k
  }
clang::Redeclarable<clang::TypedefNameDecl>::getPreviousDecl() const
Line
Count
Source
209
3.15k
  const decl_type *getPreviousDecl() const {
210
3.15k
    return const_cast<decl_type *>(
211
3.15k
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
3.15k
  }
clang::Redeclarable<clang::UsingShadowDecl>::getPreviousDecl() const
Line
Count
Source
209
64
  const decl_type *getPreviousDecl() const {
210
64
    return const_cast<decl_type *>(
211
64
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
64
  }
clang::Redeclarable<clang::TranslationUnitDecl>::getPreviousDecl() const
Line
Count
Source
209
488
  const decl_type *getPreviousDecl() const {
210
488
    return const_cast<decl_type *>(
211
488
                 static_cast<const decl_type*>(this))->getPreviousDecl();
212
488
  }
213
214
  /// Return the first declaration of this declaration or itself if this
215
  /// is the only declaration.
216
4.09G
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::TranslationUnitDecl>::getFirstDecl()
Line
Count
Source
216
1.96G
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::VarDecl>::getFirstDecl()
Line
Count
Source
216
292M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::FunctionDecl>::getFirstDecl()
Line
Count
Source
216
1.26G
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::TypedefNameDecl>::getFirstDecl()
Line
Count
Source
216
130M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::TagDecl>::getFirstDecl()
Line
Count
Source
216
339M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::NamespaceAliasDecl>::getFirstDecl()
Line
Count
Source
216
429
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::UsingShadowDecl>::getFirstDecl()
Line
Count
Source
216
1.50M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getFirstDecl()
Line
Count
Source
216
90.4M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::NamespaceDecl>::getFirstDecl()
Line
Count
Source
216
7.02M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getFirstDecl()
Line
Count
Source
216
2.71M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::ObjCProtocolDecl>::getFirstDecl()
Line
Count
Source
216
312k
  decl_type *getFirstDecl() { return First; }
217
218
  /// Return the first declaration of this declaration or itself if this
219
  /// is the only declaration.
220
65.1M
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::TypedefNameDecl>::getFirstDecl() const
Line
Count
Source
220
155
  const decl_type *getFirstDecl() const { return First; }
Unexecuted instantiation: clang::Redeclarable<clang::NamespaceAliasDecl>::getFirstDecl() const
Unexecuted instantiation: clang::Redeclarable<clang::UsingShadowDecl>::getFirstDecl() const
clang::Redeclarable<clang::ObjCProtocolDecl>::getFirstDecl() const
Line
Count
Source
220
2.20k
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getFirstDecl() const
Line
Count
Source
220
56.6k
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::VarDecl>::getFirstDecl() const
Line
Count
Source
220
19.2M
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::FunctionDecl>::getFirstDecl() const
Line
Count
Source
220
40.0M
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::TagDecl>::getFirstDecl() const
Line
Count
Source
220
268k
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getFirstDecl() const
Line
Count
Source
220
5.48M
  const decl_type *getFirstDecl() const { return First; }
221
222
  /// True if this is the first declaration in its redeclaration chain.
223
447M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::TagDecl>::isFirstDecl() const
Line
Count
Source
223
36.1M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::VarDecl>::isFirstDecl() const
Line
Count
Source
223
33.9M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::FunctionDecl>::isFirstDecl() const
Line
Count
Source
223
50.1M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::NamespaceDecl>::isFirstDecl() const
Line
Count
Source
223
326M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::ObjCInterfaceDecl>::isFirstDecl() const
Line
Count
Source
223
155k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::ObjCProtocolDecl>::isFirstDecl() const
Line
Count
Source
223
25.3k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::TypedefNameDecl>::isFirstDecl() const
Line
Count
Source
223
232k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::NamespaceAliasDecl>::isFirstDecl() const
Line
Count
Source
223
16
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::UsingShadowDecl>::isFirstDecl() const
Line
Count
Source
223
11.3k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::isFirstDecl() const
Line
Count
Source
223
607k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
224
225
  /// Returns the most recent (re)declaration of this declaration.
226
625M
  decl_type *getMostRecentDecl() {
227
625M
    return getFirstDecl()->getNextRedeclaration();
228
625M
  }
clang::Redeclarable<clang::TranslationUnitDecl>::getMostRecentDecl()
Line
Count
Source
226
115M
  decl_type *getMostRecentDecl() {
227
115M
    return getFirstDecl()->getNextRedeclaration();
228
115M
  }
clang::Redeclarable<clang::VarDecl>::getMostRecentDecl()
Line
Count
Source
226
114M
  decl_type *getMostRecentDecl() {
227
114M
    return getFirstDecl()->getNextRedeclaration();
228
114M
  }
clang::Redeclarable<clang::FunctionDecl>::getMostRecentDecl()
Line
Count
Source
226
79.1M
  decl_type *getMostRecentDecl() {
227
79.1M
    return getFirstDecl()->getNextRedeclaration();
228
79.1M
  }
clang::Redeclarable<clang::TypedefNameDecl>::getMostRecentDecl()
Line
Count
Source
226
1.48M
  decl_type *getMostRecentDecl() {
227
1.48M
    return getFirstDecl()->getNextRedeclaration();
228
1.48M
  }
clang::Redeclarable<clang::TagDecl>::getMostRecentDecl()
Line
Count
Source
226
293M
  decl_type *getMostRecentDecl() {
227
293M
    return getFirstDecl()->getNextRedeclaration();
228
293M
  }
clang::Redeclarable<clang::UsingShadowDecl>::getMostRecentDecl()
Line
Count
Source
226
420k
  decl_type *getMostRecentDecl() {
227
420k
    return getFirstDecl()->getNextRedeclaration();
228
420k
  }
clang::Redeclarable<clang::NamespaceDecl>::getMostRecentDecl()
Line
Count
Source
226
6.08M
  decl_type *getMostRecentDecl() {
227
6.08M
    return getFirstDecl()->getNextRedeclaration();
228
6.08M
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getMostRecentDecl()
Line
Count
Source
226
125
  decl_type *getMostRecentDecl() {
227
125
    return getFirstDecl()->getNextRedeclaration();
228
125
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getMostRecentDecl()
Line
Count
Source
226
527k
  decl_type *getMostRecentDecl() {
227
527k
    return getFirstDecl()->getNextRedeclaration();
228
527k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getMostRecentDecl()
Line
Count
Source
226
209k
  decl_type *getMostRecentDecl() {
227
209k
    return getFirstDecl()->getNextRedeclaration();
228
209k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getMostRecentDecl()
Line
Count
Source
226
12.4M
  decl_type *getMostRecentDecl() {
227
12.4M
    return getFirstDecl()->getNextRedeclaration();
228
12.4M
  }
229
230
  /// Returns the most recent (re)declaration of this declaration.
231
6.41M
  const decl_type *getMostRecentDecl() const {
232
6.41M
    return getFirstDecl()->getNextRedeclaration();
233
6.41M
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getMostRecentDecl() const
Line
Count
Source
231
1.39k
  const decl_type *getMostRecentDecl() const {
232
1.39k
    return getFirstDecl()->getNextRedeclaration();
233
1.39k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getMostRecentDecl() const
Line
Count
Source
231
56.6k
  const decl_type *getMostRecentDecl() const {
232
56.6k
    return getFirstDecl()->getNextRedeclaration();
233
56.6k
  }
clang::Redeclarable<clang::FunctionDecl>::getMostRecentDecl() const
Line
Count
Source
231
925k
  const decl_type *getMostRecentDecl() const {
232
925k
    return getFirstDecl()->getNextRedeclaration();
233
925k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getMostRecentDecl() const
Line
Count
Source
231
5.43M
  const decl_type *getMostRecentDecl() const {
232
5.43M
    return getFirstDecl()->getNextRedeclaration();
233
5.43M
  }
clang::Redeclarable<clang::VarDecl>::getMostRecentDecl() const
Line
Count
Source
231
1.16k
  const decl_type *getMostRecentDecl() const {
232
1.16k
    return getFirstDecl()->getNextRedeclaration();
233
1.16k
  }
clang::Redeclarable<clang::TagDecl>::getMostRecentDecl() const
Line
Count
Source
231
170
  const decl_type *getMostRecentDecl() const {
232
170
    return getFirstDecl()->getNextRedeclaration();
233
170
  }
234
235
  /// Set the previous declaration. If PrevDecl is NULL, set this as the
236
  /// first and only declaration.
237
  void setPreviousDecl(decl_type *PrevDecl);
238
239
  /// Iterates through all the redeclarations of the same decl.
240
  class redecl_iterator {
241
    /// Current - The current declaration.
242
    decl_type *Current = nullptr;
243
    decl_type *Starter;
244
    bool PassedFirst = false;
245
246
  public:
247
    using value_type = decl_type *;
248
    using reference = decl_type *;
249
    using pointer = decl_type *;
250
    using iterator_category = std::forward_iterator_tag;
251
    using difference_type = std::ptrdiff_t;
252
253
281M
    redecl_iterator() = default;
clang::Redeclarable<clang::VarDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
253
53.6M
    redecl_iterator() = default;
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
253
34.0M
    redecl_iterator() = default;
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
253
74.0k
    redecl_iterator() = default;
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
253
17.9k
    redecl_iterator() = default;
clang::Redeclarable<clang::TagDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
253
194M
    redecl_iterator() = default;
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
253
949
    redecl_iterator() = default;
254
281M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::VarDecl>::redecl_iterator::redecl_iterator(clang::VarDecl*)
Line
Count
Source
254
53.6M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::redecl_iterator(clang::FunctionDecl*)
Line
Count
Source
254
34.0M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::redecl_iterator(clang::ObjCInterfaceDecl*)
Line
Count
Source
254
74.0k
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::redecl_iterator(clang::ObjCProtocolDecl*)
Line
Count
Source
254
17.9k
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::TagDecl>::redecl_iterator::redecl_iterator(clang::TagDecl*)
Line
Count
Source
254
194M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::redecl_iterator(clang::UsingShadowDecl*)
Line
Count
Source
254
949
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
255
256
300M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::VarDecl>::redecl_iterator::operator*() const
Line
Count
Source
256
60.6M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::operator*() const
Line
Count
Source
256
35.2M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::operator*() const
Line
Count
Source
256
107k
    reference operator*() const { return Current; }
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::operator*() const
Line
Count
Source
256
22.7k
    reference operator*() const { return Current; }
clang::Redeclarable<clang::TagDecl>::redecl_iterator::operator*() const
Line
Count
Source
256
204M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::operator*() const
Line
Count
Source
256
957
    reference operator*() const { return Current; }
257
    pointer operator->() const { return Current; }
258
259
81.2M
    redecl_iterator& operator++() {
260
81.2M
      assert(Current && "Advancing while iterator has reached end");
261
      // Sanity check to avoid infinite loop on invalid redecl chain.
262
81.2M
      if (Current->isFirstDecl()) {
263
74.1M
        if (PassedFirst) {
264
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
265
0
          Current = nullptr;
266
0
          return *this;
267
0
        }
268
74.1M
        PassedFirst = true;
269
74.1M
      }
270
271
      // Get either previous decl or latest decl.
272
81.2M
      decl_type *Next = Current->getNextRedeclaration();
273
81.2M
      Current = (Next != Starter) ? 
Next18.5M
:
nullptr62.7M
;
274
81.2M
      return *this;
275
81.2M
    }
clang::Redeclarable<clang::VarDecl>::redecl_iterator::operator++()
Line
Count
Source
259
31.3M
    redecl_iterator& operator++() {
260
31.3M
      assert(Current && "Advancing while iterator has reached end");
261
      // Sanity check to avoid infinite loop on invalid redecl chain.
262
31.3M
      if (Current->isFirstDecl()) {
263
27.6M
        if (PassedFirst) {
264
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
265
0
          Current = nullptr;
266
0
          return *this;
267
0
        }
268
27.6M
        PassedFirst = true;
269
27.6M
      }
270
271
      // Get either previous decl or latest decl.
272
31.3M
      decl_type *Next = Current->getNextRedeclaration();
273
31.3M
      Current = (Next != Starter) ? 
Next6.99M
:
nullptr24.3M
;
274
31.3M
      return *this;
275
31.3M
    }
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::operator++()
Line
Count
Source
259
17.6M
    redecl_iterator& operator++() {
260
17.6M
      assert(Current && "Advancing while iterator has reached end");
261
      // Sanity check to avoid infinite loop on invalid redecl chain.
262
17.6M
      if (Current->isFirstDecl()) {
263
16.9M
        if (PassedFirst) {
264
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
265
0
          Current = nullptr;
266
0
          return *this;
267
0
        }
268
16.9M
        PassedFirst = true;
269
16.9M
      }
270
271
      // Get either previous decl or latest decl.
272
17.6M
      decl_type *Next = Current->getNextRedeclaration();
273
17.6M
      Current = (Next != Starter) ? 
Next1.24M
:
nullptr16.4M
;
274
17.6M
      return *this;
275
17.6M
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::operator++()
Line
Count
Source
259
107k
    redecl_iterator& operator++() {
260
107k
      assert(Current && "Advancing while iterator has reached end");
261
      // Sanity check to avoid infinite loop on invalid redecl chain.
262
107k
      if (Current->isFirstDecl()) {
263
74.0k
        if (PassedFirst) {
264
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
265
0
          Current = nullptr;
266
0
          return *this;
267
0
        }
268
74.0k
        PassedFirst = true;
269
74.0k
      }
270
271
      // Get either previous decl or latest decl.
272
107k
      decl_type *Next = Current->getNextRedeclaration();
273
107k
      Current = (Next != Starter) ? 
Next33.6k
:
nullptr74.0k
;
274
107k
      return *this;
275
107k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::operator++()
Line
Count
Source
259
22.7k
    redecl_iterator& operator++() {
260
22.7k
      assert(Current && "Advancing while iterator has reached end");
261
      // Sanity check to avoid infinite loop on invalid redecl chain.
262
22.7k
      if (Current->isFirstDecl()) {
263
17.9k
        if (PassedFirst) {
264
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
265
0
          Current = nullptr;
266
0
          return *this;
267
0
        }
268
17.9k
        PassedFirst = true;
269
17.9k
      }
270
271
      // Get either previous decl or latest decl.
272
22.7k
      decl_type *Next = Current->getNextRedeclaration();
273
22.7k
      Current = (Next != Starter) ? 
Next4.76k
:
nullptr17.9k
;
274
22.7k
      return *this;
275
22.7k
    }
clang::Redeclarable<clang::TagDecl>::redecl_iterator::operator++()
Line
Count
Source
259
32.1M
    redecl_iterator& operator++() {
260
32.1M
      assert(Current && "Advancing while iterator has reached end");
261
      // Sanity check to avoid infinite loop on invalid redecl chain.
262
32.1M
      if (Current->isFirstDecl()) {
263
29.4M
        if (PassedFirst) {
264
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
265
0
          Current = nullptr;
266
0
          return *this;
267
0
        }
268
29.4M
        PassedFirst = true;
269
29.4M
      }
270
271
      // Get either previous decl or latest decl.
272
32.1M
      decl_type *Next = Current->getNextRedeclaration();
273
32.1M
      Current = (Next != Starter) ? 
Next10.2M
:
nullptr21.9M
;
274
32.1M
      return *this;
275
32.1M
    }
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::operator++()
Line
Count
Source
259
957
    redecl_iterator& operator++() {
260
957
      assert(Current && "Advancing while iterator has reached end");
261
      // Sanity check to avoid infinite loop on invalid redecl chain.
262
957
      if (Current->isFirstDecl()) {
263
949
        if (PassedFirst) {
264
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
265
0
          Current = nullptr;
266
0
          return *this;
267
0
        }
268
949
        PassedFirst = true;
269
949
      }
270
271
      // Get either previous decl or latest decl.
272
957
      decl_type *Next = Current->getNextRedeclaration();
273
957
      Current = (Next != Starter) ? 
Next8
:
nullptr949
;
274
957
      return *this;
275
957
    }
276
277
    redecl_iterator operator++(int) {
278
      redecl_iterator tmp(*this);
279
      ++(*this);
280
      return tmp;
281
    }
282
283
11
    friend bool operator==(redecl_iterator x, redecl_iterator y) {
284
11
      return x.Current == y.Current;
285
11
    }
286
363M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
287
363M
      return x.Current != y.Current;
288
363M
    }
clang::operator!=(clang::Redeclarable<clang::VarDecl>::redecl_iterator, clang::Redeclarable<clang::VarDecl>::redecl_iterator)
Line
Count
Source
286
84.9M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
287
84.9M
      return x.Current != y.Current;
288
84.9M
    }
clang::operator!=(clang::Redeclarable<clang::FunctionDecl>::redecl_iterator, clang::Redeclarable<clang::FunctionDecl>::redecl_iterator)
Line
Count
Source
286
51.6M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
287
51.6M
      return x.Current != y.Current;
288
51.6M
    }
clang::operator!=(clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator, clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator)
Line
Count
Source
286
181k
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
287
181k
      return x.Current != y.Current;
288
181k
    }
clang::operator!=(clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator, clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator)
Line
Count
Source
286
40.7k
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
287
40.7k
      return x.Current != y.Current;
288
40.7k
    }
clang::operator!=(clang::Redeclarable<clang::TagDecl>::redecl_iterator, clang::Redeclarable<clang::TagDecl>::redecl_iterator)
Line
Count
Source
286
226M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
287
226M
      return x.Current != y.Current;
288
226M
    }
clang::operator!=(clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator, clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator)
Line
Count
Source
286
1.90k
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
287
1.90k
      return x.Current != y.Current;
288
1.90k
    }
289
  };
290
291
  using redecl_range = llvm::iterator_range<redecl_iterator>;
292
293
  /// Returns an iterator range for all the redeclarations of the same
294
  /// decl. It will iterate at least once (when this decl is the only one).
295
281M
  redecl_range redecls() const {
296
281M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
297
281M
                            static_cast<const decl_type *>(this))),
298
281M
                        redecl_iterator());
299
281M
  }
clang::Redeclarable<clang::VarDecl>::redecls() const
Line
Count
Source
295
53.6M
  redecl_range redecls() const {
296
53.6M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
297
53.6M
                            static_cast<const decl_type *>(this))),
298
53.6M
                        redecl_iterator());
299
53.6M
  }
clang::Redeclarable<clang::FunctionDecl>::redecls() const
Line
Count
Source
295
34.0M
  redecl_range redecls() const {
296
34.0M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
297
34.0M
                            static_cast<const decl_type *>(this))),
298
34.0M
                        redecl_iterator());
299
34.0M
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecls() const
Line
Count
Source
295
74.0k
  redecl_range redecls() const {
296
74.0k
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
297
74.0k
                            static_cast<const decl_type *>(this))),
298
74.0k
                        redecl_iterator());
299
74.0k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::redecls() const
Line
Count
Source
295
17.9k
  redecl_range redecls() const {
296
17.9k
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
297
17.9k
                            static_cast<const decl_type *>(this))),
298
17.9k
                        redecl_iterator());
299
17.9k
  }
clang::Redeclarable<clang::TagDecl>::redecls() const
Line
Count
Source
295
194M
  redecl_range redecls() const {
296
194M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
297
194M
                            static_cast<const decl_type *>(this))),
298
194M
                        redecl_iterator());
299
194M
  }
clang::Redeclarable<clang::UsingShadowDecl>::redecls() const
Line
Count
Source
295
949
  redecl_range redecls() const {
296
949
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
297
949
                            static_cast<const decl_type *>(this))),
298
949
                        redecl_iterator());
299
949
  }
300
301
  redecl_iterator redecls_begin() const { return redecls().begin(); }
302
11
  redecl_iterator redecls_end() const { return redecls().end(); }
303
};
304
305
/// Get the primary declaration for a declaration from an AST file. That
306
/// will be the first-loaded declaration.
307
Decl *getPrimaryMergedDecl(Decl *D);
308
309
/// Provides common interface for the Decls that cannot be redeclared,
310
/// but can be merged if the same declaration is brought in from multiple
311
/// modules.
312
template<typename decl_type>
313
class Mergeable {
314
public:
315
  Mergeable() = default;
316
317
  /// Return the first declaration of this declaration or itself if this
318
  /// is the only declaration.
319
9.66M
  decl_type *getFirstDecl() {
320
9.66M
    auto *D = static_cast<decl_type *>(this);
321
9.66M
    if (!D->isFromASTFile())
322
8.96M
      return D;
323
701k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
9.66M
  }
clang::Mergeable<clang::FieldDecl>::getFirstDecl()
Line
Count
Source
319
8.54M
  decl_type *getFirstDecl() {
320
8.54M
    auto *D = static_cast<decl_type *>(this);
321
8.54M
    if (!D->isFromASTFile())
322
7.91M
      return D;
323
628k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
8.54M
  }
clang::Mergeable<clang::EnumConstantDecl>::getFirstDecl()
Line
Count
Source
319
782k
  decl_type *getFirstDecl() {
320
782k
    auto *D = static_cast<decl_type *>(this);
321
782k
    if (!D->isFromASTFile())
322
748k
      return D;
323
34.2k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
782k
  }
clang::Mergeable<clang::IndirectFieldDecl>::getFirstDecl()
Line
Count
Source
319
17.4k
  decl_type *getFirstDecl() {
320
17.4k
    auto *D = static_cast<decl_type *>(this);
321
17.4k
    if (!D->isFromASTFile())
322
8.85k
      return D;
323
8.62k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
17.4k
  }
clang::Mergeable<clang::UsingDecl>::getFirstDecl()
Line
Count
Source
319
313k
  decl_type *getFirstDecl() {
320
313k
    auto *D = static_cast<decl_type *>(this);
321
313k
    if (!D->isFromASTFile())
322
285k
      return D;
323
27.9k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
313k
  }
clang::Mergeable<clang::UsingEnumDecl>::getFirstDecl()
Line
Count
Source
319
149
  decl_type *getFirstDecl() {
320
149
    auto *D = static_cast<decl_type *>(this);
321
149
    if (!D->isFromASTFile())
322
145
      return D;
323
4
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
149
  }
clang::Mergeable<clang::UsingPackDecl>::getFirstDecl()
Line
Count
Source
319
24
  decl_type *getFirstDecl() {
320
24
    auto *D = static_cast<decl_type *>(this);
321
24
    if (!D->isFromASTFile())
322
12
      return D;
323
12
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
24
  }
clang::Mergeable<clang::UnresolvedUsingValueDecl>::getFirstDecl()
Line
Count
Source
319
1.83k
  decl_type *getFirstDecl() {
320
1.83k
    auto *D = static_cast<decl_type *>(this);
321
1.83k
    if (!D->isFromASTFile())
322
1.65k
      return D;
323
185
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
1.83k
  }
clang::Mergeable<clang::UnresolvedUsingTypenameDecl>::getFirstDecl()
Line
Count
Source
319
3.41k
  decl_type *getFirstDecl() {
320
3.41k
    auto *D = static_cast<decl_type *>(this);
321
3.41k
    if (!D->isFromASTFile())
322
980
      return D;
323
2.43k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
3.41k
  }
clang::Mergeable<clang::ConceptDecl>::getFirstDecl()
Line
Count
Source
319
2.13k
  decl_type *getFirstDecl() {
320
2.13k
    auto *D = static_cast<decl_type *>(this);
321
2.13k
    if (!D->isFromASTFile())
322
2.06k
      return D;
323
72
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
2.13k
  }
clang::Mergeable<clang::TemplateParamObjectDecl>::getFirstDecl()
Line
Count
Source
319
936
  decl_type *getFirstDecl() {
320
936
    auto *D = static_cast<decl_type *>(this);
321
936
    if (!D->isFromASTFile())
322
916
      return D;
323
20
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
324
936
  }
325
326
  /// Return the first declaration of this declaration or itself if this
327
  /// is the only declaration.
328
1.64M
  const decl_type *getFirstDecl() const {
329
1.64M
    const auto *D = static_cast<const decl_type *>(this);
330
1.64M
    if (!D->isFromASTFile())
331
1.59M
      return D;
332
54.5k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
1.64M
  }
clang::Mergeable<clang::FieldDecl>::getFirstDecl() const
Line
Count
Source
328
1.64M
  const decl_type *getFirstDecl() const {
329
1.64M
    const auto *D = static_cast<const decl_type *>(this);
330
1.64M
    if (!D->isFromASTFile())
331
1.59M
      return D;
332
54.5k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
1.64M
  }
clang::Mergeable<clang::EnumConstantDecl>::getFirstDecl() const
Line
Count
Source
328
91
  const decl_type *getFirstDecl() const {
329
91
    const auto *D = static_cast<const decl_type *>(this);
330
91
    if (!D->isFromASTFile())
331
83
      return D;
332
8
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
91
  }
clang::Mergeable<clang::IndirectFieldDecl>::getFirstDecl() const
Line
Count
Source
328
62
  const decl_type *getFirstDecl() const {
329
62
    const auto *D = static_cast<const decl_type *>(this);
330
62
    if (!D->isFromASTFile())
331
41
      return D;
332
21
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
62
  }
clang::Mergeable<clang::UsingDecl>::getFirstDecl() const
Line
Count
Source
328
32
  const decl_type *getFirstDecl() const {
329
32
    const auto *D = static_cast<const decl_type *>(this);
330
32
    if (!D->isFromASTFile())
331
27
      return D;
332
5
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
32
  }
clang::Mergeable<clang::UsingEnumDecl>::getFirstDecl() const
Line
Count
Source
328
10
  const decl_type *getFirstDecl() const {
329
10
    const auto *D = static_cast<const decl_type *>(this);
330
10
    if (!D->isFromASTFile())
331
9
      return D;
332
1
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
10
  }
Unexecuted instantiation: clang::Mergeable<clang::UsingPackDecl>::getFirstDecl() const
clang::Mergeable<clang::UnresolvedUsingValueDecl>::getFirstDecl() const
Line
Count
Source
328
1
  const decl_type *getFirstDecl() const {
329
1
    const auto *D = static_cast<const decl_type *>(this);
330
1
    if (!D->isFromASTFile())
331
1
      return D;
332
0
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
1
  }
clang::Mergeable<clang::UnresolvedUsingTypenameDecl>::getFirstDecl() const
Line
Count
Source
328
1
  const decl_type *getFirstDecl() const {
329
1
    const auto *D = static_cast<const decl_type *>(this);
330
1
    if (!D->isFromASTFile())
331
1
      return D;
332
0
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
1
  }
Unexecuted instantiation: clang::Mergeable<clang::LifetimeExtendedTemporaryDecl>::getFirstDecl() const
clang::Mergeable<clang::ConceptDecl>::getFirstDecl() const
Line
Count
Source
328
6
  const decl_type *getFirstDecl() const {
329
6
    const auto *D = static_cast<const decl_type *>(this);
330
6
    if (!D->isFromASTFile())
331
6
      return D;
332
0
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
333
6
  }
Unexecuted instantiation: clang::Mergeable<clang::MSGuidDecl>::getFirstDecl() const
Unexecuted instantiation: clang::Mergeable<clang::TemplateParamObjectDecl>::getFirstDecl() const
334
335
  /// Returns true if this is the first declaration.
336
  bool isFirstDecl() const { return getFirstDecl() == this; }
337
};
338
339
/// A wrapper class around a pointer that always points to its canonical
340
/// declaration.
341
///
342
/// CanonicalDeclPtr<decl_type> behaves just like decl_type*, except we call
343
/// decl_type::getCanonicalDecl() on construction.
344
///
345
/// This is useful for hashtables that you want to be keyed on a declaration's
346
/// canonical decl -- if you use CanonicalDeclPtr as the key, you don't need to
347
/// remember to call getCanonicalDecl() everywhere.
348
template <typename decl_type> class CanonicalDeclPtr {
349
public:
350
1.76M
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::FunctionDecl>::CanonicalDeclPtr()
Line
Count
Source
350
427k
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::Decl const>::CanonicalDeclPtr()
Line
Count
Source
350
299k
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::Decl>::CanonicalDeclPtr()
Line
Count
Source
350
809k
  CanonicalDeclPtr() = default;
Unexecuted instantiation: clang::CanonicalDeclPtr<clang::VarDecl>::CanonicalDeclPtr()
clang::CanonicalDeclPtr<clang::CXXRecordDecl const>::CanonicalDeclPtr()
Line
Count
Source
350
141k
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::VarDecl const>::CanonicalDeclPtr()
Line
Count
Source
350
89.6k
  CanonicalDeclPtr() = default;
351
  CanonicalDeclPtr(decl_type *Ptr)
352
12.0M
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::Decl>::CanonicalDeclPtr(clang::Decl*)
Line
Count
Source
352
1.15M
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::FunctionDecl>::CanonicalDeclPtr(clang::FunctionDecl*)
Line
Count
Source
352
8.12M
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::Decl const>::CanonicalDeclPtr(clang::Decl const*)
Line
Count
Source
352
2.58M
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::VarDecl>::CanonicalDeclPtr(clang::VarDecl*)
Line
Count
Source
352
97.9k
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::CXXRecordDecl const>::CanonicalDeclPtr(clang::CXXRecordDecl const*)
Line
Count
Source
352
25.0k
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::VarDecl const>::CanonicalDeclPtr(clang::VarDecl const*)
Line
Count
Source
352
24.1k
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
353
  CanonicalDeclPtr(const CanonicalDeclPtr &) = default;
354
  CanonicalDeclPtr &operator=(const CanonicalDeclPtr &) = default;
355
356
224k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::FunctionDecl>::operator clang::FunctionDecl*()
Line
Count
Source
356
203k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::VarDecl>::operator clang::VarDecl*()
Line
Count
Source
356
1.11k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::Decl const>::operator clang::Decl const*()
Line
Count
Source
356
19.6k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::VarDecl const>::operator clang::VarDecl const*()
Line
Count
Source
356
24
  operator decl_type *() { return Ptr; }
357
24.1M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::FunctionDecl>::operator clang::FunctionDecl const*() const
Line
Count
Source
357
2.78M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::Decl const>::operator clang::Decl const*() const
Line
Count
Source
357
4.63M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::Decl>::operator clang::Decl const*() const
Line
Count
Source
357
12.1M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::CXXRecordDecl const>::operator clang::CXXRecordDecl const*() const
Line
Count
Source
357
3.13M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::VarDecl const>::operator clang::VarDecl const*() const
Line
Count
Source
357
1.44M
  operator const decl_type *() const { return Ptr; }
358
359
  decl_type *operator->() { return Ptr; }
360
4
  const decl_type *operator->() const { return Ptr; }
361
362
  decl_type &operator*() { return *Ptr; }
363
  const decl_type &operator*() const { return *Ptr; }
364
365
3.85k
  friend bool operator==(CanonicalDeclPtr LHS, CanonicalDeclPtr RHS) {
366
3.85k
    return LHS.Ptr == RHS.Ptr;
367
3.85k
  }
368
  friend bool operator!=(CanonicalDeclPtr LHS, CanonicalDeclPtr RHS) {
369
    return LHS.Ptr != RHS.Ptr;
370
  }
371
372
private:
373
  friend struct llvm::DenseMapInfo<CanonicalDeclPtr<decl_type>>;
374
  friend struct llvm::PointerLikeTypeTraits<CanonicalDeclPtr<decl_type>>;
375
376
  decl_type *Ptr = nullptr;
377
};
378
379
} // namespace clang
380
381
namespace llvm {
382
383
template <typename decl_type>
384
struct DenseMapInfo<clang::CanonicalDeclPtr<decl_type>> {
385
  using CanonicalDeclPtr = clang::CanonicalDeclPtr<decl_type>;
386
  using BaseInfo = DenseMapInfo<decl_type *>;
387
388
1.04M
  static CanonicalDeclPtr getEmptyKey() {
389
    // Construct our CanonicalDeclPtr this way because the regular constructor
390
    // would dereference P.Ptr, which is not allowed.
391
1.04M
    CanonicalDeclPtr P;
392
1.04M
    P.Ptr = BaseInfo::getEmptyKey();
393
1.04M
    return P;
394
1.04M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::getEmptyKey()
Line
Count
Source
388
217k
  static CanonicalDeclPtr getEmptyKey() {
389
    // Construct our CanonicalDeclPtr this way because the regular constructor
390
    // would dereference P.Ptr, which is not allowed.
391
217k
    CanonicalDeclPtr P;
392
217k
    P.Ptr = BaseInfo::getEmptyKey();
393
217k
    return P;
394
217k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::getEmptyKey()
Line
Count
Source
388
181k
  static CanonicalDeclPtr getEmptyKey() {
389
    // Construct our CanonicalDeclPtr this way because the regular constructor
390
    // would dereference P.Ptr, which is not allowed.
391
181k
    CanonicalDeclPtr P;
392
181k
    P.Ptr = BaseInfo::getEmptyKey();
393
181k
    return P;
394
181k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::getEmptyKey()
Line
Count
Source
388
495k
  static CanonicalDeclPtr getEmptyKey() {
389
    // Construct our CanonicalDeclPtr this way because the regular constructor
390
    // would dereference P.Ptr, which is not allowed.
391
495k
    CanonicalDeclPtr P;
392
495k
    P.Ptr = BaseInfo::getEmptyKey();
393
495k
    return P;
394
495k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::getEmptyKey()
Line
Count
Source
388
94.1k
  static CanonicalDeclPtr getEmptyKey() {
389
    // Construct our CanonicalDeclPtr this way because the regular constructor
390
    // would dereference P.Ptr, which is not allowed.
391
94.1k
    CanonicalDeclPtr P;
392
94.1k
    P.Ptr = BaseInfo::getEmptyKey();
393
94.1k
    return P;
394
94.1k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::getEmptyKey()
Line
Count
Source
388
56.8k
  static CanonicalDeclPtr getEmptyKey() {
389
    // Construct our CanonicalDeclPtr this way because the regular constructor
390
    // would dereference P.Ptr, which is not allowed.
391
56.8k
    CanonicalDeclPtr P;
392
56.8k
    P.Ptr = BaseInfo::getEmptyKey();
393
56.8k
    return P;
394
56.8k
  }
395
396
671k
  static CanonicalDeclPtr getTombstoneKey() {
397
671k
    CanonicalDeclPtr P;
398
671k
    P.Ptr = BaseInfo::getTombstoneKey();
399
671k
    return P;
400
671k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::getTombstoneKey()
Line
Count
Source
396
160k
  static CanonicalDeclPtr getTombstoneKey() {
397
160k
    CanonicalDeclPtr P;
398
160k
    P.Ptr = BaseInfo::getTombstoneKey();
399
160k
    return P;
400
160k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::getTombstoneKey()
Line
Count
Source
396
118k
  static CanonicalDeclPtr getTombstoneKey() {
397
118k
    CanonicalDeclPtr P;
398
118k
    P.Ptr = BaseInfo::getTombstoneKey();
399
118k
    return P;
400
118k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::getTombstoneKey()
Line
Count
Source
396
313k
  static CanonicalDeclPtr getTombstoneKey() {
397
313k
    CanonicalDeclPtr P;
398
313k
    P.Ptr = BaseInfo::getTombstoneKey();
399
313k
    return P;
400
313k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::getTombstoneKey()
Line
Count
Source
396
47.0k
  static CanonicalDeclPtr getTombstoneKey() {
397
47.0k
    CanonicalDeclPtr P;
398
47.0k
    P.Ptr = BaseInfo::getTombstoneKey();
399
47.0k
    return P;
400
47.0k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::getTombstoneKey()
Line
Count
Source
396
32.7k
  static CanonicalDeclPtr getTombstoneKey() {
397
32.7k
    CanonicalDeclPtr P;
398
32.7k
    P.Ptr = BaseInfo::getTombstoneKey();
399
32.7k
    return P;
400
32.7k
  }
401
402
496k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
403
496k
    return BaseInfo::getHashValue(P);
404
496k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::getHashValue(clang::CanonicalDeclPtr<clang::FunctionDecl> const&)
Line
Count
Source
402
152k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
403
152k
    return BaseInfo::getHashValue(P);
404
152k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::getHashValue(clang::CanonicalDeclPtr<clang::Decl const> const&)
Line
Count
Source
402
58.7k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
403
58.7k
    return BaseInfo::getHashValue(P);
404
58.7k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::getHashValue(clang::CanonicalDeclPtr<clang::Decl> const&)
Line
Count
Source
402
236k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
403
236k
    return BaseInfo::getHashValue(P);
404
236k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::getHashValue(clang::CanonicalDeclPtr<clang::CXXRecordDecl const> const&)
Line
Count
Source
402
25.0k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
403
25.0k
    return BaseInfo::getHashValue(P);
404
25.0k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::getHashValue(clang::CanonicalDeclPtr<clang::VarDecl const> const&)
Line
Count
Source
402
23.4k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
403
23.4k
    return BaseInfo::getHashValue(P);
404
23.4k
  }
405
406
  static bool isEqual(const CanonicalDeclPtr &LHS,
407
11.8M
                      const CanonicalDeclPtr &RHS) {
408
11.8M
    return BaseInfo::isEqual(LHS, RHS);
409
11.8M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::isEqual(clang::CanonicalDeclPtr<clang::FunctionDecl> const&, clang::CanonicalDeclPtr<clang::FunctionDecl> const&)
Line
Count
Source
407
1.31M
                      const CanonicalDeclPtr &RHS) {
408
1.31M
    return BaseInfo::isEqual(LHS, RHS);
409
1.31M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::isEqual(clang::CanonicalDeclPtr<clang::Decl const> const&, clang::CanonicalDeclPtr<clang::Decl const> const&)
Line
Count
Source
407
2.28M
                      const CanonicalDeclPtr &RHS) {
408
2.28M
    return BaseInfo::isEqual(LHS, RHS);
409
2.28M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::isEqual(clang::CanonicalDeclPtr<clang::Decl> const&, clang::CanonicalDeclPtr<clang::Decl> const&)
Line
Count
Source
407
5.96M
                      const CanonicalDeclPtr &RHS) {
408
5.96M
    return BaseInfo::isEqual(LHS, RHS);
409
5.96M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::isEqual(clang::CanonicalDeclPtr<clang::CXXRecordDecl const> const&, clang::CanonicalDeclPtr<clang::CXXRecordDecl const> const&)
Line
Count
Source
407
1.55M
                      const CanonicalDeclPtr &RHS) {
408
1.55M
    return BaseInfo::isEqual(LHS, RHS);
409
1.55M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::isEqual(clang::CanonicalDeclPtr<clang::VarDecl const> const&, clang::CanonicalDeclPtr<clang::VarDecl const> const&)
Line
Count
Source
407
712k
                      const CanonicalDeclPtr &RHS) {
408
712k
    return BaseInfo::isEqual(LHS, RHS);
409
712k
  }
410
};
411
412
template <typename decl_type>
413
struct PointerLikeTypeTraits<clang::CanonicalDeclPtr<decl_type>> {
414
664k
  static inline void *getAsVoidPointer(clang::CanonicalDeclPtr<decl_type> P) {
415
664k
    return P.Ptr;
416
664k
  }
417
  static inline clang::CanonicalDeclPtr<decl_type> getFromVoidPointer(void *P) {
418
    clang::CanonicalDeclPtr<decl_type> C;
419
    C.Ptr = PointerLikeTypeTraits<decl_type *>::getFromVoidPtr(P);
420
    return C;
421
  }
422
  static constexpr int NumLowBitsAvailable =
423
      PointerLikeTypeTraits<decl_type *>::NumLowBitsAvailable;
424
};
425
426
} // namespace llvm
427
428
#endif // LLVM_CLANG_AST_REDECLARABLE_H