Coverage Report

Created: 2020-09-22 08:39

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/lib/Sema/MultiplexExternalSemaSource.cpp
Line
Count
Source (jump to first uncovered line)
1
//===--- MultiplexExternalSemaSource.cpp  ---------------------------------===//
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 implements the event dispatching to the subscribed clients.
10
//
11
//===----------------------------------------------------------------------===//
12
#include "clang/Sema/MultiplexExternalSemaSource.h"
13
#include "clang/AST/DeclContextInternals.h"
14
#include "clang/Sema/Lookup.h"
15
16
using namespace clang;
17
18
char MultiplexExternalSemaSource::ID;
19
20
///Constructs a new multiplexing external sema source and appends the
21
/// given element to it.
22
///
23
MultiplexExternalSemaSource::MultiplexExternalSemaSource(ExternalSemaSource &s1,
24
153
                                                        ExternalSemaSource &s2){
25
153
  Sources.push_back(&s1);
26
153
  Sources.push_back(&s2);
27
153
}
28
29
// pin the vtable here.
30
146
MultiplexExternalSemaSource::~MultiplexExternalSemaSource() {}
31
32
///Appends new source to the source list.
33
///
34
///\param[in] source - An ExternalSemaSource.
35
///
36
2
void MultiplexExternalSemaSource::addSource(ExternalSemaSource &source) {
37
2
  Sources.push_back(&source);
38
2
}
39
40
//===----------------------------------------------------------------------===//
41
// ExternalASTSource.
42
//===----------------------------------------------------------------------===//
43
44
33
Decl *MultiplexExternalSemaSource::GetExternalDecl(uint32_t ID) {
45
66
  for(size_t i = 0; i < Sources.size(); 
++i33
)
46
66
    if (Decl *Result = Sources[i]->GetExternalDecl(ID))
47
33
      return Result;
48
0
  return nullptr;
49
33
}
50
51
0
void MultiplexExternalSemaSource::CompleteRedeclChain(const Decl *D) {
52
0
  for (size_t i = 0; i < Sources.size(); ++i)
53
0
    Sources[i]->CompleteRedeclChain(D);
54
0
}
55
56
0
Selector MultiplexExternalSemaSource::GetExternalSelector(uint32_t ID) {
57
0
  Selector Sel;
58
0
  for(size_t i = 0; i < Sources.size(); ++i) {
59
0
    Sel = Sources[i]->GetExternalSelector(ID);
60
0
    if (!Sel.isNull())
61
0
      return Sel;
62
0
  }
63
0
  return Sel;
64
0
}
65
66
0
uint32_t MultiplexExternalSemaSource::GetNumExternalSelectors() {
67
0
  uint32_t total = 0;
68
0
  for(size_t i = 0; i < Sources.size(); ++i)
69
0
    total += Sources[i]->GetNumExternalSelectors();
70
0
  return total;
71
0
}
72
73
14
Stmt *MultiplexExternalSemaSource::GetExternalDeclStmt(uint64_t Offset) {
74
28
  for(size_t i = 0; i < Sources.size(); 
++i14
)
75
28
    if (Stmt *Result = Sources[i]->GetExternalDeclStmt(Offset))
76
14
      return Result;
77
0
  return nullptr;
78
14
}
79
80
CXXBaseSpecifier *MultiplexExternalSemaSource::GetExternalCXXBaseSpecifiers(
81
13
                                                               uint64_t Offset){
82
26
  for(size_t i = 0; i < Sources.size(); 
++i13
)
83
26
    if (CXXBaseSpecifier *R = Sources[i]->GetExternalCXXBaseSpecifiers(Offset))
84
13
      return R;
85
0
  return nullptr;
86
13
}
87
88
CXXCtorInitializer **
89
2
MultiplexExternalSemaSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
90
2
  for (auto *S : Sources)
91
4
    if (auto *R = S->GetExternalCXXCtorInitializers(Offset))
92
2
      return R;
93
0
  return nullptr;
