Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/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
///Constructs a new multiplexing external sema source and appends the
19
/// given element to it.
20
///
21
MultiplexExternalSemaSource::MultiplexExternalSemaSource(ExternalSemaSource &s1,
22
145
                                                        ExternalSemaSource &s2){
23
145
  Sources.push_back(&s1);
24
145
  Sources.push_back(&s2);
25
145
}
26
27
// pin the vtable here.
28
138
MultiplexExternalSemaSource::~MultiplexExternalSemaSource() {}
29
30
///Appends new source to the source list.
31
///
32
///\param[in] source - An ExternalSemaSource.
33
///
34
2
void MultiplexExternalSemaSource::addSource(ExternalSemaSource &source) {
35
2
  Sources.push_back(&source);
36
2
}
37
38
//===----------------------------------------------------------------------===//
39
// ExternalASTSource.
40
//===----------------------------------------------------------------------===//
41
42
33
Decl *MultiplexExternalSemaSource::GetExternalDecl(uint32_t ID) {
43
66
  for(size_t i = 0; i < Sources.size(); 
++i33
)
44
66
    if (Decl *Result = Sources[i]->GetExternalDecl(ID))
45
33
      return Result;
46
33
  
return nullptr0
;
47
33
}
48
49
0
void MultiplexExternalSemaSource::CompleteRedeclChain(const Decl *D) {
50
0
  for (size_t i = 0; i < Sources.size(); ++i)
51
0
    Sources[i]->CompleteRedeclChain(D);
52
0
}
53
54
0
Selector MultiplexExternalSemaSource::GetExternalSelector(uint32_t ID) {
55
0
  Selector Sel;
56
0
  for(size_t i = 0; i < Sources.size(); ++i) {
57
0
    Sel = Sources[i]->GetExternalSelector(ID);
58
0
    if (!Sel.isNull())
59
0
      return Sel;
60
0
  }
61
0
  return Sel;
62
0
}
63
64
0
uint32_t MultiplexExternalSemaSource::GetNumExternalSelectors() {
65
0
  uint32_t total = 0;
66
0
  for(size_t i = 0; i < Sources.size(); ++i)
67
0
    total += Sources[i]->GetNumExternalSelectors();
68
0
  return total;
69
0
}
70
71
14
Stmt *MultiplexExternalSemaSource::GetExternalDeclStmt(uint64_t Offset) {
72
28
  for(size_t i = 0; i < Sources.size(); 
++i14
)
73
28
    if (Stmt *Result = Sources[i]->GetExternalDeclStmt(Offset))
74
14
      return Result;
75
14
  
return nullptr0
;
76
14
}
77
78
CXXBaseSpecifier *MultiplexExternalSemaSource::GetExternalCXXBaseSpecifiers(
79
13
                                                               uint64_t Offset){
80
26
  for(size_t i = 0; i < Sources.size(); 
++i13
)
81
26
    if (CXXBaseSpecifier *R = Sources[i]->GetExternalCXXBaseSpecifiers(Offset))
82
13
      return R;
83
13
  
return nullptr0
;
84
13
}
85
86
CXXCtorInitializer **
87
2
MultiplexExternalSemaSource::GetExternalCXXCtorInitializers(uint64_t Offset) {
88
2
  for (auto *S : Sources)
89
4
    if (auto *R = S->GetExternalCXXCtorInitializers(Offset))
90
2
      return R;
91
2
  
return nullptr0
;
92
2
}
93
94
ExternalASTSource::ExtKind
95
415
MultiplexExternalSemaSource::hasExternalDefinitions(const Decl *D) {
96
415
  for (const auto &S : Sources)
97
830
    if (auto EK = S->hasExternalDefinitions(D))
98
830
      if (EK != EK_ReplyHazy)
99
0
        return EK;
100
415
  return EK_ReplyHazy;
101
415
}
102
103
bool MultiplexExternalSemaSource::
104
265
FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) {
105
265
  bool AnyDeclsFound = false;
106
795
  for (size_t i = 0; i < Sources.size(); 
++i530
)
107
530
    AnyDeclsFound |= Sources[i]->FindExternalVisibleDeclsByName(DC, Name);
108
265
  return AnyDeclsFound;
109
265
}
110
111
1
void MultiplexExternalSemaSource::completeVisibleDeclsMap(const DeclContext *DC){
112
3
  for(size_t i = 0; i < Sources.size(); 
++i2
)
113
2
    Sources[i]->completeVisibleDeclsMap(DC);
114
1
}
115
116
void MultiplexExternalSemaSource::FindExternalLexicalDecls(
117
    const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
118
81
    SmallVectorImpl<Decl *> &Result) {
119
243
  for(size_t i = 0; i < Sources.size(); 
++i162
)
120
162
    Sources[i]->FindExternalLexicalDecls(DC, IsKindWeWant, Result);
121
81
}
122
123
void MultiplexExternalSemaSource::FindFileRegionDecls(FileID File,
124
                                                      unsigned Offset,
125
                                                      unsigned Length,
126
0
                                                SmallVectorImpl<Decl *> &Decls){
127
0
  for(size_t i = 0; i < Sources.size(); ++i)
128
0
    Sources[i]->FindFileRegionDecls(File, Offset, Length, Decls);
129
0
}
130
131
0
void MultiplexExternalSemaSource::CompleteType(TagDecl *Tag) {
132
0
  for(size_t i = 0; i < Sources.size(); ++i)
133
0
    Sources[i]->CompleteType(Tag);
134
0
}
135
136
0
void MultiplexExternalSemaSource::CompleteType(ObjCInterfaceDecl *Class) {
137
0
  for(size_t i = 0; i < Sources.size(); ++i)
138
0
    Sources[i]->CompleteType(Class);
139
0
}
140
141
0
void MultiplexExternalSemaSource::ReadComments() {
142
0
  for(size_t i = 0; i < Sources.size(); ++i)
143
0
    Sources[i]->ReadComments();
144
0
}
145
146
81
void MultiplexExternalSemaSource::StartedDeserializing() {
147
243
  for(size_t i = 0; i < Sources.size(); 
++i162
)
148
162
    Sources[i]->StartedDeserializing();
149
81
}
150
151
81
void MultiplexExternalSemaSource::FinishedDeserializing() {
152
243
  for(size_t i = 0; i < Sources.size(); 
++i162
)
153
162
    Sources[i]->FinishedDeserializing();
154
81
}
155
156
27
void MultiplexExternalSemaSource::StartTranslationUnit(ASTConsumer *Consumer) {
157
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
158
54
    Sources[i]->StartTranslationUnit(Consumer);
159
27
}
160
161
0
void MultiplexExternalSemaSource::PrintStats() {
162
0
  for(size_t i = 0; i < Sources.size(); ++i)
163
0
    Sources[i]->PrintStats();
164
0
}
165
166
0
Module *MultiplexExternalSemaSource::getModule(unsigned ID) {
167
0
  for (size_t i = 0; i < Sources.size(); ++i)
168
0
    if (auto M = Sources[i]->getModule(ID))
169
0
      return M;
170
0
  return nullptr;
171
0
}
172
173
21
bool MultiplexExternalSemaSource::DeclIsFromPCHWithObjectFile(const Decl *D) {
174
21
  for (auto *S : Sources)
175
42
    if (S->DeclIsFromPCHWithObjectFile(D))
176
0
      return true;
177
21
  return false;
178
21
}
179
180
bool MultiplexExternalSemaSource::layoutRecordType(const RecordDecl *Record,
181
                                                   uint64_t &Size,
182
                                                   uint64_t &Alignment,
183
                      llvm::DenseMap<const FieldDecl *, uint64_t> &FieldOffsets,
184
                  llvm::DenseMap<const CXXRecordDecl *, CharUnits> &BaseOffsets,
185
13
          llvm::DenseMap<const CXXRecordDecl *, CharUnits> &VirtualBaseOffsets){
186
39
  for(size_t i = 0; i < Sources.size(); 
++i26
)
187
26
    if (Sources[i]->layoutRecordType(Record, Size, Alignment, FieldOffsets,
188
26
                                     BaseOffsets, VirtualBaseOffsets))
189
0
      return true;
190
13
  return false;
191
13
}
192
193
void MultiplexExternalSemaSource::
194
0
getMemoryBufferSizes(MemoryBufferSizes &sizes) const {
195
0
  for(size_t i = 0; i < Sources.size(); ++i)
196
0
    Sources[i]->getMemoryBufferSizes(sizes);
197
0
198
0
}
199
200
//===----------------------------------------------------------------------===//
201
// ExternalSemaSource.
202
//===----------------------------------------------------------------------===//
203
204
205
27
void MultiplexExternalSemaSource::InitializeSema(Sema &S) {
206
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
207
54
    Sources[i]->InitializeSema(S);
208
27
}
209
210
27
void MultiplexExternalSemaSource::ForgetSema() {
211
81
  for(size_t i = 0; i < Sources.size(); 
++i54
)
212
54
    Sources[i]->ForgetSema();
213
27
}
214
215
0
void MultiplexExternalSemaSource::ReadMethodPool(Selector Sel) {
216
0
  for(size_t i = 0; i < Sources.size(); ++i)
217
0
    Sources[i]->ReadMethodPool(Sel);
218
0
}
219
220
0
void MultiplexExternalSemaSource::updateOutOfDateSelector(Selector Sel) {
221
0
  for(size_t i = 0; i < Sources.size(); ++i)
222
0
    Sources[i]->updateOutOfDateSelector(Sel);
223
0
}
224
225
void MultiplexExternalSemaSource::ReadKnownNamespaces(
226
0
                                   SmallVectorImpl<NamespaceDecl*> &Namespaces){
227
0
  for(size_t i = 0; i < Sources.size(); ++i)
228
0
    Sources[i]->ReadKnownNamespaces(Namespaces);
229
0
}
230
231
void MultiplexExternalSemaSource::ReadUndefinedButUsed(
232
0
    llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
233
0
  for(size_t i = 0; i < Sources.size(); ++i)
234
0
    Sources[i]->ReadUndefinedButUsed(Undefined);
235
0
}
236
237
void MultiplexExternalSemaSource::ReadMismatchingDeleteExpressions(
238
    llvm::MapVector<FieldDecl *,
239
                    llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
240
2
        Exprs) {
241
2
  for (auto &Source : Sources)
242
6
    Source->ReadMismatchingDeleteExpressions(Exprs);
243
2
}
244
245
3
bool MultiplexExternalSemaSource::LookupUnqualified(LookupResult &R, Scope *S){
246
12
  for(size_t i = 0; i < Sources.size(); 
++i9
)
247
9
    Sources[i]->LookupUnqualified(R, S);
248
3
249
3
  return !R.empty();
250
3
}
251
252
void MultiplexExternalSemaSource::ReadTentativeDefinitions(
253
2
                                     SmallVectorImpl<VarDecl*> &TentativeDefs) {
254
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
255
6
    Sources[i]->ReadTentativeDefinitions(TentativeDefs);
256
2
}
257
258
void MultiplexExternalSemaSource::ReadUnusedFileScopedDecls(
259
0
                                SmallVectorImpl<const DeclaratorDecl*> &Decls) {
260
0
  for(size_t i = 0; i < Sources.size(); ++i)
261
0
    Sources[i]->ReadUnusedFileScopedDecls(Decls);
262
0
}
263
264
void MultiplexExternalSemaSource::ReadDelegatingConstructors(
265
2
                                  SmallVectorImpl<CXXConstructorDecl*> &Decls) {
266
8
  for(size_t i = 0; i < Sources.size(); 
++i6
)
267
6
    Sources[i]->ReadDelegatingConstructors(Decls);
268
2
}
269
270
void MultiplexExternalSemaSource::ReadExtVectorDecls(
271
0
                                     SmallVectorImpl<TypedefNameDecl*> &Decls) {
272
0
  for(size_t i = 0; i < Sources.size(); ++i)
273
0
    Sources[i]->ReadExtVectorDecls(Decls);
274
0
}
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
1
                                                   MemberContext,
324
1
                                                   EnteringContext, OPT))
325
1
      return C;
326
2
  }
327
1
  
return TypoCorrection()0
;
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
1
  
return false0
;
337
1
}