Coverage Report

Created: 2020-02-15 09:57

/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
147
                                                        ExternalSemaSource &s2){
25
147
  Sources.push_back(&s1);
26
147
  Sources.push_back(&s2);
27
147
}
28
29
// pin the vtable here.
30
140
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
33
  
return nullptr0
;
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
14
  
return nullptr0
;
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
13
  
return nullptr0
;
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
2
  
return nullptr0
;
94
2
}
95
96
ExternalASTSource::ExtKind
97
421
MultiplexExternalSemaSource::hasExternalDefinitions(const Decl *D) {
98
421
  for (const auto &S : Sources)
99
842
    if (auto EK = S->hasExternalDefinitions(D))
100
842
      if (EK != EK_ReplyHazy)
101
0
        return EK;
102
421
  return EK_ReplyHazy;
103
421
}
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
21
bool MultiplexExternalSemaSource::DeclIsFromPCHWithObjectFile(const Decl *D) {
176
21
  for (auto *S : Sources)
177
42
    if (S->DeclIsFromPCHWithObjectFile(D))
178
0
      return true;
179
21
  return false;
180
21
}
181
182
bool MultiplexExternalSemaSource::layoutRecordType(const RecordDecl *Record,
183
                                                   uint64_t &Size,
184
                                                   uint64_t &Alignment,
185
                      llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
186
                  llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
187
13
          llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets){
188
39
  for(size_t i = 0; i < Sources.size(); 
++i26
)
189
26
    if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets,
190
26
                                     BaseOffsets, VirtualBaseOffsets))
191
0
      return true;
192
13
  return false;