94
2
}
95
96
ExternalASTSource::ExtKind
97
424
MultiplexExternalSemaSource::hasExternalDefinitions(const Decl *D) {
98
424
  for (const auto &S : Sources)
99
848
    if (auto EK = S->hasExternalDefinitions(D))
100
848
      if (EK != EK_ReplyHazy)
101
0
        return EK;
102
424
  return EK_ReplyHazy;
103
424
}
104
105
bool MultiplexExternalSemaSource::
106
268
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) {
107
268
  bool AnyDeclsFound = false;
108
804
  for (size_t i = 0; i < Sources.size(); 
++i536
)
109
536
    AnyDeclsFound |= Sources[i]->FindExternalVisibleDeclsByName(DC, Name);
110
268
  return AnyDeclsFound;
111
268
}
112
113
1
void MultiplexExternalSemaSource::completeVisibleDeclsMap(const DeclContext *DC){
114
3
  for(size_t i = 0; i < Sources.size(); 
++i2
)
115
2
    Sources[i]->completeVisibleDeclsMap(DC);
116
1
}
117
118
void MultiplexExternalSemaSource::FindExternalLexicalDecls(
119
    const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
120
81
    SmallVectorImpl<Decl *> &Result) {
121
243
  for(size_t i = 0; i < Sources.size(); 
++i162
)
122
162
    Sources[i]->FindExternalLexicalDecls(DC, IsKindWeWant, Result);
123
81
}
124
125
void MultiplexExternalSemaSource::FindFileRegionDecls(FileID File,
126
                                                      unsigned Offset,
127
                                                      unsigned Length,
128
0
                                                SmallVectorImpl<Decl *> &Decls){
129
0
  for(size_t i = 0; i < Sources.size(); ++i)
130
0
    Sources[i]->FindFileRegionDecls(File, Offset, Length, Decls);
131
0
}
132
133
0
void MultiplexExternalSemaSource::CompleteType(TagDecl *Tag) {
134
0
  for(size_t i = 0; i < Sources.size(); ++i)
135
0
    Sources[i]->CompleteType(Tag);
136
0
}
137
138
0
void MultiplexExternalSemaSource::CompleteType(ObjCInterfaceDecl *Class) {
139
0
  for(size_t i = 0; i < Sources.size(); ++i)
140
0
    Sources[i]->CompleteType(Class);
141
0
}
142
143
0
void MultiplexExternalSemaSource::ReadComments() {
144
0
  for(size_t i = 0; i < Sources.size(); ++i)
145
0
    Sources[i]->ReadComments();
146
0
}
147
148
81
void MultiplexExternalSemaSource::StartedDeserializing() {
149
243
  for(size_t i = 0; i < Sources.size(); 
++i162
)
150
162
    Sources[i]->StartedDeserializing();
151
81
}
152
153
81
void MultiplexExternalSemaSource::FinishedDeserializing() {
154
243
  for(size_t i = 0; i < Sources.size(); 
++i162
)
155
162
    Sources[i]->FinishedDeserializing();
156
81
}
157
158
27
void MultiplexExternalSemaSource::StartTranslationUnit(ASTConsumer *Consumer) {
159
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
160
54
    Sources[i]->StartTranslationUnit(Consumer);
161
27
}
162
163
0
void MultiplexExternalSemaSource::PrintStats() {
164
0
  for(size_t i = 0; i < Sources.size(); ++i)
165
0
    Sources[i]->PrintStats();
166
0
}
167
168
0
Module *MultiplexExternalSemaSource::getModule(unsigned ID) {
169
0
  for (size_t i = 0; i < Sources.size(); ++i)
170
0
    if (auto M = Sources[i]->getModule(ID))
171
0
      return M;
172
0
  return nullptr;
173
0
}
174
175
bool MultiplexExternalSemaSource::layoutRecordType(const RecordDecl *Record,
176
                                                   uint64_t &Size,
177
                                                   uint64_t &Alignment,
178
                      llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
179
                  llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
180
10
          llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets){
181
30
  for(size_t i = 0; i < Sources.size(); 
++i20
)
182
20
    if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets,
183
20
                                     BaseOffsets, VirtualBaseOffsets))
184
0
      return true;
185
10
  return false;
