Coverage Report

Created: 2020-09-22 08:39

/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
78.8M
        : 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
3.72M
        : 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
49.7M
        : 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
16.6M
        : 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
6.55M
        : 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
344
        : 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
265k
        : 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
161k
        : 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
354k
        : 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
32.4k
        : 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.30M
        : Link(NotKnownLatest(reinterpret_cast<UninitializedLatest>(&Ctx))) {}
113
2.59M
    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
315k
    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
158k
    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.59M
    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
220k
    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
219k
    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
7.15k
    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
19.7k
    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
60.7k
    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.15k
    DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {}
114
115
422M
    bool isFirst() const {
116
422M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
242M
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
422M
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::isFirst() const
Line
Count
Source
115
28.7M
    bool isFirst() const {
116
28.7M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
9.02M
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
28.7M
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::isFirst() const
Line
Count
Source
115
36.2M
    bool isFirst() const {
116
36.2M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
15.6M
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
36.2M
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::isFirst() const
Line
Count
Source
115
964k
    bool isFirst() const {
116
964k
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
469k
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
964k
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::isFirst() const
Line
Count
Source
115
63.4M
    bool isFirst() const {
116
63.4M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
19.7M
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
63.4M
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::isFirst() const
Line
Count
Source
115
326k
    bool isFirst() const {
116
326k
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
318k
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
326k
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::isFirst() const
Line
Count
Source
115
1.28M
    bool isFirst() const {
116
1.28M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
796k
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
1.28M
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::isFirst() const
Line
Count
Source
115
115k
    bool isFirst() const {
116
115k
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
69.2k
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
115k
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::isFirst() const
Line
Count
Source
115
3.77M
    bool isFirst() const {
116
3.77M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
2.78M
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
3.77M
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::isFirst() const
Line
Count
Source
115
287M
    bool isFirst() const {
116
287M
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
193M
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
287M
    }
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::isFirst() const
Line
Count
Source
115
82
    bool isFirst() const {
116
82
      return Link.is<KnownLatest>() ||
117
             // FIXME: 'template' is required on the next line due to an
118
             // apparent clang bug.
119
58
             Link.get<NotKnownLatest>().template is<UninitializedLatest>();
120
82
    }
121
122
491M
    decl_type *getPrevious(const decl_type *D) const {
123
491M
      if (Link.is<NotKnownLatest>()) {
124
45.7M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
45.7M
        if (NKL.is<Previous>())
126
12.4M
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
33.2M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
33.2M
                               NKL.get<UninitializedLatest>()),
131
33.2M
                           const_cast<decl_type *>(D));
132
33.2M
      }
133
134
478M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
491M
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::getPrevious(clang::VarDecl const*) const
Line
Count
Source
122
103M
    decl_type *getPrevious(const decl_type *D) const {
123
103M
      if (Link.is<NotKnownLatest>()) {
124
19.9M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
19.9M
        if (NKL.is<Previous>())
126
2.93M
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
17.0M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
17.0M
                               NKL.get<UninitializedLatest>()),
131
17.0M
                           const_cast<decl_type *>(D));
132
17.0M
      }
133
134
100M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
103M
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::getPrevious(clang::FunctionDecl const*) const
Line
Count
Source
122
59.3M
    decl_type *getPrevious(const decl_type *D) const {
123
59.3M
      if (Link.is<NotKnownLatest>()) {
124
16.1M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
16.1M
        if (NKL.is<Previous>())
126
904k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
15.2M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
15.2M
                               NKL.get<UninitializedLatest>()),
131
15.2M
                           const_cast<decl_type *>(D));
132
15.2M
      }
133
134
58.3M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
59.3M
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::getPrevious(clang::TypedefNameDecl const*) const
Line
Count
Source
122
1.27M
    decl_type *getPrevious(const decl_type *D) const {
123
1.27M
      if (Link.is<NotKnownLatest>()) {
124
392k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
392k
        if (NKL.is<Previous>())
126
17.4k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
374k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
374k
                               NKL.get<UninitializedLatest>()),
131
374k
                           const_cast<decl_type *>(D));
132
374k
      }
133
134
1.26M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
1.27M
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::getPrevious(clang::TagDecl const*) const
Line
Count
Source
122
304M
    decl_type *getPrevious(const decl_type *D) const {
123
304M
      if (Link.is<NotKnownLatest>()) {
124
7.08M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
7.08M
        if (NKL.is<Previous>())
126
7.08M
          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
297M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
304M
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::getPrevious(clang::UsingShadowDecl const*) const
Line
Count
Source
122
523k
    decl_type *getPrevious(const decl_type *D) const {
123
523k
      if (Link.is<NotKnownLatest>()) {
124
7.35k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
7.35k
        if (NKL.is<Previous>())
126
7.33k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
13
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
13
                               NKL.get<UninitializedLatest>()),
131
13
                           const_cast<decl_type *>(D));
132
13
      }
133
134
516k
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
523k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::getPrevious(clang::ObjCProtocolDecl const*) const
Line
Count
Source
122
269k
    decl_type *getPrevious(const decl_type *D) const {
123
269k
      if (Link.is<NotKnownLatest>()) {
124
11.5k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
11.5k
        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
0
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
0
                               NKL.get<UninitializedLatest>()),
131
0
                           const_cast<decl_type *>(D));
132
0
      }
133
134
257k
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
269k
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::getPrevious(clang::ObjCInterfaceDecl const*) const
Line
Count
Source
122
942k
    decl_type *getPrevious(const decl_type *D) const {
123
942k
      if (Link.is<NotKnownLatest>()) {
124
286k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
286k
        if (NKL.is<Previous>())
126
286k
          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
655k
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
942k
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::getPrevious(clang::RedeclarableTemplateDecl const*) const
Line
Count
Source
122
15.3M
    decl_type *getPrevious(const decl_type *D) const {
123
15.3M
      if (Link.is<NotKnownLatest>()) {
124
990k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
990k
        if (NKL.is<Previous>())
126
403k
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
587k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
587k
                               NKL.get<UninitializedLatest>()),
131
587k
                           const_cast<decl_type *>(D));
132
587k
      }
133
134
14.9M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
15.3M
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::getPrevious(clang::NamespaceDecl const*) const
Line
Count
Source
122
5.85M
    decl_type *getPrevious(const decl_type *D) const {
123
5.85M
      if (Link.is<NotKnownLatest>()) {
124
837k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
837k
        if (NKL.is<Previous>())
126
837k
          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
5.02M
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
5.85M
    }
clang::Redeclarable<clang::NamespaceAliasDecl>::DeclLink::getPrevious(clang::NamespaceAliasDecl const*) const
Line
Count
Source
122
207
    decl_type *getPrevious(const decl_type *D) const {
123
207
      if (Link.is<NotKnownLatest>()) {
124
62
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
125
62
        if (NKL.is<Previous>())
126
2
          return static_cast<decl_type*>(NKL.get<Previous>());
127
128
        // Allocate the generational 'most recent' cache now, if needed.
129
60
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
130
60
                               NKL.get<UninitializedLatest>()),
131
60
                           const_cast<decl_type *>(D));
132
60
      }
133
134
205
      return static_cast<decl_type*>(Link.get<KnownLatest>().get(D));
135
207
    }
136
137
1.14M
    void setPrevious(decl_type *D) {
138
1.14M
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
1.14M
      Link = Previous(D);
140
1.14M
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::setPrevious(clang::VarDecl*)
Line
Count
Source
137
3.92k
    void setPrevious(decl_type *D) {
138
3.92k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
3.92k
      Link = Previous(D);
140
3.92k
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::setPrevious(clang::FunctionDecl*)
Line
Count
Source
137
71.4k
    void setPrevious(decl_type *D) {
138
71.4k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
71.4k
      Link = Previous(D);
140
71.4k
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::setPrevious(clang::NamespaceDecl*)
Line
Count
Source
137
177k
    void setPrevious(decl_type *D) {
138
177k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
177k
      Link = Previous(D);
140
177k
    }
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
3
      Link = Previous(D);
140
3
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::setPrevious(clang::ObjCInterfaceDecl*)
Line
Count
Source
137
53.8k
    void setPrevious(decl_type *D) {
138
53.8k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
53.8k
      Link = Previous(D);
140
53.8k
    }
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
647
      Link = Previous(D);
140
647
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::setPrevious(clang::RedeclarableTemplateDecl*)
Line
Count
Source
137
81.6k
    void setPrevious(decl_type *D) {
138
81.6k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
81.6k
      Link = Previous(D);
140
81.6k
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::setPrevious(clang::TagDecl*)
Line
Count
Source
137
745k
    void setPrevious(decl_type *D) {
138
745k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
745k
      Link = Previous(D);
140
745k
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::setPrevious(clang::TypedefNameDecl*)
Line
Count
Source
137
13.7k
    void setPrevious(decl_type *D) {
138
13.7k
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
13.7k
      Link = Previous(D);
140
13.7k
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::setPrevious(clang::UsingShadowDecl*)
Line
Count
Source
137
113
    void setPrevious(decl_type *D) {
138
113
      assert(!isFirst() && "decl became non-canonical unexpectedly");
139
113
      Link = Previous(D);
140
113
    }
141
142
10.5M
    void setLatest(decl_type *D) {
143
10.5M
      assert(isFirst() && "decl became canonical unexpectedly");
144
10.5M
      if (Link.is<NotKnownLatest>()) {
145
8.18M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
8.18M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
8.18M
                               NKL.get<UninitializedLatest>()),
148
8.18M
                           D);
149
2.40M
      } else {
150
2.40M
        auto Latest = Link.get<KnownLatest>();
151
2.40M
        Latest.set(D);
152
2.40M
        Link = Latest;
153
2.40M
      }
154
10.5M
    }
clang::Redeclarable<clang::FunctionDecl>::DeclLink::setLatest(clang::FunctionDecl*)
Line
Count
Source
142
646k
    void setLatest(decl_type *D) {
143
646k
      assert(isFirst() && "decl became canonical unexpectedly");
144
646k
      if (Link.is<NotKnownLatest>()) {
145
400k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
400k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
400k
                               NKL.get<UninitializedLatest>()),
148
400k
                           D);
149
245k
      } else {
150
245k
        auto Latest = Link.get<KnownLatest>();
151
245k
        Latest.set(D);
152
245k
        Link = Latest;
153
245k
      }
154
646k
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::setLatest(clang::RedeclarableTemplateDecl*)
Line
Count
Source
142
474k
    void setLatest(decl_type *D) {
143
474k
      assert(isFirst() && "decl became canonical unexpectedly");
144
474k
      if (Link.is<NotKnownLatest>()) {
145
396k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
396k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
396k
                               NKL.get<UninitializedLatest>()),
148
396k
                           D);
149
78.0k
      } else {
150
78.0k
        auto Latest = Link.get<KnownLatest>();
151
78.0k
        Latest.set(D);
152
78.0k
        Link = Latest;
153
78.0k
      }
154
474k
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::setLatest(clang::TagDecl*)
Line
Count
Source
142
7.48M
    void setLatest(decl_type *D) {
143
7.48M
      assert(isFirst() && "decl became canonical unexpectedly");
144
7.48M
      if (Link.is<NotKnownLatest>()) {
145
5.70M
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
5.70M
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
5.70M
                               NKL.get<UninitializedLatest>()),
148
5.70M
                           D);
149
1.77M
      } else {
150
1.77M
        auto Latest = Link.get<KnownLatest>();
151
1.77M
        Latest.set(D);
152
1.77M
        Link = Latest;
153
1.77M
      }
154
7.48M
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::setLatest(clang::NamespaceDecl*)
Line
Count
Source
142
273k
    void setLatest(decl_type *D) {
143
273k
      assert(isFirst() && "decl became canonical unexpectedly");
144
273k
      if (Link.is<NotKnownLatest>()) {
145
222k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
222k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
222k
                               NKL.get<UninitializedLatest>()),
148
222k
                           D);
149
51.0k
      } else {
150
51.0k
        auto Latest = Link.get<KnownLatest>();
151
51.0k
        Latest.set(D);
152
51.0k
        Link = Latest;
153
51.0k
      }
154
273k
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::DeclLink::setLatest(clang::ObjCInterfaceDecl*)
Line
Count
Source
142
363k
    void setLatest(decl_type *D) {
143
363k
      assert(isFirst() && "decl became canonical unexpectedly");
144
363k
      if (Link.is<NotKnownLatest>()) {
145
188k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
188k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
188k
                               NKL.get<UninitializedLatest>()),
148
188k
                           D);
149
175k
      } else {
150
175k
        auto Latest = Link.get<KnownLatest>();
151
175k
        Latest.set(D);
152
175k
        Link = Latest;
153
175k
      }
154
363k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::setLatest(clang::ObjCProtocolDecl*)
Line
Count
Source
142
34.8k
    void setLatest(decl_type *D) {
143
34.8k
      assert(isFirst() && "decl became canonical unexpectedly");
144
34.8k
      if (Link.is<NotKnownLatest>()) {
145
25.9k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
25.9k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
25.9k
                               NKL.get<UninitializedLatest>()),
148
25.9k
                           D);
149
8.86k
      } else {
150
8.86k
        auto Latest = Link.get<KnownLatest>();
151
8.86k
        Latest.set(D);
152
8.86k
        Link = Latest;
153
8.86k
      }
154
34.8k
    }
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
15
      } 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
142k
    void setLatest(decl_type *D) {
143
142k
      assert(isFirst() && "decl became canonical unexpectedly");
144
142k
      if (Link.is<NotKnownLatest>()) {
145
135k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
135k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
135k
                               NKL.get<UninitializedLatest>()),
148
135k
                           D);
149
7.23k
      } else {
150
7.23k
        auto Latest = Link.get<KnownLatest>();
151
7.23k
        Latest.set(D);
152
7.23k
        Link = Latest;
153
7.23k
      }
