Coverage Report

Created: 2021-09-21 08:58

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