186
10
}
187
188
void MultiplexExternalSemaSource::
189
0
getMemoryBufferSizes(MemoryBufferSizes &sizes) const {
190
0
  for(size_t i = 0; i < Sources.size(); ++i)
191
0
    Sources[i]->getMemoryBufferSizes(sizes);
192
193
0
}
194
195
//===----------------------------------------------------------------------===//
196
// ExternalSemaSource.
197
//===----------------------------------------------------------------------===//
198
199
200
27
void MultiplexExternalSemaSource::InitializeSema(Sema &S) {
201
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
202
54
    Sources[i]->InitializeSema(S);
203
27
}
204
205
27
void MultiplexExternalSemaSource::ForgetSema() {
206
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
207
54
    Sources[i]->ForgetSema();
208
27
}
209
210
0
void MultiplexExternalSemaSource::ReadMethodPool(Selector Sel) {
211
0
  for(size_t i = 0; i < Sources.size(); ++i)
212
0
    Sources[i]->ReadMethodPool(Sel);
213
0
}
214
215
0
void MultiplexExternalSemaSource::updateOutOfDateSelector(Selector Sel) {
216
0
  for(size_t i = 0; i < Sources.size(); ++i)
217
0
    Sources[i]->updateOutOfDateSelector(Sel);
218
0
}
219
220
void MultiplexExternalSemaSource::ReadKnownNamespaces(
221
0
                                   SmallVectorImpl<NamespaceDecl*> &Namespaces){
222
0
  for(size_t i = 0; i < Sources.size(); ++i)
223
0
    Sources[i]->ReadKnownNamespaces(Namespaces);
224
0
}
225
226
void MultiplexExternalSemaSource::ReadUndefinedButUsed(
227
0
    llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
228
0
  for(size_t i = 0; i < Sources.size(); ++i)
229
0
    Sources[i]->ReadUndefinedButUsed(Undefined);
230
0
}
231
232
void MultiplexExternalSemaSource::ReadMismatchingDeleteExpressions(
233
    llvm::MapVector<FieldDecl *,
234
                    llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
235
2
        Exprs) {
236
2
  for (auto &Source : Sources)
237
6
    Source->ReadMismatchingDeleteExpressions(Exprs);
238
2
}
239
240
3
bool MultiplexExternalSemaSource::LookupUnqualified(LookupResult &R, Scope *S){
241
12
  for(size_t i = 0; i < Sources.size(); 
++i9
)
242
9
    Sources[i]->LookupUnqualified(R, S);
243
244
3
  return !R.empty();
245
3
}
246
247
void MultiplexExternalSemaSource::ReadTentativeDefinitions(
248
2
                                     SmallVectorImpl<VarDecl*> &TentativeDefs) {
249
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
250
6
    Sources[i]->ReadTentativeDefinitions(TentativeDefs);
251
2
}
252
253
void MultiplexExternalSemaSource::ReadUnusedFileScopedDecls(
254
0
                                SmallVectorImpl<const DeclaratorDecl*> &Decls) {
255
0
  for(size_t i = 0; i < Sources.size(); ++i)
256
0
    Sources[i]->ReadUnusedFileScopedDecls(Decls);
257
0
}
258
259
void MultiplexExternalSemaSource::ReadDelegatingConstructors(
260
2
                                  SmallVectorImpl<CXXConstructorDecl*> &Decls) {
261
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
262
6
    Sources[i]->ReadDelegatingConstructors(Decls);
263
2
}
264
265
void MultiplexExternalSemaSource::ReadExtVectorDecls(
266
0
                                     SmallVectorImpl<TypedefNameDecl*> &Decls) {
267
0
  for(size_t i = 0; i < Sources.size(); ++i)
268
0
    Sources[i]->ReadExtVectorDecls(Decls);
269
0
}
270
271
void MultiplexExternalSemaSource::ReadDeclsToCheckForDeferredDiags(
272
2
    llvm::SmallVector<Decl *, 4> &Decls) {
273
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
274
6
    Sources[i]->ReadDeclsToCheckForDeferredDiags(Decls);
275
2
}
276
277
void MultiplexExternalSemaSource::ReadUnusedLocalTypedefNameCandidates(
278
0
    llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) {
279
0
  for(size_t i = 0; i < Sources.size(); ++i)
280
0
    Sources[i]->ReadUnusedLocalTypedefNameCandidates(Decls);
281
0
}
282
283
void MultiplexExternalSemaSource::ReadReferencedSelectors(
284
2
                  SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {
285
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
286
6
    Sources[i]->ReadReferencedSelectors(Sels);
287
2
}
288
289
void MultiplexExternalSemaSource::ReadWeakUndeclaredIdentifiers(
290
3
                   SmallVectorImpl<std::pair<IdentifierInfo*, WeakInfo> > &WI) {
291
12
  for(size_t i = 0; i < Sources.size(); 
++i9
)
292
9
    Sources[i]->ReadWeakUndeclaredIdentifiers(WI);
293
3
}
294
295
void MultiplexExternalSemaSource::ReadUsedVTables(
296
2
                                  SmallVectorImpl<ExternalVTableUse> &VTables) {
297
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
298
6
    Sources[i]->ReadUsedVTables(VTables);
299
2
}
300
301
void MultiplexExternalSemaSource::ReadPendingInstantiations(
302
                                           SmallVectorImpl<std::pair<ValueDecl*,
303
2
                                                   SourceLocation> > &Pending) {
304
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
305
6
    Sources[i]->ReadPendingInstantiations(Pending);
306
2
}
307
308
void MultiplexExternalSemaSource::ReadLateParsedTemplates(
309
    llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
310
0
        &LPTMap) {
311
0
  for (size_t i = 0; i < Sources.size(); ++i)
312
0
    Sources[i]->ReadLateParsedTemplates(LPTMap);
313
0
}
314
315
TypoCorrection MultiplexExternalSemaSource::CorrectTypo(
316
                                     const DeclarationNameInfo &Typo,
317
                                     int LookupKind, Scope *S, CXXScopeSpec *SS,
318
                                     CorrectionCandidateCallback &CCC,
319
                                     DeclContext *MemberContext,
320
                                     bool EnteringContext,
321
1
                                     const ObjCObjectPointerType *OPT) {
322
2
  for (size_t I = 0, E = Sources.size(); I < E; 
++I1
) {
323
2
    if (TypoCorrection C = Sources[I]->CorrectTypo(Typo, LookupKind, S, SS, CCC,
324
1
                                                   MemberContext,
325
1
                                                   EnteringContext, OPT))
326
1
      return C;
327
2
  }
328
0
  return TypoCorrection();
329
1
}
330
331
bool MultiplexExternalSemaSource::MaybeDiagnoseMissingCompleteType(
332
1
    SourceLocation Loc, QualType T) {
333
2
  for (size_t I = 0, E = Sources.size(); I < E; 
++I1
) {
334
2
    if (Sources[I]->MaybeDiagnoseMissingCompleteType(Loc, T))
335
1
      return true;
336
2
  }
337
0
  return false;
338
1
}