154
142k
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::setLatest(clang::UsingShadowDecl*)
Line
Count
Source
142
160k
    void setLatest(decl_type *D) {
143
160k
      assert(isFirst() && "decl became canonical unexpectedly");
144
160k
      if (Link.is<NotKnownLatest>()) {
145
157k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
157k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
157k
                               NKL.get<UninitializedLatest>()),
148
157k
                           D);
149
3.04k
      } else {
150
3.04k
        auto Latest = Link.get<KnownLatest>();
151
3.04k
        Latest.set(D);
152
3.04k
        Link = Latest;
153
3.04k
      }
154
160k
    }
clang::Redeclarable<clang::VarDecl>::DeclLink::setLatest(clang::VarDecl*)
Line
Count
Source
142
1.01M
    void setLatest(decl_type *D) {
143
1.01M
      assert(isFirst() && "decl became canonical unexpectedly");
144
1.01M
      if (Link.is<NotKnownLatest>()) {
145
956k
        NotKnownLatest NKL = Link.get<NotKnownLatest>();
146
956k
        Link = KnownLatest(*reinterpret_cast<const ASTContext *>(
147
956k
                               NKL.get<UninitializedLatest>()),
148
956k
                           D);
149
57.7k
      } else {
150
57.7k
        auto Latest = Link.get<KnownLatest>();
151
57.7k
        Latest.set(D);
152
57.7k
        Link = Latest;
153
57.7k
      }
154
1.01M
    }
155
156
212k
    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
9.28k
    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
7.90k
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
26
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
Unexecuted instantiation: clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::markIncomplete()
clang::Redeclarable<clang::FunctionDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
195k
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
clang::Redeclarable<clang::VarDecl>::DeclLink::markIncomplete()
Line
Count
Source
156
26
    void markIncomplete() { Link.get<KnownLatest>().markIncomplete(); }
157
158
222k
    Decl *getLatestNotUpdated() const {
159
222k
      assert(isFirst() && "expected a canonical decl");
160
222k
      if (Link.is<NotKnownLatest>())
161
976
        return nullptr;
162
221k
      return Link.get<KnownLatest>().getNotUpdated();
163
221k
    }
clang::Redeclarable<clang::NamespaceDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
1.83k
    Decl *getLatestNotUpdated() const {
159
1.83k
      assert(isFirst() && "expected a canonical decl");
160
1.83k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
1.83k
      return Link.get<KnownLatest>().getNotUpdated();
163
1.83k
    }
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
9.37k
    Decl *getLatestNotUpdated() const {
159
9.37k
      assert(isFirst() && "expected a canonical decl");
160
9.37k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
9.37k
      return Link.get<KnownLatest>().getNotUpdated();
163
9.37k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
2.33k
    Decl *getLatestNotUpdated() const {
159
2.33k
      assert(isFirst() && "expected a canonical decl");
160
2.33k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
2.33k
      return Link.get<KnownLatest>().getNotUpdated();
163
2.33k
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
174k
    Decl *getLatestNotUpdated() const {
159
174k
      assert(isFirst() && "expected a canonical decl");
160
174k
      if (Link.is<NotKnownLatest>())
161
7
        return nullptr;
162
174k
      return Link.get<KnownLatest>().getNotUpdated();
163
174k
    }
clang::Redeclarable<clang::TagDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
30.0k
    Decl *getLatestNotUpdated() const {
159
30.0k
      assert(isFirst() && "expected a canonical decl");
160
30.0k
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
30.0k
      return Link.get<KnownLatest>().getNotUpdated();
163
30.0k
    }
clang::Redeclarable<clang::TypedefNameDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
2.20k
    Decl *getLatestNotUpdated() const {
159
2.20k
      assert(isFirst() && "expected a canonical decl");
160
2.20k
      if (Link.is<NotKnownLatest>())
161
969
        return nullptr;
162
1.23k
      return Link.get<KnownLatest>().getNotUpdated();
163
1.23k
    }
clang::Redeclarable<clang::UsingShadowDecl>::DeclLink::getLatestNotUpdated() const
Line
Count
Source
158
1
    Decl *getLatestNotUpdated() const {
159
1
      assert(isFirst() && "expected a canonical decl");
160
1
      if (Link.is<NotKnownLatest>())
161
0
        return nullptr;
162
1
      return Link.get<KnownLatest>().getNotUpdated();
163
1
    }
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
    }
164
  };