193
13
}
194
195
void MultiplexExternalSemaSource::
196
0
getMemoryBufferSizes(MemoryBufferSizes &sizes) const {
197
0
  for(size_t i = 0; i < Sources.size(); ++i)
198
0
    Sources[i]->getMemoryBufferSizes(sizes);
199
0
200
0
}
201
202
//===----------------------------------------------------------------------===//
203
// ExternalSemaSource.
204
//===----------------------------------------------------------------------===//
205
206
207
27
void MultiplexExternalSemaSource::InitializeSema(Sema &S) {
208
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
209
54
    Sources[i]->InitializeSema(S);
210
27
}
211
212
27
void MultiplexExternalSemaSource::ForgetSema() {
213
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
214
54
    Sources[i]->ForgetSema();
215
27
}
216
217
0
void MultiplexExternalSemaSource::ReadMethodPool(Selector Sel) {
218
0
  for(size_t i = 0; i < Sources.size(); ++i)
219
0
    Sources[i]->ReadMethodPool(Sel);
220
0
}
221
222
0
void MultiplexExternalSemaSource::updateOutOfDateSelector(Selector Sel) {
223
0
  for(size_t i = 0; i < Sources.size(); ++i)
224
0
    Sources[i]->updateOutOfDateSelector(Sel);
225
0
}
226
227
void MultiplexExternalSemaSource::ReadKnownNamespaces(
228
0
                                   SmallVectorImpl<NamespaceDecl*> &Namespaces){
229
0
  for(size_t i = 0; i < Sources.size(); ++i)
230
0
    Sources[i]->ReadKnownNamespaces(Namespaces);
231
0
}
232
233
void MultiplexExternalSemaSource::ReadUndefinedButUsed(
234
0
    llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
235
0
  for(size_t i = 0; i < Sources.size(); ++i)
236
0
    Sources[i]->ReadUndefinedButUsed(Undefined);
237
0
}
238
239
void MultiplexExternalSemaSource::ReadMismatchingDeleteExpressions(
240
    llvm::MapVector<FieldDecl *,
241
                    llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
242
2
        Exprs) {
243
2
  for (auto &Source : Sources)
244
6
    Source->ReadMismatchingDeleteExpressions(Exprs);
245
2
}
246
247
3
bool MultiplexExternalSemaSource::LookupUnqualified(LookupResult &R, Scope *S){
248
12
  for(size_t i = 0; i < Sources.size(); 
++i9
)
249
9
    Sources[i]->LookupUnqualified(R, S);
250
3
251
3
  return !R.empty();
252
3
}
253
254
void MultiplexExternalSemaSource::ReadTentativeDefinitions(
255
2
                                     SmallVectorImpl<VarDecl*> &TentativeDefs) {
256
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
257
6
    Sources[i]->ReadTentativeDefinitions(TentativeDefs);
258
2
}
259
260
void MultiplexExternalSemaSource::ReadUnusedFileScopedDecls(
261
0
                                SmallVectorImpl<const DeclaratorDecl*> &Decls) {
262
0
  for(size_t i = 0; i < Sources.size(); ++i)
263
0
    Sources[i]->ReadUnusedFileScopedDecls(Decls);
264
0
}
265
266
void MultiplexExternalSemaSource::ReadDelegatingConstructors(
267
2
                                  SmallVectorImpl<CXXConstructorDecl*> &Decls) {
268
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
269
6
    Sources[i]->ReadDelegatingConstructors(Decls);
270
2
}
271
272
void MultiplexExternalSemaSource::ReadExtVectorDecls(
273
0
                                     SmallVectorImpl<TypedefNameDecl*> &Decls) {
274
0
  for(size_t i = 0; i < Sources.size(); ++i)
275
0
    Sources[i]->ReadExtVectorDecls(Decls);
276
0
}
277
278
void MultiplexExternalSemaSource::ReadUnusedLocalTypedefNameCandidates(
279
0
    llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) {
280
0
  for(size_t i = 0; i < Sources.size(); ++i)
281
0
    Sources[i]->ReadUnusedLocalTypedefNameCandidates(Decls);
282
0
}
283
284
void MultiplexExternalSemaSource::ReadReferencedSelectors(
285
2
                  SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {
286
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
287
6
    Sources[i]->ReadReferencedSelectors(Sels);
288
2
}
289
290
void MultiplexExternalSemaSource::ReadWeakUndeclaredIdentifiers(
291
3
                   SmallVectorImpl<std::pair<IdentifierInfo*, WeakInfo> > &WI) {
292
12
  for(size_t i = 0; i < Sources.size(); 
++i9
)
293
9
    Sources[i]->ReadWeakUndeclaredIdentifiers(WI);
294
3
}
295
296
void MultiplexExternalSemaSource::ReadUsedVTables(
297
2
                                  SmallVectorImpl<ExternalVTableUse> &VTables) {
298
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
299
6
    Sources[i]->ReadUsedVTables(VTables);
300
2
}
301
302
void MultiplexExternalSemaSource::ReadPendingInstantiations(
303
                                           SmallVectorImpl<std::pair<ValueDecl*,
304
2
                                                   SourceLocation> > &Pending) {
305
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
306
6
    Sources[i]->ReadPendingInstantiations(Pending);
307
2
}
308
309
void MultiplexExternalSemaSource::ReadLateParsedTemplates(
310
    llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
311
0
        &LPTMap) {
312
0
  for (size_t i = 0; i < Sources.size(); ++i)
313
0
    Sources[i]->ReadLateParsedTemplates(LPTMap);
314
0
}
315
316
TypoCorrection MultiplexExternalSemaSource::CorrectTypo(
317
                                     const DeclarationNameInfo &Typo,
318
                                     int LookupKind, Scope *S, CXXScopeSpec *SS,
319
                                     CorrectionCandidateCallback &CCC,
320
                                     DeclContext *MemberContext,
321
                                     bool EnteringContext,
322
1
                                     const ObjCObjectPointerType *OPT) {
323
2
  for (size_t I = 0, E = Sources.size(); I < E; 
++I1
) {
324
2
    if (TypoCorrection C = Sources[I]->CorrectTypo(Typo, LookupKind, S, SS, CCC,
325
1
                                                   MemberContext,
326
1
                                                   EnteringContext, OPT))
327
1
      return C;
328
2
  }
329
1
  
return TypoCorrection()0
;
330
1
}
331
332
bool MultiplexExternalSemaSource::MaybeDiagnoseMissingCompleteType(
333
1
    SourceLocation Loc, QualType T) {
334
2
  for (size_t I = 0, E = Sources.size(); I < E; 
++I1
) {
335
2
    if (Sources[I]->MaybeDiagnoseMissingCompleteType(Loc, T))
336
1
      return true;
337
2
  }
338
1
  
return false0
;
339
1
}