Coverage Report

Created: 2020-02-25 14:32

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/AST/ExternalASTSource.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- ExternalASTSource.cpp - Abstract External AST Interface ------------===//
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 provides the default implementation of the ExternalASTSource
10
//  interface, which enables construction of AST nodes from some external
11
//  source.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#include "clang/AST/ExternalASTSource.h"
16
#include "clang/AST/ASTContext.h"
17
#include "clang/AST/DeclarationName.h"
18
#include "clang/Basic/IdentifierTable.h"
19
#include "clang/Basic/LLVM.h"
20
#include "clang/Basic/Module.h"
21
#include "llvm/ADT/None.h"
22
#include "llvm/Support/ErrorHandling.h"
23
#include <cstdint>
24
25
using namespace clang;
26
27
char ExternalASTSource::ID;
28
29
39.6k
ExternalASTSource::~ExternalASTSource() = default;
30
31
llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
32
0
ExternalASTSource::getSourceDescriptor(unsigned ID) {
33
0
  return None;
34
0
}
35
36
ExternalASTSource::ExtKind
37
2.43M
ExternalASTSource::hasExternalDefinitions(const Decl *D) {
38
2.43M
  return EK_ReplyHazy;
39
2.43M
}
40
41
ExternalASTSource::ASTSourceDescriptor::ASTSourceDescriptor(const Module &M)
42
780k
  : Signature(M.Signature), ClangModule(&M) {
43
780k
  if (M.Directory)
44
578k
    Path = M.Directory->getName();
45
780k
  if (auto *File = M.getASTFile())
46
38.5k
    ASTFile = File->getName();
47
780k
}
48
49
30.2k
std::string ExternalASTSource::ASTSourceDescriptor::getModuleName() const {
50
30.2k
  if (ClangModule)
51
30.0k
    return ClangModule->Name;
52
134
  else
53
134
    return std::string(PCHModuleName);
54
30.2k
}
55
56
void ExternalASTSource::FindFileRegionDecls(FileID File, unsigned Offset,
57
                                            unsigned Length,
58
0
                                            SmallVectorImpl<Decl *> &Decls) {}
59
60
356k
void ExternalASTSource::CompleteRedeclChain(const Decl *D) {}
61
62
53
void ExternalASTSource::CompleteType(TagDecl *Tag) {}
63
64
0
void ExternalASTSource::CompleteType(ObjCInterfaceDecl *Class) {}
65
66
37
void ExternalASTSource::ReadComments() {}
67
68
33.8k
void ExternalASTSource::StartedDeserializing() {}
69
70
33.8k
void ExternalASTSource::FinishedDeserializing() {}
71
72
89
void ExternalASTSource::StartTranslationUnit(ASTConsumer *Consumer) {}
73
74
0
void ExternalASTSource::PrintStats() {}
75
76
bool ExternalASTSource::layoutRecordType(
77
    const RecordDecl *Record, uint64_t &Size, uint64_t &Alignment,
78
    llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
79
    llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
80
130k
    llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets) {
81
130k
  return false;
82
130k
}
83
84
33
Decl *ExternalASTSource::GetExternalDecl(uint32_t ID) {
85
33
  return nullptr;
86
33
}
87
88
0
Selector ExternalASTSource::GetExternalSelector(uint32_t ID) {
89
0
  return Selector();
90
0
}
91
92
0
uint32_t ExternalASTSource::GetNumExternalSelectors() {
93
0
   return 0;
94
0
}
95
96
14
Stmt *ExternalASTSource::GetExternalDeclStmt(uint64_t Offset) {
97
14
  return nullptr;
98
14
}
99
100
CXXCtorInitializer **
101
2
ExternalASTSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
102
2
  return nullptr;
103
2
}
104
105
CXXBaseSpecifier *
106
13
ExternalASTSource::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
107
13
  return nullptr;
108
13
}
109
110
bool
111
ExternalASTSource::FindExternalVisibleDeclsByName(const DeclContext *DC,
112
2.93k
                                                  DeclarationName Name) {
113
2.93k
  return false;
114
2.93k
}
115
116
40
void ExternalASTSource::completeVisibleDeclsMap(const DeclContext *DC) {}
117
118
void ExternalASTSource::FindExternalLexicalDecls(
119
    const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
120
85
    SmallVectorImpl<Decl *> &Result) {}
121
122
0
void ExternalASTSource::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {}
123
124
10.1k
uint32_t ExternalASTSource::incrementGeneration(ASTContext &C) {
125
10.1k
  uint32_t OldGeneration = CurrentGeneration;
126
10.1k
127
10.1k
  // Make sure the generation of the topmost external source for the context is
128
10.1k
  // incremented. That might not be us.
129
10.1k
  auto *P = C.getExternalSource();
130
10.1k
  if (P && 
P != this10.1k
)
131
539
    CurrentGeneration = P->incrementGeneration(C);
132
9.65k
  else {
133
9.65k
    // FIXME: Only bump the generation counter if the current generation number
134
9.65k
    // has been observed?
135
9.65k
    if (!++CurrentGeneration)
136
0
      llvm::report_fatal_error("generation counter overflowed", false);
137
10.1k
  }
138
10.1k
139
10.1k
  return OldGeneration;
140
10.1k
}