165
166
2.59M
  static DeclLink PreviousDeclLink(decl_type *D) {
167
2.59M
    return DeclLink(DeclLink::PreviousLink, D);
168
2.59M
  }
clang::Redeclarable<clang::FunctionDecl>::PreviousDeclLink(clang::FunctionDecl*)
Line
Count
Source
166
315k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
315k
    return DeclLink(DeclLink::PreviousLink, D);
168
315k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::PreviousDeclLink(clang::RedeclarableTemplateDecl*)
Line
Count
Source
166
158k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
158k
    return DeclLink(DeclLink::PreviousLink, D);
168
158k
  }
clang::Redeclarable<clang::TagDecl>::PreviousDeclLink(clang::TagDecl*)
Line
Count
Source
166
1.59M
  static DeclLink PreviousDeclLink(decl_type *D) {
167
1.59M
    return DeclLink(DeclLink::PreviousLink, D);
168
1.59M
  }
clang::Redeclarable<clang::NamespaceDecl>::PreviousDeclLink(clang::NamespaceDecl*)
Line
Count
Source
166
220k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
220k
    return DeclLink(DeclLink::PreviousLink, D);
168
220k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::PreviousDeclLink(clang::ObjCInterfaceDecl*)
Line
Count
Source
166
219k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
219k
    return DeclLink(DeclLink::PreviousLink, D);
168
219k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::PreviousDeclLink(clang::ObjCProtocolDecl*)
Line
Count
Source
166
7.15k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
7.15k
    return DeclLink(DeclLink::PreviousLink, D);
168
7.15k
  }
clang::Redeclarable<clang::TypedefNameDecl>::PreviousDeclLink(clang::TypedefNameDecl*)
Line
Count
Source
166
19.7k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
19.7k
    return DeclLink(DeclLink::PreviousLink, D);
168
19.7k
  }
clang::Redeclarable<clang::VarDecl>::PreviousDeclLink(clang::VarDecl*)
Line
Count
Source
166
60.7k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
60.7k
    return DeclLink(DeclLink::PreviousLink, D);
168
60.7k
  }
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.15k
  static DeclLink PreviousDeclLink(decl_type *D) {
167
3.15k
    return DeclLink(DeclLink::PreviousLink, D);
168
3.15k
  }
169
170
78.8M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
78.8M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
78.8M
  }
clang::Redeclarable<clang::TypedefNameDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
3.72M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
3.72M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
3.72M
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
344
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
344
    return DeclLink(DeclLink::LatestLink, Ctx);
172
344
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
1.30M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
1.30M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
1.30M
  }
clang::Redeclarable<clang::VarDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
49.7M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
49.7M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
49.7M
  }
clang::Redeclarable<clang::FunctionDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
16.6M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
16.6M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
16.6M
  }
clang::Redeclarable<clang::TagDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
6.55M
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
6.55M
    return DeclLink(DeclLink::LatestLink, Ctx);
172
6.55M
  }
clang::Redeclarable<clang::NamespaceDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
265k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
265k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
265k
  }
clang::Redeclarable<clang::UsingShadowDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
161k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
161k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
161k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
354k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
354k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
354k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::LatestDeclLink(clang::ASTContext const&)
Line
Count
Source
170
32.4k
  static DeclLink LatestDeclLink(const ASTContext &Ctx) {
171
32.4k
    return DeclLink(DeclLink::LatestLink, Ctx);
172
32.4k
  }
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
491M
  decl_type *getNextRedeclaration() const {
190
491M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
491M
  }
clang::Redeclarable<clang::VarDecl>::getNextRedeclaration() const
Line
Count
Source
189
103M
  decl_type *getNextRedeclaration() const {
190
103M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
103M
  }
clang::Redeclarable<clang::FunctionDecl>::getNextRedeclaration() const
Line
Count
Source
189
59.3M
  decl_type *getNextRedeclaration() const {
190
59.3M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
59.3M
  }
clang::Redeclarable<clang::TypedefNameDecl>::getNextRedeclaration() const
Line
Count
Source
189
1.27M
  decl_type *getNextRedeclaration() const {
190
1.27M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
1.27M
  }
clang::Redeclarable<clang::TagDecl>::getNextRedeclaration() const
Line
Count
Source
189
304M
  decl_type *getNextRedeclaration() const {
190
304M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
304M
  }
clang::Redeclarable<clang::UsingShadowDecl>::getNextRedeclaration() const
Line
Count
Source
189
523k
  decl_type *getNextRedeclaration() const {
190
523k
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
523k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getNextRedeclaration() const
Line
Count
Source
189
269k
  decl_type *getNextRedeclaration() const {
190
269k
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
269k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getNextRedeclaration() const
Line
Count
Source
189
942k
  decl_type *getNextRedeclaration() const {
190
942k
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
942k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getNextRedeclaration() const
Line
Count
Source
189
15.3M
  decl_type *getNextRedeclaration() const {
190
15.3M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
15.3M
  }
clang::Redeclarable<clang::NamespaceDecl>::getNextRedeclaration() const
Line
Count
Source
189
5.85M
  decl_type *getNextRedeclaration() const {
190
5.85M
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
5.85M
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getNextRedeclaration() const
Line
Count
Source
189
207
  decl_type *getNextRedeclaration() const {
190
207
    return RedeclLink.getPrevious(static_cast<const decl_type *>(this));
191
207
  }
192
193
public:
194
  friend class ASTDeclReader;
195
  friend class ASTDeclWriter;
196
197
  Redeclarable(const ASTContext &Ctx)
198
      : RedeclLink(LatestDeclLink(Ctx)),
199
78.8M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::TypedefNameDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
3.72M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::VarDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
49.7M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::FunctionDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
16.6M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::TagDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
6.55M
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::NamespaceAliasDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
344
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::NamespaceDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
265k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::UsingShadowDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
161k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::ObjCInterfaceDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
354k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::ObjCProtocolDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
32.4k
        First(static_cast<decl_type *>(this)) {}
clang::Redeclarable<clang::RedeclarableTemplateDecl>::Redeclarable(clang::ASTContext const&)
Line
Count
Source
199
1.30M
        First(static_cast<decl_type *>(this)) {}
200
201
  /// Return the previous declaration of this declaration or NULL if this
202
  /// is the first declaration.
203
19.2M
  decl_type *getPreviousDecl() {
204
19.2M
    if (!RedeclLink.isFirst())
205
3.36M
      return getNextRedeclaration();
206
15.8M
    return nullptr;
207
15.8M
  }
clang::Redeclarable<clang::VarDecl>::getPreviousDecl()
Line
Count
Source
203
2.56M
  decl_type *getPreviousDecl() {
204
2.56M
    if (!RedeclLink.isFirst())
205
22.6k
      return getNextRedeclaration();
206
2.54M
    return nullptr;
207
2.54M
  }
clang::Redeclarable<clang::FunctionDecl>::getPreviousDecl()
Line
Count
Source
203
6.46M
  decl_type *getPreviousDecl() {
204
6.46M
    if (!RedeclLink.isFirst())
205
231k
      return getNextRedeclaration();
206
6.23M
    return nullptr;
207
6.23M
  }
clang::Redeclarable<clang::TypedefNameDecl>::getPreviousDecl()
Line
Count
Source
203
680k
  decl_type *getPreviousDecl() {
204
680k
    if (!RedeclLink.isFirst())
205
13.5k
      return getNextRedeclaration();
206
666k
    return nullptr;
207
666k
  }
clang::Redeclarable<clang::TagDecl>::getPreviousDecl()
Line
Count
Source
203
7.47M
  decl_type *getPreviousDecl() {
204
7.47M
    if (!RedeclLink.isFirst())
205
2.67M
      return getNextRedeclaration();
206
4.79M
    return nullptr;
207
4.79M
  }
clang::Redeclarable<clang::UsingShadowDecl>::getPreviousDecl()
Line
Count
Source
203
872
  decl_type *getPreviousDecl() {
204
872
    if (!RedeclLink.isFirst())
205
528
      return getNextRedeclaration();
206
344
    return nullptr;
207
344
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getPreviousDecl()
Line
Count
Source
203
139k
  decl_type *getPreviousDecl() {
204
139k
    if (!RedeclLink.isFirst())
205
101k
      return getNextRedeclaration();
206
37.9k
    return nullptr;
207
37.9k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getPreviousDecl()
Line
Count
Source
203
7.40k
  decl_type *getPreviousDecl() {
204
7.40k
    if (!RedeclLink.isFirst())
205
3.26k
      return getNextRedeclaration();
206
4.13k
    return nullptr;
207
4.13k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getPreviousDecl()
Line
Count
Source
203
1.81M
  decl_type *getPreviousDecl() {
204
1.81M
    if (!RedeclLink.isFirst())
205
283k
      return getNextRedeclaration();
206
1.53M
    return nullptr;
207
1.53M
  }
clang::Redeclarable<clang::NamespaceDecl>::getPreviousDecl()
Line
Count
Source
203
59.6k
  decl_type *getPreviousDecl() {
204
59.6k
    if (!RedeclLink.isFirst())
205
30.4k
      return getNextRedeclaration();
206
29.2k
    return nullptr;
207
29.2k
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getPreviousDecl()
Line
Count
Source
203
4
  decl_type *getPreviousDecl() {
204
4
    if (!RedeclLink.isFirst())
205
0
      return getNextRedeclaration();
206
4
    return nullptr;
207
4
  }
208
4.62M
  const decl_type *getPreviousDecl() const {
209
4.62M
    return const_cast<decl_type *>(
210
4.62M
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
4.62M
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getPreviousDecl() const
Line
Count
Source
208
914k
  const decl_type *getPreviousDecl() const {
209
914k
    return const_cast<decl_type *>(
210
914k
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
914k
  }
clang::Redeclarable<clang::VarDecl>::getPreviousDecl() const
Line
Count
Source
208
1.51M
  const decl_type *getPreviousDecl() const {
209
1.51M
    return const_cast<decl_type *>(
210
1.51M
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
1.51M
  }
clang::Redeclarable<clang::FunctionDecl>::getPreviousDecl() const
Line
Count
Source
208
2.13M
  const decl_type *getPreviousDecl() const {
209
2.13M
    return const_cast<decl_type *>(
210
2.13M
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
2.13M
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getPreviousDecl() const
Line
Count
Source
208
43.3k
  const decl_type *getPreviousDecl() const {
209
43.3k
    return const_cast<decl_type *>(
210
43.3k
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
43.3k
  }
clang::Redeclarable<clang::NamespaceDecl>::getPreviousDecl() const
Line
Count
Source
208
153
  const decl_type *getPreviousDecl() const {
209
153
    return const_cast<decl_type *>(
210
153
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
153
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getPreviousDecl() const
Line
Count
Source
208
4
  const decl_type *getPreviousDecl() const {
209
4
    return const_cast<decl_type *>(
210
4
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
4
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getPreviousDecl() const
Line
Count
Source
208
25
  const decl_type *getPreviousDecl() const {
209
25
    return const_cast<decl_type *>(
210
25
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
25
  }
clang::Redeclarable<clang::TagDecl>::getPreviousDecl() const
Line
Count
Source
208
3.54k
  const decl_type *getPreviousDecl() const {
209
3.54k
    return const_cast<decl_type *>(
210
3.54k
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
3.54k
  }
clang::Redeclarable<clang::TypedefNameDecl>::getPreviousDecl() const
Line
Count
Source
208
2.53k
  const decl_type *getPreviousDecl() const {
209
2.53k
    return const_cast<decl_type *>(
210
2.53k
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
2.53k
  }
clang::Redeclarable<clang::UsingShadowDecl>::getPreviousDecl() const
Line
Count
Source
208
29
  const decl_type *getPreviousDecl() const {
209
29
    return const_cast<decl_type *>(
210
29
                 static_cast<const decl_type*>(this))->getPreviousDecl();
211
29
  }
212
213
  /// Return the first declaration of this declaration or itself if this
214
  /// is the only declaration.
215
975M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::VarDecl>::getFirstDecl()
Line
Count
Source
215
191M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::FunctionDecl>::getFirstDecl()
Line
Count
Source
215
388M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::TypedefNameDecl>::getFirstDecl()
Line
Count
Source
215
18.2M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::TagDecl>::getFirstDecl()
Line
Count
Source
215
297M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::NamespaceAliasDecl>::getFirstDecl()
Line
Count
Source
215
409
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::UsingShadowDecl>::getFirstDecl()
Line
Count
Source
215
1.26M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getFirstDecl()
Line
Count
Source
215
3.07M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::ObjCProtocolDecl>::getFirstDecl()
Line
Count
Source
215
350k
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getFirstDecl()
Line
Count
Source
215
69.3M
  decl_type *getFirstDecl() { return First; }
clang::Redeclarable<clang::NamespaceDecl>::getFirstDecl()
Line
Count
Source
215
5.16M
  decl_type *getFirstDecl() { return First; }
216
217
  /// Return the first declaration of this declaration or itself if this
218
  /// is the only declaration.
219
41.7M
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::TypedefNameDecl>::getFirstDecl() const
Line
Count
Source
219
143
  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
219
2.18k
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getFirstDecl() const
Line
Count
Source
219
71.0k
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::VarDecl>::getFirstDecl() const
Line
Count
Source
219
15.7M
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::FunctionDecl>::getFirstDecl() const
Line
Count
Source
219
20.5M
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getFirstDecl() const
Line
Count
Source
219
5.09M
  const decl_type *getFirstDecl() const { return First; }
clang::Redeclarable<clang::TagDecl>::getFirstDecl() const
Line
Count
Source
219
274k
  const decl_type *getFirstDecl() const { return First; }
220
221
  /// True if this is the first declaration in its redeclaration chain.
222
381M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::TagDecl>::isFirstDecl() const
Line
Count
Source
222
40.3M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::VarDecl>::isFirstDecl() const
Line
Count
Source
222
25.0M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::FunctionDecl>::isFirstDecl() const
Line
Count
Source
222
28.5M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::NamespaceDecl>::isFirstDecl() const
Line
Count
Source
222
286M
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::ObjCInterfaceDecl>::isFirstDecl() const
Line
Count
Source
222
199k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::ObjCProtocolDecl>::isFirstDecl() const
Line
Count
Source
222
31.7k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::TypedefNameDecl>::isFirstDecl() const
Line
Count
Source
222
113k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::NamespaceAliasDecl>::isFirstDecl() const
Line
Count
Source
222
16
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::UsingShadowDecl>::isFirstDecl() const
Line
Count
Source
222
1.87k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::isFirstDecl() const
Line
Count
Source
222
844k
  bool isFirstDecl() const { return RedeclLink.isFirst(); }
223
224
  /// Returns the most recent (re)declaration of this declaration.
225
379M
  decl_type *getMostRecentDecl() {
226
379M
    return getFirstDecl()->getNextRedeclaration();
227
379M
  }
clang::Redeclarable<clang::VarDecl>::getMostRecentDecl()
Line
Count
Source
225
63.8M
  decl_type *getMostRecentDecl() {
226
63.8M
    return getFirstDecl()->getNextRedeclaration();
227
63.8M
  }
clang::Redeclarable<clang::FunctionDecl>::getMostRecentDecl()
Line
Count
Source
225
39.1M
  decl_type *getMostRecentDecl() {
226
39.1M
    return getFirstDecl()->getNextRedeclaration();
227
39.1M
  }
clang::Redeclarable<clang::TypedefNameDecl>::getMostRecentDecl()
Line
Count
Source
225
969k
  decl_type *getMostRecentDecl() {
226
969k
    return getFirstDecl()->getNextRedeclaration();
227
969k
  }
clang::Redeclarable<clang::TagDecl>::getMostRecentDecl()
Line
Count
Source
225
261M
  decl_type *getMostRecentDecl() {
226
261M
    return getFirstDecl()->getNextRedeclaration();
227
261M
  }
clang::Redeclarable<clang::UsingShadowDecl>::getMostRecentDecl()
Line
Count
Source
225
342k
  decl_type *getMostRecentDecl() {
226
342k
    return getFirstDecl()->getNextRedeclaration();
227
342k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getMostRecentDecl()
Line
Count
Source
225
315k
  decl_type *getMostRecentDecl() {
226
315k
    return getFirstDecl()->getNextRedeclaration();
227
315k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getMostRecentDecl()
Line
Count
Source
225
225k
  decl_type *getMostRecentDecl() {
226
225k
    return getFirstDecl()->getNextRedeclaration();
227
225k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getMostRecentDecl()
Line
Count
Source
225
8.68M
  decl_type *getMostRecentDecl() {
226
8.68M
    return getFirstDecl()->getNextRedeclaration();
227
8.68M
  }
clang::Redeclarable<clang::NamespaceDecl>::getMostRecentDecl()
Line
Count
Source
225
4.93M
  decl_type *getMostRecentDecl() {
226
4.93M
    return getFirstDecl()->getNextRedeclaration();
227
4.93M
  }
clang::Redeclarable<clang::NamespaceAliasDecl>::getMostRecentDecl()
Line
Count
Source
225
115
  decl_type *getMostRecentDecl() {
226
115
    return getFirstDecl()->getNextRedeclaration();
227
115
  }
228
229
  /// Returns the most recent (re)declaration of this declaration.
230
5.83M
  const decl_type *getMostRecentDecl() const {
231
5.83M
    return getFirstDecl()->getNextRedeclaration();
232
5.83M
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::getMostRecentDecl() const
Line
Count
Source
230
1.55k
  const decl_type *getMostRecentDecl() const {
231
1.55k
    return getFirstDecl()->getNextRedeclaration();
232
1.55k
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::getMostRecentDecl() const
Line
Count
Source
230
71.0k
  const decl_type *getMostRecentDecl() const {
231
71.0k
    return getFirstDecl()->getNextRedeclaration();
232
71.0k
  }
clang::Redeclarable<clang::FunctionDecl>::getMostRecentDecl() const
Line
Count
Source
230
727k
  const decl_type *getMostRecentDecl() const {
231
727k
    return getFirstDecl()->getNextRedeclaration();
232
727k
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::getMostRecentDecl() const
Line
Count
Source
230
5.03M
  const decl_type *getMostRecentDecl() const {
231
5.03M
    return getFirstDecl()->getNextRedeclaration();
232
5.03M
  }
clang::Redeclarable<clang::VarDecl>::getMostRecentDecl() const
Line
Count
Source
230
1.13k
  const decl_type *getMostRecentDecl() const {
231
1.13k
    return getFirstDecl()->getNextRedeclaration();
232
1.13k
  }
clang::Redeclarable<clang::TagDecl>::getMostRecentDecl() const
Line
Count
Source
230
165
  const decl_type *getMostRecentDecl() const {
231
165
    return getFirstDecl()->getNextRedeclaration();
232
165
  }
233
234
  /// Set the previous declaration. If PrevDecl is NULL, set this as the
235
  /// first and only declaration.
236
  void setPreviousDecl(decl_type *PrevDecl);
237
238
  /// Iterates through all the redeclarations of the same decl.
239
  class redecl_iterator {
240
    /// Current - The current declaration.
241
    decl_type *Current = nullptr;
242
    decl_type *Starter;
243
    bool PassedFirst = false;
244
245
  public:
246
    using value_type = decl_type *;
247
    using reference = decl_type *;
248
    using pointer = decl_type *;
249
    using iterator_category = std::forward_iterator_tag;
250
    using difference_type = std::ptrdiff_t;
251
252
259M
    redecl_iterator() = default;
clang::Redeclarable<clang::VarDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
252
42.0M
    redecl_iterator() = default;
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
252
26.3M
    redecl_iterator() = default;
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
252
93.1k
    redecl_iterator() = default;
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
252
22.5k
    redecl_iterator() = default;
clang::Redeclarable<clang::TagDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
252
191M
    redecl_iterator() = default;
clang::Redeclarable<clang::RedeclarableTemplateDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
252
411k
    redecl_iterator() = default;
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::redecl_iterator()
Line
Count
Source
252
913
    redecl_iterator() = default;
253
259M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::VarDecl>::redecl_iterator::redecl_iterator(clang::VarDecl*)
Line
Count
Source
253
42.0M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::redecl_iterator(clang::FunctionDecl*)
Line
Count
Source
253
26.3M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::redecl_iterator(clang::ObjCInterfaceDecl*)
Line
Count
Source
253
93.1k
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::redecl_iterator(clang::ObjCProtocolDecl*)
Line
Count
Source
253
22.5k
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::TagDecl>::redecl_iterator::redecl_iterator(clang::TagDecl*)
Line
Count
Source
253
191M
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::RedeclarableTemplateDecl>::redecl_iterator::redecl_iterator(clang::RedeclarableTemplateDecl*)
Line
Count
Source
253
411k
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::redecl_iterator(clang::UsingShadowDecl*)
Line
Count
Source
253
913
    explicit redecl_iterator(decl_type *C) : Current(C), Starter(C) {}
254
255
278M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::VarDecl>::redecl_iterator::operator*() const
Line
Count
Source
255
48.0M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::operator*() const
Line
Count
Source
255
27.3M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::operator*() const
Line
Count
Source
255
137k
    reference operator*() const { return Current; }
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::operator*() const
Line
Count
Source
255
28.8k
    reference operator*() const { return Current; }
clang::Redeclarable<clang::TagDecl>::redecl_iterator::operator*() const
Line
Count
Source
255
202M
    reference operator*() const { return Current; }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::redecl_iterator::operator*() const
Line
Count
Source
255
459k
    reference operator*() const { return Current; }
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::operator*() const
Line
Count
Source
255
921
    reference operator*() const { return Current; }
256
    pointer operator->() const { return Current; }
257
258
73.9M
    redecl_iterator& operator++() {
259
73.9M
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
73.9M
      if (Current->isFirstDecl()) {
262
67.1M
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
67.1M
        PassedFirst = true;
268
67.1M
      }
269
270
      // Get either previous decl or latest decl.
271
73.9M
      decl_type *Next = Current->getNextRedeclaration();
272
55.5M
      Current = (Next != Starter) ? 
Next18.3M
: nullptr;
273
73.9M
      return *this;
274
73.9M
    }
clang::Redeclarable<clang::VarDecl>::redecl_iterator::operator++()
Line
Count
Source
258
22.3M
    redecl_iterator& operator++() {
259
22.3M
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
22.3M
      if (Current->isFirstDecl()) {
262
19.4M
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
19.4M
        PassedFirst = true;
268
19.4M
      }
269
270
      // Get either previous decl or latest decl.
271
22.3M
      decl_type *Next = Current->getNextRedeclaration();
272
16.2M
      Current = (Next != Starter) ? 
Next6.07M
: nullptr;
273
22.3M
      return *this;
274
22.3M
    }
clang::Redeclarable<clang::FunctionDecl>::redecl_iterator::operator++()
Line
Count
Source
258
14.5M
    redecl_iterator& operator++() {
259
14.5M
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
14.5M
      if (Current->isFirstDecl()) {
262
14.0M
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
14.0M
        PassedFirst = true;
268
14.0M
      }
269
270
      // Get either previous decl or latest decl.
271
14.5M
      decl_type *Next = Current->getNextRedeclaration();
272
13.5M
      Current = (Next != Starter) ? 
Next972k
: nullptr;
273
14.5M
      return *this;
274
14.5M
    }
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator::operator++()
Line
Count
Source
258
137k
    redecl_iterator& operator++() {
259
137k
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
137k
      if (Current->isFirstDecl()) {
262
93.1k
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
93.1k
        PassedFirst = true;
268
93.1k
      }
269
270
      // Get either previous decl or latest decl.
271
137k
      decl_type *Next = Current->getNextRedeclaration();
272
93.1k
      Current = (Next != Starter) ? 
Next44.6k
: nullptr;
273
137k
      return *this;
274
137k
    }
clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator::operator++()
Line
Count
Source
258
28.8k
    redecl_iterator& operator++() {
259
28.8k
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
28.8k
      if (Current->isFirstDecl()) {
262
22.5k
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
22.5k
        PassedFirst = true;
268
22.5k
      }
269
270
      // Get either previous decl or latest decl.
271
28.8k
      decl_type *Next = Current->getNextRedeclaration();
272
22.5k
      Current = (Next != Starter) ? 
Next6.24k
: nullptr;
273
28.8k
      return *this;
274
28.8k
    }
clang::Redeclarable<clang::TagDecl>::redecl_iterator::operator++()
Line
Count
Source
258
36.5M
    redecl_iterator& operator++() {
259
36.5M
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
36.5M
      if (Current->isFirstDecl()) {
262
33.1M
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
33.1M
        PassedFirst = true;
268
33.1M
      }
269
270
      // Get either previous decl or latest decl.
271
36.5M
      decl_type *Next = Current->getNextRedeclaration();
272
25.2M
      Current = (Next != Starter) ? 
Next11.2M
: nullptr;
273
36.5M
      return *this;
274
36.5M
    }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::redecl_iterator::operator++()
Line
Count
Source
258
459k
    redecl_iterator& operator++() {
259
459k
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
459k
      if (Current->isFirstDecl()) {
262
411k
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
411k
        PassedFirst = true;
268
411k
      }
269
270
      // Get either previous decl or latest decl.
271
459k
      decl_type *Next = Current->getNextRedeclaration();
272
411k
      Current = (Next != Starter) ? 
Next48.0k
: nullptr;
273
459k
      return *this;
274
459k
    }
clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator::operator++()
Line
Count
Source
258
921
    redecl_iterator& operator++() {
259
921
      assert(Current && "Advancing while iterator has reached end");
260
      // Sanity check to avoid infinite loop on invalid redecl chain.
261
921
      if (Current->isFirstDecl()) {
262
913
        if (PassedFirst) {
263
0
          assert(0 && "Passed first decl twice, invalid redecl chain!");
264
0
          Current = nullptr;
265
0
          return *this;
266
0
        }
267
913
        PassedFirst = true;
268
913
      }
269
270
      // Get either previous decl or latest decl.
271
921
      decl_type *Next = Current->getNextRedeclaration();
272
913
      Current = (Next != Starter) ? 
Next8
: nullptr;
273
921
      return *this;
274
921
    }
275
276
    redecl_iterator operator++(int) {
277
      redecl_iterator tmp(*this);
278
      ++(*this);
279
      return tmp;
280
    }
281
282
11
    friend bool operator==(redecl_iterator x, redecl_iterator y) {
283
11
      return x.Current == y.Current;
284
11
    }
285
333M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
333M
      return x.Current != y.Current;
287
333M
    }
clang::operator!=(clang::Redeclarable<clang::VarDecl>::redecl_iterator, clang::Redeclarable<clang::VarDecl>::redecl_iterator)
Line
Count
Source
285
64.3M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
64.3M
      return x.Current != y.Current;
287
64.3M
    }
clang::operator!=(clang::Redeclarable<clang::FunctionDecl>::redecl_iterator, clang::Redeclarable<clang::FunctionDecl>::redecl_iterator)
Line
Count
Source
285
40.8M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
40.8M
      return x.Current != y.Current;
287
40.8M
    }
clang::operator!=(clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator, clang::Redeclarable<clang::ObjCInterfaceDecl>::redecl_iterator)
Line
Count
Source
285
230k
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
230k
      return x.Current != y.Current;
287
230k
    }
clang::operator!=(clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator, clang::Redeclarable<clang::ObjCProtocolDecl>::redecl_iterator)
Line
Count
Source
285
51.3k
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
51.3k
      return x.Current != y.Current;
287
51.3k
    }
clang::operator!=(clang::Redeclarable<clang::TagDecl>::redecl_iterator, clang::Redeclarable<clang::TagDecl>::redecl_iterator)
Line
Count
Source
285
227M
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
227M
      return x.Current != y.Current;
287
227M
    }
clang::operator!=(clang::Redeclarable<clang::RedeclarableTemplateDecl>::redecl_iterator, clang::Redeclarable<clang::RedeclarableTemplateDecl>::redecl_iterator)
Line
Count
Source
285
871k
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
871k
      return x.Current != y.Current;
287
871k
    }
clang::operator!=(clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator, clang::Redeclarable<clang::UsingShadowDecl>::redecl_iterator)
Line
Count
Source
285
1.83k
    friend bool operator!=(redecl_iterator x, redecl_iterator y) {
286
1.83k
      return x.Current != y.Current;
287
1.83k
    }
288
  };
289
290
  using redecl_range = llvm::iterator_range<redecl_iterator>;
291
292
  /// Returns an iterator range for all the redeclarations of the same
293
  /// decl. It will iterate at least once (when this decl is the only one).
294
259M
  redecl_range redecls() const {
295
259M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
259M
                            static_cast<const decl_type *>(this))),
297
259M
                        redecl_iterator());
298
259M
  }
clang::Redeclarable<clang::VarDecl>::redecls() const
Line
Count
Source
294
42.0M
  redecl_range redecls() const {
295
42.0M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
42.0M
                            static_cast<const decl_type *>(this))),
297
42.0M
                        redecl_iterator());
298
42.0M
  }
clang::Redeclarable<clang::FunctionDecl>::redecls() const
Line
Count
Source
294
26.3M
  redecl_range redecls() const {
295
26.3M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
26.3M
                            static_cast<const decl_type *>(this))),
297
26.3M
                        redecl_iterator());
298
26.3M
  }
clang::Redeclarable<clang::ObjCInterfaceDecl>::redecls() const
Line
Count
Source
294
93.1k
  redecl_range redecls() const {
295
93.1k
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
93.1k
                            static_cast<const decl_type *>(this))),
297
93.1k
                        redecl_iterator());
298
93.1k
  }
clang::Redeclarable<clang::ObjCProtocolDecl>::redecls() const
Line
Count
Source
294
22.5k
  redecl_range redecls() const {
295
22.5k
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
22.5k
                            static_cast<const decl_type *>(this))),
297
22.5k
                        redecl_iterator());
298
22.5k
  }
clang::Redeclarable<clang::TagDecl>::redecls() const
Line
Count
Source
294
191M
  redecl_range redecls() const {
295
191M
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
191M
                            static_cast<const decl_type *>(this))),
297
191M
                        redecl_iterator());
298
191M
  }
clang::Redeclarable<clang::RedeclarableTemplateDecl>::redecls() const
Line
Count
Source
294
411k
  redecl_range redecls() const {
295
411k
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
411k
                            static_cast<const decl_type *>(this))),
297
411k
                        redecl_iterator());
298
411k
  }
clang::Redeclarable<clang::UsingShadowDecl>::redecls() const
Line
Count
Source
294
913
  redecl_range redecls() const {
295
913
    return redecl_range(redecl_iterator(const_cast<decl_type *>(
296
913
                            static_cast<const decl_type *>(this))),
297
913
                        redecl_iterator());
298
913
  }
299
300
  redecl_iterator redecls_begin() const { return redecls().begin(); }
301
11
  redecl_iterator redecls_end() const { return redecls().end(); }
302
};
303
304
/// Get the primary declaration for a declaration from an AST file. That
305
/// will be the first-loaded declaration.
306
Decl *getPrimaryMergedDecl(Decl *D);
307
308
/// Provides common interface for the Decls that cannot be redeclared,
309
/// but can be merged if the same declaration is brought in from multiple
310
/// modules.
311
template<typename decl_type>
312
class Mergeable {
313
public:
314
  Mergeable() = default;
315
316
  /// Return the first declaration of this declaration or itself if this
317
  /// is the only declaration.
318
10.1M
  decl_type *getFirstDecl() {
319
10.1M
    auto *D = static_cast<decl_type *>(this);
320
10.1M
    if (!D->isFromASTFile())
321
9.99M
      return D;
322
104k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
104k
  }
clang::Mergeable<clang::FieldDecl>::getFirstDecl()
Line
Count
Source
318
8.99M
  decl_type *getFirstDecl() {
319
8.99M
    auto *D = static_cast<decl_type *>(this);
320
8.99M
    if (!D->isFromASTFile())
321
8.89M
      return D;
322
93.2k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
93.2k
  }
clang::Mergeable<clang::EnumConstantDecl>::getFirstDecl()
Line
Count
Source
318
836k
  decl_type *getFirstDecl() {
319
836k
    auto *D = static_cast<decl_type *>(this);
320
836k
    if (!D->isFromASTFile())
321
828k
      return D;
322
7.26k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
7.26k
  }
clang::Mergeable<clang::IndirectFieldDecl>::getFirstDecl()
Line
Count
Source
318
9.78k
  decl_type *getFirstDecl() {
319
9.78k
    auto *D = static_cast<decl_type *>(this);
320
9.78k
    if (!D->isFromASTFile())
321
8.09k
      return D;
322
1.69k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
1.69k
  }
clang::Mergeable<clang::UsingDecl>::getFirstDecl()
Line
Count
Source
318
263k
  decl_type *getFirstDecl() {
319
263k
    auto *D = static_cast<decl_type *>(this);
320
263k
    if (!D->isFromASTFile())
321
261k
      return D;
322
1.69k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
1.69k
  }
clang::Mergeable<clang::UsingPackDecl>::getFirstDecl()
Line
Count
Source
318
6
  decl_type *getFirstDecl() {
319
6
    auto *D = static_cast<decl_type *>(this);
320
6
    if (!D->isFromASTFile())
321
4
      return D;
322
2
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
2
  }
clang::Mergeable<clang::UnresolvedUsingValueDecl>::getFirstDecl()
Line
Count
Source
318
1.48k
  decl_type *getFirstDecl() {
319
1.48k
    auto *D = static_cast<decl_type *>(this);
320
1.48k
    if (!D->isFromASTFile())
321
1.35k
      return D;
322
134
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
134
  }
clang::Mergeable<clang::UnresolvedUsingTypenameDecl>::getFirstDecl()
Line
Count
Source
318
1.39k
  decl_type *getFirstDecl() {
319
1.39k
    auto *D = static_cast<decl_type *>(this);
320
1.39k
    if (!D->isFromASTFile())
321
882
      return D;
322
509
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
323
509
  }
324
325
  /// Return the first declaration of this declaration or itself if this
326
  /// is the only declaration.
327
1.15M
  const decl_type *getFirstDecl() const {
328
1.15M
    const auto *D = static_cast<const decl_type *>(this);
329
1.15M
    if (!D->isFromASTFile())
330
1.09M
      return D;
331
51.1k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
332
51.1k
  }
clang::Mergeable<clang::FieldDecl>::getFirstDecl() const
Line
Count
Source
327
1.15M
  const decl_type *getFirstDecl() const {
328
1.15M
    const auto *D = static_cast<const decl_type *>(this);
329
1.15M
    if (!D->isFromASTFile())
330
1.09M
      return D;
331
51.1k
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
332
51.1k
  }
clang::Mergeable<clang::EnumConstantDecl>::getFirstDecl() const
Line
Count
Source
327
86
  const decl_type *getFirstDecl() const {
328
86
    const auto *D = static_cast<const decl_type *>(this);
329
86
    if (!D->isFromASTFile())
330
80
      return D;
331
6
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
332
6
  }
clang::Mergeable<clang::IndirectFieldDecl>::getFirstDecl() const
Line
Count
Source
327
62
  const decl_type *getFirstDecl() const {
328
62
    const auto *D = static_cast<const decl_type *>(this);
329
62
    if (!D->isFromASTFile())
330
41
      return D;
331
21
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
332
21
  }
clang::Mergeable<clang::UsingDecl>::getFirstDecl() const
Line
Count
Source
327
25
  const decl_type *getFirstDecl() const {
328
25
    const auto *D = static_cast<const decl_type *>(this);
329
25
    if (!D->isFromASTFile())
330
22
      return D;
331
3
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
332
3
  }
Unexecuted instantiation: clang::Mergeable<clang::UsingPackDecl>::getFirstDecl() const
clang::Mergeable<clang::UnresolvedUsingValueDecl>::getFirstDecl() const
Line
Count
Source
327
1
  const decl_type *getFirstDecl() const {
328
1
    const auto *D = static_cast<const decl_type *>(this);
329
1
    if (!D->isFromASTFile())
330
1
      return D;
331
0
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
332
0
  }
clang::Mergeable<clang::UnresolvedUsingTypenameDecl>::getFirstDecl() const
Line
Count
Source
327
1
  const decl_type *getFirstDecl() const {
328
1
    const auto *D = static_cast<const decl_type *>(this);
329
1
    if (!D->isFromASTFile())
330
1
      return D;
331
0
    return cast<decl_type>(getPrimaryMergedDecl(const_cast<decl_type*>(D)));
332
0
  }
Unexecuted instantiation: clang::Mergeable<clang::LifetimeExtendedTemporaryDecl>::getFirstDecl() const
Unexecuted instantiation: clang::Mergeable<clang::ConceptDecl>::getFirstDecl() const
Unexecuted instantiation: clang::Mergeable<clang::MSGuidDecl>::getFirstDecl() const
333
334
  /// Returns true if this is the first declaration.
335
  bool isFirstDecl() const { return getFirstDecl() == this; }
336
};
337
338
/// A wrapper class around a pointer that always points to its canonical
339
/// declaration.
340
///
341
/// CanonicalDeclPtr<decl_type> behaves just like decl_type*, except we call
342
/// decl_type::getCanonicalDecl() on construction.
343
///
344
/// This is useful for hashtables that you want to be keyed on a declaration's
345
/// canonical decl -- if you use CanonicalDeclPtr as the key, you don't need to
346
/// remember to call getCanonicalDecl() everywhere.
347
template <typename decl_type> class CanonicalDeclPtr {
348
public:
349
1.66M
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::FunctionDecl>::CanonicalDeclPtr()
Line
Count
Source
349
356k
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::Decl const>::CanonicalDeclPtr()
Line
Count
Source
349
278k
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::Decl>::CanonicalDeclPtr()
Line
Count
Source
349
798k
  CanonicalDeclPtr() = default;
Unexecuted instantiation: clang::CanonicalDeclPtr<clang::VarDecl>::CanonicalDeclPtr()
clang::CanonicalDeclPtr<clang::CXXRecordDecl const>::CanonicalDeclPtr()
Line
Count
Source
349
142k
  CanonicalDeclPtr() = default;
clang::CanonicalDeclPtr<clang::VarDecl const>::CanonicalDeclPtr()
Line
Count
Source
349
87.6k
  CanonicalDeclPtr() = default;
350
  CanonicalDeclPtr(decl_type *Ptr)
351
4.25M
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::Decl>::CanonicalDeclPtr(clang::Decl*)
Line
Count
Source
351
1.08M
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::FunctionDecl>::CanonicalDeclPtr(clang::FunctionDecl*)
Line
Count
Source
351
529k
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::Decl const>::CanonicalDeclPtr(clang::Decl const*)
Line
Count
Source
351
2.49M
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::VarDecl>::CanonicalDeclPtr(clang::VarDecl*)
Line
Count
Source
351
96.7k
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::CXXRecordDecl const>::CanonicalDeclPtr(clang::CXXRecordDecl const*)
Line
Count
Source
351
25.2k
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
clang::CanonicalDeclPtr<clang::VarDecl const>::CanonicalDeclPtr(clang::VarDecl const*)
Line
Count
Source
351
23.3k
      : Ptr(Ptr ? Ptr->getCanonicalDecl() : nullptr) {}
352
  CanonicalDeclPtr(const CanonicalDeclPtr &) = default;
353
  CanonicalDeclPtr &operator=(const CanonicalDeclPtr &) = default;
354
355
205k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::FunctionDecl>::operator clang::FunctionDecl*()
Line
Count
Source
355
184k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::VarDecl>::operator clang::VarDecl*()
Line
Count
Source
355
1.08k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::Decl const>::operator clang::Decl const*()
Line
Count
Source
355
19.2k
  operator decl_type *() { return Ptr; }
clang::CanonicalDeclPtr<clang::VarDecl const>::operator clang::VarDecl const*()
Line
Count
Source
355
24
  operator decl_type *() { return Ptr; }
356
23.3M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::FunctionDecl>::operator clang::FunctionDecl const*() const
Line
Count
Source
356
2.39M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::Decl const>::operator clang::Decl const*() const
Line
Count
Source
356
4.30M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::Decl>::operator clang::Decl const*() const
Line
Count
Source
356
12.0M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::CXXRecordDecl const>::operator clang::CXXRecordDecl const*() const
Line
Count
Source
356
3.17M
  operator const decl_type *() const { return Ptr; }
clang::CanonicalDeclPtr<clang::VarDecl const>::operator clang::VarDecl const*() const
Line
Count
Source
356
1.43M
  operator const decl_type *() const { return Ptr; }
357
358
  decl_type *operator->() { return Ptr; }
359
4
  const decl_type *operator->() const { return Ptr; }
360
361
  decl_type &operator*() { return *Ptr; }
362
  const decl_type &operator*() const { return *Ptr; }
363
364
2.81k
  friend bool operator==(CanonicalDeclPtr LHS, CanonicalDeclPtr RHS) {
365
2.81k
    return LHS.Ptr == RHS.Ptr;
366
2.81k
  }
367
  friend bool operator!=(CanonicalDeclPtr LHS, CanonicalDeclPtr RHS) {
368
    return LHS.Ptr != RHS.Ptr;
369
  }
370
371
private:
372
  friend struct llvm::DenseMapInfo<CanonicalDeclPtr<decl_type>>;
373
  friend struct llvm::PointerLikeTypeTraits<CanonicalDeclPtr<decl_type>>;
374
375
  decl_type *Ptr = nullptr;
376
};
377
378
} // namespace clang
379
380
namespace llvm {
381
382
template <typename decl_type>
383
struct DenseMapInfo<clang::CanonicalDeclPtr<decl_type>> {
384
  using CanonicalDeclPtr = clang::CanonicalDeclPtr<decl_type>;
385
  using BaseInfo = DenseMapInfo<decl_type *>;
386
387
990k
  static CanonicalDeclPtr getEmptyKey() {
388
    // Construct our CanonicalDeclPtr this way because the regular constructor
389
    // would dereference P.Ptr, which is not allowed.
390
990k
    CanonicalDeclPtr P;
391
990k
    P.Ptr = BaseInfo::getEmptyKey();
392
990k
    return P;
393
990k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::getEmptyKey()
Line
Count
Source
387
182k
  static CanonicalDeclPtr getEmptyKey() {
388
    // Construct our CanonicalDeclPtr this way because the regular constructor
389
    // would dereference P.Ptr, which is not allowed.
390
182k
    CanonicalDeclPtr P;
391
182k
    P.Ptr = BaseInfo::getEmptyKey();
392
182k
    return P;
393
182k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::getEmptyKey()
Line
Count
Source
387
168k
  static CanonicalDeclPtr getEmptyKey() {
388
    // Construct our CanonicalDeclPtr this way because the regular constructor
389
    // would dereference P.Ptr, which is not allowed.
390
168k
    CanonicalDeclPtr P;
391
168k
    P.Ptr = BaseInfo::getEmptyKey();
392
168k
    return P;
393
168k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::getEmptyKey()
Line
Count
Source
387
489k
  static CanonicalDeclPtr getEmptyKey() {
388
    // Construct our CanonicalDeclPtr this way because the regular constructor
389
    // would dereference P.Ptr, which is not allowed.
390
489k
    CanonicalDeclPtr P;
391
489k
    P.Ptr = BaseInfo::getEmptyKey();
392
489k
    return P;
393
489k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::getEmptyKey()
Line
Count
Source
387
94.9k
  static CanonicalDeclPtr getEmptyKey() {
388
    // Construct our CanonicalDeclPtr this way because the regular constructor
389
    // would dereference P.Ptr, which is not allowed.
390
94.9k
    CanonicalDeclPtr P;
391
94.9k
    P.Ptr = BaseInfo::getEmptyKey();
392
94.9k
    return P;
393
94.9k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::getEmptyKey()
Line
Count
Source
387
55.8k
  static CanonicalDeclPtr getEmptyKey() {
388
    // Construct our CanonicalDeclPtr this way because the regular constructor
389
    // would dereference P.Ptr, which is not allowed.
390
55.8k
    CanonicalDeclPtr P;
391
55.8k
    P.Ptr = BaseInfo::getEmptyKey();
392
55.8k
    return P;
393
55.8k
  }
394
395
629k
  static CanonicalDeclPtr getTombstoneKey() {
396
629k
    CanonicalDeclPtr P;
397
629k
    P.Ptr = BaseInfo::getTombstoneKey();
398
629k
    return P;
399
629k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::getTombstoneKey()
Line
Count
Source
395
131k
  static CanonicalDeclPtr getTombstoneKey() {
396
131k
    CanonicalDeclPtr P;
397
131k
    P.Ptr = BaseInfo::getTombstoneKey();
398
131k
    return P;
399
131k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::getTombstoneKey()
Line
Count
Source
395
110k
  static CanonicalDeclPtr getTombstoneKey() {
396
110k
    CanonicalDeclPtr P;
397
110k
    P.Ptr = BaseInfo::getTombstoneKey();
398
110k
    return P;
399
110k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::getTombstoneKey()
Line
Count
Source
395
309k
  static CanonicalDeclPtr getTombstoneKey() {
396
309k
    CanonicalDeclPtr P;
397
309k
    P.Ptr = BaseInfo::getTombstoneKey();
398
309k
    return P;
399
309k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::getTombstoneKey()
Line
Count
Source
395
47.4k
  static CanonicalDeclPtr getTombstoneKey() {
396
47.4k
    CanonicalDeclPtr P;
397
47.4k
    P.Ptr = BaseInfo::getTombstoneKey();
398
47.4k
    return P;
399
47.4k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::getTombstoneKey()
Line
Count
Source
395
31.8k
  static CanonicalDeclPtr getTombstoneKey() {
396
31.8k
    CanonicalDeclPtr P;
397
31.8k
    P.Ptr = BaseInfo::getTombstoneKey();
398
31.8k
    return P;
399
31.8k
  }
400
401
459k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
402
459k
    return BaseInfo::getHashValue(P);
403
459k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::getHashValue(clang::CanonicalDeclPtr<clang::FunctionDecl> const&)
Line
Count
Source
401
124k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
402
124k
    return BaseInfo::getHashValue(P);
403
124k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::getHashValue(clang::CanonicalDeclPtr<clang::Decl const> const&)
Line
Count
Source
401
54.1k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
402
54.1k
    return BaseInfo::getHashValue(P);
403
54.1k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::getHashValue(clang::CanonicalDeclPtr<clang::Decl> const&)
Line
Count
Source
401
233k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
402
233k
    return BaseInfo::getHashValue(P);
403
233k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::getHashValue(clang::CanonicalDeclPtr<clang::CXXRecordDecl const> const&)
Line
Count
Source
401
25.2k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
402
25.2k
    return BaseInfo::getHashValue(P);
403
25.2k
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::getHashValue(clang::CanonicalDeclPtr<clang::VarDecl const> const&)
Line
Count
Source
401
22.6k
  static unsigned getHashValue(const CanonicalDeclPtr &P) {
402
22.6k
    return BaseInfo::getHashValue(P);
403
22.6k
  }
404
405
  static bool isEqual(const CanonicalDeclPtr &LHS,
406
11.4M
                      const CanonicalDeclPtr &RHS) {
407
11.4M
    return BaseInfo::isEqual(LHS, RHS);
408
11.4M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::FunctionDecl> >::isEqual(clang::CanonicalDeclPtr<clang::FunctionDecl> const&, clang::CanonicalDeclPtr<clang::FunctionDecl> const&)
Line
Count
Source
406
1.13M
                      const CanonicalDeclPtr &RHS) {
407
1.13M
    return BaseInfo::isEqual(LHS, RHS);
408
1.13M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl const> >::isEqual(clang::CanonicalDeclPtr<clang::Decl const> const&, clang::CanonicalDeclPtr<clang::Decl const> const&)
Line
Count
Source
406
2.12M
                      const CanonicalDeclPtr &RHS) {
407
2.12M
    return BaseInfo::isEqual(LHS, RHS);
408
2.12M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::Decl> >::isEqual(clang::CanonicalDeclPtr<clang::Decl> const&, clang::CanonicalDeclPtr<clang::Decl> const&)
Line
Count
Source
406
5.88M
                      const CanonicalDeclPtr &RHS) {
407
5.88M
    return BaseInfo::isEqual(LHS, RHS);
408
5.88M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::CXXRecordDecl const> >::isEqual(clang::CanonicalDeclPtr<clang::CXXRecordDecl const> const&, clang::CanonicalDeclPtr<clang::CXXRecordDecl const> const&)
Line
Count
Source
406
1.57M
                      const CanonicalDeclPtr &RHS) {
407
1.57M
    return BaseInfo::isEqual(LHS, RHS);
408
1.57M
  }
llvm::DenseMapInfo<clang::CanonicalDeclPtr<clang::VarDecl const> >::isEqual(clang::CanonicalDeclPtr<clang::VarDecl const> const&, clang::CanonicalDeclPtr<clang::VarDecl const> const&)
Line
Count
Source
406
704k
                      const CanonicalDeclPtr &RHS) {
407
704k
    return BaseInfo::isEqual(LHS, RHS);
408
704k
  }
409
};
410
411
template <typename decl_type>
412
struct PointerLikeTypeTraits<clang::CanonicalDeclPtr<decl_type>> {
413
603k
  static inline void *getAsVoidPointer(clang::CanonicalDeclPtr<decl_type> P) {
414
603k
    return P.Ptr;
415
603k
  }
416
  static inline clang::CanonicalDeclPtr<decl_type> getFromVoidPointer(void *P) {
417
    clang::CanonicalDeclPtr<decl_type> C;
418
    C.Ptr = PointerLikeTypeTraits<decl_type *>::getFromVoidPtr(P);
419
    return C;
420
  }
421
  static constexpr int NumLowBitsAvailable =
422
      PointerLikeTypeTraits<decl_type *>::NumLowBitsAvailable;
423
};
424
425
} // namespace llvm
426
427
#endif // LLVM_CLANG_AST_REDECLARABLE_H