clang 10.0.0

ASTReader.cpp
Go to the documentation of this file.
1 //===- ASTReader.cpp - AST File Reader ------------------------------------===//
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 defines the ASTReader class, which reads AST files.
10 //
11 //===----------------------------------------------------------------------===//
12
13 #include "clang/Basic/OpenMPKinds.h"
14 #include "clang/Serialization/ASTRecordReader.h"
15 #include "ASTCommon.h"
16 #include "ASTReaderInternals.h"
17 #include "clang/AST/AbstractTypeReader.h"
18 #include "clang/AST/ASTConsumer.h"
19 #include "clang/AST/ASTContext.h"
20 #include "clang/AST/ASTMutationListener.h"
21 #include "clang/AST/ASTUnresolvedSet.h"
22 #include "clang/AST/Decl.h"
23 #include "clang/AST/DeclBase.h"
24 #include "clang/AST/DeclCXX.h"
25 #include "clang/AST/DeclFriend.h"
26 #include "clang/AST/DeclGroup.h"
27 #include "clang/AST/DeclObjC.h"
28 #include "clang/AST/DeclTemplate.h"
29 #include "clang/AST/DeclarationName.h"
30 #include "clang/AST/Expr.h"
31 #include "clang/AST/ExprCXX.h"
32 #include "clang/AST/ExternalASTSource.h"
33 #include "clang/AST/NestedNameSpecifier.h"
34 #include "clang/AST/OpenMPClause.h"
35 #include "clang/AST/ODRHash.h"
36 #include "clang/AST/RawCommentList.h"
37 #include "clang/AST/TemplateBase.h"
38 #include "clang/AST/TemplateName.h"
39 #include "clang/AST/Type.h"
40 #include "clang/AST/TypeLoc.h"
41 #include "clang/AST/TypeLocVisitor.h"
42 #include "clang/AST/UnresolvedSet.h"
43 #include "clang/Basic/CommentOptions.h"
44 #include "clang/Basic/Diagnostic.h"
45 #include "clang/Basic/DiagnosticOptions.h"
46 #include "clang/Basic/ExceptionSpecificationType.h"
47 #include "clang/Basic/FileManager.h"
48 #include "clang/Basic/FileSystemOptions.h"
49 #include "clang/Basic/IdentifierTable.h"
50 #include "clang/Basic/LLVM.h"
51 #include "clang/Basic/LangOptions.h"
52 #include "clang/Basic/Module.h"
53 #include "clang/Basic/ObjCRuntime.h"
54 #include "clang/Basic/OperatorKinds.h"
55 #include "clang/Basic/PragmaKinds.h"
56 #include "clang/Basic/Sanitizers.h"
57 #include "clang/Basic/SourceLocation.h"
58 #include "clang/Basic/SourceManager.h"
59 #include "clang/Basic/SourceManagerInternals.h"
60 #include "clang/Basic/Specifiers.h"
61 #include "clang/Basic/TargetInfo.h"
62 #include "clang/Basic/TargetOptions.h"
63 #include "clang/Basic/TokenKinds.h"
64 #include "clang/Basic/Version.h"
65 #include "clang/Lex/HeaderSearch.h"
66 #include "clang/Lex/HeaderSearchOptions.h"
67 #include "clang/Lex/MacroInfo.h"
68 #include "clang/Lex/ModuleMap.h"
69 #include "clang/Lex/PreprocessingRecord.h"
70 #include "clang/Lex/Preprocessor.h"
71 #include "clang/Lex/PreprocessorOptions.h"
72 #include "clang/Lex/Token.h"
73 #include "clang/Sema/ObjCMethodList.h"
74 #include "clang/Sema/Scope.h"
75 #include "clang/Sema/Sema.h"
76 #include "clang/Sema/Weak.h"
77 #include "clang/Serialization/ASTBitCodes.h"
78 #include "clang/Serialization/ASTDeserializationListener.h"
79 #include "clang/Serialization/ContinuousRangeMap.h"
80 #include "clang/Serialization/GlobalModuleIndex.h"
81 #include "clang/Serialization/InMemoryModuleCache.h"
82 #include "clang/Serialization/ModuleFile.h"
83 #include "clang/Serialization/ModuleFileExtension.h"
84 #include "clang/Serialization/ModuleManager.h"
85 #include "clang/Serialization/PCHContainerOperations.h"
86 #include "clang/Serialization/SerializationDiagnostic.h"
87 #include "llvm/ADT/APFloat.h"
88 #include "llvm/ADT/APInt.h"
89 #include "llvm/ADT/APSInt.h"
90 #include "llvm/ADT/ArrayRef.h"
91 #include "llvm/ADT/DenseMap.h"
92 #include "llvm/ADT/FoldingSet.h"
93 #include "llvm/ADT/Hashing.h"
94 #include "llvm/ADT/IntrusiveRefCntPtr.h"
95 #include "llvm/ADT/None.h"
96 #include "llvm/ADT/Optional.h"
97 #include "llvm/ADT/STLExtras.h"
98 #include "llvm/ADT/ScopeExit.h"
99 #include "llvm/ADT/SmallPtrSet.h"
100 #include "llvm/ADT/SmallString.h"
101 #include "llvm/ADT/SmallVector.h"
102 #include "llvm/ADT/StringExtras.h"
103 #include "llvm/ADT/StringMap.h"
104 #include "llvm/ADT/StringRef.h"
105 #include "llvm/ADT/Triple.h"
106 #include "llvm/ADT/iterator_range.h"
107 #include "llvm/Bitstream/BitstreamReader.h"
108 #include "llvm/Support/Casting.h"
109 #include "llvm/Support/Compiler.h"
110 #include "llvm/Support/Compression.h"
111 #include "llvm/Support/DJB.h"
112 #include "llvm/Support/Endian.h"
113 #include "llvm/Support/Error.h"
114 #include "llvm/Support/ErrorHandling.h"
115 #include "llvm/Support/FileSystem.h"
116 #include "llvm/Support/MemoryBuffer.h"
117 #include "llvm/Support/Path.h"
118 #include "llvm/Support/SaveAndRestore.h"
119 #include "llvm/Support/Timer.h"
120 #include "llvm/Support/VersionTuple.h"
121 #include "llvm/Support/raw_ostream.h"
122 #include <algorithm>
123 #include <cassert>
124 #include <cstddef>
125 #include <cstdint>
126 #include <cstdio>
127 #include <ctime>
128 #include <iterator>
129 #include <limits>
130 #include <map>
131 #include <memory>
132 #include <string>
133 #include <system_error>
134 #include <tuple>
135 #include <utility>
136 #include <vector>
137
138 using namespace clang;
139 using namespace clang::serialization;
140 using namespace clang::serialization::reader;
141 using llvm::BitstreamCursor;
142
143 //===----------------------------------------------------------------------===//
144 // ChainedASTReaderListener implementation
145 //===----------------------------------------------------------------------===//
146
147 bool
148 ChainedASTReaderListener::ReadFullVersionInformation(StringRef FullVersion) {
149 return First->ReadFullVersionInformation(FullVersion) ||
150 Second->ReadFullVersionInformation(FullVersion);
151 }
152
153 void ChainedASTReaderListener::ReadModuleName(StringRef ModuleName) {
154 First->ReadModuleName(ModuleName);
155 Second->ReadModuleName(ModuleName);
156 }
157
158 void ChainedASTReaderListener::ReadModuleMapFile(StringRef ModuleMapPath) {
159 First->ReadModuleMapFile(ModuleMapPath);
160 Second->ReadModuleMapFile(ModuleMapPath);
161 }
162
163 bool
164 ChainedASTReaderListener::ReadLanguageOptions(const LangOptions &LangOpts,
165 bool Complain,
166 bool AllowCompatibleDifferences) {
167 return First->ReadLanguageOptions(LangOpts, Complain,
168 AllowCompatibleDifferences) ||
169 Second->ReadLanguageOptions(LangOpts, Complain,
170 AllowCompatibleDifferences);
171 }
172
173 bool ChainedASTReaderListener::ReadTargetOptions(
174 const TargetOptions &TargetOpts, bool Complain,
175 bool AllowCompatibleDifferences) {
176 return First->ReadTargetOptions(TargetOpts, Complain,
177 AllowCompatibleDifferences) ||
178 Second->ReadTargetOptions(TargetOpts, Complain,
179 AllowCompatibleDifferences);
180 }
181
182 bool ChainedASTReaderListener::ReadDiagnosticOptions(
183 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, bool Complain) {
184 return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
185 Second->ReadDiagnosticOptions(DiagOpts, Complain);
186 }
187
188 bool
189 ChainedASTReaderListener::ReadFileSystemOptions(const FileSystemOptions &FSOpts,
190 bool Complain) {
191 return First->ReadFileSystemOptions(FSOpts, Complain) ||
192 Second->ReadFileSystemOptions(FSOpts, Complain);
193 }
194
195 bool ChainedASTReaderListener::ReadHeaderSearchOptions(
196 const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath,
197 bool Complain) {
198 return First->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
199 Complain) ||
200 Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
201 Complain);
202 }
203
204 bool ChainedASTReaderListener::ReadPreprocessorOptions(
205 const PreprocessorOptions &PPOpts, bool Complain,
206 std::string &SuggestedPredefines) {
207 return First->ReadPreprocessorOptions(PPOpts, Complain,
208 SuggestedPredefines) ||
209 Second->ReadPreprocessorOptions(PPOpts, Complain, SuggestedPredefines);
210 }
211
212 void ChainedASTReaderListener::ReadCounter(const serialization::ModuleFile &M,
213 unsigned Value) {
214 First->ReadCounter(M, Value);
215 Second->ReadCounter(M, Value);
216 }
217
218 bool ChainedASTReaderListener::needsInputFileVisitation() {
219 return First->needsInputFileVisitation() ||
220 Second->needsInputFileVisitation();
221 }
222
223 bool ChainedASTReaderListener::needsSystemInputFileVisitation() {
224 return First->needsSystemInputFileVisitation() ||
225 Second->needsSystemInputFileVisitation();
226 }
227
228 void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
229 ModuleKind Kind) {
230 First->visitModuleFile(Filename, Kind);
231 Second->visitModuleFile(Filename, Kind);
232 }
233
234 bool ChainedASTReaderListener::visitInputFile(StringRef Filename,
235 bool isSystem,
236 bool isOverridden,
237 bool isExplicitModule) {
238 bool Continue = false;
239 if (First->needsInputFileVisitation() &&
240 (!isSystem || First->needsSystemInputFileVisitation()))
241 Continue |= First->visitInputFile(Filename, isSystem, isOverridden,
242 isExplicitModule);
243 if (Second->needsInputFileVisitation() &&
244 (!isSystem || Second->needsSystemInputFileVisitation()))
245 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
246 isExplicitModule);
247 return Continue;
248 }
249
250 void ChainedASTReaderListener::readModuleFileExtension(
251 const ModuleFileExtensionMetadata &Metadata) {
252 First->readModuleFileExtension(Metadata);
253 Second->readModuleFileExtension(Metadata);
254 }
255
256 //===----------------------------------------------------------------------===//
257 // PCH validator implementation
258 //===----------------------------------------------------------------------===//
259
260 ASTReaderListener::~ASTReaderListener() = default;
261
262 /// Compare the given set of language options against an existing set of
263 /// language options.
264 ///
265 /// \param Diags If non-NULL, diagnostics will be emitted via this engine.
266 /// \param AllowCompatibleDifferences If true, differences between compatible
267 /// language options will be permitted.
268 ///
269 /// \returns true if the languagae options mis-match, false otherwise.
270 static bool checkLanguageOptions(const LangOptions &LangOpts,
271 const LangOptions &ExistingLangOpts,
272 DiagnosticsEngine *Diags,
273 bool AllowCompatibleDifferences = true) {
274 #define LANGOPT(Name, Bits, Default, Description) \
275 if (ExistingLangOpts.Name != LangOpts.Name) { \
276 if (Diags) \
277 Diags->Report(diag::err_pch_langopt_mismatch) \
278 << Description << LangOpts.Name << ExistingLangOpts.Name; \
279 return true; \
280 }
281
282 #define VALUE_LANGOPT(Name, Bits, Default, Description) \
283 if (ExistingLangOpts.Name != LangOpts.Name) { \
284 if (Diags) \
285 Diags->Report(diag::err_pch_langopt_value_mismatch) \
286 << Description; \
287 return true; \
288 }
289
290 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
291 if (ExistingLangOpts.get##Name() != LangOpts.get##Name()) { \
292 if (Diags) \
293 Diags->Report(diag::err_pch_langopt_value_mismatch) \
294 << Description; \
295 return true; \
296 }
297
298 #define COMPATIBLE_LANGOPT(Name, Bits, Default, Description) \
299 if (!AllowCompatibleDifferences) \
300 LANGOPT(Name, Bits, Default, Description)
301
302 #define COMPATIBLE_ENUM_LANGOPT(Name, Bits, Default, Description) \
303 if (!AllowCompatibleDifferences) \
304 ENUM_LANGOPT(Name, Bits, Default, Description)
305
306 #define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
307 if (!AllowCompatibleDifferences) \
308 VALUE_LANGOPT(Name, Bits, Default, Description)
309
310 #define BENIGN_LANGOPT(Name, Bits, Default, Description)
311 #define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
312 #define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description)
313 #include "clang/Basic/LangOptions.def"
314
315 if (ExistingLangOpts.ModuleFeatures != LangOpts.ModuleFeatures) {
316 if (Diags)
317 Diags->Report(diag::err_pch_langopt_value_mismatch) << "module features";
318 return true;
319 }
320
321 if (ExistingLangOpts.ObjCRuntime != LangOpts.ObjCRuntime) {
322 if (Diags)
323 Diags->Report(diag::err_pch_langopt_value_mismatch)
324 << "target Objective-C runtime";
325 return true;
326 }
327
328 if (ExistingLangOpts.CommentOpts.BlockCommandNames !=
329 LangOpts.CommentOpts.BlockCommandNames) {
330 if (Diags)
331 Diags->Report(diag::err_pch_langopt_value_mismatch)
332 << "block command names";
333 return true;
334 }
335
336 // Sanitizer feature mismatches are treated as compatible differences. If
337 // compatible differences aren't allowed, we still only want to check for
338 // mismatches of non-modular sanitizers (the only ones which can affect AST
339 // generation).
340 if (!AllowCompatibleDifferences) {
341 SanitizerMask ModularSanitizers = getPPTransparentSanitizers();
342 SanitizerSet ExistingSanitizers = ExistingLangOpts.Sanitize;
343 SanitizerSet ImportedSanitizers = LangOpts.Sanitize;
344 ExistingSanitizers.clear(ModularSanitizers);
345 ImportedSanitizers.clear(ModularSanitizers);
346 if (ExistingSanitizers.Mask != ImportedSanitizers.Mask) {
347 const std::string Flag = "-fsanitize=";
348 if (Diags) {
349 #define SANITIZER(NAME, ID) \
350 { \
351 bool InExistingModule = ExistingSanitizers.has(SanitizerKind::ID); \
352 bool InImportedModule = ImportedSanitizers.has(SanitizerKind::ID); \
353 if (InExistingModule != InImportedModule) \
354 Diags->Report(diag::err_pch_targetopt_feature_mismatch) \
355 << InExistingModule << (Flag + NAME); \
356 }
357 #include "clang/Basic/Sanitizers.def"
358 }
359 return true;
360 }
361 }
362
363 return false;
364 }
365
366 /// Compare the given set of target options against an existing set of
367 /// target options.
368 ///
369 /// \param Diags If non-NULL, diagnostics will be emitted via this engine.
370 ///
371 /// \returns true if the target options mis-match, false otherwise.
372 static bool checkTargetOptions(const TargetOptions &TargetOpts,
373 const TargetOptions &ExistingTargetOpts,
374 DiagnosticsEngine *Diags,
375 bool AllowCompatibleDifferences = true) {
376 #define CHECK_TARGET_OPT(Field, Name) \
377 if (TargetOpts.Field != ExistingTargetOpts.Field) { \
378 if (Diags) \
379 Diags->Report(diag::err_pch_targetopt_mismatch) \
380 << Name << TargetOpts.Field << ExistingTargetOpts.Field; \
381 return true; \
382 }
383
384 // The triple and ABI must match exactly.
385 CHECK_TARGET_OPT(Triple, "target");
386 CHECK_TARGET_OPT(ABI, "target ABI");
387
388 // We can tolerate different CPUs in many cases, notably when one CPU
389 // supports a strict superset of another. When allowing compatible
390 // differences skip this check.
391 if (!AllowCompatibleDifferences)
392 CHECK_TARGET_OPT(CPU, "target CPU");
393
394 #undef CHECK_TARGET_OPT
395
396 // Compare feature sets.
397 SmallVector<StringRef, 4> ExistingFeatures(
398 ExistingTargetOpts.FeaturesAsWritten.begin(),
399 ExistingTargetOpts.FeaturesAsWritten.end());
400 SmallVector<StringRef, 4> ReadFeatures(TargetOpts.FeaturesAsWritten.begin(),
401 TargetOpts.FeaturesAsWritten.end());
402 llvm::sort(ExistingFeatures);
403 llvm::sort(ReadFeatures);
404
405 // We compute the set difference in both directions explicitly so that we can
406 // diagnose the differences differently.
407 SmallVector<StringRef, 4> UnmatchedExistingFeatures, UnmatchedReadFeatures;
408 std::set_difference(
409 ExistingFeatures.begin(), ExistingFeatures.end(), ReadFeatures.begin(),
410 ReadFeatures.end(), std::back_inserter(UnmatchedExistingFeatures));
411 std::set_difference(ReadFeatures.begin(), ReadFeatures.end(),
412 ExistingFeatures.begin(), ExistingFeatures.end(),
413 std::back_inserter(UnmatchedReadFeatures));
414
415 // If we are allowing compatible differences and the read feature set is
416 // a strict subset of the existing feature set, there is nothing to diagnose.
417 if (AllowCompatibleDifferences && UnmatchedReadFeatures.empty())
418 return false;
419
420 if (Diags) {
421 for (StringRef Feature : UnmatchedReadFeatures)
422 Diags->Report(diag::err_pch_targetopt_feature_mismatch)
423 << /* is-existing-feature */ false << Feature;
424 for (StringRef Feature : UnmatchedExistingFeatures)
425 Diags->Report(diag::err_pch_targetopt_feature_mismatch)
426 << /* is-existing-feature */ true << Feature;
427 }
428
429 return !UnmatchedReadFeatures.empty() || !UnmatchedExistingFeatures.empty();
430 }
431
432 bool
433 PCHValidator::ReadLanguageOptions(const LangOptions &LangOpts,
434 bool Complain,
435 bool AllowCompatibleDifferences) {
436 const LangOptions &ExistingLangOpts = PP.getLangOpts();
437 return checkLanguageOptions(LangOpts, ExistingLangOpts,
438 Complain ? &Reader.Diags : nullptr,
439 AllowCompatibleDifferences);
440 }
441
442 bool PCHValidator::ReadTargetOptions(const TargetOptions &TargetOpts,
443 bool Complain,
444 bool AllowCompatibleDifferences) {
445 const TargetOptions &ExistingTargetOpts = PP.getTargetInfo().getTargetOpts();
446 return checkTargetOptions(TargetOpts, ExistingTargetOpts,
447 Complain ? &Reader.Diags : nullptr,
448 AllowCompatibleDifferences);
449 }
450
451 namespace {
452
453 using MacroDefinitionsMap =
454 llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>;
455 using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
456
457 } // namespace
458
459 static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
460 DiagnosticsEngine &Diags,
461 bool Complain) {
462 using Level = DiagnosticsEngine::Level;
463
464 // Check current mappings for new -Werror mappings, and the stored mappings
465 // for cases that were explicitly mapped to *not* be errors that are now
466 // errors because of options like -Werror.
467 DiagnosticsEngine *MappingSources[] = { &Diags, &StoredDiags };
468
469 for (DiagnosticsEngine *MappingSource : MappingSources) {
470 for (auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
471 diag::kind DiagID = DiagIDMappingPair.first;
472 Level CurLevel = Diags.getDiagnosticLevel(DiagID, SourceLocation());
473 if (CurLevel < DiagnosticsEngine::Error)
474 continue; // not significant
475 Level StoredLevel =
476 StoredDiags.getDiagnosticLevel(DiagID, SourceLocation());
477 if (StoredLevel < DiagnosticsEngine::Error) {
478 if (Complain)
479 Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror=" +
480 Diags.getDiagnosticIDs()->getWarningOptionForDiag(DiagID).str();
481 return true;
482 }
483 }
484 }
485
486 return false;
487 }
488
489 static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags) {
490 diag::Severity Ext = Diags.getExtensionHandlingBehavior();
491 if (Ext == diag::Severity::Warning && Diags.getWarningsAsErrors())
492 return true;
493 return Ext >= diag::Severity::Error;
494 }
495
496 static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags,
497 DiagnosticsEngine &Diags,
498 bool IsSystem, bool Complain) {
499 // Top-level options
500 if (IsSystem) {
501 if (Diags.getSuppressSystemWarnings())
502 return false;
503 // If -Wsystem-headers was not enabled before, be conservative
504 if (StoredDiags.getSuppressSystemWarnings()) {
505 if (Complain)
506 Diags.Report(diag::err_pch_diagopt_mismatch) << "-Wsystem-headers";
507 return true;
508 }
509 }
510
511 if (Diags.getWarningsAsErrors() && !StoredDiags.getWarningsAsErrors()) {
512 if (Complain)
513 Diags.Report(diag::err_pch_diagopt_mismatch) << "-Werror";
514 return true;
515 }
516
517 if (Diags.getWarningsAsErrors() && Diags.getEnableAllWarnings() &&
518 !StoredDiags.getEnableAllWarnings()) {
519 if (Complain)
520 Diags.Report(diag::err_pch_diagopt_mismatch) << "-Weverything -Werror";
521 return true;
522 }
523
524 if (isExtHandlingFromDiagsError(Diags) &&
525 !isExtHandlingFromDiagsError(StoredDiags)) {
526 if (Complain)
527 Diags.Report(diag::err_pch_diagopt_mismatch) << "-pedantic-errors";
528 return true;
529 }
530
531 return checkDiagnosticGroupMappings(StoredDiags, Diags, Complain);
532 }
533
534 /// Return the top import module if it is implicit, nullptr otherwise.
535 static Module *getTopImportImplicitModule(ModuleManager &ModuleMgr,
536 Preprocessor &PP) {
537 // If the original import came from a file explicitly generated by the user,
538 // don't check the diagnostic mappings.
539 // FIXME: currently this is approximated by checking whether this is not a
540 // module import of an implicitly-loaded module file.
541 // Note: ModuleMgr.rbegin() may not be the current module, but it must be in
542 // the transitive closure of its imports, since unrelated modules cannot be
543 // imported until after this module finishes validation.
544 ModuleFile *TopImport = &*ModuleMgr.rbegin();
545 while (!TopImport->ImportedBy.empty())
546 TopImport = TopImport->ImportedBy[0];
547 if (TopImport->Kind != MK_ImplicitModule)
548 return nullptr;
549
550 StringRef ModuleName = TopImport->ModuleName;
551 assert(!ModuleName.empty() && "diagnostic options read before module name");
552
553 Module *M = PP.getHeaderSearchInfo().lookupModule(ModuleName);
554 assert(M && "missing module");
555 return M;
556 }
557
558 bool PCHValidator::ReadDiagnosticOptions(
559 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, bool Complain) {
560 DiagnosticsEngine &ExistingDiags = PP.getDiagnostics();
561 IntrusiveRefCntPtr<DiagnosticIDs> DiagIDs(ExistingDiags.getDiagnosticIDs());
562 IntrusiveRefCntPtr<DiagnosticsEngine> Diags(
563 new DiagnosticsEngine(DiagIDs, DiagOpts.get()));
564 // This should never fail, because we would have processed these options
565 // before writing them to an ASTFile.
566 ProcessWarningOptions(*Diags, *DiagOpts, /*Report*/false);
567
568 ModuleManager &ModuleMgr = Reader.getModuleManager();
569 assert(ModuleMgr.size() >= 1 && "what ASTFile is this then");
570
571 Module *TopM = getTopImportImplicitModule(ModuleMgr, PP);
572 if (!TopM)
573 return false;
574
575 // FIXME: if the diagnostics are incompatible, save a DiagnosticOptions that
576 // contains the union of their flags.
577 return checkDiagnosticMappings(*Diags, ExistingDiags, TopM->IsSystem,
578 Complain);
579 }
580
581 /// Collect the macro definitions provided by the given preprocessor
582 /// options.
583 static void
584 collectMacroDefinitions(const PreprocessorOptions &PPOpts,
585 MacroDefinitionsMap &Macros,
586 SmallVectorImpl<StringRef> *MacroNames = nullptr) {
587 for (unsigned I = 0, N = PPOpts.Macros.size(); I != N; ++I) {
588 StringRef Macro = PPOpts.Macros[I].first;
589 bool IsUndef = PPOpts.Macros[I].second;
590
591 std::pair<StringRef, StringRef> MacroPair = Macro.split('=');
592 StringRef MacroName = MacroPair.first;
593 StringRef MacroBody = MacroPair.second;
594
595 // For an #undef'd macro, we only care about the name.
596 if (IsUndef) {
597 if (MacroNames && !Macros.count(MacroName))
598 MacroNames->push_back(MacroName);
599
600 Macros[MacroName] = std::make_pair("", true);
601 continue;
602 }
603
604 // For a #define'd macro, figure out the actual definition.
605 if (MacroName.size() == Macro.size())
606 MacroBody = "1";
607 else {
608 // Note: GCC drops anything following an end-of-line character.
609 StringRef::size_type End = MacroBody.find_first_of("\n\r");
610 MacroBody = MacroBody.substr(0, End);
611 }
612
613 if (MacroNames && !Macros.count(MacroName))
614 MacroNames->push_back(MacroName);
615 Macros[MacroName] = std::make_pair(MacroBody, false);
616 }
617 }
618
619 /// Check the preprocessor options deserialized from the control block
620 /// against the preprocessor options in an existing preprocessor.
621 ///
622 /// \param Diags If non-null, produce diagnostics for any mismatches incurred.
623 /// \param Validate If true, validate preprocessor options. If false, allow
624 /// macros defined by \p ExistingPPOpts to override those defined by
625 /// \p PPOpts in SuggestedPredefines.
626 static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
627 const PreprocessorOptions &ExistingPPOpts,
628 DiagnosticsEngine *Diags,
629 FileManager &FileMgr,
630 std::string &SuggestedPredefines,
631 const LangOptions &LangOpts,
632 bool Validate = true) {
633 // Check macro definitions.
634 MacroDefinitionsMap ASTFileMacros;
635 collectMacroDefinitions(PPOpts, ASTFileMacros);
636 MacroDefinitionsMap ExistingMacros;
637 SmallVector<StringRef, 4> ExistingMacroNames;
638 collectMacroDefinitions(ExistingPPOpts, ExistingMacros, &ExistingMacroNames);
639
640 for (unsigned I = 0, N = ExistingMacroNames.size(); I != N; ++I) {
641 // Dig out the macro definition in the existing preprocessor options.
642 StringRef MacroName = ExistingMacroNames[I];
643 std::pair<StringRef, bool> Existing = ExistingMacros[MacroName];
644
645 // Check whether we know anything about this macro name or not.
646 llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>::iterator Known =
647 ASTFileMacros.find(MacroName);
648 if (!Validate || Known == ASTFileMacros.end()) {
649 // FIXME: Check whether this identifier was referenced anywhere in the
650 // AST file. If so, we should reject the AST file. Unfortunately, this
651 // information isn't in the control block. What shall we do about it?
652
653 if (Existing.second) {
654 SuggestedPredefines += "#undef ";
655 SuggestedPredefines += MacroName.str();
656 SuggestedPredefines += '\n';
657 } else {
658 SuggestedPredefines += "#define ";
659 SuggestedPredefines += MacroName.str();
660 SuggestedPredefines += ' ';
661 SuggestedPredefines += Existing.first.str();
662 SuggestedPredefines += '\n';
663 }
664 continue;
665 }
666
667 // If the macro was defined in one but undef'd in the other, we have a
668 // conflict.
669 if (Existing.second != Known->second.second) {
670 if (Diags) {
671 Diags->Report(diag::err_pch_macro_def_undef)
672 << MacroName << Known->second.second;
673 }
674 return true;
675 }
676
677 // If the macro was #undef'd in both, or if the macro bodies are identical,
678 // it's fine.
679 if (Existing.second || Existing.first == Known->second.first)
680 continue;
681
682 // The macro bodies differ; complain.
683 if (Diags) {
684 Diags->Report(diag::err_pch_macro_def_conflict)
685 << MacroName << Known->second.first << Existing.first;
686 }
687 return true;
688 }
689
690 // Check whether we're using predefines.
691 if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines && Validate) {
692 if (Diags) {
693 Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines;
694 }
695 return true;
696 }
697
698 // Detailed record is important since it is used for the module cache hash.
699 if (LangOpts.Modules &&
700 PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord && Validate) {
701 if (Diags) {
702 Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord;
703 }
704 return true;
705 }
706
707 // Compute the #include and #include_macros lines we need.
708 for (unsigned I = 0, N = ExistingPPOpts.Includes.size(); I != N; ++I) {
709 StringRef File = ExistingPPOpts.Includes[I];
710
711 if (!ExistingPPOpts.ImplicitPCHInclude.empty() &&
712 !ExistingPPOpts.PCHThroughHeader.empty()) {
713 // In case the through header is an include, we must add all the includes
714 // to the predefines so the start point can be determined.
715 SuggestedPredefines += "#include \"";
716 SuggestedPredefines += File;
717 SuggestedPredefines += "\"\n";
718 continue;
719 }
720
721 if (File == ExistingPPOpts.ImplicitPCHInclude)
722 continue;
723
724 if (std::find(PPOpts.Includes.begin(), PPOpts.Includes.end(), File)
725 != PPOpts.Includes.end())
726 continue;
727
728 SuggestedPredefines += "#include \"";
729 SuggestedPredefines += File;
730 SuggestedPredefines += "\"\n";
731 }
732
733 for (unsigned I = 0, N = ExistingPPOpts.MacroIncludes.size(); I != N; ++I) {
734 StringRef File = ExistingPPOpts.MacroIncludes[I];
735 if (std::find(PPOpts.MacroIncludes.begin(), PPOpts.MacroIncludes.end(),
736 File)
737 != PPOpts.MacroIncludes.end())
738 continue;
739
740 SuggestedPredefines += "#__include_macros \"";
741 SuggestedPredefines += File;
742 SuggestedPredefines += "\"\n##\n";
743 }
744
745 return false;
746 }
747
748 bool PCHValidator::ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
749 bool Complain,
750 std::string &SuggestedPredefines) {
751 const PreprocessorOptions &ExistingPPOpts = PP.getPreprocessorOpts();
752
753 return checkPreprocessorOptions(PPOpts, ExistingPPOpts,
754 Complain? &Reader.Diags : nullptr,
755 PP.getFileManager(),
756 SuggestedPredefines,
757 PP.getLangOpts());
758 }
759
760 bool SimpleASTReaderListener::ReadPreprocessorOptions(
761 const PreprocessorOptions &PPOpts,
762 bool Complain,
763 std::string &SuggestedPredefines) {
764 return checkPreprocessorOptions(PPOpts,
765 PP.getPreprocessorOpts(),
766 nullptr,
767 PP.getFileManager(),
768 SuggestedPredefines,
769 PP.getLangOpts(),
770 false);
771 }
772
773 /// Check the header search options deserialized from the control block
774 /// against the header search options in an existing preprocessor.
775 ///
776 /// \param Diags If non-null, produce diagnostics for any mismatches incurred.
777 static bool checkHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
778 StringRef SpecificModuleCachePath,
779 StringRef ExistingModuleCachePath,
780 DiagnosticsEngine *Diags,
781 const LangOptions &LangOpts) {
782 if (LangOpts.Modules) {
783 if (SpecificModuleCachePath != ExistingModuleCachePath) {
784 if (Diags)
785 Diags->Report(diag::err_pch_modulecache_mismatch)
786 << SpecificModuleCachePath << ExistingModuleCachePath;
787 return true;
788 }
789 }
790
791 return false;
792 }
793
794 bool PCHValidator::ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
795 StringRef SpecificModuleCachePath,
796 bool Complain) {
797 return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
798 PP.getHeaderSearchInfo().getModuleCachePath(),
799 Complain ? &Reader.Diags : nullptr,
800 PP.getLangOpts());
801 }
802
803 void PCHValidator::ReadCounter(const ModuleFile &M, unsigned Value) {
804 PP.setCounterValue(Value);
805 }
806
807 //===----------------------------------------------------------------------===//
808 // AST reader implementation
809 //===----------------------------------------------------------------------===//
810
811 void ASTReader::setDeserializationListener(ASTDeserializationListener *Listener,
812 bool TakeOwnership) {
813 DeserializationListener = Listener;
814 OwnsDeserializationListener = TakeOwnership;
815 }
816
817 unsigned ASTSelectorLookupTrait::ComputeHash(Selector Sel) {
818 return serialization::ComputeHash(Sel);
819 }
820
821 std::pair<unsigned, unsigned>
822 ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
823 using namespace llvm::support;
824
825 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
826 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
827 return std::make_pair(KeyLen, DataLen);
828 }
829
830 ASTSelectorLookupTrait::internal_key_type
831 ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
832 using namespace llvm::support;
833
834 SelectorTable &SelTable = Reader.getContext().Selectors;
835 unsigned N = endian::readNext<uint16_t, little, unaligned>(d);
836 IdentifierInfo *FirstII = Reader.getLocalIdentifier(
837 F, endian::readNext<uint32_t, little, unaligned>(d));
838 if (N == 0)
839 return SelTable.getNullarySelector(FirstII);
840 else if (N == 1)
841 return SelTable.getUnarySelector(FirstII);
842
843 SmallVector<IdentifierInfo *, 16> Args;
844 Args.push_back(FirstII);
845 for (unsigned I = 1; I != N; ++I)
846 Args.push_back(Reader.getLocalIdentifier(
847 F, endian::readNext<uint32_t, little, unaligned>(d)));
848
849 return SelTable.getSelector(N, Args.data());
850 }
851
852 ASTSelectorLookupTrait::data_type
853 ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
854 unsigned DataLen) {
855 using namespace llvm::support;
856
857 data_type Result;
858
859 Result.ID = Reader.getGlobalSelectorID(
860 F, endian::readNext<uint32_t, little, unaligned>(d));
861 unsigned FullInstanceBits = endian::readNext<uint16_t, little, unaligned>(d);
862 unsigned FullFactoryBits = endian::readNext<uint16_t, little, unaligned>(d);
863 Result.InstanceBits = FullInstanceBits & 0x3;
864 Result.InstanceHasMoreThanOneDecl = (FullInstanceBits >> 2) & 0x1;
865 Result.FactoryBits = FullFactoryBits & 0x3;
866 Result.FactoryHasMoreThanOneDecl = (FullFactoryBits >> 2) & 0x1;
867 unsigned NumInstanceMethods = FullInstanceBits >> 3;
868 unsigned NumFactoryMethods = FullFactoryBits >> 3;
869
870 // Load instance methods
871 for (unsigned I = 0; I != NumInstanceMethods; ++I) {
872 if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>(
873 F, endian::readNext<uint32_t, little, unaligned>(d)))
874 Result.Instance.push_back(Method);
875 }
876
877 // Load factory methods
878 for (unsigned I = 0; I != NumFactoryMethods; ++I) {
879 if (ObjCMethodDecl *Method = Reader.GetLocalDeclAs<ObjCMethodDecl>(
880 F, endian::readNext<uint32_t, little, unaligned>(d)))
881 Result.Factory.push_back(Method);
882 }
883
884 return Result;
885 }
886
887 unsigned ASTIdentifierLookupTraitBase::ComputeHash(const internal_key_type& a) {
888 return llvm::djbHash(a);
889 }
890
891 std::pair<unsigned, unsigned>
892 ASTIdentifierLookupTraitBase::ReadKeyDataLength(const unsigned char*& d) {
893 using namespace llvm::support;
894
895 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
896 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
897 return std::make_pair(KeyLen, DataLen);
898 }
899
900 ASTIdentifierLookupTraitBase::internal_key_type
901 ASTIdentifierLookupTraitBase::ReadKey(const unsigned char* d, unsigned n) {
902 assert(n >= 2 && d[n-1] == '\0');
903 return StringRef((const char*) d, n-1);
904 }
905
906 /// Whether the given identifier is "interesting".
907 static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II,
908 bool IsModule) {
909 return II.hadMacroDefinition() ||
910 II.isPoisoned() ||
911 (IsModule ? II.hasRevertedBuiltin() : II.getObjCOrBuiltinID()) ||
912 II.hasRevertedTokenIDToIdentifier() ||
913 (!(IsModule && Reader.getPreprocessor().getLangOpts().CPlusPlus) &&
914 II.getFETokenInfo());
915 }
916
917 static bool readBit(unsigned &Bits) {
918 bool Value = Bits & 0x1;
919 Bits >>= 1;
920 return Value;
921 }
922
923 IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
924 using namespace llvm::support;
925
926 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
927 return Reader.getGlobalIdentifierID(F, RawID >> 1);
928 }
929
930 static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II) {
931 if (!II.isFromAST()) {
932 II.setIsFromAST();
933 bool IsModule = Reader.getPreprocessor().getCurrentModule() != nullptr;
934 if (isInterestingIdentifier(Reader, II, IsModule))
935 II.setChangedSinceDeserialization();
936 }
937 }
938
939 IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
940 const unsigned char* d,
941 unsigned DataLen) {
942 using namespace llvm::support;
943
944 unsigned RawID = endian::readNext<uint32_t, little, unaligned>(d);
945 bool IsInteresting = RawID & 0x01;
946
947 // Wipe out the "is interesting" bit.
948 RawID = RawID >> 1;
949
950 // Build the IdentifierInfo and link the identifier ID with it.
951 IdentifierInfo *II = KnownII;
952 if (!II) {
953 II = &Reader.getIdentifierTable().getOwn(k);
954 KnownII = II;
955 }
956 markIdentifierFromAST(Reader, *II);
957 Reader.markIdentifierUpToDate(II);
958
959 IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
960 if (!IsInteresting) {
961 // For uninteresting identifiers, there's nothing else to do. Just notify
962 // the reader that we've finished loading this identifier.
963 Reader.SetIdentifierInfo(ID, II);
964 return II;
965 }
966
967 unsigned ObjCOrBuiltinID = endian::readNext<uint16_t, little, unaligned>(d);
968 unsigned Bits = endian::readNext<uint16_t, little, unaligned>(d);
969 bool CPlusPlusOperatorKeyword = readBit(Bits);
970 bool HasRevertedTokenIDToIdentifier = readBit(Bits);
971 bool HasRevertedBuiltin = readBit(Bits);
972 bool Poisoned = readBit(Bits);
973 bool ExtensionToken = readBit(Bits);
974 bool HadMacroDefinition = readBit(Bits);
975
976 assert(Bits == 0 && "Extra bits in the identifier?");
977 DataLen -= 8;
978
979 // Set or check the various bits in the IdentifierInfo structure.
980 // Token IDs are read-only.
981 if (HasRevertedTokenIDToIdentifier && II->getTokenID() != tok::identifier)
982 II->revertTokenIDToIdentifier();
983 if (!F.isModule())
984 II->setObjCOrBuiltinID(ObjCOrBuiltinID);
985 else if (HasRevertedBuiltin && II->getBuiltinID()) {
986 II->revertBuiltin();
987 assert((II->hasRevertedBuiltin() ||
988 II->getObjCOrBuiltinID() == ObjCOrBuiltinID) &&
989 "Incorrect ObjC keyword or builtin ID");
990 }
991 assert(II->isExtensionToken() == ExtensionToken &&
992 "Incorrect extension token flag");
993 (void)ExtensionToken;
994 if (Poisoned)
995 II->setIsPoisoned(true);
996 assert(II->isCPlusPlusOperatorKeyword() == CPlusPlusOperatorKeyword &&
997 "Incorrect C++ operator keyword flag");
998 (void)CPlusPlusOperatorKeyword;
999
1000 // If this identifier is a macro, deserialize the macro
1001 // definition.
1002 if (HadMacroDefinition) {
1003 uint32_t MacroDirectivesOffset =
1004 endian::readNext<uint32_t, little, unaligned>(d);
1005 DataLen -= 4;
1006
1007 Reader.addPendingMacro(II, &F, MacroDirectivesOffset);
1008 }
1009
1010 Reader.SetIdentifierInfo(ID, II);
1011
1012 // Read all of the declarations visible at global scope with this
1013 // name.
1014 if (DataLen > 0) {
1015 SmallVector<uint32_t, 4> DeclIDs;
1016 for (; DataLen > 0; DataLen -= 4)
1017 DeclIDs.push_back(Reader.getGlobalDeclID(
1018 F, endian::readNext<uint32_t, little, unaligned>(d)));
1019 Reader.SetGloballyVisibleDecls(II, DeclIDs);
1020 }
1021
1022 return II;
1023 }
1024
1025 DeclarationNameKey::DeclarationNameKey(DeclarationName Name)
1026 : Kind(Name.getNameKind()) {
1027 switch (Kind) {
1028 case DeclarationName::Identifier:
1029 Data = (uint64_t)Name.getAsIdentifierInfo();
1030 break;
1031 case DeclarationName::ObjCZeroArgSelector:
1032 case DeclarationName::ObjCOneArgSelector:
1033 case DeclarationName::ObjCMultiArgSelector:
1034 Data = (uint64_t)Name.getObjCSelector().getAsOpaquePtr();
1035 break;
1036 case DeclarationName::CXXOperatorName:
1037 Data = Name.getCXXOverloadedOperator();
1038 break;
1039 case DeclarationName::CXXLiteralOperatorName:
1040 Data = (uint64_t)Name.getCXXLiteralIdentifier();
1041 break;
1042 case DeclarationName::CXXDeductionGuideName:
1043 Data = (uint64_t)Name.getCXXDeductionGuideTemplate()
1044 ->getDeclName().getAsIdentifierInfo();
1045 break;
1046 case DeclarationName::CXXConstructorName:
1047 case DeclarationName::CXXDestructorName:
1048 case DeclarationName::CXXConversionFunctionName:
1049 case DeclarationName::CXXUsingDirective:
1050 Data = 0;
1051 break;
1052 }
1053 }
1054
1055 unsigned DeclarationNameKey::getHash() const {
1056 llvm::FoldingSetNodeID ID;
1057 ID.AddInteger(Kind);
1058
1059 switch (Kind) {
1060 case DeclarationName::Identifier:
1061 case DeclarationName::CXXLiteralOperatorName:
1062 case DeclarationName::CXXDeductionGuideName:
1063 ID.AddString(((IdentifierInfo*)Data)->getName());
1064 break;
1065 case DeclarationName::ObjCZeroArgSelector:
1066 case DeclarationName::ObjCOneArgSelector:
1067 case DeclarationName::ObjCMultiArgSelector:
1068 ID.AddInteger(serialization::ComputeHash(Selector(Data)));
1069 break;
1070 case DeclarationName::CXXOperatorName:
1071 ID.AddInteger((OverloadedOperatorKind)Data);
1072 break;
1073 case DeclarationName::CXXConstructorName:
1074 case DeclarationName::CXXDestructorName:
1075 case DeclarationName::CXXConversionFunctionName:
1076 case DeclarationName::CXXUsingDirective:
1077 break;
1078 }
1079
1080 return ID.ComputeHash();
1081 }
1082
1083 ModuleFile *
1084 ASTDeclContextNameLookupTrait::ReadFileRef(const unsigned char *&d) {
1085 using namespace llvm::support;
1086
1087 uint32_t ModuleFileID = endian::readNext<uint32_t, little, unaligned>(d);
1088 return Reader.getLocalModuleFile(F, ModuleFileID);
1089 }
1090
1091 std::pair<unsigned, unsigned>
1092 ASTDeclContextNameLookupTrait::ReadKeyDataLength(const unsigned char *&d) {
1093 using namespace llvm::support;
1094
1095 unsigned KeyLen = endian::readNext<uint16_t, little, unaligned>(d);
1096 unsigned DataLen = endian::readNext<uint16_t, little, unaligned>(d);
1097 return std::make_pair(KeyLen, DataLen);
1098 }
1099
1100 ASTDeclContextNameLookupTrait::internal_key_type
1101 ASTDeclContextNameLookupTrait::ReadKey(const unsigned char *d, unsigned) {
1102 using namespace llvm::support;
1103
1104 auto Kind = (DeclarationName::NameKind)*d++;
1105 uint64_t Data;
1106 switch (Kind) {
1107 case DeclarationName::Identifier:
1108 case DeclarationName::CXXLiteralOperatorName:
1109 case DeclarationName::CXXDeductionGuideName:
1110 Data = (uint64_t)Reader.getLocalIdentifier(
1111 F, endian::readNext<uint32_t, little, unaligned>(d));
1112 break;
1113 case DeclarationName::ObjCZeroArgSelector:
1114 case DeclarationName::ObjCOneArgSelector:
1115 case DeclarationName::ObjCMultiArgSelector:
1116 Data =
1117 (uint64_t)Reader.getLocalSelector(
1118 F, endian::readNext<uint32_t, little, unaligned>(
1119 d)).getAsOpaquePtr();
1120 break;
1121 case DeclarationName::CXXOperatorName:
1122 Data = *d++; // OverloadedOperatorKind
1123 break;
1124 case DeclarationName::CXXConstructorName:
1125 case DeclarationName::CXXDestructorName:
1126 case DeclarationName::CXXConversionFunctionName:
1127 case DeclarationName::CXXUsingDirective:
1128 Data = 0;
1129 break;
1130 }
1131
1132 return DeclarationNameKey(Kind, Data);
1133 }
1134
1135 void ASTDeclContextNameLookupTrait::ReadDataInto(internal_key_type,
1136 const unsigned char *d,
1137 unsigned DataLen,
1138 data_type_builder &Val) {
1139 using namespace llvm::support;
1140
1141 for (unsigned NumDecls = DataLen / 4; NumDecls; --NumDecls) {
1142 uint32_t LocalID = endian::readNext<uint32_t, little, unaligned>(d);
1143 Val.insert(Reader.getGlobalDeclID(F, LocalID));
1144 }
1145 }
1146
1147 bool ASTReader::ReadLexicalDeclContextStorage(ModuleFile &M,
1148 BitstreamCursor &Cursor,
1149 uint64_t Offset,
1150 DeclContext *DC) {
1151 assert(Offset != 0);
1152
1153 SavedStreamPosition SavedPosition(Cursor);
1154 if (llvm::Error Err = Cursor.JumpToBit(Offset)) {
1155 Error(std::move(Err));
1156 return true;
1157 }
1158
1159 RecordData Record;
1160 StringRef Blob;
1161 Expected<unsigned> MaybeCode = Cursor.ReadCode();
1162 if (!MaybeCode) {
1163 Error(MaybeCode.takeError());
1164 return true;
1165 }
1166 unsigned Code = MaybeCode.get();
1167
1168 Expected<unsigned> MaybeRecCode = Cursor.readRecord(Code, Record, &Blob);
1169 if (!MaybeRecCode) {
1170 Error(MaybeRecCode.takeError());
1171 return true;
1172 }
1173 unsigned RecCode = MaybeRecCode.get();
1174 if (RecCode != DECL_CONTEXT_LEXICAL) {
1175 Error("Expected lexical block");
1176 return true;
1177 }
1178
1179 assert(!isa<TranslationUnitDecl>(DC) &&
1180 "expected a TU_UPDATE_LEXICAL record for TU");
1181 // If we are handling a C++ class template instantiation, we can see multiple
1182 // lexical updates for the same record. It's important that we select only one
1183 // of them, so that field numbering works properly. Just pick the first one we
1184 // see.
1185 auto &Lex = LexicalDecls[DC];
1186 if (!Lex.first) {
1187 Lex = std::make_pair(
1188 &M, llvm::makeArrayRef(
1189 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
1190 Blob.data()),
1191 Blob.size() / 4));
1192 }
1193 DC->setHasExternalLexicalStorage(true);
1194 return false;
1195 }
1196
1197 bool ASTReader::ReadVisibleDeclContextStorage(ModuleFile &M,
1198 BitstreamCursor &Cursor,
1199 uint64_t Offset,
1200 DeclID ID) {
1201 assert(Offset != 0);
1202
1203 SavedStreamPosition SavedPosition(Cursor);
1204 if (llvm::Error Err = Cursor.JumpToBit(Offset)) {
1205 Error(std::move(Err));
1206 return true;
1207 }
1208
1209 RecordData Record;
1210 StringRef Blob;
1211 Expected<unsigned> MaybeCode = Cursor.ReadCode();
1212 if (!MaybeCode) {
1213 Error(MaybeCode.takeError());
1214 return true;
1215 }
1216 unsigned Code = MaybeCode.get();
1217
1218 Expected<unsigned> MaybeRecCode = Cursor.readRecord(Code, Record, &Blob);
1219 if (!MaybeRecCode) {
1220 Error(MaybeRecCode.takeError());
1221 return true;
1222 }
1223 unsigned RecCode = MaybeRecCode.get();
1224 if (RecCode != DECL_CONTEXT_VISIBLE) {
1225 Error("Expected visible lookup table block");
1226 return true;
1227 }
1228
1229 // We can't safely determine the primary context yet, so delay attaching the
1230 // lookup table until we're done with recursive deserialization.
1231 auto *Data = (const unsigned char*)Blob.data();
1232 PendingVisibleUpdates[ID].push_back(PendingVisibleUpdate{&M, Data});
1233 return false;
1234 }
1235
1236 void ASTReader::Error(StringRef Msg) const {
1237 Error(diag::err_fe_pch_malformed, Msg);
1238 if (PP.getLangOpts().Modules && !Diags.isDiagnosticInFlight() &&
1239 !PP.getHeaderSearchInfo().getModuleCachePath().empty()) {
1240 Diag(diag::note_module_cache_path)
1241 << PP.getHeaderSearchInfo().getModuleCachePath();
1242 }
1243 }
1244
1245 void ASTReader::Error(unsigned DiagID, StringRef Arg1, StringRef Arg2,
1246 StringRef Arg3) const {
1247 if (Diags.isDiagnosticInFlight())
1248 Diags.SetDelayedDiagnostic(DiagID, Arg1, Arg2, Arg3);
1249 else
1250 Diag(DiagID) << Arg1 << Arg2 << Arg3;
1251 }
1252
1253 void ASTReader::Error(unsigned DiagID, StringRef Arg1, StringRef Arg2,
1254 unsigned Select) const {
1255 if (!Diags.isDiagnosticInFlight())
1256 Diag(DiagID) << Arg1 << Arg2 << Select;
1257 }
1258
1259 void ASTReader::Error(llvm::Error &&Err) const {
1260 Error(toString(std::move(Err)));
1261 }
1262
1263 //===----------------------------------------------------------------------===//
1264 // Source Manager Deserialization
1265 //===----------------------------------------------------------------------===//
1266
1267 /// Read the line table in the source manager block.
1268 /// \returns true if there was an error.
1269 bool ASTReader::ParseLineTable(ModuleFile &F,
1270 const RecordData &Record) {
1271 unsigned Idx = 0;
1272 LineTableInfo &LineTable = SourceMgr.getLineTable();
1273
1274 // Parse the file names
1275 std::map<int, int> FileIDs;
1276 FileIDs[-1] = -1; // For unspecified filenames.
1277 for (unsigned I = 0; Record[Idx]; ++I) {
1278 // Extract the file name
1279 auto Filename = ReadPath(F, Record, Idx);
1280 FileIDs[I] = LineTable.getLineTableFilenameID(Filename);
1281 }
1282 ++Idx;
1283
1284 // Parse the line entries
1285 std::vector<LineEntry> Entries;
1286 while (Idx < Record.size()) {
1287 int FID = Record[Idx++];
1288 assert(FID >= 0 && "Serialized line entries for non-local file.");
1289 // Remap FileID from 1-based old view.
1290 FID += F.SLocEntryBaseID - 1;
1291
1292 // Extract the line entries
1293 unsigned NumEntries = Record[Idx++];
1294 assert(NumEntries && "no line entries for file ID");
1295 Entries.clear();
1296 Entries.reserve(NumEntries);
1297 for (unsigned I = 0; I != NumEntries; ++I) {
1298 unsigned FileOffset = Record[Idx++];
1299 unsigned LineNo = Record[Idx++];
1300 int FilenameID = FileIDs[Record[Idx++]];
1301 SrcMgr::CharacteristicKind FileKind
1302 = (SrcMgr::CharacteristicKind)Record[Idx++];
1303 unsigned IncludeOffset = Record[Idx++];
1304 Entries.push_back(LineEntry::get(FileOffset, LineNo, FilenameID,
1305 FileKind, IncludeOffset));
1306 }
1307 LineTable.AddEntry(FileID::get(FID), Entries);
1308 }
1309
1310 return false;
1311 }
1312
1313 /// Read a source manager block
1314 bool ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
1315 using namespace SrcMgr;
1316
1317 BitstreamCursor &SLocEntryCursor = F.SLocEntryCursor;
1318
1319 // Set the source-location entry cursor to the current position in
1320 // the stream. This cursor will be used to read the contents of the
1321 // source manager block initially, and then lazily read
1322 // source-location entries as needed.
1323 SLocEntryCursor = F.Stream;
1324
1325 // The stream itself is going to skip over the source manager block.
1326 if (llvm::Error Err = F.Stream.SkipBlock()) {
1327 Error(std::move(Err));
1328 return true;
1329 }
1330
1331 // Enter the source manager block.
1332 if (llvm::Error Err =
1333 SLocEntryCursor.EnterSubBlock(SOURCE_MANAGER_BLOCK_ID)) {
1334 Error(std::move(Err));
1335 return true;
1336 }
1337
1338 RecordData Record;
1339 while (true) {
1340 Expected<llvm::BitstreamEntry> MaybeE =
1341 SLocEntryCursor.advanceSkippingSubblocks();
1342 if (!MaybeE) {
1343 Error(MaybeE.takeError());
1344 return true;
1345 }
1346 llvm::BitstreamEntry E = MaybeE.get();
1347
1348 switch (E.Kind) {
1349 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1350 case llvm::BitstreamEntry::Error:
1351 Error("malformed block record in AST file");
1352 return true;
1353 case llvm::BitstreamEntry::EndBlock:
1354 return false;
1355 case llvm::BitstreamEntry::Record:
1356 // The interesting case.
1357 break;
1358 }
1359
1360 // Read a record.
1361 Record.clear();
1362 StringRef Blob;
1363 Expected<unsigned> MaybeRecord =
1364 SLocEntryCursor.readRecord(E.ID, Record, &Blob);
1365 if (!MaybeRecord) {
1366 Error(MaybeRecord.takeError());
1367 return true;
1368 }
1369 switch (MaybeRecord.get()) {
1370 default: // Default behavior: ignore.
1371 break;
1372
1373 case SM_SLOC_FILE_ENTRY:
1374 case SM_SLOC_BUFFER_ENTRY:
1375 case SM_SLOC_EXPANSION_ENTRY:
1376 // Once we hit one of the source location entries, we're done.
1377 return false;
1378 }
1379 }
1380 }
1381
1382 /// If a header file is not found at the path that we expect it to be
1383 /// and the PCH file was moved from its original location, try to resolve the
1384 /// file by assuming that header+PCH were moved together and the header is in
1385 /// the same place relative to the PCH.
1386 static std::string
1387 resolveFileRelativeToOriginalDir(const std::string &Filename,
1388 const std::string &OriginalDir,
1389 const std::string &CurrDir) {
1390 assert(OriginalDir != CurrDir &&
1391 "No point trying to resolve the file if the PCH dir didn't change");
1392
1393 using namespace llvm::sys;
1394
1395 SmallString<128> filePath(Filename);
1396 fs::make_absolute(filePath);
1397 assert(path::is_absolute(OriginalDir));
1398 SmallString<128> currPCHPath(CurrDir);
1399
1400 path::const_iterator fileDirI = path::begin(path::parent_path(filePath)),
1401 fileDirE = path::end(path::parent_path(filePath));
1402 path::const_iterator origDirI = path::begin(OriginalDir),
1403 origDirE = path::end(OriginalDir);
1404 // Skip the common path components from filePath and OriginalDir.
1405 while (fileDirI != fileDirE && origDirI != origDirE &&
1406 *fileDirI == *origDirI) {
1407 ++fileDirI;
1408 ++origDirI;
1409 }
1410 for (; origDirI != origDirE; ++origDirI)
1411 path::append(currPCHPath, "..");
1412 path::append(currPCHPath, fileDirI, fileDirE);
1413 path::append(currPCHPath, path::filename(Filename));
1414 return currPCHPath.str();
1415 }
1416
1417 bool ASTReader::ReadSLocEntry(int ID) {
1418 if (ID == 0)
1419 return false;
1420
1421 if (unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1422 Error("source location entry ID out-of-range for AST file");
1423 return true;
1424 }
1425
1426 // Local helper to read the (possibly-compressed) buffer data following the
1427 // entry record.
1428 auto ReadBuffer = [this](
1429 BitstreamCursor &SLocEntryCursor,
1430 StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1431 RecordData Record;
1432 StringRef Blob;
1433 Expected<unsigned> MaybeCode = SLocEntryCursor.ReadCode();
1434 if (!MaybeCode) {
1435 Error(MaybeCode.takeError());
1436 return nullptr;
1437 }
1438 unsigned Code = MaybeCode.get();
1439
1440 Expected<unsigned> MaybeRecCode =
1441 SLocEntryCursor.readRecord(Code, Record, &Blob);
1442 if (!MaybeRecCode) {
1443 Error(MaybeRecCode.takeError());
1444 return nullptr;
1445 }
1446 unsigned RecCode = MaybeRecCode.get();
1447
1448 if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) {
1449 if (!llvm::zlib::isAvailable()) {
1450 Error("zlib is not available");
1451 return nullptr;
1452 }
1453 SmallString<0> Uncompressed;
1454 if (llvm::Error E =
1455 llvm::zlib::uncompress(Blob, Uncompressed, Record[0])) {
1456 Error("could not decompress embedded file contents: " +
1457 llvm::toString(std::move(E)));
1458 return nullptr;
1459 }
1460 return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name);
1461 } else if (RecCode == SM_SLOC_BUFFER_BLOB) {
1462 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name, true);
1463 } else {
1464 Error("AST record has invalid code");
1465 return nullptr;
1466 }
1467 };
1468
1469 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1470 if (llvm::Error Err = F->SLocEntryCursor.JumpToBit(
1471 F->SLocEntryOffsets[ID - F->SLocEntryBaseID])) {
1472 Error(std::move(Err));
1473 return true;
1474 }
1475
1476 BitstreamCursor &SLocEntryCursor = F->SLocEntryCursor;
1477 unsigned BaseOffset = F->SLocEntryBaseOffset;
1478
1479 ++NumSLocEntriesRead;
1480 Expected<llvm::BitstreamEntry> MaybeEntry = SLocEntryCursor.advance();
1481 if (!MaybeEntry) {
1482 Error(MaybeEntry.takeError());
1483 return true;
1484 }
1485 llvm::BitstreamEntry Entry = MaybeEntry.get();
1486
1487 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1488 Error("incorrectly-formatted source location entry in AST file");
1489 return true;
1490 }
1491
1492 RecordData Record;
1493 StringRef Blob;
1494 Expected<unsigned> MaybeSLOC =
1495 SLocEntryCursor.readRecord(Entry.ID, Record, &Blob);
1496 if (!MaybeSLOC) {
1497 Error(MaybeSLOC.takeError());
1498 return true;
1499 }
1500 switch (MaybeSLOC.get()) {
1501 default:
1502 Error("incorrectly-formatted source location entry in AST file");
1503 return true;
1504
1505 case SM_SLOC_FILE_ENTRY: {
1506 // We will detect whether a file changed and return 'Failure' for it, but
1507 // we will also try to fail gracefully by setting up the SLocEntry.
1508 unsigned InputID = Record[4];
1509 InputFile IF = getInputFile(*F, InputID);
1510 const FileEntry *File = IF.getFile();
1511 bool OverriddenBuffer = IF.isOverridden();
1512
1513 // Note that we only check if a File was returned. If it was out-of-date
1514 // we have complained but we will continue creating a FileID to recover
1515 // gracefully.
1516 if (!File)
1517 return true;
1518
1519 SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
1520 if (IncludeLoc.isInvalid() && F->Kind != MK_MainFile) {
1521 // This is the module's main file.
1522 IncludeLoc = getImportLocation(F);
1523 }
1524 SrcMgr::CharacteristicKind
1525 FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
1526 // FIXME: The FileID should be created from the FileEntryRef.
1527 FileID FID = SourceMgr.createFileID(File, IncludeLoc, FileCharacter,
1528 ID, BaseOffset + Record[0]);
1529 SrcMgr::FileInfo &FileInfo =
1530 const_cast<SrcMgr::FileInfo&>(SourceMgr.getSLocEntry(FID).getFile());
1531 FileInfo.NumCreatedFIDs = Record[5];
1532 if (Record[3])
1533 FileInfo.setHasLineDirectives();
1534
1535 unsigned NumFileDecls = Record[7];
1536 if (NumFileDecls && ContextObj) {
1537 const DeclID *FirstDecl = F->FileSortedDecls + Record[6];
1538 assert(F->FileSortedDecls && "FILE_SORTED_DECLS not encountered yet ?");
1539 FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
1540 NumFileDecls));
1541 }
1542
1543 const SrcMgr::ContentCache *ContentCache
1544 = SourceMgr.getOrCreateContentCache(File, isSystem(FileCharacter));
1545 if (OverriddenBuffer && !ContentCache->BufferOverridden &&
1546 ContentCache->ContentsEntry == ContentCache->OrigEntry &&
1547 !ContentCache->getRawBuffer()) {
1548 auto Buffer = ReadBuffer(SLocEntryCursor, File->getName());
1549 if (!Buffer)
1550 return true;
1551 SourceMgr.overrideFileContents(File, std::move(Buffer));
1552 }
1553
1554 break;
1555 }
1556
1557 case SM_SLOC_BUFFER_ENTRY: {
1558 const char *Name = Blob.data();
1559 unsigned Offset = Record[0];
1560 SrcMgr::CharacteristicKind
1561 FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
1562 SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
1563 if (IncludeLoc.isInvalid() && F->isModule()) {
1564 IncludeLoc = getImportLocation(F);
1565 }
1566
1567 auto Buffer = ReadBuffer(SLocEntryCursor, Name);
1568 if (!Buffer)
1569 return true;
1570 SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
1571 BaseOffset + Offset, IncludeLoc);
1572 break;
1573 }
1574
1575 case SM_SLOC_EXPANSION_ENTRY: {
1576 SourceLocation SpellingLoc = ReadSourceLocation(*F, Record[1]);
1577 SourceMgr.createExpansionLoc(SpellingLoc,
1578 ReadSourceLocation(*F, Record[2]),
1579 ReadSourceLocation(*F, Record[3]),
1580 Record[5],
1581 Record[4],
1582 ID,
1583 BaseOffset + Record[0]);
1584 break;
1585 }
1586 }
1587
1588 return false;
1589 }
1590
1591 std::pair<SourceLocation, StringRef> ASTReader::getModuleImportLoc(int ID) {
1592 if (ID == 0)
1593 return std::make_pair(SourceLocation(), "");
1594
1595 if (unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1596 Error("source location entry ID out-of-range for AST file");
1597 return std::make_pair(SourceLocation(), "");
1598 }
1599
1600 // Find which module file this entry lands in.
1601 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1602 if (!M->isModule())
1603 return std::make_pair(SourceLocation(), "");
1604
1605 // FIXME: Can we map this down to a particular submodule? That would be
1606 // ideal.
1607 return std::make_pair(M->ImportLoc, StringRef(M->ModuleName));
1608 }
1609
1610 /// Find the location where the module F is imported.
1611 SourceLocation ASTReader::getImportLocation(ModuleFile *F) {
1612 if (F->ImportLoc.isValid())
1613 return F->ImportLoc;
1614
1615 // Otherwise we have a PCH. It's considered to be "imported" at the first
1616 // location of its includer.
1617 if (F->ImportedBy.empty() || !F->ImportedBy[0]) {
1618 // Main file is the importer.
1619 assert(SourceMgr.getMainFileID().isValid() && "missing main file");
1620 return SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
1621 }
1622 return F->ImportedBy[0]->FirstLoc;
1623 }
1624
1625 /// Enter a subblock of the specified BlockID with the specified cursor. Read
1626 /// the abbreviations that are at the top of the block and then leave the cursor
1627 /// pointing into the block.
1628 bool ASTReader::ReadBlockAbbrevs(BitstreamCursor &Cursor, unsigned BlockID) {
1629 if (llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
1630 // FIXME this drops errors on the floor.
1631 consumeError(std::move(Err));
1632 return true;
1633 }
1634
1635 while (true) {
1636 uint64_t Offset = Cursor.GetCurrentBitNo();
1637 Expected<unsigned> MaybeCode = Cursor.ReadCode();
1638 if (!MaybeCode) {
1639 // FIXME this drops errors on the floor.
1640 consumeError(MaybeCode.takeError());
1641 return true;
1642 }
1643 unsigned Code = MaybeCode.get();
1644
1645 // We expect all abbrevs to be at the start of the block.
1646 if (Code != llvm::bitc::DEFINE_ABBREV) {
1647 if (llvm::Error Err = Cursor.JumpToBit(Offset)) {
1648 // FIXME this drops errors on the floor.
1649 consumeError(std::move(Err));
1650 return true;
1651 }
1652 return false;
1653 }
1654 if (llvm::Error Err = Cursor.ReadAbbrevRecord()) {
1655 // FIXME this drops errors on the floor.
1656 consumeError(std::move(Err));
1657 return true;
1658 }
1659 }
1660 }
1661
1662 Token ASTReader::ReadToken(ModuleFile &F, const RecordDataImpl &Record,
1663 unsigned &Idx) {
1664 Token Tok;
1665 Tok.startToken();
1666 Tok.setLocation(ReadSourceLocation(F, Record, Idx));
1667 Tok.setLength(Record[Idx++]);
1668 if (IdentifierInfo *II = getLocalIdentifier(F, Record[Idx++]))
1669 Tok.setIdentifierInfo(II);
1670 Tok.setKind((tok::TokenKind)Record[Idx++]);
1671 Tok.setFlag((Token::TokenFlags)Record[Idx++]);
1672 return Tok;
1673 }
1674
1675 MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
1676 BitstreamCursor &Stream = F.MacroCursor;
1677
1678 // Keep track of where we are in the stream, then jump back there
1679 // after reading this macro.
1680 SavedStreamPosition SavedPosition(Stream);
1681
1682 if (llvm::Error Err = Stream.JumpToBit(Offset)) {
1683 // FIXME this drops errors on the floor.
1684 consumeError(std::move(Err));
1685 return nullptr;
1686 }
1687 RecordData Record;
1688 SmallVector<IdentifierInfo*, 16> MacroParams;
1689 MacroInfo *Macro = nullptr;
1690
1691 while (true) {
1692 // Advance to the next record, but if we get to the end of the block, don't
1693 // pop it (removing all the abbreviations from the cursor) since we want to
1694 // be able to reseek within the block and read entries.
1695 unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
1696 Expected<llvm::BitstreamEntry> MaybeEntry =
1697 Stream.advanceSkippingSubblocks(Flags);
1698 if (!MaybeEntry) {
1699 Error(MaybeEntry.takeError());
1700 return Macro;
1701 }
1702 llvm::BitstreamEntry Entry = MaybeEntry.get();
1703
1704 switch (Entry.Kind) {
1705 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1706 case llvm::BitstreamEntry::Error:
1707 Error("malformed block record in AST file");
1708 return Macro;
1709 case llvm::BitstreamEntry::EndBlock:
1710 return Macro;
1711 case llvm::BitstreamEntry::Record:
1712 // The interesting case.
1713 break;
1714 }
1715
1716 // Read a record.
1717 Record.clear();
1718 PreprocessorRecordTypes RecType;
1719 if (Expected<unsigned> MaybeRecType = Stream.readRecord(Entry.ID, Record))
1720 RecType = (PreprocessorRecordTypes)MaybeRecType.get();
1721 else {
1722 Error(MaybeRecType.takeError());
1723 return Macro;
1724 }
1725 switch (RecType) {
1726 case PP_MODULE_MACRO:
1727 case PP_MACRO_DIRECTIVE_HISTORY:
1728 return Macro;
1729
1730 case PP_MACRO_OBJECT_LIKE:
1731 case PP_MACRO_FUNCTION_LIKE: {
1732 // If we already have a macro, that means that we've hit the end
1733 // of the definition of the macro we were looking for. We're
1734 // done.
1735 if (Macro)
1736 return Macro;
1737
1738 unsigned NextIndex = 1; // Skip identifier ID.
1739 SourceLocation Loc = ReadSourceLocation(F, Record, NextIndex);
1740 MacroInfo *MI = PP.AllocateMacroInfo(Loc);
1741 MI->setDefinitionEndLoc(ReadSourceLocation(F, Record, NextIndex));
1742 MI->setIsUsed(Record[NextIndex++]);
1743 MI->setUsedForHeaderGuard(Record[NextIndex++]);
1744
1745 if (RecType == PP_MACRO_FUNCTION_LIKE) {
1746 // Decode function-like macro info.
1747 bool isC99VarArgs = Record[NextIndex++];
1748 bool isGNUVarArgs = Record[NextIndex++];
1749 bool hasCommaPasting = Record[NextIndex++];
1750 MacroParams.clear();
1751 unsigned NumArgs = Record[NextIndex++];
1752 for (unsigned i = 0; i != NumArgs; ++i)
1753 MacroParams.push_back(getLocalIdentifier(F, Record[NextIndex++]));
1754
1755 // Install function-like macro info.
1756 MI->setIsFunctionLike();
1757 if (isC99VarArgs) MI->setIsC99Varargs();
1758 if (isGNUVarArgs) MI->setIsGNUVarargs();
1759 if (hasCommaPasting) MI->setHasCommaPasting();
1760 MI->setParameterList(MacroParams, PP.getPreprocessorAllocator());
1761 }
1762
1763 // Remember that we saw this macro last so that we add the tokens that
1764 // form its body to it.
1765 Macro = MI;
1766
1767 if (NextIndex + 1 == Record.size() && PP.getPreprocessingRecord() &&
1768 Record[NextIndex]) {
1769 // We have a macro definition. Register the association
1770 PreprocessedEntityID
1771 GlobalID = getGlobalPreprocessedEntityID(F, Record[NextIndex]);
1772 PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
1773 PreprocessingRecord::PPEntityID PPID =
1774 PPRec.getPPEntityID(GlobalID - 1, /*isLoaded=*/true);
1775 MacroDefinitionRecord *PPDef = cast_or_null<MacroDefinitionRecord>(
1776 PPRec.getPreprocessedEntity(PPID));
1777 if (PPDef)
1778 PPRec.RegisterMacroDefinition(Macro, PPDef);
1779 }
1780
1781 ++NumMacrosRead;
1782 break;
1783 }
1784
1785 case PP_TOKEN: {
1786 // If we see a TOKEN before a PP_MACRO_*, then the file is
1787 // erroneous, just pretend we didn't see this.
1788 if (!Macro) break;
1789
1790 unsigned Idx = 0;
1791 Token Tok = ReadToken(F, Record, Idx);
1792 Macro->AddTokenToBody(Tok);
1793 break;
1794 }
1795 }
1796 }
1797 }
1798
1799 PreprocessedEntityID
1800 ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M,
1801 unsigned LocalID) const {
1802 if (!M.ModuleOffsetMap.empty())
1803 ReadModuleOffsetMap(M);
1804
1805 ContinuousRangeMap<uint32_t, int, 2>::const_iterator
1806 I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
1807 assert(I != M.PreprocessedEntityRemap.end()
1808 && "Invalid index into preprocessed entity index remap");
1809
1810 return LocalID + I->second;
1811 }
1812
1813 unsigned HeaderFileInfoTrait::ComputeHash(internal_key_ref ikey) {
1814 return llvm::hash_combine(ikey.Size, ikey.ModTime);
1815 }
1816
1817 HeaderFileInfoTrait::internal_key_type
1818 HeaderFileInfoTrait::GetInternalKey(const FileEntry *FE) {
1819 internal_key_type ikey = {FE->getSize(),
1820 M.HasTimestamps ? FE->getModificationTime() : 0,
1821 FE->getName(), /*Imported*/ false};
1822 return ikey;
1823 }
1824
1825 bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
1826 if (a.Size != b.Size || (a.ModTime && b.ModTime && a.ModTime != b.ModTime))
1827 return false;
1828
1829 if (llvm::sys::path::is_absolute(a.Filename) && a.Filename == b.Filename)
1830 return true;
1831
1832 // Determine whether the actual files are equivalent.
1833 FileManager &FileMgr = Reader.getFileManager();
1834 auto GetFile = [&](const internal_key_type &Key) -> const FileEntry* {
1835 if (!Key.Imported) {
1836 if (auto File = FileMgr.getFile(Key.Filename))
1837 return *File;
1838 return nullptr;
1839 }
1840
1841 std::string Resolved = Key.Filename;
1842 Reader.ResolveImportedPath(M, Resolved);
1843 if (auto File = FileMgr.getFile(Resolved))
1844 return *File;
1845 return nullptr;
1846 };
1847
1848 const FileEntry *FEA = GetFile(a);
1849 const FileEntry *FEB = GetFile(b);
1850 return FEA && FEA == FEB;
1851 }
1852
1853 std::pair<unsigned, unsigned>
1854 HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
1855 using namespace llvm::support;
1856
1857 unsigned KeyLen = (unsigned) endian::readNext<uint16_t, little, unaligned>(d);
1858 unsigned DataLen = (unsigned) *d++;
1859 return std::make_pair(KeyLen, DataLen);
1860 }
1861
1862 HeaderFileInfoTrait::internal_key_type
1863 HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) {
1864 using namespace llvm::support;
1865
1866 internal_key_type ikey;
1867 ikey.Size = off_t(endian::readNext<uint64_t, little, unaligned>(d));
1868 ikey.ModTime = time_t(endian::readNext<uint64_t, little, unaligned>(d));
1869 ikey.Filename = (const char *)d;
1870 ikey.Imported = true;
1871 return ikey;
1872 }
1873
1874 HeaderFileInfoTrait::data_type
1875 HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
1876 unsigned DataLen) {
1877 using namespace llvm::support;
1878
1879 const unsigned char *End = d + DataLen;
1880 HeaderFileInfo HFI;
1881 unsigned Flags = *d++;
1882 // FIXME: Refactor with mergeHeaderFileInfo in HeaderSearch.cpp.
1883 HFI.isImport |= (Flags >> 5) & 0x01;
1884 HFI.isPragmaOnce |= (Flags >> 4) & 0x01;
1885 HFI.DirInfo = (Flags >> 1) & 0x07;
1886 HFI.IndexHeaderMapHeader = Flags & 0x01;
1887 // FIXME: Find a better way to handle this. Maybe just store a
1888 // "has been included" flag?
1889 HFI.NumIncludes = std::max(endian::readNext<uint16_t, little, unaligned>(d),
1890 HFI.NumIncludes);
1891 HFI.ControllingMacroID = Reader.getGlobalIdentifierID(
1892 M, endian::readNext<uint32_t, little, unaligned>(d));
1893 if (unsigned FrameworkOffset =
1894 endian::readNext<uint32_t, little, unaligned>(d)) {
1895 // The framework offset is 1 greater than the actual offset,
1896 // since 0 is used as an indicator for "no framework name".
1897 StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
1898 HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
1899 }
1900
1901 assert((End - d) % 4 == 0 &&
1902 "Wrong data length in HeaderFileInfo deserialization");
1903 while (d != End) {
1904 uint32_t LocalSMID = endian::readNext<uint32_t, little, unaligned>(d);
1905 auto HeaderRole = static_cast<ModuleMap::ModuleHeaderRole>(LocalSMID & 3);
1906 LocalSMID >>= 2;
1907
1908 // This header is part of a module. Associate it with the module to enable
1909 // implicit module import.
1910 SubmoduleID GlobalSMID = Reader.getGlobalSubmoduleID(M, LocalSMID);
1911 Module *Mod = Reader.getSubmodule(GlobalSMID);
1912 FileManager &FileMgr = Reader.getFileManager();
1913 ModuleMap &ModMap =
1914 Reader.getPreprocessor().getHeaderSearchInfo().getModuleMap();
1915
1916 std::string Filename = key.Filename;
1917 if (key.Imported)
1918 Reader.ResolveImportedPath(M, Filename);
1919 // FIXME: This is not always the right filename-as-written, but we're not
1920 // going to use this information to rebuild the module, so it doesn't make
1921 // a lot of difference.
1922 Module::Header H = { key.Filename, *FileMgr.getFile(Filename) };
1923 ModMap.addHeader(Mod, H, HeaderRole, /*Imported*/true);
1924 HFI.isModuleHeader |= !(HeaderRole & ModuleMap::TextualHeader);
1925 }
1926
1927 // This HeaderFileInfo was externally loaded.
1928 HFI.External = true;
1929 HFI.IsValid = true;
1930 return HFI;
1931 }
1932
1933 void ASTReader::addPendingMacro(IdentifierInfo *II,
1934 ModuleFile *M,
1935 uint64_t MacroDirectivesOffset) {
1936 assert(NumCurrentElementsDeserializing > 0 &&"Missing deserialization guard");
1937 PendingMacroIDs[II].push_back(PendingMacroInfo(M, MacroDirectivesOffset));
1938 }
1939
1940 void ASTReader::ReadDefinedMacros() {
1941 // Note that we are loading defined macros.
1942 Deserializing Macros(this);
1943
1944 for (ModuleFile &I : llvm::reverse(ModuleMgr)) {
1945 BitstreamCursor &MacroCursor = I.MacroCursor;
1946
1947 // If there was no preprocessor block, skip this file.
1948 if (MacroCursor.getBitcodeBytes().empty())
1949 continue;
1950
1951 BitstreamCursor Cursor = MacroCursor;
1952 if (llvm::Error Err = Cursor.JumpToBit(I.MacroStartOffset)) {
1953 Error(std::move(Err));
1954 return;
1955 }
1956
1957 RecordData Record;
1958 while (true) {
1959 Expected<llvm::BitstreamEntry> MaybeE = Cursor.advanceSkippingSubblocks();
1960 if (!MaybeE) {
1961 Error(MaybeE.takeError());
1962 return;
1963 }
1964 llvm::BitstreamEntry E = MaybeE.get();
1965
1966 switch (E.Kind) {
1967 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1968 case llvm::BitstreamEntry::Error:
1969 Error("malformed block record in AST file");
1970 return;
1971 case llvm::BitstreamEntry::EndBlock:
1972 goto NextCursor;
1973
1974 case llvm::BitstreamEntry::Record: {
1975 Record.clear();
1976 Expected<unsigned> MaybeRecord = Cursor.readRecord(E.ID, Record);
1977 if (!MaybeRecord) {
1978 Error(MaybeRecord.takeError());
1979 return;
1980 }
1981 switch (MaybeRecord.get()) {
1982 default: // Default behavior: ignore.
1983 break;
1984
1985 case PP_MACRO_OBJECT_LIKE:
1986 case PP_MACRO_FUNCTION_LIKE: {
1987 IdentifierInfo *II = getLocalIdentifier(I, Record[0]);
1988 if (II->isOutOfDate())
1989 updateOutOfDateIdentifier(*II);
1990 break;
1991 }
1992
1993 case PP_TOKEN:
1994 // Ignore tokens.
1995 break;
1996 }
1997 break;
1998 }
1999 }
2000 }
2001 NextCursor: ;
2002 }
2003 }
2004
2005 namespace {
2006
2007 /// Visitor class used to look up identifirs in an AST file.
2008 class IdentifierLookupVisitor {
2009 StringRef Name;
2010 unsigned NameHash;
2011 unsigned PriorGeneration;
2012 unsigned &NumIdentifierLookups;
2013 unsigned &NumIdentifierLookupHits;
2014 IdentifierInfo *Found = nullptr;
2015
2016 public:
2017 IdentifierLookupVisitor(StringRef Name, unsigned PriorGeneration,
2018 unsigned &NumIdentifierLookups,
2019 unsigned &NumIdentifierLookupHits)
2020 : Name(Name), NameHash(ASTIdentifierLookupTrait::ComputeHash(Name)),
2021 PriorGeneration(PriorGeneration),
2022 NumIdentifierLookups(NumIdentifierLookups),
2023 NumIdentifierLookupHits(NumIdentifierLookupHits) {}
2024
2025 bool operator()(ModuleFile &M) {
2026 // If we've already searched this module file, skip it now.
2027 if (M.Generation <= PriorGeneration)
2028 return true;
2029
2030 ASTIdentifierLookupTable *IdTable
2031 = (ASTIdentifierLookupTable *)M.IdentifierLookupTable;
2032 if (!IdTable)
2033 return false;
2034
2035 ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(), M,
2036 Found);
2037 ++NumIdentifierLookups;
2038 ASTIdentifierLookupTable::iterator Pos =
2039 IdTable->find_hashed(Name, NameHash, &Trait);
2040 if (Pos == IdTable->end())
2041 return false;
2042
2043 // Dereferencing the iterator has the effect of building the
2044 // IdentifierInfo node and populating it with the various
2045 // declarations it needs.
2046 ++NumIdentifierLookupHits;
2047 Found = *Pos;
2048 return true;
2049 }
2050
2051 // Retrieve the identifier info found within the module
2052 // files.
2053 IdentifierInfo *getIdentifierInfo() const { return Found; }
2054 };
2055
2056 } // namespace
2057
2058 void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) {
2059 // Note that we are loading an identifier.
2060 Deserializing AnIdentifier(this);
2061
2062 unsigned PriorGeneration = 0;
2063 if (getContext().getLangOpts().Modules)
2064 PriorGeneration = IdentifierGeneration[&II];
2065
2066 // If there is a global index, look there first to determine which modules
2067 // provably do not have any results for this identifier.
2068 GlobalModuleIndex::HitSet Hits;
2069 GlobalModuleIndex::HitSet *HitsPtr = nullptr;
2070 if (!loadGlobalIndex()) {
2071 if (GlobalIndex->lookupIdentifier(II.getName(), Hits)) {
2072 HitsPtr = &Hits;
2073 }
2074 }
2075
2076 IdentifierLookupVisitor Visitor(II.getName(), PriorGeneration,
2077 NumIdentifierLookups,
2078 NumIdentifierLookupHits);
2079 ModuleMgr.visit(Visitor, HitsPtr);
2080 markIdentifierUpToDate(&II);
2081 }
2082
2083 void ASTReader::markIdentifierUpToDate(IdentifierInfo *II) {
2084 if (!II)
2085 return;
2086
2087 II->setOutOfDate(false);
2088
2089 // Update the generation for this identifier.
2090 if (getContext().getLangOpts().Modules)
2091 IdentifierGeneration[II] = getGeneration();
2092 }
2093
2094 void ASTReader::resolvePendingMacro(IdentifierInfo *II,
2095 const PendingMacroInfo &PMInfo) {
2096 ModuleFile &M = *PMInfo.M;
2097
2098 BitstreamCursor &Cursor = M.MacroCursor;
2099 SavedStreamPosition SavedPosition(Cursor);
2100 if (llvm::Error Err = Cursor.JumpToBit(PMInfo.MacroDirectivesOffset)) {
2101 Error(std::move(Err));
2102 return;
2103 }
2104
2105 struct ModuleMacroRecord {
2106 SubmoduleID SubModID;
2107 MacroInfo *MI;
2108 SmallVector<SubmoduleID, 8> Overrides;
2109 };
2110 llvm::SmallVector<ModuleMacroRecord, 8> ModuleMacros;
2111
2112 // We expect to see a sequence of PP_MODULE_MACRO records listing exported
2113 // macros, followed by a PP_MACRO_DIRECTIVE_HISTORY record with the complete
2114 // macro histroy.
2115 RecordData Record;
2116 while (true) {
2117 Expected<llvm::BitstreamEntry> MaybeEntry =
2118 Cursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
2119 if (!MaybeEntry) {
2120 Error(MaybeEntry.takeError());
2121 return;
2122 }
2123 llvm::BitstreamEntry Entry = MaybeEntry.get();
2124
2125 if (Entry.Kind != llvm::BitstreamEntry::Record) {
2126 Error("malformed block record in AST file");
2127 return;
2128 }
2129
2130 Record.clear();
2131 Expected<unsigned> MaybePP = Cursor.readRecord(Entry.ID, Record);
2132 if (!MaybePP) {
2133 Error(MaybePP.takeError());
2134 return;
2135 }
2136 switch ((PreprocessorRecordTypes)MaybePP.get()) {
2137 case PP_MACRO_DIRECTIVE_HISTORY:
2138 break;
2139
2140 case PP_MODULE_MACRO: {
2141 ModuleMacros.push_back(ModuleMacroRecord());
2142 auto &Info = ModuleMacros.back();
2143 Info.SubModID = getGlobalSubmoduleID(M, Record[0]);
2144 Info.MI = getMacro(getGlobalMacroID(M, Record[1]));
2145 for (int I = 2, N = Record.size(); I != N; ++I)
2146 Info.Overrides.push_back(getGlobalSubmoduleID(M, Record[I]));
2147 continue;
2148 }
2149
2150 default:
2151 Error("malformed block record in AST file");
2152 return;
2153 }
2154
2155 // We found the macro directive history; that's the last record
2156 // for this macro.
2157 break;
2158 }
2159
2160 // Module macros are listed in reverse dependency order.
2161 {
2162 std::reverse(ModuleMacros.begin(), ModuleMacros.end());
2163 llvm::SmallVector<ModuleMacro*, 8> Overrides;
2164 for (auto &MMR : ModuleMacros) {
2165 Overrides.clear();
2166 for (unsigned ModID : MMR.Overrides) {
2167 Module *Mod = getSubmodule(ModID);
2168 auto *Macro = PP.getModuleMacro(Mod, II);
2169 assert(Macro && "missing definition for overridden macro");
2170 Overrides.push_back(Macro);
2171 }
2172
2173 bool Inserted = false;
2174 Module *Owner = getSubmodule(MMR.SubModID);
2175 PP.addModuleMacro(Owner, II, MMR.MI, Overrides, Inserted);
2176 }
2177 }
2178
2179 // Don't read the directive history for a module; we don't have anywhere
2180 // to put it.
2181 if (M.isModule())
2182 return;
2183
2184 // Deserialize the macro directives history in reverse source-order.
2185 MacroDirective *Latest = nullptr, *Earliest = nullptr;
2186 unsigned Idx = 0, N = Record.size();
2187 while (Idx < N) {
2188 MacroDirective *MD = nullptr;
2189 SourceLocation Loc = ReadSourceLocation(M, Record, Idx);
2190 MacroDirective::Kind K = (MacroDirective::Kind)Record[Idx++];
2191 switch (K) {
2192 case MacroDirective::MD_Define: {
2193 MacroInfo *MI = getMacro(getGlobalMacroID(M, Record[Idx++]));
2194 MD = PP.AllocateDefMacroDirective(MI, Loc);
2195 break;
2196 }
2197 case MacroDirective::MD_Undefine:
2198 MD = PP.AllocateUndefMacroDirective(Loc);
2199 break;
2200 case MacroDirective::MD_Visibility:
2201 bool isPublic = Record[Idx++];
2202 MD = PP.AllocateVisibilityMacroDirective(Loc, isPublic);
2203 break;
2204 }
2205
2206 if (!Latest)
2207 Latest = MD;
2208 if (Earliest)
2209 Earliest->setPrevious(MD);
2210 Earliest = MD;
2211 }
2212
2213 if (Latest)
2214 PP.setLoadedMacroDirective(II, Earliest, Latest);
2215 }
2216
2217 ASTReader::InputFileInfo
2218 ASTReader::readInputFileInfo(ModuleFile &F, unsigned ID) {
2219 // Go find this input file.
2220 BitstreamCursor &Cursor = F.InputFilesCursor;
2221 SavedStreamPosition SavedPosition(Cursor);
2222 if (llvm::Error Err = Cursor.JumpToBit(F.InputFileOffsets[ID - 1])) {
2223 // FIXME this drops errors on the floor.
2224 consumeError(std::move(Err));
2225 }
2226
2227 Expected<unsigned> MaybeCode = Cursor.ReadCode();
2228 if (!MaybeCode) {
2229 // FIXME this drops errors on the floor.
2230 consumeError(MaybeCode.takeError());
2231 }
2232 unsigned Code = MaybeCode.get();
2233 RecordData Record;
2234 StringRef Blob;
2235
2236 if (Expected<unsigned> Maybe = Cursor.readRecord(Code, Record, &Blob))
2237 assert(static_cast<InputFileRecordTypes>(Maybe.get()) == INPUT_FILE &&
2238 "invalid record type for input file");
2239 else {
2240 // FIXME this drops errors on the floor.
2241 consumeError(Maybe.takeError());
2242 }
2243
2244 assert(Record[0] == ID && "Bogus stored ID or offset");
2245 InputFileInfo R;
2246 R.StoredSize = static_cast<off_t>(Record[1]);
2247 R.StoredTime = static_cast<time_t>(Record[2]);
2248 R.Overridden = static_cast<bool>(Record[3]);
2249 R.Transient = static_cast<bool>(Record[4]);
2250 R.TopLevelModuleMap = static_cast<bool>(Record[5]);
2251 R.Filename = Blob;
2252 ResolveImportedPath(F, R.Filename);
2253
2254 Expected<llvm::BitstreamEntry> MaybeEntry = Cursor.advance();
2255 if (!MaybeEntry) // FIXME this drops errors on the floor.
2256 consumeError(MaybeEntry.takeError());
2257 llvm::BitstreamEntry Entry = MaybeEntry.get();
2258 assert(Entry.Kind == llvm::BitstreamEntry::Record &&
2259 "expected record type for input file hash");
2260
2261 Record.clear();
2262 if (Expected<unsigned> Maybe = Cursor.readRecord(Entry.ID, Record))
2263 assert(static_cast<InputFileRecordTypes>(Maybe.get()) == INPUT_FILE_HASH &&
2264 "invalid record type for input file hash");
2265 else {
2266 // FIXME this drops errors on the floor.
2267 consumeError(Maybe.takeError());
2268 }
2269 R.ContentHash = (static_cast<uint64_t>(Record[1]) << 32) |
2270 static_cast<uint64_t>(Record[0]);
2271 return R;
2272 }
2273
2274 static unsigned moduleKindForDiagnostic(ModuleKind Kind);
2275 InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
2276 // If this ID is bogus, just return an empty input file.
2277 if (ID == 0 || ID > F.InputFilesLoaded.size())
2278 return InputFile();
2279
2280 // If we've already loaded this input file, return it.
2281 if (F.InputFilesLoaded[ID-1].getFile())
2282 return F.InputFilesLoaded[ID-1];
2283
2284 if (F.InputFilesLoaded[ID-1].isNotFound())
2285 return InputFile();
2286
2287 // Go find this input file.
2288 BitstreamCursor &Cursor = F.InputFilesCursor;
2289 SavedStreamPosition SavedPosition(Cursor);
2290 if (llvm::Error Err = Cursor.JumpToBit(F.InputFileOffsets[ID - 1])) {
2291 // FIXME this drops errors on the floor.
2292 consumeError(std::move(Err));
2293 }
2294
2295 InputFileInfo FI = readInputFileInfo(F, ID);
2296 off_t StoredSize = FI.StoredSize;
2297 time_t StoredTime = FI.StoredTime;
2298 bool Overridden = FI.Overridden;
2299 bool Transient = FI.Transient;
2300 StringRef Filename = FI.Filename;
2301 uint64_t StoredContentHash = FI.ContentHash;
2302
2303 const FileEntry *File = nullptr;
2304 if (auto FE = FileMgr.getFile(Filename, /*OpenFile=*/false))
2305 File = *FE;
2306
2307 // If we didn't find the file, resolve it relative to the
2308 // original directory from which this AST file was created.
2309 if (File == nullptr && !F.OriginalDir.empty() && !F.BaseDirectory.empty() &&
2310 F.OriginalDir != F.BaseDirectory) {
2311 std::string Resolved = resolveFileRelativeToOriginalDir(
2312 Filename, F.OriginalDir, F.BaseDirectory);
2313 if (!Resolved.empty())
2314 if (auto FE = FileMgr.getFile(Resolved))
2315 File = *FE;
2316 }
2317
2318 // For an overridden file, create a virtual file with the stored
2319 // size/timestamp.
2320 if ((Overridden || Transient) && File == nullptr)
2321 File = FileMgr.getVirtualFile(Filename, StoredSize, StoredTime);
2322
2323 if (File == nullptr) {
2324 if (Complain) {
2325 std::string ErrorStr = "could not find file '";
2326 ErrorStr += Filename;
2327 ErrorStr += "' referenced by AST file '";
2328 ErrorStr += F.FileName;
2329 ErrorStr += "'";
2330 Error(ErrorStr);
2331 }
2332 // Record that we didn't find the file.
2333 F.InputFilesLoaded[ID-1] = InputFile::getNotFound();
2334 return InputFile();
2335 }
2336
2337 // Check if there was a request to override the contents of the file
2338 // that was part of the precompiled header. Overriding such a file
2339 // can lead to problems when lexing using the source locations from the
2340 // PCH.
2341 SourceManager &SM = getSourceManager();
2342 // FIXME: Reject if the overrides are different.
2343 if ((!Overridden && !Transient) && SM.isFileOverridden(File)) {
2344 if (Complain)
2345 Error(diag::err_fe_pch_file_overridden, Filename);
2346
2347 // After emitting the diagnostic, bypass the overriding file to recover
2348 // (this creates a separate FileEntry).
2349 File = SM.bypassFileContentsOverride(*File);
2350 if (!File) {
2351 F.InputFilesLoaded[ID - 1] = InputFile::getNotFound();
2352 return InputFile();
2353 }
2354 }
2355
2356 enum ModificationType {
2357 Size,
2358 ModTime,
2359 Content,
2360 None,
2361 };
2362 auto HasInputFileChanged = [&]() {
2363 if (StoredSize != File->getSize())
2364 return ModificationType::Size;
2365 if (!DisableValidation && StoredTime &&
2366 StoredTime != File->getModificationTime()) {
2367 // In case the modification time changes but not the content,
2368 // accept the cached file as legit.
2369 if (ValidateASTInputFilesContent &&
2370 StoredContentHash != static_cast<uint64_t>(llvm::hash_code(-1))) {
2371 auto MemBuffOrError = FileMgr.getBufferForFile(File);
2372 if (!MemBuffOrError) {
2373 if (!Complain)
2374 return ModificationType::ModTime;
2375 std::string ErrorStr = "could not get buffer for file '";
2376 ErrorStr += File->getName();
2377 ErrorStr += "'";
2378 Error(ErrorStr);
2379 return ModificationType::ModTime;
2380 }
2381
2382 auto ContentHash = hash_value(MemBuffOrError.get()->getBuffer());
2383 if (StoredContentHash == static_cast<uint64_t>(ContentHash))
2384 return ModificationType::None;
2385 return ModificationType::Content;
2386 }
2387 return ModificationType::ModTime;
2388 }
2389 return ModificationType::None;
2390 };
2391
2392 bool IsOutOfDate = false;
2393 auto FileChange = HasInputFileChanged();
2394 // For an overridden file, there is nothing to validate.
2395 if (!Overridden && FileChange != ModificationType::None) {
2396 if (Complain) {
2397 // Build a list of the PCH imports that got us here (in reverse).
2398 SmallVector<ModuleFile *, 4> ImportStack(1, &F);
2399 while (!ImportStack.back()->ImportedBy.empty())
2400 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2401
2402 // The top-level PCH is stale.
2403 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2404 unsigned DiagnosticKind =
2405 moduleKindForDiagnostic(ImportStack.back()->Kind);
2406 if (DiagnosticKind == 0)
2407 Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName,
2408 (unsigned)FileChange);
2409 else if (DiagnosticKind == 1)
2410 Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName,
2411 (unsigned)FileChange);
2412 else
2413 Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName,
2414 (unsigned)FileChange);
2415
2416 // Print the import stack.
2417 if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
2418 Diag(diag::note_pch_required_by)
2419 << Filename << ImportStack[0]->FileName;
2420 for (unsigned I = 1; I < ImportStack.size(); ++I)
2421 Diag(diag::note_pch_required_by)
2422 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
2423 }
2424
2425 if (!Diags.isDiagnosticInFlight())
2426 Diag(diag::note_pch_rebuild_required) << TopLevelPCHName;
2427 }
2428
2429 IsOutOfDate = true;
2430 }
2431 // FIXME: If the file is overridden and we've already opened it,
2432 // issue an error (or split it into a separate FileEntry).
2433
2434 InputFile IF = InputFile(File, Overridden || Transient, IsOutOfDate);
2435
2436 // Note that we've loaded this input file.
2437 F.InputFilesLoaded[ID-1] = IF;
2438 return IF;
2439 }
2440
2441 /// If we are loading a relocatable PCH or module file, and the filename
2442 /// is not an absolute path, add the system or module root to the beginning of
2443 /// the file name.
2444 void ASTReader::ResolveImportedPath(ModuleFile &M, std::string &Filename) {
2445 // Resolve relative to the base directory, if we have one.
2446 if (!M.BaseDirectory.empty())
2447 return ResolveImportedPath(Filename, M.BaseDirectory);
2448 }
2449
2450 void ASTReader::ResolveImportedPath(std::string &Filename, StringRef Prefix) {
2451 if (Filename.empty() || llvm::sys::path::is_absolute(Filename))
2452 return;
2453
2454 SmallString<128> Buffer;
2455 llvm::sys::path::append(Buffer, Prefix, Filename);
2456 Filename.assign(Buffer.begin(), Buffer.end());
2457 }
2458
2459 static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps) {
2460 switch (ARR) {
2461 case ASTReader::Failure: return true;
2462 case ASTReader::Missing: return !(Caps & ASTReader::ARR_Missing);
2463 case ASTReader::OutOfDate: return !(Caps & ASTReader::ARR_OutOfDate);
2464 case ASTReader::VersionMismatch: return !(Caps & ASTReader::ARR_VersionMismatch);
2465 case ASTReader::ConfigurationMismatch:
2466 return !(Caps & ASTReader::ARR_ConfigurationMismatch);
2467 case ASTReader::HadErrors: return true;
2468 case ASTReader::Success: return false;
2469 }
2470
2471 llvm_unreachable("unknown ASTReadResult");
2472 }
2473
2474 ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
2475 BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
2476 bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
2477 std::string &SuggestedPredefines) {
2478 if (llvm::Error Err = Stream.EnterSubBlock(OPTIONS_BLOCK_ID)) {
2479 // FIXME this drops errors on the floor.
2480 consumeError(std::move(Err));
2481 return Failure;
2482 }
2483
2484 // Read all of the records in the options block.
2485 RecordData Record;
2486 ASTReadResult Result = Success;
2487 while (true) {
2488 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
2489 if (!MaybeEntry) {
2490 // FIXME this drops errors on the floor.
2491 consumeError(MaybeEntry.takeError());
2492 return Failure;
2493 }
2494 llvm::BitstreamEntry Entry = MaybeEntry.get();
2495
2496 switch (Entry.Kind) {
2497 case llvm::BitstreamEntry::Error:
2498 case llvm::BitstreamEntry::SubBlock:
2499 return Failure;
2500
2501 case llvm::BitstreamEntry::EndBlock:
2502 return Result;
2503
2504 case llvm::BitstreamEntry::Record:
2505 // The interesting case.
2506 break;
2507 }
2508
2509 // Read and process a record.
2510 Record.clear();
2511 Expected<unsigned> MaybeRecordType = Stream.readRecord(Entry.ID, Record);
2512 if (!MaybeRecordType) {
2513 // FIXME this drops errors on the floor.
2514 consumeError(MaybeRecordType.takeError());
2515 return Failure;
2516 }
2517 switch ((OptionsRecordTypes)MaybeRecordType.get()) {
2518 case LANGUAGE_OPTIONS: {
2519 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2520 if (ParseLanguageOptions(Record, Complain, Listener,
2521 AllowCompatibleConfigurationMismatch))
2522 Result = ConfigurationMismatch;
2523 break;
2524 }
2525
2526 case TARGET_OPTIONS: {
2527 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2528 if (ParseTargetOptions(Record, Complain, Listener,
2529 AllowCompatibleConfigurationMismatch))
2530 Result = ConfigurationMismatch;
2531 break;
2532 }
2533
2534 case FILE_SYSTEM_OPTIONS: {
2535 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2536 if (!AllowCompatibleConfigurationMismatch &&
2537 ParseFileSystemOptions(Record, Complain, Listener))
2538 Result = ConfigurationMismatch;
2539 break;
2540 }
2541
2542 case HEADER_SEARCH_OPTIONS: {
2543 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2544 if (!AllowCompatibleConfigurationMismatch &&
2545 ParseHeaderSearchOptions(Record, Complain, Listener))
2546 Result = ConfigurationMismatch;
2547 break;
2548 }
2549
2550 case PREPROCESSOR_OPTIONS:
2551 bool Complain = (ClientLoadCapabilities & ARR_ConfigurationMismatch) == 0;
2552 if (!AllowCompatibleConfigurationMismatch &&
2553 ParsePreprocessorOptions(Record, Complain, Listener,
2554 SuggestedPredefines))
2555 Result = ConfigurationMismatch;
2556 break;
2557 }
2558 }
2559 }
2560
2561 ASTReader::ASTReadResult
2562 ASTReader::ReadControlBlock(ModuleFile &F,
2563 SmallVectorImpl<ImportedModule> &Loaded,
2564 const ModuleFile *ImportedBy,
2565 unsigned ClientLoadCapabilities) {
2566 BitstreamCursor &Stream = F.Stream;
2567
2568 if (llvm::Error Err = Stream.EnterSubBlock(CONTROL_BLOCK_ID)) {
2569 Error(std::move(Err));
2570 return Failure;
2571 }
2572
2573 // Lambda to read the unhashed control block the first time it's called.
2574 //
2575 // For PCM files, the unhashed control block cannot be read until after the
2576 // MODULE_NAME record. However, PCH files have no MODULE_NAME, and yet still
2577 // need to look ahead before reading the IMPORTS record. For consistency,
2578 // this block is always read somehow (see BitstreamEntry::EndBlock).
2579 bool HasReadUnhashedControlBlock = false;
2580 auto readUnhashedControlBlockOnce = [&]() {
2581 if (!HasReadUnhashedControlBlock) {
2582 HasReadUnhashedControlBlock = true;
2583 if (ASTReadResult Result =
2584 readUnhashedControlBlock(F, ImportedBy, ClientLoadCapabilities))
2585 return Result;
2586 }
2587 return Success;
2588 };
2589
2590 // Read all of the records and blocks in the control block.
2591 RecordData Record;
2592 unsigned NumInputs = 0;
2593 unsigned NumUserInputs = 0;
2594 StringRef BaseDirectoryAsWritten;
2595 while (true) {
2596 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
2597 if (!MaybeEntry) {
2598 Error(MaybeEntry.takeError());
2599 return Failure;
2600 }
2601 llvm::BitstreamEntry Entry = MaybeEntry.get();
2602
2603 switch (Entry.Kind) {
2604 case llvm::BitstreamEntry::Error:
2605 Error("malformed block record in AST file");
2606 return Failure;
2607 case llvm::BitstreamEntry::EndBlock: {
2608 // Validate the module before returning. This call catches an AST with
2609 // no module name and no imports.
2610 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2611 return Result;
2612
2613 // Validate input files.
2614 const HeaderSearchOptions &HSOpts =
2615 PP.getHeaderSearchInfo().getHeaderSearchOpts();
2616
2617 // All user input files reside at the index range [0, NumUserInputs), and
2618 // system input files reside at [NumUserInputs, NumInputs). For explicitly
2619 // loaded module files, ignore missing inputs.
2620 if (!DisableValidation && F.Kind != MK_ExplicitModule &&
2621 F.Kind != MK_PrebuiltModule) {
2622 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
2623
2624 // If we are reading a module, we will create a verification timestamp,
2625 // so we verify all input files. Otherwise, verify only user input
2626 // files.
2627
2628 unsigned N = NumUserInputs;
2629 if (ValidateSystemInputs ||
2630 (HSOpts.ModulesValidateOncePerBuildSession &&
2631 F.InputFilesValidationTimestamp <= HSOpts.BuildSessionTimestamp &&
2632 F.Kind == MK_ImplicitModule))
2633 N = NumInputs;
2634
2635 for (unsigned I = 0; I < N; ++I) {
2636 InputFile IF = getInputFile(F, I+1, Complain);
2637 if (!IF.getFile() || IF.isOutOfDate())
2638 return OutOfDate;
2639 }
2640 }
2641
2642 if (Listener)
2643 Listener->visitModuleFile(F.FileName, F.Kind);
2644
2645 if (Listener && Listener->needsInputFileVisitation()) {
2646 unsigned N = Listener->needsSystemInputFileVisitation() ? NumInputs
2647 : NumUserInputs;
2648 for (unsigned I = 0; I < N; ++I) {
2649 bool IsSystem = I >= NumUserInputs;
2650 InputFileInfo FI = readInputFileInfo(F, I+1);
2651 Listener->visitInputFile(FI.Filename, IsSystem, FI.Overridden,
2652 F.Kind == MK_ExplicitModule ||
2653 F.Kind == MK_PrebuiltModule);
2654 }
2655 }
2656
2657 return Success;
2658 }
2659
2660 case llvm::BitstreamEntry::SubBlock:
2661 switch (Entry.ID) {
2662 case INPUT_FILES_BLOCK_ID:
2663 F.InputFilesCursor = Stream;
2664 if (llvm::Error Err = Stream.SkipBlock()) {
2665 Error(std::move(Err));
2666 return Failure;
2667 }
2668 if (ReadBlockAbbrevs(F.InputFilesCursor, INPUT_FILES_BLOCK_ID)) {
2669 Error("malformed block record in AST file");
2670 return Failure;
2671 }
2672 continue;
2673
2674 case OPTIONS_BLOCK_ID:
2675 // If we're reading the first module for this group, check its options
2676 // are compatible with ours. For modules it imports, no further checking
2677 // is required, because we checked them when we built it.
2678 if (Listener && !ImportedBy) {
2679 // Should we allow the configuration of the module file to differ from
2680 // the configuration of the current translation unit in a compatible
2681 // way?
2682 //
2683 // FIXME: Allow this for files explicitly specified with -include-pch.
2684 bool AllowCompatibleConfigurationMismatch =
2685 F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule;
2686
2687 ASTReadResult Result =
2688 ReadOptionsBlock(Stream, ClientLoadCapabilities,
2689 AllowCompatibleConfigurationMismatch, *Listener,
2690 SuggestedPredefines);
2691 if (Result == Failure) {
2692 Error("malformed block record in AST file");
2693 return Result;
2694 }
2695
2696 if (DisableValidation ||
2697 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
2698 Result = Success;
2699
2700 // If we can't load the module, exit early since we likely
2701 // will rebuild the module anyway. The stream may be in the
2702 // middle of a block.
2703 if (Result != Success)
2704 return Result;
2705 } else if (llvm::Error Err = Stream.SkipBlock()) {
2706 Error(std::move(Err));
2707 return Failure;
2708 }
2709 continue;
2710
2711 default:
2712 if (llvm::Error Err = Stream.SkipBlock()) {
2713 Error(std::move(Err));
2714 return Failure;
2715 }
2716 continue;
2717 }
2718
2719 case llvm::BitstreamEntry::Record:
2720 // The interesting case.
2721 break;
2722 }
2723
2724 // Read and process a record.
2725 Record.clear();
2726 StringRef Blob;
2727 Expected<unsigned> MaybeRecordType =
2728 Stream.readRecord(Entry.ID, Record, &Blob);
2729 if (!MaybeRecordType) {
2730 Error(MaybeRecordType.takeError());
2731 return Failure;
2732 }
2733 switch ((ControlRecordTypes)MaybeRecordType.get()) {
2734 case METADATA: {
2735 if (Record[0] != VERSION_MAJOR && !DisableValidation) {
2736 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2737 Diag(Record[0] < VERSION_MAJOR? diag::err_pch_version_too_old
2738 : diag::err_pch_version_too_new);
2739 return VersionMismatch;
2740 }
2741
2742 bool hasErrors = Record[7];
2743 if (hasErrors && !DisableValidation && !AllowASTWithCompilerErrors) {
2744 Diag(diag::err_pch_with_compiler_errors);
2745 return HadErrors;
2746 }
2747 if (hasErrors) {
2748 Diags.ErrorOccurred = true;
2749 Diags.UncompilableErrorOccurred = true;
2750 Diags.UnrecoverableErrorOccurred = true;
2751 }
2752
2753 F.RelocatablePCH = Record[4];
2754 // Relative paths in a relocatable PCH are relative to our sysroot.
2755 if (F.RelocatablePCH)
2756 F.BaseDirectory = isysroot.empty() ? "/" : isysroot;
2757
2758 F.HasTimestamps = Record[5];
2759
2760 F.PCHHasObjectFile = Record[6];
2761
2762 const std::string &CurBranch = getClangFullRepositoryVersion();
2763 StringRef ASTBranch = Blob;
2764 if (StringRef(CurBranch) != ASTBranch && !DisableValidation) {
2765 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
2766 Diag(diag::err_pch_different_branch) << ASTBranch << CurBranch;
2767 return VersionMismatch;
2768 }
2769 break;
2770 }
2771
2772 case IMPORTS: {
2773 // Validate the AST before processing any imports (otherwise, untangling
2774 // them can be error-prone and expensive). A module will have a name and
2775 // will already have been validated, but this catches the PCH case.
2776 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2777 return Result;
2778
2779 // Load each of the imported PCH files.
2780 unsigned Idx = 0, N = Record.size();
2781 while (Idx < N) {
2782 // Read information about the AST file.
2783 ModuleKind ImportedKind = (ModuleKind)Record[Idx++];
2784 // The import location will be the local one for now; we will adjust
2785 // all import locations of module imports after the global source
2786 // location info are setup, in ReadAST.
2787 SourceLocation ImportLoc =
2788 ReadUntranslatedSourceLocation(Record[Idx++]);
2789 off_t StoredSize = (off_t)Record[Idx++];
2790 time_t StoredModTime = (time_t)Record[Idx++];
2791 ASTFileSignature StoredSignature = {
2792 {{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2793 (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
2794 (uint32_t)Record[Idx++]}}};
2795
2796 std::string ImportedName = ReadString(Record, Idx);
2797 std::string ImportedFile;
2798
2799 // For prebuilt and explicit modules first consult the file map for
2800 // an override. Note that here we don't search prebuilt module
2801 // directories, only the explicit name to file mappings. Also, we will
2802 // still verify the size/signature making sure it is essentially the
2803 // same file but perhaps in a different location.
2804 if (ImportedKind == MK_PrebuiltModule || ImportedKind == MK_ExplicitModule)
2805 ImportedFile = PP.getHeaderSearchInfo().getPrebuiltModuleFileName(
2806 ImportedName, /*FileMapOnly*/ true);
2807
2808 if (ImportedFile.empty())
2809 // Use BaseDirectoryAsWritten to ensure we use the same path in the
2810 // ModuleCache as when writing.
2811 ImportedFile = ReadPath(BaseDirectoryAsWritten, Record, Idx);
2812 else
2813 SkipPath(Record, Idx);
2814
2815 // If our client can't cope with us being out of date, we can't cope with
2816 // our dependency being missing.
2817 unsigned Capabilities = ClientLoadCapabilities;
2818 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2819 Capabilities &= ~ARR_Missing;
2820
2821 // Load the AST file.
2822 auto Result = ReadASTCore(ImportedFile, ImportedKind, ImportLoc, &F,
2823 Loaded, StoredSize, StoredModTime,
2824 StoredSignature, Capabilities);
2825
2826 // If we diagnosed a problem, produce a backtrace.
2827 if (isDiagnosedResult(Result, Capabilities))
2828 Diag(diag::note_module_file_imported_by)
2829 << F.FileName << !F.ModuleName.empty() << F.ModuleName;
2830
2831 switch (Result) {
2832 case Failure: return Failure;
2833 // If we have to ignore the dependency, we'll have to ignore this too.
2834 case Missing:
2835 case OutOfDate: return OutOfDate;
2836 case VersionMismatch: return VersionMismatch;
2837 case ConfigurationMismatch: return ConfigurationMismatch;
2838 case HadErrors: return HadErrors;
2839 case Success: break;
2840 }
2841 }
2842 break;
2843 }
2844
2845 case ORIGINAL_FILE:
2846 F.OriginalSourceFileID = FileID::get(Record[0]);
2847 F.ActualOriginalSourceFileName = Blob;
2848 F.OriginalSourceFileName = F.ActualOriginalSourceFileName;
2849 ResolveImportedPath(F, F.OriginalSourceFileName);
2850 break;
2851
2852 case ORIGINAL_FILE_ID:
2853 F.OriginalSourceFileID = FileID::get(Record[0]);
2854 break;
2855
2856 case ORIGINAL_PCH_DIR:
2857 F.OriginalDir = Blob;
2858 break;
2859
2860 case MODULE_NAME:
2861 F.ModuleName = Blob;
2862 Diag(diag::remark_module_import)
2863 << F.ModuleName << F.FileName << (ImportedBy ? true : false)
2864 << (ImportedBy ? StringRef(ImportedBy->ModuleName) : StringRef());
2865 if (Listener)
2866 Listener->ReadModuleName(F.ModuleName);
2867
2868 // Validate the AST as soon as we have a name so we can exit early on
2869 // failure.
2870 if (ASTReadResult Result = readUnhashedControlBlockOnce())
2871 return Result;
2872
2873 break;
2874
2875 case MODULE_DIRECTORY: {
2876 // Save the BaseDirectory as written in the PCM for computing the module
2877 // filename for the ModuleCache.
2878 BaseDirectoryAsWritten = Blob;
2879 assert(!F.ModuleName.empty() &&
2880 "MODULE_DIRECTORY found before MODULE_NAME");
2881 // If we've already loaded a module map file covering this module, we may
2882 // have a better path for it (relative to the current build).
2883 Module *M = PP.getHeaderSearchInfo().lookupModule(
2884 F.ModuleName, /*AllowSearch*/ true,
2885 /*AllowExtraModuleMapSearch*/ true);
2886 if (M && M->Directory) {
2887 // If we're implicitly loading a module, the base directory can't
2888 // change between the build and use.
2889 // Don't emit module relocation error if we have -fno-validate-pch
2890 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
2891 F.Kind != MK_ExplicitModule && F.Kind != MK_PrebuiltModule) {
2892 auto BuildDir = PP.getFileManager().getDirectory(Blob);
2893 if (!BuildDir || *BuildDir != M->Directory) {
2894 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
2895 Diag(diag::err_imported_module_relocated)
2896 << F.ModuleName << Blob << M->Directory->getName();
2897 return OutOfDate;
2898 }
2899 }
2900 F.BaseDirectory = M->Directory->getName();
2901 } else {
2902 F.BaseDirectory = Blob;
2903 }
2904 break;
2905 }
2906
2907 case MODULE_MAP_FILE:
2908 if (ASTReadResult Result =
2909 ReadModuleMapFileBlock(Record, F, ImportedBy, ClientLoadCapabilities))
2910 return Result;
2911 break;
2912
2913 case INPUT_FILE_OFFSETS:
2914 NumInputs = Record[0];
2915 NumUserInputs = Record[1];
2916 F.InputFileOffsets =
2917 (const llvm::support::unaligned_uint64_t *)Blob.data();
2918 F.InputFilesLoaded.resize(NumInputs);
2919 F.NumUserInputFiles = NumUserInputs;
2920 break;
2921 }
2922 }
2923 }
2924
2925 ASTReader::ASTReadResult
2926 ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
2927 BitstreamCursor &Stream = F.Stream;
2928
2929 if (llvm::Error Err = Stream.EnterSubBlock(AST_BLOCK_ID)) {
2930 Error(std::move(Err));
2931 return Failure;
2932 }
2933
2934 // Read all of the records and blocks for the AST file.
2935 RecordData Record;
2936 while (true) {
2937 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
2938 if (!MaybeEntry) {
2939 Error(MaybeEntry.takeError());
2940 return Failure;
2941 }
2942 llvm::BitstreamEntry Entry = MaybeEntry.get();
2943
2944 switch (Entry.Kind) {
2945 case llvm::BitstreamEntry::Error:
2946 Error("error at end of module block in AST file");
2947 return Failure;
2948 case llvm::BitstreamEntry::EndBlock:
2949 // Outside of C++, we do not store a lookup map for the translation unit.
2950 // Instead, mark it as needing a lookup map to be built if this module
2951 // contains any declarations lexically within it (which it always does!).
2952 // This usually has no cost, since we very rarely need the lookup map for
2953 // the translation unit outside C++.
2954 if (ASTContext *Ctx = ContextObj) {
2955 DeclContext *DC = Ctx->getTranslationUnitDecl();
2956 if (DC->hasExternalLexicalStorage() && !Ctx->getLangOpts().CPlusPlus)
2957 DC->setMustBuildLookupTable();
2958 }
2959
2960 return Success;
2961 case llvm::BitstreamEntry::SubBlock:
2962 switch (Entry.ID) {
2963 case DECLTYPES_BLOCK_ID:
2964 // We lazily load the decls block, but we want to set up the
2965 // DeclsCursor cursor to point into it. Clone our current bitcode
2966 // cursor to it, enter the block and read the abbrevs in that block.
2967 // With the main cursor, we just skip over it.
2968 F.DeclsCursor = Stream;
2969 if (llvm::Error Err = Stream.SkipBlock()) {
2970 Error(std::move(Err));
2971 return Failure;
2972 }
2973 if (ReadBlockAbbrevs(F.DeclsCursor, DECLTYPES_BLOCK_ID)) {
2974 Error("malformed block record in AST file");
2975 return Failure;
2976 }
2977 break;
2978
2979 case PREPROCESSOR_BLOCK_ID:
2980 F.MacroCursor = Stream;
2981 if (!PP.getExternalSource())
2982 PP.setExternalSource(this);
2983
2984 if (llvm::Error Err = Stream.SkipBlock()) {
2985 Error(std::move(Err));
2986 return Failure;
2987 }
2988 if (ReadBlockAbbrevs(F.MacroCursor, PREPROCESSOR_BLOCK_ID)) {
2989 Error("malformed block record in AST file");
2990 return Failure;
2991 }
2992 F.MacroStartOffset = F.MacroCursor.GetCurrentBitNo();
2993 break;
2994
2995 case PREPROCESSOR_DETAIL_BLOCK_ID:
2996 F.PreprocessorDetailCursor = Stream;
2997
2998 if (llvm::Error Err = Stream.SkipBlock()) {
2999 Error(std::move(Err));
3000 return Failure;
3001 }
3002 if (ReadBlockAbbrevs(F.PreprocessorDetailCursor,
3003 PREPROCESSOR_DETAIL_BLOCK_ID)) {
3004 Error("malformed preprocessor detail record in AST file");
3005 return Failure;
3006 }
3007 F.PreprocessorDetailStartOffset
3008 = F.PreprocessorDetailCursor.GetCurrentBitNo();
3009
3010 if (!PP.getPreprocessingRecord())
3011 PP.createPreprocessingRecord();
3012 if (!PP.getPreprocessingRecord()->getExternalSource())
3013 PP.getPreprocessingRecord()->SetExternalSource(*this);
3014 break;
3015
3016 case SOURCE_MANAGER_BLOCK_ID:
3017 if (ReadSourceManagerBlock(F))
3018 return Failure;
3019 break;
3020
3021 case SUBMODULE_BLOCK_ID:
3022 if (ASTReadResult Result =
3023 ReadSubmoduleBlock(F, ClientLoadCapabilities))
3024 return Result;
3025 break;
3026
3027 case COMMENTS_BLOCK_ID: {
3028 BitstreamCursor C = Stream;
3029
3030 if (llvm::Error Err = Stream.SkipBlock()) {
3031 Error(std::move(Err));
3032 return Failure;
3033 }
3034 if (ReadBlockAbbrevs(C, COMMENTS_BLOCK_ID)) {
3035 Error("malformed comments block in AST file");
3036 return Failure;
3037 }
3038 CommentsCursors.push_back(std::make_pair(C, &F));
3039 break;
3040 }
3041
3042 default:
3043 if (llvm::Error Err = Stream.SkipBlock()) {
3044 Error(std::move(Err));
3045 return Failure;
3046 }
3047 break;
3048 }
3049 continue;
3050
3051 case llvm::BitstreamEntry::Record:
3052 // The interesting case.
3053 break;
3054 }
3055
3056 // Read and process a record.
3057 Record.clear();
3058 StringRef Blob;
3059 Expected<unsigned> MaybeRecordType =
3060 Stream.readRecord(Entry.ID, Record, &Blob);
3061 if (!MaybeRecordType) {
3062 Error(MaybeRecordType.takeError());
3063 return Failure;
3064 }
3065 ASTRecordTypes RecordType = (ASTRecordTypes)MaybeRecordType.get();
3066
3067 // If we're not loading an AST context, we don't care about most records.
3068 if (!ContextObj) {
3069 switch (RecordType) {
3070 case IDENTIFIER_TABLE:
3071 case IDENTIFIER_OFFSET:
3072 case INTERESTING_IDENTIFIERS:
3073 case STATISTICS:
3074 case PP_CONDITIONAL_STACK:
3075 case PP_COUNTER_VALUE:
3076 case SOURCE_LOCATION_OFFSETS:
3077 case MODULE_OFFSET_MAP:
3078 case SOURCE_MANAGER_LINE_TABLE:
3079 case SOURCE_LOCATION_PRELOADS:
3080 case PPD_ENTITIES_OFFSETS:
3081 case HEADER_SEARCH_TABLE:
3082 case IMPORTED_MODULES:
3083 case MACRO_OFFSET:
3084 break;
3085 default:
3086 continue;
3087 }
3088 }
3089
3090 switch (RecordType) {
3091 default: // Default behavior: ignore.
3092 break;
3093
3094 case TYPE_OFFSET: {
3095 if (F.LocalNumTypes != 0) {
3096 Error("duplicate TYPE_OFFSET record in AST file");
3097 return Failure;
3098 }
3099 F.TypeOffsets = (const uint32_t *)Blob.data();
3100 F.LocalNumTypes = Record[0];
3101 unsigned LocalBaseTypeIndex = Record[1];
3102 F.BaseTypeIndex = getTotalNumTypes();
3103
3104 if (F.LocalNumTypes > 0) {
3105 // Introduce the global -> local mapping for types within this module.
3106 GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
3107
3108 // Introduce the local -> global mapping for types within this module.
3109 F.TypeRemap.insertOrReplace(
3110 std::make_pair(LocalBaseTypeIndex,
3111 F.BaseTypeIndex - LocalBaseTypeIndex));
3112
3113 TypesLoaded.resize(TypesLoaded.size() + F.LocalNumTypes);
3114 }
3115 break;
3116 }
3117
3118 case DECL_OFFSET: {
3119 if (F.LocalNumDecls != 0) {
3120 Error("duplicate DECL_OFFSET record in AST file");
3121 return Failure;
3122 }
3123 F.DeclOffsets = (const DeclOffset *)Blob.data();
3124 F.LocalNumDecls = Record[0];
3125 unsigned LocalBaseDeclID = Record[1];
3126 F.BaseDeclID = getTotalNumDecls();
3127
3128 if (F.LocalNumDecls > 0) {
3129 // Introduce the global -> local mapping for declarations within this
3130 // module.
3131 GlobalDeclMap.insert(
3132 std::make_pair(getTotalNumDecls() + NUM_PREDEF_DECL_IDS, &F));
3133
3134 // Introduce the local -> global mapping for declarations within this
3135 // module.
3136 F.DeclRemap.insertOrReplace(
3137 std::make_pair(LocalBaseDeclID, F.BaseDeclID - LocalBaseDeclID));
3138
3139 // Introduce the global -> local mapping for declarations within this
3140 // module.
3141 F.GlobalToLocalDeclIDs[&F] = LocalBaseDeclID;
3142
3143 DeclsLoaded.resize(DeclsLoaded.size() + F.LocalNumDecls);
3144 }
3145 break;
3146 }
3147
3148 case TU_UPDATE_LEXICAL: {
3149 DeclContext *TU = ContextObj->getTranslationUnitDecl();
3150 LexicalContents Contents(
3151 reinterpret_cast<const llvm::support::unaligned_uint32_t *>(
3152 Blob.data()),
3153 static_cast<unsigned int>(Blob.size() / 4));
3154 TULexicalDecls.push_back(std::make_pair(&F, Contents));
3155 TU->setHasExternalLexicalStorage(true);
3156 break;
3157 }
3158
3159 case UPDATE_VISIBLE: {
3160 unsigned Idx = 0;
3161 serialization::DeclID ID = ReadDeclID(F, Record, Idx);
3162 auto *Data = (const unsigned char*)Blob.data();
3163 PendingVisibleUpdates[ID].push_back(PendingVisibleUpdate{&F, Data});
3164 // If we've already loaded the decl, perform the updates when we finish
3165 // loading this block.
3166 if (Decl *D = GetExistingDecl(ID))
3167 PendingUpdateRecords.push_back(
3168 PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
3169 break;
3170 }
3171
3172 case IDENTIFIER_TABLE:
3173 F.IdentifierTableData = Blob.data();
3174 if (Record[0]) {
3175 F.IdentifierLookupTable = ASTIdentifierLookupTable::Create(
3176 (const unsigned char *)F.IdentifierTableData + Record[0],
3177 (const unsigned char *)F.IdentifierTableData + sizeof(uint32_t),
3178 (const unsigned char *)F.IdentifierTableData,
3179 ASTIdentifierLookupTrait(*this, F));
3180
3181 PP.getIdentifierTable().setExternalIdentifierLookup(this);
3182 }
3183 break;
3184
3185 case IDENTIFIER_OFFSET: {
3186 if (F.LocalNumIdentifiers != 0) {
3187 Error("duplicate IDENTIFIER_OFFSET record in AST file");
3188 return Failure;
3189 }
3190 F.IdentifierOffsets = (const uint32_t *)Blob.data();
3191 F.LocalNumIdentifiers = Record[0];
3192 unsigned LocalBaseIdentifierID = Record[1];
3193 F.BaseIdentifierID = getTotalNumIdentifiers();
3194
3195 if (F.LocalNumIdentifiers > 0) {
3196 // Introduce the global -> local mapping for identifiers within this
3197 // module.
3198 GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
3199 &F));
3200
3201 // Introduce the local -> global mapping for identifiers within this
3202 // module.
3203 F.IdentifierRemap.insertOrReplace(
3204 std::make_pair(LocalBaseIdentifierID,
3205 F.BaseIdentifierID - LocalBaseIdentifierID));
3206
3207 IdentifiersLoaded.resize(IdentifiersLoaded.size()
3208 + F.LocalNumIdentifiers);
3209 }
3210 break;
3211 }
3212
3213 case INTERESTING_IDENTIFIERS:
3214 F.PreloadIdentifierOffsets.assign(Record.begin(), Record.end());
3215 break;
3216
3217 case EAGERLY_DESERIALIZED_DECLS:
3218 // FIXME: Skip reading this record if our ASTConsumer doesn't care
3219 // about "interesting" decls (for instance, if we're building a module).
3220 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3221 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
3222 break;
3223
3224 case MODULAR_CODEGEN_DECLS:
3225 // FIXME: Skip reading this record if our ASTConsumer doesn't care about
3226 // them (ie: if we're not codegenerating this module).
3227 if (F.Kind == MK_MainFile)
3228 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3229 EagerlyDeserializedDecls.push_back(getGlobalDeclID(F, Record[I]));
3230 break;
3231
3232 case SPECIAL_TYPES:
3233 if (SpecialTypes.empty()) {
3234 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3235 SpecialTypes.push_back(getGlobalTypeID(F, Record[I]));
3236 break;
3237 }
3238
3239 if (SpecialTypes.size() != Record.size()) {
3240 Error("invalid special-types record");
3241 return Failure;
3242 }
3243
3244 for (unsigned I = 0, N = Record.size(); I != N; ++I) {
3245 serialization::TypeID ID = getGlobalTypeID(F, Record[I]);
3246 if (!SpecialTypes[I])
3247 SpecialTypes[I] = ID;
3248 // FIXME: If ID && SpecialTypes[I] != ID, do we need a separate
3249 // merge step?
3250 }
3251 break;
3252
3253 case STATISTICS:
3254 TotalNumStatements += Record[0];
3255 TotalNumMacros += Record[1];
3256 TotalLexicalDeclContexts += Record[2];
3257 TotalVisibleDeclContexts += Record[3];
3258 break;
3259
3260 case UNUSED_FILESCOPED_DECLS:
3261 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3262 UnusedFileScopedDecls.push_back(getGlobalDeclID(F, Record[I]));
3263 break;
3264
3265 case DELEGATING_CTORS:
3266 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3267 DelegatingCtorDecls.push_back(getGlobalDeclID(F, Record[I]));
3268 break;
3269
3270 case WEAK_UNDECLARED_IDENTIFIERS:
3271 if (Record.size() % 4 != 0) {
3272 Error("invalid weak identifiers record");
3273 return Failure;
3274 }
3275
3276 // FIXME: Ignore weak undeclared identifiers from non-original PCH
3277 // files. This isn't the way to do it :)
3278 WeakUndeclaredIdentifiers.clear();
3279
3280 // Translate the weak, undeclared identifiers into global IDs.
3281 for (unsigned I = 0, N = Record.size(); I < N; /* in loop */) {
3282 WeakUndeclaredIdentifiers.push_back(
3283 getGlobalIdentifierID(F, Record[I++]));
3284 WeakUndeclaredIdentifiers.push_back(
3285 getGlobalIdentifierID(F, Record[I++]));
3286 WeakUndeclaredIdentifiers.push_back(
3287 ReadSourceLocation(F, Record, I).getRawEncoding());
3288 WeakUndeclaredIdentifiers.push_back(Record[I++]);
3289 }
3290 break;
3291
3292 case SELECTOR_OFFSETS: {
3293 F.SelectorOffsets = (const uint32_t *)Blob.data();
3294 F.LocalNumSelectors = Record[0];
3295 unsigned LocalBaseSelectorID = Record[1];
3296 F.BaseSelectorID = getTotalNumSelectors();
3297
3298 if (F.LocalNumSelectors > 0) {
3299 // Introduce the global -> local mapping for selectors within this
3300 // module.
3301 GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
3302
3303 // Introduce the local -> global mapping for selectors within this
3304 // module.
3305 F.SelectorRemap.insertOrReplace(
3306 std::make_pair(LocalBaseSelectorID,
3307 F.BaseSelectorID - LocalBaseSelectorID));
3308
3309 SelectorsLoaded.resize(SelectorsLoaded.size() + F.LocalNumSelectors);
3310 }
3311 break;
3312 }
3313
3314 case METHOD_POOL:
3315 F.SelectorLookupTableData = (const unsigned char *)Blob.data();
3316 if (Record[0])
3317 F.SelectorLookupTable
3318 = ASTSelectorLookupTable::Create(
3319 F.SelectorLookupTableData + Record[0],
3320 F.SelectorLookupTableData,
3321 ASTSelectorLookupTrait(*this, F));
3322 TotalNumMethodPoolEntries += Record[1];
3323 break;
3324
3325 case REFERENCED_SELECTOR_POOL:
3326 if (!Record.empty()) {
3327 for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) {
3328 ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
3329 Record[Idx++]));
3330 ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
3331 getRawEncoding());
3332 }
3333 }
3334 break;
3335
3336 case PP_CONDITIONAL_STACK:
3337 if (!Record.empty()) {
3338 unsigned Idx = 0, End = Record.size() - 1;
3339 bool ReachedEOFWhileSkipping = Record[Idx++];
3340 llvm::Optional<Preprocessor::PreambleSkipInfo> SkipInfo;
3341 if (ReachedEOFWhileSkipping) {
3342 SourceLocation HashToken = ReadSourceLocation(F, Record, Idx);
3343 SourceLocation IfTokenLoc = ReadSourceLocation(F, Record, Idx);
3344 bool FoundNonSkipPortion = Record[Idx++];
3345 bool FoundElse = Record[Idx++];
3346 SourceLocation ElseLoc = ReadSourceLocation(F, Record, Idx);
3347 SkipInfo.emplace(HashToken, IfTokenLoc, FoundNonSkipPortion,
3348 FoundElse, ElseLoc);
3349 }
3350 SmallVector<PPConditionalInfo, 4> ConditionalStack;
3351 while (Idx < End) {
3352 auto Loc = ReadSourceLocation(F, Record, Idx);
3353 bool WasSkipping = Record[Idx++];
3354 bool FoundNonSkip = Record[Idx++];
3355 bool FoundElse = Record[Idx++];
3356 ConditionalStack.push_back(
3357 {Loc, WasSkipping, FoundNonSkip, FoundElse});
3358 }
3359 PP.setReplayablePreambleConditionalStack(ConditionalStack, SkipInfo);
3360 }
3361 break;
3362
3363 case PP_COUNTER_VALUE:
3364 if (!Record.empty() && Listener)
3365 Listener->ReadCounter(F, Record[0]);
3366 break;
3367
3368 case FILE_SORTED_DECLS:
3369 F.FileSortedDecls = (const DeclID *)Blob.data();
3370 F.NumFileSortedDecls = Record[0];
3371 break;
3372
3373 case SOURCE_LOCATION_OFFSETS: {
3374 F.SLocEntryOffsets = (const uint32_t *)Blob.data();
3375 F.LocalNumSLocEntries = Record[0];
3376 unsigned SLocSpaceSize = Record[1];
3377 std::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
3378 SourceMgr.AllocateLoadedSLocEntries(F.LocalNumSLocEntries,
3379 SLocSpaceSize);
3380 if (!F.SLocEntryBaseID) {
3381 Error("ran out of source locations");
3382 break;
3383 }
3384 // Make our entry in the range map. BaseID is negative and growing, so
3385 // we invert it. Because we invert it, though, we need the other end of
3386 // the range.
3387 unsigned RangeStart =
3388 unsigned(-F.SLocEntryBaseID) - F.LocalNumSLocEntries + 1;
3389 GlobalSLocEntryMap.insert(std::make_pair(RangeStart, &F));
3390 F.FirstLoc = SourceLocation::getFromRawEncoding(F.SLocEntryBaseOffset);
3391
3392 // SLocEntryBaseOffset is lower than MaxLoadedOffset and decreasing.
3393 assert((F.SLocEntryBaseOffset & (1U << 31U)) == 0);
3394 GlobalSLocOffsetMap.insert(
3395 std::make_pair(SourceManager::MaxLoadedOffset - F.SLocEntryBaseOffset
3396 - SLocSpaceSize,&F));
3397
3398 // Initialize the remapping table.
3399 // Invalid stays invalid.
3400 F.SLocRemap.insertOrReplace(std::make_pair(0U, 0));
3401 // This module. Base was 2 when being compiled.
3402 F.SLocRemap.insertOrReplace(std::make_pair(2U,
3403 static_cast<int>(F.SLocEntryBaseOffset - 2)));
3404
3405 TotalNumSLocEntries += F.LocalNumSLocEntries;
3406 break;
3407 }
3408
3409 case MODULE_OFFSET_MAP:
3410 F.ModuleOffsetMap = Blob;
3411 break;
3412
3413 case SOURCE_MANAGER_LINE_TABLE:
3414 if (ParseLineTable(F, Record)) {
3415 Error("malformed SOURCE_MANAGER_LINE_TABLE in AST file");
3416 return Failure;
3417 }
3418 break;
3419
3420 case SOURCE_LOCATION_PRELOADS: {
3421 // Need to transform from the local view (1-based IDs) to the global view,
3422 // which is based off F.SLocEntryBaseID.
3423 if (!F.PreloadSLocEntries.empty()) {
3424 Error("Multiple SOURCE_LOCATION_PRELOADS records in AST file");
3425 return Failure;
3426 }
3427
3428 F.PreloadSLocEntries.swap(Record);
3429 break;
3430 }
3431
3432 case EXT_VECTOR_DECLS:
3433 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3434 ExtVectorDecls.push_back(getGlobalDeclID(F, Record[I]));
3435 break;
3436
3437 case VTABLE_USES:
3438 if (Record.size() % 3 != 0) {
3439 Error("Invalid VTABLE_USES record");
3440 return Failure;
3441 }
3442
3443 // Later tables overwrite earlier ones.
3444 // FIXME: Modules will have some trouble with this. This is clearly not
3445 // the right way to do this.
3446 VTableUses.clear();
3447
3448 for (unsigned Idx = 0, N = Record.size(); Idx != N; /* In loop */) {
3449 VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
3450 VTableUses.push_back(
3451 ReadSourceLocation(F, Record, Idx).getRawEncoding());
3452 VTableUses.push_back(Record[Idx++]);
3453 }
3454 break;
3455
3456 case PENDING_IMPLICIT_INSTANTIATIONS:
3457 if (PendingInstantiations.size() % 2 != 0) {
3458 Error("Invalid existing PendingInstantiations");
3459 return Failure;
3460 }
3461
3462 if (Record.size() % 2 != 0) {
3463 Error("Invalid PENDING_IMPLICIT_INSTANTIATIONS block");
3464 return Failure;
3465 }
3466
3467 for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) {
3468 PendingInstantiations.push_back(getGlobalDeclID(F, Record[I++]));
3469 PendingInstantiations.push_back(
3470 ReadSourceLocation(F, Record, I).getRawEncoding());
3471 }
3472 break;
3473
3474 case SEMA_DECL_REFS:
3475 if (Record.size() != 3) {
3476 Error("Invalid SEMA_DECL_REFS block");
3477 return Failure;
3478 }
3479 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3480 SemaDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3481 break;
3482
3483 case PPD_ENTITIES_OFFSETS: {
3484 F.PreprocessedEntityOffsets = (const PPEntityOffset *)Blob.data();
3485 assert(Blob.size() % sizeof(PPEntityOffset) == 0);
3486 F.NumPreprocessedEntities = Blob.size() / sizeof(PPEntityOffset);
3487
3488 unsigned LocalBasePreprocessedEntityID = Record[0];
3489
3490 unsigned StartingID;
3491 if (!PP.getPreprocessingRecord())
3492 PP.createPreprocessingRecord();
3493 if (!PP.getPreprocessingRecord()->getExternalSource())
3494 PP.getPreprocessingRecord()->SetExternalSource(*this);
3495 StartingID
3496 = PP.getPreprocessingRecord()
3497 ->allocateLoadedEntities(F.NumPreprocessedEntities);
3498 F.BasePreprocessedEntityID = StartingID;
3499
3500 if (F.NumPreprocessedEntities > 0) {
3501 // Introduce the global -> local mapping for preprocessed entities in
3502 // this module.
3503 GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
3504
3505 // Introduce the local -> global mapping for preprocessed entities in
3506 // this module.
3507 F.PreprocessedEntityRemap.insertOrReplace(
3508 std::make_pair(LocalBasePreprocessedEntityID,
3509 F.BasePreprocessedEntityID - LocalBasePreprocessedEntityID));
3510 }
3511
3512 break;
3513 }
3514
3515 case PPD_SKIPPED_RANGES: {
3516 F.PreprocessedSkippedRangeOffsets = (const PPSkippedRange*)Blob.data();
3517 assert(Blob.size() % sizeof(PPSkippedRange) == 0);
3518 F.NumPreprocessedSkippedRanges = Blob.size() / sizeof(PPSkippedRange);
3519
3520 if (!PP.getPreprocessingRecord())
3521 PP.createPreprocessingRecord();
3522 if (!PP.getPreprocessingRecord()->getExternalSource())
3523 PP.getPreprocessingRecord()->SetExternalSource(*this);
3524 F.BasePreprocessedSkippedRangeID = PP.getPreprocessingRecord()
3525 ->allocateSkippedRanges(F.NumPreprocessedSkippedRanges);
3526
3527 if (F.NumPreprocessedSkippedRanges > 0)
3528 GlobalSkippedRangeMap.insert(
3529 std::make_pair(F.BasePreprocessedSkippedRangeID, &F));
3530 break;
3531 }
3532
3533 case DECL_UPDATE_OFFSETS:
3534 if (Record.size() % 2 != 0) {
3535 Error("invalid DECL_UPDATE_OFFSETS block in AST file");
3536 return Failure;
3537 }
3538 for (unsigned I = 0, N = Record.size(); I != N; I += 2) {
3539 GlobalDeclID ID = getGlobalDeclID(F, Record[I]);
3540 DeclUpdateOffsets[ID].push_back(std::make_pair(&F, Record[I + 1]));
3541
3542 // If we've already loaded the decl, perform the updates when we finish
3543 // loading this block.
3544 if (Decl *D = GetExistingDecl(ID))
3545 PendingUpdateRecords.push_back(
3546 PendingUpdateRecord(ID, D, /*JustLoaded=*/false));
3547 }
3548 break;
3549
3550 case OBJC_CATEGORIES_MAP:
3551 if (F.LocalNumObjCCategoriesInMap != 0) {
3552 Error("duplicate OBJC_CATEGORIES_MAP record in AST file");
3553 return Failure;
3554 }
3555
3556 F.LocalNumObjCCategoriesInMap = Record[0];
3557 F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)Blob.data();
3558 break;
3559
3560 case OBJC_CATEGORIES:
3561 F.ObjCCategories.swap(Record);
3562 break;
3563
3564 case CUDA_SPECIAL_DECL_REFS:
3565 // Later tables overwrite earlier ones.
3566 // FIXME: Modules will have trouble with this.
3567 CUDASpecialDeclRefs.clear();
3568 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3569 CUDASpecialDeclRefs.push_back(getGlobalDeclID(F, Record[I]));
3570 break;
3571
3572 case HEADER_SEARCH_TABLE:
3573 F.HeaderFileInfoTableData = Blob.data();
3574 F.LocalNumHeaderFileInfos = Record[1];
3575 if (Record[0]) {
3576 F.HeaderFileInfoTable
3577 = HeaderFileInfoLookupTable::Create(
3578 (const unsigned char *)F.HeaderFileInfoTableData + Record[0],
3579 (const unsigned char *)F.HeaderFileInfoTableData,
3580 HeaderFileInfoTrait(*this, F,
3581 &PP.getHeaderSearchInfo(),
3582 Blob.data() + Record[2]));
3583
3584 PP.getHeaderSearchInfo().SetExternalSource(this);
3585 if (!PP.getHeaderSearchInfo().getExternalLookup())
3586 PP.getHeaderSearchInfo().SetExternalLookup(this);
3587 }
3588 break;
3589
3590 case FP_PRAGMA_OPTIONS:
3591 // Later tables overwrite earlier ones.
3592 FPPragmaOptions.swap(Record);
3593 break;
3594
3595 case OPENCL_EXTENSIONS:
3596 for (unsigned I = 0, E = Record.size(); I != E; ) {
3597 auto Name = ReadString(Record, I);
3598 auto &Opt = OpenCLExtensions.OptMap[Name];
3599 Opt.Supported = Record[I++] != 0;
3600 Opt.Enabled = Record[I++] != 0;
3601 Opt.Avail = Record[I++];
3602 Opt.Core = Record[I++];
3603 }
3604 break;
3605
3606 case OPENCL_EXTENSION_TYPES:
3607 for (unsigned I = 0, E = Record.size(); I != E;) {
3608 auto TypeID = static_cast<::TypeID>(Record[I++]);
3609 auto *Type = GetType(TypeID).getTypePtr();
3610 auto NumExt = static_cast<unsigned>(Record[I++]);
3611 for (unsigned II = 0; II != NumExt; ++II) {
3612 auto Ext = ReadString(Record, I);
3613 OpenCLTypeExtMap[Type].insert(Ext);
3614 }
3615 }
3616 break;
3617
3618 case OPENCL_EXTENSION_DECLS:
3619 for (unsigned I = 0, E = Record.size(); I != E;) {
3620 auto DeclID = static_cast<::DeclID>(Record[I++]);
3621 auto *Decl = GetDecl(DeclID);
3622 auto NumExt = static_cast<unsigned>(Record[I++]);
3623 for (unsigned II = 0; II != NumExt; ++II) {
3624 auto Ext = ReadString(Record, I);
3625 OpenCLDeclExtMap[Decl].insert(Ext);
3626 }
3627 }
3628 break;
3629
3630 case TENTATIVE_DEFINITIONS:
3631 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3632 TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
3633 break;
3634
3635 case KNOWN_NAMESPACES:
3636 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3637 KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
3638 break;
3639
3640 case UNDEFINED_BUT_USED:
3641 if (UndefinedButUsed.size() % 2 != 0) {
3642 Error("Invalid existing UndefinedButUsed");
3643 return Failure;
3644 }
3645
3646 if (Record.size() % 2 != 0) {
3647 Error("invalid undefined-but-used record");
3648 return Failure;
3649 }
3650 for (unsigned I = 0, N = Record.size(); I != N; /* in loop */) {
3651 UndefinedButUsed.push_back(getGlobalDeclID(F, Record[I++]));
3652 UndefinedButUsed.push_back(
3653 ReadSourceLocation(F, Record, I).getRawEncoding());
3654 }
3655 break;
3656
3657 case DELETE_EXPRS_TO_ANALYZE:
3658 for (unsigned I = 0, N = Record.size(); I != N;) {
3659 DelayedDeleteExprs.push_back(getGlobalDeclID(F, Record[I++]));
3660 const uint64_t Count = Record[I++];
3661 DelayedDeleteExprs.push_back(Count);
3662 for (uint64_t C = 0; C < Count; ++C) {
3663 DelayedDeleteExprs.push_back(ReadSourceLocation(F, Record, I).getRawEncoding());
3664 bool IsArrayForm = Record[I++] == 1;
3665 DelayedDeleteExprs.push_back(IsArrayForm);
3666 }
3667 }
3668 break;
3669
3670 case IMPORTED_MODULES:
3671 if (!F.isModule()) {
3672 // If we aren't loading a module (which has its own exports), make
3673 // all of the imported modules visible.
3674 // FIXME: Deal with macros-only imports.
3675 for (unsigned I = 0, N = Record.size(); I != N; /**/) {
3676 unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]);
3677 SourceLocation Loc = ReadSourceLocation(F, Record, I);
3678 if (GlobalID) {
3679 ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc));
3680 if (DeserializationListener)
3681 DeserializationListener->ModuleImportRead(GlobalID, Loc);
3682 }
3683 }
3684 }
3685 break;
3686
3687 case MACRO_OFFSET: {
3688 if (F.LocalNumMacros != 0) {
3689 Error("duplicate MACRO_OFFSET record in AST file");
3690 return Failure;
3691 }
3692 F.MacroOffsets = (const uint32_t *)Blob.data();
3693 F.LocalNumMacros = Record[0];
3694 unsigned LocalBaseMacroID = Record[1];
3695 F.BaseMacroID = getTotalNumMacros();
3696
3697 if (F.LocalNumMacros > 0) {
3698 // Introduce the global -> local mapping for macros within this module.
3699 GlobalMacroMap.insert(std::make_pair(getTotalNumMacros() + 1, &F));
3700
3701 // Introduce the local -> global mapping for macros within this module.
3702 F.MacroRemap.insertOrReplace(
3703 std::make_pair(LocalBaseMacroID,
3704 F.BaseMacroID - LocalBaseMacroID));
3705
3706 MacrosLoaded.resize(MacrosLoaded.size() + F.LocalNumMacros);
3707 }
3708 break;
3709 }
3710
3711 case LATE_PARSED_TEMPLATE:
3712 LateParsedTemplates.append(Record.begin(), Record.end());
3713 break;
3714
3715 case OPTIMIZE_PRAGMA_OPTIONS:
3716 if (Record.size() != 1) {
3717 Error("invalid pragma optimize record");
3718 return Failure;
3719 }
3720 OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
3721 break;
3722
3723 case MSSTRUCT_PRAGMA_OPTIONS:
3724 if (Record.size() != 1) {
3725 Error("invalid pragma ms_struct record");
3726 return Failure;
3727 }
3728 PragmaMSStructState = Record[0];
3729 break;
3730
3731 case POINTERS_TO_MEMBERS_PRAGMA_OPTIONS:
3732 if (Record.size() != 2) {
3733 Error("invalid pragma ms_struct record");
3734 return Failure;
3735 }
3736 PragmaMSPointersToMembersState = Record[0];
3737 PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
3738 break;
3739
3740 case UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES:
3741 for (unsigned I = 0, N = Record.size(); I != N; ++I)
3742 UnusedLocalTypedefNameCandidates.push_back(
3743 getGlobalDeclID(F, Record[I]));
3744 break;
3745
3746 case CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH:
3747 if (Record.size() != 1) {
3748 Error("invalid cuda pragma options record");
3749 return Failure;
3750 }
3751 ForceCUDAHostDeviceDepth = Record[0];
3752 break;
3753
3754 case PACK_PRAGMA_OPTIONS: {
3755 if (Record.size() < 3) {
3756 Error("invalid pragma pack record");
3757 return Failure;
3758 }
3759 PragmaPackCurrentValue = Record[0];
3760 PragmaPackCurrentLocation = ReadSourceLocation(F, Record[1]);
3761 unsigned NumStackEntries = Record[2];
3762 unsigned Idx = 3;
3763 // Reset the stack when importing a new module.
3764 PragmaPackStack.clear();
3765 for (unsigned I = 0; I < NumStackEntries; ++I) {
3766 PragmaPackStackEntry Entry;
3767 Entry.Value = Record[Idx++];
3768 Entry.Location = ReadSourceLocation(F, Record[Idx++]);
3769 Entry.PushLocation = ReadSourceLocation(F, Record[Idx++]);
3770 PragmaPackStrings.push_back(ReadString(Record, Idx));
3771 Entry.SlotLabel = PragmaPackStrings.back();
3772 PragmaPackStack.push_back(Entry);
3773 }
3774 break;
3775 }
3776 }
3777 }
3778 }
3779
3780 void ASTReader::ReadModuleOffsetMap(ModuleFile &F) const {
3781 assert(!F.ModuleOffsetMap.empty() && "no module offset map to read");
3782
3783 // Additional remapping information.
3784 const unsigned char *Data = (const unsigned char*)F.ModuleOffsetMap.data();
3785 const unsigned char *DataEnd = Data + F.ModuleOffsetMap.size();
3786 F.ModuleOffsetMap = StringRef();
3787
3788 // If we see this entry before SOURCE_LOCATION_OFFSETS, add placeholders.
3789 if (F.SLocRemap.find(0) == F.SLocRemap.end()) {
3790 F.SLocRemap.insert(std::make_pair(0U, 0));
3791 F.SLocRemap.insert(std::make_pair(2U, 1));
3792 }
3793
3794 // Continuous range maps we may be updating in our module.
3795 using RemapBuilder = ContinuousRangeMap<uint32_t, int, 2>::Builder;
3796 RemapBuilder SLocRemap(F.SLocRemap);
3797 RemapBuilder IdentifierRemap(F.IdentifierRemap);
3798 RemapBuilder MacroRemap(F.MacroRemap);
3799 RemapBuilder PreprocessedEntityRemap(F.PreprocessedEntityRemap);
3800 RemapBuilder SubmoduleRemap(F.SubmoduleRemap);
3801 RemapBuilder SelectorRemap(F.SelectorRemap);
3802 RemapBuilder DeclRemap(F.DeclRemap);
3803 RemapBuilder TypeRemap(F.TypeRemap);
3804
3805 while (Data < DataEnd) {
3806 // FIXME: Looking up dependency modules by filename is horrible. Let's
3807 // start fixing this with prebuilt and explicit modules and see how it
3808 // goes...
3809 using namespace llvm::support;
3810 ModuleKind Kind = static_cast<ModuleKind>(
3811 endian::readNext<uint8_t, little, unaligned>(Data));
3812 uint16_t Len = endian::readNext<uint16_t, little, unaligned>(Data);
3813 StringRef Name = StringRef((const char*)Data, Len);
3814 Data += Len;
3815 ModuleFile *OM = (Kind == MK_PrebuiltModule || Kind == MK_ExplicitModule
3816 ? ModuleMgr.lookupByModuleName(Name)
3817 : ModuleMgr.lookupByFileName(Name));
3818 if (!OM) {
3819 std::string Msg =
3820 "SourceLocation remap refers to unknown module, cannot find ";
3821 Msg.append(Name);
3822 Error(Msg);
3823 return;
3824 }
3825
3826 uint32_t SLocOffset =
3827 endian::readNext<uint32_t, little, unaligned>(Data);
3828 uint32_t IdentifierIDOffset =
3829 endian::readNext<uint32_t, little, unaligned>(Data);
3830 uint32_t MacroIDOffset =
3831 endian::readNext<uint32_t, little, unaligned>(Data);
3832 uint32_t PreprocessedEntityIDOffset =
3833 endian::readNext<uint32_t, little, unaligned>(Data);
3834 uint32_t SubmoduleIDOffset =
3835 endian::readNext<uint32_t, little, unaligned>(Data);
3836 uint32_t SelectorIDOffset =
3837 endian::readNext<uint32_t, little, unaligned>(Data);
3838 uint32_t DeclIDOffset =
3839 endian::readNext<uint32_t, little, unaligned>(Data);
3840 uint32_t TypeIndexOffset =
3841 endian::readNext<uint32_t, little, unaligned>(Data);
3842
3843 uint32_t None = std::numeric_limits<uint32_t>::max();
3844
3845 auto mapOffset = [&](uint32_t Offset, uint32_t BaseOffset,
3846 RemapBuilder &Remap) {
3847 if (Offset != None)
3848 Remap.insert(std::make_pair(Offset,
3849 static_cast<int>(BaseOffset - Offset)));
3850 };
3851 mapOffset(SLocOffset, OM->SLocEntryBaseOffset, SLocRemap);
3852 mapOffset(IdentifierIDOffset, OM->BaseIdentifierID, IdentifierRemap);
3853 mapOffset(MacroIDOffset, OM->BaseMacroID, MacroRemap);
3854 mapOffset(PreprocessedEntityIDOffset, OM->BasePreprocessedEntityID,
3855 PreprocessedEntityRemap);
3856 mapOffset(SubmoduleIDOffset, OM->BaseSubmoduleID, SubmoduleRemap);
3857 mapOffset(SelectorIDOffset, OM->BaseSelectorID, SelectorRemap);
3858 mapOffset(DeclIDOffset, OM->BaseDeclID, DeclRemap);
3859 mapOffset(TypeIndexOffset, OM->BaseTypeIndex, TypeRemap);
3860
3861 // Global -> local mappings.
3862 F.GlobalToLocalDeclIDs[OM] = DeclIDOffset;
3863 }
3864 }
3865
3866 ASTReader::ASTReadResult
3867 ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
3868 const ModuleFile *ImportedBy,
3869 unsigned ClientLoadCapabilities) {
3870 unsigned Idx = 0;
3871 F.ModuleMapPath = ReadPath(F, Record, Idx);
3872
3873 // Try to resolve ModuleName in the current header search context and
3874 // verify that it is found in the same module map file as we saved. If the
3875 // top-level AST file is a main file, skip this check because there is no
3876 // usable header search context.
3877 assert(!F.ModuleName.empty() &&
3878 "MODULE_NAME should come before MODULE_MAP_FILE");
3879 if (F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
3880 // An implicitly-loaded module file should have its module listed in some
3881 // module map file that we've already loaded.
3882 Module *M = PP.getHeaderSearchInfo().lookupModule(F.ModuleName);
3883 auto &Map = PP.getHeaderSearchInfo().getModuleMap();
3884 const FileEntry *ModMap = M ? Map.getModuleMapFileForUniquing(M) : nullptr;
3885 // Don't emit module relocation error if we have -fno-validate-pch
3886 if (!PP.getPreprocessorOpts().DisablePCHValidation && !ModMap) {
3887 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
3888 if (auto *ASTFE = M ? M->getASTFile() : nullptr) {
3889 // This module was defined by an imported (explicit) module.
3890 Diag(diag::err_module_file_conflict) << F.ModuleName << F.FileName
3891 << ASTFE->getName();
3892 } else {
3893 // This module was built with a different module map.
3894 Diag(diag::err_imported_module_not_found)
3895 << F.ModuleName << F.FileName
3896 << (ImportedBy ? ImportedBy->FileName : "") << F.ModuleMapPath
3897 << !ImportedBy;
3898 // In case it was imported by a PCH, there's a chance the user is
3899 // just missing to include the search path to the directory containing
3900 // the modulemap.
3901 if (ImportedBy && ImportedBy->Kind == MK_PCH)
3902 Diag(diag::note_imported_by_pch_module_not_found)
3903 << llvm::sys::path::parent_path(F.ModuleMapPath);
3904 }
3905 }
3906 return OutOfDate;
3907 }
3908
3909 assert(M->Name == F.ModuleName && "found module with different name");
3910
3911 // Check the primary module map file.
3912 auto StoredModMap = FileMgr.getFile(F.ModuleMapPath);
3913 if (!StoredModMap || *StoredModMap != ModMap) {
3914 assert(ModMap && "found module is missing module map file");
3915 assert((ImportedBy || F.Kind == MK_ImplicitModule) &&
3916 "top-level import should be verified");
3917 bool NotImported = F.Kind == MK_ImplicitModule && !ImportedBy;
3918 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3919 Diag(diag::err_imported_module_modmap_changed)
3920 << F.ModuleName << (NotImported ? F.FileName : ImportedBy->FileName)
3921 << ModMap->getName() << F.ModuleMapPath << NotImported;
3922 return OutOfDate;
3923 }
3924
3925 llvm::SmallPtrSet<const FileEntry *, 1> AdditionalStoredMaps;
3926 for (unsigned I = 0, N = Record[Idx++]; I < N; ++I) {
3927 // FIXME: we should use input files rather than storing names.
3928 std::string Filename = ReadPath(F, Record, Idx);
3929 auto F = FileMgr.getFile(Filename, false, false);
3930 if (!F) {
3931 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3932 Error("could not find file '" + Filename +"' referenced by AST file");
3933 return OutOfDate;
3934 }
3935 AdditionalStoredMaps.insert(*F);
3936 }
3937
3938 // Check any additional module map files (e.g. module.private.modulemap)
3939 // that are not in the pcm.
3940 if (auto *AdditionalModuleMaps = Map.getAdditionalModuleMapFiles(M)) {
3941 for (const FileEntry *ModMap : *AdditionalModuleMaps) {
3942 // Remove files that match
3943 // Note: SmallPtrSet::erase is really remove
3944 if (!AdditionalStoredMaps.erase(ModMap)) {
3945 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3946 Diag(diag::err_module_different_modmap)
3947 << F.ModuleName << /*new*/0 << ModMap->getName();
3948 return OutOfDate;
3949 }
3950 }
3951 }
3952
3953 // Check any additional module map files that are in the pcm, but not
3954 // found in header search. Cases that match are already removed.
3955 for (const FileEntry *ModMap : AdditionalStoredMaps) {
3956 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
3957 Diag(diag::err_module_different_modmap)
3958 << F.ModuleName << /*not new*/1 << ModMap->getName();
3959 return OutOfDate;
3960 }
3961 }
3962
3963 if (Listener)
3964 Listener->ReadModuleMapFile(F.ModuleMapPath);
3965 return Success;
3966 }
3967
3968 /// Move the given method to the back of the global list of methods.
3969 static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method) {
3970 // Find the entry for this selector in the method pool.
3971 Sema::GlobalMethodPool::iterator Known
3972 = S.MethodPool.find(Method->getSelector());
3973 if (Known == S.MethodPool.end())
3974 return;
3975
3976 // Retrieve the appropriate method list.
3977 ObjCMethodList &Start = Method->isInstanceMethod()? Known->second.first
3978 : Known->second.second;
3979 bool Found = false;
3980 for (ObjCMethodList *List = &Start; List; List = List->getNext()) {
3981 if (!Found) {
3982 if (List->getMethod() == Method) {
3983 Found = true;
3984 } else {
3985 // Keep searching.
3986 continue;
3987 }
3988 }
3989
3990 if (List->getNext())
3991 List->setMethod(List->getNext()->getMethod());
3992 else
3993 List->setMethod(Method);
3994 }
3995 }
3996
3997 void ASTReader::makeNamesVisible(const HiddenNames &Names, Module *Owner) {
3998 assert(Owner->NameVisibility != Module::Hidden && "nothing to make visible?");
3999 for (Decl *D : Names) {
4000 bool wasHidden = D->isHidden();
4001 D->setVisibleDespiteOwningModule();
4002
4003 if (wasHidden && SemaObj) {
4004 if (ObjCMethodDecl *Method = dyn_cast<ObjCMethodDecl>(D)) {
4005 moveMethodToBackOfGlobalList(*SemaObj, Method);
4006 }
4007 }
4008 }
4009 }
4010
4011 void ASTReader::makeModuleVisible(Module *Mod,
4012 Module::NameVisibilityKind NameVisibility,
4013 SourceLocation ImportLoc) {
4014 llvm::SmallPtrSet<Module *, 4> Visited;
4015 SmallVector<Module *, 4> Stack;
4016 Stack.push_back(Mod);
4017 while (!Stack.empty()) {
4018 Mod = Stack.pop_back_val();
4019
4020 if (NameVisibility <= Mod->NameVisibility) {
4021 // This module already has this level of visibility (or greater), so
4022 // there is nothing more to do.
4023 continue;
4024 }
4025
4026 if (!Mod->isAvailable()) {
4027 // Modules that aren't available cannot be made visible.
4028 continue;
4029 }
4030
4031 // Update the module's name visibility.
4032 Mod->NameVisibility = NameVisibility;
4033
4034 // If we've already deserialized any names from this module,
4035 // mark them as visible.
4036 HiddenNamesMapType::iterator Hidden = HiddenNamesMap.find(Mod);
4037 if (Hidden != HiddenNamesMap.end()) {
4038 auto HiddenNames = std::move(*Hidden);
4039 HiddenNamesMap.erase(Hidden);
4040 makeNamesVisible(HiddenNames.second, HiddenNames.first);
4041 assert(HiddenNamesMap.find(Mod) == HiddenNamesMap.end() &&
4042 "making names visible added hidden names");
4043 }
4044
4045 // Push any exported modules onto the stack to be marked as visible.
4046 SmallVector<Module *, 16> Exports;
4047 Mod->getExportedModules(Exports);
4048 for (SmallVectorImpl<Module *>::iterator
4049 I = Exports.begin(), E = Exports.end(); I != E; ++I) {
4050 Module *Exported = *I;
4051 if (Visited.insert(Exported).second)
4052 Stack.push_back(Exported);
4053 }
4054 }
4055 }
4056
4057 /// We've merged the definition \p MergedDef into the existing definition
4058 /// \p Def. Ensure that \p Def is made visible whenever \p MergedDef is made
4059 /// visible.
4060 void ASTReader::mergeDefinitionVisibility(NamedDecl *Def,
4061 NamedDecl *MergedDef) {
4062 if (Def->isHidden()) {
4063 // If MergedDef is visible or becomes visible, make the definition visible.
4064 if (!MergedDef->isHidden())
4065 Def->setVisibleDespiteOwningModule();
4066 else {
4067 getContext().mergeDefinitionIntoModule(
4068 Def, MergedDef->getImportedOwningModule(),
4069 /*NotifyListeners*/ false);
4070 PendingMergedDefinitionsToDeduplicate.insert(Def);
4071 }
4072 }
4073 }
4074
4075 bool ASTReader::loadGlobalIndex() {
4076 if (GlobalIndex)
4077 return false;
4078
4079 if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
4080 !PP.getLangOpts().Modules)
4081 return true;
4082
4083 // Try to load the global index.
4084 TriedLoadingGlobalIndex = true;
4085 StringRef ModuleCachePath
4086 = getPreprocessor().getHeaderSearchInfo().getModuleCachePath();
4087 std::pair<GlobalModuleIndex *, llvm::Error> Result =
4088 GlobalModuleIndex::readIndex(ModuleCachePath);
4089 if (llvm::Error Err = std::move(Result.second)) {
4090 assert(!Result.first);
4091 consumeError(std::move(Err)); // FIXME this drops errors on the floor.
4092 return true;
4093 }
4094
4095 GlobalIndex.reset(Result.first);
4096 ModuleMgr.setGlobalIndex(GlobalIndex.get());
4097 return false;
4098 }
4099
4100 bool ASTReader::isGlobalIndexUnavailable() const {
4101 return PP.getLangOpts().Modules && UseGlobalIndex &&
4102 !hasGlobalIndex() && TriedLoadingGlobalIndex;
4103 }
4104
4105 static void updateModuleTimestamp(ModuleFile &MF) {
4106 // Overwrite the timestamp file contents so that file's mtime changes.
4107 std::string TimestampFilename = MF.getTimestampFilename();
4108 std::error_code EC;
4109 llvm::raw_fd_ostream OS(TimestampFilename, EC, llvm::sys::fs::OF_Text);
4110 if (EC)
4111 return;
4112 OS << "Timestamp file\n";
4113 OS.close();
4114 OS.clear_error(); // Avoid triggering a fatal error.
4115 }
4116
4117 /// Given a cursor at the start of an AST file, scan ahead and drop the
4118 /// cursor into the start of the given block ID, returning false on success and
4119 /// true on failure.
4120 static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID) {
4121 while (true) {
4122 Expected<llvm::BitstreamEntry> MaybeEntry = Cursor.advance();
4123 if (!MaybeEntry) {
4124 // FIXME this drops errors on the floor.
4125 consumeError(MaybeEntry.takeError());
4126 return true;
4127 }
4128 llvm::BitstreamEntry Entry = MaybeEntry.get();
4129
4130 switch (Entry.Kind) {
4131 case llvm::BitstreamEntry::Error:
4132 case llvm::BitstreamEntry::EndBlock:
4133 return true;
4134
4135 case llvm::BitstreamEntry::Record:
4136 // Ignore top-level records.
4137 if (Expected<unsigned> Skipped = Cursor.skipRecord(Entry.ID))
4138 break;
4139 else {
4140 // FIXME this drops errors on the floor.
4141 consumeError(Skipped.takeError());
4142 return true;
4143 }
4144
4145 case llvm::BitstreamEntry::SubBlock:
4146 if (Entry.ID == BlockID) {
4147 if (llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
4148 // FIXME this drops the error on the floor.
4149 consumeError(std::move(Err));
4150 return true;
4151 }
4152 // Found it!
4153 return false;
4154 }
4155
4156 if (llvm::Error Err = Cursor.SkipBlock()) {
4157 // FIXME this drops the error on the floor.
4158 consumeError(std::move(Err));
4159 return true;
4160 }
4161 }
4162 }
4163 }
4164
4165 ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
4166 ModuleKind Type,
4167 SourceLocation ImportLoc,
4168 unsigned ClientLoadCapabilities,
4169 SmallVectorImpl<ImportedSubmodule> *Imported) {
4170 llvm::SaveAndRestore<SourceLocation>
4171 SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
4172
4173 // Defer any pending actions until we get to the end of reading the AST file.
4174 Deserializing AnASTFile(this);
4175
4176 // Bump the generation number.
4177 unsigned PreviousGeneration = 0;
4178 if (ContextObj)
4179 PreviousGeneration = incrementGeneration(*ContextObj);
4180
4181 unsigned NumModules = ModuleMgr.size();
4182 auto removeModulesAndReturn = [&](ASTReadResult ReadResult) {
4183 assert(ReadResult && "expected to return error");
4184 ModuleMgr.removeModules(ModuleMgr.begin() + NumModules,
4185 PP.getLangOpts().Modules
4186 ? &PP.getHeaderSearchInfo().getModuleMap()
4187 : nullptr);
4188
4189 // If we find that any modules are unusable, the global index is going
4190 // to be out-of-date. Just remove it.
4191 GlobalIndex.reset();
4192 ModuleMgr.setGlobalIndex(nullptr);
4193 return ReadResult;
4194 };
4195
4196 SmallVector<ImportedModule, 4> Loaded;
4197 switch (ASTReadResult ReadResult =
4198 ReadASTCore(FileName, Type, ImportLoc,
4199 /*ImportedBy=*/nullptr, Loaded, 0, 0,
4200 ASTFileSignature(), ClientLoadCapabilities)) {
4201 case Failure:
4202 case Missing:
4203 case OutOfDate:
4204 case VersionMismatch:
4205 case ConfigurationMismatch:
4206 case HadErrors:
4207 return removeModulesAndReturn(ReadResult);
4208 case Success:
4209 break;
4210 }
4211
4212 // Here comes stuff that we only do once the entire chain is loaded.
4213
4214 // Load the AST blocks of all of the modules that we loaded. We can still
4215 // hit errors parsing the ASTs at this point.
4216 for (ImportedModule &M : Loaded) {
4217 ModuleFile &F = *M.Mod;
4218
4219 // Read the AST block.
4220 if (ASTReadResult Result = ReadASTBlock(F, ClientLoadCapabilities))
4221 return removeModulesAndReturn(Result);
4222
4223 // The AST block should always have a definition for the main module.
4224 if (F.isModule() && !F.DidReadTopLevelSubmodule) {
4225 Error(diag::err_module_file_missing_top_level_submodule, F.FileName);
4226 return removeModulesAndReturn(Failure);
4227 }
4228
4229 // Read the extension blocks.
4230 while (!SkipCursorToBlock(F.Stream, EXTENSION_BLOCK_ID)) {
4231 if (ASTReadResult Result = ReadExtensionBlock(F))
4232 return removeModulesAndReturn(Result);
4233 }
4234
4235 // Once read, set the ModuleFile bit base offset and update the size in
4236 // bits of all files we've seen.
4237 F.GlobalBitOffset = TotalModulesSizeInBits;
4238 TotalModulesSizeInBits += F.SizeInBits;
4239 GlobalBitOffsetsMap.insert(std::make_pair(F.GlobalBitOffset, &F));
4240 }
4241
4242 // Preload source locations and interesting indentifiers.
4243 for (ImportedModule &M : Loaded) {
4244 ModuleFile &F = *M.Mod;
4245
4246 // Preload SLocEntries.
4247 for (unsigned I = 0, N = F.PreloadSLocEntries.size(); I != N; ++I) {
4248 int Index = int(F.PreloadSLocEntries[I] - 1) + F.SLocEntryBaseID;
4249 // Load it through the SourceManager and don't call ReadSLocEntry()
4250 // directly because the entry may have already been loaded in which case
4251 // calling ReadSLocEntry() directly would trigger an assertion in
4252 // SourceManager.
4253 SourceMgr.getLoadedSLocEntryByID(Index);
4254 }
4255
4256 // Map the original source file ID into the ID space of the current
4257 // compilation.
4258 if (F.OriginalSourceFileID.isValid()) {
4259 F.OriginalSourceFileID = FileID::get(
4260 F.SLocEntryBaseID + F.OriginalSourceFileID.getOpaqueValue() - 1);
4261 }
4262
4263 // Preload all the pending interesting identifiers by marking them out of
4264 // date.
4265 for (auto Offset : F.PreloadIdentifierOffsets) {
4266 const unsigned char *Data = reinterpret_cast<const unsigned char *>(
4267 F.IdentifierTableData + Offset);
4268
4269 ASTIdentifierLookupTrait Trait(*this, F);
4270 auto KeyDataLen = Trait.ReadKeyDataLength(Data);
4271 auto Key = Trait.ReadKey(Data, KeyDataLen.first);
4272 auto &II = PP.getIdentifierTable().getOwn(Key);
4273 II.setOutOfDate(true);
4274
4275 // Mark this identifier as being from an AST file so that we can track
4276 // whether we need to serialize it.
4277 markIdentifierFromAST(*this, II);
4278
4279 // Associate the ID with the identifier so that the writer can reuse it.
4280 auto ID = Trait.ReadIdentifierID(Data + KeyDataLen.first);
4281 SetIdentifierInfo(ID, &II);
4282 }
4283 }
4284
4285 // Setup the import locations and notify the module manager that we've
4286 // committed to these module files.
4287 for (ImportedModule &M : Loaded) {
4288 ModuleFile &F = *M.Mod;
4289
4290 ModuleMgr.moduleFileAccepted(&F);
4291
4292 // Set the import location.
4293 F.DirectImportLoc = ImportLoc;
4294 // FIXME: We assume that locations from PCH / preamble do not need
4295 // any translation.
4296 if (!M.ImportedBy)
4297 F.ImportLoc = M.ImportLoc;
4298 else
4299 F.ImportLoc = TranslateSourceLocation(*M.ImportedBy, M.ImportLoc);
4300 }
4301
4302 if (!PP.getLangOpts().CPlusPlus ||
4303 (Type != MK_ImplicitModule && Type != MK_ExplicitModule &&
4304 Type != MK_PrebuiltModule)) {
4305 // Mark all of the identifiers in the identifier table as being out of date,
4306 // so that various accessors know to check the loaded modules when the
4307 // identifier is used.
4308 //
4309 // For C++ modules, we don't need information on many identifiers (just
4310 // those that provide macros or are poisoned), so we mark all of
4311 // the interesting ones via PreloadIdentifierOffsets.
4312 for (IdentifierTable::iterator Id = PP.getIdentifierTable().begin(),
4313 IdEnd = PP.getIdentifierTable().end();
4314 Id != IdEnd; ++Id)
4315 Id->second->setOutOfDate(true);
4316 }
4317 // Mark selectors as out of date.
4318 for (auto Sel : SelectorGeneration)
4319 SelectorOutOfDate[Sel.first] = true;
4320
4321 // Resolve any unresolved module exports.
4322 for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
4323 UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
4324 SubmoduleID GlobalID = getGlobalSubmoduleID(*Unresolved.File,Unresolved.ID);
4325 Module *ResolvedMod = getSubmodule(GlobalID);
4326
4327 switch (Unresolved.Kind) {
4328 case UnresolvedModuleRef::Conflict:
4329 if (ResolvedMod) {
4330 Module::Conflict Conflict;
4331 Conflict.Other = ResolvedMod;
4332 Conflict.Message = Unresolved.String.str();
4333 Unresolved.Mod->Conflicts.push_back(Conflict);
4334 }
4335 continue;
4336
4337 case UnresolvedModuleRef::Import:
4338 if (ResolvedMod)
4339 Unresolved.Mod->Imports.insert(ResolvedMod);
4340 continue;
4341
4342 case UnresolvedModuleRef::Export:
4343 if (ResolvedMod || Unresolved.IsWildcard)
4344 Unresolved.Mod->Exports.push_back(
4345 Module::ExportDecl(ResolvedMod, Unresolved.IsWildcard));
4346 continue;
4347 }
4348 }
4349 UnresolvedModuleRefs.clear();
4350
4351 if (Imported)
4352 Imported->append(ImportedModules.begin(),
4353 ImportedModules.end());
4354
4355 // FIXME: How do we load the 'use'd modules? They may not be submodules.
4356 // Might be unnecessary as use declarations are only used to build the
4357 // module itself.
4358
4359 if (ContextObj)
4360 InitializeContext();
4361
4362 if (SemaObj)
4363 UpdateSema();
4364
4365 if (DeserializationListener)
4366 DeserializationListener->ReaderInitialized(this);
4367
4368 ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
4369 if (PrimaryModule.OriginalSourceFileID.isValid()) {
4370 // If this AST file is a precompiled preamble, then set the
4371 // preamble file ID of the source manager to the file source file
4372 // from which the preamble was built.
4373 if (Type == MK_Preamble) {
4374 SourceMgr.setPreambleFileID(PrimaryModule.OriginalSourceFileID);
4375 } else if (Type == MK_MainFile) {
4376 SourceMgr.setMainFileID(PrimaryModule.OriginalSourceFileID);
4377 }
4378 }
4379
4380 // For any Objective-C class definitions we have already loaded, make sure
4381 // that we load any additional categories.
4382 if (ContextObj) {
4383 for (unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
4384 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
4385 ObjCClassesLoaded[I],
4386 PreviousGeneration);
4387 }
4388 }
4389
4390 if (PP.getHeaderSearchInfo()
4391 .getHeaderSearchOpts()
4392 .ModulesValidateOncePerBuildSession) {
4393 // Now we are certain that the module and all modules it depends on are
4394 // up to date. Create or update timestamp files for modules that are
4395 // located in the module cache (not for PCH files that could be anywhere
4396 // in the filesystem).
4397 for (unsigned I = 0, N = Loaded.size(); I != N; ++I) {
4398 ImportedModule &M = Loaded[I];
4399 if (M.Mod->Kind == MK_ImplicitModule) {
4400 updateModuleTimestamp(*M.Mod);
4401 }
4402 }
4403 }
4404
4405 return Success;
4406 }
4407
4408 static ASTFileSignature readASTFileSignature(StringRef PCH);
4409
4410 /// Whether \p Stream doesn't start with the AST/PCH file magic number 'CPCH'.
4411 static llvm::Error doesntStartWithASTFileMagic(BitstreamCursor &Stream) {
4412 // FIXME checking magic headers is done in other places such as
4413 // SerializedDiagnosticReader and GlobalModuleIndex, but error handling isn't
4414 // always done the same. Unify it all with a helper.
4415 if (!Stream.canSkipToPos(4))
4416 return llvm::createStringError(std::errc::illegal_byte_sequence,
4417 "file too small to contain AST file magic");
4418 for (unsigned C : {'C', 'P', 'C', 'H'})
4419 if (Expected<llvm::SimpleBitstreamCursor::word_t> Res = Stream.Read(8)) {
4420 if (Res.get() != C)
4421 return llvm::createStringError(
4422 std::errc::illegal_byte_sequence,
4423 "file doesn't start with AST file magic");
4424 } else
4425 return Res.takeError();
4426 return llvm::Error::success();
4427 }
4428
4429 static unsigned moduleKindForDiagnostic(ModuleKind Kind) {
4430 switch (Kind) {
4431 case MK_PCH:
4432 return 0; // PCH
4433 case MK_ImplicitModule:
4434 case MK_ExplicitModule:
4435 case MK_PrebuiltModule:
4436 return 1; // module
4437 case MK_MainFile:
4438 case MK_Preamble:
4439 return 2; // main source file
4440 }
4441 llvm_unreachable("unknown module kind");
4442 }
4443
4444 ASTReader::ASTReadResult
4445 ASTReader::ReadASTCore(StringRef FileName,
4446 ModuleKind Type,
4447 SourceLocation ImportLoc,
4448 ModuleFile *ImportedBy,
4449 SmallVectorImpl<ImportedModule> &Loaded,
4450 off_t ExpectedSize, time_t ExpectedModTime,
4451 ASTFileSignature ExpectedSignature,
4452 unsigned ClientLoadCapabilities) {
4453 ModuleFile *M;
4454 std::string ErrorStr;
4455 ModuleManager::AddModuleResult AddResult
4456 = ModuleMgr.addModule(FileName, Type, ImportLoc, ImportedBy,
4457 getGeneration(), ExpectedSize, ExpectedModTime,
4458 ExpectedSignature, readASTFileSignature,
4459 M, ErrorStr);
4460
4461 switch (AddResult) {
4462 case ModuleManager::AlreadyLoaded:
4463 Diag(diag::remark_module_import)
4464 << M->ModuleName << M->FileName << (ImportedBy ? true : false)
4465 << (ImportedBy ? StringRef(ImportedBy->ModuleName) : StringRef());
4466 return Success;
4467
4468 case ModuleManager::NewlyLoaded:
4469 // Load module file below.
4470 break;
4471
4472 case ModuleManager::Missing:
4473 // The module file was missing; if the client can handle that, return
4474 // it.
4475 if (ClientLoadCapabilities & ARR_Missing)
4476 return Missing;
4477
4478 // Otherwise, return an error.
4479 Diag(diag::err_module_file_not_found) << moduleKindForDiagnostic(Type)
4480 << FileName << !ErrorStr.empty()
4481 << ErrorStr;
4482 return Failure;
4483
4484 case ModuleManager::OutOfDate:
4485 // We couldn't load the module file because it is out-of-date. If the
4486 // client can handle out-of-date, return it.
4487 if (ClientLoadCapabilities & ARR_OutOfDate)
4488 return OutOfDate;
4489
4490 // Otherwise, return an error.
4491 Diag(diag::err_module_file_out_of_date) << moduleKindForDiagnostic(Type)
4492 << FileName << !ErrorStr.empty()
4493 << ErrorStr;
4494 return Failure;
4495 }
4496
4497 assert(M && "Missing module file");
4498
4499 bool ShouldFinalizePCM = false;
4500 auto FinalizeOrDropPCM = llvm::make_scope_exit([&]() {
4501 auto &MC = getModuleManager().getModuleCache();
4502 if (ShouldFinalizePCM)
4503 MC.finalizePCM(FileName);
4504 else
4505 MC.tryToDropPCM(FileName);
4506 });
4507 ModuleFile &F = *M;
4508 BitstreamCursor &Stream = F.Stream;
4509 Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer));
4510 F.SizeInBits = F.Buffer->getBufferSize() * 8;
4511
4512 // Sniff for the signature.
4513 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
4514 Diag(diag::err_module_file_invalid)
4515 << moduleKindForDiagnostic(Type) << FileName << std::move(Err);
4516 return Failure;
4517 }
4518
4519 // This is used for compatibility with older PCH formats.
4520 bool HaveReadControlBlock = false;
4521 while (true) {
4522 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
4523 if (!MaybeEntry) {
4524 Error(MaybeEntry.takeError());
4525 return Failure;
4526 }
4527 llvm::BitstreamEntry Entry = MaybeEntry.get();
4528
4529 switch (Entry.Kind) {
4530 case llvm::BitstreamEntry::Error:
4531 case llvm::BitstreamEntry::Record:
4532 case llvm::BitstreamEntry::EndBlock:
4533 Error("invalid record at top-level of AST file");
4534 return Failure;
4535
4536 case llvm::BitstreamEntry::SubBlock:
4537 break;
4538 }
4539
4540 switch (Entry.ID) {
4541 case CONTROL_BLOCK_ID:
4542 HaveReadControlBlock = true;
4543 switch (ReadControlBlock(F, Loaded, ImportedBy, ClientLoadCapabilities)) {
4544 case Success:
4545 // Check that we didn't try to load a non-module AST file as a module.
4546 //
4547 // FIXME: Should we also perform the converse check? Loading a module as
4548 // a PCH file sort of works, but it's a bit wonky.
4549 if ((Type == MK_ImplicitModule || Type == MK_ExplicitModule ||
4550 Type == MK_PrebuiltModule) &&
4551 F.ModuleName.empty()) {
4552 auto Result = (Type == MK_ImplicitModule) ? OutOfDate : Failure;
4553 if (Result != OutOfDate ||
4554 (ClientLoadCapabilities & ARR_OutOfDate) == 0)
4555 Diag(diag::err_module_file_not_module) << FileName;
4556 return Result;
4557 }
4558 break;
4559
4560 case Failure: return Failure;
4561 case Missing: return Missing;
4562 case OutOfDate: return OutOfDate;
4563 case VersionMismatch: return VersionMismatch;
4564 case ConfigurationMismatch: return ConfigurationMismatch;
4565 case HadErrors: return HadErrors;
4566 }
4567 break;
4568
4569 case AST_BLOCK_ID:
4570 if (!HaveReadControlBlock) {
4571 if ((ClientLoadCapabilities & ARR_VersionMismatch) == 0)
4572 Diag(diag::err_pch_version_too_old);
4573 return VersionMismatch;
4574 }
4575
4576 // Record that we've loaded this module.
4577 Loaded.push_back(ImportedModule(M, ImportedBy, ImportLoc));
4578 ShouldFinalizePCM = true;
4579 return Success;
4580
4581 case UNHASHED_CONTROL_BLOCK_ID:
4582 // This block is handled using look-ahead during ReadControlBlock. We
4583 // shouldn't get here!
4584 Error("malformed block record in AST file");
4585 return Failure;
4586
4587 default:
4588 if (llvm::Error Err = Stream.SkipBlock()) {
4589 Error(std::move(Err));
4590 return Failure;
4591 }
4592 break;
4593 }
4594 }
4595
4596 llvm_unreachable("unexpected break; expected return");
4597 }
4598
4599 ASTReader::ASTReadResult
4600 ASTReader::readUnhashedControlBlock(ModuleFile &F, bool WasImportedBy,
4601 unsigned ClientLoadCapabilities) {
4602 const HeaderSearchOptions &HSOpts =
4603 PP.getHeaderSearchInfo().getHeaderSearchOpts();
4604 bool AllowCompatibleConfigurationMismatch =
4605 F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule;
4606
4607 ASTReadResult Result = readUnhashedControlBlockImpl(
4608 &F, F.Data, ClientLoadCapabilities, AllowCompatibleConfigurationMismatch,
4609 Listener.get(),
4610 WasImportedBy ? false : HSOpts.ModulesValidateDiagnosticOptions);
4611
4612 // If F was directly imported by another module, it's implicitly validated by
4613 // the importing module.
4614 if (DisableValidation || WasImportedBy ||
4615 (AllowConfigurationMismatch && Result == ConfigurationMismatch))
4616 return Success;
4617
4618 if (Result == Failure) {
4619 Error("malformed block record in AST file");
4620 return Failure;
4621 }
4622
4623 if (Result == OutOfDate && F.Kind == MK_ImplicitModule) {
4624 // If this module has already been finalized in the ModuleCache, we're stuck
4625 // with it; we can only load a single version of each module.
4626 //
4627 // This can happen when a module is imported in two contexts: in one, as a
4628 // user module; in another, as a system module (due to an import from
4629 // another module marked with the [system] flag). It usually indicates a
4630 // bug in the module map: this module should also be marked with [system].
4631 //
4632 // If -Wno-system-headers (the default), and the first import is as a
4633 // system module, then validation will fail during the as-user import,
4634 // since -Werror flags won't have been validated. However, it's reasonable
4635 // to treat this consistently as a system module.
4636 //
4637 // If -Wsystem-headers, the PCM on disk was built with
4638 // -Wno-system-headers, and the first import is as a user module, then
4639 // validation will fail during the as-system import since the PCM on disk
4640 // doesn't guarantee that -Werror was respected. However, the -Werror
4641 // flags were checked during the initial as-user import.
4642 if (getModuleManager().getModuleCache().isPCMFinal(F.FileName)) {
4643 Diag(diag::warn_module_system_bit_conflict) << F.FileName;
4644 return Success;
4645 }
4646 }
4647
4648 return Result;
4649 }
4650
4651 ASTReader::ASTReadResult ASTReader::readUnhashedControlBlockImpl(
4652 ModuleFile *F, llvm::StringRef StreamData, unsigned ClientLoadCapabilities,
4653 bool AllowCompatibleConfigurationMismatch, ASTReaderListener *Listener,
4654 bool ValidateDiagnosticOptions) {
4655 // Initialize a stream.
4656 BitstreamCursor Stream(StreamData);
4657
4658 // Sniff for the signature.
4659 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
4660 // FIXME this drops the error on the floor.
4661 consumeError(std::move(Err));
4662 return Failure;
4663 }
4664
4665 // Scan for the UNHASHED_CONTROL_BLOCK_ID block.
4666 if (SkipCursorToBlock(Stream, UNHASHED_CONTROL_BLOCK_ID))
4667 return Failure;
4668
4669 // Read all of the records in the options block.
4670 RecordData Record;
4671 ASTReadResult Result = Success;
4672 while (true) {
4673 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
4674 if (!MaybeEntry) {
4675 // FIXME this drops the error on the floor.
4676 consumeError(MaybeEntry.takeError());
4677 return Failure;
4678 }
4679 llvm::BitstreamEntry Entry = MaybeEntry.get();
4680
4681 switch (Entry.Kind) {
4682 case llvm::BitstreamEntry::Error:
4683 case llvm::BitstreamEntry::SubBlock:
4684 return Failure;
4685
4686 case llvm::BitstreamEntry::EndBlock:
4687 return Result;
4688
4689 case llvm::BitstreamEntry::Record:
4690 // The interesting case.
4691 break;
4692 }
4693
4694 // Read and process a record.
4695 Record.clear();
4696 Expected<unsigned> MaybeRecordType = Stream.readRecord(Entry.ID, Record);
4697 if (!MaybeRecordType) {
4698 // FIXME this drops the error.
4699 return Failure;
4700 }
4701 switch ((UnhashedControlBlockRecordTypes)MaybeRecordType.get()) {
4702 case SIGNATURE:
4703 if (F)
4704 std::copy(Record.begin(), Record.end(), F->Signature.data());
4705 break;
4706 case DIAGNOSTIC_OPTIONS: {
4707 bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
4708 if (Listener && ValidateDiagnosticOptions &&
4709 !AllowCompatibleConfigurationMismatch &&
4710 ParseDiagnosticOptions(Record, Complain, *Listener))
4711 Result = OutOfDate; // Don't return early. Read the signature.
4712 break;
4713 }
4714 case DIAG_PRAGMA_MAPPINGS:
4715 if (!F)
4716 break;
4717 if (F->PragmaDiagMappings.empty())
4718 F->PragmaDiagMappings.swap(Record);
4719 else
4720 F->PragmaDiagMappings.insert(F->PragmaDiagMappings.end(),
4721 Record.begin(), Record.end());
4722 break;
4723 }
4724 }
4725 }
4726
4727 /// Parse a record and blob containing module file extension metadata.
4728 static bool parseModuleFileExtensionMetadata(
4729 const SmallVectorImpl<uint64_t> &Record,
4730 StringRef Blob,
4731 ModuleFileExtensionMetadata &Metadata) {
4732 if (Record.size() < 4) return true;
4733
4734 Metadata.MajorVersion = Record[0];
4735 Metadata.MinorVersion = Record[1];
4736
4737 unsigned BlockNameLen = Record[2];
4738 unsigned UserInfoLen = Record[3];
4739
4740 if (BlockNameLen + UserInfoLen > Blob.size()) return true;
4741
4742 Metadata.BlockName = std::string(Blob.data(), Blob.data() + BlockNameLen);
4743 Metadata.UserInfo = std::string(Blob.data() + BlockNameLen,
4744 Blob.data() + BlockNameLen + UserInfoLen);
4745 return false;
4746 }
4747
4748 ASTReader::ASTReadResult ASTReader::ReadExtensionBlock(ModuleFile &F) {
4749 BitstreamCursor &Stream = F.Stream;
4750
4751 RecordData Record;
4752 while (true) {
4753 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
4754 if (!MaybeEntry) {
4755 Error(MaybeEntry.takeError());
4756 return Failure;
4757 }
4758 llvm::BitstreamEntry Entry = MaybeEntry.get();
4759
4760 switch (Entry.Kind) {
4761 case llvm::BitstreamEntry::SubBlock:
4762 if (llvm::Error Err = Stream.SkipBlock()) {
4763 Error(std::move(Err));
4764 return Failure;
4765 }
4766 continue;
4767
4768 case llvm::BitstreamEntry::EndBlock:
4769 return Success;
4770
4771 case llvm::BitstreamEntry::Error:
4772 return HadErrors;
4773
4774 case llvm::BitstreamEntry::Record:
4775 break;
4776 }
4777
4778 Record.clear();
4779 StringRef Blob;
4780 Expected<unsigned> MaybeRecCode =
4781 Stream.readRecord(Entry.ID, Record, &Blob);
4782 if (!MaybeRecCode) {
4783 Error(MaybeRecCode.takeError());
4784 return Failure;
4785 }
4786 switch (MaybeRecCode.get()) {
4787 case EXTENSION_METADATA: {
4788 ModuleFileExtensionMetadata Metadata;
4789 if (parseModuleFileExtensionMetadata(Record, Blob, Metadata)) {
4790 Error("malformed EXTENSION_METADATA in AST file");
4791 return Failure;
4792 }
4793
4794 // Find a module file extension with this block name.
4795 auto Known = ModuleFileExtensions.find(Metadata.BlockName);
4796 if (Known == ModuleFileExtensions.end()) break;
4797
4798 // Form a reader.
4799 if (auto Reader = Known->second->createExtensionReader(Metadata, *this,
4800 F, Stream)) {
4801 F.ExtensionReaders.push_back(std::move(Reader));
4802 }
4803
4804 break;
4805 }
4806 }
4807 }
4808
4809 return Success;
4810 }
4811
4812 void ASTReader::InitializeContext() {
4813 assert(ContextObj && "no context to initialize");
4814 ASTContext &Context = *ContextObj;
4815
4816 // If there's a listener, notify them that we "read" the translation unit.
4817 if (DeserializationListener)
4818 DeserializationListener->DeclRead(PREDEF_DECL_TRANSLATION_UNIT_ID,
4819 Context.getTranslationUnitDecl());
4820
4821 // FIXME: Find a better way to deal with collisions between these
4822 // built-in types. Right now, we just ignore the problem.
4823
4824 // Load the special types.
4825 if (SpecialTypes.size() >= NumSpecialTypeIDs) {
4826 if (unsigned String = SpecialTypes[SPECIAL_TYPE_CF_CONSTANT_STRING]) {
4827 if (!Context.CFConstantStringTypeDecl)
4828 Context.setCFConstantStringType(GetType(String));
4829 }
4830
4831 if (unsigned File = SpecialTypes[SPECIAL_TYPE_FILE]) {
4832 QualType FileType = GetType(File);
4833 if (FileType.isNull()) {
4834 Error("FILE type is NULL");
4835 return;
4836 }
4837
4838 if (!Context.FILEDecl) {
4839 if (const TypedefType *Typedef = FileType->getAs<TypedefType>())
4840 Context.setFILEDecl(Typedef->getDecl());
4841 else {
4842 const TagType *Tag = FileType->getAs<TagType>();
4843 if (!Tag) {
4844 Error("Invalid FILE type in AST file");
4845 return;
4846 }
4847 Context.setFILEDecl(Tag->getDecl());
4848 }
4849 }
4850 }
4851
4852 if (unsigned Jmp_buf = SpecialTypes[SPECIAL_TYPE_JMP_BUF]) {
4853 QualType Jmp_bufType = GetType(Jmp_buf);
4854 if (Jmp_bufType.isNull()) {
4855 Error("jmp_buf type is NULL");
4856 return;
4857 }
4858
4859 if (!Context.jmp_bufDecl) {
4860 if (const TypedefType *Typedef = Jmp_bufType->getAs<TypedefType>())
4861 Context.setjmp_bufDecl(Typedef->getDecl());
4862 else {
4863 const TagType *Tag = Jmp_bufType->getAs<TagType>();
4864 if (!Tag) {
4865 Error("Invalid jmp_buf type in AST file");
4866 return;
4867 }
4868 Context.setjmp_bufDecl(Tag->getDecl());
4869 }
4870 }
4871 }
4872
4873 if (unsigned Sigjmp_buf = SpecialTypes[SPECIAL_TYPE_SIGJMP_BUF]) {
4874 QualType Sigjmp_bufType = GetType(Sigjmp_buf);
4875 if (Sigjmp_bufType.isNull()) {
4876 Error("sigjmp_buf type is NULL");
4877 return;
4878 }
4879
4880 if (!Context.sigjmp_bufDecl) {
4881 if (const TypedefType *Typedef = Sigjmp_bufType->getAs<TypedefType>())
4882 Context.setsigjmp_bufDecl(Typedef->getDecl());
4883 else {
4884 const TagType *Tag = Sigjmp_bufType->getAs<TagType>();
4885 assert(Tag && "Invalid sigjmp_buf type in AST file");
4886 Context.setsigjmp_bufDecl(Tag->getDecl());
4887 }
4888 }
4889 }
4890
4891 if (unsigned ObjCIdRedef
4892 = SpecialTypes[SPECIAL_TYPE_OBJC_ID_REDEFINITION]) {
4893 if (Context.ObjCIdRedefinitionType.isNull())
4894 Context.ObjCIdRedefinitionType = GetType(ObjCIdRedef);
4895 }
4896
4897 if (unsigned ObjCClassRedef
4898 = SpecialTypes[SPECIAL_TYPE_OBJC_CLASS_REDEFINITION]) {
4899 if (Context.ObjCClassRedefinitionType.isNull())
4900 Context.ObjCClassRedefinitionType = GetType(ObjCClassRedef);
4901 }
4902
4903 if (unsigned ObjCSelRedef
4904 = SpecialTypes[SPECIAL_TYPE_OBJC_SEL_REDEFINITION]) {
4905 if (Context.ObjCSelRedefinitionType.isNull())
4906 Context.ObjCSelRedefinitionType = GetType(ObjCSelRedef);
4907 }
4908
4909 if (unsigned Ucontext_t = SpecialTypes[SPECIAL_TYPE_UCONTEXT_T]) {
4910 QualType Ucontext_tType = GetType(Ucontext_t);
4911 if (Ucontext_tType.isNull()) {
4912 Error("ucontext_t type is NULL");
4913 return;
4914 }
4915
4916 if (!Context.ucontext_tDecl) {
4917 if (const TypedefType *Typedef = Ucontext_tType->getAs<TypedefType>())
4918 Context.setucontext_tDecl(Typedef->getDecl());
4919 else {
4920 const TagType *Tag = Ucontext_tType->getAs<TagType>();
4921 assert(Tag && "Invalid ucontext_t type in AST file");
4922 Context.setucontext_tDecl(Tag->getDecl());
4923 }
4924 }
4925 }
4926 }
4927
4928 ReadPragmaDiagnosticMappings(Context.getDiagnostics());
4929
4930 // If there were any CUDA special declarations, deserialize them.
4931 if (!CUDASpecialDeclRefs.empty()) {
4932 assert(CUDASpecialDeclRefs.size() == 1 && "More decl refs than expected!");
4933 Context.setcudaConfigureCallDecl(
4934 cast<FunctionDecl>(GetDecl(CUDASpecialDeclRefs[0])));
4935 }
4936
4937 // Re-export any modules that were imported by a non-module AST file.
4938 // FIXME: This does not make macro-only imports visible again.
4939 for (auto &Import : ImportedModules) {
4940 if (Module *Imported = getSubmodule(Import.ID)) {
4941 makeModuleVisible(Imported, Module::AllVisible,
4942 /*ImportLoc=*/Import.ImportLoc);
4943 if (Import.ImportLoc.isValid())
4944 PP.makeModuleVisible(Imported, Import.ImportLoc);
4945 // FIXME: should we tell Sema to make the module visible too?
4946 }
4947 }
4948 ImportedModules.clear();
4949 }
4950
4951 void ASTReader::finalizeForWriting() {
4952 // Nothing to do for now.
4953 }
4954
4955 /// Reads and return the signature record from \p PCH's control block, or
4956 /// else returns 0.
4957 static ASTFileSignature readASTFileSignature(StringRef PCH) {
4958 BitstreamCursor Stream(PCH);
4959 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
4960 // FIXME this drops the error on the floor.
4961 consumeError(std::move(Err));
4962 return ASTFileSignature();
4963 }
4964
4965 // Scan for the UNHASHED_CONTROL_BLOCK_ID block.
4966 if (SkipCursorToBlock(Stream, UNHASHED_CONTROL_BLOCK_ID))
4967 return ASTFileSignature();
4968
4969 // Scan for SIGNATURE inside the diagnostic options block.
4970 ASTReader::RecordData Record;
4971 while (true) {
4972 Expected<llvm::BitstreamEntry> MaybeEntry =
4973 Stream.advanceSkippingSubblocks();
4974 if (!MaybeEntry) {
4975 // FIXME this drops the error on the floor.
4976 consumeError(MaybeEntry.takeError());
4977 return ASTFileSignature();
4978 }
4979 llvm::BitstreamEntry Entry = MaybeEntry.get();
4980
4981 if (Entry.Kind != llvm::BitstreamEntry::Record)
4982 return ASTFileSignature();
4983
4984 Record.clear();
4985 StringRef Blob;
4986 Expected<unsigned> MaybeRecord = Stream.readRecord(Entry.ID, Record, &Blob);
4987 if (!MaybeRecord) {
4988 // FIXME this drops the error on the floor.
4989 consumeError(MaybeRecord.takeError());
4990 return ASTFileSignature();
4991 }
4992 if (SIGNATURE == MaybeRecord.get())
4993 return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
4994 (uint32_t)Record[3], (uint32_t)Record[4]}}};
4995 }
4996 }
4997
4998 /// Retrieve the name of the original source file name
4999 /// directly from the AST file, without actually loading the AST
5000 /// file.
5001 std::string ASTReader::getOriginalSourceFile(
5002 const std::string &ASTFileName, FileManager &FileMgr,
5003 const PCHContainerReader &PCHContainerRdr, DiagnosticsEngine &Diags) {
5004 // Open the AST file.
5005 auto Buffer = FileMgr.getBufferForFile(ASTFileName);
5006 if (!Buffer) {
5007 Diags.Report(diag::err_fe_unable_to_read_pch_file)
5008 << ASTFileName << Buffer.getError().message();
5009 return std::string();
5010 }
5011
5012 // Initialize the stream
5013 BitstreamCursor Stream(PCHContainerRdr.ExtractPCH(**Buffer));
5014
5015 // Sniff for the signature.
5016 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
5017 Diags.Report(diag::err_fe_not_a_pch_file) << ASTFileName << std::move(Err);
5018 return std::string();
5019 }
5020
5021 // Scan for the CONTROL_BLOCK_ID block.
5022 if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID)) {
5023 Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
5024 return std::string();
5025 }
5026
5027 // Scan for ORIGINAL_FILE inside the control block.
5028 RecordData Record;
5029 while (true) {
5030 Expected<llvm::BitstreamEntry> MaybeEntry =
5031 Stream.advanceSkippingSubblocks();
5032 if (!MaybeEntry) {
5033 // FIXME this drops errors on the floor.
5034 consumeError(MaybeEntry.takeError());
5035 return std::string();
5036 }
5037 llvm::BitstreamEntry Entry = MaybeEntry.get();
5038
5039 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
5040 return std::string();
5041
5042 if (Entry.Kind != llvm::BitstreamEntry::Record) {
5043 Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
5044 return std::string();
5045 }
5046
5047 Record.clear();
5048 StringRef Blob;
5049 Expected<unsigned> MaybeRecord = Stream.readRecord(Entry.ID, Record, &Blob);
5050 if (!MaybeRecord) {
5051 // FIXME this drops the errors on the floor.
5052 consumeError(MaybeRecord.takeError());
5053 return std::string();
5054 }
5055 if (ORIGINAL_FILE == MaybeRecord.get())
5056 return Blob.str();
5057 }
5058 }
5059
5060 namespace {
5061
5062 class SimplePCHValidator : public ASTReaderListener {
5063 const LangOptions &ExistingLangOpts;
5064 const TargetOptions &ExistingTargetOpts;
5065 const PreprocessorOptions &ExistingPPOpts;
5066 std::string ExistingModuleCachePath;
5067 FileManager &FileMgr;
5068
5069 public:
5070 SimplePCHValidator(const LangOptions &ExistingLangOpts,
5071 const TargetOptions &ExistingTargetOpts,
5072 const PreprocessorOptions &ExistingPPOpts,
5073 StringRef ExistingModuleCachePath,
5074 FileManager &FileMgr)
5075 : ExistingLangOpts(ExistingLangOpts),
5076 ExistingTargetOpts(ExistingTargetOpts),
5077 ExistingPPOpts(ExistingPPOpts),
5078 ExistingModuleCachePath(ExistingModuleCachePath),
5079 FileMgr(FileMgr) {}
5080
5081 bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
5082 bool AllowCompatibleDifferences) override {
5083 return checkLanguageOptions(ExistingLangOpts, LangOpts, nullptr,
5084 AllowCompatibleDifferences);
5085 }
5086
5087 bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
5088 bool AllowCompatibleDifferences) override {
5089 return checkTargetOptions(ExistingTargetOpts, TargetOpts, nullptr,
5090 AllowCompatibleDifferences);
5091 }
5092
5093 bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
5094 StringRef SpecificModuleCachePath,
5095 bool Complain) override {
5096 return checkHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
5097 ExistingModuleCachePath,
5098 nullptr, ExistingLangOpts);
5099 }
5100
5101 bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
5102 bool Complain,
5103 std::string &SuggestedPredefines) override {
5104 return checkPreprocessorOptions(ExistingPPOpts, PPOpts, nullptr, FileMgr,
5105 SuggestedPredefines, ExistingLangOpts);
5106 }
5107 };
5108
5109 } // namespace
5110
5111 bool ASTReader::readASTFileControlBlock(
5112 StringRef Filename, FileManager &FileMgr,
5113 const PCHContainerReader &PCHContainerRdr,
5114 bool FindModuleFileExtensions,
5115 ASTReaderListener &Listener, bool ValidateDiagnosticOptions) {
5116 // Open the AST file.
5117 // FIXME: This allows use of the VFS; we do not allow use of the
5118 // VFS when actually loading a module.
5119 auto Buffer = FileMgr.getBufferForFile(Filename);
5120 if (!Buffer) {
5121 return true;
5122 }
5123
5124 // Initialize the stream
5125 StringRef Bytes = PCHContainerRdr.ExtractPCH(**Buffer);
5126 BitstreamCursor Stream(Bytes);
5127
5128 // Sniff for the signature.
5129 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
5130 consumeError(std::move(Err)); // FIXME this drops errors on the floor.
5131 return true;
5132 }
5133
5134 // Scan for the CONTROL_BLOCK_ID block.
5135 if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID))
5136 return true;
5137
5138 bool NeedsInputFiles = Listener.needsInputFileVisitation();
5139 bool NeedsSystemInputFiles = Listener.needsSystemInputFileVisitation();
5140 bool NeedsImports = Listener.needsImportVisitation();
5141 BitstreamCursor InputFilesCursor;
5142
5143 RecordData Record;
5144 std::string ModuleDir;
5145 bool DoneWithControlBlock = false;
5146 while (!DoneWithControlBlock) {
5147 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5148 if (!MaybeEntry) {
5149 // FIXME this drops the error on the floor.
5150 consumeError(MaybeEntry.takeError());
5151 return true;
5152 }
5153 llvm::BitstreamEntry Entry = MaybeEntry.get();
5154
5155 switch (Entry.Kind) {
5156 case llvm::BitstreamEntry::SubBlock: {
5157 switch (Entry.ID) {
5158 case OPTIONS_BLOCK_ID: {
5159 std::string IgnoredSuggestedPredefines;
5160 if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
5161 /*AllowCompatibleConfigurationMismatch*/ false,
5162 Listener, IgnoredSuggestedPredefines) != Success)
5163 return true;
5164 break;
5165 }
5166
5167 case INPUT_FILES_BLOCK_ID:
5168 InputFilesCursor = Stream;
5169 if (llvm::Error Err = Stream.SkipBlock()) {
5170 // FIXME this drops the error on the floor.
5171 consumeError(std::move(Err));
5172 return true;
5173 }
5174 if (NeedsInputFiles &&
5175 ReadBlockAbbrevs(InputFilesCursor, INPUT_FILES_BLOCK_ID))
5176 return true;
5177 break;
5178
5179 default:
5180 if (llvm::Error Err = Stream.SkipBlock()) {
5181 // FIXME this drops the error on the floor.
5182 consumeError(std::move(Err));
5183 return true;
5184 }
5185 break;
5186 }
5187
5188 continue;
5189 }
5190
5191 case llvm::BitstreamEntry::EndBlock:
5192 DoneWithControlBlock = true;
5193 break;
5194
5195 case llvm::BitstreamEntry::Error:
5196 return true;
5197
5198 case llvm::BitstreamEntry::Record:
5199 break;
5200 }
5201
5202 if (DoneWithControlBlock) break;
5203
5204 Record.clear();
5205 StringRef Blob;
5206 Expected<unsigned> MaybeRecCode =
5207 Stream.readRecord(Entry.ID, Record, &Blob);
5208 if (!MaybeRecCode) {
5209 // FIXME this drops the error.
5210 return Failure;
5211 }
5212 switch ((ControlRecordTypes)MaybeRecCode.get()) {
5213 case METADATA:
5214 if (Record[0] != VERSION_MAJOR)
5215 return true;
5216 if (Listener.ReadFullVersionInformation(Blob))
5217 return true;
5218 break;
5219 case MODULE_NAME:
5220 Listener.ReadModuleName(Blob);
5221 break;
5222 case MODULE_DIRECTORY:
5223 ModuleDir = Blob;
5224 break;
5225 case MODULE_MAP_FILE: {
5226 unsigned Idx = 0;
5227 auto Path = ReadString(Record, Idx);
5228 ResolveImportedPath(Path, ModuleDir);
5229 Listener.ReadModuleMapFile(Path);
5230 break;
5231 }
5232 case INPUT_FILE_OFFSETS: {
5233 if (!NeedsInputFiles)
5234 break;
5235
5236 unsigned NumInputFiles = Record[0];
5237 unsigned NumUserFiles = Record[1];
5238 const llvm::support::unaligned_uint64_t *InputFileOffs =
5239 (const llvm::support::unaligned_uint64_t *)Blob.data();
5240 for (unsigned I = 0; I != NumInputFiles; ++I) {
5241 // Go find this input file.
5242 bool isSystemFile = I >= NumUserFiles;
5243
5244 if (isSystemFile && !NeedsSystemInputFiles)
5245 break; // the rest are system input files
5246
5247 BitstreamCursor &Cursor = InputFilesCursor;
5248 SavedStreamPosition SavedPosition(Cursor);
5249 if (llvm::Error Err = Cursor.JumpToBit(InputFileOffs[I])) {
5250 // FIXME this drops errors on the floor.
5251 consumeError(std::move(Err));
5252 }
5253
5254 Expected<unsigned> MaybeCode = Cursor.ReadCode();
5255 if (!MaybeCode) {
5256 // FIXME this drops errors on the floor.
5257 consumeError(MaybeCode.takeError());
5258 }
5259 unsigned Code = MaybeCode.get();
5260
5261 RecordData Record;
5262 StringRef Blob;
5263 bool shouldContinue = false;
5264 Expected<unsigned> MaybeRecordType =
5265 Cursor.readRecord(Code, Record, &Blob);
5266 if (!MaybeRecordType) {
5267 // FIXME this drops errors on the floor.
5268 consumeError(MaybeRecordType.takeError());
5269 }
5270 switch ((InputFileRecordTypes)MaybeRecordType.get()) {
5271 case INPUT_FILE_HASH:
5272 break;
5273 case INPUT_FILE:
5274 bool Overridden = static_cast<bool>(Record[3]);
5275 std::string Filename = Blob;
5276 ResolveImportedPath(Filename, ModuleDir);
5277 shouldContinue = Listener.visitInputFile(
5278 Filename, isSystemFile, Overridden, /*IsExplicitModule*/false);
5279 break;
5280 }
5281 if (!shouldContinue)
5282 break;
5283 }
5284 break;
5285 }
5286
5287 case IMPORTS: {
5288 if (!NeedsImports)
5289 break;
5290
5291 unsigned Idx = 0, N = Record.size();
5292 while (Idx < N) {
5293 // Read information about the AST file.
5294 Idx += 1+1+1+1+5; // Kind, ImportLoc, Size, ModTime, Signature
5295 std::string ModuleName = ReadString(Record, Idx);
5296 std::string Filename = ReadString(Record, Idx);
5297 ResolveImportedPath(Filename, ModuleDir);
5298 Listener.visitImport(ModuleName, Filename);
5299 }
5300 break;
5301 }
5302
5303 default:
5304 // No other validation to perform.
5305 break;
5306 }
5307 }
5308
5309 // Look for module file extension blocks, if requested.
5310 if (FindModuleFileExtensions) {
5311 BitstreamCursor SavedStream = Stream;
5312 while (!SkipCursorToBlock(Stream, EXTENSION_BLOCK_ID)) {
5313 bool DoneWithExtensionBlock = false;
5314 while (!DoneWithExtensionBlock) {
5315 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5316 if (!MaybeEntry) {
5317 // FIXME this drops the error.
5318 return true;
5319 }
5320 llvm::BitstreamEntry Entry = MaybeEntry.get();
5321
5322 switch (Entry.Kind) {
5323 case llvm::BitstreamEntry::SubBlock:
5324 if (llvm::Error Err = Stream.SkipBlock()) {
5325 // FIXME this drops the error on the floor.
5326 consumeError(std::move(Err));
5327 return true;
5328 }
5329 continue;
5330
5331 case llvm::BitstreamEntry::EndBlock:
5332 DoneWithExtensionBlock = true;
5333 continue;
5334
5335 case llvm::BitstreamEntry::Error:
5336 return true;
5337
5338 case llvm::BitstreamEntry::Record:
5339 break;
5340 }
5341
5342 Record.clear();
5343 StringRef Blob;
5344 Expected<unsigned> MaybeRecCode =
5345 Stream.readRecord(Entry.ID, Record, &Blob);
5346 if (!MaybeRecCode) {
5347 // FIXME this drops the error.
5348 return true;
5349 }
5350 switch (MaybeRecCode.get()) {
5351 case EXTENSION_METADATA: {
5352 ModuleFileExtensionMetadata Metadata;
5353 if (parseModuleFileExtensionMetadata(Record, Blob, Metadata))
5354 return true;
5355
5356 Listener.readModuleFileExtension(Metadata);
5357 break;
5358 }
5359 }
5360 }
5361 }
5362 Stream = SavedStream;
5363 }
5364
5365 // Scan for the UNHASHED_CONTROL_BLOCK_ID block.
5366 if (readUnhashedControlBlockImpl(
5367 nullptr, Bytes, ARR_ConfigurationMismatch | ARR_OutOfDate,
5368 /*AllowCompatibleConfigurationMismatch*/ false, &Listener,
5369 ValidateDiagnosticOptions) != Success)
5370 return true;
5371
5372 return false;
5373 }
5374
5375 bool ASTReader::isAcceptableASTFile(StringRef Filename, FileManager &FileMgr,
5376 const PCHContainerReader &PCHContainerRdr,
5377 const LangOptions &LangOpts,
5378 const TargetOptions &TargetOpts,
5379 const PreprocessorOptions &PPOpts,
5380 StringRef ExistingModuleCachePath) {
5381 SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
5382 ExistingModuleCachePath, FileMgr);
5383 return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
5384 /*FindModuleFileExtensions=*/false,
5385 validator,
5386 /*ValidateDiagnosticOptions=*/true);
5387 }
5388
5389 ASTReader::ASTReadResult
5390 ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
5391 // Enter the submodule block.
5392 if (llvm::Error Err = F.Stream.EnterSubBlock(SUBMODULE_BLOCK_ID)) {
5393 Error(std::move(Err));
5394 return Failure;
5395 }
5396
5397 ModuleMap &ModMap = PP.getHeaderSearchInfo().getModuleMap();
5398 bool First = true;
5399 Module *CurrentModule = nullptr;
5400 RecordData Record;
5401 while (true) {
5402 Expected<llvm::BitstreamEntry> MaybeEntry =
5403 F.Stream.advanceSkippingSubblocks();
5404 if (!MaybeEntry) {
5405 Error(MaybeEntry.takeError());
5406 return Failure;
5407 }
5408 llvm::BitstreamEntry Entry = MaybeEntry.get();
5409
5410 switch (Entry.Kind) {
5411 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
5412 case llvm::BitstreamEntry::Error:
5413 Error("malformed block record in AST file");
5414 return Failure;
5415 case llvm::BitstreamEntry::EndBlock:
5416 return Success;
5417 case llvm::BitstreamEntry::Record:
5418 // The interesting case.
5419 break;
5420 }
5421
5422 // Read a record.
5423 StringRef Blob;
5424 Record.clear();
5425 Expected<unsigned> MaybeKind = F.Stream.readRecord(Entry.ID, Record, &Blob);
5426 if (!MaybeKind) {
5427 Error(MaybeKind.takeError());
5428 return Failure;
5429 }
5430 unsigned Kind = MaybeKind.get();
5431
5432 if ((Kind == SUBMODULE_METADATA) != First) {
5433 Error("submodule metadata record should be at beginning of block");
5434 return Failure;
5435 }
5436 First = false;
5437
5438 // Submodule information is only valid if we have a current module.
5439 // FIXME: Should we error on these cases?
5440 if (!CurrentModule && Kind != SUBMODULE_METADATA &&
5441 Kind != SUBMODULE_DEFINITION)
5442 continue;
5443
5444 switch (Kind) {
5445 default: // Default behavior: ignore.
5446 break;
5447
5448 case SUBMODULE_DEFINITION: {
5449 if (Record.size() < 12) {
5450 Error("malformed module definition");
5451 return Failure;
5452 }
5453
5454 StringRef Name = Blob;
5455 unsigned Idx = 0;
5456 SubmoduleID GlobalID = getGlobalSubmoduleID(F, Record[Idx++]);
5457 SubmoduleID Parent = getGlobalSubmoduleID(F, Record[Idx++]);
5458 Module::ModuleKind Kind = (Module::ModuleKind)Record[Idx++];
5459 bool IsFramework = Record[Idx++];
5460 bool IsExplicit = Record[Idx++];
5461 bool IsSystem = Record[Idx++];
5462 bool IsExternC = Record[Idx++];
5463 bool InferSubmodules = Record[Idx++];
5464 bool InferExplicitSubmodules = Record[Idx++];
5465 bool InferExportWildcard = Record[Idx++];
5466 bool ConfigMacrosExhaustive = Record[Idx++];
5467 bool ModuleMapIsPrivate = Record[Idx++];
5468
5469 Module *ParentModule = nullptr;
5470 if (Parent)
5471 ParentModule = getSubmodule(Parent);
5472
5473 // Retrieve this (sub)module from the module map, creating it if
5474 // necessary.
5475 CurrentModule =
5476 ModMap.findOrCreateModule(Name, ParentModule, IsFramework, IsExplicit)
5477 .first;
5478
5479 // FIXME: set the definition loc for CurrentModule, or call
5480 // ModMap.setInferredModuleAllowedBy()
5481
5482 SubmoduleID GlobalIndex = GlobalID - NUM_PREDEF_SUBMODULE_IDS;
5483 if (GlobalIndex >= SubmodulesLoaded.size() ||
5484 SubmodulesLoaded[GlobalIndex]) {
5485 Error("too many submodules");
5486 return Failure;
5487 }
5488
5489 if (!ParentModule) {
5490 if (const FileEntry *CurFile = CurrentModule->getASTFile()) {
5491 // Don't emit module relocation error if we have -fno-validate-pch
5492 if (!PP.getPreprocessorOpts().DisablePCHValidation &&
5493 CurFile != F.File) {
5494 Error(diag::err_module_file_conflict,
5495 CurrentModule->getTopLevelModuleName(), CurFile->getName(),
5496 F.File->getName());
5497 return Failure;
5498 }
5499 }
5500
5501 F.DidReadTopLevelSubmodule = true;
5502 CurrentModule->setASTFile(F.File);
5503 CurrentModule->PresumedModuleMapFile = F.ModuleMapPath;
5504 }
5505
5506 CurrentModule->Kind = Kind;
5507 CurrentModule->Signature = F.Signature;
5508 CurrentModule->IsFromModuleFile = true;
5509 CurrentModule->IsSystem = IsSystem || CurrentModule->IsSystem;
5510 CurrentModule->IsExternC = IsExternC;
5511 CurrentModule->InferSubmodules = InferSubmodules;
5512 CurrentModule->InferExplicitSubmodules = InferExplicitSubmodules;
5513 CurrentModule->InferExportWildcard = InferExportWildcard;
5514 CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
5515 CurrentModule->ModuleMapIsPrivate = ModuleMapIsPrivate;
5516 if (DeserializationListener)
5517 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
5518
5519 SubmodulesLoaded[GlobalIndex] = CurrentModule;
5520
5521 // Clear out data that will be replaced by what is in the module file.
5522 CurrentModule->LinkLibraries.clear();
5523 CurrentModule->ConfigMacros.clear();
5524 CurrentModule->UnresolvedConflicts.clear();
5525 CurrentModule->Conflicts.clear();
5526
5527 // The module is available unless it's missing a requirement; relevant
5528 // requirements will be (re-)added by SUBMODULE_REQUIRES records.
5529 // Missing headers that were present when the module was built do not
5530 // make it unavailable -- if we got this far, this must be an explicitly
5531 // imported module file.
5532 CurrentModule->Requirements.clear();
5533 CurrentModule->MissingHeaders.clear();
5534 CurrentModule->IsMissingRequirement =
5535 ParentModule && ParentModule->IsMissingRequirement;
5536 CurrentModule->IsAvailable = !CurrentModule->IsMissingRequirement;
5537 break;
5538 }
5539
5540 case SUBMODULE_UMBRELLA_HEADER: {
5541 std::string Filename = Blob;
5542 ResolveImportedPath(F, Filename);
5543 if (auto Umbrella = PP.getFileManager().getFile(Filename)) {
5544 if (!CurrentModule->getUmbrellaHeader())
5545 ModMap.setUmbrellaHeader(CurrentModule, *Umbrella, Blob);
5546 else if (CurrentModule->getUmbrellaHeader().Entry != *Umbrella) {
5547 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5548 Error("mismatched umbrella headers in submodule");
5549 return OutOfDate;
5550 }
5551 }
5552 break;
5553 }
5554
5555 case SUBMODULE_HEADER:
5556 case SUBMODULE_EXCLUDED_HEADER:
5557 case SUBMODULE_PRIVATE_HEADER:
5558 // We lazily associate headers with their modules via the HeaderInfo table.
5559 // FIXME: Re-evaluate this section; maybe only store InputFile IDs instead
5560 // of complete filenames or remove it entirely.
5561 break;
5562
5563 case SUBMODULE_TEXTUAL_HEADER:
5564 case SUBMODULE_PRIVATE_TEXTUAL_HEADER:
5565 // FIXME: Textual headers are not marked in the HeaderInfo table. Load
5566 // them here.
5567 break;
5568
5569 case SUBMODULE_TOPHEADER:
5570 CurrentModule->addTopHeaderFilename(Blob);
5571 break;
5572
5573 case SUBMODULE_UMBRELLA_DIR: {
5574 std::string Dirname = Blob;
5575 ResolveImportedPath(F, Dirname);
5576 if (auto Umbrella = PP.getFileManager().getDirectory(Dirname)) {
5577 if (!CurrentModule->getUmbrellaDir())
5578 ModMap.setUmbrellaDir(CurrentModule, *Umbrella, Blob);
5579 else if (CurrentModule->getUmbrellaDir().Entry != *Umbrella) {
5580 if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
5581 Error("mismatched umbrella directories in submodule");
5582 return OutOfDate;
5583 }
5584 }
5585 break;
5586 }
5587
5588 case SUBMODULE_METADATA: {
5589 F.BaseSubmoduleID = getTotalNumSubmodules();
5590 F.LocalNumSubmodules = Record[0];
5591 unsigned LocalBaseSubmoduleID = Record[1];
5592 if (F.LocalNumSubmodules > 0) {
5593 // Introduce the global -> local mapping for submodules within this
5594 // module.
5595 GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
5596
5597 // Introduce the local -> global mapping for submodules within this
5598 // module.
5599 F.SubmoduleRemap.insertOrReplace(
5600 std::make_pair(LocalBaseSubmoduleID,
5601 F.BaseSubmoduleID - LocalBaseSubmoduleID));
5602
5603 SubmodulesLoaded.resize(SubmodulesLoaded.size() + F.LocalNumSubmodules);
5604 }
5605 break;
5606 }
5607
5608 case SUBMODULE_IMPORTS:
5609 for (unsigned Idx = 0; Idx != Record.size(); ++Idx) {
5610 UnresolvedModuleRef Unresolved;
5611 Unresolved.File = &F;
5612 Unresolved.Mod = CurrentModule;
5613 Unresolved.ID = Record[Idx];
5614 Unresolved.Kind = UnresolvedModuleRef::Import;
5615 Unresolved.IsWildcard = false;
5616 UnresolvedModuleRefs.push_back(Unresolved);
5617 }
5618 break;
5619
5620 case SUBMODULE_EXPORTS:
5621 for (unsigned Idx = 0; Idx + 1 < Record.size(); Idx += 2) {
5622 UnresolvedModuleRef Unresolved;
5623 Unresolved.File = &F;
5624 Unresolved.Mod = CurrentModule;
5625 Unresolved.ID = Record[Idx];
5626 Unresolved.Kind = UnresolvedModuleRef::Export;
5627 Unresolved.IsWildcard = Record[Idx + 1];
5628 UnresolvedModuleRefs.push_back(Unresolved);
5629 }
5630
5631 // Once we've loaded the set of exports, there's no reason to keep
5632 // the parsed, unresolved exports around.
5633 CurrentModule->UnresolvedExports.clear();
5634 break;
5635
5636 case SUBMODULE_REQUIRES:
5637 CurrentModule->addRequirement(Blob, Record[0], PP.getLangOpts(),
5638 PP.getTargetInfo());
5639 break;
5640
5641 case SUBMODULE_LINK_LIBRARY:
5642 ModMap.resolveLinkAsDependencies(CurrentModule);
5643 CurrentModule->LinkLibraries.push_back(
5644 Module::LinkLibrary(Blob, Record[0]));
5645 break;
5646
5647 case SUBMODULE_CONFIG_MACRO:
5648 CurrentModule->ConfigMacros.push_back(Blob.str());
5649 break;
5650
5651 case SUBMODULE_CONFLICT: {
5652 UnresolvedModuleRef Unresolved;
5653 Unresolved.File = &F;
5654 Unresolved.Mod = CurrentModule;
5655 Unresolved.ID = Record[0];
5656 Unresolved.Kind = UnresolvedModuleRef::Conflict;
5657 Unresolved.IsWildcard = false;
5658 Unresolved.String = Blob;
5659 UnresolvedModuleRefs.push_back(Unresolved);
5660 break;
5661 }
5662
5663 case SUBMODULE_INITIALIZERS: {
5664 if (!ContextObj)
5665 break;
5666 SmallVector<uint32_t, 16> Inits;
5667 for (auto &ID : Record)
5668 Inits.push_back(getGlobalDeclID(F, ID));
5669 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
5670 break;
5671 }
5672
5673 case SUBMODULE_EXPORT_AS:
5674 CurrentModule->ExportAsModule = Blob.str();
5675 ModMap.addLinkAsDependency(CurrentModule);
5676 break;
5677 }
5678 }
5679 }
5680
5681 /// Parse the record that corresponds to a LangOptions data
5682 /// structure.
5683 ///
5684 /// This routine parses the language options from the AST file and then gives
5685 /// them to the AST listener if one is set.
5686 ///
5687 /// \returns true if the listener deems the file unacceptable, false otherwise.
5688 bool ASTReader::ParseLanguageOptions(const RecordData &Record,
5689 bool Complain,
5690 ASTReaderListener &Listener,
5691 bool AllowCompatibleDifferences) {
5692 LangOptions LangOpts;
5693 unsigned Idx = 0;
5694 #define LANGOPT(Name, Bits, Default, Description) \
5695 LangOpts.Name = Record[Idx++];
5696 #define ENUM_LANGOPT(Name, Type, Bits, Default, Description) \
5697 LangOpts.set##Name(static_cast<LangOptions::Type>(Record[Idx++]));
5698 #include "clang/Basic/LangOptions.def"
5699 #define SANITIZER(NAME, ID) \
5700 LangOpts.Sanitize.set(SanitizerKind::ID, Record[Idx++]);
5701 #include "clang/Basic/Sanitizers.def"
5702
5703 for (unsigned N = Record[Idx++]; N; --N)
5704 LangOpts.ModuleFeatures.push_back(ReadString(Record, Idx));
5705
5706 ObjCRuntime::Kind runtimeKind = (ObjCRuntime::Kind) Record[Idx++];
5707 VersionTuple runtimeVersion = ReadVersionTuple(Record, Idx);
5708 LangOpts.ObjCRuntime = ObjCRuntime(runtimeKind, runtimeVersion);
5709
5710 LangOpts.CurrentModule = ReadString(Record, Idx);
5711
5712 // Comment options.
5713 for (unsigned N = Record[Idx++]; N; --N) {
5714 LangOpts.CommentOpts.BlockCommandNames.push_back(
5715 ReadString(Record, Idx));
5716 }
5717 LangOpts.CommentOpts.ParseAllComments = Record[Idx++];
5718
5719 // OpenMP offloading options.
5720 for (unsigned N = Record[Idx++]; N; --N) {
5721 LangOpts.OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
5722 }
5723
5724 LangOpts.OMPHostIRFile = ReadString(Record, Idx);
5725
5726 return Listener.ReadLanguageOptions(LangOpts, Complain,
5727 AllowCompatibleDifferences);
5728 }
5729
5730 bool ASTReader::ParseTargetOptions(const RecordData &Record, bool Complain,
5731 ASTReaderListener &Listener,
5732 bool AllowCompatibleDifferences) {
5733 unsigned Idx = 0;
5734 TargetOptions TargetOpts;
5735 TargetOpts.Triple = ReadString(Record, Idx);
5736 TargetOpts.CPU = ReadString(Record, Idx);
5737 TargetOpts.ABI = ReadString(Record, Idx);
5738 for (unsigned N = Record[Idx++]; N; --N) {
5739 TargetOpts.FeaturesAsWritten.push_back(ReadString(Record, Idx));
5740 }
5741 for (unsigned N = Record[Idx++]; N; --N) {
5742 TargetOpts.Features.push_back(ReadString(Record, Idx));
5743 }
5744
5745 return Listener.ReadTargetOptions(TargetOpts, Complain,
5746 AllowCompatibleDifferences);
5747 }
5748
5749 bool ASTReader::ParseDiagnosticOptions(const RecordData &Record, bool Complain,
5750 ASTReaderListener &Listener) {
5751 IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts(new DiagnosticOptions);
5752 unsigned Idx = 0;
5753 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
5754 #define ENUM_DIAGOPT(Name, Type, Bits, Default) \
5755 DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
5756 #include "clang/Basic/DiagnosticOptions.def"
5757
5758 for (unsigned N = Record[Idx++]; N; --N)
5759 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
5760 for (unsigned N = Record[Idx++]; N; --N)
5761 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
5762
5763 return Listener.ReadDiagnosticOptions(DiagOpts, Complain);
5764 }
5765
5766 bool ASTReader::ParseFileSystemOptions(const RecordData &Record, bool Complain,
5767 ASTReaderListener &Listener) {
5768 FileSystemOptions FSOpts;
5769 unsigned Idx = 0;
5770 FSOpts.WorkingDir = ReadString(Record, Idx);
5771 return Listener.ReadFileSystemOptions(FSOpts, Complain);
5772 }
5773
5774 bool ASTReader::ParseHeaderSearchOptions(const RecordData &Record,
5775 bool Complain,
5776 ASTReaderListener &Listener) {
5777 HeaderSearchOptions HSOpts;
5778 unsigned Idx = 0;
5779 HSOpts.Sysroot = ReadString(Record, Idx);
5780
5781 // Include entries.
5782 for (unsigned N = Record[Idx++]; N; --N) {
5783 std::string Path = ReadString(Record, Idx);
5784 frontend::IncludeDirGroup Group
5785 = static_cast<frontend::IncludeDirGroup>(Record[Idx++]);
5786 bool IsFramework = Record[Idx++];
5787 bool IgnoreSysRoot = Record[Idx++];
5788 HSOpts.UserEntries.emplace_back(std::move(Path), Group, IsFramework,
5789 IgnoreSysRoot);
5790 }
5791
5792 // System header prefixes.
5793 for (unsigned N = Record[Idx++]; N; --N) {
5794 std::string Prefix = ReadString(Record, Idx);
5795 bool IsSystemHeader = Record[Idx++];
5796 HSOpts.SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
5797 }
5798
5799 HSOpts.ResourceDir = ReadString(Record, Idx);
5800 HSOpts.ModuleCachePath = ReadString(Record, Idx);
5801 HSOpts.ModuleUserBuildPath = ReadString(Record, Idx);
5802 HSOpts.DisableModuleHash = Record[Idx++];
5803 HSOpts.ImplicitModuleMaps = Record[Idx++];
5804 HSOpts.ModuleMapFileHomeIsCwd = Record[Idx++];
5805 HSOpts.UseBuiltinIncludes = Record[Idx++];
5806 HSOpts.UseStandardSystemIncludes = Record[Idx++];
5807 HSOpts.UseStandardCXXIncludes = Record[Idx++];
5808 HSOpts.UseLibcxx = Record[Idx++];
5809 std::string SpecificModuleCachePath = ReadString(Record, Idx);
5810
5811 return Listener.ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
5812 Complain);
5813 }
5814
5815 bool ASTReader::ParsePreprocessorOptions(const RecordData &Record,
5816 bool Complain,
5817 ASTReaderListener &Listener,
5818 std::string &SuggestedPredefines) {
5819 PreprocessorOptions PPOpts;
5820 unsigned Idx = 0;
5821
5822 // Macro definitions/undefs
5823 for (unsigned N = Record[Idx++]; N; --N) {
5824 std::string Macro = ReadString(Record, Idx);
5825 bool IsUndef = Record[Idx++];
5826 PPOpts.Macros.push_back(std::make_pair(Macro, IsUndef));
5827 }
5828
5829 // Includes
5830 for (unsigned N = Record[Idx++]; N; --N) {
5831 PPOpts.Includes.push_back(ReadString(Record, Idx));
5832 }
5833
5834 // Macro Includes
5835 for (unsigned N = Record[Idx++]; N; --N) {
5836 PPOpts.MacroIncludes.push_back(ReadString(Record, Idx));
5837 }
5838
5839 PPOpts.UsePredefines = Record[Idx++];
5840 PPOpts.DetailedRecord = Record[Idx++];
5841 PPOpts.ImplicitPCHInclude = ReadString(Record, Idx);
5842 PPOpts.ObjCXXARCStandardLibrary =
5843 static_cast<ObjCXXARCStandardLibraryKind>(Record[Idx++]);
5844 SuggestedPredefines.clear();
5845 return Listener.ReadPreprocessorOptions(PPOpts, Complain,
5846 SuggestedPredefines);
5847 }
5848
5849 std::pair<ModuleFile *, unsigned>
5850 ASTReader::getModulePreprocessedEntity(unsigned GlobalIndex) {
5851 GlobalPreprocessedEntityMapType::iterator
5852 I = GlobalPreprocessedEntityMap.find(GlobalIndex);
5853 assert(I != GlobalPreprocessedEntityMap.end() &&
5854 "Corrupted global preprocessed entity map");
5855 ModuleFile *M = I->second;
5856 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID;
5857 return std::make_pair(M, LocalIndex);
5858 }
5859
5860 llvm::iterator_range<PreprocessingRecord::iterator>
5861 ASTReader::getModulePreprocessedEntities(ModuleFile &Mod) const {
5862 if (PreprocessingRecord *PPRec = PP.getPreprocessingRecord())
5863 return PPRec->getIteratorsForLoadedRange(Mod.BasePreprocessedEntityID,
5864 Mod.NumPreprocessedEntities);
5865
5866 return llvm::make_range(PreprocessingRecord::iterator(),
5867 PreprocessingRecord::iterator());
5868 }
5869
5870 llvm::iterator_range<ASTReader::ModuleDeclIterator>
5871 ASTReader::getModuleFileLevelDecls(ModuleFile &Mod) {
5872 return llvm::make_range(
5873 ModuleDeclIterator(this, &Mod, Mod.FileSortedDecls),
5874 ModuleDeclIterator(this, &Mod,
5875 Mod.FileSortedDecls + Mod.NumFileSortedDecls));
5876 }
5877
5878 SourceRange ASTReader::ReadSkippedRange(unsigned GlobalIndex) {
5879 auto I = GlobalSkippedRangeMap.find(GlobalIndex);
5880 assert(I != GlobalSkippedRangeMap.end() &&
5881 "Corrupted global skipped range map");
5882 ModuleFile *M = I->second;
5883 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedSkippedRangeID;
5884 assert(LocalIndex < M->NumPreprocessedSkippedRanges);
5885 PPSkippedRange RawRange = M->PreprocessedSkippedRangeOffsets[LocalIndex];
5886 SourceRange Range(TranslateSourceLocation(*M, RawRange.getBegin()),
5887 TranslateSourceLocation(*M, RawRange.getEnd()));
5888 assert(Range.isValid());
5889 return Range;
5890 }
5891
5892 PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
5893 PreprocessedEntityID PPID = Index+1;
5894 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
5895 ModuleFile &M = *PPInfo.first;
5896 unsigned LocalIndex = PPInfo.second;
5897 const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
5898
5899 if (!PP.getPreprocessingRecord()) {
5900 Error("no preprocessing record");
5901 return nullptr;
5902 }
5903
5904 SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor);
5905 if (llvm::Error Err =
5906 M.PreprocessorDetailCursor.JumpToBit(PPOffs.BitOffset)) {
5907 Error(std::move(Err));
5908 return nullptr;
5909 }
5910
5911 Expected<llvm::BitstreamEntry> MaybeEntry =
5912 M.PreprocessorDetailCursor.advance(BitstreamCursor::AF_DontPopBlockAtEnd);
5913 if (!MaybeEntry) {
5914 Error(MaybeEntry.takeError());
5915 return nullptr;
5916 }
5917 llvm::BitstreamEntry Entry = MaybeEntry.get();
5918
5919 if (Entry.Kind != llvm::BitstreamEntry::Record)
5920 return nullptr;
5921
5922 // Read the record.
5923 SourceRange Range(TranslateSourceLocation(M, PPOffs.getBegin()),
5924 TranslateSourceLocation(M, PPOffs.getEnd()));
5925 PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
5926 StringRef Blob;
5927 RecordData Record;
5928 Expected<unsigned> MaybeRecType =
5929 M.PreprocessorDetailCursor.readRecord(Entry.ID, Record, &Blob);
5930 if (!MaybeRecType) {
5931 Error(MaybeRecType.takeError());
5932 return nullptr;
5933 }
5934 switch ((PreprocessorDetailRecordTypes)MaybeRecType.get()) {
5935 case PPD_MACRO_EXPANSION: {
5936 bool isBuiltin = Record[0];
5937 IdentifierInfo *Name = nullptr;
5938 MacroDefinitionRecord *Def = nullptr;
5939 if (isBuiltin)
5940 Name = getLocalIdentifier(M, Record[1]);
5941 else {
5942 PreprocessedEntityID GlobalID =
5943 getGlobalPreprocessedEntityID(M, Record[1]);
5944 Def = cast<MacroDefinitionRecord>(
5945 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
5946 }
5947
5948 MacroExpansion *ME;
5949 if (isBuiltin)
5950 ME = new (PPRec) MacroExpansion(Name, Range);
5951 else
5952 ME = new (PPRec) MacroExpansion(Def, Range);
5953
5954 return ME;
5955 }
5956
5957 case PPD_MACRO_DEFINITION: {
5958 // Decode the identifier info and then check again; if the macro is
5959 // still defined and associated with the identifier,
5960 IdentifierInfo *II = getLocalIdentifier(M, Record[0]);
5961 MacroDefinitionRecord *MD = new (PPRec) MacroDefinitionRecord(II, Range);
5962
5963 if (DeserializationListener)
5964 DeserializationListener->MacroDefinitionRead(PPID, MD);
5965
5966 return MD;
5967 }
5968
5969 case PPD_INCLUSION_DIRECTIVE: {
5970 const char *FullFileNameStart = Blob.data() + Record[0];
5971 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
5972 const FileEntry *File = nullptr;
5973 if (!FullFileName.empty())
5974 if (auto FE = PP.getFileManager().getFile(FullFileName))
5975 File = *FE;
5976
5977 // FIXME: Stable encoding
5978 InclusionDirective::InclusionKind Kind
5979 = static_cast<InclusionDirective::InclusionKind>(Record[2]);
5980 InclusionDirective *ID
5981 = new (PPRec) InclusionDirective(PPRec, Kind,
5982 StringRef(Blob.data(), Record[0]),
5983 Record[1], Record[3],
5984 File,
5985 Range);
5986 return ID;
5987 }
5988 }
5989
5990 llvm_unreachable("Invalid PreprocessorDetailRecordTypes");
5991 }
5992
5993 /// Find the next module that contains entities and return the ID
5994 /// of the first entry.
5995 ///
5996 /// \param SLocMapI points at a chunk of a module that contains no
5997 /// preprocessed entities or the entities it contains are not the ones we are
5998 /// looking for.
5999 PreprocessedEntityID ASTReader::findNextPreprocessedEntity(
6000 GlobalSLocOffsetMapType::const_iterator SLocMapI) const {
6001 ++SLocMapI;
6002 for (GlobalSLocOffsetMapType::const_iterator
6003 EndI = GlobalSLocOffsetMap.end(); SLocMapI != EndI; ++SLocMapI) {
6004 ModuleFile &M = *SLocMapI->second;
6005 if (M.NumPreprocessedEntities)
6006 return M.BasePreprocessedEntityID;
6007 }
6008
6009 return getTotalNumPreprocessedEntities();
6010 }
6011
6012 namespace {
6013
6014 struct PPEntityComp {
6015 const ASTReader &Reader;
6016 ModuleFile &M;
6017
6018 PPEntityComp(const ASTReader &Reader, ModuleFile &M) : Reader(Reader), M(M) {}
6019
6020 bool operator()(const PPEntityOffset &L, const PPEntityOffset &R) const {
6021 SourceLocation LHS = getLoc(L);
6022 SourceLocation RHS = getLoc(R);
6023 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
6024 }
6025
6026 bool operator()(const PPEntityOffset &L, SourceLocation RHS) const {
6027 SourceLocation LHS = getLoc(L);
6028 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
6029 }
6030
6031 bool operator()(SourceLocation LHS, const PPEntityOffset &R) const {
6032 SourceLocation RHS = getLoc(R);
6033 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
6034 }
6035
6036 SourceLocation getLoc(const PPEntityOffset &PPE) const {
6037 return Reader.TranslateSourceLocation(M, PPE.getBegin());
6038 }
6039 };
6040
6041 } // namespace
6042
6043 PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
6044 bool EndsAfter) const {
6045 if (SourceMgr.isLocalSourceLocation(Loc))
6046 return getTotalNumPreprocessedEntities();
6047
6048 GlobalSLocOffsetMapType::const_iterator SLocMapI = GlobalSLocOffsetMap.find(
6049 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
6050 assert(SLocMapI != GlobalSLocOffsetMap.end() &&
6051 "Corrupted global sloc offset map");
6052
6053 if (SLocMapI->second->NumPreprocessedEntities == 0)
6054 return findNextPreprocessedEntity(SLocMapI);
6055
6056 ModuleFile &M = *SLocMapI->second;
6057
6058 using pp_iterator = const PPEntityOffset *;
6059
6060 pp_iterator pp_begin = M.PreprocessedEntityOffsets;
6061 pp_iterator pp_end = pp_begin + M.NumPreprocessedEntities;
6062
6063 size_t Count = M.NumPreprocessedEntities;
6064 size_t Half;
6065 pp_iterator First = pp_begin;
6066 pp_iterator PPI;
6067
6068 if (EndsAfter) {
6069 PPI = std::upper_bound(pp_begin, pp_end, Loc,
6070 PPEntityComp(*this, M));
6071 } else {
6072 // Do a binary search manually instead of using std::lower_bound because
6073 // The end locations of entities may be unordered (when a macro expansion
6074 // is inside another macro argument), but for this case it is not important
6075 // whether we get the first macro expansion or its containing macro.
6076 while (Count > 0) {
6077 Half = Count / 2;
6078 PPI = First;
6079 std::advance(PPI, Half);
6080 if (SourceMgr.isBeforeInTranslationUnit(
6081 TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
6082 First = PPI;
6083 ++First;
6084 Count = Count - Half - 1;
6085 } else
6086 Count = Half;
6087 }
6088 }
6089
6090 if (PPI == pp_end)
6091 return findNextPreprocessedEntity(SLocMapI);
6092
6093 return M.BasePreprocessedEntityID + (PPI - pp_begin);
6094 }
6095
6096 /// Returns a pair of [Begin, End) indices of preallocated
6097 /// preprocessed entities that \arg Range encompasses.
6098 std::pair<unsigned, unsigned>
6099 ASTReader::findPreprocessedEntitiesInRange(SourceRange Range) {
6100 if (Range.isInvalid())
6101 return std::make_pair(0,0);
6102 assert(!SourceMgr.isBeforeInTranslationUnit(Range.getEnd(),Range.getBegin()));
6103
6104 PreprocessedEntityID BeginID =
6105 findPreprocessedEntity(Range.getBegin(), false);
6106 PreprocessedEntityID EndID = findPreprocessedEntity(Range.getEnd(), true);
6107 return std::make_pair(BeginID, EndID);
6108 }
6109
6110 /// Optionally returns true or false if the preallocated preprocessed
6111 /// entity with index \arg Index came from file \arg FID.
6112 Optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index,
6113 FileID FID) {
6114 if (FID.isInvalid())
6115 return false;
6116
6117 std::pair<ModuleFile *, unsigned> PPInfo = getModulePreprocessedEntity(Index);
6118 ModuleFile &M = *PPInfo.first;
6119 unsigned LocalIndex = PPInfo.second;
6120 const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
6121
6122 SourceLocation Loc = TranslateSourceLocation(M, PPOffs.getBegin());
6123 if (Loc.isInvalid())
6124 return false;
6125
6126 if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
6127 return true;
6128 else
6129 return false;
6130 }
6131
6132 namespace {
6133
6134 /// Visitor used to search for information about a header file.
6135 class HeaderFileInfoVisitor {
6136 const FileEntry *FE;
6137 Optional<HeaderFileInfo> HFI;
6138
6139 public:
6140 explicit HeaderFileInfoVisitor(const FileEntry *FE) : FE(FE) {}
6141
6142 bool operator()(ModuleFile &M) {
6143 HeaderFileInfoLookupTable *Table
6144 = static_cast<HeaderFileInfoLookupTable *>(M.HeaderFileInfoTable);
6145 if (!Table)
6146 return false;
6147
6148 // Look in the on-disk hash table for an entry for this file name.
6149 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
6150 if (Pos == Table->end())
6151 return false;
6152
6153 HFI = *Pos;
6154 return true;
6155 }
6156
6157 Optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
6158 };
6159
6160 } // namespace
6161
6162 HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
6163 HeaderFileInfoVisitor Visitor(FE);
6164 ModuleMgr.visit(Visitor);
6165 if (Optional<HeaderFileInfo> HFI = Visitor.getHeaderFileInfo())
6166 return *HFI;
6167
6168 return HeaderFileInfo();
6169 }
6170
6171 void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
6172 using DiagState = DiagnosticsEngine::DiagState;
6173 SmallVector<DiagState *, 32> DiagStates;
6174
6175 for (ModuleFile &F : ModuleMgr) {
6176 unsigned Idx = 0;
6177 auto &Record = F.PragmaDiagMappings;
6178 if (Record.empty())
6179 continue;
6180
6181 DiagStates.clear();
6182
6183 auto ReadDiagState =
6184 [&](const DiagState &BasedOn, SourceLocation Loc,
6185 bool IncludeNonPragmaStates) -> DiagnosticsEngine::DiagState * {
6186 unsigned BackrefID = Record[Idx++];
6187 if (BackrefID != 0)
6188 return DiagStates[BackrefID - 1];
6189
6190 // A new DiagState was created here.
6191 Diag.DiagStates.push_back(BasedOn);
6192 DiagState *NewState = &Diag.DiagStates.back();
6193 DiagStates.push_back(NewState);
6194 unsigned Size = Record[Idx++];
6195 assert(Idx + Size * 2 <= Record.size() &&
6196 "Invalid data, not enough diag/map pairs");
6197 while (Size--) {
6198 unsigned DiagID = Record[Idx++];
6199 DiagnosticMapping NewMapping =
6200 DiagnosticMapping::deserialize(Record[Idx++]);
6201 if (!NewMapping.isPragma() && !IncludeNonPragmaStates)
6202 continue;
6203
6204 DiagnosticMapping &Mapping = NewState->getOrAddMapping(DiagID);
6205
6206 // If this mapping was specified as a warning but the severity was
6207 // upgraded due to diagnostic settings, simulate the current diagnostic
6208 // settings (and use a warning).
6209 if (NewMapping.wasUpgradedFromWarning() && !Mapping.isErrorOrFatal()) {
6210 NewMapping.setSeverity(diag::Severity::Warning);
6211 NewMapping.setUpgradedFromWarning(false);
6212 }
6213
6214 Mapping = NewMapping;
6215 }
6216 return NewState;
6217 };
6218
6219 // Read the first state.
6220 DiagState *FirstState;
6221 if (F.Kind == MK_ImplicitModule) {
6222 // Implicitly-built modules are reused with different diagnostic
6223 // settings. Use the initial diagnostic state from Diag to simulate this
6224 // compilation's diagnostic settings.
6225 FirstState = Diag.DiagStatesByLoc.FirstDiagState;
6226 DiagStates.push_back(FirstState);
6227
6228 // Skip the initial diagnostic state from the serialized module.
6229 assert(Record[1] == 0 &&
6230 "Invalid data, unexpected backref in initial state");
6231 Idx = 3 + Record[2] * 2;
6232 assert(Idx < Record.size() &&
6233 "Invalid data, not enough state change pairs in initial state");
6234 } else if (F.isModule()) {
6235 // For an explicit module, preserve the flags from the module build
6236 // command line (-w, -Weverything, -Werror, ...) along with any explicit
6237 // -Wblah flags.
6238 unsigned Flags = Record[Idx++];
6239 DiagState Initial;
6240 Initial.SuppressSystemWarnings = Flags & 1; Flags >>= 1;
6241 Initial.ErrorsAsFatal = Flags & 1; Flags >>= 1;
6242 Initial.WarningsAsErrors = Flags & 1; Flags >>= 1;
6243 Initial.EnableAllWarnings = Flags & 1; Flags >>= 1;
6244 Initial.IgnoreAllWarnings = Flags & 1; Flags >>= 1;
6245 Initial.ExtBehavior = (diag::Severity)Flags;
6246 FirstState = ReadDiagState(Initial, SourceLocation(), true);
6247
6248 assert(F.OriginalSourceFileID.isValid());
6249
6250 // Set up the root buffer of the module to start with the initial
6251 // diagnostic state of the module itself, to cover files that contain no
6252 // explicit transitions (for which we did not serialize anything).
6253 Diag.DiagStatesByLoc.Files[F.OriginalSourceFileID]
6254 .StateTransitions.push_back({FirstState, 0});
6255 } else {
6256 // For prefix ASTs, start with whatever the user configured on the
6257 // command line.
6258 Idx++; // Skip flags.
6259 FirstState = ReadDiagState(*Diag.DiagStatesByLoc.CurDiagState,
6260 SourceLocation(), false);
6261 }
6262
6263 // Read the state transitions.
6264 unsigned NumLocations = Record[Idx++];
6265 while (NumLocations--) {
6266 assert(Idx < Record.size() &&
6267 "Invalid data, missing pragma diagnostic states");
6268 SourceLocation Loc = ReadSourceLocation(F, Record[Idx++]);
6269 auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
6270 assert(IDAndOffset.first.isValid() && "invalid FileID for transition");
6271 assert(IDAndOffset.second == 0 && "not a start location for a FileID");
6272 unsigned Transitions = Record[Idx++];
6273
6274 // Note that we don't need to set up Parent/ParentOffset here, because
6275 // we won't be changing the diagnostic state within imported FileIDs
6276 // (other than perhaps appending to the main source file, which has no
6277 // parent).
6278 auto &F = Diag.DiagStatesByLoc.Files[IDAndOffset.first];
6279 F.StateTransitions.reserve(F.StateTransitions.size() + Transitions);
6280 for (unsigned I = 0; I != Transitions; ++I) {
6281 unsigned Offset = Record[Idx++];
6282 auto *State =
6283 ReadDiagState(*FirstState, Loc.getLocWithOffset(Offset), false);
6284 F.StateTransitions.push_back({State, Offset});
6285 }
6286 }
6287
6288 // Read the final state.
6289 assert(Idx < Record.size() &&
6290 "Invalid data, missing final pragma diagnostic state");
6291 SourceLocation CurStateLoc =
6292 ReadSourceLocation(F, F.PragmaDiagMappings[Idx++]);
6293 auto *CurState = ReadDiagState(*FirstState, CurStateLoc, false);
6294
6295 if (!F.isModule()) {
6296 Diag.DiagStatesByLoc.CurDiagState = CurState;
6297 Diag.DiagStatesByLoc.CurDiagStateLoc = CurStateLoc;
6298
6299 // Preserve the property that the imaginary root file describes the
6300 // current state.
6301 FileID NullFile;
6302 auto &T = Diag.DiagStatesByLoc.Files[NullFile].StateTransitions;
6303 if (T.empty())
6304 T.push_back({CurState, 0});
6305 else
6306 T[0].State = CurState;
6307 }
6308
6309 // Don't try to read these mappings again.
6310 Record.clear();
6311 }
6312 }
6313
6314 /// Get the correct cursor and offset for loading a type.
6315 ASTReader::RecordLocation ASTReader::TypeCursorForIndex(unsigned Index) {
6316 GlobalTypeMapType::iterator I = GlobalTypeMap.find(Index);
6317 assert(I != GlobalTypeMap.end() && "Corrupted global type map");
6318 ModuleFile *M = I->second;
6319 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex]);
6320 }
6321
6322 static llvm::Optional<Type::TypeClass> getTypeClassForCode(TypeCode code) {
6323 switch (code) {
6324 #define TYPE_BIT_CODE(CLASS_ID, CODE_ID, CODE_VALUE) \
6325 case TYPE_##CODE_ID: return Type::CLASS_ID;
6326 #include "clang/Serialization/TypeBitCodes.def"
6327 default: return llvm::None;
6328 }
6329 }
6330
6331 /// Read and return the type with the given index..
6332 ///
6333 /// The index is the type ID, shifted and minus the number of predefs. This
6334 /// routine actually reads the record corresponding to the type at the given
6335 /// location. It is a helper routine for GetType, which deals with reading type
6336 /// IDs.
6337 QualType ASTReader::readTypeRecord(unsigned Index) {
6338 assert(ContextObj && "reading type with no AST context");
6339 ASTContext &Context = *ContextObj;
6340 RecordLocation Loc = TypeCursorForIndex(Index);
6341 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
6342
6343 // Keep track of where we are in the stream, then jump back there
6344 // after reading this type.
6345 SavedStreamPosition SavedPosition(DeclsCursor);
6346
6347 ReadingKindTracker ReadingKind(Read_Type, *this);
6348
6349 // Note that we are loading a type record.
6350 Deserializing AType(this);
6351
6352 if (llvm::Error Err = DeclsCursor.JumpToBit(Loc.Offset)) {
6353 Error(std::move(Err));
6354 return QualType();
6355 }
6356 Expected<unsigned> RawCode = DeclsCursor.ReadCode();
6357 if (!RawCode) {
6358 Error(RawCode.takeError());
6359 return QualType();
6360 }
6361
6362 ASTRecordReader Record(*this, *Loc.F);
6363 Expected<unsigned> Code = Record.readRecord(DeclsCursor, RawCode.get());
6364 if (!Code) {
6365 Error(Code.takeError());
6366 return QualType();
6367 }
6368 if (Code.get() == TYPE_EXT_QUAL) {
6369 QualType baseType = Record.readQualType();
6370 Qualifiers quals = Record.readQualifiers();
6371 return Context.getQualifiedType(baseType, quals);
6372 }
6373
6374 auto maybeClass = getTypeClassForCode((TypeCode) Code.get());
6375 if (!maybeClass) {
6376 Error("Unexpected code for type");
6377 return QualType();
6378 }
6379
6380 serialization::AbstractTypeReader<ASTRecordReader> TypeReader(Record);
6381 return TypeReader.read(*maybeClass);
6382 }
6383
6384 namespace clang {
6385
6386 class TypeLocReader : public TypeLocVisitor<TypeLocReader> {
6387 ASTRecordReader &Reader;
6388
6389 SourceLocation readSourceLocation() {
6390 return Reader.readSourceLocation();
6391 }
6392
6393 TypeSourceInfo *GetTypeSourceInfo() {
6394 return Reader.readTypeSourceInfo();
6395 }
6396
6397 NestedNameSpecifierLoc ReadNestedNameSpecifierLoc() {
6398 return Reader.readNestedNameSpecifierLoc();
6399 }
6400
6401 Attr *ReadAttr() {
6402 return Reader.readAttr();
6403 }
6404
6405 public:
6406 TypeLocReader(ASTRecordReader &Reader) : Reader(Reader) {}
6407
6408 // We want compile-time assurance that we've enumerated all of
6409 // these, so unfortunately we have to declare them first, then
6410 // define them out-of-line.
6411 #define ABSTRACT_TYPELOC(CLASS, PARENT)
6412 #define TYPELOC(CLASS, PARENT) \
6413 void Visit##CLASS##TypeLoc(CLASS##TypeLoc TyLoc);
6414 #include "clang/AST/TypeLocNodes.def"
6415
6416 void VisitFunctionTypeLoc(FunctionTypeLoc);
6417 void VisitArrayTypeLoc(ArrayTypeLoc);
6418 };
6419
6420 } // namespace clang
6421
6422 void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
6423 // nothing to do
6424 }
6425
6426 void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
6427 TL.setBuiltinLoc(readSourceLocation());
6428 if (TL.needsExtraLocalData()) {
6429 TL.setWrittenTypeSpec(static_cast<DeclSpec::TST>(Reader.readInt()));
6430 TL.setWrittenSignSpec(static_cast<DeclSpec::TSS>(Reader.readInt()));
6431 TL.setWrittenWidthSpec(static_cast<DeclSpec::TSW>(Reader.readInt()));
6432 TL.setModeAttr(Reader.readInt());
6433 }
6434 }
6435
6436 void TypeLocReader::VisitComplexTypeLoc(ComplexTypeLoc TL) {
6437 TL.setNameLoc(readSourceLocation());
6438 }
6439
6440 void TypeLocReader::VisitPointerTypeLoc(PointerTypeLoc TL) {
6441 TL.setStarLoc(readSourceLocation());
6442 }
6443
6444 void TypeLocReader::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
6445 // nothing to do
6446 }
6447
6448 void TypeLocReader::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
6449 // nothing to do
6450 }
6451
6452 void TypeLocReader::VisitMacroQualifiedTypeLoc(MacroQualifiedTypeLoc TL) {
6453 TL.setExpansionLoc(readSourceLocation());
6454 }
6455
6456 void TypeLocReader::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
6457 TL.setCaretLoc(readSourceLocation());
6458 }
6459
6460 void TypeLocReader::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
6461 TL.setAmpLoc(readSourceLocation());
6462 }
6463
6464 void TypeLocReader::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
6465 TL.setAmpAmpLoc(readSourceLocation());
6466 }
6467
6468 void TypeLocReader::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
6469 TL.setStarLoc(readSourceLocation());
6470 TL.setClassTInfo(GetTypeSourceInfo());
6471 }
6472
6473 void TypeLocReader::VisitArrayTypeLoc(ArrayTypeLoc TL) {
6474 TL.setLBracketLoc(readSourceLocation());
6475 TL.setRBracketLoc(readSourceLocation());
6476 if (Reader.readBool())
6477 TL.setSizeExpr(Reader.readExpr());
6478 else
6479 TL.setSizeExpr(nullptr);
6480 }
6481
6482 void TypeLocReader::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
6483 VisitArrayTypeLoc(TL);
6484 }
6485
6486 void TypeLocReader::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
6487 VisitArrayTypeLoc(TL);
6488 }
6489
6490 void TypeLocReader::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
6491 VisitArrayTypeLoc(TL);
6492 }
6493
6494 void TypeLocReader::VisitDependentSizedArrayTypeLoc(
6495 DependentSizedArrayTypeLoc TL) {
6496 VisitArrayTypeLoc(TL);
6497 }
6498
6499 void TypeLocReader::VisitDependentAddressSpaceTypeLoc(
6500 DependentAddressSpaceTypeLoc TL) {
6501
6502 TL.setAttrNameLoc(readSourceLocation());
6503 TL.setAttrOperandParensRange(Reader.readSourceRange());
6504 TL.setAttrExprOperand(Reader.readExpr());
6505 }
6506
6507 void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
6508 DependentSizedExtVectorTypeLoc TL) {
6509 TL.setNameLoc(readSourceLocation());
6510 }
6511
6512 void TypeLocReader::VisitVectorTypeLoc(VectorTypeLoc TL) {
6513 TL.setNameLoc(readSourceLocation());
6514 }
6515
6516 void TypeLocReader::VisitDependentVectorTypeLoc(
6517 DependentVectorTypeLoc TL) {
6518 TL.setNameLoc(readSourceLocation());
6519 }
6520
6521 void TypeLocReader::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
6522 TL.setNameLoc(readSourceLocation());
6523 }
6524
6525 void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
6526 TL.setLocalRangeBegin(readSourceLocation());
6527 TL.setLParenLoc(readSourceLocation());
6528 TL.setRParenLoc(readSourceLocation());
6529 TL.setExceptionSpecRange(Reader.readSourceRange());
6530 TL.setLocalRangeEnd(readSourceLocation());
6531 for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
6532 TL.setParam(i, Reader.readDeclAs<ParmVarDecl>());
6533 }
6534 }
6535
6536 void TypeLocReader::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
6537 VisitFunctionTypeLoc(TL);
6538 }
6539
6540 void TypeLocReader::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
6541 VisitFunctionTypeLoc(TL);
6542 }
6543
6544 void TypeLocReader::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
6545 TL.setNameLoc(readSourceLocation());
6546 }
6547
6548 void TypeLocReader::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
6549 TL.setNameLoc(readSourceLocation());
6550 }
6551
6552 void TypeLocReader::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
6553 TL.setTypeofLoc(readSourceLocation());
6554 TL.setLParenLoc(readSourceLocation());
6555 TL.setRParenLoc(readSourceLocation());
6556 }
6557
6558 void TypeLocReader::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
6559 TL.setTypeofLoc(readSourceLocation());
6560 TL.setLParenLoc(readSourceLocation());
6561 TL.setRParenLoc(readSourceLocation());
6562 TL.setUnderlyingTInfo(GetTypeSourceInfo());
6563 }
6564
6565 void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
6566 TL.setNameLoc(readSourceLocation());
6567 }
6568
6569 void TypeLocReader::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
6570 TL.setKWLoc(readSourceLocation());
6571 TL.setLParenLoc(readSourceLocation());
6572 TL.setRParenLoc(readSourceLocation());
6573 TL.setUnderlyingTInfo(GetTypeSourceInfo());
6574 }
6575
6576 void TypeLocReader::VisitAutoTypeLoc(AutoTypeLoc TL) {
6577 TL.setNameLoc(readSourceLocation());
6578 if (Reader.readBool()) {
6579 TL.setNestedNameSpecifierLoc(ReadNestedNameSpecifierLoc());
6580 TL.setTemplateKWLoc(readSourceLocation());
6581 TL.setConceptNameLoc(readSourceLocation());
6582 TL.setFoundDecl(Reader.readDeclAs<NamedDecl>());
6583 TL.setLAngleLoc(readSourceLocation());
6584 TL.setRAngleLoc(readSourceLocation());
6585 for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
6586 TL.setArgLocInfo(i, Reader.readTemplateArgumentLocInfo(
6587 TL.getTypePtr()->getArg(i).getKind()));
6588 }
6589 }
6590
6591 void TypeLocReader::VisitDeducedTemplateSpecializationTypeLoc(
6592 DeducedTemplateSpecializationTypeLoc TL) {
6593 TL.setTemplateNameLoc(readSourceLocation());
6594 }
6595
6596 void TypeLocReader::VisitRecordTypeLoc(RecordTypeLoc TL) {
6597 TL.setNameLoc(readSourceLocation());
6598 }
6599
6600 void TypeLocReader::VisitEnumTypeLoc(EnumTypeLoc TL) {
6601 TL.setNameLoc(readSourceLocation());
6602 }
6603
6604 void TypeLocReader::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
6605 TL.setAttr(ReadAttr());
6606 }
6607
6608 void TypeLocReader::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
6609 TL.setNameLoc(readSourceLocation());
6610 }
6611
6612 void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
6613 SubstTemplateTypeParmTypeLoc TL) {
6614 TL.setNameLoc(readSourceLocation());
6615 }
6616
6617 void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
6618 SubstTemplateTypeParmPackTypeLoc TL) {
6619 TL.setNameLoc(readSourceLocation());
6620 }
6621
6622 void TypeLocReader::VisitTemplateSpecializationTypeLoc(
6623 TemplateSpecializationTypeLoc TL) {
6624 TL.setTemplateKeywordLoc(readSourceLocation());
6625 TL.setTemplateNameLoc(readSourceLocation());
6626 TL.setLAngleLoc(readSourceLocation());
6627 TL.setRAngleLoc(readSourceLocation());
6628 for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
6629 TL.setArgLocInfo(
6630 i,
6631 Reader.readTemplateArgumentLocInfo(
6632 TL.getTypePtr()->getArg(i).getKind()));
6633 }
6634
6635 void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) {
6636 TL.setLParenLoc(readSourceLocation());
6637 TL.setRParenLoc(readSourceLocation());
6638 }
6639
6640 void TypeLocReader::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
6641 TL.setElaboratedKeywordLoc(readSourceLocation());
6642 TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
6643 }
6644
6645 void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
6646 TL.setNameLoc(readSourceLocation());
6647 }
6648
6649 void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
6650 TL.setElaboratedKeywordLoc(readSourceLocation());
6651 TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
6652 TL.setNameLoc(readSourceLocation());
6653 }
6654
6655 void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
6656 DependentTemplateSpecializationTypeLoc TL) {
6657 TL.setElaboratedKeywordLoc(readSourceLocation());
6658 TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
6659 TL.setTemplateKeywordLoc(readSourceLocation());
6660 TL.setTemplateNameLoc(readSourceLocation());
6661 TL.setLAngleLoc(readSourceLocation());
6662 TL.setRAngleLoc(readSourceLocation());
6663 for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
6664 TL.setArgLocInfo(
6665 I,
6666 Reader.readTemplateArgumentLocInfo(
6667 TL.getTypePtr()->getArg(I).getKind()));
6668 }
6669
6670 void TypeLocReader::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
6671 TL.setEllipsisLoc(readSourceLocation());
6672 }
6673
6674 void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
6675 TL.setNameLoc(readSourceLocation());
6676 }
6677
6678 void TypeLocReader::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
6679 if (TL.getNumProtocols()) {
6680 TL.setProtocolLAngleLoc(readSourceLocation());
6681 TL.setProtocolRAngleLoc(readSourceLocation());
6682 }
6683 for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
6684 TL.setProtocolLoc(i, readSourceLocation());
6685 }
6686
6687 void TypeLocReader::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
6688 TL.setHasBaseTypeAsWritten(Reader.readBool());
6689 TL.setTypeArgsLAngleLoc(readSourceLocation());
6690 TL.setTypeArgsRAngleLoc(readSourceLocation());
6691 for (unsigned i = 0, e = TL.getNumTypeArgs(); i != e; ++i)
6692 TL.setTypeArgTInfo(i, GetTypeSourceInfo());
6693 TL.setProtocolLAngleLoc(readSourceLocation());
6694 TL.setProtocolRAngleLoc(readSourceLocation());
6695 for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
6696 TL.setProtocolLoc(i, readSourceLocation());
6697 }
6698
6699 void TypeLocReader::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
6700 TL.setStarLoc(readSourceLocation());
6701 }
6702
6703 void TypeLocReader::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6704 TL.setKWLoc(readSourceLocation());
6705 TL.setLParenLoc(readSourceLocation());
6706 TL.setRParenLoc(readSourceLocation());
6707 }
6708
6709 void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) {
6710 TL.setKWLoc(readSourceLocation());
6711 }
6712
6713 void ASTRecordReader::readTypeLoc(TypeLoc TL) {
6714 TypeLocReader TLR(*this);
6715 for (; !TL.isNull(); TL = TL.getNextTypeLoc())
6716 TLR.Visit(TL);
6717 }
6718
6719 TypeSourceInfo *ASTRecordReader::readTypeSourceInfo() {
6720 QualType InfoTy = readType();
6721 if (InfoTy.isNull())
6722 return nullptr;
6723
6724 TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
6725 readTypeLoc(TInfo->getTypeLoc());
6726 return TInfo;
6727 }
6728
6729 QualType ASTReader::GetType(TypeID ID) {
6730 assert(ContextObj && "reading type with no AST context");
6731 ASTContext &Context = *ContextObj;
6732
6733 unsigned FastQuals = ID & Qualifiers::FastMask;
6734 unsigned Index = ID >> Qualifiers::FastWidth;
6735
6736 if (Index < NUM_PREDEF_TYPE_IDS) {
6737 QualType T;
6738 switch ((PredefinedTypeIDs)Index) {
6739 case PREDEF_TYPE_NULL_ID:
6740 return QualType();
6741 case PREDEF_TYPE_VOID_ID:
6742 T = Context.VoidTy;
6743 break;
6744 case PREDEF_TYPE_BOOL_ID:
6745 T = Context.BoolTy;
6746 break;
6747 case PREDEF_TYPE_CHAR_U_ID:
6748 case PREDEF_TYPE_CHAR_S_ID:
6749 // FIXME: Check that the signedness of CharTy is correct!
6750 T = Context.CharTy;
6751 break;
6752 case PREDEF_TYPE_UCHAR_ID:
6753 T = Context.UnsignedCharTy;
6754 break;
6755 case PREDEF_TYPE_USHORT_ID:
6756 T = Context.UnsignedShortTy;
6757 break;
6758 case PREDEF_TYPE_UINT_ID:
6759 T = Context.UnsignedIntTy;
6760 break;
6761 case PREDEF_TYPE_ULONG_ID:
6762 T = Context.UnsignedLongTy;
6763 break;
6764 case PREDEF_TYPE_ULONGLONG_ID:
6765 T = Context.UnsignedLongLongTy;
6766 break;
6767 case PREDEF_TYPE_UINT128_ID:
6768 T = Context.UnsignedInt128Ty;
6769 break;
6770 case PREDEF_TYPE_SCHAR_ID:
6771 T = Context.SignedCharTy;
6772 break;
6773 case PREDEF_TYPE_WCHAR_ID:
6774 T = Context.WCharTy;
6775 break;
6776 case PREDEF_TYPE_SHORT_ID:
6777 T = Context.ShortTy;
6778 break;
6779 case PREDEF_TYPE_INT_ID:
6780 T = Context.IntTy;
6781 break;
6782 case PREDEF_TYPE_LONG_ID:
6783 T = Context.LongTy;
6784 break;
6785 case PREDEF_TYPE_LONGLONG_ID:
6786 T = Context.LongLongTy;
6787 break;
6788 case PREDEF_TYPE_INT128_ID:
6789 T = Context.Int128Ty;
6790 break;
6791 case PREDEF_TYPE_HALF_ID:
6792 T = Context.HalfTy;
6793 break;
6794 case PREDEF_TYPE_FLOAT_ID:
6795 T = Context.FloatTy;
6796 break;
6797 case PREDEF_TYPE_DOUBLE_ID:
6798 T = Context.DoubleTy;
6799 break;
6800 case PREDEF_TYPE_LONGDOUBLE_ID:
6801 T = Context.LongDoubleTy;
6802 break;
6803 case PREDEF_TYPE_SHORT_ACCUM_ID:
6804 T = Context.ShortAccumTy;
6805 break;
6806 case PREDEF_TYPE_ACCUM_ID:
6807 T = Context.AccumTy;
6808 break;
6809 case PREDEF_TYPE_LONG_ACCUM_ID:
6810 T = Context.LongAccumTy;
6811 break;
6812 case PREDEF_TYPE_USHORT_ACCUM_ID:
6813 T = Context.UnsignedShortAccumTy;
6814 break;
6815 case PREDEF_TYPE_UACCUM_ID:
6816 T = Context.UnsignedAccumTy;
6817 break;
6818 case PREDEF_TYPE_ULONG_ACCUM_ID:
6819 T = Context.UnsignedLongAccumTy;
6820 break;
6821 case PREDEF_TYPE_SHORT_FRACT_ID:
6822 T = Context.ShortFractTy;
6823 break;
6824 case PREDEF_TYPE_FRACT_ID:
6825 T = Context.FractTy;
6826 break;
6827 case PREDEF_TYPE_LONG_FRACT_ID:
6828 T = Context.LongFractTy;
6829 break;
6830 case PREDEF_TYPE_USHORT_FRACT_ID:
6831 T = Context.UnsignedShortFractTy;
6832 break;
6833 case PREDEF_TYPE_UFRACT_ID:
6834 T = Context.UnsignedFractTy;
6835 break;
6836 case PREDEF_TYPE_ULONG_FRACT_ID:
6837 T = Context.UnsignedLongFractTy;
6838 break;
6839 case PREDEF_TYPE_SAT_SHORT_ACCUM_ID:
6840 T = Context.SatShortAccumTy;
6841 break;
6842 case PREDEF_TYPE_SAT_ACCUM_ID:
6843 T = Context.SatAccumTy;
6844 break;
6845 case PREDEF_TYPE_SAT_LONG_ACCUM_ID:
6846 T = Context.SatLongAccumTy;
6847 break;
6848 case PREDEF_TYPE_SAT_USHORT_ACCUM_ID:
6849 T = Context.SatUnsignedShortAccumTy;
6850 break;
6851 case PREDEF_TYPE_SAT_UACCUM_ID:
6852 T = Context.SatUnsignedAccumTy;
6853 break;
6854 case PREDEF_TYPE_SAT_ULONG_ACCUM_ID:
6855 T = Context.SatUnsignedLongAccumTy;
6856 break;
6857 case PREDEF_TYPE_SAT_SHORT_FRACT_ID:
6858 T = Context.SatShortFractTy;
6859 break;
6860 case PREDEF_TYPE_SAT_FRACT_ID:
6861 T = Context.SatFractTy;
6862 break;
6863 case PREDEF_TYPE_SAT_LONG_FRACT_ID:
6864 T = Context.SatLongFractTy;
6865 break;
6866 case PREDEF_TYPE_SAT_USHORT_FRACT_ID:
6867 T = Context.SatUnsignedShortFractTy;
6868 break;
6869 case PREDEF_TYPE_SAT_UFRACT_ID:
6870 T = Context.SatUnsignedFractTy;
6871 break;
6872 case PREDEF_TYPE_SAT_ULONG_FRACT_ID:
6873 T = Context.SatUnsignedLongFractTy;
6874 break;
6875 case PREDEF_TYPE_FLOAT16_ID:
6876 T = Context.Float16Ty;
6877 break;
6878 case PREDEF_TYPE_FLOAT128_ID:
6879 T = Context.Float128Ty;
6880 break;
6881 case PREDEF_TYPE_OVERLOAD_ID:
6882 T = Context.OverloadTy;
6883 break;
6884 case PREDEF_TYPE_BOUND_MEMBER:
6885 T = Context.BoundMemberTy;
6886 break;
6887 case PREDEF_TYPE_PSEUDO_OBJECT:
6888 T = Context.PseudoObjectTy;
6889 break;
6890 case PREDEF_TYPE_DEPENDENT_ID:
6891 T = Context.DependentTy;
6892 break;
6893 case PREDEF_TYPE_UNKNOWN_ANY:
6894 T = Context.UnknownAnyTy;
6895 break;
6896 case PREDEF_TYPE_NULLPTR_ID:
6897 T = Context.NullPtrTy;
6898 break;
6899 case PREDEF_TYPE_CHAR8_ID:
6900 T = Context.Char8Ty;
6901 break;
6902 case PREDEF_TYPE_CHAR16_ID:
6903 T = Context.Char16Ty;
6904 break;
6905 case PREDEF_TYPE_CHAR32_ID:
6906 T = Context.Char32Ty;
6907 break;
6908 case PREDEF_TYPE_OBJC_ID:
6909 T = Context.ObjCBuiltinIdTy;
6910 break;
6911 case PREDEF_TYPE_OBJC_CLASS:
6912 T = Context.ObjCBuiltinClassTy;
6913 break;
6914 case PREDEF_TYPE_OBJC_SEL:
6915 T = Context.ObjCBuiltinSelTy;
6916 break;
6917 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
6918 case PREDEF_TYPE_##Id##_ID: \
6919 T = Context.SingletonId; \
6920 break;
6921 #include "clang/Basic/OpenCLImageTypes.def"
6922 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
6923 case PREDEF_TYPE_##Id##_ID: \
6924 T = Context.Id##Ty; \
6925 break;
6926 #include "clang/Basic/OpenCLExtensionTypes.def"
6927 case PREDEF_TYPE_SAMPLER_ID:
6928 T = Context.OCLSamplerTy;
6929 break;
6930 case PREDEF_TYPE_EVENT_ID:
6931 T = Context.OCLEventTy;
6932 break;
6933 case PREDEF_TYPE_CLK_EVENT_ID:
6934 T = Context.OCLClkEventTy;
6935 break;
6936 case PREDEF_TYPE_QUEUE_ID:
6937 T = Context.OCLQueueTy;
6938 break;
6939 case PREDEF_TYPE_RESERVE_ID_ID:
6940 T = Context.OCLReserveIDTy;
6941 break;
6942 case PREDEF_TYPE_AUTO_DEDUCT:
6943 T = Context.getAutoDeductType();
6944 break;
6945 case PREDEF_TYPE_AUTO_RREF_DEDUCT:
6946 T = Context.getAutoRRefDeductType();
6947 break;
6948 case PREDEF_TYPE_ARC_UNBRIDGED_CAST:
6949 T = Context.ARCUnbridgedCastTy;
6950 break;
6951 case PREDEF_TYPE_BUILTIN_FN:
6952 T = Context.BuiltinFnTy;
6953 break;
6954 case PREDEF_TYPE_OMP_ARRAY_SECTION:
6955 T = Context.OMPArraySectionTy;
6956 break;
6957 #define SVE_TYPE(Name, Id, SingletonId) \
6958 case PREDEF_TYPE_##Id##_ID: \
6959 T = Context.SingletonId; \
6960 break;
6961 #include "clang/Basic/AArch64SVEACLETypes.def"
6962 }
6963
6964 assert(!T.isNull() && "Unknown predefined type");
6965 return T.withFastQualifiers(FastQuals);
6966 }
6967
6968 Index -= NUM_PREDEF_TYPE_IDS;
6969 assert(Index < TypesLoaded.size() && "Type index out-of-range");
6970 if (TypesLoaded[Index].isNull()) {
6971 TypesLoaded[Index] = readTypeRecord(Index);
6972 if (TypesLoaded[Index].isNull())
6973 return QualType();
6974
6975 TypesLoaded[Index]->setFromAST();
6976 if (DeserializationListener)
6977 DeserializationListener->TypeRead(TypeIdx::fromTypeID(ID),
6978 TypesLoaded[Index]);
6979 }
6980
6981 return TypesLoaded[Index].withFastQualifiers(FastQuals);
6982 }
6983
6984 QualType ASTReader::getLocalType(ModuleFile &F, unsigned LocalID) {
6985 return GetType(getGlobalTypeID(F, LocalID));
6986 }
6987
6988 serialization::TypeID
6989 ASTReader::getGlobalTypeID(ModuleFile &F, unsigned LocalID) const {
6990 unsigned FastQuals = LocalID & Qualifiers::FastMask;
6991 unsigned LocalIndex = LocalID >> Qualifiers::FastWidth;
6992
6993 if (LocalIndex < NUM_PREDEF_TYPE_IDS)
6994 return LocalID;
6995
6996 if (!F.ModuleOffsetMap.empty())
6997 ReadModuleOffsetMap(F);
6998
6999 ContinuousRangeMap<uint32_t, int, 2>::iterator I
7000 = F.TypeRemap.find(LocalIndex - NUM_PREDEF_TYPE_IDS);
7001 assert(I != F.TypeRemap.end() && "Invalid index into type index remap");
7002
7003 unsigned GlobalIndex = LocalIndex + I->second;
7004 return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
7005 }
7006
7007 TemplateArgumentLocInfo
7008 ASTRecordReader::readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind) {
7009 switch (Kind) {
7010 case TemplateArgument::Expression:
7011 return readExpr();
7012 case TemplateArgument::Type:
7013 return readTypeSourceInfo();
7014 case TemplateArgument::Template: {
7015 NestedNameSpecifierLoc QualifierLoc =
7016 readNestedNameSpecifierLoc();
7017 SourceLocation TemplateNameLoc = readSourceLocation();
7018 return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc,
7019 SourceLocation());
7020 }
7021 case TemplateArgument::TemplateExpansion: {
7022 NestedNameSpecifierLoc QualifierLoc = readNestedNameSpecifierLoc();
7023 SourceLocation TemplateNameLoc = readSourceLocation();
7024 SourceLocation EllipsisLoc = readSourceLocation();
7025 return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc,
7026 EllipsisLoc);
7027 }
7028 case TemplateArgument::Null:
7029 case TemplateArgument::Integral:
7030 case TemplateArgument::Declaration:
7031 case TemplateArgument::NullPtr:
7032 case TemplateArgument::Pack:
7033 // FIXME: Is this right?
7034 return TemplateArgumentLocInfo();
7035 }
7036 llvm_unreachable("unexpected template argument loc");
7037 }
7038
7039 TemplateArgumentLoc ASTRecordReader::readTemplateArgumentLoc() {
7040 TemplateArgument Arg = readTemplateArgument();
7041
7042 if (Arg.getKind() == TemplateArgument::Expression) {
7043 if (readBool()) // bool InfoHasSameExpr.
7044 return TemplateArgumentLoc(Arg, TemplateArgumentLocInfo(Arg.getAsExpr()));
7045 }
7046 return TemplateArgumentLoc(Arg, readTemplateArgumentLocInfo(Arg.getKind()));
7047 }
7048
7049 const ASTTemplateArgumentListInfo *
7050 ASTRecordReader::readASTTemplateArgumentListInfo() {
7051 SourceLocation LAngleLoc = readSourceLocation();
7052 SourceLocation RAngleLoc = readSourceLocation();
7053 unsigned NumArgsAsWritten = readInt();
7054 TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc);
7055 for (unsigned i = 0; i != NumArgsAsWritten; ++i)
7056 TemplArgsInfo.addArgument(readTemplateArgumentLoc());
7057 return ASTTemplateArgumentListInfo::Create(getContext(), TemplArgsInfo);
7058 }
7059
7060 Decl *ASTReader::GetExternalDecl(uint32_t ID) {
7061 return GetDecl(ID);
7062 }
7063
7064 void ASTReader::CompleteRedeclChain(const Decl *D) {
7065 if (NumCurrentElementsDeserializing) {
7066 // We arrange to not care about the complete redeclaration chain while we're
7067 // deserializing. Just remember that the AST has marked this one as complete
7068 // but that it's not actually complete yet, so we know we still need to
7069 // complete it later.
7070 PendingIncompleteDeclChains.push_back(const_cast<Decl*>(D));
7071 return;
7072 }
7073
7074 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
7075
7076 // If this is a named declaration, complete it by looking it up
7077 // within its context.
7078 //
7079 // FIXME: Merging a function definition should merge
7080 // all mergeable entities within it.
7081 if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
7082 isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
7083 if (DeclarationName Name = cast<NamedDecl>(D)->getDeclName()) {
7084 if (!getContext().getLangOpts().CPlusPlus &&
7085 isa<TranslationUnitDecl>(DC)) {
7086 // Outside of C++, we don't have a lookup table for the TU, so update
7087 // the identifier instead. (For C++ modules, we don't store decls
7088 // in the serialized identifier table, so we do the lookup in the TU.)
7089 auto *II = Name.getAsIdentifierInfo();
7090 assert(II && "non-identifier name in C?");
7091 if (II->isOutOfDate())
7092 updateOutOfDateIdentifier(*II);
7093 } else
7094 DC->lookup(Name);
7095 } else if (needsAnonymousDeclarationNumber(cast<NamedDecl>(D))) {
7096 // Find all declarations of this kind from the relevant context.
7097 for (auto *DCDecl : cast<Decl>(D->getLexicalDeclContext())->redecls()) {
7098 auto *DC = cast<DeclContext>(DCDecl);
7099 SmallVector<Decl*, 8> Decls;
7100 FindExternalLexicalDecls(
7101 DC, [&](Decl::Kind K) { return K == D->getKind(); }, Decls);
7102 }
7103 }
7104 }
7105
7106 if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D))
7107 CTSD->getSpecializedTemplate()->LoadLazySpecializations();
7108 if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(D))
7109 VTSD->getSpecializedTemplate()->LoadLazySpecializations();
7110 if (auto *FD = dyn_cast<FunctionDecl>(D)) {
7111 if (auto *Template = FD->getPrimaryTemplate())
7112 Template->LoadLazySpecializations();
7113 }
7114 }
7115
7116 CXXCtorInitializer **
7117 ASTReader::GetExternalCXXCtorInitializers(uint64_t Offset) {
7118 RecordLocation Loc = getLocalBitOffset(Offset);
7119 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
7120 SavedStreamPosition SavedPosition(Cursor);
7121 if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7122 Error(std::move(Err));
7123 return nullptr;
7124 }
7125 ReadingKindTracker ReadingKind(Read_Decl, *this);
7126
7127 Expected<unsigned> MaybeCode = Cursor.ReadCode();
7128 if (!MaybeCode) {
7129 Error(MaybeCode.takeError());
7130 return nullptr;
7131 }
7132 unsigned Code = MaybeCode.get();
7133
7134 ASTRecordReader Record(*this, *Loc.F);
7135 Expected<unsigned> MaybeRecCode = Record.readRecord(Cursor, Code);
7136 if (!MaybeRecCode) {
7137 Error(MaybeRecCode.takeError());
7138 return nullptr;
7139 }
7140 if (MaybeRecCode.get() != DECL_CXX_CTOR_INITIALIZERS) {
7141 Error("malformed AST file: missing C++ ctor initializers");
7142 return nullptr;
7143 }
7144
7145 return Record.readCXXCtorInitializers();
7146 }
7147
7148 CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
7149 assert(ContextObj && "reading base specifiers with no AST context");
7150 ASTContext &Context = *ContextObj;
7151
7152 RecordLocation Loc = getLocalBitOffset(Offset);
7153 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
7154 SavedStreamPosition SavedPosition(Cursor);
7155 if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7156 Error(std::move(Err));
7157 return nullptr;
7158 }
7159 ReadingKindTracker ReadingKind(Read_Decl, *this);
7160
7161 Expected<unsigned> MaybeCode = Cursor.ReadCode();
7162 if (!MaybeCode) {
7163 Error(MaybeCode.takeError());
7164 return nullptr;
7165 }
7166 unsigned Code = MaybeCode.get();
7167
7168 ASTRecordReader Record(*this, *Loc.F);
7169 Expected<unsigned> MaybeRecCode = Record.readRecord(Cursor, Code);
7170 if (!MaybeRecCode) {
7171 Error(MaybeCode.takeError());
7172 return nullptr;
7173 }
7174 unsigned RecCode = MaybeRecCode.get();
7175
7176 if (RecCode != DECL_CXX_BASE_SPECIFIERS) {
7177 Error("malformed AST file: missing C++ base specifiers");
7178 return nullptr;
7179 }
7180
7181 unsigned NumBases = Record.readInt();
7182 void *Mem = Context.Allocate(sizeof(CXXBaseSpecifier) * NumBases);
7183 CXXBaseSpecifier *Bases = new (Mem) CXXBaseSpecifier [NumBases];
7184 for (unsigned I = 0; I != NumBases; ++I)
7185 Bases[I] = Record.readCXXBaseSpecifier();
7186 return Bases;
7187 }
7188
7189 serialization::DeclID
7190 ASTReader::getGlobalDeclID(ModuleFile &F, LocalDeclID LocalID) const {
7191 if (LocalID < NUM_PREDEF_DECL_IDS)
7192 return LocalID;
7193
7194 if (!F.ModuleOffsetMap.empty())
7195 ReadModuleOffsetMap(F);
7196
7197 ContinuousRangeMap<uint32_t, int, 2>::iterator I
7198 = F.DeclRemap.find(LocalID - NUM_PREDEF_DECL_IDS);
7199 assert(I != F.DeclRemap.end() && "Invalid index into decl index remap");
7200
7201 return LocalID + I->second;
7202 }
7203
7204 bool ASTReader::isDeclIDFromModule(serialization::GlobalDeclID ID,
7205 ModuleFile &M) const {
7206 // Predefined decls aren't from any module.
7207 if (ID < NUM_PREDEF_DECL_IDS)
7208 return false;
7209
7210 return ID - NUM_PREDEF_DECL_IDS >= M.BaseDeclID &&
7211 ID - NUM_PREDEF_DECL_IDS < M.BaseDeclID + M.LocalNumDecls;
7212 }
7213
7214 ModuleFile *ASTReader::getOwningModuleFile(const Decl *D) {
7215 if (!D->isFromASTFile())
7216 return nullptr;
7217 GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(D->getGlobalID());
7218 assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
7219 return I->second;
7220 }
7221
7222 SourceLocation ASTReader::getSourceLocationForDeclID(GlobalDeclID ID) {
7223 if (ID < NUM_PREDEF_DECL_IDS)
7224 return SourceLocation();
7225
7226 unsigned Index = ID - NUM_PREDEF_DECL_IDS;
7227
7228 if (Index > DeclsLoaded.size()) {
7229 Error("declaration ID out-of-range for AST file");
7230 return SourceLocation();
7231 }
7232
7233 if (Decl *D = DeclsLoaded[Index])
7234 return D->getLocation();
7235
7236 SourceLocation Loc;
7237 DeclCursorForID(ID, Loc);
7238 return Loc;
7239 }
7240
7241 static Decl *getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID) {
7242 switch (ID) {
7243 case PREDEF_DECL_NULL_ID:
7244 return nullptr;
7245
7246 case PREDEF_DECL_TRANSLATION_UNIT_ID:
7247 return Context.getTranslationUnitDecl();
7248
7249 case PREDEF_DECL_OBJC_ID_ID:
7250 return Context.getObjCIdDecl();
7251
7252 case PREDEF_DECL_OBJC_SEL_ID:
7253 return Context.getObjCSelDecl();
7254
7255 case PREDEF_DECL_OBJC_CLASS_ID:
7256 return Context.getObjCClassDecl();
7257
7258 case PREDEF_DECL_OBJC_PROTOCOL_ID:
7259 return Context.getObjCProtocolDecl();
7260
7261 case PREDEF_DECL_INT_128_ID:
7262 return Context.getInt128Decl();
7263
7264 case PREDEF_DECL_UNSIGNED_INT_128_ID:
7265 return Context.getUInt128Decl();
7266
7267 case PREDEF_DECL_OBJC_INSTANCETYPE_ID:
7268 return Context.getObjCInstanceTypeDecl();
7269
7270 case PREDEF_DECL_BUILTIN_VA_LIST_ID:
7271 return Context.getBuiltinVaListDecl();
7272
7273 case PREDEF_DECL_VA_LIST_TAG:
7274 return Context.getVaListTagDecl();
7275
7276 case PREDEF_DECL_BUILTIN_MS_VA_LIST_ID:
7277 return Context.getBuiltinMSVaListDecl();
7278
7279 case PREDEF_DECL_EXTERN_C_CONTEXT_ID:
7280 return Context.getExternCContextDecl();
7281
7282 case PREDEF_DECL_MAKE_INTEGER_SEQ_ID:
7283 return Context.getMakeIntegerSeqDecl();
7284
7285 case PREDEF_DECL_CF_CONSTANT_STRING_ID:
7286 return Context.getCFConstantStringDecl();
7287
7288 case PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID:
7289 return Context.getCFConstantStringTagDecl();
7290
7291 case PREDEF_DECL_TYPE_PACK_ELEMENT_ID:
7292 return Context.getTypePackElementDecl();
7293 }
7294 llvm_unreachable("PredefinedDeclIDs unknown enum value");
7295 }
7296
7297 Decl *ASTReader::GetExistingDecl(DeclID ID) {
7298 assert(ContextObj && "reading decl with no AST context");
7299 if (ID < NUM_PREDEF_DECL_IDS) {
7300 Decl *D = getPredefinedDecl(*ContextObj, (PredefinedDeclIDs)ID);
7301 if (D) {
7302 // Track that we have merged the declaration with ID \p ID into the
7303 // pre-existing predefined declaration \p D.
7304 auto &Merged = KeyDecls[D->getCanonicalDecl()];
7305 if (Merged.empty())
7306 Merged.push_back(ID);
7307 }
7308 return D;
7309 }
7310
7311 unsigned Index = ID - NUM_PREDEF_DECL_IDS;
7312
7313 if (Index >= DeclsLoaded.size()) {
7314 assert(0 && "declaration ID out-of-range for AST file");
7315 Error("declaration ID out-of-range for AST file");
7316 return nullptr;
7317 }
7318
7319 return DeclsLoaded[Index];
7320 }
7321
7322 Decl *ASTReader::GetDecl(DeclID ID) {
7323 if (ID < NUM_PREDEF_DECL_IDS)
7324 return GetExistingDecl(ID);
7325
7326 unsigned Index = ID - NUM_PREDEF_DECL_IDS;
7327
7328 if (Index >= DeclsLoaded.size()) {
7329 assert(0 && "declaration ID out-of-range for AST file");
7330 Error("declaration ID out-of-range for AST file");
7331 return nullptr;
7332 }
7333
7334 if (!DeclsLoaded[Index]) {
7335 ReadDeclRecord(ID);
7336 if (DeserializationListener)
7337 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
7338 }
7339
7340 return DeclsLoaded[Index];
7341 }
7342
7343 DeclID ASTReader::mapGlobalIDToModuleFileGlobalID(ModuleFile &M,
7344 DeclID GlobalID) {
7345 if (GlobalID < NUM_PREDEF_DECL_IDS)
7346 return GlobalID;
7347
7348 GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(GlobalID);
7349 assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
7350 ModuleFile *Owner = I->second;
7351
7352 llvm::DenseMap<ModuleFile *, serialization::DeclID>::iterator Pos
7353 = M.GlobalToLocalDeclIDs.find(Owner);
7354 if (Pos == M.GlobalToLocalDeclIDs.end())
7355 return 0;
7356
7357 return GlobalID - Owner->BaseDeclID + Pos->second;
7358 }
7359
7360 serialization::DeclID ASTReader::ReadDeclID(ModuleFile &F,
7361 const RecordData &Record,
7362 unsigned &Idx) {
7363 if (Idx >= Record.size()) {
7364 Error("Corrupted AST file");
7365 return 0;
7366 }
7367
7368 return getGlobalDeclID(F, Record[Idx++]);
7369 }
7370
7371 /// Resolve the offset of a statement into a statement.
7372 ///
7373 /// This operation will read a new statement from the external
7374 /// source each time it is called, and is meant to be used via a
7375 /// LazyOffsetPtr (which is used by Decls for the body of functions, etc).
7376 Stmt *ASTReader::GetExternalDeclStmt(uint64_t Offset) {
7377 // Switch case IDs are per Decl.
7378 ClearSwitchCaseIDs();
7379
7380 // Offset here is a global offset across the entire chain.
7381 RecordLocation Loc = getLocalBitOffset(Offset);
7382 if (llvm::Error Err = Loc.F->DeclsCursor.JumpToBit(Loc.Offset)) {
7383 Error(std::move(Err));
7384 return nullptr;
7385 }
7386 assert(NumCurrentElementsDeserializing == 0 &&
7387 "should not be called while already deserializing");
7388 Deserializing D(this);
7389 return ReadStmtFromStream(*Loc.F);
7390 }
7391
7392 void ASTReader::FindExternalLexicalDecls(
7393 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
7394 SmallVectorImpl<Decl *> &Decls) {
7395 bool PredefsVisited[NUM_PREDEF_DECL_IDS] = {};
7396
7397 auto Visit = [&] (ModuleFile *M, LexicalContents LexicalDecls) {
7398 assert(LexicalDecls.size() % 2 == 0 && "expected an even number of entries");
7399 for (int I = 0, N = LexicalDecls.size(); I != N; I += 2) {
7400 auto K = (Decl::Kind)+LexicalDecls[I];
7401 if (!IsKindWeWant(K))
7402 continue;
7403
7404 auto ID = (serialization::DeclID)+LexicalDecls[I + 1];
7405
7406 // Don't add predefined declarations to the lexical context more
7407 // than once.
7408 if (ID < NUM_PREDEF_DECL_IDS) {
7409 if (PredefsVisited[ID])
7410 continue;
7411
7412 PredefsVisited[ID] = true;
7413 }
7414
7415 if (Decl *D = GetLocalDecl(*M, ID)) {
7416 assert(D->getKind() == K && "wrong kind for lexical decl");
7417 if (!DC->isDeclInLexicalTraversal(D))
7418 Decls.push_back(D);
7419 }
7420 }
7421 };
7422
7423 if (isa<TranslationUnitDecl>(DC)) {
7424 for (auto Lexical : TULexicalDecls)
7425 Visit(Lexical.first, Lexical.second);
7426 } else {
7427 auto I = LexicalDecls.find(DC);
7428 if (I != LexicalDecls.end())
7429 Visit(I->second.first, I->second.second);
7430 }
7431
7432 ++NumLexicalDeclContextsRead;
7433 }
7434
7435 namespace {
7436
7437 class DeclIDComp {
7438 ASTReader &Reader;
7439 ModuleFile &Mod;
7440
7441 public:
7442 DeclIDComp(ASTReader &Reader, ModuleFile &M) : Reader(Reader), Mod(M) {}
7443
7444 bool operator()(LocalDeclID L, LocalDeclID R) const {
7445 SourceLocation LHS = getLocation(L);
7446 SourceLocation RHS = getLocation(R);
7447 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
7448 }
7449
7450 bool operator()(SourceLocation LHS, LocalDeclID R) const {
7451 SourceLocation RHS = getLocation(R);
7452 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
7453 }
7454
7455 bool operator()(LocalDeclID L, SourceLocation RHS) const {
7456 SourceLocation LHS = getLocation(L);
7457 return Reader.getSourceManager().isBeforeInTranslationUnit(LHS, RHS);
7458 }
7459
7460 SourceLocation getLocation(LocalDeclID ID) const {
7461 return Reader.getSourceManager().getFileLoc(
7462 Reader.getSourceLocationForDeclID(Reader.getGlobalDeclID(Mod, ID)));
7463 }
7464 };
7465
7466 } // namespace
7467
7468 void ASTReader::FindFileRegionDecls(FileID File,
7469 unsigned Offset, unsigned Length,
7470 SmallVectorImpl<Decl *> &Decls) {
7471 SourceManager &SM = getSourceManager();
7472
7473 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
7474 if (I == FileDeclIDs.end())
7475 return;
7476
7477 FileDeclsInfo &DInfo = I->second;
7478 if (DInfo.Decls.empty())
7479 return;
7480
7481 SourceLocation
7482 BeginLoc = SM.getLocForStartOfFile(File).getLocWithOffset(Offset);
7483 SourceLocation EndLoc = BeginLoc.getLocWithOffset(Length);
7484
7485 DeclIDComp DIDComp(*this, *DInfo.Mod);
7486 ArrayRef<serialization::LocalDeclID>::iterator BeginIt =
7487 llvm::lower_bound(DInfo.Decls, BeginLoc, DIDComp);
7488 if (BeginIt != DInfo.Decls.begin())
7489 --BeginIt;
7490
7491 // If we are pointing at a top-level decl inside an objc container, we need
7492 // to backtrack until we find it otherwise we will fail to report that the
7493 // region overlaps with an objc container.
7494 while (BeginIt != DInfo.Decls.begin() &&
7495 GetDecl(getGlobalDeclID(*DInfo.Mod, *BeginIt))
7496 ->isTopLevelDeclInObjCContainer())
7497 --BeginIt;
7498
7499 ArrayRef<serialization::LocalDeclID>::iterator EndIt =
7500 llvm::upper_bound(DInfo.Decls, EndLoc, DIDComp);
7501 if (EndIt != DInfo.Decls.end())
7502 ++EndIt;
7503
7504 for (ArrayRef<serialization::LocalDeclID>::iterator
7505 DIt = BeginIt; DIt != EndIt; ++DIt)
7506 Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
7507 }
7508
7509 bool
7510 ASTReader::FindExternalVisibleDeclsByName(const DeclContext *DC,
7511 DeclarationName Name) {
7512 assert(DC->hasExternalVisibleStorage() && DC == DC->getPrimaryContext() &&
7513 "DeclContext has no visible decls in storage");
7514 if (!Name)
7515 return false;
7516
7517 auto It = Lookups.find(DC);
7518 if (It == Lookups.end())
7519 return false;
7520
7521 Deserializing LookupResults(this);
7522
7523 // Load the list of declarations.
7524 SmallVector<NamedDecl *, 64> Decls;
7525 for (DeclID ID : It->second.Table.find(Name)) {
7526 NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
7527 if (ND->getDeclName() == Name)
7528 Decls.push_back(ND);
7529 }
7530
7531 ++NumVisibleDeclContextsRead;
7532 SetExternalVisibleDeclsForName(DC, Name, Decls);
7533 return !Decls.empty();
7534 }
7535
7536 void ASTReader::completeVisibleDeclsMap(const DeclContext *DC) {
7537 if (!DC->hasExternalVisibleStorage())
7538 return;
7539
7540 auto It = Lookups.find(DC);
7541 assert(It != Lookups.end() &&
7542 "have external visible storage but no lookup tables");
7543
7544 DeclsMap Decls;
7545
7546 for (DeclID ID : It->second.Table.findAll()) {
7547 NamedDecl *ND = cast<NamedDecl>(GetDecl(ID));
7548 Decls[ND->getDeclName()].push_back(ND);
7549 }
7550
7551 ++NumVisibleDeclContextsRead;
7552
7553 for (DeclsMap::iterator I = Decls.begin(), E = Decls.end(); I != E; ++I) {
7554 SetExternalVisibleDeclsForName(DC, I->first, I->second);
7555 }
7556 const_cast<DeclContext *>(DC)->setHasExternalVisibleStorage(false);
7557 }
7558
7559 const serialization::reader::DeclContextLookupTable *
7560 ASTReader::getLoadedLookupTables(DeclContext *Primary) const {
7561 auto I = Lookups.find(Primary);
7562 return I == Lookups.end() ? nullptr : &I->second;
7563 }
7564
7565 /// Under non-PCH compilation the consumer receives the objc methods
7566 /// before receiving the implementation, and codegen depends on this.
7567 /// We simulate this by deserializing and passing to consumer the methods of the
7568 /// implementation before passing the deserialized implementation decl.
7569 static void PassObjCImplDeclToConsumer(ObjCImplDecl *ImplD,
7570 ASTConsumer *Consumer) {
7571 assert(ImplD && Consumer);
7572
7573 for (auto *I : ImplD->methods())
7574 Consumer->HandleInterestingDecl(DeclGroupRef(I));
7575
7576 Consumer->HandleInterestingDecl(DeclGroupRef(ImplD));
7577 }
7578
7579 void ASTReader::PassInterestingDeclToConsumer(Decl *D) {
7580 if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(D))
7581 PassObjCImplDeclToConsumer(ImplD, Consumer);
7582 else
7583 Consumer->HandleInterestingDecl(DeclGroupRef(D));
7584 }
7585
7586 void ASTReader::StartTranslationUnit(ASTConsumer *Consumer) {
7587 this->Consumer = Consumer;
7588
7589 if (Consumer)
7590 PassInterestingDeclsToConsumer();
7591
7592 if (DeserializationListener)
7593 DeserializationListener->ReaderInitialized(this);
7594 }
7595
7596 void ASTReader::PrintStats() {
7597 std::fprintf(stderr, "*** AST File Statistics:\n");
7598
7599 unsigned NumTypesLoaded
7600 = TypesLoaded.size() - std::count(TypesLoaded.begin(), TypesLoaded.end(),
7601 QualType());
7602 unsigned NumDeclsLoaded
7603 = DeclsLoaded.size() - std::count(DeclsLoaded.begin(), DeclsLoaded.end(),
7604 (Decl *)nullptr);
7605 unsigned NumIdentifiersLoaded
7606 = IdentifiersLoaded.size() - std::count(IdentifiersLoaded.begin(),
7607 IdentifiersLoaded.end(),
7608 (IdentifierInfo *)nullptr);
7609 unsigned NumMacrosLoaded
7610 = MacrosLoaded.size() - std::count(MacrosLoaded.begin(),
7611 MacrosLoaded.end(),
7612 (MacroInfo *)nullptr);
7613 unsigned NumSelectorsLoaded
7614 = SelectorsLoaded.size() - std::count(SelectorsLoaded.begin(),
7615 SelectorsLoaded.end(),
7616 Selector());
7617
7618 if (unsigned TotalNumSLocEntries = getTotalNumSLocs())
7619 std::fprintf(stderr, " %u/%u source location entries read (%f%%)\n",
7620 NumSLocEntriesRead, TotalNumSLocEntries,
7621 ((float)NumSLocEntriesRead/TotalNumSLocEntries * 100));
7622 if (!TypesLoaded.empty())
7623 std::fprintf(stderr, " %u/%u types read (%f%%)\n",
7624 NumTypesLoaded, (unsigned)TypesLoaded.size(),
7625 ((float)NumTypesLoaded/TypesLoaded.size() * 100));
7626 if (!DeclsLoaded.empty())
7627 std::fprintf(stderr, " %u/%u declarations read (%f%%)\n",
7628 NumDeclsLoaded, (unsigned)DeclsLoaded.size(),
7629 ((float)NumDeclsLoaded/DeclsLoaded.size() * 100));
7630 if (!IdentifiersLoaded.empty())
7631 std::fprintf(stderr, " %u/%u identifiers read (%f%%)\n",
7632 NumIdentifiersLoaded, (unsigned)IdentifiersLoaded.size(),
7633 ((float)NumIdentifiersLoaded/IdentifiersLoaded.size() * 100));
7634 if (!MacrosLoaded.empty())
7635 std::fprintf(stderr, " %u/%u macros read (%f%%)\n",
7636 NumMacrosLoaded, (unsigned)MacrosLoaded.size(),
7637 ((float)NumMacrosLoaded/MacrosLoaded.size() * 100));
7638 if (!SelectorsLoaded.empty())
7639 std::fprintf(stderr, " %u/%u selectors read (%f%%)\n",
7640 NumSelectorsLoaded, (unsigned)SelectorsLoaded.size(),
7641 ((float)NumSelectorsLoaded/SelectorsLoaded.size() * 100));
7642 if (TotalNumStatements)
7643 std::fprintf(stderr, " %u/%u statements read (%f%%)\n",
7644 NumStatementsRead, TotalNumStatements,
7645 ((float)NumStatementsRead/TotalNumStatements * 100));
7646 if (TotalNumMacros)
7647 std::fprintf(stderr, " %u/%u macros read (%f%%)\n",
7648 NumMacrosRead, TotalNumMacros,
7649 ((float)NumMacrosRead/TotalNumMacros * 100));
7650 if (TotalLexicalDeclContexts)
7651 std::fprintf(stderr, " %u/%u lexical declcontexts read (%f%%)\n",
7652 NumLexicalDeclContextsRead, TotalLexicalDeclContexts,
7653 ((float)NumLexicalDeclContextsRead/TotalLexicalDeclContexts
7654 * 100));
7655 if (TotalVisibleDeclContexts)
7656 std::fprintf(stderr, " %u/%u visible declcontexts read (%f%%)\n",
7657 NumVisibleDeclContextsRead, TotalVisibleDeclContexts,
7658 ((float)NumVisibleDeclContextsRead/TotalVisibleDeclContexts
7659 * 100));
7660 if (TotalNumMethodPoolEntries)
7661 std::fprintf(stderr, " %u/%u method pool entries read (%f%%)\n",
7662 NumMethodPoolEntriesRead, TotalNumMethodPoolEntries,
7663 ((float)NumMethodPoolEntriesRead/TotalNumMethodPoolEntries
7664 * 100));
7665 if (NumMethodPoolLookups)
7666 std::fprintf(stderr, " %u/%u method pool lookups succeeded (%f%%)\n",
7667 NumMethodPoolHits, NumMethodPoolLookups,
7668 ((float)NumMethodPoolHits/NumMethodPoolLookups * 100.0));
7669 if (NumMethodPoolTableLookups)
7670 std::fprintf(stderr, " %u/%u method pool table lookups succeeded (%f%%)\n",
7671 NumMethodPoolTableHits, NumMethodPoolTableLookups,
7672 ((float)NumMethodPoolTableHits/NumMethodPoolTableLookups
7673 * 100.0));
7674 if (NumIdentifierLookupHits)
7675 std::fprintf(stderr,
7676 " %u / %u identifier table lookups succeeded (%f%%)\n",
7677 NumIdentifierLookupHits, NumIdentifierLookups,
7678 (double)NumIdentifierLookupHits*100.0/NumIdentifierLookups);
7679
7680 if (GlobalIndex) {
7681 std::fprintf(stderr, "\n");
7682 GlobalIndex->printStats();
7683 }
7684
7685 std::fprintf(stderr, "\n");
7686 dump();
7687 std::fprintf(stderr, "\n");
7688 }
7689
7690 template<typename Key, typename ModuleFile, unsigned InitialCapacity>
7691 LLVM_DUMP_METHOD static void
7692 dumpModuleIDMap(StringRef Name,
7693 const ContinuousRangeMap<Key, ModuleFile *,
7694 InitialCapacity> &Map) {
7695 if (Map.begin() == Map.end())
7696 return;
7697
7698 using MapType = ContinuousRangeMap<Key, ModuleFile *, InitialCapacity>;
7699
7700 llvm::errs() << Name << ":\n";
7701 for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
7702 I != IEnd; ++I) {
7703 llvm::errs() << " " << I->first << " -> " << I->second->FileName
7704 << "\n";
7705 }
7706 }
7707
7708 LLVM_DUMP_METHOD void ASTReader::dump() {
7709 llvm::errs() << "*** PCH/ModuleFile Remappings:\n";
7710 dumpModuleIDMap("Global bit offset map", GlobalBitOffsetsMap);
7711 dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap);
7712 dumpModuleIDMap("Global type map", GlobalTypeMap);
7713 dumpModuleIDMap("Global declaration map", GlobalDeclMap);
7714 dumpModuleIDMap("Global identifier map", GlobalIdentifierMap);
7715 dumpModuleIDMap("Global macro map", GlobalMacroMap);
7716 dumpModuleIDMap("Global submodule map", GlobalSubmoduleMap);
7717 dumpModuleIDMap("Global selector map", GlobalSelectorMap);
7718 dumpModuleIDMap("Global preprocessed entity map",
7719 GlobalPreprocessedEntityMap);
7720
7721 llvm::errs() << "\n*** PCH/Modules Loaded:";
7722 for (ModuleFile &M : ModuleMgr)
7723 M.dump();
7724 }
7725
7726 /// Return the amount of memory used by memory buffers, breaking down
7727 /// by heap-backed versus mmap'ed memory.
7728 void ASTReader::getMemoryBufferSizes(MemoryBufferSizes &sizes) const {
7729 for (ModuleFile &I : ModuleMgr) {
7730 if (llvm::MemoryBuffer *buf = I.Buffer) {
7731 size_t bytes = buf->getBufferSize();
7732 switch (buf->getBufferKind()) {
7733 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
7734 sizes.malloc_bytes += bytes;
7735 break;
7736 case llvm::MemoryBuffer::MemoryBuffer_MMap:
7737 sizes.mmap_bytes += bytes;
7738 break;
7739 }
7740 }
7741 }
7742 }
7743
7744 void ASTReader::InitializeSema(Sema &S) {
7745 SemaObj = &S;
7746 S.addExternalSource(this);
7747
7748 // Makes sure any declarations that were deserialized "too early"
7749 // still get added to the identifier's declaration chains.
7750 for (uint64_t ID : PreloadedDeclIDs) {
7751 NamedDecl *D = cast<NamedDecl>(GetDecl(ID));
7752 pushExternalDeclIntoScope(D, D->getDeclName());
7753 }
7754 PreloadedDeclIDs.clear();
7755
7756 // FIXME: What happens if these are changed by a module import?
7757 if (!FPPragmaOptions.empty()) {
7758 assert(FPPragmaOptions.size() == 1 && "Wrong number of FP_PRAGMA_OPTIONS");
7759 SemaObj->FPFeatures = FPOptions(FPPragmaOptions[0]);
7760 }
7761
7762 SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
7763 SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
7764 SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
7765
7766 UpdateSema();
7767 }
7768
7769 void ASTReader::UpdateSema() {
7770 assert(SemaObj && "no Sema to update");
7771
7772 // Load the offsets of the declarations that Sema references.
7773 // They will be lazily deserialized when needed.
7774 if (!SemaDeclRefs.empty()) {
7775 assert(SemaDeclRefs.size() % 3 == 0);
7776 for (unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
7777 if (!SemaObj->StdNamespace)
7778 SemaObj->StdNamespace = SemaDeclRefs[I];
7779 if (!SemaObj->StdBadAlloc)
7780 SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
7781 if (!SemaObj->StdAlignValT)
7782 SemaObj->StdAlignValT = SemaDeclRefs[I+2];
7783 }
7784 SemaDeclRefs.clear();
7785 }
7786
7787 // Update the state of pragmas. Use the same API as if we had encountered the
7788 // pragma in the source.
7789 if(OptimizeOffPragmaLocation.isValid())
7790 SemaObj->ActOnPragmaOptimize(/* On = */ false, OptimizeOffPragmaLocation);
7791 if (PragmaMSStructState != -1)
7792 SemaObj->ActOnPragmaMSStruct((PragmaMSStructKind)PragmaMSStructState);
7793 if (PointersToMembersPragmaLocation.isValid()) {
7794 SemaObj->ActOnPragmaMSPointersToMembers(
7795 (LangOptions::PragmaMSPointersToMembersKind)
7796 PragmaMSPointersToMembersState,
7797 PointersToMembersPragmaLocation);
7798 }
7799 SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
7800
7801 if (PragmaPackCurrentValue) {
7802 // The bottom of the stack might have a default value. It must be adjusted
7803 // to the current value to ensure that the packing state is preserved after
7804 // popping entries that were included/imported from a PCH/module.
7805 bool DropFirst = false;
7806 if (!PragmaPackStack.empty() &&
7807 PragmaPackStack.front().Location.isInvalid()) {
7808 assert(PragmaPackStack.front().Value == SemaObj->PackStack.DefaultValue &&
7809 "Expected a default alignment value");
7810 SemaObj->PackStack.Stack.emplace_back(
7811 PragmaPackStack.front().SlotLabel, SemaObj->PackStack.CurrentValue,
7812 SemaObj->PackStack.CurrentPragmaLocation,
7813 PragmaPackStack.front().PushLocation);
7814 DropFirst = true;
7815 }
7816 for (const auto &Entry :
7817 llvm::makeArrayRef(PragmaPackStack).drop_front(DropFirst ? 1 : 0))
7818 SemaObj->PackStack.Stack.emplace_back(Entry.SlotLabel, Entry.Value,
7819 Entry.Location, Entry.PushLocation);
7820 if (PragmaPackCurrentLocation.isInvalid()) {
7821 assert(*PragmaPackCurrentValue == SemaObj->PackStack.DefaultValue &&
7822 "Expected a default alignment value");
7823 // Keep the current values.
7824 } else {
7825 SemaObj->PackStack.CurrentValue = *PragmaPackCurrentValue;
7826 SemaObj->PackStack.CurrentPragmaLocation = PragmaPackCurrentLocation;
7827 }
7828 }
7829 }
7830
7831 IdentifierInfo *ASTReader::get(StringRef Name) {
7832 // Note that we are loading an identifier.
7833 Deserializing AnIdentifier(this);
7834
7835 IdentifierLookupVisitor Visitor(Name, /*PriorGeneration=*/0,
7836 NumIdentifierLookups,
7837 NumIdentifierLookupHits);
7838
7839 // We don't need to do identifier table lookups in C++ modules (we preload
7840 // all interesting declarations, and don't need to use the scope for name
7841 // lookups). Perform the lookup in PCH files, though, since we don't build
7842 // a complete initial identifier table if we're carrying on from a PCH.
7843 if (PP.getLangOpts().CPlusPlus) {
7844 for (auto F : ModuleMgr.pch_modules())
7845 if (Visitor(*F))
7846 break;
7847 } else {
7848 // If there is a global index, look there first to determine which modules
7849 // provably do not have any results for this identifier.
7850 GlobalModuleIndex::HitSet Hits;
7851 GlobalModuleIndex::HitSet *HitsPtr = nullptr;
7852 if (!loadGlobalIndex()) {
7853 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
7854 HitsPtr = &Hits;
7855 }
7856 }
7857
7858 ModuleMgr.visit(Visitor, HitsPtr);
7859 }
7860
7861 IdentifierInfo *II = Visitor.getIdentifierInfo();
7862 markIdentifierUpToDate(II);
7863 return II;
7864 }
7865
7866 namespace clang {
7867
7868 /// An identifier-lookup iterator that enumerates all of the
7869 /// identifiers stored within a set of AST files.
7870 class ASTIdentifierIterator : public IdentifierIterator {
7871 /// The AST reader whose identifiers are being enumerated.
7872 const ASTReader &Reader;
7873
7874 /// The current index into the chain of AST files stored in
7875 /// the AST reader.
7876 unsigned Index;
7877
7878 /// The current position within the identifier lookup table
7879 /// of the current AST file.
7880 ASTIdentifierLookupTable::key_iterator Current;
7881
7882 /// The end position within the identifier lookup table of
7883 /// the current AST file.
7884 ASTIdentifierLookupTable::key_iterator End;
7885
7886 /// Whether to skip any modules in the ASTReader.
7887 bool SkipModules;
7888
7889 public:
7890 explicit ASTIdentifierIterator(const ASTReader &Reader,
7891 bool SkipModules = false);
7892
7893 StringRef Next() override;
7894 };
7895
7896 } // namespace clang
7897
7898 ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader &Reader,
7899 bool SkipModules)
7900 : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
7901 }
7902
7903 StringRef ASTIdentifierIterator::Next() {
7904 while (Current == End) {
7905 // If we have exhausted all of our AST files, we're done.
7906 if (Index == 0)
7907 return StringRef();
7908
7909 --Index;
7910 ModuleFile &F = Reader.ModuleMgr[Index];
7911 if (SkipModules && F.isModule())
7912 continue;
7913
7914 ASTIdentifierLookupTable *IdTable =
7915 (ASTIdentifierLookupTable *)F.IdentifierLookupTable;
7916 Current = IdTable->key_begin();
7917 End = IdTable->key_end();
7918 }
7919
7920 // We have any identifiers remaining in the current AST file; return
7921 // the next one.
7922 StringRef Result = *Current;
7923 ++Current;
7924 return Result;
7925 }
7926
7927 namespace {
7928
7929 /// A utility for appending two IdentifierIterators.
7930 class ChainedIdentifierIterator : public IdentifierIterator {
7931 std::unique_ptr<IdentifierIterator> Current;
7932 std::unique_ptr<IdentifierIterator> Queued;
7933
7934 public:
7935 ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator> First,
7936 std::unique_ptr<IdentifierIterator> Second)
7937 : Current(std::move(First)), Queued(std::move(Second)) {}
7938
7939 StringRef Next() override {
7940 if (!Current)
7941 return StringRef();
7942
7943 StringRef result = Current->Next();
7944 if (!result.empty())
7945 return result;
7946
7947 // Try the queued iterator, which may itself be empty.
7948 Current.reset();
7949 std::swap(Current, Queued);
7950 return Next();
7951 }
7952 };
7953
7954 } // namespace
7955
7956 IdentifierIterator *ASTReader::getIdentifiers() {
7957 if (!loadGlobalIndex()) {
7958 std::unique_ptr<IdentifierIterator> ReaderIter(
7959 new ASTIdentifierIterator(*this, /*SkipModules=*/true));
7960 std::unique_ptr<IdentifierIterator> ModulesIter(
7961 GlobalIndex->createIdentifierIterator());
7962 return new ChainedIdentifierIterator(std::move(ReaderIter),
7963 std::move(ModulesIter));
7964 }
7965
7966 return new ASTIdentifierIterator(*this);
7967 }
7968
7969 namespace clang {
7970 namespace serialization {
7971
7972 class ReadMethodPoolVisitor {
7973 ASTReader &Reader;
7974 Selector Sel;
7975 unsigned PriorGeneration;
7976 unsigned InstanceBits = 0;
7977 unsigned FactoryBits = 0;
7978 bool InstanceHasMoreThanOneDecl = false;
7979 bool FactoryHasMoreThanOneDecl = false;
7980 SmallVector<ObjCMethodDecl *, 4> InstanceMethods;
7981 SmallVector<ObjCMethodDecl *, 4> FactoryMethods;
7982
7983 public:
7984 ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel,
7985 unsigned PriorGeneration)
7986 : Reader(Reader), Sel(Sel), PriorGeneration(PriorGeneration) {}
7987
7988 bool operator()(ModuleFile &M) {
7989 if (!M.SelectorLookupTable)
7990 return false;
7991
7992 // If we've already searched this module file, skip it now.
7993 if (M.Generation <= PriorGeneration)
7994 return true;
7995
7996 ++Reader.NumMethodPoolTableLookups;
7997 ASTSelectorLookupTable *PoolTable
7998 = (ASTSelectorLookupTable*)M.SelectorLookupTable;
7999 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
8000 if (Pos == PoolTable->end())
8001 return false;
8002
8003 ++Reader.NumMethodPoolTableHits;
8004 ++Reader.NumSelectorsRead;
8005 // FIXME: Not quite happy with the statistics here. We probably should
8006 // disable this tracking when called via LoadSelector.
8007 // Also, should entries without methods count as misses?
8008 ++Reader.NumMethodPoolEntriesRead;
8009 ASTSelectorLookupTrait::data_type Data = *Pos;
8010 if (Reader.DeserializationListener)
8011 Reader.DeserializationListener->SelectorRead(Data.ID, Sel);
8012
8013 InstanceMethods.append(Data.Instance.begin(), Data.Instance.end());
8014 FactoryMethods.append(Data.Factory.begin(), Data.Factory.end());
8015 InstanceBits = Data.InstanceBits;
8016 FactoryBits = Data.FactoryBits;
8017 InstanceHasMoreThanOneDecl = Data.InstanceHasMoreThanOneDecl;
8018 FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl;
8019 return true;
8020 }
8021
8022 /// Retrieve the instance methods found by this visitor.
8023 ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
8024 return InstanceMethods;
8025 }
8026
8027 /// Retrieve the instance methods found by this visitor.
8028 ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
8029 return FactoryMethods;
8030 }
8031
8032 unsigned getInstanceBits() const { return InstanceBits; }
8033 unsigned getFactoryBits() const { return FactoryBits; }
8034
8035 bool instanceHasMoreThanOneDecl() const {
8036 return InstanceHasMoreThanOneDecl;
8037 }
8038
8039 bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
8040 };
8041
8042 } // namespace serialization
8043 } // namespace clang
8044
8045 /// Add the given set of methods to the method list.
8046 static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods,
8047 ObjCMethodList &List) {
8048 for (unsigned I = 0, N = Methods.size(); I != N; ++I) {
8049 S.addMethodToGlobalList(&List, Methods[I]);
8050 }
8051 }
8052
8053 void ASTReader::ReadMethodPool(Selector Sel) {
8054 // Get the selector generation and update it to the current generation.
8055 unsigned &Generation = SelectorGeneration[Sel];
8056 unsigned PriorGeneration = Generation;
8057 Generation = getGeneration();
8058 SelectorOutOfDate[Sel] = false;
8059
8060 // Search for methods defined with this selector.
8061 ++NumMethodPoolLookups;
8062 ReadMethodPoolVisitor Visitor(*this, Sel, PriorGeneration);
8063 ModuleMgr.visit(Visitor);
8064
8065 if (Visitor.getInstanceMethods().empty() &&
8066 Visitor.getFactoryMethods().empty())
8067 return;
8068
8069 ++NumMethodPoolHits;
8070
8071 if (!getSema())
8072 return;
8073
8074 Sema &S = *getSema();
8075 Sema::GlobalMethodPool::iterator Pos
8076 = S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
8077
8078 Pos->second.first.setBits(Visitor.getInstanceBits());
8079 Pos->second.first.setHasMoreThanOneDecl(Visitor.instanceHasMoreThanOneDecl());
8080 Pos->second.second.setBits(Visitor.getFactoryBits());
8081 Pos->second.second.setHasMoreThanOneDecl(Visitor.factoryHasMoreThanOneDecl());
8082
8083 // Add methods to the global pool *after* setting hasMoreThanOneDecl, since
8084 // when building a module we keep every method individually and may need to
8085 // update hasMoreThanOneDecl as we add the methods.
8086 addMethodsToPool(S, Visitor.getInstanceMethods(), Pos->second.first);
8087 addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
8088 }
8089
8090 void ASTReader::updateOutOfDateSelector(Selector Sel) {
8091 if (SelectorOutOfDate[Sel])
8092 ReadMethodPool(Sel);
8093 }
8094
8095 void ASTReader::ReadKnownNamespaces(
8096 SmallVectorImpl<NamespaceDecl *> &Namespaces) {
8097 Namespaces.clear();
8098
8099 for (unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
8100 if (NamespaceDecl *Namespace
8101 = dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
8102 Namespaces.push_back(Namespace);
8103 }
8104 }
8105
8106 void ASTReader::ReadUndefinedButUsed(
8107 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
8108 for (unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
8109 NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++]));
8110 SourceLocation Loc =
8111 SourceLocation::getFromRawEncoding(UndefinedButUsed[Idx++]);
8112 Undefined.insert(std::make_pair(D, Loc));
8113 }
8114 }
8115
8116 void ASTReader::ReadMismatchingDeleteExpressions(llvm::MapVector<
8117 FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
8118 Exprs) {
8119 for (unsigned Idx = 0, N = DelayedDeleteExprs.size(); Idx != N;) {
8120 FieldDecl *FD = cast<FieldDecl>(GetDecl(DelayedDeleteExprs[Idx++]));
8121 uint64_t Count = DelayedDeleteExprs[Idx++];
8122 for (uint64_t C = 0; C < Count; ++C) {
8123 SourceLocation DeleteLoc =
8124 SourceLocation::getFromRawEncoding(DelayedDeleteExprs[Idx++]);
8125 const bool IsArrayForm = DelayedDeleteExprs[Idx++];
8126 Exprs[FD].push_back(std::make_pair(DeleteLoc, IsArrayForm));
8127 }
8128 }
8129 }
8130
8131 void ASTReader::ReadTentativeDefinitions(
8132 SmallVectorImpl<VarDecl *> &TentativeDefs) {
8133 for (unsigned I = 0, N = TentativeDefinitions.size(); I != N; ++I) {
8134 VarDecl *Var = dyn_cast_or_null<VarDecl>(GetDecl(TentativeDefinitions[I]));
8135 if (Var)
8136 TentativeDefs.push_back(Var);
8137 }
8138 TentativeDefinitions.clear();
8139 }
8140
8141 void ASTReader::ReadUnusedFileScopedDecls(
8142 SmallVectorImpl<const DeclaratorDecl *> &Decls) {
8143 for (unsigned I = 0, N = UnusedFileScopedDecls.size(); I != N; ++I) {
8144 DeclaratorDecl *D
8145 = dyn_cast_or_null<DeclaratorDecl>(GetDecl(UnusedFileScopedDecls[I]));
8146 if (D)
8147 Decls.push_back(D);
8148 }
8149 UnusedFileScopedDecls.clear();
8150 }
8151
8152 void ASTReader::ReadDelegatingConstructors(
8153 SmallVectorImpl<CXXConstructorDecl *> &Decls) {
8154 for (unsigned I = 0, N = DelegatingCtorDecls.size(); I != N; ++I) {
8155 CXXConstructorDecl *D
8156 = dyn_cast_or_null<CXXConstructorDecl>(GetDecl(DelegatingCtorDecls[I]));
8157 if (D)
8158 Decls.push_back(D);
8159 }
8160 DelegatingCtorDecls.clear();
8161 }
8162
8163 void ASTReader::ReadExtVectorDecls(SmallVectorImpl<TypedefNameDecl *> &Decls) {
8164 for (unsigned I = 0, N = ExtVectorDecls.size(); I != N; ++I) {
8165 TypedefNameDecl *D
8166 = dyn_cast_or_null<TypedefNameDecl>(GetDecl(ExtVectorDecls[I]));
8167 if (D)
8168 Decls.push_back(D);
8169 }
8170 ExtVectorDecls.clear();
8171 }
8172
8173 void ASTReader::ReadUnusedLocalTypedefNameCandidates(
8174 llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) {
8175 for (unsigned I = 0, N = UnusedLocalTypedefNameCandidates.size(); I != N;
8176 ++I) {
8177 TypedefNameDecl *D = dyn_cast_or_null<TypedefNameDecl>(
8178 GetDecl(UnusedLocalTypedefNameCandidates[I]));
8179 if (D)
8180 Decls.insert(D);
8181 }
8182 UnusedLocalTypedefNameCandidates.clear();
8183 }
8184
8185 void ASTReader::ReadReferencedSelectors(
8186 SmallVectorImpl<std::pair<Selector, SourceLocation>> &Sels) {
8187 if (ReferencedSelectorsData.empty())
8188 return;
8189
8190 // If there are @selector references added them to its pool. This is for
8191 // implementation of -Wselector.
8192 unsigned int DataSize = ReferencedSelectorsData.size()-1;
8193 unsigned I = 0;
8194 while (I < DataSize) {
8195 Selector Sel = DecodeSelector(ReferencedSelectorsData[I++]);
8196 SourceLocation SelLoc
8197 = SourceLocation::getFromRawEncoding(ReferencedSelectorsData[I++]);
8198 Sels.push_back(std::make_pair(Sel, SelLoc));
8199 }
8200 ReferencedSelectorsData.clear();
8201 }
8202
8203 void ASTReader::ReadWeakUndeclaredIdentifiers(
8204 SmallVectorImpl<std::pair<IdentifierInfo *, WeakInfo>> &WeakIDs) {
8205 if (WeakUndeclaredIdentifiers.empty())
8206 return;
8207
8208 for (unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; /*none*/) {
8209 IdentifierInfo *WeakId
8210 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8211 IdentifierInfo *AliasId
8212 = DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
8213 SourceLocation Loc
8214 = SourceLocation::getFromRawEncoding(WeakUndeclaredIdentifiers[I++]);
8215 bool Used = WeakUndeclaredIdentifiers[I++];
8216 WeakInfo WI(AliasId, Loc);
8217 WI.setUsed(Used);
8218 WeakIDs.push_back(std::make_pair(WeakId, WI));
8219 }
8220 WeakUndeclaredIdentifiers.clear();
8221 }
8222
8223 void ASTReader::ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {
8224 for (unsigned Idx = 0, N = VTableUses.size(); Idx < N; /* In loop */) {
8225 ExternalVTableUse VT;
8226 VT.Record = dyn_cast_or_null<CXXRecordDecl>(GetDecl(VTableUses[Idx++]));
8227 VT.Location = SourceLocation::getFromRawEncoding(VTableUses[Idx++]);
8228 VT.DefinitionRequired = VTableUses[Idx++];
8229 VTables.push_back(VT);
8230 }
8231
8232 VTableUses.clear();
8233 }
8234
8235 void ASTReader::ReadPendingInstantiations(
8236 SmallVectorImpl<std::pair<ValueDecl *, SourceLocation>> &Pending) {
8237 for (unsigned Idx = 0, N = PendingInstantiations.size(); Idx < N;) {
8238 ValueDecl *D = cast<ValueDecl>(GetDecl(PendingInstantiations[Idx++]));
8239 SourceLocation Loc
8240 = SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]);
8241
8242 Pending.push_back(std::make_pair(D, Loc));
8243 }
8244 PendingInstantiations.clear();
8245 }
8246
8247 void ASTReader::ReadLateParsedTemplates(
8248 llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
8249 &LPTMap) {
8250 for (unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
8251 /* In loop */) {
8252 FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
8253
8254 auto LT = std::make_unique<LateParsedTemplate>();
8255 LT->D = GetDecl(LateParsedTemplates[Idx++]);
8256
8257 ModuleFile *F = getOwningModuleFile(LT->D);
8258 assert(F && "No module");
8259
8260 unsigned TokN = LateParsedTemplates[Idx++];
8261 LT->Toks.reserve(TokN);
8262 for (unsigned T = 0; T < TokN; ++T)
8263 LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
8264
8265 LPTMap.insert(std::make_pair(FD, std::move(LT)));
8266 }
8267
8268 LateParsedTemplates.clear();
8269 }
8270
8271 void ASTReader::LoadSelector(Selector Sel) {
8272 // It would be complicated to avoid reading the methods anyway. So don't.
8273 ReadMethodPool(Sel);
8274 }
8275
8276 void ASTReader::SetIdentifierInfo(IdentifierID ID, IdentifierInfo *II) {
8277 assert(ID && "Non-zero identifier ID required");
8278 assert(ID <= IdentifiersLoaded.size() && "identifier ID out of range");
8279 IdentifiersLoaded[ID - 1] = II;
8280 if (DeserializationListener)
8281 DeserializationListener->IdentifierRead(ID, II);
8282 }
8283
8284 /// Set the globally-visible declarations associated with the given
8285 /// identifier.
8286 ///
8287 /// If the AST reader is currently in a state where the given declaration IDs
8288 /// cannot safely be resolved, they are queued until it is safe to resolve
8289 /// them.
8290 ///
8291 /// \param II an IdentifierInfo that refers to one or more globally-visible
8292 /// declarations.
8293 ///
8294 /// \param DeclIDs the set of declaration IDs with the name @p II that are
8295 /// visible at global scope.
8296 ///
8297 /// \param Decls if non-null, this vector will be populated with the set of
8298 /// deserialized declarations. These declarations will not be pushed into
8299 /// scope.
8300 void
8301 ASTReader::SetGloballyVisibleDecls(IdentifierInfo *II,
8302 const SmallVectorImpl<uint32_t> &DeclIDs,
8303 SmallVectorImpl<Decl *> *Decls) {
8304 if (NumCurrentElementsDeserializing && !Decls) {
8305 PendingIdentifierInfos[II].append(DeclIDs.begin(), DeclIDs.end());
8306 return;
8307 }
8308
8309 for (unsigned I = 0, N = DeclIDs.size(); I != N; ++I) {
8310 if (!SemaObj) {
8311 // Queue this declaration so that it will be added to the
8312 // translation unit scope and identifier's declaration chain
8313 // once a Sema object is known.
8314 PreloadedDeclIDs.push_back(DeclIDs[I]);
8315 continue;
8316 }
8317
8318 NamedDecl *D = cast<NamedDecl>(GetDecl(DeclIDs[I]));
8319
8320 // If we're simply supposed to record the declarations, do so now.
8321 if (Decls) {
8322 Decls->push_back(D);
8323 continue;
8324 }
8325
8326 // Introduce this declaration into the translation-unit scope
8327 // and add it to the declaration chain for this identifier, so
8328 // that (unqualified) name lookup will find it.
8329 pushExternalDeclIntoScope(D, II);
8330 }
8331 }
8332
8333 IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
8334 if (ID == 0)
8335 return nullptr;
8336
8337 if (IdentifiersLoaded.empty()) {
8338 Error("no identifier table in AST file");
8339 return nullptr;
8340 }
8341
8342 ID -= 1;
8343 if (!IdentifiersLoaded[ID]) {
8344 GlobalIdentifierMapType::iterator I = GlobalIdentifierMap.find(ID + 1);
8345 assert(I != GlobalIdentifierMap.end() && "Corrupted global identifier map");
8346 ModuleFile *M = I->second;
8347 unsigned Index = ID - M->BaseIdentifierID;
8348 const char *Str = M->IdentifierTableData + M->IdentifierOffsets[Index];
8349
8350 // All of the strings in the AST file are preceded by a 16-bit length.
8351 // Extract that 16-bit length to avoid having to execute strlen().
8352 // NOTE: 'StrLenPtr' is an 'unsigned char*' so that we load bytes as
8353 // unsigned integers. This is important to avoid integer overflow when
8354 // we cast them to 'unsigned'.
8355 const unsigned char *StrLenPtr = (const unsigned char*) Str - 2;
8356 unsigned StrLen = (((unsigned) StrLenPtr[0])
8357 | (((unsigned) StrLenPtr[1]) << 8)) - 1;
8358 auto &II = PP.getIdentifierTable().get(StringRef(Str, StrLen));
8359 IdentifiersLoaded[ID] = &II;
8360 markIdentifierFromAST(*this, II);
8361 if (DeserializationListener)
8362 DeserializationListener->IdentifierRead(ID + 1, &II);
8363 }
8364
8365 return IdentifiersLoaded[ID];
8366 }
8367
8368 IdentifierInfo *ASTReader::getLocalIdentifier(ModuleFile &M, unsigned LocalID) {
8369 return DecodeIdentifierInfo(getGlobalIdentifierID(M, LocalID));
8370 }
8371
8372 IdentifierID ASTReader::getGlobalIdentifierID(ModuleFile &M, unsigned LocalID) {
8373 if (LocalID < NUM_PREDEF_IDENT_IDS)
8374 return LocalID;
8375
8376 if (!M.ModuleOffsetMap.empty())
8377 ReadModuleOffsetMap(M);
8378
8379 ContinuousRangeMap<uint32_t, int, 2>::iterator I
8380 = M.IdentifierRemap.find(LocalID - NUM_PREDEF_IDENT_IDS);
8381 assert(I != M.IdentifierRemap.end()
8382 && "Invalid index into identifier index remap");
8383
8384 return LocalID + I->second;
8385 }
8386
8387 MacroInfo *ASTReader::getMacro(MacroID ID) {
8388 if (ID == 0)
8389 return nullptr;
8390
8391 if (MacrosLoaded.empty()) {
8392 Error("no macro table in AST file");
8393 return nullptr;
8394 }
8395
8396 ID -= NUM_PREDEF_MACRO_IDS;
8397 if (!MacrosLoaded[ID]) {
8398 GlobalMacroMapType::iterator I
8399 = GlobalMacroMap.find(ID + NUM_PREDEF_MACRO_IDS);
8400 assert(I != GlobalMacroMap.end() && "Corrupted global macro map");
8401 ModuleFile *M = I->second;
8402 unsigned Index = ID - M->BaseMacroID;
8403 MacrosLoaded[ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]);
8404
8405 if (DeserializationListener)
8406 DeserializationListener->MacroRead(ID + NUM_PREDEF_MACRO_IDS,
8407 MacrosLoaded[ID]);
8408 }
8409
8410 return MacrosLoaded[ID];
8411 }
8412
8413 MacroID ASTReader::getGlobalMacroID(ModuleFile &M, unsigned LocalID) {
8414 if (LocalID < NUM_PREDEF_MACRO_IDS)
8415 return LocalID;
8416
8417 if (!M.ModuleOffsetMap.empty())
8418 ReadModuleOffsetMap(M);
8419
8420 ContinuousRangeMap<uint32_t, int, 2>::iterator I
8421 = M.MacroRemap.find(LocalID - NUM_PREDEF_MACRO_IDS);
8422 assert(I != M.MacroRemap.end() && "Invalid index into macro index remap");
8423
8424 return LocalID + I->second;
8425 }
8426
8427 serialization::SubmoduleID
8428 ASTReader::getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) {
8429 if (LocalID < NUM_PREDEF_SUBMODULE_IDS)
8430 return LocalID;
8431
8432 if (!M.ModuleOffsetMap.empty())
8433 ReadModuleOffsetMap(M);
8434
8435 ContinuousRangeMap<uint32_t, int, 2>::iterator I
8436 = M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS);
8437 assert(I != M.SubmoduleRemap.end()
8438 && "Invalid index into submodule index remap");
8439
8440 return LocalID + I->second;
8441 }
8442
8443 Module *ASTReader::getSubmodule(SubmoduleID GlobalID) {
8444 if (GlobalID < NUM_PREDEF_SUBMODULE_IDS) {
8445 assert(GlobalID == 0 && "Unhandled global submodule ID");
8446 return nullptr;
8447 }
8448
8449 if (GlobalID > SubmodulesLoaded.size()) {
8450 Error("submodule ID out of range in AST file");
8451 return nullptr;
8452 }
8453
8454 return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS];
8455 }
8456
8457 Module *ASTReader::getModule(unsigned ID) {
8458 return getSubmodule(ID);
8459 }
8460
8461 bool ASTReader::DeclIsFromPCHWithObjectFile(const Decl *D) {
8462 ModuleFile *MF = getOwningModuleFile(D);
8463 return MF && MF->PCHHasObjectFile;
8464 }
8465
8466 ModuleFile *ASTReader::getLocalModuleFile(ModuleFile &F, unsigned ID) {
8467 if (ID & 1) {
8468 // It's a module, look it up by submodule ID.
8469 auto I = GlobalSubmoduleMap.find(getGlobalSubmoduleID(F, ID >> 1));
8470 return I == GlobalSubmoduleMap.end() ? nullptr : I->second;
8471 } else {
8472 // It's a prefix (preamble, PCH, ...). Look it up by index.
8473 unsigned IndexFromEnd = ID >> 1;
8474 assert(IndexFromEnd && "got reference to unknown module file");
8475 return getModuleManager().pch_modules().end()[-IndexFromEnd];
8476 }
8477 }
8478
8479 unsigned ASTReader::getModuleFileID(ModuleFile *F) {
8480 if (!F)
8481 return 1;
8482
8483 // For a file representing a module, use the submodule ID of the top-level
8484 // module as the file ID. For any other kind of file, the number of such
8485 // files loaded beforehand will be the same on reload.
8486 // FIXME: Is this true even if we have an explicit module file and a PCH?
8487 if (F->isModule())
8488 return ((F->BaseSubmoduleID + NUM_PREDEF_SUBMODULE_IDS) << 1) | 1;
8489
8490 auto PCHModules = getModuleManager().pch_modules();
8491 auto I = llvm::find(PCHModules, F);
8492 assert(I != PCHModules.end() && "emitting reference to unknown file");
8493 return (I - PCHModules.end()) << 1;
8494 }
8495
8496 llvm::Optional<ExternalASTSource::ASTSourceDescriptor>
8497 ASTReader::getSourceDescriptor(unsigned ID) {
8498 if (const Module *M = getSubmodule(ID))
8499 return ExternalASTSource::ASTSourceDescriptor(*M);
8500
8501 // If there is only a single PCH, return it instead.
8502 // Chained PCH are not supported.
8503 const auto &PCHChain = ModuleMgr.pch_modules();
8504 if (std::distance(std::begin(PCHChain), std::end(PCHChain))) {
8505 ModuleFile &MF = ModuleMgr.getPrimaryModule();
8506 StringRef ModuleName = llvm::sys::path::filename(MF.OriginalSourceFileName);
8507 StringRef FileName = llvm::sys::path::filename(MF.FileName);
8508 return ASTReader::ASTSourceDescriptor(ModuleName, MF.OriginalDir, FileName,
8509 MF.Signature);
8510 }
8511 return None;
8512 }
8513
8514 ExternalASTSource::ExtKind ASTReader::hasExternalDefinitions(const Decl *FD) {
8515 auto I = DefinitionSource.find(FD);
8516 if (I == DefinitionSource.end())
8517 return EK_ReplyHazy;
8518 return I->second ? EK_Never : EK_Always;
8519 }
8520
8521 Selector ASTReader::getLocalSelector(ModuleFile &M, unsigned LocalID) {
8522 return DecodeSelector(getGlobalSelectorID(M, LocalID));
8523 }
8524
8525 Selector ASTReader::DecodeSelector(serialization::SelectorID ID) {
8526 if (ID == 0)
8527 return Selector();
8528
8529 if (ID > SelectorsLoaded.size()) {
8530 Error("selector ID out of range in AST file");
8531 return Selector();
8532 }
8533
8534 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() == nullptr) {
8535 // Load this selector from the selector table.
8536 GlobalSelectorMapType::iterator I = GlobalSelectorMap.find(ID);
8537 assert(I != GlobalSelectorMap.end() && "Corrupted global selector map");
8538 ModuleFile &M = *I->second;
8539 ASTSelectorLookupTrait Trait(*this, M);
8540 unsigned Idx = ID - M.BaseSelectorID - NUM_PREDEF_SELECTOR_IDS;
8541 SelectorsLoaded[ID - 1] =
8542 Trait.ReadKey(M.SelectorLookupTableData + M.SelectorOffsets[Idx], 0);
8543 if (DeserializationListener)
8544 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
8545 }
8546
8547 return SelectorsLoaded[ID - 1];
8548 }
8549
8550 Selector ASTReader::GetExternalSelector(serialization::SelectorID ID) {
8551 return DecodeSelector(ID);
8552 }
8553
8554 uint32_t ASTReader::GetNumExternalSelectors() {
8555 // ID 0 (the null selector) is considered an external selector.
8556 return getTotalNumSelectors() + 1;
8557 }
8558
8559 serialization::SelectorID
8560 ASTReader::getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const {
8561 if (LocalID < NUM_PREDEF_SELECTOR_IDS)
8562 return LocalID;
8563
8564 if (!M.ModuleOffsetMap.empty())
8565 ReadModuleOffsetMap(M);
8566
8567 ContinuousRangeMap<uint32_t, int, 2>::iterator I
8568 = M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS);
8569 assert(I != M.SelectorRemap.end()
8570 && "Invalid index into selector index remap");
8571
8572 return LocalID + I->second;
8573 }
8574
8575 DeclarationNameLoc
8576 ASTRecordReader::readDeclarationNameLoc(DeclarationName Name) {
8577 DeclarationNameLoc DNLoc;
8578 switch (Name.getNameKind()) {
8579 case DeclarationName::CXXConstructorName:
8580 case DeclarationName::CXXDestructorName:
8581 case DeclarationName::CXXConversionFunctionName:
8582 DNLoc.NamedType.TInfo = readTypeSourceInfo();
8583 break;
8584
8585 case DeclarationName::CXXOperatorName:
8586 DNLoc.CXXOperatorName.BeginOpNameLoc
8587 = readSourceLocation().getRawEncoding();
8588 DNLoc.CXXOperatorName.EndOpNameLoc
8589 = readSourceLocation().getRawEncoding();
8590 break;
8591
8592 case DeclarationName::CXXLiteralOperatorName:
8593 DNLoc.CXXLiteralOperatorName.OpNameLoc
8594 = readSourceLocation().getRawEncoding();
8595 break;
8596
8597 case DeclarationName::Identifier:
8598 case DeclarationName::ObjCZeroArgSelector:
8599 case DeclarationName::ObjCOneArgSelector:
8600 case DeclarationName::ObjCMultiArgSelector:
8601 case DeclarationName::CXXUsingDirective:
8602 case DeclarationName::CXXDeductionGuideName:
8603 break;
8604 }
8605 return DNLoc;
8606 }
8607
8608 DeclarationNameInfo ASTRecordReader::readDeclarationNameInfo() {
8609 DeclarationNameInfo NameInfo;
8610 NameInfo.setName(readDeclarationName());
8611 NameInfo.setLoc(readSourceLocation());
8612 NameInfo.setInfo(readDeclarationNameLoc(NameInfo.getName()));
8613 return NameInfo;
8614 }
8615
8616 void ASTRecordReader::readQualifierInfo(QualifierInfo &Info) {
8617 Info.QualifierLoc = readNestedNameSpecifierLoc();
8618 unsigned NumTPLists = readInt();
8619 Info.NumTemplParamLists = NumTPLists;
8620 if (NumTPLists) {
8621 Info.TemplParamLists =
8622 new (getContext()) TemplateParameterList *[NumTPLists];
8623 for (unsigned i = 0; i != NumTPLists; ++i)
8624 Info.TemplParamLists[i] = readTemplateParameterList();
8625 }
8626 }
8627
8628 TemplateParameterList *
8629 ASTRecordReader::readTemplateParameterList() {
8630 SourceLocation TemplateLoc = readSourceLocation();
8631 SourceLocation LAngleLoc = readSourceLocation();
8632 SourceLocation RAngleLoc = readSourceLocation();
8633
8634 unsigned NumParams = readInt();
8635 SmallVector<NamedDecl *, 16> Params;
8636 Params.reserve(NumParams);
8637 while (NumParams--)
8638 Params.push_back(readDeclAs<NamedDecl>());
8639
8640 bool HasRequiresClause = readBool();
8641 Expr *RequiresClause = HasRequiresClause ? readExpr() : nullptr;
8642
8643 TemplateParameterList *TemplateParams = TemplateParameterList::Create(
8644 getContext(), TemplateLoc, LAngleLoc, Params, RAngleLoc, RequiresClause);
8645 return TemplateParams;
8646 }
8647
8648 void ASTRecordReader::readTemplateArgumentList(
8649 SmallVectorImpl<TemplateArgument> &TemplArgs,
8650 bool Canonicalize) {
8651 unsigned NumTemplateArgs = readInt();
8652 TemplArgs.reserve(NumTemplateArgs);
8653 while (NumTemplateArgs--)
8654 TemplArgs.push_back(readTemplateArgument(Canonicalize));
8655 }
8656
8657 /// Read a UnresolvedSet structure.
8658 void ASTRecordReader::readUnresolvedSet(LazyASTUnresolvedSet &Set) {
8659 unsigned NumDecls = readInt();
8660 Set.reserve(getContext(), NumDecls);
8661 while (NumDecls--) {
8662 DeclID ID = readDeclID();
8663 AccessSpecifier AS = (AccessSpecifier) readInt();
8664 Set.addLazyDecl(getContext(), ID, AS);
8665 }
8666 }
8667
8668 CXXBaseSpecifier
8669 ASTRecordReader::readCXXBaseSpecifier() {
8670 bool isVirtual = readBool();
8671 bool isBaseOfClass = readBool();
8672 AccessSpecifier AS = static_cast<AccessSpecifier>(readInt());
8673 bool inheritConstructors = readBool();
8674 TypeSourceInfo *TInfo = readTypeSourceInfo();
8675 SourceRange Range = readSourceRange();
8676 SourceLocation EllipsisLoc = readSourceLocation();
8677 CXXBaseSpecifier Result(Range, isVirtual, isBaseOfClass, AS, TInfo,
8678 EllipsisLoc);
8679 Result.setInheritConstructors(inheritConstructors);
8680 return Result;
8681 }
8682
8683 CXXCtorInitializer **
8684 ASTRecordReader::readCXXCtorInitializers() {
8685 ASTContext &Context = getContext();
8686 unsigned NumInitializers = readInt();
8687 assert(NumInitializers && "wrote ctor initializers but have no inits");
8688 auto **CtorInitializers = new (Context) CXXCtorInitializer*[NumInitializers];
8689 for (unsigned i = 0; i != NumInitializers; ++i) {
8690 TypeSourceInfo *TInfo = nullptr;
8691 bool IsBaseVirtual = false;
8692 FieldDecl *Member = nullptr;
8693 IndirectFieldDecl *IndirectMember = nullptr;
8694
8695 CtorInitializerType Type = (CtorInitializerType) readInt();
8696 switch (Type) {
8697 case CTOR_INITIALIZER_BASE:
8698 TInfo = readTypeSourceInfo();
8699 IsBaseVirtual = readBool();
8700 break;
8701
8702 case CTOR_INITIALIZER_DELEGATING:
8703 TInfo = readTypeSourceInfo();
8704 break;
8705
8706 case CTOR_INITIALIZER_MEMBER:
8707 Member = readDeclAs<FieldDecl>();
8708 break;
8709
8710 case CTOR_INITIALIZER_INDIRECT_MEMBER:
8711 IndirectMember = readDeclAs<IndirectFieldDecl>();
8712 break;
8713 }
8714
8715 SourceLocation MemberOrEllipsisLoc = readSourceLocation();
8716 Expr *Init = readExpr();
8717 SourceLocation LParenLoc = readSourceLocation();
8718 SourceLocation RParenLoc = readSourceLocation();
8719
8720 CXXCtorInitializer *BOMInit;
8721 if (Type == CTOR_INITIALIZER_BASE)
8722 BOMInit = new (Context)
8723 CXXCtorInitializer(Context, TInfo, IsBaseVirtual, LParenLoc, Init,
8724 RParenLoc, MemberOrEllipsisLoc);
8725 else if (Type == CTOR_INITIALIZER_DELEGATING)
8726 BOMInit = new (Context)
8727 CXXCtorInitializer(Context, TInfo, LParenLoc, Init, RParenLoc);
8728 else if (Member)
8729 BOMInit = new (Context)
8730 CXXCtorInitializer(Context, Member, MemberOrEllipsisLoc, LParenLoc,
8731 Init, RParenLoc);
8732 else
8733 BOMInit = new (Context)
8734 CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
8735 LParenLoc, Init, RParenLoc);
8736
8737 if (/*IsWritten*/readBool()) {
8738 unsigned SourceOrder = readInt();
8739 BOMInit->setSourceOrder(SourceOrder);
8740 }
8741
8742 CtorInitializers[i] = BOMInit;
8743 }
8744
8745 return CtorInitializers;
8746 }
8747
8748 NestedNameSpecifierLoc
8749 ASTRecordReader::readNestedNameSpecifierLoc() {
8750 ASTContext &Context = getContext();
8751 unsigned N = readInt();
8752 NestedNameSpecifierLocBuilder Builder;
8753 for (unsigned I = 0; I != N; ++I) {
8754 auto Kind = readNestedNameSpecifierKind();
8755 switch (Kind) {
8756 case NestedNameSpecifier::Identifier: {
8757 IdentifierInfo *II = readIdentifier();
8758 SourceRange Range = readSourceRange();
8759 Builder.Extend(Context, II, Range.getBegin(), Range.getEnd());
8760 break;
8761 }
8762
8763 case NestedNameSpecifier::Namespace: {
8764 NamespaceDecl *NS = readDeclAs<NamespaceDecl>();
8765 SourceRange Range = readSourceRange();
8766 Builder.Extend(Context, NS, Range.getBegin(), Range.getEnd());
8767 break;
8768 }
8769
8770 case NestedNameSpecifier::NamespaceAlias: {
8771 NamespaceAliasDecl *Alias = readDeclAs<NamespaceAliasDecl>();
8772 SourceRange Range = readSourceRange();
8773 Builder.Extend(Context, Alias, Range.getBegin(), Range.getEnd());
8774 break;
8775 }
8776
8777 case NestedNameSpecifier::TypeSpec:
8778 case NestedNameSpecifier::TypeSpecWithTemplate: {
8779 bool Template = readBool();
8780 TypeSourceInfo *T = readTypeSourceInfo();
8781 if (!T)
8782 return NestedNameSpecifierLoc();
8783 SourceLocation ColonColonLoc = readSourceLocation();
8784
8785 // FIXME: 'template' keyword location not saved anywhere, so we fake it.
8786 Builder.Extend(Context,
8787 Template? T->getTypeLoc().getBeginLoc() : SourceLocation(),
8788 T->getTypeLoc(), ColonColonLoc);
8789 break;
8790 }
8791
8792 case NestedNameSpecifier::Global: {
8793 SourceLocation ColonColonLoc = readSourceLocation();
8794 Builder.MakeGlobal(Context, ColonColonLoc);
8795 break;
8796 }
8797
8798 case NestedNameSpecifier::Super: {
8799 CXXRecordDecl *RD = readDeclAs<CXXRecordDecl>();
8800 SourceRange Range = readSourceRange();
8801 Builder.MakeSuper(Context, RD, Range.getBegin(), Range.getEnd());
8802 break;
8803 }
8804 }
8805 }
8806
8807 return Builder.getWithLocInContext(Context);
8808 }
8809
8810 SourceRange
8811 ASTReader::ReadSourceRange(ModuleFile &F, const RecordData &Record,
8812 unsigned &Idx) {
8813 SourceLocation beg = ReadSourceLocation(F, Record, Idx);
8814 SourceLocation end = ReadSourceLocation(F, Record, Idx);
8815 return SourceRange(beg, end);
8816 }
8817
8818 static FixedPointSemantics
8819 ReadFixedPointSemantics(const SmallVectorImpl<uint64_t> &Record,
8820 unsigned &Idx) {
8821 unsigned Width = Record[Idx++];
8822 unsigned Scale = Record[Idx++];
8823 uint64_t Tmp = Record[Idx++];
8824 bool IsSigned = Tmp & 0x1;
8825 bool IsSaturated = Tmp & 0x2;
8826 bool HasUnsignedPadding = Tmp & 0x4;
8827 return FixedPointSemantics(Width, Scale, IsSigned, IsSaturated,
8828 HasUnsignedPadding);
8829 }
8830
8831 static const llvm::fltSemantics &
8832 readAPFloatSemantics(ASTRecordReader &reader) {
8833 return llvm::APFloatBase::EnumToSemantics(
8834 static_cast<llvm::APFloatBase::Semantics>(reader.readInt()));
8835 }
8836
8837 APValue ASTRecordReader::readAPValue() {
8838 unsigned Kind = readInt();
8839 switch ((APValue::ValueKind) Kind) {
8840 case APValue::None:
8841 return APValue();
8842 case APValue::Indeterminate:
8843 return APValue::IndeterminateValue();
8844 case APValue::Int:
8845 return APValue(readAPSInt());
8846 case APValue::Float: {
8847 const llvm::fltSemantics &FloatSema = readAPFloatSemantics(*this);
8848 return APValue(readAPFloat(FloatSema));
8849 }
8850 case APValue::FixedPoint: {
8851 FixedPointSemantics FPSema = ReadFixedPointSemantics(Record, Idx);
8852 return APValue(APFixedPoint(readAPInt(), FPSema));
8853 }
8854 case APValue::ComplexInt: {
8855 llvm::APSInt First = readAPSInt();
8856 return APValue(std::move(First), readAPSInt());
8857 }
8858 case APValue::ComplexFloat: {
8859 const llvm::fltSemantics &FloatSema1 = readAPFloatSemantics(*this);
8860 llvm::APFloat First = readAPFloat(FloatSema1);
8861 const llvm::fltSemantics &FloatSema2 = readAPFloatSemantics(*this);
8862 return APValue(std::move(First), readAPFloat(FloatSema2));
8863 }
8864 case APValue::LValue:
8865 case APValue::Vector:
8866 case APValue::Array:
8867 case APValue::Struct:
8868 case APValue::Union:
8869 case APValue::MemberPointer:
8870 case APValue::AddrLabelDiff:
8871 // TODO : Handle all these APValue::ValueKind.
8872 return APValue();
8873 }
8874 llvm_unreachable("Invalid APValue::ValueKind");
8875 }
8876
8877 /// Read a floating-point value
8878 llvm::APFloat ASTRecordReader::readAPFloat(const llvm::fltSemantics &Sem) {
8879 return llvm::APFloat(Sem, readAPInt());
8880 }
8881
8882 // Read a string
8883 std::string ASTReader::ReadString(const RecordData &Record, unsigned &Idx) {
8884 unsigned Len = Record[Idx++];
8885 std::string Result(Record.data() + Idx, Record.data() + Idx + Len);
8886 Idx += Len;
8887 return Result;
8888 }
8889
8890 std::string ASTReader::ReadPath(ModuleFile &F, const RecordData &Record,
8891 unsigned &Idx) {
8892 std::string Filename = ReadString(Record, Idx);
8893 ResolveImportedPath(F, Filename);
8894 return Filename;
8895 }
8896
8897 std::string ASTReader::ReadPath(StringRef BaseDirectory,
8898 const RecordData &Record, unsigned &Idx) {
8899 std::string Filename = ReadString(Record, Idx);
8900 if (!BaseDirectory.empty())
8901 ResolveImportedPath(Filename, BaseDirectory);
8902 return Filename;
8903 }
8904
8905 VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record,
8906 unsigned &Idx) {
8907 unsigned Major = Record[Idx++];
8908 unsigned Minor = Record[Idx++];
8909 unsigned Subminor = Record[Idx++];
8910 if (Minor == 0)
8911 return VersionTuple(Major);
8912 if (Subminor == 0)
8913 return VersionTuple(Major, Minor - 1);
8914 return VersionTuple(Major, Minor - 1, Subminor - 1);
8915 }
8916
8917 CXXTemporary *ASTReader::ReadCXXTemporary(ModuleFile &F,
8918 const RecordData &Record,
8919 unsigned &Idx) {
8920 CXXDestructorDecl *Decl = ReadDeclAs<CXXDestructorDecl>(F, Record, Idx);
8921 return CXXTemporary::Create(getContext(), Decl);
8922 }
8923
8924 DiagnosticBuilder ASTReader::Diag(unsigned DiagID) const {
8925 return Diag(CurrentImportLoc, DiagID);
8926 }
8927
8928 DiagnosticBuilder ASTReader::Diag(SourceLocation Loc, unsigned DiagID) const {
8929 return Diags.Report(Loc, DiagID);
8930 }
8931
8932 /// Retrieve the identifier table associated with the
8933 /// preprocessor.
8934 IdentifierTable &ASTReader::getIdentifierTable() {
8935 return PP.getIdentifierTable();
8936 }
8937
8938 /// Record that the given ID maps to the given switch-case
8939 /// statement.
8940 void ASTReader::RecordSwitchCaseID(SwitchCase *SC, unsigned ID) {
8941 assert((*CurrSwitchCaseStmts)[ID] == nullptr &&
8942 "Already have a SwitchCase with this ID");
8943 (*CurrSwitchCaseStmts)[ID] = SC;
8944 }
8945
8946 /// Retrieve the switch-case statement with the given ID.
8947 SwitchCase *ASTReader::getSwitchCaseWithID(unsigned ID) {
8948 assert((*CurrSwitchCaseStmts)[ID] != nullptr && "No SwitchCase with this ID");
8949 return (*CurrSwitchCaseStmts)[ID];
8950 }
8951
8952 void ASTReader::ClearSwitchCaseIDs() {
8953 CurrSwitchCaseStmts->clear();
8954 }
8955
8956 void ASTReader::ReadComments() {
8957 ASTContext &Context = getContext();
8958 std::vector<RawComment *> Comments;
8959 for (SmallVectorImpl<std::pair<BitstreamCursor,
8960 serialization::ModuleFile *>>::iterator
8961 I = CommentsCursors.begin(),
8962 E = CommentsCursors.end();
8963 I != E; ++I) {
8964 Comments.clear();
8965 BitstreamCursor &Cursor = I->first;
8966 serialization::ModuleFile &F = *I->second;
8967 SavedStreamPosition SavedPosition(Cursor);
8968
8969 RecordData Record;
8970 while (true) {
8971 Expected<llvm::BitstreamEntry> MaybeEntry =
8972 Cursor.advanceSkippingSubblocks(
8973 BitstreamCursor::AF_DontPopBlockAtEnd);
8974 if (!MaybeEntry) {
8975 Error(MaybeEntry.takeError());
8976 return;
8977 }
8978 llvm::BitstreamEntry Entry = MaybeEntry.get();
8979
8980 switch (Entry.Kind) {
8981 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
8982 case llvm::BitstreamEntry::Error:
8983 Error("malformed block record in AST file");
8984 return;
8985 case llvm::BitstreamEntry::EndBlock:
8986 goto NextCursor;
8987 case llvm::BitstreamEntry::Record:
8988 // The interesting case.
8989 break;
8990 }
8991
8992 // Read a record.
8993 Record.clear();
8994 Expected<unsigned> MaybeComment = Cursor.readRecord(Entry.ID, Record);
8995 if (!MaybeComment) {
8996 Error(MaybeComment.takeError());
8997 return;
8998 }
8999 switch ((CommentRecordTypes)MaybeComment.get()) {
9000 case COMMENTS_RAW_COMMENT: {
9001 unsigned Idx = 0;
9002 SourceRange SR = ReadSourceRange(F, Record, Idx);
9003 RawComment::CommentKind Kind =
9004 (RawComment::CommentKind) Record[Idx++];
9005 bool IsTrailingComment = Record[Idx++];
9006 bool IsAlmostTrailingComment = Record[Idx++];
9007 Comments.push_back(new (Context) RawComment(
9008 SR, Kind, IsTrailingComment, IsAlmostTrailingComment));
9009 break;
9010 }
9011 }
9012 }
9013 NextCursor:
9014 llvm::DenseMap<FileID, std::map<unsigned, RawComment *>>
9015 FileToOffsetToComment;
9016 for (RawComment *C : Comments) {
9017 SourceLocation CommentLoc = C->getBeginLoc();
9018 if (CommentLoc.isValid()) {
9019 std::pair<FileID, unsigned> Loc =
9020 SourceMgr.getDecomposedLoc(CommentLoc);
9021 if (Loc.first.isValid())
9022 Context.Comments.OrderedComments[Loc.first].emplace(Loc.second, C);
9023 }
9024 }
9025 }
9026 }
9027
9028 void ASTReader::visitInputFiles(serialization::ModuleFile &MF,
9029 bool IncludeSystem, bool Complain,
9030 llvm::function_ref<void(const serialization::InputFile &IF,
9031 bool isSystem)> Visitor) {
9032 unsigned NumUserInputs = MF.NumUserInputFiles;
9033 unsigned NumInputs = MF.InputFilesLoaded.size();
9034 assert(NumUserInputs <= NumInputs);
9035 unsigned N = IncludeSystem ? NumInputs : NumUserInputs;
9036 for (unsigned I = 0; I < N; ++I) {
9037 bool IsSystem = I >= NumUserInputs;
9038 InputFile IF = getInputFile(MF, I+1, Complain);
9039 Visitor(IF, IsSystem);
9040 }
9041 }
9042
9043 void ASTReader::visitTopLevelModuleMaps(
9044 serialization::ModuleFile &MF,
9045 llvm::function_ref<void(const FileEntry *FE)> Visitor) {
9046 unsigned NumInputs = MF.InputFilesLoaded.size();
9047 for (unsigned I = 0; I < NumInputs; ++I) {
9048 InputFileInfo IFI = readInputFileInfo(MF, I + 1);
9049 if (IFI.TopLevelModuleMap)
9050 // FIXME: This unnecessarily re-reads the InputFileInfo.
9051 if (auto *FE = getInputFile(MF, I + 1).getFile())
9052 Visitor(FE);
9053 }
9054 }
9055
9056 std::string ASTReader::getOwningModuleNameForDiagnostic(const Decl *D) {
9057 // If we know the owning module, use it.
9058 if (Module *M = D->getImportedOwningModule())
9059 return M->getFullModuleName();
9060
9061 // Otherwise, use the name of the top-level module the decl is within.
9062 if (ModuleFile *M = getOwningModuleFile(D))
9063 return M->ModuleName;
9064
9065 // Not from a module.
9066 return {};
9067 }
9068
9069 void ASTReader::finishPendingActions() {
9070 while (!PendingIdentifierInfos.empty() || !PendingFunctionTypes.empty() ||
9071 !PendingIncompleteDeclChains.empty() || !PendingDeclChains.empty() ||
9072 !PendingMacroIDs.empty() || !PendingDeclContextInfos.empty() ||
9073 !PendingUpdateRecords.empty()) {
9074 // If any identifiers with corresponding top-level declarations have
9075 // been loaded, load those declarations now.
9076 using TopLevelDeclsMap =
9077 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
9078 TopLevelDeclsMap TopLevelDecls;
9079
9080 while (!PendingIdentifierInfos.empty()) {
9081 IdentifierInfo *II = PendingIdentifierInfos.back().first;
9082 SmallVector<uint32_t, 4> DeclIDs =
9083 std::move(PendingIdentifierInfos.back().second);
9084 PendingIdentifierInfos.pop_back();
9085
9086 SetGloballyVisibleDecls(II, DeclIDs, &TopLevelDecls[II]);
9087 }
9088
9089 // Load each function type that we deferred loading because it was a
9090 // deduced type that might refer to a local type declared within itself.
9091 for (unsigned I = 0; I != PendingFunctionTypes.size(); ++I) {
9092 auto *FD = PendingFunctionTypes[I].first;
9093 FD->setType(GetType(PendingFunctionTypes[I].second));
9094
9095 // If we gave a function a deduced return type, remember that we need to
9096 // propagate that along the redeclaration chain.
9097 auto *DT = FD->getReturnType()->getContainedDeducedType();
9098 if (DT && DT->isDeduced())
9099 PendingDeducedTypeUpdates.insert(
9100 {FD->getCanonicalDecl(), FD->getReturnType()});
9101 }
9102 PendingFunctionTypes.clear();
9103
9104 // For each decl chain that we wanted to complete while deserializing, mark
9105 // it as "still needs to be completed".
9106 for (unsigned I = 0; I != PendingIncompleteDeclChains.size(); ++I) {
9107 markIncompleteDeclChain(PendingIncompleteDeclChains[I]);
9108 }
9109 PendingIncompleteDeclChains.clear();
9110
9111 // Load pending declaration chains.
9112 for (unsigned I = 0; I != PendingDeclChains.size(); ++I)
9113 loadPendingDeclChain(PendingDeclChains[I].first,
9114 PendingDeclChains[I].second);
9115 PendingDeclChains.clear();
9116
9117 // Make the most recent of the top-level declarations visible.
9118 for (TopLevelDeclsMap::iterator TLD = TopLevelDecls.begin(),
9119 TLDEnd = TopLevelDecls.end(); TLD != TLDEnd; ++TLD) {
9120 IdentifierInfo *II = TLD->first;
9121 for (unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
9122 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
9123 }
9124 }
9125
9126 // Load any pending macro definitions.
9127 for (unsigned I = 0; I != PendingMacroIDs.size(); ++I) {
9128 IdentifierInfo *II = PendingMacroIDs.begin()[I].first;
9129 SmallVector<PendingMacroInfo, 2> GlobalIDs;
9130 GlobalIDs.swap(PendingMacroIDs.begin()[I].second);
9131 // Initialize the macro history from chained-PCHs ahead of module imports.
9132 for (unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9133 ++IDIdx) {
9134 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9135 if (!Info.M->isModule())
9136 resolvePendingMacro(II, Info);
9137 }
9138 // Handle module imports.
9139 for (unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
9140 ++IDIdx) {
9141 const PendingMacroInfo &Info = GlobalIDs[IDIdx];
9142 if (Info.M->isModule())
9143 resolvePendingMacro(II, Info);
9144 }
9145 }
9146 PendingMacroIDs.clear();
9147
9148 // Wire up the DeclContexts for Decls that we delayed setting until
9149 // recursive loading is completed.
9150 while (!PendingDeclContextInfos.empty()) {
9151 PendingDeclContextInfo Info = PendingDeclContextInfos.front();
9152 PendingDeclContextInfos.pop_front();
9153 DeclContext *SemaDC = cast<DeclContext>(GetDecl(Info.SemaDC));
9154 DeclContext *LexicalDC = cast<DeclContext>(GetDecl(Info.LexicalDC));
9155 Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
9156 }
9157
9158 // Perform any pending declaration updates.
9159 while (!PendingUpdateRecords.empty()) {
9160 auto Update = PendingUpdateRecords.pop_back_val();
9161 ReadingKindTracker ReadingKind(Read_Decl, *this);
9162 loadDeclUpdateRecords(Update);
9163 }
9164 }
9165
9166 // At this point, all update records for loaded decls are in place, so any
9167 // fake class definitions should have become real.
9168 assert(PendingFakeDefinitionData.empty() &&
9169 "faked up a class definition but never saw the real one");
9170
9171 // If we deserialized any C++ or Objective-C class definitions, any
9172 // Objective-C protocol definitions, or any redeclarable templates, make sure
9173 // that all redeclarations point to the definitions. Note that this can only
9174 // happen now, after the redeclaration chains have been fully wired.
9175 for (Decl *D : PendingDefinitions) {
9176 if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
9177 if (const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
9178 // Make sure that the TagType points at the definition.
9179 const_cast<TagType*>(TagT)->decl = TD;
9180 }
9181
9182 if (auto RD = dyn_cast<CXXRecordDecl>(D)) {
9183 for (auto *R = getMostRecentExistingDecl(RD); R;
9184 R = R->getPreviousDecl()) {
9185 assert((R == D) ==
9186 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
9187 "declaration thinks it's the definition but it isn't");
9188 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
9189 }
9190 }
9191
9192 continue;
9193 }
9194
9195 if (auto ID = dyn_cast<ObjCInterfaceDecl>(D)) {
9196 // Make sure that the ObjCInterfaceType points at the definition.
9197 const_cast<ObjCInterfaceType *>(cast<ObjCInterfaceType>(ID->TypeForDecl))
9198 ->Decl = ID;
9199
9200 for (auto *R = getMostRecentExistingDecl(ID); R; R = R->getPreviousDecl())
9201 cast<ObjCInterfaceDecl>(R)->Data = ID->Data;
9202
9203 continue;
9204 }
9205
9206 if (auto PD = dyn_cast<ObjCProtocolDecl>(D)) {
9207 for (auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
9208 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
9209
9210 continue;
9211 }
9212
9213 auto RTD = cast<RedeclarableTemplateDecl>(D)->getCanonicalDecl();
9214 for (auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
9215 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
9216 }
9217 PendingDefinitions.clear();
9218
9219 // Load the bodies of any functions or methods we've encountered. We do
9220 // this now (delayed) so that we can be sure that the declaration chains
9221 // have been fully wired up (hasBody relies on this).
9222 // FIXME: We shouldn't require complete redeclaration chains here.
9223 for (PendingBodiesMap::iterator PB = PendingBodies.begin(),
9224 PBEnd = PendingBodies.end();
9225 PB != PBEnd; ++PB) {
9226 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
9227 // For a function defined inline within a class template, force the
9228 // canonical definition to be the one inside the canonical definition of
9229 // the template. This ensures that we instantiate from a correct view
9230 // of the template.
9231 //
9232 // Sadly we can't do this more generally: we can't be sure that all
9233 // copies of an arbitrary class definition will have the same members
9234 // defined (eg, some member functions may not be instantiated, and some
9235 // special members may or may not have been implicitly defined).
9236 if (auto *RD = dyn_cast<CXXRecordDecl>(FD->getLexicalParent()))
9237 if (RD->isDependentContext() && !RD->isThisDeclarationADefinition())
9238 continue;
9239
9240 // FIXME: Check for =delete/=default?
9241 // FIXME: Complain about ODR violations here?
9242 const FunctionDecl *Defn = nullptr;
9243 if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
9244 FD->setLazyBody(PB->second);
9245 } else {
9246 auto *NonConstDefn = const_cast<FunctionDecl*>(Defn);
9247 mergeDefinitionVisibility(NonConstDefn, FD);
9248
9249 if (!FD->isLateTemplateParsed() &&
9250 !NonConstDefn->isLateTemplateParsed() &&
9251 FD->getODRHash() != NonConstDefn->getODRHash()) {
9252 if (!isa<CXXMethodDecl>(FD)) {
9253 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9254 } else if (FD->getLexicalParent()->isFileContext() &&
9255 NonConstDefn->getLexicalParent()->isFileContext()) {
9256 // Only diagnose out-of-line method definitions. If they are
9257 // in class definitions, then an error will be generated when
9258 // processing the class bodies.
9259 PendingFunctionOdrMergeFailures[FD].push_back(NonConstDefn);
9260 }
9261 }
9262 }
9263 continue;
9264 }
9265
9266 ObjCMethodDecl *MD = cast<ObjCMethodDecl>(PB->first);
9267 if (!getContext().getLangOpts().Modules || !MD->hasBody())
9268 MD->setLazyBody(PB->second);
9269 }
9270 PendingBodies.clear();
9271
9272 // Do some cleanup.
9273 for (auto *ND : PendingMergedDefinitionsToDeduplicate)
9274 getContext().deduplicateMergedDefinitonsFor(ND);
9275 PendingMergedDefinitionsToDeduplicate.clear();
9276 }
9277
9278 void ASTReader::diagnoseOdrViolations() {
9279 if (PendingOdrMergeFailures.empty() && PendingOdrMergeChecks.empty() &&
9280 PendingFunctionOdrMergeFailures.empty() &&
9281 PendingEnumOdrMergeFailures.empty())
9282 return;
9283
9284 // Trigger the import of the full definition of each class that had any
9285 // odr-merging problems, so we can produce better diagnostics for them.
9286 // These updates may in turn find and diagnose some ODR failures, so take
9287 // ownership of the set first.
9288 auto OdrMergeFailures = std::move(PendingOdrMergeFailures);
9289 PendingOdrMergeFailures.clear();
9290 for (auto &Merge : OdrMergeFailures) {
9291 Merge.first->buildLookup();
9292 Merge.first->decls_begin();
9293 Merge.first->bases_begin();
9294 Merge.first->vbases_begin();
9295 for (auto &RecordPair : Merge.second) {
9296 auto *RD = RecordPair.first;
9297 RD->decls_begin();
9298 RD->bases_begin();
9299 RD->vbases_begin();
9300 }
9301 }
9302
9303 // Trigger the import of functions.
9304 auto FunctionOdrMergeFailures = std::move(PendingFunctionOdrMergeFailures);
9305 PendingFunctionOdrMergeFailures.clear();
9306 for (auto &Merge : FunctionOdrMergeFailures) {
9307 Merge.first->buildLookup();
9308 Merge.first->decls_begin();
9309 Merge.first->getBody();
9310 for (auto &FD : Merge.second) {
9311 FD->buildLookup();
9312 FD->decls_begin();
9313 FD->getBody();
9314 }
9315 }
9316
9317 // Trigger the import of enums.
9318 auto EnumOdrMergeFailures = std::move(PendingEnumOdrMergeFailures);
9319 PendingEnumOdrMergeFailures.clear();
9320 for (auto &Merge : EnumOdrMergeFailures) {
9321 Merge.first->decls_begin();
9322 for (auto &Enum : Merge.second) {
9323 Enum->decls_begin();
9324 }
9325 }
9326
9327 // For each declaration from a merged context, check that the canonical
9328 // definition of that context also contains a declaration of the same
9329 // entity.
9330 //
9331 // Caution: this loop does things that might invalidate iterators into
9332 // PendingOdrMergeChecks. Don't turn this into a range-based for loop!
9333 while (!PendingOdrMergeChecks.empty()) {
9334 NamedDecl *D = PendingOdrMergeChecks.pop_back_val();
9335
9336 // FIXME: Skip over implicit declarations for now. This matters for things
9337 // like implicitly-declared special member functions. This isn't entirely
9338 // correct; we can end up with multiple unmerged declarations of the same
9339 // implicit entity.
9340 if (D->isImplicit())
9341 continue;
9342
9343 DeclContext *CanonDef = D->getDeclContext();
9344
9345 bool Found = false;
9346 const Decl *DCanon = D->getCanonicalDecl();
9347
9348 for (auto RI : D->redecls()) {
9349 if (RI->getLexicalDeclContext() == CanonDef) {
9350 Found = true;
9351 break;
9352 }
9353 }
9354 if (Found)
9355 continue;
9356
9357 // Quick check failed, time to do the slow thing. Note, we can't just
9358 // look up the name of D in CanonDef here, because the member that is
9359 // in CanonDef might not be found by name lookup (it might have been
9360 // replaced by a more recent declaration in the lookup table), and we
9361 // can't necessarily find it in the redeclaration chain because it might
9362 // be merely mergeable, not redeclarable.
9363 llvm::SmallVector<const NamedDecl*, 4> Candidates;
9364 for (auto *CanonMember : CanonDef->decls()) {
9365 if (CanonMember->getCanonicalDecl() == DCanon) {
9366 // This can happen if the declaration is merely mergeable and not
9367 // actually redeclarable (we looked for redeclarations earlier).
9368 //
9369 // FIXME: We should be able to detect this more efficiently, without
9370 // pulling in all of the members of CanonDef.
9371 Found = true;
9372 break;
9373 }
9374 if (auto *ND = dyn_cast<NamedDecl>(CanonMember))
9375 if (ND->getDeclName() == D->getDeclName())
9376 Candidates.push_back(ND);
9377 }
9378
9379 if (!Found) {
9380 // The AST doesn't like TagDecls becoming invalid after they've been
9381 // completed. We only really need to mark FieldDecls as invalid here.
9382 if (!isa<TagDecl>(D))
9383 D->setInvalidDecl();
9384
9385 // Ensure we don't accidentally recursively enter deserialization while
9386 // we're producing our diagnostic.
9387 Deserializing RecursionGuard(this);
9388
9389 std::string CanonDefModule =
9390 getOwningModuleNameForDiagnostic(cast<Decl>(CanonDef));
9391 Diag(D->getLocation(), diag::err_module_odr_violation_missing_decl)
9392 << D << getOwningModuleNameForDiagnostic(D)
9393 << CanonDef << CanonDefModule.empty() << CanonDefModule;
9394
9395 if (Candidates.empty())
9396 Diag(cast<Decl>(CanonDef)->getLocation(),
9397 diag::note_module_odr_violation_no_possible_decls) << D;
9398 else {
9399 for (unsigned I = 0, N = Candidates.size(); I != N; ++I)
9400 Diag(Candidates[I]->getLocation(),
9401 diag::note_module_odr_violation_possible_decl)
9402 << Candidates[I];
9403 }
9404
9405 DiagnosedOdrMergeFailures.insert(CanonDef);
9406 }
9407 }
9408
9409 if (OdrMergeFailures.empty() && FunctionOdrMergeFailures.empty() &&
9410 EnumOdrMergeFailures.empty())
9411 return;
9412
9413 // Ensure we don't accidentally recursively enter deserialization while
9414 // we're producing our diagnostics.
9415 Deserializing RecursionGuard(this);
9416
9417 // Common code for hashing helpers.
9418 ODRHash Hash;
9419 auto ComputeQualTypeODRHash = [&Hash](QualType Ty) {
9420 Hash.clear();
9421 Hash.AddQualType(Ty);
9422 return Hash.CalculateHash();
9423 };
9424
9425 auto ComputeODRHash = [&Hash](const Stmt *S) {
9426 assert(S);
9427 Hash.clear();
9428 Hash.AddStmt(S);
9429 return Hash.CalculateHash();
9430 };
9431
9432 auto ComputeSubDeclODRHash = [&Hash](const Decl *D) {
9433 assert(D);
9434 Hash.clear();
9435 Hash.AddSubDecl(D);
9436 return Hash.CalculateHash();
9437 };
9438
9439 auto ComputeTemplateArgumentODRHash = [&Hash](const TemplateArgument &TA) {
9440 Hash.clear();
9441 Hash.AddTemplateArgument(TA);
9442 return Hash.CalculateHash();
9443 };
9444
9445 auto ComputeTemplateParameterListODRHash =
9446 [&Hash](const TemplateParameterList *TPL) {
9447 assert(TPL);
9448 Hash.clear();
9449 Hash.AddTemplateParameterList(TPL);
9450 return Hash.CalculateHash();
9451 };
9452
9453 // Issue any pending ODR-failure diagnostics.
9454 for (auto &Merge : OdrMergeFailures) {
9455 // If we've already pointed out a specific problem with this class, don't
9456 // bother issuing a general "something's different" diagnostic.
9457 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
9458 continue;
9459
9460 bool Diagnosed = false;
9461 CXXRecordDecl *FirstRecord = Merge.first;
9462 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstRecord);
9463 for (auto &RecordPair : Merge.second) {
9464 CXXRecordDecl *SecondRecord = RecordPair.first;
9465 // Multiple different declarations got merged together; tell the user
9466 // where they came from.
9467 if (FirstRecord == SecondRecord)
9468 continue;
9469
9470 std::string SecondModule = getOwningModuleNameForDiagnostic(SecondRecord);
9471
9472 auto *FirstDD = FirstRecord->DefinitionData;
9473 auto *SecondDD = RecordPair.second;
9474
9475 assert(FirstDD && SecondDD && "Definitions without DefinitionData");
9476
9477 // Diagnostics from DefinitionData are emitted here.
9478 if (FirstDD != SecondDD) {
9479 enum ODRDefinitionDataDifference {
9480 NumBases,
9481 NumVBases,
9482 BaseType,
9483 BaseVirtual,
9484 BaseAccess,
9485 };
9486 auto ODRDiagError = [FirstRecord, &FirstModule,
9487 this](SourceLocation Loc, SourceRange Range,
9488 ODRDefinitionDataDifference DiffType) {
9489 return Diag(Loc, diag::err_module_odr_violation_definition_data)
9490 << FirstRecord << FirstModule.empty() << FirstModule << Range
9491 << DiffType;
9492 };
9493 auto ODRDiagNote = [&SecondModule,
9494 this](SourceLocation Loc, SourceRange Range,
9495 ODRDefinitionDataDifference DiffType) {
9496 return Diag(Loc, diag::note_module_odr_violation_definition_data)
9497 << SecondModule << Range << DiffType;
9498 };
9499
9500 unsigned FirstNumBases = FirstDD->NumBases;
9501 unsigned FirstNumVBases = FirstDD->NumVBases;
9502 unsigned SecondNumBases = SecondDD->NumBases;
9503 unsigned SecondNumVBases = SecondDD->NumVBases;
9504
9505 auto GetSourceRange = [](struct CXXRecordDecl::DefinitionData *DD) {
9506 unsigned NumBases = DD->NumBases;
9507 if (NumBases == 0) return SourceRange();
9508 auto bases = DD->bases();
9509 return SourceRange(bases[0].getBeginLoc(),
9510 bases[NumBases - 1].getEndLoc());
9511 };
9512
9513 if (FirstNumBases != SecondNumBases) {
9514 ODRDiagError(FirstRecord->getLocation(), GetSourceRange(FirstDD),
9515 NumBases)
9516 << FirstNumBases;
9517 ODRDiagNote(SecondRecord->getLocation(), GetSourceRange(SecondDD),
9518 NumBases)
9519 << SecondNumBases;
9520 Diagnosed = true;
9521 break;
9522 }
9523
9524 if (FirstNumVBases != SecondNumVBases) {
9525 ODRDiagError(FirstRecord->getLocation(), GetSourceRange(FirstDD),
9526 NumVBases)
9527 << FirstNumVBases;
9528 ODRDiagNote(SecondRecord->getLocation(), GetSourceRange(SecondDD),
9529 NumVBases)
9530 << SecondNumVBases;
9531 Diagnosed = true;
9532 break;
9533 }
9534
9535 auto FirstBases = FirstDD->bases();
9536 auto SecondBases = SecondDD->bases();
9537 unsigned i = 0;
9538 for (i = 0; i < FirstNumBases; ++i) {
9539 auto FirstBase = FirstBases[i];
9540 auto SecondBase = SecondBases[i];
9541 if (ComputeQualTypeODRHash(FirstBase.getType()) !=
9542 ComputeQualTypeODRHash(SecondBase.getType())) {
9543 ODRDiagError(FirstRecord->getLocation(), FirstBase.getSourceRange(),
9544 BaseType)
9545 << (i + 1) << FirstBase.getType();
9546 ODRDiagNote(SecondRecord->getLocation(),
9547 SecondBase.getSourceRange(), BaseType)
9548 << (i + 1) << SecondBase.getType();
9549 break;
9550 }
9551
9552 if (FirstBase.isVirtual() != SecondBase.isVirtual()) {
9553 ODRDiagError(FirstRecord->getLocation(), FirstBase.getSourceRange(),
9554 BaseVirtual)
9555 << (i + 1) << FirstBase.isVirtual() << FirstBase.getType();
9556 ODRDiagNote(SecondRecord->getLocation(),
9557 SecondBase.getSourceRange(), BaseVirtual)
9558 << (i + 1) << SecondBase.isVirtual() << SecondBase.getType();
9559 break;
9560 }
9561
9562 if (FirstBase.getAccessSpecifierAsWritten() !=
9563 SecondBase.getAccessSpecifierAsWritten()) {
9564 ODRDiagError(FirstRecord->getLocation(), FirstBase.getSourceRange(),
9565 BaseAccess)
9566 << (i + 1) << FirstBase.getType()
9567 << (int)FirstBase.getAccessSpecifierAsWritten();
9568 ODRDiagNote(SecondRecord->getLocation(),
9569 SecondBase.getSourceRange(), BaseAccess)
9570 << (i + 1) << SecondBase.getType()
9571 << (int)SecondBase.getAccessSpecifierAsWritten();
9572 break;
9573 }
9574 }
9575
9576 if (i != FirstNumBases) {
9577 Diagnosed = true;
9578 break;
9579 }
9580 }
9581
9582 using DeclHashes = llvm::SmallVector<std::pair<Decl *, unsigned>, 4>;
9583
9584 const ClassTemplateDecl *FirstTemplate =
9585 FirstRecord->getDescribedClassTemplate();
9586 const ClassTemplateDecl *SecondTemplate =
9587 SecondRecord->getDescribedClassTemplate();
9588
9589 assert(!FirstTemplate == !SecondTemplate &&
9590 "Both pointers should be null or non-null");
9591
9592 enum ODRTemplateDifference {
9593 ParamEmptyName,
9594 ParamName,
9595 ParamSingleDefaultArgument,
9596 ParamDifferentDefaultArgument,
9597 };
9598
9599 if (FirstTemplate && SecondTemplate) {
9600 DeclHashes FirstTemplateHashes;
9601 DeclHashes SecondTemplateHashes;
9602
9603 auto PopulateTemplateParameterHashs =
9604 [&ComputeSubDeclODRHash](DeclHashes &Hashes,
9605 const ClassTemplateDecl *TD) {
9606 for (auto *D : TD->getTemplateParameters()->asArray()) {
9607 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9608 }
9609 };
9610
9611 PopulateTemplateParameterHashs(FirstTemplateHashes, FirstTemplate);
9612 PopulateTemplateParameterHashs(SecondTemplateHashes, SecondTemplate);
9613
9614 assert(FirstTemplateHashes.size() == SecondTemplateHashes.size() &&
9615 "Number of template parameters should be equal.");
9616
9617 auto FirstIt = FirstTemplateHashes.begin();
9618 auto FirstEnd = FirstTemplateHashes.end();
9619 auto SecondIt = SecondTemplateHashes.begin();
9620 for (; FirstIt != FirstEnd; ++FirstIt, ++SecondIt) {
9621 if (FirstIt->second == SecondIt->second)
9622 continue;
9623
9624 auto ODRDiagError = [FirstRecord, &FirstModule,
9625 this](SourceLocation Loc, SourceRange Range,
9626 ODRTemplateDifference DiffType) {
9627 return Diag(Loc, diag::err_module_odr_violation_template_parameter)
9628 << FirstRecord << FirstModule.empty() << FirstModule << Range
9629 << DiffType;
9630 };
9631 auto ODRDiagNote = [&SecondModule,
9632 this](SourceLocation Loc, SourceRange Range,
9633 ODRTemplateDifference DiffType) {
9634 return Diag(Loc, diag::note_module_odr_violation_template_parameter)
9635 << SecondModule << Range << DiffType;
9636 };
9637
9638 const NamedDecl* FirstDecl = cast<NamedDecl>(FirstIt->first);
9639 const NamedDecl* SecondDecl = cast<NamedDecl>(SecondIt->first);
9640
9641 assert(FirstDecl->getKind() == SecondDecl->getKind() &&
9642 "Parameter Decl's should be the same kind.");
9643
9644 DeclarationName FirstName = FirstDecl->getDeclName();
9645 DeclarationName SecondName = SecondDecl->getDeclName();
9646
9647 if (FirstName != SecondName) {
9648 const bool FirstNameEmpty =
9649 FirstName.isIdentifier() && !FirstName.getAsIdentifierInfo();
9650 const bool SecondNameEmpty =
9651 SecondName.isIdentifier() && !SecondName.getAsIdentifierInfo();
9652 assert((!FirstNameEmpty || !SecondNameEmpty) &&
9653 "Both template parameters cannot be unnamed.");
9654 ODRDiagError(FirstDecl->getLocation(), FirstDecl->getSourceRange(),
9655 FirstNameEmpty ? ParamEmptyName : ParamName)
9656 << FirstName;
9657 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9658 SecondNameEmpty ? ParamEmptyName : ParamName)
9659 << SecondName;
9660 break;
9661 }
9662
9663 switch (FirstDecl->getKind()) {
9664 default:
9665 llvm_unreachable("Invalid template parameter type.");
9666 case Decl::TemplateTypeParm: {
9667 const auto *FirstParam = cast<TemplateTypeParmDecl>(FirstDecl);
9668 const auto *SecondParam = cast<TemplateTypeParmDecl>(SecondDecl);
9669 const bool HasFirstDefaultArgument =
9670 FirstParam->hasDefaultArgument() &&
9671 !FirstParam->defaultArgumentWasInherited();
9672 const bool HasSecondDefaultArgument =
9673 SecondParam->hasDefaultArgument() &&
9674 !SecondParam->defaultArgumentWasInherited();
9675
9676 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9677 ODRDiagError(FirstDecl->getLocation(),
9678 FirstDecl->getSourceRange(),
9679 ParamSingleDefaultArgument)
9680 << HasFirstDefaultArgument;
9681 ODRDiagNote(SecondDecl->getLocation(),
9682 SecondDecl->getSourceRange(),
9683 ParamSingleDefaultArgument)
9684 << HasSecondDefaultArgument;
9685 break;
9686 }
9687
9688 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9689 "Expecting default arguments.");
9690
9691 ODRDiagError(FirstDecl->getLocation(), FirstDecl->getSourceRange(),
9692 ParamDifferentDefaultArgument);
9693 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9694 ParamDifferentDefaultArgument);
9695
9696 break;
9697 }
9698 case Decl::NonTypeTemplateParm: {
9699 const auto *FirstParam = cast<NonTypeTemplateParmDecl>(FirstDecl);
9700 const auto *SecondParam = cast<NonTypeTemplateParmDecl>(SecondDecl);
9701 const bool HasFirstDefaultArgument =
9702 FirstParam->hasDefaultArgument() &&
9703 !FirstParam->defaultArgumentWasInherited();
9704 const bool HasSecondDefaultArgument =
9705 SecondParam->hasDefaultArgument() &&
9706 !SecondParam->defaultArgumentWasInherited();
9707
9708 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9709 ODRDiagError(FirstDecl->getLocation(),
9710 FirstDecl->getSourceRange(),
9711 ParamSingleDefaultArgument)
9712 << HasFirstDefaultArgument;
9713 ODRDiagNote(SecondDecl->getLocation(),
9714 SecondDecl->getSourceRange(),
9715 ParamSingleDefaultArgument)
9716 << HasSecondDefaultArgument;
9717 break;
9718 }
9719
9720 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9721 "Expecting default arguments.");
9722
9723 ODRDiagError(FirstDecl->getLocation(), FirstDecl->getSourceRange(),
9724 ParamDifferentDefaultArgument);
9725 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9726 ParamDifferentDefaultArgument);
9727
9728 break;
9729 }
9730 case Decl::TemplateTemplateParm: {
9731 const auto *FirstParam = cast<TemplateTemplateParmDecl>(FirstDecl);
9732 const auto *SecondParam =
9733 cast<TemplateTemplateParmDecl>(SecondDecl);
9734 const bool HasFirstDefaultArgument =
9735 FirstParam->hasDefaultArgument() &&
9736 !FirstParam->defaultArgumentWasInherited();
9737 const bool HasSecondDefaultArgument =
9738 SecondParam->hasDefaultArgument() &&
9739 !SecondParam->defaultArgumentWasInherited();
9740
9741 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
9742 ODRDiagError(FirstDecl->getLocation(),
9743 FirstDecl->getSourceRange(),
9744 ParamSingleDefaultArgument)
9745 << HasFirstDefaultArgument;
9746 ODRDiagNote(SecondDecl->getLocation(),
9747 SecondDecl->getSourceRange(),
9748 ParamSingleDefaultArgument)
9749 << HasSecondDefaultArgument;
9750 break;
9751 }
9752
9753 assert(HasFirstDefaultArgument && HasSecondDefaultArgument &&
9754 "Expecting default arguments.");
9755
9756 ODRDiagError(FirstDecl->getLocation(), FirstDecl->getSourceRange(),
9757 ParamDifferentDefaultArgument);
9758 ODRDiagNote(SecondDecl->getLocation(), SecondDecl->getSourceRange(),
9759 ParamDifferentDefaultArgument);
9760
9761 break;
9762 }
9763 }
9764
9765 break;
9766 }
9767
9768 if (FirstIt != FirstEnd) {
9769 Diagnosed = true;
9770 break;
9771 }
9772 }
9773
9774 DeclHashes FirstHashes;
9775 DeclHashes SecondHashes;
9776
9777 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstRecord](
9778 DeclHashes &Hashes, CXXRecordDecl *Record) {
9779 for (auto *D : Record->decls()) {
9780 // Due to decl merging, the first CXXRecordDecl is the parent of
9781 // Decls in both records.
9782 if (!ODRHash::isWhitelistedDecl(D, FirstRecord))
9783 continue;
9784 Hashes.emplace_back(D, ComputeSubDeclODRHash(D));
9785 }
9786 };
9787 PopulateHashes(FirstHashes, FirstRecord);
9788 PopulateHashes(SecondHashes, SecondRecord);
9789
9790 // Used with err_module_odr_violation_mismatch_decl and
9791 // note_module_odr_violation_mismatch_decl
9792 // This list should be the same Decl's as in ODRHash::isWhiteListedDecl
9793 enum {
9794 EndOfClass,
9795 PublicSpecifer,
9796 PrivateSpecifer,
9797 ProtectedSpecifer,
9798 StaticAssert,
9799 Field,
9800 CXXMethod,
9801 TypeAlias,
9802 TypeDef,
9803 Var,
9804 Friend,
9805 FunctionTemplate,
9806 Other
9807 } FirstDiffType = Other,
9808 SecondDiffType = Other;
9809
9810 auto DifferenceSelector = [](Decl *D) {
9811 assert(D && "valid Decl required");
9812 switch (D->getKind()) {
9813 default:
9814 return Other;
9815 case Decl::AccessSpec:
9816 switch (D->getAccess()) {
9817 case AS_public:
9818 return PublicSpecifer;
9819 case AS_private:
9820 return PrivateSpecifer;
9821 case AS_protected:
9822 return ProtectedSpecifer;
9823 case AS_none:
9824 break;
9825 }
9826 llvm_unreachable("Invalid access specifier");
9827 case Decl::StaticAssert:
9828 return StaticAssert;
9829 case Decl::Field:
9830 return Field;
9831 case Decl::CXXMethod:
9832 case Decl::CXXConstructor:
9833 case Decl::CXXDestructor:
9834 return CXXMethod;
9835 case Decl::TypeAlias:
9836 return TypeAlias;
9837 case Decl::Typedef:
9838 return TypeDef;
9839 case Decl::Var:
9840 return Var;
9841 case Decl::Friend:
9842 return Friend;
9843 case Decl::FunctionTemplate:
9844 return FunctionTemplate;
9845 }
9846 };
9847
9848 Decl *FirstDecl = nullptr;
9849 Decl *SecondDecl = nullptr;
9850 auto FirstIt = FirstHashes.begin();
9851 auto SecondIt = SecondHashes.begin();
9852
9853 // If there is a diagnoseable difference, FirstDiffType and
9854 // SecondDiffType will not be Other and FirstDecl and SecondDecl will be
9855 // filled in if not EndOfClass.
9856 while (FirstIt != FirstHashes.end() || SecondIt != SecondHashes.end()) {
9857 if (FirstIt != FirstHashes.end() && SecondIt != SecondHashes.end() &&
9858 FirstIt->second == SecondIt->second) {
9859 ++FirstIt;
9860 ++SecondIt;
9861 continue;
9862 }
9863
9864 FirstDecl = FirstIt == FirstHashes.end() ? nullptr : FirstIt->first;
9865 SecondDecl = SecondIt == SecondHashes.end() ? nullptr : SecondIt->first;
9866
9867 FirstDiffType = FirstDecl ? DifferenceSelector(FirstDecl) : EndOfClass;
9868 SecondDiffType =
9869 SecondDecl ? DifferenceSelector(SecondDecl) : EndOfClass;
9870
9871 break;
9872 }
9873
9874 if (FirstDiffType == Other || SecondDiffType == Other) {
9875 // Reaching this point means an unexpected Decl was encountered
9876 // or no difference was detected. This causes a generic error
9877 // message to be emitted.
9878 Diag(FirstRecord->getLocation(),
9879 diag::err_module_odr_violation_different_definitions)
9880 << FirstRecord << FirstModule.empty() << FirstModule;
9881
9882 if (FirstDecl) {
9883 Diag(FirstDecl->getLocation(), diag::note_first_module_difference)
9884 << FirstRecord << FirstDecl->getSourceRange();
9885 }
9886
9887 Diag(SecondRecord->getLocation(),
9888 diag::note_module_odr_violation_different_definitions)
9889 << SecondModule;
9890
9891 if (SecondDecl) {
9892 Diag(SecondDecl->getLocation(), diag::note_second_module_difference)
9893 << SecondDecl->getSourceRange();
9894 }
9895
9896 Diagnosed = true;
9897 break;
9898 }
9899
9900 if (FirstDiffType != SecondDiffType) {
9901 SourceLocation FirstLoc;
9902 SourceRange FirstRange;
9903 if (FirstDiffType == EndOfClass) {
9904 FirstLoc = FirstRecord->getBraceRange().getEnd();
9905 } else {
9906 FirstLoc = FirstIt->first->getLocation();
9907 FirstRange = FirstIt->first->getSourceRange();
9908 }
9909 Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
9910 << FirstRecord << FirstModule.empty() << FirstModule << FirstRange
9911 << FirstDiffType;
9912
9913 SourceLocation SecondLoc;
9914 SourceRange SecondRange;
9915 if (SecondDiffType == EndOfClass) {
9916 SecondLoc = SecondRecord->getBraceRange().getEnd();
9917 } else {
9918 SecondLoc = SecondDecl->getLocation();
9919 SecondRange = SecondDecl->getSourceRange();
9920 }
9921 Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
9922 << SecondModule << SecondRange << SecondDiffType;
9923 Diagnosed = true;
9924 break;
9925 }
9926
9927 assert(FirstDiffType == SecondDiffType);
9928
9929 // Used with err_module_odr_violation_mismatch_decl_diff and
9930 // note_module_odr_violation_mismatch_decl_diff
9931 enum ODRDeclDifference {
9932 StaticAssertCondition,
9933 StaticAssertMessage,
9934 StaticAssertOnlyMessage,
9935 FieldName,
9936 FieldTypeName,
9937 FieldSingleBitField,
9938 FieldDifferentWidthBitField,
9939 FieldSingleMutable,
9940 FieldSingleInitializer,
9941 FieldDifferentInitializers,
9942 MethodName,
9943 MethodDeleted,
9944 MethodDefaulted,
9945 MethodVirtual,
9946 MethodStatic,
9947 MethodVolatile,
9948 MethodConst,
9949 MethodInline,
9950 MethodNumberParameters,
9951 MethodParameterType,
9952 MethodParameterName,
9953 MethodParameterSingleDefaultArgument,
9954 MethodParameterDifferentDefaultArgument,
9955 MethodNoTemplateArguments,
9956 MethodDifferentNumberTemplateArguments,
9957 MethodDifferentTemplateArgument,
9958 MethodSingleBody,
9959 MethodDifferentBody,
9960 TypedefName,
9961 TypedefType,
9962 VarName,
9963 VarType,
9964 VarSingleInitializer,
9965 VarDifferentInitializer,
9966 VarConstexpr,
9967 FriendTypeFunction,
9968 FriendType,
9969 FriendFunction,
9970 FunctionTemplateDifferentNumberParameters,
9971 FunctionTemplateParameterDifferentKind,
9972 FunctionTemplateParameterName,
9973 FunctionTemplateParameterSingleDefaultArgument,
9974 FunctionTemplateParameterDifferentDefaultArgument,
9975 FunctionTemplateParameterDifferentType,
9976 FunctionTemplatePackParameter,
9977 };
9978
9979 // These lambdas have the common portions of the ODR diagnostics. This
9980 // has the same return as Diag(), so addition parameters can be passed
9981 // in with operator<<
9982 auto ODRDiagError = [FirstRecord, &FirstModule, this](
9983 SourceLocation Loc, SourceRange Range, ODRDeclDifference DiffType) {
9984 return Diag(Loc, diag::err_module_odr_violation_mismatch_decl_diff)
9985 << FirstRecord << FirstModule.empty() << FirstModule << Range
9986 << DiffType;
9987 };
9988 auto ODRDiagNote = [&SecondModule, this](
9989 SourceLocation Loc, SourceRange Range, ODRDeclDifference DiffType) {
9990 return Diag(Loc, diag::note_module_odr_violation_mismatch_decl_diff)
9991 << SecondModule << Range << DiffType;
9992 };
9993
9994 switch (FirstDiffType) {
9995 case Other:
9996 case EndOfClass:
9997 case PublicSpecifer:
9998 case PrivateSpecifer:
9999 case ProtectedSpecifer:
10000 llvm_unreachable("Invalid diff type");
10001
10002 case StaticAssert: {
10003 StaticAssertDecl *FirstSA = cast<StaticAssertDecl>(FirstDecl);
10004 StaticAssertDecl *SecondSA = cast<StaticAssertDecl>(SecondDecl);
10005
10006 Expr *FirstExpr = FirstSA->getAssertExpr();
10007 Expr *SecondExpr = SecondSA->getAssertExpr();
10008 unsigned FirstODRHash = ComputeODRHash(FirstExpr);
10009 unsigned SecondODRHash = ComputeODRHash(SecondExpr);
10010 if (FirstODRHash != SecondODRHash) {
10011 ODRDiagError(FirstExpr->getBeginLoc(), FirstExpr->getSourceRange(),
10012 StaticAssertCondition);
10013 ODRDiagNote(SecondExpr->getBeginLoc(), SecondExpr->getSourceRange(),
10014 StaticAssertCondition);
10015 Diagnosed = true;
10016 break;
10017 }
10018
10019 StringLiteral *FirstStr = FirstSA->getMessage();
10020 StringLiteral *SecondStr = SecondSA->getMessage();
10021 assert((FirstStr || SecondStr) && "Both messages cannot be empty");
10022 if ((FirstStr && !SecondStr) || (!FirstStr && SecondStr)) {
10023 SourceLocation FirstLoc, SecondLoc;
10024 SourceRange FirstRange, SecondRange;
10025 if (FirstStr) {
10026 FirstLoc = FirstStr->getBeginLoc();
10027 FirstRange = FirstStr->getSourceRange();
10028 } else {
10029 FirstLoc = FirstSA->getBeginLoc();
10030 FirstRange = FirstSA->getSourceRange();
10031 }
10032 if (SecondStr) {
10033 SecondLoc = SecondStr->getBeginLoc();
10034 SecondRange = SecondStr->getSourceRange();
10035 } else {
10036 SecondLoc = SecondSA->getBeginLoc();
10037 SecondRange = SecondSA->getSourceRange();
10038 }
10039 ODRDiagError(FirstLoc, FirstRange, StaticAssertOnlyMessage)
10040 << (FirstStr == nullptr);
10041 ODRDiagNote(SecondLoc, SecondRange, StaticAssertOnlyMessage)
10042 << (SecondStr == nullptr);
10043 Diagnosed = true;
10044 break;
10045 }
10046
10047 if (FirstStr && SecondStr &&
10048 FirstStr->getString() != SecondStr->getString()) {
10049 ODRDiagError(FirstStr->getBeginLoc(), FirstStr->getSourceRange(),
10050 StaticAssertMessage);
10051 ODRDiagNote(SecondStr->getBeginLoc(), SecondStr->getSourceRange(),
10052 StaticAssertMessage);
10053 Diagnosed = true;
10054 break;
10055 }
10056 break;
10057 }
10058 case Field: {
10059 FieldDecl *FirstField = cast<FieldDecl>(FirstDecl);
10060 FieldDecl *SecondField = cast<FieldDecl>(SecondDecl);
10061 IdentifierInfo *FirstII = FirstField->getIdentifier();
10062 IdentifierInfo *SecondII = SecondField->getIdentifier();
10063 if (FirstII->getName() != SecondII->getName()) {
10064 ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
10065 FieldName)
10066 << FirstII;
10067 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10068 FieldName)
10069 << SecondII;
10070
10071 Diagnosed = true;
10072 break;
10073 }
10074
10075 assert(getContext().hasSameType(FirstField->getType(),
10076 SecondField->getType()));
10077
10078 QualType FirstType = FirstField->getType();
10079 QualType SecondType = SecondField->getType();
10080 if (ComputeQualTypeODRHash(FirstType) !=
10081 ComputeQualTypeODRHash(SecondType)) {
10082 ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
10083 FieldTypeName)
10084 << FirstII << FirstType;
10085 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10086 FieldTypeName)
10087 << SecondII << SecondType;
10088
10089 Diagnosed = true;
10090 break;
10091 }
10092
10093 const bool IsFirstBitField = FirstField->isBitField();
10094 const bool IsSecondBitField = SecondField->isBitField();
10095 if (IsFirstBitField != IsSecondBitField) {
10096 ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
10097 FieldSingleBitField)
10098 << FirstII << IsFirstBitField;
10099 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10100 FieldSingleBitField)
10101 << SecondII << IsSecondBitField;
10102 Diagnosed = true;
10103 break;
10104 }
10105
10106 if (IsFirstBitField && IsSecondBitField) {
10107 unsigned FirstBitWidthHash =
10108 ComputeODRHash(FirstField->getBitWidth());
10109 unsigned SecondBitWidthHash =
10110 ComputeODRHash(SecondField->getBitWidth());
10111 if (FirstBitWidthHash != SecondBitWidthHash) {
10112 ODRDiagError(FirstField->getLocation(),
10113 FirstField->getSourceRange(),
10114 FieldDifferentWidthBitField)
10115 << FirstII << FirstField->getBitWidth()->getSourceRange();
10116 ODRDiagNote(SecondField->getLocation(),
10117 SecondField->getSourceRange(),
10118 FieldDifferentWidthBitField)
10119 << SecondII << SecondField->getBitWidth()->getSourceRange();
10120 Diagnosed = true;
10121 break;
10122 }
10123 }
10124
10125 const bool IsFirstMutable = FirstField->isMutable();
10126 const bool IsSecondMutable = SecondField->isMutable();
10127 if (IsFirstMutable != IsSecondMutable) {
10128 ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
10129 FieldSingleMutable)
10130 << FirstII << IsFirstMutable;
10131 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10132 FieldSingleMutable)
10133 << SecondII << IsSecondMutable;
10134 Diagnosed = true;
10135 break;
10136 }
10137
10138 const Expr *FirstInitializer = FirstField->getInClassInitializer();
10139 const Expr *SecondInitializer = SecondField->getInClassInitializer();
10140 if ((!FirstInitializer && SecondInitializer) ||
10141 (FirstInitializer && !SecondInitializer)) {
10142 ODRDiagError(FirstField->getLocation(), FirstField->getSourceRange(),
10143 FieldSingleInitializer)
10144 << FirstII << (FirstInitializer != nullptr);
10145 ODRDiagNote(SecondField->getLocation(), SecondField->getSourceRange(),
10146 FieldSingleInitializer)
10147 << SecondII << (SecondInitializer != nullptr);
10148 Diagnosed = true;
10149 break;
10150 }
10151
10152 if (FirstInitializer && SecondInitializer) {
10153 unsigned FirstInitHash = ComputeODRHash(FirstInitializer);
10154 unsigned SecondInitHash = ComputeODRHash(SecondInitializer);
10155 if (FirstInitHash != SecondInitHash) {
10156 ODRDiagError(FirstField->getLocation(),
10157 FirstField->getSourceRange(),
10158 FieldDifferentInitializers)
10159 << FirstII << FirstInitializer->getSourceRange();
10160 ODRDiagNote(SecondField->getLocation(),
10161 SecondField->getSourceRange(),
10162 FieldDifferentInitializers)
10163 << SecondII << SecondInitializer->getSourceRange();
10164 Diagnosed = true;
10165 break;
10166 }
10167 }
10168
10169 break;
10170 }
10171 case CXXMethod: {
10172 enum {
10173 DiagMethod,
10174 DiagConstructor,
10175 DiagDestructor,
10176 } FirstMethodType,
10177 SecondMethodType;
10178 auto GetMethodTypeForDiagnostics = [](const CXXMethodDecl* D) {
10179 if (isa<CXXConstructorDecl>(D)) return DiagConstructor;
10180 if (isa<CXXDestructorDecl>(D)) return DiagDestructor;
10181 return DiagMethod;
10182 };
10183 const CXXMethodDecl *FirstMethod = cast<CXXMethodDecl>(FirstDecl);
10184 const CXXMethodDecl *SecondMethod = cast<CXXMethodDecl>(SecondDecl);
10185 FirstMethodType = GetMethodTypeForDiagnostics(FirstMethod);
10186 SecondMethodType = GetMethodTypeForDiagnostics(SecondMethod);
10187 auto FirstName = FirstMethod->getDeclName();
10188 auto SecondName = SecondMethod->getDeclName();
10189 if (FirstMethodType != SecondMethodType || FirstName != SecondName) {
10190 ODRDiagError(FirstMethod->getLocation(),
10191 FirstMethod->getSourceRange(), MethodName)
10192 << FirstMethodType << FirstName;
10193 ODRDiagNote(SecondMethod->getLocation(),
10194 SecondMethod->getSourceRange(), MethodName)
10195 << SecondMethodType << SecondName;
10196
10197 Diagnosed = true;
10198 break;
10199 }
10200
10201 const bool FirstDeleted = FirstMethod->isDeletedAsWritten();
10202 const bool SecondDeleted = SecondMethod->isDeletedAsWritten();
10203 if (FirstDeleted != SecondDeleted) {
10204 ODRDiagError(FirstMethod->getLocation(),
10205 FirstMethod->getSourceRange(), MethodDeleted)
10206 << FirstMethodType << FirstName << FirstDeleted;
10207
10208 ODRDiagNote(SecondMethod->getLocation(),
10209 SecondMethod->getSourceRange(), MethodDeleted)
10210 << SecondMethodType << SecondName << SecondDeleted;
10211 Diagnosed = true;
10212 break;
10213 }
10214
10215 const bool FirstDefaulted = FirstMethod->isExplicitlyDefaulted();
10216 const bool SecondDefaulted = SecondMethod->isExplicitlyDefaulted();
10217 if (FirstDefaulted != SecondDefaulted) {
10218 ODRDiagError(FirstMethod->getLocation(),
10219 FirstMethod->getSourceRange(), MethodDefaulted)
10220 << FirstMethodType << FirstName << FirstDefaulted;
10221
10222 ODRDiagNote(SecondMethod->getLocation(),
10223 SecondMethod->getSourceRange(), MethodDefaulted)
10224 << SecondMethodType << SecondName << SecondDefaulted;
10225 Diagnosed = true;
10226 break;
10227 }
10228
10229 const bool FirstVirtual = FirstMethod->isVirtualAsWritten();
10230 const bool SecondVirtual = SecondMethod->isVirtualAsWritten();
10231 const bool FirstPure = FirstMethod->isPure();
10232 const bool SecondPure = SecondMethod->isPure();
10233 if ((FirstVirtual || SecondVirtual) &&
10234 (FirstVirtual != SecondVirtual || FirstPure != SecondPure)) {
10235 ODRDiagError(FirstMethod->getLocation(),
10236 FirstMethod->getSourceRange(), MethodVirtual)
10237 << FirstMethodType << FirstName << FirstPure << FirstVirtual;
10238 ODRDiagNote(SecondMethod->getLocation(),
10239 SecondMethod->getSourceRange(), MethodVirtual)
10240 << SecondMethodType << SecondName << SecondPure << SecondVirtual;
10241 Diagnosed = true;
10242 break;
10243 }
10244
10245 // CXXMethodDecl::isStatic uses the canonical Decl. With Decl merging,
10246 // FirstDecl is the canonical Decl of SecondDecl, so the storage
10247 // class needs to be checked instead.
10248 const auto FirstStorage = FirstMethod->getStorageClass();
10249 const auto SecondStorage = SecondMethod->getStorageClass();
10250 const bool FirstStatic = FirstStorage == SC_Static;
10251 const bool SecondStatic = SecondStorage == SC_Static;
10252 if (FirstStatic != SecondStatic) {
10253 ODRDiagError(FirstMethod->getLocation(),
10254 FirstMethod->getSourceRange(), MethodStatic)
10255 << FirstMethodType << FirstName << FirstStatic;
10256 ODRDiagNote(SecondMethod->getLocation(),
10257 SecondMethod->getSourceRange(), MethodStatic)
10258 << SecondMethodType << SecondName << SecondStatic;
10259 Diagnosed = true;
10260 break;
10261 }
10262
10263 const bool FirstVolatile = FirstMethod->isVolatile();
10264 const bool SecondVolatile = SecondMethod->isVolatile();
10265 if (FirstVolatile != SecondVolatile) {
10266 ODRDiagError(FirstMethod->getLocation(),
10267 FirstMethod->getSourceRange(), MethodVolatile)
10268 << FirstMethodType << FirstName << FirstVolatile;
10269 ODRDiagNote(SecondMethod->getLocation(),
10270 SecondMethod->getSourceRange(), MethodVolatile)
10271 << SecondMethodType << SecondName << SecondVolatile;
10272 Diagnosed = true;
10273 break;
10274 }
10275
10276 const bool FirstConst = FirstMethod->isConst();
10277 const bool SecondConst = SecondMethod->isConst();
10278 if (FirstConst != SecondConst) {
10279 ODRDiagError(FirstMethod->getLocation(),
10280 FirstMethod->getSourceRange(), MethodConst)
10281 << FirstMethodType << FirstName << FirstConst;
10282 ODRDiagNote(SecondMethod->getLocation(),
10283 SecondMethod->getSourceRange(), MethodConst)
10284 << SecondMethodType << SecondName << SecondConst;
10285 Diagnosed = true;
10286 break;
10287 }
10288
10289 const bool FirstInline = FirstMethod->isInlineSpecified();
10290 const bool SecondInline = SecondMethod->isInlineSpecified();
10291 if (FirstInline != SecondInline) {
10292 ODRDiagError(FirstMethod->getLocation(),
10293 FirstMethod->getSourceRange(), MethodInline)
10294 << FirstMethodType << FirstName << FirstInline;
10295 ODRDiagNote(SecondMethod->getLocation(),
10296 SecondMethod->getSourceRange(), MethodInline)
10297 << SecondMethodType << SecondName << SecondInline;
10298 Diagnosed = true;
10299 break;
10300 }
10301
10302 const unsigned FirstNumParameters = FirstMethod->param_size();
10303 const unsigned SecondNumParameters = SecondMethod->param_size();
10304 if (FirstNumParameters != SecondNumParameters) {
10305 ODRDiagError(FirstMethod->getLocation(),
10306 FirstMethod->getSourceRange(), MethodNumberParameters)
10307 << FirstMethodType << FirstName << FirstNumParameters;
10308 ODRDiagNote(SecondMethod->getLocation(),
10309 SecondMethod->getSourceRange(), MethodNumberParameters)
10310 << SecondMethodType << SecondName << SecondNumParameters;
10311 Diagnosed = true;
10312 break;
10313 }
10314
10315 // Need this status boolean to know when break out of the switch.
10316 bool ParameterMismatch = false;
10317 for (unsigned I = 0; I < FirstNumParameters; ++I) {
10318 const ParmVarDecl *FirstParam = FirstMethod->getParamDecl(I);
10319 const ParmVarDecl *SecondParam = SecondMethod->getParamDecl(I);
10320
10321 QualType FirstParamType = FirstParam->getType();
10322 QualType SecondParamType = SecondParam->getType();
10323 if (FirstParamType != SecondParamType &&
10324 ComputeQualTypeODRHash(FirstParamType) !=
10325 ComputeQualTypeODRHash(SecondParamType)) {
10326 if (const DecayedType *ParamDecayedType =
10327 FirstParamType->getAs<DecayedType>()) {
10328 ODRDiagError(FirstMethod->getLocation(),
10329 FirstMethod->getSourceRange(), MethodParameterType)
10330 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10331 << true << ParamDecayedType->getOriginalType();
10332 } else {
10333 ODRDiagError(FirstMethod->getLocation(),
10334 FirstMethod->getSourceRange(), MethodParameterType)
10335 << FirstMethodType << FirstName << (I + 1) << FirstParamType
10336 << false;
10337 }
10338
10339 if (const DecayedType *ParamDecayedType =
10340 SecondParamType->getAs<DecayedType>()) {
10341 ODRDiagNote(SecondMethod->getLocation(),
10342 SecondMethod->getSourceRange(), MethodParameterType)
10343 << SecondMethodType << SecondName << (I + 1)
10344 << SecondParamType << true
10345 << ParamDecayedType->getOriginalType();
10346 } else {
10347 ODRDiagNote(SecondMethod->getLocation(),
10348 SecondMethod->getSourceRange(), MethodParameterType)
10349 << SecondMethodType << SecondName << (I + 1)
10350 << SecondParamType << false;
10351 }
10352 ParameterMismatch = true;
10353 break;
10354 }
10355
10356 DeclarationName FirstParamName = FirstParam->getDeclName();
10357 DeclarationName SecondParamName = SecondParam->getDeclName();
10358 if (FirstParamName != SecondParamName) {
10359 ODRDiagError(FirstMethod->getLocation(),
10360 FirstMethod->getSourceRange(), MethodParameterName)
10361 << FirstMethodType << FirstName << (I + 1) << FirstParamName;
10362 ODRDiagNote(SecondMethod->getLocation(),
10363 SecondMethod->getSourceRange(), MethodParameterName)
10364 << SecondMethodType << SecondName << (I + 1) << SecondParamName;
10365 ParameterMismatch = true;
10366 break;
10367 }
10368
10369 const Expr *FirstInit = FirstParam->getInit();
10370 const Expr *SecondInit = SecondParam->getInit();
10371 if ((FirstInit == nullptr) != (SecondInit == nullptr)) {
10372 ODRDiagError(FirstMethod->getLocation(),
10373 FirstMethod->getSourceRange(),
10374 MethodParameterSingleDefaultArgument)
10375 << FirstMethodType << FirstName << (I + 1)
10376 << (FirstInit == nullptr)
10377 << (FirstInit ? FirstInit->getSourceRange() : SourceRange());
10378 ODRDiagNote(SecondMethod->getLocation(),
10379 SecondMethod->getSourceRange(),
10380 MethodParameterSingleDefaultArgument)
10381 << SecondMethodType << SecondName << (I + 1)
10382 << (SecondInit == nullptr)
10383 << (SecondInit ? SecondInit->getSourceRange() : SourceRange());
10384 ParameterMismatch = true;
10385 break;
10386 }
10387
10388 if (FirstInit && SecondInit &&
10389 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10390 ODRDiagError(FirstMethod->getLocation(),
10391 FirstMethod->getSourceRange(),
10392 MethodParameterDifferentDefaultArgument)
10393 << FirstMethodType << FirstName << (I + 1)
10394 << FirstInit->getSourceRange();
10395 ODRDiagNote(SecondMethod->getLocation(),
10396 SecondMethod->getSourceRange(),
10397 MethodParameterDifferentDefaultArgument)
10398 << SecondMethodType << SecondName << (I + 1)
10399 << SecondInit->getSourceRange();
10400 ParameterMismatch = true;
10401 break;
10402
10403 }
10404 }
10405
10406 if (ParameterMismatch) {
10407 Diagnosed = true;
10408 break;
10409 }
10410
10411 const auto *FirstTemplateArgs =
10412 FirstMethod->getTemplateSpecializationArgs();
10413 const auto *SecondTemplateArgs =
10414 SecondMethod->getTemplateSpecializationArgs();
10415
10416 if ((FirstTemplateArgs && !SecondTemplateArgs) ||
10417 (!FirstTemplateArgs && SecondTemplateArgs)) {
10418 ODRDiagError(FirstMethod->getLocation(),
10419 FirstMethod->getSourceRange(), MethodNoTemplateArguments)
10420 << FirstMethodType << FirstName << (FirstTemplateArgs != nullptr);
10421 ODRDiagNote(SecondMethod->getLocation(),
10422 SecondMethod->getSourceRange(), MethodNoTemplateArguments)
10423 << SecondMethodType << SecondName
10424 << (SecondTemplateArgs != nullptr);
10425
10426 Diagnosed = true;
10427 break;
10428 }
10429
10430 if (FirstTemplateArgs && SecondTemplateArgs) {
10431 // Remove pack expansions from argument list.
10432 auto ExpandTemplateArgumentList =
10433 [](const TemplateArgumentList *TAL) {
10434 llvm::SmallVector<const TemplateArgument *, 8> ExpandedList;
10435 for (const TemplateArgument &TA : TAL->asArray()) {
10436 if (TA.getKind() != TemplateArgument::Pack) {
10437 ExpandedList.push_back(&TA);
10438 continue;
10439 }
10440 for (const TemplateArgument &PackTA : TA.getPackAsArray()) {
10441 ExpandedList.push_back(&PackTA);
10442 }
10443 }
10444 return ExpandedList;
10445 };
10446 llvm::SmallVector<const TemplateArgument *, 8> FirstExpandedList =
10447 ExpandTemplateArgumentList(FirstTemplateArgs);
10448 llvm::SmallVector<const TemplateArgument *, 8> SecondExpandedList =
10449 ExpandTemplateArgumentList(SecondTemplateArgs);
10450
10451 if (FirstExpandedList.size() != SecondExpandedList.size()) {
10452 ODRDiagError(FirstMethod->getLocation(),
10453 FirstMethod->getSourceRange(),
10454 MethodDifferentNumberTemplateArguments)
10455 << FirstMethodType << FirstName
10456 << (unsigned)FirstExpandedList.size();
10457 ODRDiagNote(SecondMethod->getLocation(),
10458 SecondMethod->getSourceRange(),
10459 MethodDifferentNumberTemplateArguments)
10460 << SecondMethodType << SecondName
10461 << (unsigned)SecondExpandedList.size();
10462
10463 Diagnosed = true;
10464 break;
10465 }
10466
10467 bool TemplateArgumentMismatch = false;
10468 for (unsigned i = 0, e = FirstExpandedList.size(); i != e; ++i) {
10469 const TemplateArgument &FirstTA = *FirstExpandedList[i],
10470 &SecondTA = *SecondExpandedList[i];
10471 if (ComputeTemplateArgumentODRHash(FirstTA) ==
10472 ComputeTemplateArgumentODRHash(SecondTA)) {
10473 continue;
10474 }
10475
10476 ODRDiagError(FirstMethod->getLocation(),
10477 FirstMethod->getSourceRange(),
10478 MethodDifferentTemplateArgument)
10479 << FirstMethodType << FirstName << FirstTA << i + 1;
10480 ODRDiagNote(SecondMethod->getLocation(),
10481 SecondMethod->getSourceRange(),
10482 MethodDifferentTemplateArgument)
10483 << SecondMethodType << SecondName << SecondTA << i + 1;
10484
10485 TemplateArgumentMismatch = true;
10486 break;
10487 }
10488
10489 if (TemplateArgumentMismatch) {
10490 Diagnosed = true;
10491 break;
10492 }
10493 }
10494
10495 // Compute the hash of the method as if it has no body.
10496 auto ComputeCXXMethodODRHash = [&Hash](const CXXMethodDecl *D) {
10497 Hash.clear();
10498 Hash.AddFunctionDecl(D, true /*SkipBody*/);
10499 return Hash.CalculateHash();
10500 };
10501
10502 // Compare the hash generated to the hash stored. A difference means
10503 // that a body was present in the original source. Due to merging,
10504 // the stardard way of detecting a body will not work.
10505 const bool HasFirstBody =
10506 ComputeCXXMethodODRHash(FirstMethod) != FirstMethod->getODRHash();
10507 const bool HasSecondBody =
10508 ComputeCXXMethodODRHash(SecondMethod) != SecondMethod->getODRHash();
10509
10510 if (HasFirstBody != HasSecondBody) {
10511 ODRDiagError(FirstMethod->getLocation(),
10512 FirstMethod->getSourceRange(), MethodSingleBody)
10513 << FirstMethodType << FirstName << HasFirstBody;
10514 ODRDiagNote(SecondMethod->getLocation(),
10515 SecondMethod->getSourceRange(), MethodSingleBody)
10516 << SecondMethodType << SecondName << HasSecondBody;
10517 Diagnosed = true;
10518 break;
10519 }
10520
10521 if (HasFirstBody && HasSecondBody) {
10522 ODRDiagError(FirstMethod->getLocation(),
10523 FirstMethod->getSourceRange(), MethodDifferentBody)
10524 << FirstMethodType << FirstName;
10525 ODRDiagNote(SecondMethod->getLocation(),
10526 SecondMethod->getSourceRange(), MethodDifferentBody)
10527 << SecondMethodType << SecondName;
10528 Diagnosed = true;
10529 break;
10530 }
10531
10532 break;
10533 }
10534 case TypeAlias:
10535 case TypeDef: {
10536 TypedefNameDecl *FirstTD = cast<TypedefNameDecl>(FirstDecl);
10537 TypedefNameDecl *SecondTD = cast<TypedefNameDecl>(SecondDecl);
10538 auto FirstName = FirstTD->getDeclName();
10539 auto SecondName = SecondTD->getDeclName();
10540 if (FirstName != SecondName) {
10541 ODRDiagError(FirstTD->getLocation(), FirstTD->getSourceRange(),
10542 TypedefName)
10543 << (FirstDiffType == TypeAlias) << FirstName;
10544 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10545 TypedefName)
10546 << (FirstDiffType == TypeAlias) << SecondName;
10547 Diagnosed = true;
10548 break;
10549 }
10550
10551 QualType FirstType = FirstTD->getUnderlyingType();
10552 QualType SecondType = SecondTD->getUnderlyingType();
10553 if (ComputeQualTypeODRHash(FirstType) !=
10554 ComputeQualTypeODRHash(SecondType)) {
10555 ODRDiagError(FirstTD->getLocation(), FirstTD->getSourceRange(),
10556 TypedefType)
10557 << (FirstDiffType == TypeAlias) << FirstName << FirstType;
10558 ODRDiagNote(SecondTD->getLocation(), SecondTD->getSourceRange(),
10559 TypedefType)
10560 << (FirstDiffType == TypeAlias) << SecondName << SecondType;
10561 Diagnosed = true;
10562 break;
10563 }
10564 break;
10565 }
10566 case Var: {
10567 VarDecl *FirstVD = cast<VarDecl>(FirstDecl);
10568 VarDecl *SecondVD = cast<VarDecl>(SecondDecl);
10569 auto FirstName = FirstVD->getDeclName();
10570 auto SecondName = SecondVD->getDeclName();
10571 if (FirstName != SecondName) {
10572 ODRDiagError(FirstVD->getLocation(), FirstVD->getSourceRange(),
10573 VarName)
10574 << FirstName;
10575 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10576 VarName)
10577 << SecondName;
10578 Diagnosed = true;
10579 break;
10580 }
10581
10582 QualType FirstType = FirstVD->getType();
10583 QualType SecondType = SecondVD->getType();
10584 if (ComputeQualTypeODRHash(FirstType) !=
10585 ComputeQualTypeODRHash(SecondType)) {
10586 ODRDiagError(FirstVD->getLocation(), FirstVD->getSourceRange(),
10587 VarType)
10588 << FirstName << FirstType;
10589 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10590 VarType)
10591 << SecondName << SecondType;
10592 Diagnosed = true;
10593 break;
10594 }
10595
10596 const Expr *FirstInit = FirstVD->getInit();
10597 const Expr *SecondInit = SecondVD->getInit();
10598 if ((FirstInit == nullptr) != (SecondInit == nullptr)) {
10599 ODRDiagError(FirstVD->getLocation(), FirstVD->getSourceRange(),
10600 VarSingleInitializer)
10601 << FirstName << (FirstInit == nullptr)
10602 << (FirstInit ? FirstInit->getSourceRange(): SourceRange());
10603 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10604 VarSingleInitializer)
10605 << SecondName << (SecondInit == nullptr)
10606 << (SecondInit ? SecondInit->getSourceRange() : SourceRange());
10607 Diagnosed = true;
10608 break;
10609 }
10610
10611 if (FirstInit && SecondInit &&
10612 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
10613 ODRDiagError(FirstVD->getLocation(), FirstVD->getSourceRange(),
10614 VarDifferentInitializer)
10615 << FirstName << FirstInit->getSourceRange();
10616 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10617 VarDifferentInitializer)
10618 << SecondName << SecondInit->getSourceRange();
10619 Diagnosed = true;
10620 break;
10621 }
10622
10623 const bool FirstIsConstexpr = FirstVD->isConstexpr();
10624 const bool SecondIsConstexpr = SecondVD->isConstexpr();
10625 if (FirstIsConstexpr != SecondIsConstexpr) {
10626 ODRDiagError(FirstVD->getLocation(), FirstVD->getSourceRange(),
10627 VarConstexpr)
10628 << FirstName << FirstIsConstexpr;
10629 ODRDiagNote(SecondVD->getLocation(), SecondVD->getSourceRange(),
10630 VarConstexpr)
10631 << SecondName << SecondIsConstexpr;
10632 Diagnosed = true;
10633 break;
10634 }
10635 break;
10636 }
10637 case Friend: {
10638 FriendDecl *FirstFriend = cast<FriendDecl>(FirstDecl);
10639 FriendDecl *SecondFriend = cast<FriendDecl>(SecondDecl);
10640
10641 NamedDecl *FirstND = FirstFriend->getFriendDecl();
10642 NamedDecl *SecondND = SecondFriend->getFriendDecl();
10643
10644 TypeSourceInfo *FirstTSI = FirstFriend->getFriendType();
10645 TypeSourceInfo *SecondTSI = SecondFriend->getFriendType();
10646
10647 if (FirstND && SecondND) {
10648 ODRDiagError(FirstFriend->getFriendLoc(),
10649 FirstFriend->getSourceRange(), FriendFunction)
10650 << FirstND;
10651 ODRDiagNote(SecondFriend->getFriendLoc(),
10652 SecondFriend->getSourceRange(), FriendFunction)
10653 << SecondND;
10654
10655 Diagnosed = true;
10656 break;
10657 }
10658
10659 if (FirstTSI && SecondTSI) {
10660 QualType FirstFriendType = FirstTSI->getType();
10661 QualType SecondFriendType = SecondTSI->getType();
10662 assert(ComputeQualTypeODRHash(FirstFriendType) !=
10663 ComputeQualTypeODRHash(SecondFriendType));
10664 ODRDiagError(FirstFriend->getFriendLoc(),
10665 FirstFriend->getSourceRange(), FriendType)
10666 << FirstFriendType;
10667 ODRDiagNote(SecondFriend->getFriendLoc(),
10668 SecondFriend->getSourceRange(), FriendType)
10669 << SecondFriendType;
10670 Diagnosed = true;
10671 break;
10672 }
10673
10674 ODRDiagError(FirstFriend->getFriendLoc(), FirstFriend->getSourceRange(),
10675 FriendTypeFunction)
10676 << (FirstTSI == nullptr);
10677 ODRDiagNote(SecondFriend->getFriendLoc(),
10678 SecondFriend->getSourceRange(), FriendTypeFunction)
10679 << (SecondTSI == nullptr);
10680
10681 Diagnosed = true;
10682 break;
10683 }
10684 case FunctionTemplate: {
10685 FunctionTemplateDecl *FirstTemplate =
10686 cast<FunctionTemplateDecl>(FirstDecl);
10687 FunctionTemplateDecl *SecondTemplate =
10688 cast<FunctionTemplateDecl>(SecondDecl);
10689
10690 TemplateParameterList *FirstTPL =
10691 FirstTemplate->getTemplateParameters();
10692 TemplateParameterList *SecondTPL =
10693 SecondTemplate->getTemplateParameters();
10694
10695 if (FirstTPL->size() != SecondTPL->size()) {
10696 ODRDiagError(FirstTemplate->getLocation(),
10697 FirstTemplate->getSourceRange(),
10698 FunctionTemplateDifferentNumberParameters)
10699 << FirstTemplate << FirstTPL->size();
10700 ODRDiagNote(SecondTemplate->getLocation(),
10701 SecondTemplate->getSourceRange(),
10702 FunctionTemplateDifferentNumberParameters)
10703 << SecondTemplate << SecondTPL->size();
10704
10705 Diagnosed = true;
10706 break;
10707 }
10708
10709 bool ParameterMismatch = false;
10710 for (unsigned i = 0, e = FirstTPL->size(); i != e; ++i) {
10711 NamedDecl *FirstParam = FirstTPL->getParam(i);
10712 NamedDecl *SecondParam = SecondTPL->getParam(i);
10713
10714 if (FirstParam->getKind() != SecondParam->getKind()) {
10715 enum {
10716 TemplateTypeParameter,
10717 NonTypeTemplateParameter,
10718 TemplateTemplateParameter,
10719 };
10720 auto GetParamType = [](NamedDecl *D) {
10721 switch (D->getKind()) {
10722 default:
10723 llvm_unreachable("Unexpected template parameter type");
10724 case Decl::TemplateTypeParm:
10725 return TemplateTypeParameter;
10726 case Decl::NonTypeTemplateParm:
10727 return NonTypeTemplateParameter;
10728 case Decl::TemplateTemplateParm:
10729 return TemplateTemplateParameter;
10730 }
10731 };
10732
10733 ODRDiagError(FirstTemplate->getLocation(),
10734 FirstTemplate->getSourceRange(),
10735 FunctionTemplateParameterDifferentKind)
10736 << FirstTemplate << (i + 1) << GetParamType(FirstParam);
10737 ODRDiagNote(SecondTemplate->getLocation(),
10738 SecondTemplate->getSourceRange(),
10739 FunctionTemplateParameterDifferentKind)
10740 << SecondTemplate << (i + 1) << GetParamType(SecondParam);
10741
10742 ParameterMismatch = true;
10743 break;
10744 }
10745
10746 if (FirstParam->getName() != SecondParam->getName()) {
10747 ODRDiagError(FirstTemplate->getLocation(),
10748 FirstTemplate->getSourceRange(),
10749 FunctionTemplateParameterName)
10750 << FirstTemplate << (i + 1) << (bool)FirstParam->getIdentifier()
10751 << FirstParam;
10752 ODRDiagNote(SecondTemplate->getLocation(),
10753 SecondTemplate->getSourceRange(),
10754 FunctionTemplateParameterName)
10755 << SecondTemplate << (i + 1)
10756 << (bool)SecondParam->getIdentifier() << SecondParam;
10757 ParameterMismatch = true;
10758 break;
10759 }
10760
10761 if (isa<TemplateTypeParmDecl>(FirstParam) &&
10762 isa<TemplateTypeParmDecl>(SecondParam)) {
10763 TemplateTypeParmDecl *FirstTTPD =
10764 cast<TemplateTypeParmDecl>(FirstParam);
10765 TemplateTypeParmDecl *SecondTTPD =
10766 cast<TemplateTypeParmDecl>(SecondParam);
10767 bool HasFirstDefaultArgument =
10768 FirstTTPD->hasDefaultArgument() &&
10769 !FirstTTPD->defaultArgumentWasInherited();
10770 bool HasSecondDefaultArgument =
10771 SecondTTPD->hasDefaultArgument() &&
10772 !SecondTTPD->defaultArgumentWasInherited();
10773 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10774 ODRDiagError(FirstTemplate->getLocation(),
10775 FirstTemplate->getSourceRange(),
10776 FunctionTemplateParameterSingleDefaultArgument)
10777 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10778 ODRDiagNote(SecondTemplate->getLocation(),
10779 SecondTemplate->getSourceRange(),
10780 FunctionTemplateParameterSingleDefaultArgument)
10781 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10782 ParameterMismatch = true;
10783 break;
10784 }
10785
10786 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10787 QualType FirstType = FirstTTPD->getDefaultArgument();
10788 QualType SecondType = SecondTTPD->getDefaultArgument();
10789 if (ComputeQualTypeODRHash(FirstType) !=
10790 ComputeQualTypeODRHash(SecondType)) {
10791 ODRDiagError(FirstTemplate->getLocation(),
10792 FirstTemplate->getSourceRange(),
10793 FunctionTemplateParameterDifferentDefaultArgument)
10794 << FirstTemplate << (i + 1) << FirstType;
10795 ODRDiagNote(SecondTemplate->getLocation(),
10796 SecondTemplate->getSourceRange(),
10797 FunctionTemplateParameterDifferentDefaultArgument)
10798 << SecondTemplate << (i + 1) << SecondType;
10799 ParameterMismatch = true;
10800 break;
10801 }
10802 }
10803
10804 if (FirstTTPD->isParameterPack() !=
10805 SecondTTPD->isParameterPack()) {
10806 ODRDiagError(FirstTemplate->getLocation(),
10807 FirstTemplate->getSourceRange(),
10808 FunctionTemplatePackParameter)
10809 << FirstTemplate << (i + 1) << FirstTTPD->isParameterPack();
10810 ODRDiagNote(SecondTemplate->getLocation(),
10811 SecondTemplate->getSourceRange(),
10812 FunctionTemplatePackParameter)
10813 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
10814 ParameterMismatch = true;
10815 break;
10816 }
10817 }
10818
10819 if (isa<TemplateTemplateParmDecl>(FirstParam) &&
10820 isa<TemplateTemplateParmDecl>(SecondParam)) {
10821 TemplateTemplateParmDecl *FirstTTPD =
10822 cast<TemplateTemplateParmDecl>(FirstParam);
10823 TemplateTemplateParmDecl *SecondTTPD =
10824 cast<TemplateTemplateParmDecl>(SecondParam);
10825
10826 TemplateParameterList *FirstTPL =
10827 FirstTTPD->getTemplateParameters();
10828 TemplateParameterList *SecondTPL =
10829 SecondTTPD->getTemplateParameters();
10830
10831 if (ComputeTemplateParameterListODRHash(FirstTPL) !=
10832 ComputeTemplateParameterListODRHash(SecondTPL)) {
10833 ODRDiagError(FirstTemplate->getLocation(),
10834 FirstTemplate->getSourceRange(),
10835 FunctionTemplateParameterDifferentType)
10836 << FirstTemplate << (i + 1);
10837 ODRDiagNote(SecondTemplate->getLocation(),
10838 SecondTemplate->getSourceRange(),
10839 FunctionTemplateParameterDifferentType)
10840 << SecondTemplate << (i + 1);
10841 ParameterMismatch = true;
10842 break;
10843 }
10844
10845 bool HasFirstDefaultArgument =
10846 FirstTTPD->hasDefaultArgument() &&
10847 !FirstTTPD->defaultArgumentWasInherited();
10848 bool HasSecondDefaultArgument =
10849 SecondTTPD->hasDefaultArgument() &&
10850 !SecondTTPD->defaultArgumentWasInherited();
10851 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10852 ODRDiagError(FirstTemplate->getLocation(),
10853 FirstTemplate->getSourceRange(),
10854 FunctionTemplateParameterSingleDefaultArgument)
10855 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10856 ODRDiagNote(SecondTemplate->getLocation(),
10857 SecondTemplate->getSourceRange(),
10858 FunctionTemplateParameterSingleDefaultArgument)
10859 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10860 ParameterMismatch = true;
10861 break;
10862 }
10863
10864 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10865 TemplateArgument FirstTA =
10866 FirstTTPD->getDefaultArgument().getArgument();
10867 TemplateArgument SecondTA =
10868 SecondTTPD->getDefaultArgument().getArgument();
10869 if (ComputeTemplateArgumentODRHash(FirstTA) !=
10870 ComputeTemplateArgumentODRHash(SecondTA)) {
10871 ODRDiagError(FirstTemplate->getLocation(),
10872 FirstTemplate->getSourceRange(),
10873 FunctionTemplateParameterDifferentDefaultArgument)
10874 << FirstTemplate << (i + 1) << FirstTA;
10875 ODRDiagNote(SecondTemplate->getLocation(),
10876 SecondTemplate->getSourceRange(),
10877 FunctionTemplateParameterDifferentDefaultArgument)
10878 << SecondTemplate << (i + 1) << SecondTA;
10879 ParameterMismatch = true;
10880 break;
10881 }
10882 }
10883
10884 if (FirstTTPD->isParameterPack() !=
10885 SecondTTPD->isParameterPack()) {
10886 ODRDiagError(FirstTemplate->getLocation(),
10887 FirstTemplate->getSourceRange(),
10888 FunctionTemplatePackParameter)
10889 << FirstTemplate << (i + 1) << FirstTTPD->isParameterPack();
10890 ODRDiagNote(SecondTemplate->getLocation(),
10891 SecondTemplate->getSourceRange(),
10892 FunctionTemplatePackParameter)
10893 << SecondTemplate << (i + 1) << SecondTTPD->isParameterPack();
10894 ParameterMismatch = true;
10895 break;
10896 }
10897 }
10898
10899 if (isa<NonTypeTemplateParmDecl>(FirstParam) &&
10900 isa<NonTypeTemplateParmDecl>(SecondParam)) {
10901 NonTypeTemplateParmDecl *FirstNTTPD =
10902 cast<NonTypeTemplateParmDecl>(FirstParam);
10903 NonTypeTemplateParmDecl *SecondNTTPD =
10904 cast<NonTypeTemplateParmDecl>(SecondParam);
10905
10906 QualType FirstType = FirstNTTPD->getType();
10907 QualType SecondType = SecondNTTPD->getType();
10908 if (ComputeQualTypeODRHash(FirstType) !=
10909 ComputeQualTypeODRHash(SecondType)) {
10910 ODRDiagError(FirstTemplate->getLocation(),
10911 FirstTemplate->getSourceRange(),
10912 FunctionTemplateParameterDifferentType)
10913 << FirstTemplate << (i + 1);
10914 ODRDiagNote(SecondTemplate->getLocation(),
10915 SecondTemplate->getSourceRange(),
10916 FunctionTemplateParameterDifferentType)
10917 << SecondTemplate << (i + 1);
10918 ParameterMismatch = true;
10919 break;
10920 }
10921
10922 bool HasFirstDefaultArgument =
10923 FirstNTTPD->hasDefaultArgument() &&
10924 !FirstNTTPD->defaultArgumentWasInherited();
10925 bool HasSecondDefaultArgument =
10926 SecondNTTPD->hasDefaultArgument() &&
10927 !SecondNTTPD->defaultArgumentWasInherited();
10928 if (HasFirstDefaultArgument != HasSecondDefaultArgument) {
10929 ODRDiagError(FirstTemplate->getLocation(),
10930 FirstTemplate->getSourceRange(),
10931 FunctionTemplateParameterSingleDefaultArgument)
10932 << FirstTemplate << (i + 1) << HasFirstDefaultArgument;
10933 ODRDiagNote(SecondTemplate->getLocation(),
10934 SecondTemplate->getSourceRange(),
10935 FunctionTemplateParameterSingleDefaultArgument)
10936 << SecondTemplate << (i + 1) << HasSecondDefaultArgument;
10937 ParameterMismatch = true;
10938 break;
10939 }
10940
10941 if (HasFirstDefaultArgument && HasSecondDefaultArgument) {
10942 Expr *FirstDefaultArgument = FirstNTTPD->getDefaultArgument();
10943 Expr *SecondDefaultArgument = SecondNTTPD->getDefaultArgument();
10944 if (ComputeODRHash(FirstDefaultArgument) !=
10945 ComputeODRHash(SecondDefaultArgument)) {
10946 ODRDiagError(FirstTemplate->getLocation(),
10947 FirstTemplate->getSourceRange(),
10948 FunctionTemplateParameterDifferentDefaultArgument)
10949 << FirstTemplate << (i + 1) << FirstDefaultArgument;
10950 ODRDiagNote(SecondTemplate->getLocation(),
10951 SecondTemplate->getSourceRange(),
10952 FunctionTemplateParameterDifferentDefaultArgument)
10953 << SecondTemplate << (i + 1) << SecondDefaultArgument;
10954 ParameterMismatch = true;
10955 break;
10956 }
10957 }
10958
10959 if (FirstNTTPD->isParameterPack() !=
10960 SecondNTTPD->isParameterPack()) {
10961 ODRDiagError(FirstTemplate->getLocation(),
10962 FirstTemplate->getSourceRange(),
10963 FunctionTemplatePackParameter)
10964 << FirstTemplate << (i + 1) << FirstNTTPD->isParameterPack();
10965 ODRDiagNote(SecondTemplate->getLocation(),
10966 SecondTemplate->getSourceRange(),
10967 FunctionTemplatePackParameter)
10968 << SecondTemplate << (i + 1)
10969 << SecondNTTPD->isParameterPack();
10970 ParameterMismatch = true;
10971 break;
10972 }
10973 }
10974 }
10975
10976 if (ParameterMismatch) {
10977 Diagnosed = true;
10978 break;
10979 }
10980
10981 break;
10982 }
10983 }
10984
10985 if (Diagnosed)
10986 continue;
10987
10988 Diag(FirstDecl->getLocation(),
10989 diag::err_module_odr_violation_mismatch_decl_unknown)
10990 << FirstRecord << FirstModule.empty() << FirstModule << FirstDiffType
10991 << FirstDecl->getSourceRange();
10992 Diag(SecondDecl->getLocation(),
10993 diag::note_module_odr_violation_mismatch_decl_unknown)
10994 << SecondModule << FirstDiffType << SecondDecl->getSourceRange();
10995 Diagnosed = true;
10996 }
10997
10998 if (!Diagnosed) {
10999 // All definitions are updates to the same declaration. This happens if a
11000 // module instantiates the declaration of a class template specialization
11001 // and two or more other modules instantiate its definition.
11002 //
11003 // FIXME: Indicate which modules had instantiations of this definition.
11004 // FIXME: How can this even happen?
11005 Diag(Merge.first->getLocation(),
11006 diag::err_module_odr_violation_different_instantiations)
11007 << Merge.first;
11008 }
11009 }
11010
11011 // Issue ODR failures diagnostics for functions.
11012 for (auto &Merge : FunctionOdrMergeFailures) {
11013 enum ODRFunctionDifference {
11014 ReturnType,
11015 ParameterName,
11016 ParameterType,
11017 ParameterSingleDefaultArgument,
11018 ParameterDifferentDefaultArgument,
11019 FunctionBody,
11020 };
11021
11022 FunctionDecl *FirstFunction = Merge.first;
11023 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstFunction);
11024
11025 bool Diagnosed = false;
11026 for (auto &SecondFunction : Merge.second) {
11027
11028 if (FirstFunction == SecondFunction)
11029 continue;
11030
11031 std::string SecondModule =
11032 getOwningModuleNameForDiagnostic(SecondFunction);
11033
11034 auto ODRDiagError = [FirstFunction, &FirstModule,
11035 this](SourceLocation Loc, SourceRange Range,
11036 ODRFunctionDifference DiffType) {
11037 return Diag(Loc, diag::err_module_odr_violation_function)
11038 << FirstFunction << FirstModule.empty() << FirstModule << Range
11039 << DiffType;
11040 };
11041 auto ODRDiagNote = [&SecondModule, this](SourceLocation Loc,
11042 SourceRange Range,
11043 ODRFunctionDifference DiffType) {
11044 return Diag(Loc, diag::note_module_odr_violation_function)
11045 << SecondModule << Range << DiffType;
11046 };
11047
11048 if (ComputeQualTypeODRHash(FirstFunction->getReturnType()) !=
11049 ComputeQualTypeODRHash(SecondFunction->getReturnType())) {
11050 ODRDiagError(FirstFunction->getReturnTypeSourceRange().getBegin(),
11051 FirstFunction->getReturnTypeSourceRange(), ReturnType)
11052 << FirstFunction->getReturnType();
11053 ODRDiagNote(SecondFunction->getReturnTypeSourceRange().getBegin(),
11054 SecondFunction->getReturnTypeSourceRange(), ReturnType)
11055 << SecondFunction->getReturnType();
11056 Diagnosed = true;
11057 break;
11058 }
11059
11060 assert(FirstFunction->param_size() == SecondFunction->param_size() &&
11061 "Merged functions with different number of parameters");
11062
11063 auto ParamSize = FirstFunction->param_size();
11064 bool ParameterMismatch = false;
11065 for (unsigned I = 0; I < ParamSize; ++I) {
11066 auto *FirstParam = FirstFunction->getParamDecl(I);
11067 auto *SecondParam = SecondFunction->getParamDecl(I);
11068
11069 assert(getContext().hasSameType(FirstParam->getType(),
11070 SecondParam->getType()) &&
11071 "Merged function has different parameter types.");
11072
11073 if (FirstParam->getDeclName() != SecondParam->getDeclName()) {
11074 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11075 ParameterName)
11076 << I + 1 << FirstParam->getDeclName();
11077 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11078 ParameterName)
11079 << I + 1 << SecondParam->getDeclName();
11080 ParameterMismatch = true;
11081 break;
11082 };
11083
11084 QualType FirstParamType = FirstParam->getType();
11085 QualType SecondParamType = SecondParam->getType();
11086 if (FirstParamType != SecondParamType &&
11087 ComputeQualTypeODRHash(FirstParamType) !=
11088 ComputeQualTypeODRHash(SecondParamType)) {
11089 if (const DecayedType *ParamDecayedType =
11090 FirstParamType->getAs<DecayedType>()) {
11091 ODRDiagError(FirstParam->getLocation(),
11092 FirstParam->getSourceRange(), ParameterType)
11093 << (I + 1) << FirstParamType << true
11094 << ParamDecayedType->getOriginalType();
11095 } else {
11096 ODRDiagError(FirstParam->getLocation(),
11097 FirstParam->getSourceRange(), ParameterType)
11098 << (I + 1) << FirstParamType << false;
11099 }
11100
11101 if (const DecayedType *ParamDecayedType =
11102 SecondParamType->getAs<DecayedType>()) {
11103 ODRDiagNote(SecondParam->getLocation(),
11104 SecondParam->getSourceRange(), ParameterType)
11105 << (I + 1) << SecondParamType << true
11106 << ParamDecayedType->getOriginalType();
11107 } else {
11108 ODRDiagNote(SecondParam->getLocation(),
11109 SecondParam->getSourceRange(), ParameterType)
11110 << (I + 1) << SecondParamType << false;
11111 }
11112 ParameterMismatch = true;
11113 break;
11114 }
11115
11116 const Expr *FirstInit = FirstParam->getInit();
11117 const Expr *SecondInit = SecondParam->getInit();
11118 if ((FirstInit == nullptr) != (SecondInit == nullptr)) {
11119 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11120 ParameterSingleDefaultArgument)
11121 << (I + 1) << (FirstInit == nullptr)
11122 << (FirstInit ? FirstInit->getSourceRange() : SourceRange());
11123 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11124 ParameterSingleDefaultArgument)
11125 << (I + 1) << (SecondInit == nullptr)
11126 << (SecondInit ? SecondInit->getSourceRange() : SourceRange());
11127 ParameterMismatch = true;
11128 break;
11129 }
11130
11131 if (FirstInit && SecondInit &&
11132 ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11133 ODRDiagError(FirstParam->getLocation(), FirstParam->getSourceRange(),
11134 ParameterDifferentDefaultArgument)
11135 << (I + 1) << FirstInit->getSourceRange();
11136 ODRDiagNote(SecondParam->getLocation(), SecondParam->getSourceRange(),
11137 ParameterDifferentDefaultArgument)
11138 << (I + 1) << SecondInit->getSourceRange();
11139 ParameterMismatch = true;
11140 break;
11141 }
11142
11143 assert(ComputeSubDeclODRHash(FirstParam) ==
11144 ComputeSubDeclODRHash(SecondParam) &&
11145 "Undiagnosed parameter difference.");
11146 }
11147
11148 if (ParameterMismatch) {
11149 Diagnosed = true;
11150 break;
11151 }
11152
11153 // If no error has been generated before now, assume the problem is in
11154 // the body and generate a message.
11155 ODRDiagError(FirstFunction->getLocation(),
11156 FirstFunction->getSourceRange(), FunctionBody);
11157 ODRDiagNote(SecondFunction->getLocation(),
11158 SecondFunction->getSourceRange(), FunctionBody);
11159 Diagnosed = true;
11160 break;
11161 }
11162 (void)Diagnosed;
11163 assert(Diagnosed && "Unable to emit ODR diagnostic.");
11164 }
11165
11166 // Issue ODR failures diagnostics for enums.
11167 for (auto &Merge : EnumOdrMergeFailures) {
11168 enum ODREnumDifference {
11169 SingleScopedEnum,
11170 EnumTagKeywordMismatch,
11171 SingleSpecifiedType,
11172 DifferentSpecifiedTypes,
11173 DifferentNumberEnumConstants,
11174 EnumConstantName,
11175 EnumConstantSingleInitilizer,
11176 EnumConstantDifferentInitilizer,
11177 };
11178
11179 // If we've already pointed out a specific problem with this enum, don't
11180 // bother issuing a general "something's different" diagnostic.
11181 if (!DiagnosedOdrMergeFailures.insert(Merge.first).second)
11182 continue;
11183
11184 EnumDecl *FirstEnum = Merge.first;
11185 std::string FirstModule = getOwningModuleNameForDiagnostic(FirstEnum);
11186
11187 using DeclHashes =
11188 llvm::SmallVector<std::pair<EnumConstantDecl *, unsigned>, 4>;
11189 auto PopulateHashes = [&ComputeSubDeclODRHash, FirstEnum](
11190 DeclHashes &Hashes, EnumDecl *Enum) {
11191 for (auto *D : Enum->decls()) {
11192 // Due to decl merging, the first EnumDecl is the parent of
11193 // Decls in both records.
11194 if (!ODRHash::isWhitelistedDecl(D, FirstEnum))
11195 continue;
11196 assert(isa<EnumConstantDecl>(D) && "Unexpected Decl kind");
11197 Hashes.emplace_back(cast<EnumConstantDecl>(D),
11198 ComputeSubDeclODRHash(D));
11199 }
11200 };
11201 DeclHashes FirstHashes;
11202 PopulateHashes(FirstHashes, FirstEnum);
11203 bool Diagnosed = false;
11204 for (auto &SecondEnum : Merge.second) {
11205
11206 if (FirstEnum == SecondEnum)
11207 continue;
11208
11209 std::string SecondModule =
11210 getOwningModuleNameForDiagnostic(SecondEnum);
11211
11212 auto ODRDiagError = [FirstEnum, &FirstModule,
11213 this](SourceLocation Loc, SourceRange Range,
11214 ODREnumDifference DiffType) {
11215 return Diag(Loc, diag::err_module_odr_violation_enum)
11216 << FirstEnum << FirstModule.empty() << FirstModule << Range
11217 << DiffType;
11218 };
11219 auto ODRDiagNote = [&SecondModule, this](SourceLocation Loc,
11220 SourceRange Range,
11221 ODREnumDifference DiffType) {
11222 return Diag(Loc, diag::note_module_odr_violation_enum)
11223 << SecondModule << Range << DiffType;
11224 };
11225
11226 if (FirstEnum->isScoped() != SecondEnum->isScoped()) {
11227 ODRDiagError(FirstEnum->getLocation(), FirstEnum->getSourceRange(),
11228 SingleScopedEnum)
11229 << FirstEnum->isScoped();
11230 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11231 SingleScopedEnum)
11232 << SecondEnum->isScoped();
11233 Diagnosed = true;
11234 continue;
11235 }
11236
11237 if (FirstEnum->isScoped() && SecondEnum->isScoped()) {
11238 if (FirstEnum->isScopedUsingClassTag() !=
11239 SecondEnum->isScopedUsingClassTag()) {
11240 ODRDiagError(FirstEnum->getLocation(), FirstEnum->getSourceRange(),
11241 EnumTagKeywordMismatch)
11242 << FirstEnum->isScopedUsingClassTag();
11243 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11244 EnumTagKeywordMismatch)
11245 << SecondEnum->isScopedUsingClassTag();
11246 Diagnosed = true;
11247 continue;
11248 }
11249 }
11250
11251 QualType FirstUnderlyingType =
11252 FirstEnum->getIntegerTypeSourceInfo()
11253 ? FirstEnum->getIntegerTypeSourceInfo()->getType()
11254 : QualType();
11255 QualType SecondUnderlyingType =
11256 SecondEnum->getIntegerTypeSourceInfo()
11257 ? SecondEnum->getIntegerTypeSourceInfo()->getType()
11258 : QualType();
11259 if (FirstUnderlyingType.isNull() != SecondUnderlyingType.isNull()) {
11260 ODRDiagError(FirstEnum->getLocation(), FirstEnum->getSourceRange(),
11261 SingleSpecifiedType)
11262 << !FirstUnderlyingType.isNull();
11263 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11264 SingleSpecifiedType)
11265 << !SecondUnderlyingType.isNull();
11266 Diagnosed = true;
11267 continue;
11268 }
11269
11270 if (!FirstUnderlyingType.isNull() && !SecondUnderlyingType.isNull()) {
11271 if (ComputeQualTypeODRHash(FirstUnderlyingType) !=
11272 ComputeQualTypeODRHash(SecondUnderlyingType)) {
11273 ODRDiagError(FirstEnum->getLocation(), FirstEnum->getSourceRange(),
11274 DifferentSpecifiedTypes)
11275 << FirstUnderlyingType;
11276 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11277 DifferentSpecifiedTypes)
11278 << SecondUnderlyingType;
11279 Diagnosed = true;
11280 continue;
11281 }
11282 }
11283
11284 DeclHashes SecondHashes;
11285 PopulateHashes(SecondHashes, SecondEnum);
11286
11287 if (FirstHashes.size() != SecondHashes.size()) {
11288 ODRDiagError(FirstEnum->getLocation(), FirstEnum->getSourceRange(),
11289 DifferentNumberEnumConstants)
11290 << (int)FirstHashes.size();
11291 ODRDiagNote(SecondEnum->getLocation(), SecondEnum->getSourceRange(),
11292 DifferentNumberEnumConstants)
11293 << (int)SecondHashes.size();
11294 Diagnosed = true;
11295 continue;
11296 }
11297
11298 for (unsigned I = 0; I < FirstHashes.size(); ++I) {
11299 if (FirstHashes[I].second == SecondHashes[I].second)
11300 continue;
11301 const EnumConstantDecl *FirstEnumConstant = FirstHashes[I].first;
11302 const EnumConstantDecl *SecondEnumConstant = SecondHashes[I].first;
11303
11304 if (FirstEnumConstant->getDeclName() !=
11305 SecondEnumConstant->getDeclName()) {
11306
11307 ODRDiagError(FirstEnumConstant->getLocation(),
11308 FirstEnumConstant->getSourceRange(), EnumConstantName)
11309 << I + 1 << FirstEnumConstant;
11310 ODRDiagNote(SecondEnumConstant->getLocation(),
11311 SecondEnumConstant->getSourceRange(), EnumConstantName)
11312 << I + 1 << SecondEnumConstant;
11313 Diagnosed = true;
11314 break;
11315 }
11316
11317 const Expr *FirstInit = FirstEnumConstant->getInitExpr();
11318 const Expr *SecondInit = SecondEnumConstant->getInitExpr();
11319 if (!FirstInit && !SecondInit)
11320 continue;
11321
11322 if (!FirstInit || !SecondInit) {
11323 ODRDiagError(FirstEnumConstant->getLocation(),
11324 FirstEnumConstant->getSourceRange(),
11325 EnumConstantSingleInitilizer)
11326 << I + 1 << FirstEnumConstant << (FirstInit != nullptr);
11327 ODRDiagNote(SecondEnumConstant->getLocation(),
11328 SecondEnumConstant->getSourceRange(),
11329 EnumConstantSingleInitilizer)
11330 << I + 1 << SecondEnumConstant << (SecondInit != nullptr);
11331 Diagnosed = true;
11332 break;
11333 }
11334
11335 if (ComputeODRHash(FirstInit) != ComputeODRHash(SecondInit)) {
11336 ODRDiagError(FirstEnumConstant->getLocation(),
11337 FirstEnumConstant->getSourceRange(),
11338 EnumConstantDifferentInitilizer)
11339 << I + 1 << FirstEnumConstant;
11340 ODRDiagNote(SecondEnumConstant->getLocation(),
11341 SecondEnumConstant->getSourceRange(),
11342 EnumConstantDifferentInitilizer)
11343 << I + 1 << SecondEnumConstant;
11344 Diagnosed = true;
11345 break;
11346 }
11347 }
11348 }
11349
11350 (void)Diagnosed;
11351 assert(Diagnosed && "Unable to emit ODR diagnostic.");
11352 }
11353 }
11354
11355 void ASTReader::StartedDeserializing() {
11356 if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
11357 ReadTimer->startTimer();
11358 }
11359
11360 void ASTReader::FinishedDeserializing() {
11361 assert(NumCurrentElementsDeserializing &&
11362 "FinishedDeserializing not paired with StartedDeserializing");
11363 if (NumCurrentElementsDeserializing == 1) {
11364 // We decrease NumCurrentElementsDeserializing only after pending actions
11365 // are finished, to avoid recursively re-calling finishPendingActions().
11366 finishPendingActions();
11367 }
11368 --NumCurrentElementsDeserializing;
11369
11370 if (NumCurrentElementsDeserializing == 0) {
11371 // Propagate exception specification and deduced type updates along
11372 // redeclaration chains.
11373 //
11374 // We do this now rather than in finishPendingActions because we want to
11375 // be able to walk the complete redeclaration chains of the updated decls.
11376 while (!PendingExceptionSpecUpdates.empty() ||
11377 !PendingDeducedTypeUpdates.empty()) {
11378 auto ESUpdates = std::move(PendingExceptionSpecUpdates);
11379 PendingExceptionSpecUpdates.clear();
11380 for (auto Update : ESUpdates) {
11381 ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
11382 auto *FPT = Update.second->getType()->castAs<FunctionProtoType>();
11383 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
11384 if (auto *Listener = getContext().getASTMutationListener())
11385 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(Update.second));
11386 for (auto *Redecl : Update.second->redecls())
11387 getContext().adjustExceptionSpec(cast<FunctionDecl>(Redecl), ESI);
11388 }
11389
11390 auto DTUpdates = std::move(PendingDeducedTypeUpdates);
11391 PendingDeducedTypeUpdates.clear();
11392 for (auto Update : DTUpdates) {
11393 ProcessingUpdatesRAIIObj ProcessingUpdates(*this);
11394 // FIXME: If the return type is already deduced, check that it matches.
11395 getContext().adjustDeducedFunctionResultType(Update.first,
11396 Update.second);
11397 }
11398 }
11399
11400 if (ReadTimer)
11401 ReadTimer->stopTimer();
11402
11403 diagnoseOdrViolations();
11404
11405 // We are not in recursive loading, so it's safe to pass the "interesting"
11406 // decls to the consumer.
11407 if (Consumer)
11408 PassInterestingDeclsToConsumer();
11409 }
11410 }
11411
11412 void ASTReader::pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name) {
11413 if (IdentifierInfo *II = Name.getAsIdentifierInfo()) {
11414 // Remove any fake results before adding any real ones.
11415 auto It = PendingFakeLookupResults.find(II);
11416 if (It != PendingFakeLookupResults.end()) {
11417 for (auto *ND : It->second)
11418 SemaObj->IdResolver.RemoveDecl(ND);
11419 // FIXME: this works around module+PCH performance issue.
11420 // Rather than erase the result from the map, which is O(n), just clear
11421 // the vector of NamedDecls.
11422 It->second.clear();
11423 }
11424 }
11425
11426 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
11427 SemaObj->TUScope->AddDecl(D);
11428 } else if (SemaObj->TUScope) {
11429 // Adding the decl to IdResolver may have failed because it was already in
11430 // (even though it was not added in scope). If it is already in, make sure
11431 // it gets in the scope as well.
11432 if (std::find(SemaObj->IdResolver.begin(Name),
11433 SemaObj->IdResolver.end(), D) != SemaObj->IdResolver.end())
11434 SemaObj->TUScope->AddDecl(D);
11435 }
11436 }
11437
11438 ASTReader::ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache,
11439 ASTContext *Context,
11440 const PCHContainerReader &PCHContainerRdr,
11441 ArrayRef<std::shared_ptr<ModuleFileExtension>> Extensions,
11442 StringRef isysroot, bool DisableValidation,
11443 bool AllowASTWithCompilerErrors,
11444 bool AllowConfigurationMismatch, bool ValidateSystemInputs,
11445 bool ValidateASTInputFilesContent, bool UseGlobalIndex,
11446 std::unique_ptr<llvm::Timer> ReadTimer)
11447 : Listener(DisableValidation
11448 ? cast<ASTReaderListener>(new SimpleASTReaderListener(PP))
11449 : cast<ASTReaderListener>(new PCHValidator(PP, *this))),
11450 SourceMgr(PP.getSourceManager()), FileMgr(PP.getFileManager()),
11451 PCHContainerRdr(PCHContainerRdr), Diags(PP.getDiagnostics()), PP(PP),
11452 ContextObj(Context), ModuleMgr(PP.getFileManager(), ModuleCache,
11453 PCHContainerRdr, PP.getHeaderSearchInfo()),
11454 DummyIdResolver(PP), ReadTimer(std::move(ReadTimer)), isysroot(isysroot),
11455 DisableValidation(DisableValidation),
11456 AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
11457 AllowConfigurationMismatch(AllowConfigurationMismatch),
11458 ValidateSystemInputs(ValidateSystemInputs),
11459 ValidateASTInputFilesContent(ValidateASTInputFilesContent),
11460 UseGlobalIndex(UseGlobalIndex), CurrSwitchCaseStmts(&SwitchCaseStmts) {
11461 SourceMgr.setExternalSLocEntrySource(this);
11462
11463 for (const auto &Ext : Extensions) {
11464 auto BlockName = Ext->getExtensionMetadata().BlockName;
11465 auto Known = ModuleFileExtensions.find(BlockName);
11466 if (Known != ModuleFileExtensions.end()) {
11467 Diags.Report(diag::warn_duplicate_module_file_extension)
11468 << BlockName;
11469 continue;
11470 }
11471
11472 ModuleFileExtensions.insert({BlockName, Ext});
11473 }
11474 }
11475
11476 ASTReader::~ASTReader() {
11477 if (OwnsDeserializationListener)
11478 delete DeserializationListener;
11479 }
11480
11481 IdentifierResolver &ASTReader::getIdResolver() {
11482 return SemaObj ? SemaObj->IdResolver : DummyIdResolver;
11483 }
11484
11485 Expected<unsigned> ASTRecordReader::readRecord(llvm::BitstreamCursor &Cursor,
11486 unsigned AbbrevID) {
11487 Idx = 0;
11488 Record.clear();
11489 return Cursor.readRecord(AbbrevID, Record);
11490 }
11491 //===----------------------------------------------------------------------===//
11492 //// OMPClauseReader implementation
11493 ////===----------------------------------------------------------------------===//
11494
11495 // This has to be in namespace clang because it's friended by all
11496 // of the OMP clauses.
11497 namespace clang {
11498
11499 class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
11500 ASTRecordReader &Record;
11501 ASTContext &Context;
11502
11503 public:
11504 OMPClauseReader(ASTRecordReader &Record)
11505 : Record(Record), Context(Record.getContext()) {}
11506
11507 #define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
11508 #include "clang/Basic/OpenMPKinds.def"
11509 OMPClause *readClause();
11510 void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
11511 void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
11512 };
11513
11514 } // end namespace clang
11515
11516 OMPClause *ASTRecordReader::readOMPClause() {
11517 return OMPClauseReader(*this).readClause();
11518 }
11519
11520 OMPClause *OMPClauseReader::readClause() {
11521 OMPClause *C = nullptr;
11522 switch (Record.readInt()) {
11523 case OMPC_if:
11524 C = new (Context) OMPIfClause();
11525 break;
11526 case OMPC_final:
11527 C = new (Context) OMPFinalClause();
11528 break;
11529 case OMPC_num_threads:
11530 C = new (Context) OMPNumThreadsClause();
11531 break;
11532 case OMPC_safelen:
11533 C = new (Context) OMPSafelenClause();
11534 break;
11535 case OMPC_simdlen:
11536 C = new (Context) OMPSimdlenClause();
11537 break;
11538 case OMPC_allocator:
11539 C = new (Context) OMPAllocatorClause();
11540 break;
11541 case OMPC_collapse:
11542 C = new (Context) OMPCollapseClause();
11543 break;
11544 case OMPC_default:
11545 C = new (Context) OMPDefaultClause();
11546 break;
11547 case OMPC_proc_bind:
11548 C = new (Context) OMPProcBindClause();
11549 break;
11550 case OMPC_schedule:
11551 C = new (Context) OMPScheduleClause();
11552 break;
11553 case OMPC_ordered:
11554 C = OMPOrderedClause::CreateEmpty(Context, Record.readInt());
11555 break;
11556 case OMPC_nowait:
11557 C = new (Context) OMPNowaitClause();
11558 break;
11559 case OMPC_untied:
11560 C = new (Context) OMPUntiedClause();
11561 break;
11562 case OMPC_mergeable:
11563 C = new (Context) OMPMergeableClause();
11564 break;
11565 case OMPC_read:
11566 C = new (Context) OMPReadClause();
11567 break;
11568 case OMPC_write:
11569 C = new (Context) OMPWriteClause();
11570 break;
11571 case OMPC_update:
11572 C = new (Context) OMPUpdateClause();
11573 break;
11574 case OMPC_capture:
11575 C = new (Context) OMPCaptureClause();
11576 break;
11577 case OMPC_seq_cst:
11578 C = new (Context) OMPSeqCstClause();
11579 break;
11580 case OMPC_threads:
11581 C = new (Context) OMPThreadsClause();
11582 break;
11583 case OMPC_simd:
11584 C = new (Context) OMPSIMDClause();
11585 break;
11586 case OMPC_nogroup:
11587 C = new (Context) OMPNogroupClause();
11588 break;
11589 case OMPC_unified_address:
11590 C = new (Context) OMPUnifiedAddressClause();
11591 break;
11592 case OMPC_unified_shared_memory:
11593 C = new (Context) OMPUnifiedSharedMemoryClause();
11594 break;
11595 case OMPC_reverse_offload:
11596 C = new (Context) OMPReverseOffloadClause();
11597 break;
11598 case OMPC_dynamic_allocators:
11599 C = new (Context) OMPDynamicAllocatorsClause();
11600 break;
11601 case OMPC_atomic_default_mem_order:
11602 C = new (Context) OMPAtomicDefaultMemOrderClause();
11603 break;
11604 case OMPC_private:
11605 C = OMPPrivateClause::CreateEmpty(Context, Record.readInt());
11606 break;
11607 case OMPC_firstprivate:
11608 C = OMPFirstprivateClause::CreateEmpty(Context, Record.readInt());
11609 break;
11610 case OMPC_lastprivate:
11611 C = OMPLastprivateClause::CreateEmpty(Context, Record.readInt());
11612 break;
11613 case OMPC_shared:
11614 C = OMPSharedClause::CreateEmpty(Context, Record.readInt());
11615 break;
11616 case OMPC_reduction:
11617 C = OMPReductionClause::CreateEmpty(Context, Record.readInt());
11618 break;
11619 case OMPC_task_reduction:
11620 C = OMPTaskReductionClause::CreateEmpty(Context, Record.readInt());
11621 break;
11622 case OMPC_in_reduction:
11623 C = OMPInReductionClause::CreateEmpty(Context, Record.readInt());
11624 break;
11625 case OMPC_linear:
11626 C = OMPLinearClause::CreateEmpty(Context, Record.readInt());
11627 break;
11628 case OMPC_aligned:
11629 C = OMPAlignedClause::CreateEmpty(Context, Record.readInt());
11630 break;
11631 case OMPC_copyin:
11632 C = OMPCopyinClause::CreateEmpty(Context, Record.readInt());
11633 break;
11634 case OMPC_copyprivate:
11635 C = OMPCopyprivateClause::CreateEmpty(Context, Record.readInt());
11636 break;
11637 case OMPC_flush:
11638 C = OMPFlushClause::CreateEmpty(Context, Record.readInt());
11639 break;
11640 case OMPC_depend: {
11641 unsigned NumVars = Record.readInt();
11642 unsigned NumLoops = Record.readInt();
11643 C = OMPDependClause::CreateEmpty(Context, NumVars, NumLoops);
11644 break;
11645 }
11646 case OMPC_device:
11647 C = new (Context) OMPDeviceClause();
11648 break;
11649 case OMPC_map: {
11650 OMPMappableExprListSizeTy Sizes;
11651 Sizes.NumVars = Record.readInt();
11652 Sizes.NumUniqueDeclarations = Record.readInt();
11653 Sizes.NumComponentLists = Record.readInt();
11654 Sizes.NumComponents = Record.readInt();
11655 C = OMPMapClause::CreateEmpty(Context, Sizes);
11656 break;
11657 }
11658 case OMPC_num_teams:
11659 C = new (Context) OMPNumTeamsClause();
11660 break;
11661 case OMPC_thread_limit:
11662 C = new (Context) OMPThreadLimitClause();
11663 break;
11664 case OMPC_priority:
11665 C = new (Context) OMPPriorityClause();
11666 break;
11667 case OMPC_grainsize:
11668 C = new (Context) OMPGrainsizeClause();
11669 break;
11670 case OMPC_num_tasks:
11671 C = new (Context) OMPNumTasksClause();
11672 break;
11673 case OMPC_hint:
11674 C = new (Context) OMPHintClause();
11675 break;
11676 case OMPC_dist_schedule:
11677 C = new (Context) OMPDistScheduleClause();
11678 break;
11679 case OMPC_defaultmap:
11680 C = new (Context) OMPDefaultmapClause();
11681 break;
11682 case OMPC_to: {
11683 OMPMappableExprListSizeTy Sizes;
11684 Sizes.NumVars = Record.readInt();
11685 Sizes.NumUniqueDeclarations = Record.readInt();
11686 Sizes.NumComponentLists = Record.readInt();
11687 Sizes.NumComponents = Record.readInt();
11688 C = OMPToClause::CreateEmpty(Context, Sizes);
11689 break;
11690 }
11691 case OMPC_from: {
11692 OMPMappableExprListSizeTy Sizes;
11693 Sizes.NumVars = Record.readInt();
11694 Sizes.NumUniqueDeclarations = Record.readInt();
11695 Sizes.NumComponentLists = Record.readInt();
11696 Sizes.NumComponents = Record.readInt();
11697 C = OMPFromClause::CreateEmpty(Context, Sizes);
11698 break;
11699 }
11700 case OMPC_use_device_ptr: {
11701 OMPMappableExprListSizeTy Sizes;
11702 Sizes.NumVars = Record.readInt();
11703 Sizes.NumUniqueDeclarations = Record.readInt();
11704 Sizes.NumComponentLists = Record.readInt();
11705 Sizes.NumComponents = Record.readInt();
11706 C = OMPUseDevicePtrClause::CreateEmpty(Context, Sizes);
11707 break;
11708 }
11709 case OMPC_is_device_ptr: {
11710 OMPMappableExprListSizeTy Sizes;
11711 Sizes.NumVars = Record.readInt();
11712 Sizes.NumUniqueDeclarations = Record.readInt();
11713 Sizes.NumComponentLists = Record.readInt();
11714 Sizes.NumComponents = Record.readInt();
11715 C = OMPIsDevicePtrClause::CreateEmpty(Context, Sizes);
11716 break;
11717 }
11718 case OMPC_allocate:
11719 C = OMPAllocateClause::CreateEmpty(Context, Record.readInt());
11720 break;
11721 case OMPC_nontemporal:
11722 C = OMPNontemporalClause::CreateEmpty(Context, Record.readInt());
11723 break;
11724 }
11725 assert(C && "Unknown OMPClause type");
11726
11727 Visit(C);
11728 C->setLocStart(Record.readSourceLocation());
11729 C->setLocEnd(Record.readSourceLocation());
11730
11731 return C;
11732 }
11733
11734 void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
11735 C->setPreInitStmt(Record.readSubStmt(),
11736 static_cast<OpenMPDirectiveKind>(Record.readInt()));
11737 }
11738
11739 void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
11740 VisitOMPClauseWithPreInit(C);
11741 C->setPostUpdateExpr(Record.readSubExpr());
11742 }
11743
11744 void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
11745 VisitOMPClauseWithPreInit(C);
11746 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Record.readInt()));
11747 C->setNameModifierLoc(Record.readSourceLocation());
11748 C->setColonLoc(Record.readSourceLocation());
11749 C->setCondition(Record.readSubExpr());
11750 C->setLParenLoc(Record.readSourceLocation());
11751 }
11752
11753 void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {
11754 VisitOMPClauseWithPreInit(C);
11755 C->setCondition(Record.readSubExpr());
11756 C->setLParenLoc(Record.readSourceLocation());
11757 }
11758
11759 void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
11760 VisitOMPClauseWithPreInit(C);
11761 C->setNumThreads(Record.readSubExpr());
11762 C->setLParenLoc(Record.readSourceLocation());
11763 }
11764
11765 void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) {
11766 C->setSafelen(Record.readSubExpr());
11767 C->setLParenLoc(Record.readSourceLocation());
11768 }
11769
11770 void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
11771 C->setSimdlen(Record.readSubExpr());
11772 C->setLParenLoc(Record.readSourceLocation());
11773 }
11774
11775 void OMPClauseReader::VisitOMPAllocatorClause(OMPAllocatorClause *C) {
11776 C->setAllocator(Record.readExpr());
11777 C->setLParenLoc(Record.readSourceLocation());
11778 }
11779
11780 void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
11781 C->setNumForLoops(Record.readSubExpr());
11782 C->setLParenLoc(Record.readSourceLocation());
11783 }
11784
11785 void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
11786 C->setDefaultKind(
11787 static_cast<OpenMPDefaultClauseKind>(Record.readInt()));
11788 C->setLParenLoc(Record.readSourceLocation());
11789 C->setDefaultKindKwLoc(Record.readSourceLocation());
11790 }
11791
11792 void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
11793 C->setProcBindKind(static_cast<llvm::omp::ProcBindKind>(Record.readInt()));
11794 C->setLParenLoc(Record.readSourceLocation());
11795 C->setProcBindKindKwLoc(Record.readSourceLocation());
11796 }
11797
11798 void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
11799 VisitOMPClauseWithPreInit(C);
11800 C->setScheduleKind(
11801 static_cast<OpenMPScheduleClauseKind>(Record.readInt()));
11802 C->setFirstScheduleModifier(
11803 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
11804 C->setSecondScheduleModifier(
11805 static_cast<OpenMPScheduleClauseModifier>(Record.readInt()));
11806 C->setChunkSize(Record.readSubExpr());
11807 C->setLParenLoc(Record.readSourceLocation());
11808 C->setFirstScheduleModifierLoc(Record.readSourceLocation());
11809 C->setSecondScheduleModifierLoc(Record.readSourceLocation());
11810 C->setScheduleKindLoc(Record.readSourceLocation());
11811 C->setCommaLoc(Record.readSourceLocation());
11812 }
11813
11814 void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) {
11815 C->setNumForLoops(Record.readSubExpr());
11816 for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11817 C->setLoopNumIterations(I, Record.readSubExpr());
11818 for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11819 C->setLoopCounter(I, Record.readSubExpr());
11820 C->setLParenLoc(Record.readSourceLocation());
11821 }
11822
11823 void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
11824
11825 void OMPClauseReader::VisitOMPUntiedClause(OMPUntiedClause *) {}
11826
11827 void OMPClauseReader::VisitOMPMergeableClause(OMPMergeableClause *) {}
11828
11829 void OMPClauseReader::VisitOMPReadClause(OMPReadClause *) {}
11830
11831 void OMPClauseReader::VisitOMPWriteClause(OMPWriteClause *) {}
11832
11833 void OMPClauseReader::VisitOMPUpdateClause(OMPUpdateClause *) {}
11834
11835 void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}
11836
11837 void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}
11838
11839 void OMPClauseReader::VisitOMPThreadsClause(OMPThreadsClause *) {}
11840
11841 void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
11842
11843 void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {}
11844
11845 void OMPClauseReader::VisitOMPUnifiedAddressClause(OMPUnifiedAddressClause *) {}
11846
11847 void OMPClauseReader::VisitOMPUnifiedSharedMemoryClause(
11848 OMPUnifiedSharedMemoryClause *) {}
11849
11850 void OMPClauseReader::VisitOMPReverseOffloadClause(OMPReverseOffloadClause *) {}
11851
11852 void
11853 OMPClauseReader::VisitOMPDynamicAllocatorsClause(OMPDynamicAllocatorsClause *) {
11854 }
11855
11856 void OMPClauseReader::VisitOMPAtomicDefaultMemOrderClause(
11857 OMPAtomicDefaultMemOrderClause *C) {
11858 C->setAtomicDefaultMemOrderKind(
11859 static_cast<OpenMPAtomicDefaultMemOrderClauseKind>(Record.readInt()));
11860 C->setLParenLoc(Record.readSourceLocation());
11861 C->setAtomicDefaultMemOrderKindKwLoc(Record.readSourceLocation());
11862 }
11863
11864 void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
11865 C->setLParenLoc(Record.readSourceLocation());
11866 unsigned NumVars = C->varlist_size();
11867 SmallVector<Expr *, 16> Vars;
11868 Vars.reserve(NumVars);
11869 for (unsigned i = 0; i != NumVars; ++i)
11870 Vars.push_back(Record.readSubExpr());
11871 C->setVarRefs(Vars);
11872 Vars.clear();
11873 for (unsigned i = 0; i != NumVars; ++i)
11874 Vars.push_back(Record.readSubExpr());
11875 C->setPrivateCopies(Vars);
11876 }
11877
11878 void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
11879 VisitOMPClauseWithPreInit(C);
11880 C->setLParenLoc(Record.readSourceLocation());
11881 unsigned NumVars = C->varlist_size();
11882 SmallVector<Expr *, 16> Vars;
11883 Vars.reserve(NumVars);
11884 for (unsigned i = 0; i != NumVars; ++i)
11885 Vars.push_back(Record.readSubExpr());
11886 C->setVarRefs(Vars);
11887 Vars.clear();
11888 for (unsigned i = 0; i != NumVars; ++i)
11889 Vars.push_back(Record.readSubExpr());
11890 C->setPrivateCopies(Vars);
11891 Vars.clear();
11892 for (unsigned i = 0; i != NumVars; ++i)
11893 Vars.push_back(Record.readSubExpr());
11894 C->setInits(Vars);
11895 }
11896
11897 void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
11898 VisitOMPClauseWithPostUpdate(C);
11899 C->setLParenLoc(Record.readSourceLocation());
11900 C->setKind(Record.readEnum<OpenMPLastprivateModifier>());
11901 C->setKindLoc(Record.readSourceLocation());
11902 C->setColonLoc(Record.readSourceLocation());
11903 unsigned NumVars = C->varlist_size();
11904 SmallVector<Expr *, 16> Vars;
11905 Vars.reserve(NumVars);
11906 for (unsigned i = 0; i != NumVars; ++i)
11907 Vars.push_back(Record.readSubExpr());
11908 C->setVarRefs(Vars);
11909 Vars.clear();
11910 for (unsigned i = 0; i != NumVars; ++i)
11911 Vars.push_back(Record.readSubExpr());
11912 C->setPrivateCopies(Vars);
11913 Vars.clear();
11914 for (unsigned i = 0; i != NumVars; ++i)
11915 Vars.push_back(Record.readSubExpr());
11916 C->setSourceExprs(Vars);
11917 Vars.clear();
11918 for (unsigned i = 0; i != NumVars; ++i)
11919 Vars.push_back(Record.readSubExpr());
11920 C->setDestinationExprs(Vars);
11921 Vars.clear();
11922 for (unsigned i = 0; i != NumVars; ++i)
11923 Vars.push_back(Record.readSubExpr());
11924 C->setAssignmentOps(Vars);
11925 }
11926
11927 void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
11928 C->setLParenLoc(Record.readSourceLocation());
11929 unsigned NumVars = C->varlist_size();
11930 SmallVector<Expr *, 16> Vars;
11931 Vars.reserve(NumVars);
11932 for (unsigned i = 0; i != NumVars; ++i)
11933 Vars.push_back(Record.readSubExpr());
11934 C->setVarRefs(Vars);
11935 }
11936
11937 void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
11938 VisitOMPClauseWithPostUpdate(C);
11939 C->setLParenLoc(Record.readSourceLocation());
11940 C->setColonLoc(Record.readSourceLocation());
11941 NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc();
11942 DeclarationNameInfo DNI = Record.readDeclarationNameInfo();
11943 C->setQualifierLoc(NNSL);
11944 C->setNameInfo(DNI);
11945
11946 unsigned NumVars = C->varlist_size();
11947 SmallVector<Expr *, 16> Vars;
11948 Vars.reserve(NumVars);
11949 for (unsigned i = 0; i != NumVars; ++i)
11950 Vars.push_back(Record.readSubExpr());
11951 C->setVarRefs(Vars);
11952 Vars.clear();
11953 for (unsigned i = 0; i != NumVars; ++i)
11954 Vars.push_back(Record.readSubExpr());
11955 C->setPrivates(Vars);
11956 Vars.clear();
11957 for (unsigned i = 0; i != NumVars; ++i)
11958 Vars.push_back(Record.readSubExpr());
11959 C->setLHSExprs(Vars);
11960 Vars.clear();
11961 for (unsigned i = 0; i != NumVars; ++i)
11962 Vars.push_back(Record.readSubExpr());
11963 C->setRHSExprs(Vars);
11964 Vars.clear();
11965 for (unsigned i = 0; i != NumVars; ++i)
11966 Vars.push_back(Record.readSubExpr());
11967 C->setReductionOps(Vars);
11968 }
11969
11970 void OMPClauseReader::VisitOMPTaskReductionClause(OMPTaskReductionClause *C) {
11971 VisitOMPClauseWithPostUpdate(C);
11972 C->setLParenLoc(Record.readSourceLocation());
11973 C->setColonLoc(Record.readSourceLocation());
11974 NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc();
11975 DeclarationNameInfo DNI = Record.readDeclarationNameInfo();
11976 C->setQualifierLoc(NNSL);
11977 C->setNameInfo(DNI);
11978
11979 unsigned NumVars = C->varlist_size();
11980 SmallVector<Expr *, 16> Vars;
11981 Vars.reserve(NumVars);
11982 for (unsigned I = 0; I != NumVars; ++I)
11983 Vars.push_back(Record.readSubExpr());
11984 C->setVarRefs(Vars);
11985 Vars.clear();
11986 for (unsigned I = 0; I != NumVars; ++I)
11987 Vars.push_back(Record.readSubExpr());
11988 C->setPrivates(Vars);
11989 Vars.clear();
11990 for (unsigned I = 0; I != NumVars; ++I)
11991 Vars.push_back(Record.readSubExpr());
11992 C->setLHSExprs(Vars);
11993 Vars.clear();
11994 for (unsigned I = 0; I != NumVars; ++I)
11995 Vars.push_back(Record.readSubExpr());
11996 C->setRHSExprs(Vars);
11997 Vars.clear();
11998 for (unsigned I = 0; I != NumVars; ++I)
11999 Vars.push_back(Record.readSubExpr());
12000 C->setReductionOps(Vars);
12001 }
12002
12003 void OMPClauseReader::VisitOMPInReductionClause(OMPInReductionClause *C) {
12004 VisitOMPClauseWithPostUpdate(C);
12005 C->setLParenLoc(Record.readSourceLocation());
12006 C->setColonLoc(Record.readSourceLocation());
12007 NestedNameSpecifierLoc NNSL = Record.readNestedNameSpecifierLoc();
12008 DeclarationNameInfo DNI = Record.readDeclarationNameInfo();
12009 C->setQualifierLoc(NNSL);
12010 C->setNameInfo(DNI);
12011
12012 unsigned NumVars = C->varlist_size();
12013 SmallVector<Expr *, 16> Vars;
12014 Vars.reserve(NumVars);
12015 for (unsigned I = 0; I != NumVars; ++I)
12016 Vars.push_back(Record.readSubExpr());
12017 C->setVarRefs(Vars);
12018 Vars.clear();
12019 for (unsigned I = 0; I != NumVars; ++I)
12020 Vars.push_back(Record.readSubExpr());
12021 C->setPrivates(Vars);
12022 Vars.clear();
12023 for (unsigned I = 0; I != NumVars; ++I)
12024 Vars.push_back(Record.readSubExpr());
12025 C->setLHSExprs(Vars);
12026 Vars.clear();
12027 for (unsigned I = 0; I != NumVars; ++I)
12028 Vars.push_back(Record.readSubExpr());
12029 C->setRHSExprs(Vars);
12030 Vars.clear();
12031 for (unsigned I = 0; I != NumVars; ++I)
12032 Vars.push_back(Record.readSubExpr());
12033 C->setReductionOps(Vars);
12034 Vars.clear();
12035 for (unsigned I = 0; I != NumVars; ++I)
12036 Vars.push_back(Record.readSubExpr());
12037 C->setTaskgroupDescriptors(Vars);
12038 }
12039
12040 void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) {
12041 VisitOMPClauseWithPostUpdate(C);
12042 C->setLParenLoc(Record.readSourceLocation());
12043 C->setColonLoc(Record.readSourceLocation());
12044 C->setModifier(static_cast<OpenMPLinearClauseKind>(Record.readInt()));
12045 C->setModifierLoc(Record.readSourceLocation());
12046 unsigned NumVars = C->varlist_size();
12047 SmallVector<Expr *, 16> Vars;
12048 Vars.reserve(NumVars);
12049 for (unsigned i = 0; i != NumVars; ++i)
12050 Vars.push_back(Record.readSubExpr());
12051 C->setVarRefs(Vars);
12052 Vars.clear();
12053 for (unsigned i = 0; i != NumVars; ++i)
12054 Vars.push_back(Record.readSubExpr());
12055 C->setPrivates(Vars);
12056 Vars.clear();
12057 for (unsigned i = 0; i != NumVars; ++i)
12058 Vars.push_back(Record.readSubExpr());
12059 C->setInits(Vars);
12060 Vars.clear();
12061 for (unsigned i = 0; i != NumVars; ++i)
12062 Vars.push_back(Record.readSubExpr());
12063 C->setUpdates(Vars);
12064 Vars.clear();
12065 for (unsigned i = 0; i != NumVars; ++i)
12066 Vars.push_back(Record.readSubExpr());
12067 C->setFinals(Vars);
12068 C->setStep(Record.readSubExpr());
12069 C->setCalcStep(Record.readSubExpr());
12070 Vars.clear();
12071 for (unsigned I = 0; I != NumVars + 1; ++I)
12072 Vars.push_back(Record.readSubExpr());
12073 C->setUsedExprs(Vars);
12074 }
12075
12076 void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) {
12077 C->setLParenLoc(Record.readSourceLocation());
12078 C->setColonLoc(Record.readSourceLocation());
12079 unsigned NumVars = C->varlist_size();
12080 SmallVector<Expr *, 16> Vars;
12081 Vars.reserve(NumVars);
12082 for (unsigned i = 0; i != NumVars; ++i)
12083 Vars.push_back(Record.readSubExpr());
12084 C->setVarRefs(Vars);
12085 C->setAlignment(Record.readSubExpr());
12086 }
12087
12088 void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) {
12089 C->setLParenLoc(Record.readSourceLocation());
12090 unsigned NumVars = C->varlist_size();
12091 SmallVector<Expr *, 16> Exprs;
12092 Exprs.reserve(NumVars);
12093 for (unsigned i = 0; i != NumVars; ++i)
12094 Exprs.push_back(Record.readSubExpr());
12095 C->setVarRefs(Exprs);
12096 Exprs.clear();
12097 for (unsigned i = 0; i != NumVars; ++i)
12098 Exprs.push_back(Record.readSubExpr());
12099 C->setSourceExprs(Exprs);
12100 Exprs.clear();
12101 for (unsigned i = 0; i != NumVars; ++i)
12102 Exprs.push_back(Record.readSubExpr());
12103 C->setDestinationExprs(Exprs);
12104 Exprs.clear();
12105 for (unsigned i = 0; i != NumVars; ++i)
12106 Exprs.push_back(Record.readSubExpr());
12107 C->setAssignmentOps(Exprs);
12108 }
12109
12110 void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
12111 C->setLParenLoc(Record.readSourceLocation());
12112 unsigned NumVars = C->varlist_size();
12113 SmallVector<Expr *, 16> Exprs;
12114 Exprs.reserve(NumVars);
12115 for (unsigned i = 0; i != NumVars; ++i)
12116 Exprs.push_back(Record.readSubExpr());
12117 C->setVarRefs(Exprs);
12118 Exprs.clear();
12119 for (unsigned i = 0; i != NumVars; ++i)
12120 Exprs.push_back(Record.readSubExpr());
12121 C->setSourceExprs(Exprs);
12122 Exprs.clear();
12123 for (unsigned i = 0; i != NumVars; ++i)
12124 Exprs.push_back(Record.readSubExpr());
12125 C->setDestinationExprs(Exprs);
12126 Exprs.clear();
12127 for (unsigned i = 0; i != NumVars; ++i)
12128 Exprs.push_back(Record.readSubExpr());
12129 C->setAssignmentOps(Exprs);
12130 }
12131
12132 void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) {
12133 C->setLParenLoc(Record.readSourceLocation());
12134 unsigned NumVars = C->varlist_size();
12135 SmallVector<Expr *, 16> Vars;
12136 Vars.reserve(NumVars);
12137 for (unsigned i = 0; i != NumVars; ++i)
12138 Vars.push_back(Record.readSubExpr());
12139 C->setVarRefs(Vars);
12140 }
12141
12142 void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
12143 C->setLParenLoc(Record.readSourceLocation());
12144 C->setDependencyKind(
12145 static_cast<OpenMPDependClauseKind>(Record.readInt()));
12146 C->setDependencyLoc(Record.readSourceLocation());
12147 C->setColonLoc(Record.readSourceLocation());
12148 unsigned NumVars = C->varlist_size();
12149 SmallVector<Expr *, 16> Vars;
12150 Vars.reserve(NumVars);
12151 for (unsigned I = 0; I != NumVars; ++I)
12152 Vars.push_back(Record.readSubExpr());
12153 C->setVarRefs(Vars);
12154 for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I)
12155 C->setLoopData(I, Record.readSubExpr());
12156 }
12157
12158 void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) {
12159 VisitOMPClauseWithPreInit(C);
12160 C->setDevice(Record.readSubExpr());
12161 C->setLParenLoc(Record.readSourceLocation());
12162 }
12163
12164 void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
12165 C->setLParenLoc(Record.readSourceLocation());
12166 for (unsigned I = 0; I < OMPMapClause::NumberOfModifiers; ++I) {
12167 C->setMapTypeModifier(
12168 I, static_cast<OpenMPMapModifierKind>(Record.readInt()));
12169 C->setMapTypeModifierLoc(I, Record.readSourceLocation());
12170 }
12171 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12172 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12173 C->setMapType(
12174 static_cast<OpenMPMapClauseKind>(Record.readInt()));
12175 C->setMapLoc(Record.readSourceLocation());
12176 C->setColonLoc(Record.readSourceLocation());
12177 auto NumVars = C->varlist_size();
12178 auto UniqueDecls = C->getUniqueDeclarationsNum();
12179 auto TotalLists = C->getTotalComponentListNum();
12180 auto TotalComponents = C->getTotalComponentsNum();
12181
12182 SmallVector<Expr *, 16> Vars;
12183 Vars.reserve(NumVars);
12184 for (unsigned i = 0; i != NumVars; ++i)
12185 Vars.push_back(Record.readExpr());
12186 C->setVarRefs(Vars);
12187
12188 SmallVector<Expr *, 16> UDMappers;
12189 UDMappers.reserve(NumVars);
12190 for (unsigned I = 0; I < NumVars; ++I)
12191 UDMappers.push_back(Record.readExpr());
12192 C->setUDMapperRefs(UDMappers);
12193
12194 SmallVector<ValueDecl *, 16> Decls;
12195 Decls.reserve(UniqueDecls);
12196 for (unsigned i = 0; i < UniqueDecls; ++i)
12197 Decls.push_back(Record.readDeclAs<ValueDecl>());
12198 C->setUniqueDecls(Decls);
12199
12200 SmallVector<unsigned, 16> ListsPerDecl;
12201 ListsPerDecl.reserve(UniqueDecls);
12202 for (unsigned i = 0; i < UniqueDecls; ++i)
12203 ListsPerDecl.push_back(Record.readInt());
12204 C->setDeclNumLists(ListsPerDecl);
12205
12206 SmallVector<unsigned, 32> ListSizes;
12207 ListSizes.reserve(TotalLists);
12208 for (unsigned i = 0; i < TotalLists; ++i)
12209 ListSizes.push_back(Record.readInt());
12210 C->setComponentListSizes(ListSizes);
12211
12212 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12213 Components.reserve(TotalComponents);
12214 for (unsigned i = 0; i < TotalComponents; ++i) {
12215 Expr *AssociatedExpr = Record.readExpr();
12216 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12217 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
12218 AssociatedExpr, AssociatedDecl));
12219 }
12220 C->setComponents(Components, ListSizes);
12221 }
12222
12223 void OMPClauseReader::VisitOMPAllocateClause(OMPAllocateClause *C) {
12224 C->setLParenLoc(Record.readSourceLocation());
12225 C->setColonLoc(Record.readSourceLocation());
12226 C->setAllocator(Record.readSubExpr());
12227 unsigned NumVars = C->varlist_size();
12228 SmallVector<Expr *, 16> Vars;
12229 Vars.reserve(NumVars);
12230 for (unsigned i = 0; i != NumVars; ++i)
12231 Vars.push_back(Record.readSubExpr());
12232 C->setVarRefs(Vars);
12233 }
12234
12235 void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
12236 VisitOMPClauseWithPreInit(C);
12237 C->setNumTeams(Record.readSubExpr());
12238 C->setLParenLoc(Record.readSourceLocation());
12239 }
12240
12241 void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) {
12242 VisitOMPClauseWithPreInit(C);
12243 C->setThreadLimit(Record.readSubExpr());
12244 C->setLParenLoc(Record.readSourceLocation());
12245 }
12246
12247 void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) {
12248 VisitOMPClauseWithPreInit(C);
12249 C->setPriority(Record.readSubExpr());
12250 C->setLParenLoc(Record.readSourceLocation());
12251 }
12252
12253 void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
12254 VisitOMPClauseWithPreInit(C);
12255 C->setGrainsize(Record.readSubExpr());
12256 C->setLParenLoc(Record.readSourceLocation());
12257 }
12258
12259 void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
12260 VisitOMPClauseWithPreInit(C);
12261 C->setNumTasks(Record.readSubExpr());
12262 C->setLParenLoc(Record.readSourceLocation());
12263 }
12264
12265 void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) {
12266 C->setHint(Record.readSubExpr());
12267 C->setLParenLoc(Record.readSourceLocation());
12268 }
12269
12270 void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
12271 VisitOMPClauseWithPreInit(C);
12272 C->setDistScheduleKind(
12273 static_cast<OpenMPDistScheduleClauseKind>(Record.readInt()));
12274 C->setChunkSize(Record.readSubExpr());
12275 C->setLParenLoc(Record.readSourceLocation());
12276 C->setDistScheduleKindLoc(Record.readSourceLocation());
12277 C->setCommaLoc(Record.readSourceLocation());
12278 }
12279
12280 void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
12281 C->setDefaultmapKind(
12282 static_cast<OpenMPDefaultmapClauseKind>(Record.readInt()));
12283 C->setDefaultmapModifier(
12284 static_cast<OpenMPDefaultmapClauseModifier>(Record.readInt()));
12285 C->setLParenLoc(Record.readSourceLocation());
12286 C->setDefaultmapModifierLoc(Record.readSourceLocation());
12287 C->setDefaultmapKindLoc(Record.readSourceLocation());
12288 }
12289
12290 void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
12291 C->setLParenLoc(Record.readSourceLocation());
12292 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12293 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12294 auto NumVars = C->varlist_size();
12295 auto UniqueDecls = C->getUniqueDeclarationsNum();
12296 auto TotalLists = C->getTotalComponentListNum();
12297 auto TotalComponents = C->getTotalComponentsNum();
12298
12299 SmallVector<Expr *, 16> Vars;
12300 Vars.reserve(NumVars);
12301 for (unsigned i = 0; i != NumVars; ++i)
12302 Vars.push_back(Record.readSubExpr());
12303 C->setVarRefs(Vars);
12304
12305 SmallVector<Expr *, 16> UDMappers;
12306 UDMappers.reserve(NumVars);
12307 for (unsigned I = 0; I < NumVars; ++I)
12308 UDMappers.push_back(Record.readSubExpr());
12309 C->setUDMapperRefs(UDMappers);
12310
12311 SmallVector<ValueDecl *, 16> Decls;
12312 Decls.reserve(UniqueDecls);
12313 for (unsigned i = 0; i < UniqueDecls; ++i)
12314 Decls.push_back(Record.readDeclAs<ValueDecl>());
12315 C->setUniqueDecls(Decls);
12316
12317 SmallVector<unsigned, 16> ListsPerDecl;
12318 ListsPerDecl.reserve(UniqueDecls);
12319 for (unsigned i = 0; i < UniqueDecls; ++i)
12320 ListsPerDecl.push_back(Record.readInt());
12321 C->setDeclNumLists(ListsPerDecl);
12322
12323 SmallVector<unsigned, 32> ListSizes;
12324 ListSizes.reserve(TotalLists);
12325 for (unsigned i = 0; i < TotalLists; ++i)
12326 ListSizes.push_back(Record.readInt());
12327 C->setComponentListSizes(ListSizes);
12328
12329 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12330 Components.reserve(TotalComponents);
12331 for (unsigned i = 0; i < TotalComponents; ++i) {
12332 Expr *AssociatedExpr = Record.readSubExpr();
12333 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12334 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
12335 AssociatedExpr, AssociatedDecl));
12336 }
12337 C->setComponents(Components, ListSizes);
12338 }
12339
12340 void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
12341 C->setLParenLoc(Record.readSourceLocation());
12342 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12343 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12344 auto NumVars = C->varlist_size();
12345 auto UniqueDecls = C->getUniqueDeclarationsNum();
12346 auto TotalLists = C->getTotalComponentListNum();
12347 auto TotalComponents = C->getTotalComponentsNum();
12348
12349 SmallVector<Expr *, 16> Vars;
12350 Vars.reserve(NumVars);
12351 for (unsigned i = 0; i != NumVars; ++i)
12352 Vars.push_back(Record.readSubExpr());
12353 C->setVarRefs(Vars);
12354
12355 SmallVector<Expr *, 16> UDMappers;
12356 UDMappers.reserve(NumVars);
12357 for (unsigned I = 0; I < NumVars; ++I)
12358 UDMappers.push_back(Record.readSubExpr());
12359 C->setUDMapperRefs(UDMappers);
12360
12361 SmallVector<ValueDecl *, 16> Decls;
12362 Decls.reserve(UniqueDecls);
12363 for (unsigned i = 0; i < UniqueDecls; ++i)
12364 Decls.push_back(Record.readDeclAs<ValueDecl>());
12365 C->setUniqueDecls(Decls);
12366
12367 SmallVector<unsigned, 16> ListsPerDecl;
12368 ListsPerDecl.reserve(UniqueDecls);
12369 for (unsigned i = 0; i < UniqueDecls; ++i)
12370 ListsPerDecl.push_back(Record.readInt());
12371 C->setDeclNumLists(ListsPerDecl);
12372
12373 SmallVector<unsigned, 32> ListSizes;
12374 ListSizes.reserve(TotalLists);
12375 for (unsigned i = 0; i < TotalLists; ++i)
12376 ListSizes.push_back(Record.readInt());
12377 C->setComponentListSizes(ListSizes);
12378
12379 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12380 Components.reserve(TotalComponents);
12381 for (unsigned i = 0; i < TotalComponents; ++i) {
12382 Expr *AssociatedExpr = Record.readSubExpr();
12383 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12384 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
12385 AssociatedExpr, AssociatedDecl));
12386 }
12387 C->setComponents(Components, ListSizes);
12388 }
12389
12390 void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
12391 C->setLParenLoc(Record.readSourceLocation());
12392 auto NumVars = C->varlist_size();
12393 auto UniqueDecls = C->getUniqueDeclarationsNum();
12394 auto TotalLists = C->getTotalComponentListNum();
12395 auto TotalComponents = C->getTotalComponentsNum();
12396
12397 SmallVector<Expr *, 16> Vars;
12398 Vars.reserve(NumVars);
12399 for (unsigned i = 0; i != NumVars; ++i)
12400 Vars.push_back(Record.readSubExpr());
12401 C->setVarRefs(Vars);
12402 Vars.clear();
12403 for (unsigned i = 0; i != NumVars; ++i)
12404 Vars.push_back(Record.readSubExpr());
12405 C->setPrivateCopies(Vars);
12406 Vars.clear();
12407 for (unsigned i = 0; i != NumVars; ++i)
12408 Vars.push_back(Record.readSubExpr());
12409 C->setInits(Vars);
12410
12411 SmallVector<ValueDecl *, 16> Decls;
12412 Decls.reserve(UniqueDecls);
12413 for (unsigned i = 0; i < UniqueDecls; ++i)
12414 Decls.push_back(Record.readDeclAs<ValueDecl>());
12415 C->setUniqueDecls(Decls);
12416
12417 SmallVector<unsigned, 16> ListsPerDecl;
12418 ListsPerDecl.reserve(UniqueDecls);
12419 for (unsigned i = 0; i < UniqueDecls; ++i)
12420 ListsPerDecl.push_back(Record.readInt());
12421 C->setDeclNumLists(ListsPerDecl);
12422
12423 SmallVector<unsigned, 32> ListSizes;
12424 ListSizes.reserve(TotalLists);
12425 for (unsigned i = 0; i < TotalLists; ++i)
12426 ListSizes.push_back(Record.readInt());
12427 C->setComponentListSizes(ListSizes);
12428
12429 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12430 Components.reserve(TotalComponents);
12431 for (unsigned i = 0; i < TotalComponents; ++i) {
12432 Expr *AssociatedExpr = Record.readSubExpr();
12433 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12434 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
12435 AssociatedExpr, AssociatedDecl));
12436 }
12437 C->setComponents(Components, ListSizes);
12438 }
12439
12440 void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
12441 C->setLParenLoc(Record.readSourceLocation());
12442 auto NumVars = C->varlist_size();
12443 auto UniqueDecls = C->getUniqueDeclarationsNum();
12444 auto TotalLists = C->getTotalComponentListNum();
12445 auto TotalComponents = C->getTotalComponentsNum();
12446
12447 SmallVector<Expr *, 16> Vars;
12448 Vars.reserve(NumVars);
12449 for (unsigned i = 0; i != NumVars; ++i)
12450 Vars.push_back(Record.readSubExpr());
12451 C->setVarRefs(Vars);
12452 Vars.clear();
12453
12454 SmallVector<ValueDecl *, 16> Decls;
12455 Decls.reserve(UniqueDecls);
12456 for (unsigned i = 0; i < UniqueDecls; ++i)
12457 Decls.push_back(Record.readDeclAs<ValueDecl>());
12458 C->setUniqueDecls(Decls);
12459
12460 SmallVector<unsigned, 16> ListsPerDecl;
12461 ListsPerDecl.reserve(UniqueDecls);
12462 for (unsigned i = 0; i < UniqueDecls; ++i)
12463 ListsPerDecl.push_back(Record.readInt());
12464 C->setDeclNumLists(ListsPerDecl);
12465
12466 SmallVector<unsigned, 32> ListSizes;
12467 ListSizes.reserve(TotalLists);
12468 for (unsigned i = 0; i < TotalLists; ++i)
12469 ListSizes.push_back(Record.readInt());
12470 C->setComponentListSizes(ListSizes);
12471
12472 SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
12473 Components.reserve(TotalComponents);
12474 for (unsigned i = 0; i < TotalComponents; ++i) {
12475 Expr *AssociatedExpr = Record.readSubExpr();
12476 auto *AssociatedDecl = Record.readDeclAs<ValueDecl>();
12477 Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
12478 AssociatedExpr, AssociatedDecl));
12479 }
12480 C->setComponents(Components, ListSizes);
12481 }
12482
12483 void OMPClauseReader::VisitOMPNontemporalClause(OMPNontemporalClause *C) {
12484 C->setLParenLoc(Record.readSourceLocation());
12485 unsigned NumVars = C->varlist_size();
12486 SmallVector<Expr *, 16> Vars;
12487 Vars.reserve(NumVars);
12488 for (unsigned i = 0; i != NumVars; ++i)
12489 Vars.push_back(Record.readSubExpr());
12490 C->setVarRefs(Vars);
12491 Vars.clear();
12492 Vars.reserve(NumVars);
12493 for (unsigned i = 0; i != NumVars; ++i)
12494 Vars.push_back(Record.readSubExpr());
12495 C->setPrivateRefs(Vars);
12496 }
clang::ASTReader::GetExistingDecl
Decl * GetExistingDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration.
Definition: ASTReader.cpp:7297
clang::Module::IsAvailable
unsigned IsAvailable
Whether this module is available in the current translation unit.
Definition: Module.h:219
clang::SourceManager::getLocForStartOfFile
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
Definition: SourceManager.h:1109
clang::ASTContext::getObjCInstanceTypeDecl
TypedefDecl * getObjCInstanceTypeDecl()
Retrieve the typedef declaration corresponding to the Objective-C "instancetype" type.
Definition: ASTContext.cpp:6417
clang::serialization::reader::DeclContextLookupTable
Definition: ASTReaderInternals.h:119
clang::ASTContext::SatShortAccumTy
CanQualType SatShortAccumTy
Definition: ASTContext.h:1034
clang::CXXCtorInitializer::setSourceOrder
void setSourceOrder(int Pos)
Set the source order of this initializer.
Definition: DeclCXX.h:2338
clang::RawComment
Definition: RawCommentList.h:30
clang::ASTContext::SatUnsignedLongFractTy
CanQualType SatUnsignedLongFractTy
Definition: ASTContext.h:1038
clang::Builtin::ID
ID
Definition: Builtins.h:46
ASTContext.h
Defines the clang::ASTContext interface.
ASTReaderInternals.h
clang::serialization::PREDEF_TYPE_OBJC_SEL
The ObjC &#39;SEL&#39; type.
Definition: ASTBitCodes.h:891
clang::ASTReader::isAcceptableASTFile
static bool isAcceptableASTFile(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, const LangOptions &LangOpts, const TargetOptions &TargetOpts, const PreprocessorOptions &PPOpts, StringRef ExistingModuleCachePath)
Determine whether the given AST file is acceptable to load into a translation unit with the given lan...
Definition: ASTReader.cpp:5375
clang::SrcMgr::ContentCache::OrigEntry
const FileEntry * OrigEntry
Reference to the file entry representing this ContentCache.
Definition: SourceManager.h:117
clang::ASTReader::updateOutOfDateSelector
void updateOutOfDateSelector(Selector Sel) override
Load the contents of the global method pool for a given selector if necessary.
Definition: ASTReader.cpp:8090
clang::ASTReader::FindExternalVisibleDeclsByName
bool FindExternalVisibleDeclsByName(const DeclContext *DC, DeclarationName Name) override
Finds all the visible declarations with a given name.
Definition: ASTReader.cpp:7510
clang::ASTReader::ASTReadResult
ASTReadResult
The result of reading the control block of an AST file, which can fail for various reasons...
Definition: ASTReader.h:365
ModuleFileExtension.h
clang::serialization::PREPROCESSOR_OPTIONS
Record code for the preprocessor options table.
Definition: ASTBitCodes.h:357
clang::serialization::ModuleFile::PreloadIdentifierOffsets
std::vector< unsigned > PreloadIdentifierOffsets
Offsets of identifiers that we&#39;re going to preload within IdentifierTableData.
Definition: ModuleFile.h:295
clang::ASTRecordReader::readSourceLocation
SourceLocation readSourceLocation()
Read a source location, advancing Idx.
Definition: ASTRecordReader.h:265
clang::Module::UnresolvedExports
SmallVector< UnresolvedExportDecl, 2 > UnresolvedExports
The set of export declarations that have yet to be resolved.
Definition: Module.h:315
clang::serialization::PREDEF_TYPE_UACCUM_ID
The &#39;unsigned _Accum&#39; type.
Definition: ASTBitCodes.h:957
clang::ASTContext::LongLongTy
CanQualType LongLongTy
Definition: ASTContext.h:1025
getCanonicalDecl
static const Decl * getCanonicalDecl(const Decl *D)
Definition: IndexingContext.cpp:292
clang::ASTReader::ARR_VersionMismatch
The client can handle an AST file that cannot load because it was built with a different version of C...
Definition: ASTReader.h:1514
clang::DeclarationNameInfo::setInfo
void setInfo(const DeclarationNameLoc &Info)
Definition: DeclarationName.h:726
clang::FunctionDecl
Represents a function declaration or definition.
Definition: Decl.h:1783
clang::serialization::PREDEF_DECL_TRANSLATION_UNIT_ID
The translation unit.
Definition: ASTBitCodes.h:1096
clang::Module::Signature
ASTFileSignature Signature
The module signature.
Definition: Module.h:107
clang::Module::Name
std::string Name
The name of this module.
Definition: Module.h:67
OMPThreadLimitClause
This represents &#39;thread_limit&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5164
Diag
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Definition: LiteralSupport.cpp:77
clang::HeaderFileInfo::DirInfo
unsigned DirInfo
Keep track of whether this is a system header, and if so, whether it is C++ clean or not...
Definition: HeaderSearch.h:61
clang::serialization::PPEntityOffset
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:177
clang::ASTReader::getGlobalPreprocessedEntityID
serialization::PreprocessedEntityID getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const
Determine the global preprocessed entity ID that corresponds to the given local ID within the given m...
Definition: ASTReader.cpp:1800
clang::PreprocessorOptions::Macros
std::vector< std::pair< std::string, bool > > Macros
Definition: PreprocessorOptions.h:47
clang::ASTReader::getIdentifiers
IdentifierIterator * getIdentifiers() override
Retrieve an iterator into the set of all identifiers in all loaded AST files.
Definition: ASTReader.cpp:7956
OMPThreadLimitClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:5203
clang::serialization::ModuleFile::IdentifierLookupTable
void * IdentifierLookupTable
A pointer to an on-disk hash table of opaque type IdentifierHashTable.
Definition: ModuleFile.h:291
clang::ASTContext::setjmp_bufDecl
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
Definition: ASTContext.h:1774
clang::serialization::PREDEF_TYPE_USHORT_FRACT_ID
The &#39;unsigned short _Fract&#39; type.
Definition: ASTBitCodes.h:972
clang::ASTContext::AccumTy
CanQualType AccumTy
Definition: ASTContext.h:1029
clang::SourceLocation::getLocWithOffset
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Definition: SourceLocation.h:132
clang::ChainedASTReaderListener::ReadHeaderSearchOptions
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:195
OMPCopyinClause::CreateEmpty
static OMPCopyinClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: OpenMPClause.cpp:576
clang::ASTContext::OCLQueueTy
CanQualType OCLQueueTy
Definition: ASTContext.h:1054
clang::serialization::UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES
Record code for potentially unused local typedef names.
Definition: ASTBitCodes.h:621
clang::serialization::OBJC_CATEGORIES_MAP
Record code for map of Objective-C class definition IDs to the ObjC categories in a module that are a...
Definition: ASTBitCodes.h:579
clang::Selector
Smart pointer class that efficiently represents Objective-C method names.
Definition: IdentifierTable.h:685
updateModuleTimestamp
static void updateModuleTimestamp(ModuleFile &MF)
Definition: ASTReader.cpp:4105
clang::ODRHash
Definition: ODRHash.h:41
OMPCopyinClause
This represents clause &#39;copyin&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:3541
clang::ASTContext::getCFConstantStringDecl
TypedefDecl * getCFConstantStringDecl() const
Definition: ASTContext.cpp:6126
clang::if
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
Definition: RecursiveASTVisitor.h:1045
clang::ASTRecordReader::readQualifierInfo
void readQualifierInfo(QualifierInfo &Info)
Definition: ASTReader.cpp:8616
clang::serialization::reader::ASTSelectorLookupTrait::ComputeHash
static hash_value_type ComputeHash(Selector Sel)
Definition: ASTReader.cpp:817
clang::Module::MissingHeaders
SmallVector< UnresolvedHeaderDirective, 1 > MissingHeaders
Headers that are mentioned in the module map file but could not be found on the file system...
Definition: Module.h:194
checkTargetOptions
static bool checkTargetOptions(const TargetOptions &TargetOpts, const TargetOptions &ExistingTargetOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of target options against an existing set of target options.
Definition: ASTReader.cpp:372
clang::QualType
A (possibly-)qualified type.
Definition: Type.h:654
dumpModuleIDMap
static LLVM_DUMP_METHOD void dumpModuleIDMap(StringRef Name, const ContinuousRangeMap< Key, ModuleFile *, InitialCapacity > &Map)
Definition: ASTReader.cpp:7692
clang::ASTReaderListener::ReadPreprocessorOptions
virtual bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines)
Receives the preprocessor options.
Definition: ASTReader.h:182
addMethodsToPool
static void addMethodsToPool(Sema &S, ArrayRef< ObjCMethodDecl *> Methods, ObjCMethodList &List)
Add the given set of methods to the method list.
Definition: ASTReader.cpp:8046
clang::Selector::getAsOpaquePtr
void * getAsOpaquePtr() const
Definition: IdentifierTable.h:750
clang::serialization::CtorInitializerType
CtorInitializerType
The different kinds of data that can occur in a CtorInitializer.
Definition: ASTBitCodes.h:1895
clang::serialization::PREDEF_TYPE_FLOAT16_ID
The &#39;_Float16&#39; type.
Definition: ASTBitCodes.h:939
clang::serialization::ModuleFile::BasePreprocessedSkippedRangeID
unsigned BasePreprocessedSkippedRangeID
Base ID for preprocessed skipped ranges local to this module.
Definition: ModuleFile.h:342
clang::IdentifierInfo::setChangedSinceDeserialization
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
Definition: IdentifierTable.h:332
clang::MacroInfo::AddTokenToBody
void AddTokenToBody(const Token &Tok)
Add the specified token to the replacement text for the macro.
Definition: MacroInfo.h:248
clang::ObjCObjectPointerTypeLoc::setStarLoc
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1302
clang::DeclarationName::NameKind
NameKind
The kind of the name stored in this DeclarationName.
Definition: DeclarationName.h:202
clang::AtomicTypeLoc
Definition: TypeLoc.h:2358
clang::HeaderSearchOptions::UseLibcxx
unsigned UseLibcxx
Use libc++ instead of the default libstdc++.
Definition: HeaderSearchOptions.h:186
clang::serialization::PP_MACRO_DIRECTIVE_HISTORY
The macro directives history for a particular identifier.
Definition: ASTBitCodes.h:700
clang::ASTReader::SetIdentifierInfo
void SetIdentifierInfo(unsigned ID, IdentifierInfo *II)
Definition: ASTReader.cpp:8276
clang::TypeLocVisitor
Definition: TypeLocVisitor.h:26
clang::HeaderSearchOptions::ImplicitModuleMaps
unsigned ImplicitModuleMaps
Implicit module maps.
Definition: HeaderSearchOptions.h:134
clang::ASTReaderListener::visitInputFile
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.h:210
clang::FileManager
Implements support for file system lookup, file system caching, and directory search management...
Definition: FileManager.h:171
clang::serialization::PREDEF_TYPE_UINT_ID
The &#39;unsigned int&#39; type.
Definition: ASTBitCodes.h:825
clang::serialization::PREDEF_TYPE_LONGLONG_ID
The (signed) &#39;long long&#39; type.
Definition: ASTBitCodes.h:852
ASTDeserializationListener.h
clang::serialization
Definition: AbstractBasicReader.h:15
clang::ASTConsumer
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
Definition: ASTConsumer.h:33
clang::ASTContext::UnsignedLongFractTy
CanQualType UnsignedLongFractTy
Definition: ASTContext.h:1033
clang::ASTReaderListener::visitModuleFile
virtual void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind)
This is called for each AST file loaded.
Definition: ASTReader.h:193
clang::ExternalVTableUse
A simple structure that captures a vtable use for the purposes of the ExternalSemaSource.
Definition: ExternalSemaSource.h:43
clang::VariableArrayTypeLoc
Definition: TypeLoc.h:1557
clang::ASTReader::getSourceManager
SourceManager & getSourceManager() const
Definition: ASTReader.h:1491
clang::serialization::ReadMethodPoolVisitor::operator()
bool operator()(ModuleFile &M)
Definition: ASTReader.cpp:7988
clang::ExternalASTSource::Deserializing
RAII class for safely pairing a StartedDeserializing call with FinishedDeserializing.
Definition: ExternalASTSource.h:78
clang::ConcreteTypeLoc::getTypePtr
const TypeClass * getTypePtr() const
Definition: TypeLoc.h:409
ODRHash.h
This file contains the declaration of the ODRHash class, which calculates a hash based on AST nodes...
clang::TemplateArgument::getPackAsArray
ArrayRef< TemplateArgument > getPackAsArray() const
Return the array of arguments in this template argument pack.
Definition: TemplateBase.h:365
clang::EnumConstantDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:4794
FileManager.h
Defines the clang::FileManager interface and associated types.
clang::FileEntry::getModificationTime
time_t getModificationTime() const
Definition: FileManager.h:108
clang::ASTReader::GetExternalCXXBaseSpecifiers
CXXBaseSpecifier * GetExternalCXXBaseSpecifiers(uint64_t Offset) override
Resolve the offset of a set of C++ base specifiers in the decl stream into an array of specifiers...
Definition: ASTReader.cpp:7148
clang::serialization::SOURCE_MANAGER_LINE_TABLE
Record code for the source manager line table information, which stores information about #line direc...
Definition: ASTBitCodes.h:575
clang::ASTContext::FractTy
CanQualType FractTy
Definition: ASTContext.h:1032
clang::AutoTypeLoc::getNumArgs
unsigned getNumArgs() const
Definition: TypeLoc.h:2014
clang::serialization::reader
Definition: ASTReader.h:317
clang::TagDecl::getBraceRange
SourceRange getBraceRange() const
Definition: Decl.h:3300
clang::ASTRecordReader::readCXXBaseSpecifier
CXXBaseSpecifier readCXXBaseSpecifier()
Read a C++ base specifier, advancing Idx.
Definition: ASTReader.cpp:8669
clang::ObjCXXARCStandardLibraryKind
ObjCXXARCStandardLibraryKind
Enumerate the kinds of standard library that.
Definition: PreprocessorOptions.h:33
clang::ModuleMap::TextualHeader
This header is part of the module (for layering purposes) but should be textually included...
Definition: ModuleMap.h:137
clang::serialization::PREDEF_TYPE_BOOL_ID
The &#39;bool&#39; or &#39;_Bool&#39; type.
Definition: ASTBitCodes.h:813
clang::diff::Update
Definition: ASTDiff.h:30
clang::HeaderSearchOptions::ModuleUserBuildPath
std::string ModuleUserBuildPath
The directory used for a user build.
Definition: HeaderSearchOptions.h:115
clang::OMPAtomicDefaultMemOrderClause
This represents &#39;atomic_default_mem_order&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:1192
clang::ASTContext::Char32Ty
CanQualType Char32Ty
Definition: ASTContext.h:1024
clang::PipeTypeLoc::setKWLoc
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2425
clang::HeaderFileInfo::isPragmaOnce
unsigned isPragmaOnce
True if this is a #pragma once file.
Definition: HeaderSearch.h:55
clang::FunctionTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1398
clang::serialization::NUM_PREDEF_TYPE_IDS
const unsigned NUM_PREDEF_TYPE_IDS
The number of predefined type IDs that are reserved for the PREDEF_TYPE_* constants.
Definition: ASTBitCodes.h:1034
clang::TypeLoc::getNextTypeLoc
TypeLoc getNextTypeLoc() const
Get the next TypeLoc pointed by this TypeLoc, e.g for "int*" the TypeLoc is a PointerLoc and next Typ...
Definition: TypeLoc.h:169
OMPMappableExprListClause::setUniqueDecls
void setUniqueDecls(ArrayRef< ValueDecl *> UDs)
Set the unique declarations that are in the trailing objects of the class.
Definition: OpenMPClause.h:4384
clang::Stmt
Stmt - This represents one statement.
Definition: Stmt.h:66
clang::PointerTypeLoc::setStarLoc
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1233
clang::OMPInReductionClause
This represents clause &#39;in_reduction&#39; in the &#39;#pragma omp task&#39; directives.
Definition: OpenMPClause.h:2910
clang::ASTReader::isPreprocessedEntityInFileID
Optional< bool > isPreprocessedEntityInFileID(unsigned Index, FileID FID) override
Optionally returns true or false if the preallocated preprocessed entity with index Index came from f...
Definition: ASTReader.cpp:6112
clang::FieldDecl::getBitWidth
Expr * getBitWidth() const
Definition: Decl.h:2818
clang::TemplateSpecializationTypeLoc::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1592
clang::serialization::InputFile::getFile
const FileEntry * getFile() const
Definition: ModuleFile.h:94
clang::DiagnosticsEngine::getEnableAllWarnings
bool getEnableAllWarnings() const
Definition: Diagnostic.h:608
clang::ODRHash::AddQualType
void AddQualType(QualType T)
Definition: ODRHash.cpp:1124
clang::FunctionTypeLoc::setExceptionSpecRange
void setExceptionSpecRange(SourceRange R)
Definition: TypeLoc.h:1412
clang::serialization::ModuleFile::DidReadTopLevelSubmodule
bool DidReadTopLevelSubmodule
Whether the top-level module has been read from the AST file.
Definition: ModuleFile.h:163
clang::LangOptions::Sanitize
SanitizerSet Sanitize
Set of enabled sanitizers.
Definition: LangOptions.h:234
clang::FunctionNoProtoTypeLoc
Definition: TypeLoc.h:1472
clang::serialization::ModuleFile::DirectImportLoc
SourceLocation DirectImportLoc
The source location where the module was explicitly or implicitly imported in the local translation u...
Definition: ModuleFile.h:204
clang::Module::IsExternC
unsigned IsExternC
Whether this is an &#39;extern "C"&#39; module (which implicitly puts all headers in it within an &#39;extern "C"...
Definition: Module.h:237
clang::OMPClauseWithPreInit
Class that handles pre-initialization statement for some clauses, like &#39;shedule&#39;, &#39;firstprivate&#39; etc...
Definition: OpenMPClause.h:108
clang::AutoTypeLoc::setConceptNameLoc
void setConceptNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1976
clang::serialization::ControlRecordTypes
ControlRecordTypes
Record types that occur within the control block.
Definition: ASTBitCodes.h:300
clang::EnumConstantDecl
An instance of this object exists for each enum constant that is defined.
Definition: Decl.h:2941
clang::Module::addTopHeaderFilename
void addTopHeaderFilename(StringRef Filename)
Add a top-level header filename associated with this module.
Definition: Module.h:508
clang::DiagnosticMapping::isPragma
bool isPragma() const
Definition: DiagnosticIDs.h:123
clang::FixedPointSemantics
The fixed point semantics work similarly to llvm::fltSemantics.
Definition: FixedPoint.h:33
clang::serialization::ModuleFile::Generation
unsigned Generation
The generation of which this module file is a part.
Definition: ModuleFile.h:177
clang::ElaboratedTypeLoc
Definition: TypeLoc.h:2087
clang::ASTReader::ReadComments
void ReadComments() override
Loads comments ranges.
Definition: ASTReader.cpp:8956
clang::Module::UnresolvedConflicts
std::vector< UnresolvedConflict > UnresolvedConflicts
The list of conflicts for which the module-id has not yet been resolved.
Definition: Module.h:363
clang::serialization::reader::HeaderFileInfoTrait::internal_key_type::Size
off_t Size
Definition: ASTReaderInternals.h:254
Type.h
C Language Family Type Representation.
SourceManager.h
Defines the SourceManager interface.
clang::serialization::PREDEF_TYPE_UNKNOWN_ANY
The &#39;unknown any&#39; placeholder type.
Definition: ASTBitCodes.h:894
clang::BuiltinTypeLoc::setWrittenWidthSpec
void setWrittenWidthSpec(TypeSpecifierWidth written)
Definition: TypeLoc.h:629
clang::NestedNameSpecifier::Super
Microsoft&#39;s &#39;__super&#39; specifier, stored as a CXXRecordDecl* of the class it appeared in...
Definition: NestedNameSpecifier.h:99
clang::serialization::PPSkippedRange
Source range of a skipped preprocessor region.
Definition: ASTBitCodes.h:201
clang::ASTContext::setucontext_tDecl
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
Definition: ASTContext.h:1798
clang::ChainedASTReaderListener::ReadTargetOptions
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:173
clang::TemplateArgument::Expression
The template argument is an expression, and we&#39;ve not resolved it to one of the other forms yet...
Definition: TemplateBase.h:86
clang::DeclarationNameLoc::NT::TInfo
TypeSourceInfo * TInfo
Definition: DeclarationName.h:658
clang::ASTContext::Comments
RawCommentList Comments
All comments in this translation unit.
Definition: ASTContext.h:741
clang::ASTReader::getSubmodule
Module * getSubmodule(serialization::SubmoduleID GlobalID)
Retrieve the submodule that corresponds to a global submodule ID.
Definition: ASTReader.cpp:8443
clang::OMPFirstprivateClause::CreateEmpty
static OMPFirstprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:371
clang::ASTContext::getQualifiedType
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
Definition: ASTContext.h:1958
clang::AutoType::getArg
const TemplateArgument & getArg(unsigned Idx) const
Definition: TemplateBase.h:705
clang::serialization::NUM_PREDEF_SELECTOR_IDS
const unsigned int NUM_PREDEF_SELECTOR_IDS
The number of predefined selector IDs.
Definition: ASTBitCodes.h:156
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:88
OMPGrainsizeClause
This represents &#39;grainsize&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5314
clang::serialization::ModuleFile::PreloadSLocEntries
SmallVector< uint64_t, 4 > PreloadSLocEntries
SLocEntries that we&#39;re going to preload.
Definition: ModuleFile.h:260
clang::Preprocessor::getCurrentModule
Module * getCurrentModule()
Retrieves the module that we&#39;re currently building, if any.
Definition: Preprocessor.cpp:521
OMPNumTeamsClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:5127
clang::TagType::getDecl
TagDecl * getDecl() const
Definition: Type.cpp:3296
clang::Decl::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: DeclBase.h:421
clang::ASTContext::ObjCBuiltinSelTy
CanQualType ObjCBuiltinSelTy
Definition: ASTContext.h:1048
clang::TypeLocVisitor::Visit
RetTy Visit(TypeLoc TyLoc)
Definition: TypeLocVisitor.h:28
clang::ASTTemplateArgumentListInfo::Create
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
Definition: TemplateBase.cpp:564
Cursor
Cursor
Definition: SerializedDiagnosticReader.cpp:109
OMPMapClause::NumberOfModifiers
static constexpr unsigned NumberOfModifiers
Number of allowed map-type-modifiers.
Definition: OpenMPClause.h:4858
clang::ASTReader::FindFileRegionDecls
void FindFileRegionDecls(FileID File, unsigned Offset, unsigned Length, SmallVectorImpl< Decl *> &Decls) override
Get the decls that are contained in a file in the Offset/Length range.
Definition: ASTReader.cpp:7468
clang::DeclarationName::getObjCSelector
Selector getObjCSelector() const
Get the Objective-C selector stored in this declaration name.
Definition: DeclarationName.h:481
clang::ASTRecordReader::readUnresolvedSet
void readUnresolvedSet(LazyASTUnresolvedSet &Set)
Read a UnresolvedSet structure, advancing Idx.
Definition: ASTReader.cpp:8658
clang::TypeLocReader::VisitFunctionTypeLoc
void VisitFunctionTypeLoc(FunctionTypeLoc)
Definition: ASTReader.cpp:6525
clang::serialization::ModuleFile::Kind
ModuleKind Kind
The type of this module.
Definition: ModuleFile.h:119
clang::ASTReaderListener::ReadCounter
virtual void ReadCounter(const serialization::ModuleFile &M, unsigned Value)
Receives COUNTER value.
Definition: ASTReader.h:189
clang::OMPIfClause
This represents &#39;if&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:425
DeclTemplate.h
Defines the C++ template declaration subclasses.
clang::DecltypeTypeLoc
Definition: TypeLoc.h:1877
clang::serialization::SM_SLOC_EXPANSION_ENTRY
Describes a source location entry (SLocEntry) for a macro expansion.
Definition: ASTBitCodes.h:678
clang::DeclarationName::getCXXOverloadedOperator
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
Definition: DeclarationName.h:462
clang::PreprocessorOptions::Includes
std::vector< std::string > Includes
Definition: PreprocessorOptions.h:48
clang::SourceManager::isBeforeInTranslationUnit
bool isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
Definition: SourceManager.cpp:1936
checkPreprocessorOptions
static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts, const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags, FileManager &FileMgr, std::string &SuggestedPredefines, const LangOptions &LangOpts, bool Validate=true)
Check the preprocessor options deserialized from the control block against the preprocessor options i...
Definition: ASTReader.cpp:626
clang::ASTReader::ReadDelegatingConstructors
void ReadDelegatingConstructors(SmallVectorImpl< CXXConstructorDecl *> &Decls) override
Read the set of delegating constructors known to the external Sema source.
Definition: ASTReader.cpp:8152
clang::serialization::PREDEF_TYPE_BUILTIN_FN
The placeholder type for builtin functions.
Definition: ASTBitCodes.h:915
clang::RValueReferenceTypeLoc
Definition: TypeLoc.h:1329
MacroInfo.h
Defines the clang::MacroInfo and clang::MacroDirective classes.
clang::Module::getASTFile
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
Definition: Module.h:472
ObjCRuntime.h
Defines types useful for describing an Objective-C runtime.
clang::serialization::SUBMODULE_IMPORTS
Specifies the submodules that are imported by this submodule.
Definition: ASTBitCodes.h:744
clang::serialization::ModuleFile::ModuleName
std::string ModuleName
The name of the module.
Definition: ModuleFile.h:125
clang::ASTReader::ReadTentativeDefinitions
void ReadTentativeDefinitions(SmallVectorImpl< VarDecl *> &TentativeDefs) override
Read the set of tentative definitions known to the external Sema source.
Definition: ASTReader.cpp:8131
clang::serialization::INPUT_FILE
An input file.
Definition: ASTBitCodes.h:385
clang::ASTContext::ARCUnbridgedCastTy
CanQualType ARCUnbridgedCastTy
Definition: ASTContext.h:1047
clang::serialization::DECL_CONTEXT_LEXICAL
A record that stores the set of declarations that are lexically stored within a given DeclContext...
Definition: ASTBitCodes.h:1254
OMPPriorityClause
This represents &#39;priority&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5240
clang::serialization::ModuleManager::OutOfDate
The module file is out-of-date.
Definition: ModuleManager.h:209
clang::serialization::SUBMODULE_UMBRELLA_DIR
Specifies an umbrella directory.
Definition: ASTBitCodes.h:740
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1450
clang::ASTContext::SatUnsignedAccumTy
CanQualType SatUnsignedAccumTy
Definition: ASTContext.h:1035
clang::IdentifierInfo::isOutOfDate
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
Definition: IdentifierTable.h:350
clang::ASTReader::getLocalIdentifier
IdentifierInfo * getLocalIdentifier(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:8368
clang::ASTContext::LongTy
CanQualType LongTy
Definition: ASTContext.h:1025
clang::ASTContext::getDiagnostics
DiagnosticsEngine & getDiagnostics() const
Definition: ASTContext.cpp:1512
clang::OMPProcBindClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:984
clang::serialization::ModuleFile::LocalNumObjCCategoriesInMap
unsigned LocalNumObjCCategoriesInMap
The number of redeclaration info entries in ObjCCategoriesMap.
Definition: ModuleFile.h:441
clang::SrcMgr::FileInfo::setHasLineDirectives
void setHasLineDirectives()
Set the flag that indicates that this FileID has line table entries associated with it...
Definition: SourceManager.h:308
clang::ASTReader::getOriginalSourceFile
StringRef getOriginalSourceFile()
Retrieve the name of the original source file name for the primary module file.
Definition: ASTReader.h:1662
CHECK_TARGET_OPT
#define CHECK_TARGET_OPT(Field, Name)
clang::ASTReader::GetDecl
Decl * GetDecl(serialization::DeclID ID)
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:7322
clang::DiagnosticsEngine::Report
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Definition: Diagnostic.h:1300
clang::AutoTypeLoc::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2002
clang::DependentTemplateSpecializationTypeLoc::setTemplateKeywordLoc
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2244
clang::Token::setFlag
void setFlag(TokenFlags Flag)
Set the specified flag.
Definition: Token.h:236
clang::TemplateArgument::Declaration
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
Definition: TemplateBase.h:63
clang::NamespaceDecl
Represent a C++ namespace.
Definition: Decl.h:497
clang::TypedefTypeLoc
Wrapper for source info for typedefs.
Definition: TypeLoc.h:670
markIdentifierFromAST
static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II)
Definition: ASTReader.cpp:930
clang::TemplateParameterList::getParam
NamedDecl * getParam(unsigned Idx)
Definition: DeclTemplate.h:138
clang::AccessSpecifier
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Definition: Specifiers.h:113
DeclObjC.h
clang::TypeSourceInfo
A container of type source information.
Definition: Type.h:6227
HeaderSearch.h
clang::OMPUpdateClause
This represents &#39;update&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Definition: OpenMPClause.h:1765
clang::PreprocessedEntity
Base class that describes a preprocessed entity, which may be a preprocessor directive or macro expan...
Definition: PreprocessingRecord.h:60
clang::serialization::ModuleFile::GlobalBitOffset
uint64_t GlobalBitOffset
The global bit offset (or base) of this module.
Definition: ModuleFile.h:187
OMPMappableExprListClause::setComponents
void setComponents(ArrayRef< MappableComponent > Components, ArrayRef< unsigned > CLSs)
Set the components that are in the trailing objects of the class.
Definition: OpenMPClause.h:4459
clang::DeclContext::isDeclInLexicalTraversal
bool isDeclInLexicalTraversal(const Decl *D) const
Determine whether the given declaration is stored in the list of declarations lexically within this c...
Definition: DeclBase.h:2374
clang::serialization::OPENCL_EXTENSIONS
Record code for enabled OpenCL extensions.
Definition: ASTBitCodes.h:558
clang::serialization::MODULE_DIRECTORY
Record code for the module build directory.
Definition: ASTBitCodes.h:333
clang::serialization::reader::ASTSelectorLookupTrait::data_type::Instance
SmallVector< ObjCMethodDecl *, 2 > Instance
Definition: ASTReaderInternals.h:202
clang::FPOptions
Floating point control options.
Definition: LangOptions.h:357
clang::IdentifierInfo::isFromAST
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
Definition: IdentifierTable.h:320
clang::ASTReader::makeModuleVisible
void makeModuleVisible(Module *Mod, Module::NameVisibilityKind NameVisibility, SourceLocation ImportLoc)
Make the entities in the given module and any of its (non-explicit) submodules visible to name lookup...
Definition: ASTReader.cpp:4011
clang::serialization::ModuleFile::BaseSelectorID
serialization::SelectorID BaseSelectorID
Base selector ID for selectors local to this module.
Definition: ModuleFile.h:386
clang::PreprocessorOptions
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
Definition: PreprocessorOptions.h:45
clang::ASTRecordReader::readDeclarationNameInfo
DeclarationNameInfo readDeclarationNameInfo()
Definition: ASTReader.cpp:8608
clang::ASTRecordReader::readTemplateParameterList
TemplateParameterList * readTemplateParameterList()
Read a template parameter list, advancing Idx.
Definition: ASTReader.cpp:8629
clang::OMPCollapseClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:829
clang::DiagnosticsEngine::getSuppressSystemWarnings
bool getSuppressSystemWarnings() const
Definition: Diagnostic.h:634
clang::serialization::ReadMethodPoolVisitor::factoryHasMoreThanOneDecl
bool factoryHasMoreThanOneDecl() const
Definition: ASTReader.cpp:8039
clang::DecayedTypeLoc
Wrapper for source info for pointers decayed from arrays and functions.
Definition: TypeLoc.h:1187
clang::serialization::PREDEF_TYPE_SHORT_FRACT_ID
The &#39;short _Fract&#39; type.
Definition: ASTBitCodes.h:963
clang::serialization::ModuleFile::Signature
ASTFileSignature Signature
The signature of the module file, which may be used instead of the size and modification time to iden...
Definition: ModuleFile.h:170
clang::DeclContext::hasExternalVisibleStorage
bool hasExternalVisibleStorage() const
Whether this DeclContext has external storage containing additional declarations that are visible in ...
Definition: DeclBase.h:2360
ASTRecordReader.h
clang::CXXConstructorDecl
Represents a C++ constructor within a class.
Definition: DeclCXX.h:2383
clang::serialization::PREDEF_TYPE_FLOAT_ID
The &#39;float&#39; type.
Definition: ASTBitCodes.h:855
clang::OMPSimdlenClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:763
distance
float __ovld __cnfn distance(float p0, float p1)
Returns the distance between p0 and p1.
clang::serialization::PREDEF_DECL_TYPE_PACK_ELEMENT_ID
The internal &#39;__type_pack_element&#39; template.
Definition: ASTBitCodes.h:1141
clang::DiagnosticsEngine::getExtensionHandlingBehavior
diag::Severity getExtensionHandlingBehavior() const
Definition: Diagnostic.h:694
clang::ASTReader::addPendingMacro
void addPendingMacro(IdentifierInfo *II, ModuleFile *M, uint64_t MacroDirectivesOffset)
Add a macro to deserialize its macro directive history.
Definition: ASTReader.cpp:1933
clang::FunctionDecl::isVirtualAsWritten
bool isVirtualAsWritten() const
Whether this function is marked as virtual explicitly.
Definition: Decl.h:2096
clang::serialization::SUBMODULE_TEXTUAL_HEADER
Specifies a header that is part of the module but must be textually included.
Definition: ASTBitCodes.h:771
clang::serialization::ModuleFile::SLocEntryOffsets
const uint32_t * SLocEntryOffsets
Offsets for all of the source location entries in the AST file.
Definition: ModuleFile.h:257
clang::FunctionDecl::param_size
size_t param_size() const
Definition: Decl.h:2415
clang::serialization::ModuleFile::RelocatablePCH
bool RelocatablePCH
Whether this precompiled header is a relocatable PCH file.
Definition: ModuleFile.h:154
clang::serialization::PREDEF_TYPE_ARC_UNBRIDGED_CAST
ARC&#39;s unbridged-cast placeholder type.
Definition: ASTBitCodes.h:909
clang::ASTContext::HalfTy
CanQualType HalfTy
Definition: ASTContext.h:1040
clang::ASTReader::ARR_OutOfDate
The client can handle an AST file that cannot load because it is out-of-date relative to its input fi...
Definition: ASTReader.h:1510
clang::NonTypeTemplateParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Definition: DeclTemplate.h:1472
clang::serialization::PREDEF_TYPE_INT128_ID
The &#39;__int128_t&#39; type.
Definition: ASTBitCodes.h:873
clang::OMPReductionClause::CreateEmpty
static OMPReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:670
Value
Value
Definition: UninitializedValues.cpp:101
clang::ASTReader::HadErrors
The AST file has errors.
Definition: ASTReader.h:388
clang::QualType::withFastQualifiers
QualType withFastQualifiers(unsigned TQs) const
Definition: Type.h:869
OMPUseDevicePtrClause::CreateEmpty
static OMPUseDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
Definition: OpenMPClause.cpp:1104
clang::serialization::PREDEF_TYPE_CLK_EVENT_ID
OpenCL clk event type.
Definition: ASTBitCodes.h:921
clang::serialization::ModuleFile::NumPreprocessedEntities
unsigned NumPreprocessedEntities
Definition: ModuleFile.h:339
doesntStartWithASTFileMagic
static llvm::Error doesntStartWithASTFileMagic(BitstreamCursor &Stream)
Whether Stream doesn&#39;t start with the AST/PCH file magic number &#39;CPCH&#39;.
Definition: ASTReader.cpp:4411
clang::serialization::PREDEF_TYPE_CHAR32_ID
The C++ &#39;char32_t&#39; type.
Definition: ASTBitCodes.h:882
clang::OMPOrderedClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:1526
clang::NestedNameSpecifier::Identifier
An identifier, stored as an IdentifierInfo*.
Definition: NestedNameSpecifier.h:79
clang::serialization::PREDEF_DECL_BUILTIN_VA_LIST_ID
The internal &#39;__builtin_va_list&#39; typedef.
Definition: ASTBitCodes.h:1120
clang::serialization::PP_CONDITIONAL_STACK
The stack of open #ifs/#ifdefs recorded in a preamble.
Definition: ASTBitCodes.h:650
clang::Module::addRequirement
void addRequirement(StringRef Feature, bool RequiredState, const LangOptions &LangOpts, const TargetInfo &Target)
Add the given feature requirement to the list of features required by this module.
Definition: Module.cpp:276
clang::serialization::ModuleManager
Manages the set of modules loaded by an AST reader.
Definition: ModuleManager.h:48
clang::OMPReadClause
This represents &#39;read&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Definition: OpenMPClause.h:1687
clang::FriendDecl
FriendDecl - Represents the declaration of a friend entity, which can be a function, a type, or a templated function or type.
Definition: DeclFriend.h:53
clang::VarDecl
Represents a variable declaration or definition.
Definition: Decl.h:820
clang::OMPPrivateClause
This represents clause &#39;private&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:1885
clang::ExternalVTableUse::Location
SourceLocation Location
Definition: ExternalSemaSource.h:45
clang::serialization::PACK_PRAGMA_OPTIONS
Record code for #pragma pack options.
Definition: ASTBitCodes.h:647
clang::serialization::UNHASHED_CONTROL_BLOCK_ID
A block with unhashed content.
Definition: ASTBitCodes.h:296
clang::FunctionDecl::getReturnType
QualType getReturnType() const
Definition: Decl.h:2445
clang::DiagnosticMapping
Definition: DiagnosticIDs.h:98
clang::ASTReader::GetExternalCXXCtorInitializers
CXXCtorInitializer ** GetExternalCXXCtorInitializers(uint64_t Offset) override
Read the contents of a CXXCtorInitializer array.
Definition: ASTReader.cpp:7117
clang::OMPNumThreadsClause
This represents &#39;num_threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:594
clang::MemberPointerTypeLoc
Wrapper for source info for member pointers.
Definition: TypeLoc.h:1256
clang::SC_Static
Definition: Specifiers.h:239
clang::TypeLocReader::VisitArrayTypeLoc
void VisitArrayTypeLoc(ArrayTypeLoc)
Definition: ASTReader.cpp:6473
clang::TargetOptions
Options for controlling the target.
Definition: TargetOptions.h:26
Sema.h
clang::QualifiedTypeLoc
Wrapper of type source information for a type with non-trivial direct qualifiers. ...
Definition: TypeLoc.h:277
clang::diag::Severity
Severity
Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs to either Ignore (nothing)...
Definition: DiagnosticIDs.h:79
RawCommentList.h
clang::Type::getAs
const T * getAs() const
Member-template getAs<specific type>&#39;.
Definition: Type.h:7002
clang::serialization::OPENCL_EXTENSION_DECLS
Record code for declarations associated with OpenCL extensions.
Definition: ASTBitCodes.h:642
clang::ASTReader::CompleteRedeclChain
void CompleteRedeclChain(const Decl *D) override
If any redeclarations of D have been imported since it was last checked, this digs out those redeclar...
Definition: ASTReader.cpp:7064
clang::ASTContext::Float128Ty
CanQualType Float128Ty
Definition: ASTContext.h:1028
clang::NonTypeTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1462
clang::ASTRecordReader::readASTTemplateArgumentListInfo
const ASTTemplateArgumentListInfo * readASTTemplateArgumentListInfo()
Definition: ASTReader.cpp:7050
clang::TemplateArgument::Null
Represents an empty template argument, e.g., one that has not been deduced.
Definition: TemplateBase.h:56
OMPDefaultmapClause
This represents &#39;defaultmap&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5668
clang::ASTContext::ShortAccumTy
CanQualType ShortAccumTy
Definition: ASTContext.h:1029
clang::DeclContext::decls
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
Definition: DeclBase.h:2033
clang::ASTReader::InitializeSema
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
Definition: ASTReader.cpp:7744
clang::serialization::ModuleFile::BaseSubmoduleID
serialization::SubmoduleID BaseSubmoduleID
Base submodule ID for submodules local to this module.
Definition: ModuleFile.h:369
clang::serialization::NUM_PREDEF_DECL_IDS
const unsigned int NUM_PREDEF_DECL_IDS
The number of declaration IDs that are predefined.
Definition: ASTBitCodes.h:1148
clang::serialization::PREDEF_DECL_EXTERN_C_CONTEXT_ID
The extern "C" context.
Definition: ASTBitCodes.h:1129
clang::TemplateSpecializationTypeLoc
Definition: TypeLoc.h:1574
clang::serialization::PP_COUNTER_VALUE
The value of the next COUNTER to dispense.
Definition: ASTBitCodes.h:483
clang::ObjCMethodDecl
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:138
sys
clang::LineTableInfo::getLineTableFilenameID
unsigned getLineTableFilenameID(StringRef Str)
Definition: SourceManager.cpp:230
clang::APValue::IndeterminateValue
static APValue IndeterminateValue()
Definition: APValue.h:334
clang::DeclarationName::CXXUsingDirective
Definition: DeclarationName.h:215
clang::serialization::SUBMODULE_UMBRELLA_HEADER
Specifies the umbrella header used to create this module, if any.
Definition: ASTBitCodes.h:731
clang::ASTTemplateArgumentListInfo
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
Definition: TemplateBase.h:603
clang::NestedNameSpecifier::Namespace
A namespace, stored as a NamespaceDecl*.
Definition: NestedNameSpecifier.h:82
clang::ASTReader::ReadReferencedSelectors
void ReadReferencedSelectors(SmallVectorImpl< std::pair< Selector, SourceLocation >> &Sels) override
Definition: ASTReader.cpp:8185
clang::SrcMgr::CharacteristicKind
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
Definition: SourceManager.h:77
clang::serialization::HEADER_SEARCH_TABLE
Record code for header search information.
Definition: ASTBitCodes.h:552
clang::serialization::reader::ASTSelectorLookupTrait::ReadData
data_type ReadData(Selector, const unsigned char *d, unsigned DataLen)
Definition: ASTReader.cpp:853
clang::CommentOptions::BlockCommandNames
BlockCommandNamesTy BlockCommandNames
Command names to treat as block commands in comments.
Definition: CommentOptions.h:28
clang::DependentAddressSpaceTypeLoc::setAttrOperandParensRange
void setAttrOperandParensRange(SourceRange range)
Definition: TypeLoc.h:1714
clang::ObjCTypeParamTypeLoc::setProtocolRAngleLoc
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:784
clang::TemplateParameterList
Stores a list of template parameters for a TemplateDecl and its derived classes.
Definition: DeclTemplate.h:69
clang::HeaderSearchOptions::ModuleCachePath
std::string ModuleCachePath
The directory used for the module cache.
Definition: HeaderSearchOptions.h:112
OMPFlushClause
This represents implicit clause &#39;flush&#39; for the &#39;#pragma omp flush&#39; directive.
Definition: OpenMPClause.h:3885
clang::serialization::SM_SLOC_BUFFER_ENTRY
Describes a source location entry (SLocEntry) for a buffer.
Definition: ASTBitCodes.h:664
clang::DeclarationName::ObjCOneArgSelector
Definition: DeclarationName.h:205
clang::LineTableInfo
Used to hold and unique data used to represent #line information.
Definition: SourceManagerInternals.h:80
clang::serialization::TARGET_OPTIONS
Record code for the target options table.
Definition: ASTBitCodes.h:348
clang::ASTContext::ShortFractTy
CanQualType ShortFractTy
Definition: ASTContext.h:1032
bytes
static StringRef bytes(const std::vector< T, Allocator > &v)
Definition: ASTWriter.cpp:121
clang::ODRHash::AddTemplateArgument
void AddTemplateArgument(TemplateArgument TA)
Definition: ODRHash.cpp:157
clang::AdjustedTypeLoc
Definition: TypeLoc.h:1159
OMPMappableExprListClause::getTotalComponentsNum
unsigned getTotalComponentsNum() const
Return the total number of components in all lists derived from the clause.
Definition: OpenMPClause.h:4589
clang::OMPReverseOffloadClause
This represents &#39;reverse_offload&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
Definition: OpenMPClause.h:1107
clang::PCHValidator::ReadCounter
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:803
clang::ASTContext::getVaListTagDecl
Decl * getVaListTagDecl() const
Retrieve the C type declaration corresponding to the predefined __va_list_tag type used to help defin...
Definition: ASTContext.cpp:7841
clang::serialization::EAGERLY_DESERIALIZED_DECLS
Record code for the array of eagerly deserialized decls.
Definition: ASTBitCodes.h:454
clang::Module::PresumedModuleMapFile
std::string PresumedModuleMapFile
The presumed file name for the module map defining this module.
Definition: Module.h:101
clang::ParmVarDecl
Represents a parameter to a function.
Definition: Decl.h:1595
clang::DependentVectorTypeLoc
Definition: TypeLoc.h:1758
clang::serialization::PREDEF_DECL_NULL_ID
The NULL declaration.
Definition: ASTBitCodes.h:1093
ExprCXX.h
Defines the clang::Expr interface and subclasses for C++ expressions.
clang::HeaderFileInfo::isImport
unsigned isImport
True if this is a #import&#39;d or #pragma once file.
Definition: HeaderSearch.h:52
clang::serialization::ModuleFile::SLocEntryBaseID
int SLocEntryBaseID
The base ID in the source manager&#39;s view of this module.
Definition: ModuleFile.h:250
clang::OMPTaskReductionClause::CreateEmpty
static OMPTaskReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:723
clang::ExternalASTSource::MemoryBufferSizes::mmap_bytes
size_t mmap_bytes
Definition: ExternalASTSource.h:311
clang::TemplateDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclTemplate.h:443
clang::serialization::ModuleFile::DeclRemap
ContinuousRangeMap< uint32_t, int, 2 > DeclRemap
Remapping table for declaration IDs in this module.
Definition: ModuleFile.h:421
clang::ElaboratedTypeLoc::setQualifierLoc
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2105
OMPNogroupClause
This represents &#39;nogroup&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5380
clang::serialization::ReadMethodPoolVisitor::getFactoryBits
unsigned getFactoryBits() const
Definition: ASTReader.cpp:8033
clang::Qualifiers
The collection of all-type qualifiers we support.
Definition: Type.h:143
clang::ObjCObjectTypeLoc::setTypeArgTInfo
void setTypeArgTInfo(unsigned i, TypeSourceInfo *TInfo)
Definition: TypeLoc.h:949
clang::OMPAllocatorClause
This represents &#39;allocator&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:266
clang::ODRHash::clear
void clear()
Definition: ODRHash.cpp:198
clang::serialization::ModuleFile::ImportLoc
SourceLocation ImportLoc
The source location where this module was first imported.
Definition: ModuleFile.h:207
clang::OMPSafelenClause
This represents &#39;safelen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:670
clang::LazyASTUnresolvedSet
An UnresolvedSet-like class that might not have been loaded from the external AST source yet...
Definition: ASTUnresolvedSet.h:93
clang::BuiltinTypeLoc::needsExtraLocalData
bool needsExtraLocalData() const
Definition: TypeLoc.h:582
clang::Module::Kind
ModuleKind Kind
The kind of this module.
Definition: Module.h:88
clang::ASTReader::ARR_Missing
The client can handle an AST file that cannot load because it is missing.
Definition: ASTReader.h:1506
clang::DeclarationName::CXXDeductionGuideName
Definition: DeclarationName.h:210
clang::FunctionDecl::getReturnTypeSourceRange
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
Definition: Decl.cpp:3395
clang::ASTContext::OCLSamplerTy
CanQualType OCLSamplerTy
Definition: ASTContext.h:1053
clang::OMPOrderedClause::CreateEmpty
static OMPOrderedClause * CreateEmpty(const ASTContext &C, unsigned NumLoops)
Build an empty clause.
Definition: OpenMPClause.cpp:283
clang::ASTReader::DeclIsFromPCHWithObjectFile
bool DeclIsFromPCHWithObjectFile(const Decl *D) override
Determine whether D comes from a PCH which was built with a corresponding object file.
Definition: ASTReader.cpp:8461
clang::NamedDecl::getIdentifier
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Definition: Decl.h:244
Sanitizers.h
Defines the clang::SanitizerKind enum.
clang::ASTReader::ReadUndefinedButUsed
void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined) override
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
Definition: ASTReader.cpp:8106
clang::TypeLoc
Base wrapper for a particular "section" of type source info.
Definition: TypeLoc.h:58
clang::MacroInfo::setIsGNUVarargs
void setIsGNUVarargs()
Definition: MacroInfo.h:204
clang::serialization::ModuleFile::ModuleOffsetMap
StringRef ModuleOffsetMap
The module offset map data for this file.
Definition: ModuleFile.h:218
clang::serialization::CTOR_INITIALIZER_MEMBER
Definition: ASTBitCodes.h:1898
clang::serialization::SPECIAL_TYPE_UCONTEXT_T
C ucontext_t typedef type.
Definition: ASTBitCodes.h:1079
clang::serialization::VERSION_MAJOR
const unsigned VERSION_MAJOR
AST file major version number supported by this version of Clang.
Definition: ASTBitCodes.h:44
clang::OMPVarListClause::varlist_size
unsigned varlist_size() const
Definition: OpenMPClause.h:229
clang::Qualifiers::FastWidth
The width of the "fast" qualifier mask.
Definition: Type.h:186
clang::ASTContext::getCFConstantStringTagDecl
RecordDecl * getCFConstantStringTagDecl() const
Definition: ASTContext.cpp:6210
clang::NamedDecl::getDeclName
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
Definition: Decl.h:272
clang::SelectorTable::getUnarySelector
Selector getUnarySelector(IdentifierInfo *ID)
Definition: IdentifierTable.h:846
clang::TypeOfTypeLoc
Definition: TypeLoc.h:1858
clang::EnumDecl::getIntegerTypeSourceInfo
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
Definition: Decl.h:3651
clang::ASTContext::getObjCIdDecl
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
Definition: ASTContext.cpp:7458
clang::IdentifierInfo
One of these records is kept for each identifier that is lexed.
Definition: IdentifierTable.h:57
clang::serialization::PP_MODULE_MACRO
A macro directive exported by a module.
Definition: ASTBitCodes.h:704
clang::DeclContext::setHasExternalLexicalStorage
void setHasExternalLexicalStorage(bool ES=true) const
State whether this DeclContext has external storage for declarations lexically in this context...
Definition: DeclBase.h:2354
clang::FriendDecl::getFriendType
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
Definition: DeclFriend.h:123
clang::FunctionTypeLoc::setLocalRangeEnd
void setLocalRangeEnd(SourceLocation L)
Definition: TypeLoc.h:1382
clang::LazyASTUnresolvedSet::addLazyDecl
void addLazyDecl(ASTContext &C, uintptr_t ID, AccessSpecifier AS)
Definition: ASTUnresolvedSet.h:107
clang::ChainedASTReaderListener::ReadDiagnosticOptions
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:182
clang::serialization::SUBMODULE_TOPHEADER
Specifies a top-level header that falls into this (sub)module.
Definition: ASTBitCodes.h:737
clang::serialization::ModuleFile::ActualOriginalSourceFileName
std::string ActualOriginalSourceFileName
The actual original source file name that was used to build this AST file.
Definition: ModuleFile.h:141
clang::serialization::COMMENTS_BLOCK_ID
The block containing comments.
Definition: ASTBitCodes.h:269
clang::SelectorTable
This table allows us to fully hide how we implement multi-keyword caching.
Definition: IdentifierTable.h:830
clang::serialization::ModuleManager::AddModuleResult
AddModuleResult
The result of attempting to add a new module.
Definition: ModuleManager.h:198
clang::CXXMethodDecl::isConst
bool isConst() const
Definition: DeclCXX.h:1973
clang::serialization::PREDEF_DECL_OBJC_SEL_ID
The Objective-C &#39;SEL&#39; type.
Definition: ASTBitCodes.h:1102
clang::StaticAssertDecl::getMessage
StringLiteral * getMessage()
Definition: DeclCXX.h:3789
clang::Module::LinkLibrary
A library or framework to link against when an entity from this module is used.
Definition: Module.h:325
clang::ASTReader::finalizeForWriting
void finalizeForWriting()
Finalizes the AST reader&#39;s state before writing an AST file to disk.
Definition: ASTReader.cpp:4951
clang::APValue::ComplexInt
Definition: APValue.h:127
clang::PreprocessingRecord::iterator
Iteration over the preprocessed entities.
Definition: PreprocessingRecord.h:430
clang::TemplateArgument::getAsExpr
Expr * getAsExpr() const
Retrieve the template argument as an expression.
Definition: TemplateBase.h:329
getTopImportImplicitModule
static Module * getTopImportImplicitModule(ModuleManager &ModuleMgr, Preprocessor &PP)
Return the top import module if it is implicit, nullptr otherwise.
Definition: ASTReader.cpp:535
clang::ASTContext
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition: ASTContext.h:168
clang::NestedNameSpecifierLoc
A C++ nested-name-specifier augmented with source location information.
Definition: NestedNameSpecifier.h:236
clang::MacroDefinitionRecord
Record the location of a macro definition.
Definition: PreprocessingRecord.h:148
clang::OMPAllocateClause::CreateEmpty
static OMPAllocateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:805
llvm::Optional
Definition: LLVM.h:37
State
LineState State
Definition: UnwrappedLineFormatter.cpp:932
OMPSIMDClause
This represents &#39;simd&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:4200
clang::serialization::PREDEF_TYPE_CHAR_S_ID
The &#39;char&#39; type, when it is signed.
Definition: ASTBitCodes.h:834
resolveFileRelativeToOriginalDir
static std::string resolveFileRelativeToOriginalDir(const std::string &Filename, const std::string &OriginalDir, const std::string &CurrDir)
If a header file is not found at the path that we expect it to be and the PCH file was moved from its...
Definition: ASTReader.cpp:1387
clang::TemplateArgument::Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Definition: TemplateBase.h:71
clang::BuiltinTypeLoc::setBuiltinLoc
void setBuiltinLoc(SourceLocation Loc)
Definition: TypeLoc.h:559
clang::TemplateSpecializationTypeLoc::setArgLocInfo
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:1608
clang::ASTContext::UnsignedFractTy
CanQualType UnsignedFractTy
Definition: ASTContext.h:1033
toString
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Definition: SanitizerArgs.cpp:856
clang::serialization::PREDEF_TYPE_ULONG_ID
The &#39;unsigned long&#39; type.
Definition: ASTBitCodes.h:828
clang::serialization::SUBMODULE_EXCLUDED_HEADER
Specifies a header that has been explicitly excluded from this submodule.
Definition: ASTBitCodes.h:755
clang::ArrayTypeLoc::setRBracketLoc
void setRBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1501
clang::SourceLocation::getFromRawEncoding
static SourceLocation getFromRawEncoding(unsigned Encoding)
Turn a raw encoding of a SourceLocation object into a real SourceLocation.
Definition: SourceLocation.h:150
clang::Module::Requirements
SmallVector< Requirement, 2 > Requirements
The set of language features required to use this module.
Definition: Module.h:204
clang::serialization::PPEntityOffset::getBegin
SourceLocation getBegin() const
Definition: ASTBitCodes.h:191
clang::Stmt::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Stmt.cpp:275
clang::DeclarationName::getNameKind
NameKind getNameKind() const
Determine what kind of name this is.
Definition: DeclarationName.h:384
clang::FieldDecl
Represents a member of a struct/union/class.
Definition: Decl.h:2729
clang::CXXMethodDecl::isVolatile
bool isVolatile() const
Definition: DeclCXX.h:1974
clang::OMPLastprivateClause
This represents clause &#39;lastprivate&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:2132
clang::IdentifierInfo::isCPlusPlusOperatorKeyword
bool isCPlusPlusOperatorKeyword() const
Definition: IdentifierTable.h:297
clang::OMPAllocateClause
This represents clause &#39;allocate&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:328
ExceptionSpecificationType.h
Defines the ExceptionSpecificationType enumeration and various utility functions. ...
clang::serialization::PREDEF_TYPE_SAT_UACCUM_ID
The &#39;_Sat unsigned _Accum&#39; type.
Definition: ASTBitCodes.h:993
clang::serialization::PREDEF_DECL_UNSIGNED_INT_128_ID
The unsigned 128-bit integer type.
Definition: ASTBitCodes.h:1114
std
Definition: Format.h:2445
clang::OMPOrderedClause::setLoopNumIterations
void setLoopNumIterations(unsigned NumLoop, Expr *NumIterations)
Set number of iterations for the specified loop.
Definition: OpenMPClause.cpp:294
clang::ParenTypeLoc
Definition: TypeLoc.h:1113
clang::serialization::ModuleFile::PreprocessedEntityRemap
ContinuousRangeMap< uint32_t, int, 2 > PreprocessedEntityRemap
Remapping table for preprocessed entity IDs in this module.
Definition: ModuleFile.h:336
clang::serialization::MODULE_MAP_FILE
Record code for the module map file that was used to build this AST file.
Definition: ASTBitCodes.h:330
clang::SrcMgr::ContentCache
One instance of this struct is kept for every file loaded or used.
Definition: SourceManager.h:94
clang::HeaderSearchOptions::UserEntries
std::vector< Entry > UserEntries
User specified include entries.
Definition: HeaderSearchOptions.h:102
clang::Token::TokenFlags
TokenFlags
Definition: Token.h:72
clang::Decl::setVisibleDespiteOwningModule
void setVisibleDespiteOwningModule()
Set that this declaration is globally visible, even if it came from a module that is not visible...
Definition: DeclBase.h:780
clang::serialization::DELETE_EXPRS_TO_ANALYZE
Delete expressions that will be analyzed later.
Definition: ASTBitCodes.h:626
clang::HeaderSearchOptions::SystemHeaderPrefixes
std::vector< SystemHeaderPrefix > SystemHeaderPrefixes
User-specified system header prefixes.
Definition: HeaderSearchOptions.h:105
clang::GlobalModuleIndex::HitSet
llvm::SmallPtrSet< ModuleFile *, 4 > HitSet
A set of module files in which we found a result.
Definition: GlobalModuleIndex.h:153
clang::ASTContext::LongAccumTy
CanQualType LongAccumTy
Definition: ASTContext.h:1029
clang::ObjCContainerDecl::methods
method_range methods() const
Definition: DeclObjC.h:1051
clang::SavedStreamPosition
Helper class that saves the current stream position and then restores it when destroyed.
Definition: ASTRecordReader.h:337
clang::Module::getUmbrellaHeader
Header getUmbrellaHeader() const
Retrieve the header that serves as the umbrella header for this module.
Definition: Module.h:489
clang::DeclarationNameInfo::setName
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
Definition: DeclarationName.h:716
clang::ASTContext::OCLEventTy
CanQualType OCLEventTy
Definition: ASTContext.h:1053
OMPMapClause
This represents clause &#39;map&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:4833
OMPNontemporalClause::setPrivateRefs
void setPrivateRefs(ArrayRef< Expr *> VL)
Sets the list of references to private copies created in private clauses.
Definition: OpenMPClause.cpp:1181
OMPNumTasksClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:5456
clang::FriendDecl::getFriendDecl
NamedDecl * getFriendDecl() const
If this friend declaration doesn&#39;t name a type, return the inner declaration.
Definition: DeclFriend.h:138
clang::DependentNameTypeLoc::setElaboratedKeywordLoc
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2155
clang::Decl::getSourceRange
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
Definition: DeclBase.h:417
clang::serialization::PREDEF_TYPE_ULONG_FRACT_ID
The &#39;unsigned long _Fract&#39; type.
Definition: ASTBitCodes.h:978
clang::ASTReaderListener::ReadLanguageOptions
virtual bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the language options.
Definition: ASTReader.h:130
OMPToClause
This represents clause &#39;to&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:5781
OMPAlignedClause::setColonLoc
void setColonLoc(SourceLocation Loc)
Sets the location of &#39;:&#39;.
Definition: OpenMPClause.h:3501
clang::SanitizerSet::Mask
SanitizerMask Mask
Bitmask of enabled sanitizers.
Definition: Sanitizers.h:174
clang::serialization::PREDEF_TYPE_LONG_FRACT_ID
The &#39;long _Fract&#39; type.
Definition: ASTBitCodes.h:969
clang::Token
Token - This structure provides full information about a lexed token.
Definition: Token.h:34
clang::ModuleMap::setUmbrellaDir
void setUmbrellaDir(Module *Mod, const DirectoryEntry *UmbrellaDir, Twine NameAsWritten)
Sets the umbrella directory of the given module to the given directory.
Definition: ModuleMap.cpp:1116
clang::ODRHash::AddTemplateParameterList
void AddTemplateParameterList(const TemplateParameterList *TPL)
Definition: ODRHash.cpp:189
clang::UnresolvedUsingTypeLoc
Wrapper for source info for unresolved typename using decls.
Definition: TypeLoc.h:692
clang::serialization::ModuleFile::OriginalDir
std::string OriginalDir
The directory that the PCH was originally created in.
Definition: ModuleFile.h:149
clang::Token::setKind
void setKind(tok::TokenKind K)
Definition: Token.h:93
OpenMPKinds.h
Defines some OpenMP-specific enums and functions.
clang::serialization::MacroID
uint32_t MacroID
An ID number that refers to a macro in an AST file.
Definition: ASTBitCodes.h:140
clang::serialization::reader::HeaderFileInfoLookupTable
llvm::OnDiskChainedHashTable< HeaderFileInfoTrait > HeaderFileInfoLookupTable
The on-disk hash table used for known header files.
Definition: ASTReaderInternals.h:284
clang::DeclarationName::ObjCZeroArgSelector
Definition: DeclarationName.h:204
clang::serialization::PP_MACRO_OBJECT_LIKE
An object-like macro definition.
Definition: ASTBitCodes.h:688
clang::OMPClauseReader::VisitOMPClauseWithPostUpdate
void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C)
Definition: ASTReader.cpp:11739
max
__DEVICE__ int max(int __a, int __b)
Definition: __clang_cuda_device_functions.h:1628
clang::UnaryTransformTypeLoc::setUnderlyingTInfo
void setUnderlyingTInfo(TypeSourceInfo *TInfo)
Definition: TypeLoc.h:1909
clang::ASTReader::ARR_ConfigurationMismatch
The client can handle an AST file that cannot load because it&#39;s compiled configuration doesn&#39;t match ...
Definition: ASTReader.h:1519
clang::ASTContext::OCLReserveIDTy
CanQualType OCLReserveIDTy
Definition: ASTContext.h:1054
clang::ASTFileSignature
The signature of a module, which is a hash of the AST content.
Definition: Module.h:54
clang::LangOptions
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Definition: LangOptions.h:53
clang::DeclarationName::CXXLiteralOperatorName
Definition: DeclarationName.h:212
clang::ASTRecordReader::readDeclarationNameLoc
DeclarationNameLoc readDeclarationNameLoc(DeclarationName Name)
Read a declaration name, advancing Idx.
Definition: ASTReader.cpp:8576
clang::Preprocessor::getLangOpts
const LangOptions & getLangOpts() const
Definition: Preprocessor.h:907
clang::serialization::PP_TOKEN
Describes one token.
Definition: ASTBitCodes.h:697
clang::serialization::reader::ASTSelectorLookupTrait::ReadKey
internal_key_type ReadKey(const unsigned char *d, unsigned)
Definition: ASTReader.cpp:831
OMPHintClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:5516
clang::Module
Describes a module or submodule.
Definition: Module.h:64
llvm::SmallVectorImpl
Definition: LLVM.h:36
clang::serialization::PREDEF_TYPE_SHORT_ACCUM_ID
The &#39;short _Accum&#39; type.
Definition: ASTBitCodes.h:945
clang::ASTReader::ReadAST
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, unsigned ClientLoadCapabilities, SmallVectorImpl< ImportedSubmodule > *Imported=nullptr)
Load the AST file designated by the given file name.
Definition: ASTReader.cpp:4165
clang::ASTReader::completeVisibleDeclsMap
void completeVisibleDeclsMap(const DeclContext *DC) override
Load all external visible decls in the given DeclContext.
Definition: ASTReader.cpp:7536
clang::SrcMgr::ContentCache::getRawBuffer
const llvm::MemoryBuffer * getRawBuffer() const
Get the underlying buffer, returning NULL if the buffer is not yet available.
Definition: SourceManager.h:212
clang::serialization::ModuleFile::LocalNumHeaderFileInfos
unsigned LocalNumHeaderFileInfos
The number of local HeaderFileInfo structures.
Definition: ModuleFile.h:350
clang::PCHContainerReader::ExtractPCH
virtual llvm::StringRef ExtractPCH(llvm::MemoryBufferRef Buffer) const =0
Returns the serialized AST inside the PCH container Buffer.
clang::serialization::EXT_VECTOR_DECLS
Record code for the set of ext_vector type names.
Definition: ASTBitCodes.h:498
clang::serialization::PREDEF_TYPE_LONG_ACCUM_ID
The &#39;long _Accum&#39; type.
Definition: ASTBitCodes.h:951
clang::ASTContext::LongFractTy
CanQualType LongFractTy
Definition: ASTContext.h:1032
clang::ASTReader::ReadVersionTuple
static VersionTuple ReadVersionTuple(const RecordData &Record, unsigned &Idx)
Read a version tuple.
Definition: ASTReader.cpp:8905
clang::ASTReader::getSourceDescriptor
llvm::Optional< ASTSourceDescriptor > getSourceDescriptor(unsigned ID) override
Return a descriptor for the corresponding module.
Definition: ASTReader.cpp:8497
clang::HeaderFileInfo::External
unsigned External
Whether this header file info was supplied by an external source, and has not changed since...
Definition: HeaderSearch.h:65
collectMacroDefinitions
static void collectMacroDefinitions(const PreprocessorOptions &PPOpts, MacroDefinitionsMap &Macros, SmallVectorImpl< StringRef > *MacroNames=nullptr)
Collect the macro definitions provided by the given preprocessor options.
Definition: ASTReader.cpp:584
OMPCopyprivateClause
This represents clause &#39;copyprivate&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:3718
clang::OMPOrderedClause::setLoopCounter
void setLoopCounter(unsigned NumLoop, Expr *Counter)
Set loop counter for the specified loop.
Definition: OpenMPClause.cpp:304
clang::Module::getTopLevelModuleName
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
Definition: Module.h:467
clang::FileID::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:45
clang::serialization::ModuleFile::PreprocessedEntityOffsets
const PPEntityOffset * PreprocessedEntityOffsets
Definition: ModuleFile.h:338
clang::serialization::SUBMODULE_EXPORTS
Specifies the submodules that are re-exported from this submodule.
Definition: ASTBitCodes.h:748
clang::ObjCTypeParamTypeLoc::setProtocolLoc
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:797
clang::QualifierInfo::TemplParamLists
TemplateParameterList ** TemplParamLists
A new-allocated array of size NumTemplParamLists, containing pointers to the "outer" template paramet...
Definition: Decl.h:658
clang::ModuleFileExtensionMetadata::UserInfo
std::string UserInfo
A string containing additional user information that will be stored with the metadata.
Definition: ModuleFileExtension.h:49
clang::serialization::ModuleFile::BaseMacroID
serialization::MacroID BaseMacroID
Base macro ID for macros local to this module.
Definition: ModuleFile.h:314
clang::FieldDecl::isBitField
bool isBitField() const
Determines whether this field is a bitfield.
Definition: Decl.h:2807
clang::SelectorTable::getNullarySelector
Selector getNullarySelector(IdentifierInfo *ID)
Definition: IdentifierTable.h:850
clang::serialization::PREDEF_DECL_OBJC_ID_ID
The Objective-C &#39;id&#39; type.
Definition: ASTBitCodes.h:1099
clang::AtomicTypeLoc::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2381
clang::Module::InferExportWildcard
unsigned InferExportWildcard
Whether, when inferring submodules, the inferr submodules should export all modules they import (e...
Definition: Module.h:254
clang::AttributedTypeLoc::setAttr
void setAttr(const Attr *A)
Definition: TypeLoc.h:876
clang::TypeSpecTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:527
llvm::Expected
Definition: LLVM.h:38
clang::serialization::SPECIAL_TYPE_CF_CONSTANT_STRING
CFConstantString type.
Definition: ASTBitCodes.h:1058
clang::ASTConsumer::HandleInterestingDecl
virtual void HandleInterestingDecl(DeclGroupRef D)
HandleInterestingDecl - Handle the specified interesting declaration.
Definition: ASTConsumer.cpp:22
clang::ASTReader::ReadPreprocessedEntity
PreprocessedEntity * ReadPreprocessedEntity(unsigned Index) override
Read a preallocated preprocessed entity from the external source.
Definition: ASTReader.cpp:5892
clang::MacroQualifiedTypeLoc::setExpansionLoc
void setExpansionLoc(SourceLocation Loc)
Definition: TypeLoc.h:1097
clang::AS_private
Definition: Specifiers.h:116
clang::BlockPointerTypeLoc::setCaretLoc
void setCaretLoc(SourceLocation Loc)
Definition: TypeLoc.h:1246
clang::DependentTemplateSpecializationTypeLoc::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2268
clang::InjectedClassNameTypeLoc
Wrapper for source info for injected class names of class templates.
Definition: TypeLoc.h:681
clang::serialization::ModuleFile::PCHHasObjectFile
bool PCHHasObjectFile
Whether the PCH has a corresponding object file.
Definition: ModuleFile.h:160
clang::PreprocessingRecord
A record of the steps taken while preprocessing a source file, including the various preprocessing di...
Definition: PreprocessingRecord.h:308
clang::Preprocessor::getHeaderSearchInfo
HeaderSearch & getHeaderSearchInfo() const
Definition: Preprocessor.h:912
clang::format::hash_combine
static void hash_combine(std::size_t &seed, const T &v)
Definition: UnwrappedLineParser.cpp:519
clang::IdentifierInfo::getTokenID
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
Definition: IdentifierTable.h:185
ModuleFile.h
clang::ObjCTypeParamTypeLoc::getNumProtocols
unsigned getNumProtocols() const
Definition: TypeLoc.h:788
clang::serialization::NumSpecialTypeIDs
const unsigned NumSpecialTypeIDs
The number of special type IDs.
Definition: ASTBitCodes.h:1083
clang::DeclarationNameLoc::CXXOpName::BeginOpNameLoc
unsigned BeginOpNameLoc
Definition: DeclarationName.h:663
clang::TemplateArgumentListInfo
A convenient class for passing around template argument information.
Definition: TemplateBase.h:554
clang::ASTContext::setcudaConfigureCallDecl
void setcudaConfigureCallDecl(FunctionDecl *FD)
Definition: ASTContext.h:1291
clang::ASTContext::SatShortFractTy
CanQualType SatShortFractTy
Definition: ASTContext.h:1037
clang::serialization::SM_SLOC_BUFFER_BLOB
Describes a blob that contains the data for a buffer entry.
Definition: ASTBitCodes.h:670
clang::format::Tok
const FormatToken & Tok
Definition: BreakableToken.h:239
clang::serialization::ReadMethodPoolVisitor
Definition: ASTReader.cpp:7972
dump
static void dump(llvm::raw_ostream &OS, StringRef FunctionName, ArrayRef< CounterExpression > Expressions, ArrayRef< CounterMappingRegion > Regions)
Definition: CoverageMappingGen.cpp:1290
clang::ExternalVTableUse::DefinitionRequired
bool DefinitionRequired
Definition: ExternalSemaSource.h:46
clang::serialization::LANGUAGE_OPTIONS
Record code for the language options table.
Definition: ASTBitCodes.h:345
clang::serialization::PREDEF_TYPE_USHORT_ACCUM_ID
The &#39;unsigned short _Accum&#39; type.
Definition: ASTBitCodes.h:954
clang::ASTContext::getObjCSelDecl
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined &#39;SEL&#39; type in Objective-C.
Definition: ASTContext.cpp:7467
clang::ODRHash::AddFunctionDecl
void AddFunctionDecl(const FunctionDecl *Function, bool SkipBody=false)
Definition: ODRHash.cpp:519
clang::ASTContext::SatUnsignedShortAccumTy
CanQualType SatUnsignedShortAccumTy
Definition: ASTContext.h:1035
TypeLocVisitor.h
clang::OMPInReductionClause::CreateEmpty
static OMPInReductionClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:786
LLVM.h
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
clang::Module::Conflict::Message
std::string Message
The message provided to the user when there is a conflict.
Definition: Module.h:371
clang::APValue::FixedPoint
Definition: APValue.h:126
clang::ASTReader::getGlobalDeclID
serialization::DeclID getGlobalDeclID(ModuleFile &F, serialization::LocalDeclID LocalID) const
Map from a local declaration ID within a given module to a global declaration ID. ...
Definition: ASTReader.cpp:7190
clang::FunctionTypeLoc
Wrapper for source info for functions.
Definition: TypeLoc.h:1351
clang::serialization::SUBMODULE_CONFLICT
Specifies a conflict with another module.
Definition: ASTBitCodes.h:764
clang::serialization::PREDEF_DECL_INT_128_ID
The signed 128-bit integer type.
Definition: ASTBitCodes.h:1111
clang::serialization::DeclarationNameKey::getHash
unsigned getHash() const
Compute a fingerprint of this key for use in on-disk hash table.
Definition: ASTReader.cpp:1055
clang::SourceManager::isFileOverridden
bool isFileOverridden(const FileEntry *File) const
Returns true if the file contents have been overridden.
Definition: SourceManager.h:949
clang::ComparisonCategoryType::First
clang::ASTReader::FindExternalLexicalDecls
void FindExternalLexicalDecls(const DeclContext *DC, llvm::function_ref< bool(Decl::Kind)> IsKindWeWant, SmallVectorImpl< Decl *> &Decls) override
Read all of the declarations lexically stored in a declaration context.
Definition: ASTReader.cpp:7392
clang::ASTReader::ReadPath
std::string ReadPath(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8890
clang::PCHValidator::ReadPreprocessorOptions
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:748
clang::ASTReader::getModuleFileLevelDecls
llvm::iterator_range< ModuleDeclIterator > getModuleFileLevelDecls(ModuleFile &Mod)
Definition: ASTReader.cpp:5871
clang::SubstTemplateTypeParmPackTypeLoc
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:840
clang::ASTReader::getOwningModuleNameForDiagnostic
std::string getOwningModuleNameForDiagnostic(const Decl *D)
Get the best name we know for the module that owns the given declaration, or an empty string if the d...
Definition: ASTReader.cpp:9056
clang::DiagnosticsEngine
Concrete class used by the front-end to report problems and issues.
Definition: Diagnostic.h:149
clang::ASTReader::getGlobalSubmoduleID
serialization::SubmoduleID getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID)
Retrieve the global submodule ID given a module and its local ID number.
Definition: ASTReader.cpp:8428
clang::serialization::OPTIMIZE_PRAGMA_OPTIONS
Record code for #pragma optimize options.
Definition: ASTBitCodes.h:618
clang::serialization::PPEntityOffset::BitOffset
uint32_t BitOffset
Offset in the AST file.
Definition: ASTBitCodes.h:185
clang::ASTReader::ReadCXXTemporary
CXXTemporary * ReadCXXTemporary(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8917
clang::HeaderFileInfo::NumIncludes
unsigned short NumIncludes
The number of times the file has been included already.
Definition: HeaderSearch.h:90
clang::Sema::MethodPool
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Definition: Sema.h:1256
clang::serialization::ModuleFile::Data
StringRef Data
The serialized bitstream data for this file.
Definition: ModuleFile.h:190
clang::HeaderSearchOptions::ResourceDir
std::string ResourceDir
The directory which holds the compiler resource files (builtin includes, etc.).
Definition: HeaderSearchOptions.h:109
clang::serialization::SUBMODULE_PRIVATE_TEXTUAL_HEADER
Specifies a header that is private to this submodule but must be textually included.
Definition: ASTBitCodes.h:775
clang::serialization::PENDING_IMPLICIT_INSTANTIATIONS
Record code for pending implicit instantiations.
Definition: ASTBitCodes.h:528
clang::SubstTemplateTypeParmTypeLoc
Wrapper for substituted template type parameters.
Definition: TypeLoc.h:833
clang::ASTReader::hasExternalDefinitions
ExtKind hasExternalDefinitions(const Decl *D) override
Definition: ASTReader.cpp:8514
clang::ASTContext::PseudoObjectTy
CanQualType PseudoObjectTy
Definition: ASTContext.h:1047
clang::OMPDefaultClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:903
clang::serialization::PREDEF_DECL_MAKE_INTEGER_SEQ_ID
The internal &#39;__make_integer_seq&#39; template.
Definition: ASTBitCodes.h:1132
clang::TypeofLikeTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1820
clang::MacroDirective::MD_Define
Definition: MacroInfo.h:293
clang::ObjCMethodDecl::setLazyBody
void setLazyBody(uint64_t Offset)
Definition: DeclObjC.h:521
clang::ASTReader::getContext
ASTContext & getContext()
Retrieve the AST context that this AST reader supplements.
Definition: ASTReader.h:2214
clang::DependentTemplateSpecializationType::getArg
const TemplateArgument & getArg(unsigned Idx) const
Definition: TemplateBase.h:700
clang::serialization::TYPE_EXT_QUAL
An ExtQualType record.
Definition: ASTBitCodes.h:1048
clang::TypeLoc::isNull
bool isNull() const
Definition: TypeLoc.h:120
clang::serialization::FP_PRAGMA_OPTIONS
Record code for floating point #pragma options.
Definition: ASTBitCodes.h:555
clang::serialization::CommentRecordTypes
CommentRecordTypes
Record types used within a comments block.
Definition: ASTBitCodes.h:787
clang::serialization::SPECIAL_TYPE_JMP_BUF
C jmp_buf typedef type.
Definition: ASTBitCodes.h:1064
Error
llvm::Error Error
Definition: ByteCodeEmitter.cpp:19
clang::serialization::ModuleFile::NumPreprocessedSkippedRanges
unsigned NumPreprocessedSkippedRanges
Definition: ModuleFile.h:345
clang::OMPClauseWithPostUpdate
Class that handles post-update expression for some clauses, like &#39;lastprivate&#39;, &#39;reduction&#39; etc...
Definition: OpenMPClause.h:146
Diagnostic.h
Defines the Diagnostic-related interfaces.
clang::SanitizerSet
Definition: Sanitizers.h:151
clang::VarDecl::isConstexpr
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
Definition: Decl.h:1412
clang::serialization::reader::ASTIdentifierLookupTraitBase::ReadKey
static internal_key_type ReadKey(const unsigned char *d, unsigned n)
Definition: ASTReader.cpp:901
ASTCommon.h
clang::ASTContext::LongDoubleTy
CanQualType LongDoubleTy
Definition: ASTContext.h:1028
clang::OMPDefaultClause
This represents &#39;default&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:862
clang::DeclContext::setMustBuildLookupTable
void setMustBuildLookupTable()
Mark that there are external lexical declarations that we need to include in our lookup table (and th...
Definition: DeclBase.h:2333
clang::serialization::ModuleManager::Missing
The module file is missing.
Definition: ModuleManager.h:206
clang::Sema::addExternalSource
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Definition: Sema.cpp:462
clang::RawComment::CommentKind
CommentKind
Definition: RawCommentList.h:32
clang::Module::IsFromModuleFile
unsigned IsFromModuleFile
Whether this module was loaded from a module file.
Definition: Module.h:222
clang::serialization::ModuleFile::OriginalSourceFileName
std::string OriginalSourceFileName
The original source file name that was used to build the primary AST file, which may have been modifi...
Definition: ModuleFile.h:137
clang::ObjCInterfaceTypeLoc
Wrapper for source info for ObjC interfaces.
Definition: TypeLoc.h:1040
clang::serialization::KNOWN_NAMESPACES
Record code for the set of known namespaces, which are used for typo correction.
Definition: ASTBitCodes.h:565
clang::serialization::PREDEF_TYPE_RESERVE_ID_ID
OpenCL reserve_id type.
Definition: ASTBitCodes.h:930
isDiagnosedResult
static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps)
Definition: ASTReader.cpp:2459
clang::MacroDirective::Kind
Kind
Definition: MacroInfo.h:292
clang::ASTReader::getLoadedLookupTables
const serialization::reader::DeclContextLookupTable * getLoadedLookupTables(DeclContext *Primary) const
Get the loaded lookup tables for Primary, if any.
Definition: ASTReader.cpp:7560
clang::IdentifierInfo::hasRevertedBuiltin
bool hasRevertedBuiltin() const
True if setNotBuiltin() was called.
Definition: IdentifierTable.h:224
clang::serialization::IMPORTED_MODULES
Record code for an array of all of the (sub)modules that were imported by the AST file...
Definition: ASTBitCodes.h:586
clang::OMPFinalClause
This represents &#39;final&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:525
clang::OMPMergeableClause
This represents &#39;mergeable&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:1648
clang::serialization::PREDEF_TYPE_USHORT_ID
The &#39;unsigned short&#39; type.
Definition: ASTBitCodes.h:822
clang::serialization::ModuleFile::BaseDeclID
serialization::DeclID BaseDeclID
Base declaration ID for declarations local to this module.
Definition: ModuleFile.h:418
clang::diag::Severity::Error
Present this diagnostic as an error.
clang::EnumConstantDecl::getInitExpr
const Expr * getInitExpr() const
Definition: Decl.h:2960
OMPGrainsizeClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:5349
clang::OMPReductionClause
This represents clause &#39;reduction&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:2443
clang::TemplateTypeParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1248
clang::serialization::ModuleFile::FirstLoc
SourceLocation FirstLoc
The first source location in this module.
Definition: ModuleFile.h:210
clang::Decl::getLexicalDeclContext
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
Definition: DeclBase.h:828
clang::ObjCObjectTypeLoc::setProtocolLoc
void setProtocolLoc(unsigned i, SourceLocation Loc)
Definition: TypeLoc.h:979
clang::serialization::ModuleFile::SLocRemap
ContinuousRangeMap< uint32_t, int, 2 > SLocRemap
Remapping table for source locations in this module.
Definition: ModuleFile.h:263
OMPMappableExprListSizeTy::NumVars
unsigned NumVars
Number of expressions listed.
Definition: OpenMPClause.h:4294
clang::serialization::PREDEF_TYPE_SAT_SHORT_FRACT_ID
The &#39;_Sat short _Fract&#39; type.
Definition: ASTBitCodes.h:999
clang::HeaderSearchOptions::DisableModuleHash
unsigned DisableModuleHash
Whether we should disable the use of the hash string within the module cache.
Definition: HeaderSearchOptions.h:130
clang::serialization::PREDEF_TYPE_ULONG_ACCUM_ID
The &#39;unsigned long _Accum&#39; type.
Definition: ASTBitCodes.h:960
clang::ASTReader::ReadWeakUndeclaredIdentifiers
void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo >> &WI) override
Definition: ASTReader.cpp:8203
OMPIsDevicePtrClause
This represents clause &#39;is_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:6179
clang::ASTRecordReader::readCXXCtorInitializers
CXXCtorInitializer ** readCXXCtorInitializers()
Read a CXXCtorInitializer array, advancing Idx.
Definition: ASTReader.cpp:8684
clang::FunctionTypeLoc::setLocalRangeBegin
void setLocalRangeBegin(SourceLocation L)
Definition: TypeLoc.h:1374
clang::ASTReader::ReadPragmaDiagnosticMappings
void ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag)
Definition: ASTReader.cpp:6171
TemplateName.h
clang::PCHContainerReader
This abstract interface provides operations for unwrapping containers for serialized ASTs (precompile...
Definition: PCHContainerOperations.h:57
clang::IdentifierInfo::revertBuiltin
void revertBuiltin()
Revert the identifier to a non-builtin identifier.
Definition: IdentifierTable.h:231
clang::StaticAssertDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: DeclCXX.h:3796
llvm::ArrayRef
Definition: LLVM.h:31
clang::ASTReader::Failure
The AST file itself appears corrupted.
Definition: ASTReader.h:371
clang::serialization::CTOR_INITIALIZER_DELEGATING
Definition: ASTBitCodes.h:1897
clang::serialization::InputFile::isOverridden
bool isOverridden() const
Definition: ModuleFile.h:95
OMPMappableExprListClause::getUniqueDeclarationsNum
unsigned getUniqueDeclarationsNum() const
Return the number of unique base declarations in this clause.
Definition: OpenMPClause.h:4582
llvm::SmallString< 128 >
clang::OpenMPDirectiveKind
llvm::omp::Directive OpenMPDirectiveKind
OpenMP directives.
Definition: OpenMPKinds.h:62
clang::TemplateTemplateParmDecl::isParameterPack
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
Definition: DeclTemplate.h:1669
clang::ASTReader::dump
void dump()
Dump information about the AST reader to standard error.
Definition: ASTReader.cpp:7708
clang::ASTReader::ReadMismatchingDeleteExpressions
void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &Exprs) override
Definition: ASTReader.cpp:8116
clang::TemplateSpecializationTypeLoc::getNumArgs
unsigned getNumArgs() const
Definition: TypeLoc.h:1604
ASTMutationListener.h
readASTFileSignature
static ASTFileSignature readASTFileSignature(StringRef PCH)
Reads and return the signature record from PCH&#39;s control block, or else returns 0.
Definition: ASTReader.cpp:4957
clang::HeaderFileInfo
The preprocessor keeps track of this information for each file that is #included. ...
Definition: HeaderSearch.h:50
clang::serialization::PREDEF_TYPE_NULLPTR_ID
The type of &#39;nullptr&#39;.
Definition: ASTBitCodes.h:876
clang::serialization::ModuleFile::PreprocessorDetailStartOffset
uint64_t PreprocessorDetailStartOffset
The offset of the start of the preprocessor detail cursor.
Definition: ModuleFile.h:329
clang::serialization::PREDEF_TYPE_SAT_ULONG_FRACT_ID
The &#39;_Sat unsigned long _Fract&#39; type.
Definition: ASTBitCodes.h:1014
clang::ASTContext::UnsignedCharTy
CanQualType UnsignedCharTy
Definition: ASTContext.h:1026
clang::serialization::SOURCE_LOCATION_OFFSETS
Record code for the table of offsets into the block of source-location information.
Definition: ASTBitCodes.h:487
clang::DependentAddressSpaceTypeLoc::setAttrNameLoc
void setAttrNameLoc(SourceLocation loc)
Definition: TypeLoc.h:1693
clang::Decl::getCanonicalDecl
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
Definition: DeclBase.h:877
clang::UnaryTransformTypeLoc::setKWLoc
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1897
clang::ASTReaderListener::needsInputFileVisitation
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.h:198
OMPFromClause
This represents clause &#39;from&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:5898
clang::serialization::SPECIAL_TYPE_OBJC_ID_REDEFINITION
Objective-C "id" redefinition type.
Definition: ASTBitCodes.h:1070
clang::ASTReader::ReadString
static std::string ReadString(const RecordData &Record, unsigned &Idx)
Definition: ASTReader.cpp:8883
clang::serialization::TypeCode
TypeCode
Record codes for each kind of type.
Definition: ASTBitCodes.h:1042
clang::MacroExpansion
Records the location of a macro expansion.
Definition: PreprocessingRecord.h:170
clang::ASTDeserializationListener::SelectorRead
virtual void SelectorRead(serialization::SelectorID iD, Selector Sel)
A selector was read from the AST file.
Definition: ASTDeserializationListener.h:49
clang::ASTReaderListener::ReadFileSystemOptions
virtual bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain)
Receives the file system options.
Definition: ASTReader.h:159
clang::LangOptions::ModuleFeatures
std::vector< std::string > ModuleFeatures
The names of any features to enable in module &#39;requires&#39; decls in addition to the hard-coded list in ...
Definition: LangOptions.h:283
clang::AS_none
Definition: Specifiers.h:117
clang::DeclContext::lookup
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
Definition: DeclBase.cpp:1612
clang::NestedNameSpecifierLocBuilder
Class that aids in the construction of nested-name-specifiers along with source-location information ...
Definition: NestedNameSpecifier.h:349
clang::APFixedPoint
The APFixedPoint class works similarly to APInt/APSInt in that it is a functional replacement for a s...
Definition: FixedPoint.h:95
clang::Module::getExportedModules
void getExportedModules(SmallVectorImpl< Module *> &Exported) const
Appends this module&#39;s list of exported modules to Exported.
Definition: Module.cpp:339
ExternalASTSource.h
clang::MacroQualifiedTypeLoc
Definition: TypeLoc.h:1079
clang::Module::IsSystem
unsigned IsSystem
Whether this is a "system" module (which assumes that all headers in it are system headers)...
Definition: Module.h:232
clang::serialization::SOURCE_MANAGER_BLOCK_ID
The block containing information about the source manager.
Definition: ASTBitCodes.h:252
Parent
NodeId Parent
Definition: ASTDiff.cpp:191
clang::PreprocessorOptions::DetailedRecord
bool DetailedRecord
Whether we should maintain a detailed record of all macro definitions and expansions.
Definition: PreprocessorOptions.h:57
clang::DiagnosticMapping::isErrorOrFatal
bool isErrorOrFatal() const
Definition: DiagnosticIDs.h:125
clang::serialization::PREDEF_TYPE_OMP_ARRAY_SECTION
The placeholder type for OpenMP array section.
Definition: ASTBitCodes.h:933
clang::OMPDynamicAllocatorsClause
This represents &#39;dynamic_allocators&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:1149
clang::FunctionDecl::setLazyBody
void setLazyBody(uint64_t Offset)
Definition: Decl.h:2084
clang::ContinuousRangeMap< unsigned, ModuleFile *, 4 >::iterator
typename Representation::iterator iterator
Definition: ContinuousRangeMap.h:85
clang::Sema
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:336
clang::serialization::NUM_PREDEF_PP_ENTITY_IDS
const unsigned int NUM_PREDEF_PP_ENTITY_IDS
The number of predefined preprocessed entity IDs.
Definition: ASTBitCodes.h:241
clang::ASTRecordReader::readTypeSourceInfo
TypeSourceInfo * readTypeSourceInfo()
Reads a declarator info from the given record, advancing Idx.
Definition: ASTReader.cpp:6719
clang::StringLiteral::getString
StringRef getString() const
Definition: Expr.h:1794
clang::MacroInfo::setUsedForHeaderGuard
void setUsedForHeaderGuard(bool Val)
Definition: MacroInfo.h:273
clang::serialization::ASTRecordTypes
ASTRecordTypes
Record types that occur within the AST block itself.
Definition: ASTBitCodes.h:392
clang::IdentifierTable::iterator
HashTableTy::const_iterator iterator
Definition: IdentifierTable.h:588
clang::DiagnosticBuilder
A little helper class used to produce diagnostics.
Definition: Diagnostic.h:1053
parseModuleFileExtensionMetadata
static bool parseModuleFileExtensionMetadata(const SmallVectorImpl< uint64_t > &Record, StringRef Blob, ModuleFileExtensionMetadata &Metadata)
Parse a record and blob containing module file extension metadata.
Definition: ASTReader.cpp:4728
clang::ASTReader::GetExternalDeclStmt
Stmt * GetExternalDeclStmt(uint64_t Offset) override
Resolve the offset of a statement into a statement.
Definition: ASTReader.cpp:7376
clang::QualifierInfo::NumTemplParamLists
unsigned NumTemplParamLists
The number of "outer" template parameter lists.
Definition: Decl.h:651
clang::FunctionProtoType
Represents a prototype with parameter type info, e.g.
Definition: Type.h:3754
clang::serialization::SPECIAL_TYPE_FILE
C FILE typedef type.
Definition: ASTBitCodes.h:1061
clang::serialization::SUBMODULE_DEFINITION
Defines the major attributes of a submodule, including its name and parent.
Definition: ASTBitCodes.h:727
clang::serialization::ModuleFile::Stream
llvm::BitstreamCursor Stream
The main bitstream cursor for the main block.
Definition: ModuleFile.h:193
OMPThreadsClause
This represents &#39;threads&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:4161
clang::LangOptions::CurrentModule
std::string CurrentModule
The name of the current module, of which the main source file is a part.
Definition: LangOptions.h:277
clang::serialization::PREDEF_TYPE_UINT128_ID
The &#39;__uint128_t&#39; type.
Definition: ASTBitCodes.h:870
clang::serialization::ModuleFile::GlobalToLocalDeclIDs
llvm::DenseMap< ModuleFile *, serialization::DeclID > GlobalToLocalDeclIDs
Mapping from the module files that this module file depends on to the base declaration ID for that mo...
Definition: ModuleFile.h:430
OMPClauseReader
friend class OMPClauseReader
Definition: OpenMPClause.h:96
clang::ASTReaderListener::needsImportVisitation
virtual bool needsImportVisitation() const
Returns true if this ASTReaderListener wants to receive the imports of the AST file via visitImport...
Definition: ASTReader.h:217
clang::DeclaratorDecl
Represents a ValueDecl that came out of a declarator.
Definition: Decl.h:671
clang::serialization::DeclarationNameKey::DeclarationNameKey
DeclarationNameKey()=default
clang::serialization::PREDEF_TYPE_AUTO_RREF_DEDUCT
The "auto &&" deduction type.
Definition: ASTBitCodes.h:903
clang::ModuleMap::ModuleHeaderRole
ModuleHeaderRole
Flags describing the role of a module header.
Definition: ModuleMap.h:128
OMPAlignedClause
This represents clause &#39;aligned&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:3443
clang::serialization::ReadMethodPoolVisitor::ReadMethodPoolVisitor
ReadMethodPoolVisitor(ASTReader &Reader, Selector Sel, unsigned PriorGeneration)
Definition: ASTReader.cpp:7984
clang::ASTRecordReader::readAPValue
APValue readAPValue()
Read an arbitrary constant value, advancing Idx.
Definition: ASTReader.cpp:8837
clang::APValue::Int
Definition: APValue.h:124
clang::serialization::ModuleKind
ModuleKind
Specifies the kind of module that has been loaded.
Definition: ModuleFile.h:42
Filename
StringRef Filename
Definition: Format.cpp:1825
clang::serialization::PPD_SKIPPED_RANGES
A table of skipped ranges within the preprocessing record.
Definition: ASTBitCodes.h:653
OMPAlignedClause::CreateEmpty
static OMPAlignedClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
Definition: OpenMPClause.cpp:534
clang::ASTContext::getBuiltinMSVaListDecl
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
Definition: ASTContext.cpp:7850
clang::serialization::PREDEF_TYPE_SAMPLER_ID
OpenCL sampler type.
Definition: ASTBitCodes.h:924
clang::OMPClause::setLocEnd
void setLocEnd(SourceLocation Loc)
Sets the ending location of the clause.
Definition: OpenMPClause.h:76
clang::FileID::isValid
bool isValid() const
Definition: SourceLocation.h:44
Used
Definition: ObjCUnusedIVarsChecker.cpp:29
clang::NonTypeTemplateParmDecl::isParameterPack
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
Definition: DeclTemplate.h:1497
clang::serialization::reader::HeaderFileInfoTrait::internal_key_type::Filename
StringRef Filename
Definition: ASTReaderInternals.h:256
clang::APValue::LValue
Definition: APValue.h:129
clang::ChainedASTReaderListener::ReadModuleMapFile
void ReadModuleMapFile(StringRef ModuleMapPath) override
Definition: ASTReader.cpp:158
clang::OMPTaskReductionClause
This represents clause &#39;task_reduction&#39; in the &#39;#pragma omp taskgroup&#39; directives.
Definition: OpenMPClause.h:2679
clang::ArrayTypeLoc::setSizeExpr
void setSizeExpr(Expr *Size)
Definition: TypeLoc.h:1513
clang::serialization::ModuleFile::LocalNumSLocEntries
unsigned LocalNumSLocEntries
The number of source location entries in this AST file.
Definition: ModuleFile.h:247
clang::ASTContext::getAutoRRefDeductType
QualType getAutoRRefDeductType() const
C++11 deduction pattern for &#39;auto &&&#39; type.
Definition: ASTContext.cpp:5231
clang::ASTContext::setCFConstantStringType
void setCFConstantStringType(QualType T)
Definition: ASTContext.cpp:6230
clang::WeakInfo
Captures information about a #pragma weak directive.
Definition: Weak.h:24
clang::DependentTemplateSpecializationTypeLoc::setArgLocInfo
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2276
clang::ASTReader::visitInputFiles
void visitInputFiles(serialization::ModuleFile &MF, bool IncludeSystem, bool Complain, llvm::function_ref< void(const serialization::InputFile &IF, bool isSystem)> Visitor)
Visit all the input files of the given module file.
Definition: ASTReader.cpp:9028
clang::serialization::ReadMethodPoolVisitor::getInstanceMethods
ArrayRef< ObjCMethodDecl * > getInstanceMethods() const
Retrieve the instance methods found by this visitor.
Definition: ASTReader.cpp:8023
clang::ModuleMap
Definition: ModuleMap.h:75
clang::serialization::MACRO_OFFSET
Record code for the table of offsets of each macro ID.
Definition: ASTBitCodes.h:603
clang::Module::DirectoryName::Entry
const DirectoryEntry * Entry
Definition: Module.h:168
clang::ASTContext::UnsignedAccumTy
CanQualType UnsignedAccumTy
Definition: ASTContext.h:1031
clang::serialization::ModuleFile::TypeOffsets
const uint32_t * TypeOffsets
Offset of each type within the bitstream, indexed by the type ID, or the representation of a Type*...
Definition: ModuleFile.h:454
clang::ASTReader::resolvePendingMacro
void resolvePendingMacro(IdentifierInfo *II, const PendingMacroInfo &PMInfo)
Definition: ASTReader.cpp:2094
OMPDependClause::getNumLoops
unsigned getNumLoops() const
Get number of loops associated with the clause.
Definition: OpenMPClause.h:4049
Offset
unsigned Offset
Definition: Format.cpp:1827
clang::DependentTemplateSpecializationTypeLoc::setTemplateNameLoc
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2252
clang::ASTContext::UnsignedShortFractTy
CanQualType UnsignedShortFractTy
Definition: ASTContext.h:1033
OMPDependClause
This represents implicit clause &#39;depend&#39; for the &#39;#pragma omp task&#39; directive.
Definition: OpenMPClause.h:3958
clang::serialization::reader::ASTSelectorLookupTrait::data_type::InstanceBits
unsigned InstanceBits
Definition: ASTReaderInternals.h:198
clang::serialization::DECL_CXX_BASE_SPECIFIERS
A record containing CXXBaseSpecifiers.
Definition: ASTBitCodes.h:1368
clang::ASTReader::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Report a diagnostic.
Definition: ASTReader.cpp:8924
clang::Module::ModuleKind
ModuleKind
Definition: Module.h:72
clang::PCHValidator
ASTReaderListener implementation to validate the information of the PCH file against an initialized P...
Definition: ASTReader.h:274
clang::TypeLoc::getBeginLoc
SourceLocation getBeginLoc() const
Get the begin source location.
Definition: TypeLoc.cpp:191
clang::LangOptions::CommentOpts
CommentOptions CommentOpts
Options for parsing comments.
Definition: LangOptions.h:286
clang::TemplateDecl::getTemplateParameters
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Definition: DeclTemplate.h:421
clang::OpenMPLastprivateModifier
OpenMPLastprivateModifier
OpenMP &#39;lastprivate&#39; clause modifier.
Definition: OpenMPKinds.h:191
clang::serialization::SUBMODULE_INITIALIZERS
Specifies some declarations with initializers that must be emitted to initialize the module...
Definition: ASTBitCodes.h:779
clang::serialization::MK_PrebuiltModule
File is from a prebuilt module path.
Definition: ModuleFile.h:59
clang::ASTReader::getGlobalTypeID
serialization::TypeID getGlobalTypeID(ModuleFile &F, unsigned LocalID) const
Map a local type ID within a given AST file into a global type ID.
Definition: ASTReader.cpp:6989
clang::FunctionDecl::isInlineSpecified
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Definition: Decl.h:2499
clang::AttributedTypeLoc
Type source information for an attributed type.
Definition: TypeLoc.h:851
clang::DependentTemplateSpecializationTypeLoc::setQualifierLoc
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2224
clang::ASTReader::GetHeaderFileInfo
HeaderFileInfo GetHeaderFileInfo(const FileEntry *FE) override
Read the header file information for the given file entry.
Definition: ASTReader.cpp:6162
clang::OMPProcBindClause
This represents &#39;proc_bind&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:942
clang::OMPCaptureClause
This represents &#39;capture&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Definition: OpenMPClause.h:1805
clang::serialization::SM_SLOC_BUFFER_BLOB_COMPRESSED
Describes a zlib-compressed blob that contains the data for a buffer entry.
Definition: ASTBitCodes.h:674
clang::ValueDecl
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:619
clang::Expr
This represents one expression.
Definition: Expr.h:108
clang::ASTReader::getModuleFileID
unsigned getModuleFileID(ModuleFile *M)
Get an ID for the given module file.
Definition: ASTReader.cpp:8479
LangOptions.h
Defines the clang::LangOptions interface.
ModuleMap.h
clang::serialization::PPEntityOffset::getEnd
SourceLocation getEnd() const
Definition: ASTBitCodes.h:195
End
SourceLocation End
Definition: USRLocFinder.cpp:166
clang::serialization::VTABLE_USES
Record code for the array of VTable uses.
Definition: ASTBitCodes.h:508
clang::frontend::IncludeDirGroup
IncludeDirGroup
IncludeDirGroup - Identifies the group an include Entry belongs to, representing its relative positiv...
Definition: HeaderSearchOptions.h:31
clang::serialization::PREDEF_TYPE_CHAR_U_ID
The &#39;char&#39; type, when it is unsigned.
Definition: ASTBitCodes.h:816
clang::MacroInfo::setHasCommaPasting
void setHasCommaPasting()
Definition: MacroInfo.h:218
isInterestingIdentifier
static bool isInterestingIdentifier(ASTReader &Reader, IdentifierInfo &II, bool IsModule)
Whether the given identifier is "interesting".
Definition: ASTReader.cpp:907
clang::serialization::InputFile::getNotFound
static InputFile getNotFound()
Definition: ModuleFile.h:88
clang::BuiltinTypeLoc::setModeAttr
void setModeAttr(bool written)
Definition: TypeLoc.h:652
clang::ASTReader::getSwitchCaseWithID
SwitchCase * getSwitchCaseWithID(unsigned ID)
Retrieve the switch-case statement with the given ID.
Definition: ASTReader.cpp:8947
clang::ASTReader::getGlobalMacroID
serialization::MacroID getGlobalMacroID(ModuleFile &M, unsigned LocalID)
Retrieve the global macro ID corresponding to the given local ID within the given module file...
Definition: ASTReader.cpp:8413
clang::serialization::ORIGINAL_PCH_DIR
The directory that the PCH was originally created in.
Definition: ASTBitCodes.h:315
clang::IncompleteArrayTypeLoc
Definition: TypeLoc.h:1540
clang::serialization::COMMENTS_RAW_COMMENT
Definition: ASTBitCodes.h:788
clang::EnumDecl::isScopedUsingClassTag
bool isScopedUsingClassTag() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3678
Id
int Id
Definition: ASTDiff.cpp:190
clang::OMPSimdlenClause
This represents &#39;simdlen&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:735
clang::serialization::PREDEF_TYPE_SAT_LONG_FRACT_ID
The &#39;_Sat long _Fract&#39; type.
Definition: ASTBitCodes.h:1005
clang::CPlusPlus
Definition: LangStandard.h:47
clang::TemplateTypeParmDecl
Declaration of a template type parameter.
Definition: DeclTemplate.h:1177
OMPMappableExprListSizeTy::NumComponentLists
unsigned NumComponentLists
Number of component lists.
Definition: OpenMPClause.h:4298
clang::serialization::reader::ASTSelectorLookupTrait::data_type::FactoryBits
unsigned FactoryBits
Definition: ASTReaderInternals.h:199
clang::DiagnosticMapping::wasUpgradedFromWarning
bool wasUpgradedFromWarning() const
Whether this mapping attempted to map the diagnostic to a warning, but was overruled because the diag...
Definition: DiagnosticIDs.h:139
clang::FileSystemOptions::WorkingDir
std::string WorkingDir
If set, paths are resolved as if the working directory was set to the value of WorkingDir.
Definition: FileSystemOptions.h:26
clang::serialization::ModuleFile::LocalNumIdentifiers
unsigned LocalNumIdentifiers
The number of identifiers in this AST file.
Definition: ModuleFile.h:268
clang::ASTReader::ReadUsedVTables
void ReadUsedVTables(SmallVectorImpl< ExternalVTableUse > &VTables) override
Read the set of used vtables known to the external Sema source.
Definition: ASTReader.cpp:8223
clang::serialization::PREDEF_TYPE_OVERLOAD_ID
The placeholder type for overloaded function sets.
Definition: ASTBitCodes.h:864
clang::LangOptions::OMPHostIRFile
std::string OMPHostIRFile
Name of the IR file that contains the result of the OpenMP target host code generation.
Definition: LangOptions.h:297
CommentOptions.h
Defines the clang::CommentOptions interface.
clang::IdentifierTable
Implements an efficient mapping from strings to IdentifierInfo nodes.
Definition: IdentifierTable.h:496
SourceManagerInternals.h
Defines implementation details of the clang::SourceManager class.
clang::APValue::Struct
Definition: APValue.h:132
clang::TemplateArgument::NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
Definition: TemplateBase.h:67
clang::ASTReaderListener::readModuleFileExtension
virtual void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata)
Indicates that a particular module file extension has been read.
Definition: ASTReader.h:224
Inits
Inits[]
Definition: OpenMPClause.h:150
clang::Module::ConfigMacrosExhaustive
unsigned ConfigMacrosExhaustive
Whether the set of configuration macros is exhaustive.
Definition: Module.h:261
clang::serialization::PPD_ENTITIES_OFFSETS
Record code for the table of offsets to entries in the preprocessing record.
Definition: ASTBitCodes.h:505
clang::DependentAddressSpaceTypeLoc
Definition: TypeLoc.h:1681
clang::AutoTypeLoc::setFoundDecl
void setFoundDecl(NamedDecl *D)
Definition: TypeLoc.h:1984
clang::CXXDestructorDecl
Represents a C++ destructor within a class.
Definition: DeclCXX.h:2649
AbstractTypeReader.h
clang::serialization::ModuleFile::IdentifierRemap
ContinuousRangeMap< uint32_t, int, 2 > IdentifierRemap
Remapping table for identifier IDs in this module.
Definition: ModuleFile.h:281
clang::ast_matchers::decl
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
Definition: ASTMatchersInternal.cpp:613
clang::ASTRecordReader::readRecord
Expected< unsigned > readRecord(llvm::BitstreamCursor &Cursor, unsigned AbbrevID)
Reads a record with id AbbrevID from Cursor, resetting the internal state.
Definition: ASTReader.cpp:11485
clang::ASTContext::OMPArraySectionTy
CanQualType OMPArraySectionTy
Definition: ASTContext.h:1055
clang::serialization::ModuleFile::SLocEntryCursor
llvm::BitstreamCursor SLocEntryCursor
Cursor used to read source location entries.
Definition: ModuleFile.h:244
clang::Decl::setInvalidDecl
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
Definition: DeclBase.cpp:132
Version.h
Defines version macros and version-related utility functions for Clang.
DeclBase.h
clang::serialization::PREDEF_TYPE_HALF_ID
The OpenCL &#39;half&#39; / ARM NEON __fp16 type.
Definition: ASTBitCodes.h:906
clang::DeclarationNameLoc::CXXLitOpName::OpNameLoc
unsigned OpNameLoc
Definition: DeclarationName.h:669
clang::SrcMgr::ContentCache::ContentsEntry
const FileEntry * ContentsEntry
References the file which the contents were actually loaded from.
Definition: SourceManager.h:123
clang::Decl::isImplicit
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
Definition: DeclBase.h:558
clang::Decl::getImportedOwningModule
Module * getImportedOwningModule() const
Get the imported owning module, if this decl is from an imported (non-local) module.
Definition: DeclBase.h:729
clang::FunctionDecl::getTemplateSpecializationArgs
const TemplateArgumentList * getTemplateSpecializationArgs() const
Retrieve the template arguments used to produce this function template specialization from the primar...
Definition: Decl.cpp:3669
OMPDependClause::CreateEmpty
static OMPDependClause * CreateEmpty(const ASTContext &C, unsigned N, unsigned NumLoops)
Creates an empty clause with N variables.
Definition: OpenMPClause.cpp:846
OperatorKinds.h
Defines an enumeration for C++ overloaded operators.
Preprocessor.h
Defines the clang::Preprocessor interface.
clang::TemplateArgument::ArgKind
ArgKind
The kind of template argument we&#39;re storing.
Definition: TemplateBase.h:53
clang::hash_value
llvm::hash_code hash_value(const clang::SanitizerMask &Arg)
Definition: Sanitizers.cpp:51
clang::serialization::PREPROCESSOR_DETAIL_BLOCK_ID
The block containing the detailed preprocessing record.
Definition: ASTBitCodes.h:263
ASTUnresolvedSet.h
clang::SimpleASTReaderListener
ASTReaderListenter implementation to set SuggestedPredefines of ASTReader which is required to use a ...
Definition: ASTReader.h:303
clang::serialization::DIAG_PRAGMA_MAPPINGS
Record code for #pragma diagnostic mappings.
Definition: ASTBitCodes.h:369
bool
#define bool
Definition: stdbool.h:15
clang::IdentifierInfo::setIsPoisoned
void setIsPoisoned(bool Value=true)
setIsPoisoned - Mark this identifier as poisoned.
Definition: IdentifierTable.h:281
clang::ASTReader::getModuleImportLoc
std::pair< SourceLocation, StringRef > getModuleImportLoc(int ID) override
Retrieve the module import location and module name for the given source manager entry ID...
Definition: ASTReader.cpp:1591
clang::OMPVarListClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:245
clang::Decl::getDeclContext
DeclContext * getDeclContext()
Definition: DeclBase.h:438
clang::LineEntry::get
static LineEntry get(unsigned Offs, unsigned Line, int Filename, SrcMgr::CharacteristicKind FileKind, unsigned IncludeOffset)
Definition: SourceManagerInternals.h:52
clang::BuiltinTypeLoc::setWrittenSignSpec
void setWrittenSignSpec(TypeSpecifierSign written)
Definition: TypeLoc.h:613
clang::serialization::ModuleFile::InputFilesCursor
llvm::BitstreamCursor InputFilesCursor
The cursor to the start of the input-files block.
Definition: ModuleFile.h:223
clang::serialization::ModuleFile::LocalNumMacros
unsigned LocalNumMacros
The number of macros in this AST file.
Definition: ModuleFile.h:304
clang::ASTReader::ReadSourceRange
SourceRange ReadSourceRange(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Read a source range.
Definition: ASTReader.cpp:8811
clang::serialization::DECL_CXX_CTOR_INITIALIZERS
A record containing CXXCtorInitializers.
Definition: ASTBitCodes.h:1371
clang::ASTContext::ShortTy
CanQualType ShortTy
Definition: ASTContext.h:1025
clang::IdentifierResolver
IdentifierResolver - Keeps track of shadowed decls on enclosing scopes.
Definition: IdentifierResolver.h:38
clang::HeaderSearchOptions::UseBuiltinIncludes
unsigned UseBuiltinIncludes
Include the compiler builtin includes.
Definition: HeaderSearchOptions.h:177
clang::serialization::ORIGINAL_FILE
Record code for the original file that was used to generate the AST file, including both its file ID ...
Definition: ASTBitCodes.h:312
clang::SwitchCase
Definition: Stmt.h:1470
clang::APValue::ValueKind
ValueKind
Definition: APValue.h:119
clang::FunctionDecl::getStorageClass
StorageClass getStorageClass() const
Returns the storage class as written in the source.
Definition: Decl.h:2488
Scope.h
clang::ASTContext::getInt128Decl
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
Definition: ASTContext.cpp:1299
clang::AtomicTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:2389
clang::NonTypeTemplateParmDecl
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
Definition: DeclTemplate.h:1383
clang::AutoTypeLoc::setTemplateKWLoc
void setTemplateKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:1968
clang::Module::LinkLibraries
llvm::SmallVector< LinkLibrary, 2 > LinkLibraries
The set of libraries or frameworks to link against when an entity from this module is used...
Definition: Module.h:342
clang::SanitizerSet::clear
void clear(SanitizerMask K=SanitizerKind::All)
Disable the sanitizers specified in K.
Definition: Sanitizers.h:168
clang::OMPFinalClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:561
clang::ASTReader::getLocalType
QualType getLocalType(ModuleFile &F, unsigned LocalID)
Resolve a local type ID within a given AST file into a type.
Definition: ASTReader.cpp:6984
clang::serialization::ModuleFile
Information about a module that has been loaded by the ASTReader.
Definition: ModuleFile.h:107
OMPMappableExprListClause::setDeclNumLists
void setDeclNumLists(ArrayRef< unsigned > DNLs)
Set the number of lists per declaration that are in the trailing objects of the class.
Definition: OpenMPClause.h:4408
TypeLoc.h
Defines the clang::TypeLoc interface and its subclasses.
clang::NestedNameSpecifier::NamespaceAlias
A namespace alias, stored as a NamespaceAliasDecl*.
Definition: NestedNameSpecifier.h:85
clang::OMPOrderedClause
This represents &#39;ordered&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:1474
clang::ASTRecordReader::readOMPClause
OMPClause * readOMPClause()
Read an OpenMP clause, advancing Idx.
Definition: ASTReader.cpp:11516
clang::ASTReaderListener::~ASTReaderListener
virtual ~ASTReaderListener()
clang::serialization::PREDEF_TYPE_LONGDOUBLE_ID
The &#39;long double&#39; type.
Definition: ASTBitCodes.h:861
clang::OMPClauseReader::OMPClauseReader
OMPClauseReader(ASTRecordReader &Record)
Definition: ASTReader.cpp:11504
OMPFlushClause::CreateEmpty
static OMPFlushClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: OpenMPClause.cpp:823
clang::serialization::DIAGNOSTIC_OPTIONS
Record code for the diagnostic options table.
Definition: ASTBitCodes.h:366
clang::DeclarationName::getAsIdentifierInfo
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn&#39;t...
Definition: DeclarationName.h:410
clang::serialization::IdentifierID
uint32_t IdentifierID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:60
clang::ChainedASTReaderListener::ReadCounter
void ReadCounter(const serialization::ModuleFile &M, unsigned Value) override
Receives COUNTER value.
Definition: ASTReader.cpp:212
clang::ASTContext::UnsignedInt128Ty
CanQualType UnsignedInt128Ty
Definition: ASTContext.h:1027
GCCTypeClass::Enum
clang::IdentifierIterator
An iterator that walks over all of the known identifiers in the lookup table.
Definition: IdentifierTable.h:448
clang::serialization::ModuleFile::ObjCCategories
SmallVector< uint64_t, 1 > ObjCCategories
The Objective-C category lists for categories known to this module.
Definition: ModuleFile.h:445
clang::ObjCInterfaceTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1053
clang::TypeofLikeTypeLoc::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1812
clang::serialization::ModuleFile::OriginalSourceFileID
FileID OriginalSourceFileID
The file ID for the original source file that was used to build this AST file.
Definition: ModuleFile.h:145
clang::CXXBaseSpecifier::setInheritConstructors
void setInheritConstructors(bool Inherit=true)
Set that this base class&#39;s constructors should be inherited.
Definition: DeclCXX.h:211
IdentifierTable.h
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
clang::SourceRange::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:223
clang::serialization::ModuleFile::HasTimestamps
bool HasTimestamps
Whether timestamps are included in this module file.
Definition: ModuleFile.h:157
clang::serialization::SM_SLOC_FILE_ENTRY
Describes a source location entry (SLocEntry) for a file.
Definition: ASTBitCodes.h:660
ASTBitCodes.h
clang::EnumTypeLoc
Wrapper for source info for enum types.
Definition: TypeLoc.h:726
clang::serialization::EXTENSION_BLOCK_ID
A block containing a module file extension.
Definition: ASTBitCodes.h:290
clang::DiagnosticLevelMask::Error
clang::DeclarationName::isIdentifier
bool isIdentifier() const
Predicate functions for querying what type of name this is.
Definition: DeclarationName.h:375
OMPMappableExprListClause::setMapperIdInfo
void setMapperIdInfo(DeclarationNameInfo MapperId)
Set the name of associated user-defined mapper.
Definition: OpenMPClause.h:4550
clang::serialization::ModuleFile::NumUserInputFiles
unsigned NumUserInputFiles
Definition: ModuleFile.h:233
clang::CreateEmpty
static OMPLinearClause * CreateEmpty(const ASTContext &C, unsigned NumVars)
Creates an empty clause with the place for NumVars variables.
clang::MacroDirective::MD_Undefine
Definition: MacroInfo.h:294
clang::LangOptions::ObjCRuntime
clang::ObjCRuntime ObjCRuntime
Definition: LangOptions.h:257
clang::serialization::ModuleFile::FileName
std::string FileName
The file name of the module file.
Definition: ModuleFile.h:122
clang::ModuleMap::setUmbrellaHeader
void setUmbrellaHeader(Module *Mod, const FileEntry *UmbrellaHeader, Twine NameAsWritten)
Sets the umbrella header of the given module to the given header.
Definition: ModuleMap.cpp:1104
clang::PackExpansionTypeLoc::setEllipsisLoc
void setEllipsisLoc(SourceLocation Loc)
Definition: TypeLoc.h:2333
clang::DependentAddressSpaceTypeLoc::setAttrExprOperand
void setAttrExprOperand(Expr *e)
Definition: TypeLoc.h:1703
clang::serialization::UPDATE_VISIBLE
Record code for an update to a decl context&#39;s lookup table.
Definition: ASTBitCodes.h:535
clang::ObjCTypeParamTypeLoc
ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...
Definition: TypeLoc.h:748
clang::AutoTypeLoc::setNestedNameSpecifierLoc
void setNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS)
Definition: TypeLoc.h:1960
clang::ObjCObjectTypeLoc::setHasBaseTypeAsWritten
void setHasBaseTypeAsWritten(bool HasBaseType)
Definition: TypeLoc.h:998
clang::InclusionDirective
Record the location of an inclusion directive, such as an #include or #import statement.
Definition: PreprocessingRecord.h:208
clang::PCHValidator::ReadTargetOptions
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the target options.
Definition: ASTReader.cpp:442
clang::serialization::MSSTRUCT_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
Definition: ASTBitCodes.h:629
clang::InclusionDirective::InclusionKind
InclusionKind
The kind of inclusion directives known to the preprocessor.
Definition: PreprocessingRecord.h:212
clang::SourceRange::getEnd
SourceLocation getEnd() const
Definition: SourceLocation.h:217
clang::HeaderSearchOptions::ModulesValidateOncePerBuildSession
unsigned ModulesValidateOncePerBuildSession
If true, skip verifying input files used by modules if the module was already verified during this bu...
Definition: HeaderSearchOptions.h:194
clang::ObjCMethodDecl::isInstanceMethod
bool isInstanceMethod() const
Definition: DeclObjC.h:423
clang::DeclarationNameLoc::CXXOperatorName
struct CXXOpName CXXOperatorName
Definition: DeclarationName.h:678
clang::DeclarationNameLoc::CXXOpName::EndOpNameLoc
unsigned EndOpNameLoc
Definition: DeclarationName.h:664
clang::OMPAtomicDefaultMemOrderClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:1241
clang::ASTReader::ReadPendingInstantiations
void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation >> &Pending) override
Definition: ASTReader.cpp:8235
clang::TemplateTemplateParmDecl
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
Definition: DeclTemplate.h:1600
clang::ASTContext::getBuiltinVaListDecl
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
Definition: ASTContext.cpp:7832
clang::serialization::reader::HeaderFileInfoTrait
Trait class used to search the on-disk hash table containing all of the header search information...
Definition: ASTReaderInternals.h:244
clang::ASTContext::SatLongAccumTy
CanQualType SatLongAccumTy
Definition: ASTContext.h:1034
clang::ContinuousRangeMap::insertOrReplace
void insertOrReplace(const value_type &Val)
Definition: ContinuousRangeMap.h:75
clang::Sema::addMethodToGlobalList
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
Definition: SemaDeclObjC.cpp:3290
clang::Module::isAvailable
bool isAvailable() const
Determine whether this module is available for use within the current translation unit...
Definition: Module.h:385
clang::OMPPrivateClause::CreateEmpty
static OMPPrivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:338
clang::OMPCollapseClause
This represents &#39;collapse&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:800
clang::OMPFirstprivateClause
This represents clause &#39;firstprivate&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:1991
OMPIsDevicePtrClause::CreateEmpty
static OMPIsDevicePtrClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
Definition: OpenMPClause.cpp:1151
ASTConsumer.h
clang::ASTReader::StartedDeserializing
void StartedDeserializing() override
Notify ASTReader that we started deserialization of a decl or type so until FinishedDeserializing is ...
Definition: ASTReader.cpp:11355
clang::FieldDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:4094
clang::ObjCMethodDecl::getSelector
Selector getSelector() const
Definition: DeclObjC.h:322
clang::Module::Header
Information about a header directive as found in the module map file.
Definition: Module.h:157
clang::ObjCSubstitutionContext::Result
The result type of a method or function.
clang::UnaryTransformTypeLoc::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1900
clang::serialization::ModuleFile::SLocEntryBaseOffset
unsigned SLocEntryBaseOffset
The base offset in the source manager&#39;s view of this module.
Definition: ModuleFile.h:253
clang::serialization::IDENTIFIER_OFFSET
Record code for the table of offsets of each identifier ID.
Definition: ASTBitCodes.h:425
clang::DependentNameTypeLoc::setQualifierLoc
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
Definition: TypeLoc.h:2164
clang::ExternalASTSource::getMemoryBufferSizes
MemoryBufferSizes getMemoryBufferSizes() const
Return the amount of memory used by memory buffers, breaking down by heap-backed versus mmap&#39;ed memor...
Definition: ExternalASTSource.h:319
clang::QualType::isNull
bool isNull() const
Return true if this QualType doesn&#39;t point to a type yet.
Definition: Type.h:719
clang::NestedNameSpecifier::TypeSpec
A type, stored as a Type*.
Definition: NestedNameSpecifier.h:88
clang::serialization::UNDEFINED_BUT_USED
Record code for undefined but used functions and variables that need a definition in this TU...
Definition: ASTBitCodes.h:612
SM
const SourceManager & SM
Definition: Format.cpp:1685
clang::ModuleFileExtensionMetadata::MajorVersion
unsigned MajorVersion
The major version of the extension data.
Definition: ModuleFileExtension.h:42
clang::StaticAssertDecl::getAssertExpr
Expr * getAssertExpr()
Definition: DeclCXX.h:3786
clang::serialization::reader::ASTSelectorLookupTrait::data_type::Factory
SmallVector< ObjCMethodDecl *, 2 > Factory
Definition: ASTReaderInternals.h:203
clang::ASTDeserializationListener
Definition: ASTDeserializationListener.h:30
OpenMPClause.h
This file defines OpenMP AST classes for clauses.
clang::ASTContext::SignedCharTy
CanQualType SignedCharTy
Definition: ASTContext.h:1025
clang::TemplateParameterList::Create
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl *> Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Definition: DeclTemplate.cpp:90
clang::TemplateTemplateParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Definition: DeclTemplate.h:1731
SerializationDiagnostic.h
clang::VectorTypeLoc
Definition: TypeLoc.h:1751
clang::OMPClauseWithPreInit::setPreInitStmt
void setPreInitStmt(Stmt *S, OpenMPDirectiveKind ThisRegion=llvm::omp::OMPD_unknown)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:124
clang::serialization::IDENTIFIER_TABLE
Record code for the identifier table.
Definition: ASTBitCodes.h:444
clang::serialization::PREDEF_TYPE_SAT_ULONG_ACCUM_ID
The &#39;_Sat unsigned long _Accum&#39; type.
Definition: ASTBitCodes.h:996
readAPFloatSemantics
static const llvm::fltSemantics & readAPFloatSemantics(ASTRecordReader &reader)
Definition: ASTReader.cpp:8832
clang::ASTReader::Missing
The AST file was missing.
Definition: ASTReader.h:374
clang::HeaderSearchOptions::BuildSessionTimestamp
uint64_t BuildSessionTimestamp
The time in seconds when the build session started.
Definition: HeaderSearchOptions.h:167
clang::ModuleFileExtensionMetadata::MinorVersion
unsigned MinorVersion
The minor version of the extension data.
Definition: ModuleFileExtension.h:45
clang::OMPSeqCstClause
This represents &#39;seq_cst&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Definition: OpenMPClause.h:1845
clang::LineTableInfo::AddEntry
void AddEntry(FileID FID, const std::vector< LineEntry > &Entries)
Add a new line entry that has already been encoded into the internal representation of the line table...
Definition: SourceManager.cpp:297
clang::OMPUntiedClause
This represents &#39;untied&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:1608
clang::serialization::PREDEF_TYPE_BOUND_MEMBER
The placeholder type for bound member functions.
Definition: ASTBitCodes.h:897
clang::IdentifierInfo::getBuiltinID
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Definition: IdentifierTable.h:238
clang::MacroInfo::setIsUsed
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
Definition: MacroInfo.h:152
clang::serialization::PREDEF_TYPE_AUTO_DEDUCT
The "auto" deduction type.
Definition: ASTBitCodes.h:900
clang::InMemoryModuleCache
In-memory cache for modules.
Definition: InMemoryModuleCache.h:30
clang::ASTReader::mergeDefinitionVisibility
void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef)
Note that MergedDef is a redefinition of the canonical definition Def, so Def should be visible whene...
Definition: ASTReader.cpp:4060
clang::TargetOptions::CPU
std::string CPU
If given, the name of the target CPU to generate code for.
Definition: TargetOptions.h:36
clang::MemberPointerTypeLoc::setStarLoc
void setStarLoc(SourceLocation Loc)
Definition: TypeLoc.h:1264
ModuleManager.h
clang::serialization::ModuleFile::ExtensionReaders
std::vector< std::unique_ptr< ModuleFileExtensionReader > > ExtensionReaders
The list of extension readers that are attached to this module file.
Definition: ModuleFile.h:214
clang::serialization::NUM_PREDEF_IDENT_IDS
const unsigned int NUM_PREDEF_IDENT_IDS
The number of predefined identifier IDs.
Definition: ASTBitCodes.h:137
clang::TypeofLikeTypeLoc::setTypeofLoc
void setTypeofLoc(SourceLocation Loc)
Definition: TypeLoc.h:1804
clang::getPPTransparentSanitizers
SanitizerMask getPPTransparentSanitizers()
Return the sanitizers which do not affect preprocessing.
Definition: Sanitizers.h:186
clang::serialization::PREDEF_DECL_OBJC_CLASS_ID
The Objective-C &#39;Class&#39; type.
Definition: ASTBitCodes.h:1105
clang::OMPUnifiedAddressClause
This represents &#39;unified_address&#39; clause in the &#39;#pragma omp requires&#39; directive. ...
Definition: OpenMPClause.h:1023
clang::DependentTemplateSpecializationTypeLoc
Definition: TypeLoc.h:2202
clang::ModuleMap::findOrCreateModule
std::pair< Module *, bool > findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework, bool IsExplicit)
Find a new module or submodule, or create it if it does not already exist.
Definition: ModuleMap.cpp:795
clang::OMPClauseWithPostUpdate::setPostUpdateExpr
void setPostUpdateExpr(Expr *S)
Set pre-initialization statement for the clause.
Definition: OpenMPClause.h:158
clang::serialization::SubmoduleID
uint32_t SubmoduleID
An ID number that refers to a submodule in a module file.
Definition: ASTBitCodes.h:171
clang::AS_protected
Definition: Specifiers.h:115
clang::ASTReader::makeNamesVisible
void makeNamesVisible(const HiddenNames &Names, Module *Owner)
Make the names within this set of hidden names visible.
Definition: ASTReader.cpp:3997
clang::serialization::PREDEF_TYPE_SAT_SHORT_ACCUM_ID
The &#39;_Sat short _Accum&#39; type.
Definition: ASTBitCodes.h:981
clang::ASTIdentifierIterator::Next
StringRef Next() override
Retrieve the next string in the identifier table and advances the iterator for the following string...
Definition: ASTReader.cpp:7903
clang::serialization::PREDEF_TYPE_ULONGLONG_ID
The &#39;unsigned long long&#39; type.
Definition: ASTBitCodes.h:831
clang::APValue::Union
Definition: APValue.h:133
clang::ArrayTypeLoc
Wrapper for source info for arrays.
Definition: TypeLoc.h:1484
clang::serialization::SOURCE_LOCATION_PRELOADS
Record code for the set of source location entries that need to be preloaded by the AST reader...
Definition: ASTBitCodes.h:495
clang::QualifierInfo
A struct with extended info about a syntactic name qualifier, to be used for the case of out-of-line ...
Definition: Decl.h:644
clang::ASTContext::OverloadTy
CanQualType OverloadTy
Definition: ASTContext.h:1045
OMPNumTeamsClause
This represents &#39;num_teams&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5089
clang::ASTReader::Success
The control block was read successfully.
Definition: ASTReader.h:368
clang::serialization::DELEGATING_CTORS
The list of delegating constructor declarations.
Definition: ASTBitCodes.h:561
clang::SrcMgr::FileInfo
Information about a FileID, basically just the logical file that it represents and include stack info...
Definition: SourceManager.h:249
clang::serialization::PREDEF_TYPE_CHAR8_ID
The C++ &#39;char8_t&#39; type.
Definition: ASTBitCodes.h:942
clang::serialization::OPENCL_EXTENSION_TYPES
Record code for types associated with OpenCL extensions.
Definition: ASTBitCodes.h:639
readBit
static bool readBit(unsigned &Bits)
Definition: ASTReader.cpp:917
clang::MacroInfo::setIsFunctionLike
void setIsFunctionLike()
Function/Object-likeness.
Definition: MacroInfo.h:198
getTypeClassForCode
static llvm::Optional< Type::TypeClass > getTypeClassForCode(TypeCode code)
Definition: ASTReader.cpp:6322
clang::HeaderFileInfo::isModuleHeader
unsigned isModuleHeader
Whether this header is part of a module.
Definition: HeaderSearch.h:68
clang::serialization::ModuleFile::SelectorLookupTableData
const unsigned char * SelectorLookupTableData
A pointer to the character data that comprises the selector table.
Definition: ModuleFile.h:394
clang::MacroDirective
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
Definition: MacroInfo.h:290
clang::ChainedASTReaderListener::ReadFullVersionInformation
bool ReadFullVersionInformation(StringRef FullVersion) override
Receives the full Clang version information.
Definition: ASTReader.cpp:148
clang::APValue::Indeterminate
This object has an indeterminate value (C++ [basic.indet]).
Definition: APValue.h:123
false
#define false
Definition: stdbool.h:17
clang::serialization::ModuleFile::BaseTypeIndex
serialization::TypeID BaseTypeIndex
Base type ID for types local to this module as represented in the global type ID space.
Definition: ModuleFile.h:458
clang::ASTContext::BuiltinFnTy
CanQualType BuiltinFnTy
Definition: ASTContext.h:1046
clang::serialization::ModuleFile::SelectorRemap
ContinuousRangeMap< uint32_t, int, 2 > SelectorRemap
Remapping table for selector IDs in this module.
Definition: ModuleFile.h:389
ReadFixedPointSemantics
static FixedPointSemantics ReadFixedPointSemantics(const SmallVectorImpl< uint64_t > &Record, unsigned &Idx)
Definition: ASTReader.cpp:8819
Kind
Kind
Definition: ChrootChecker.cpp:29
clang::TargetOptions::ABI
std::string ABI
If given, the name of the target ABI to use.
Definition: TargetOptions.h:42
clang::Module::setASTFile
void setASTFile(const FileEntry *File)
Set the serialized AST file for the top-level module of this module.
Definition: Module.h:477
InMemoryModuleCache.h
clang::ASTReader::LoadSelector
void LoadSelector(Selector Sel)
Load a selector from disk, registering its ID if it exists.
Definition: ASTReader.cpp:8271
clang::DependentTemplateSpecializationTypeLoc::setLAngleLoc
void setLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2260
clang::FunctionProtoType::getExtProtoInfo
ExtProtoInfo getExtProtoInfo() const
Definition: Type.h:3975
clang::serialization::ModuleFile::BaseIdentifierID
serialization::IdentID BaseIdentifierID
Base identifier ID for identifiers local to this module.
Definition: ModuleFile.h:278
clang::ASTReader::ReadMacroRecord
MacroInfo * ReadMacroRecord(ModuleFile &F, uint64_t Offset)
Reads the macro record located at the given offset.
Definition: ASTReader.cpp:1675
clang::ASTReader::ReadKnownNamespaces
void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl *> &Namespaces) override
Load the set of namespaces that are known to the external source, which will be used during typo corr...
Definition: ASTReader.cpp:8095
clang::serialization::MK_Preamble
File is a PCH file treated as the preamble.
Definition: ModuleFile.h:53
clang::serialization::ModuleFile::getTimestampFilename
std::string getTimestampFilename() const
Definition: ModuleFile.h:130
OMPMappableExprListClause::getTotalComponentListNum
unsigned getTotalComponentListNum() const
Return the number of lists derived from the clause expressions.
Definition: OpenMPClause.h:4585
llvm::IntrusiveRefCntPtr
Definition: LLVM.h:44
clang::serialization::LocalDeclID
DeclID LocalDeclID
Definition: ASTBitCodes.h:72
moveMethodToBackOfGlobalList
static void moveMethodToBackOfGlobalList(Sema &S, ObjCMethodDecl *Method)
Move the given method to the back of the global list of methods.
Definition: ASTReader.cpp:3969
clang::NestedNameSpecifierLocBuilder::MakeSuper
void MakeSuper(ASTContext &Context, CXXRecordDecl *RD, SourceLocation SuperLoc, SourceLocation ColonColonLoc)
Turns this (empty) nested-name-specifier into &#39;__super&#39; nested-name-specifier.
Definition: NestedNameSpecifier.cpp:628
clang::serialization::PREDEF_TYPE_SAT_UFRACT_ID
The &#39;_Sat unsigned _Fract&#39; type.
Definition: ASTBitCodes.h:1011
clang::TemplateTypeParmDecl::isParameterPack
bool isParameterPack() const
Returns whether this is a parameter pack.
Definition: DeclTemplate.cpp:650
clang::SourceLocation
Encodes a location in the source.
Definition: SourceLocation.h:86
clang::HeaderSearchOptions::UseStandardSystemIncludes
unsigned UseStandardSystemIncludes
Include the system standard include search directories.
Definition: HeaderSearchOptions.h:180
clang::ASTContext::getUInt128Decl
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
Definition: ASTContext.cpp:1305
clang::DeclarationName::CXXConstructorName
Definition: DeclarationName.h:206
clang::FunctionDecl::isPure
bool isPure() const
Whether this virtual function is pure, i.e.
Definition: Decl.h:2105
checkHeaderSearchOptions
static bool checkHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, StringRef ExistingModuleCachePath, DiagnosticsEngine *Diags, const LangOptions &LangOpts)
Check the header search options deserialized from the control block against the header search options...
Definition: ASTReader.cpp:777
OMPHintClause
This represents &#39;hint&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5488
clang::DeclarationName::Identifier
Definition: DeclarationName.h:203
APSInt
llvm::APSInt APSInt
Definition: ByteCodeEmitter.cpp:18
clang::FileEntry::getName
StringRef getName() const
Definition: FileManager.h:102
clang::APValue::Array
Definition: APValue.h:131
clang::ASTContext::UnsignedLongAccumTy
CanQualType UnsignedLongAccumTy
Definition: ASTContext.h:1031
clang::serialization::DECL_CONTEXT_VISIBLE
A record that stores the set of declarations that are visible from a given DeclContext.
Definition: ASTBitCodes.h:1263
clang::serialization::MK_PCH
File is a PCH file treated as such.
Definition: ModuleFile.h:50
clang::OMPAllocatorClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:295
clang::ASTContext::Int128Ty
CanQualType Int128Ty
Definition: ASTContext.h:1025
clang::ASTReader::get
IdentifierInfo * get(StringRef Name) override
Retrieve the IdentifierInfo for the named identifier.
Definition: ASTReader.cpp:7831
clang::Token::setLength
void setLength(unsigned Len)
Definition: Token.h:135
clang::serialization::SUBMODULE_LINK_LIBRARY
Specifies a library or framework to link against.
Definition: ASTBitCodes.h:758
clang::serialization::MODULAR_CODEGEN_DECLS
Definition: ASTBitCodes.h:644
clang::serialization::ORIGINAL_FILE_ID
Record code for file ID of the file or buffer that was used to generate the AST file.
Definition: ASTBitCodes.h:319
clang::CXXTemporary
Represents a C++ temporary.
Definition: ExprCXX.h:1341
clang::ObjCInterfaceType
Interfaces are the core concept in Objective-C for object oriented design.
Definition: Type.h:5894
clang::ASTReader::InitializeContext
void InitializeContext()
Initializes the ASTContext.
Definition: ASTReader.cpp:4812
clang::serialization::SUBMODULE_HEADER
Specifies a header that falls into this (sub)module.
Definition: ASTBitCodes.h:734
clang::serialization::GlobalDeclID
DeclID GlobalDeclID
Definition: ASTBitCodes.h:73
PreprocessorOptions.h
clang::PreprocessorOptions::ImplicitPCHInclude
std::string ImplicitPCHInclude
The implicit PCH included at the start of the translation unit, or empty.
Definition: PreprocessorOptions.h:77
clang::Module::ExportAsModule
std::string ExportAsModule
The module through which entities defined in this module will eventually be exposed, for use in "private" modules.
Definition: Module.h:114
clang::OMPClauseReader
Definition: ASTReader.cpp:11499
clang::serialization::ModuleFile::SubmoduleRemap
ContinuousRangeMap< uint32_t, int, 2 > SubmoduleRemap
Remapping table for submodule IDs in this module.
Definition: ModuleFile.h:372
clang::WeakInfo::setUsed
void setUsed(bool Used=true)
Definition: Weak.h:35
clang::ContinuousRangeMap< serialization::DeclID, ModuleFile *, 4 >::const_iterator
typename Representation::const_iterator const_iterator
Definition: ContinuousRangeMap.h:86
clang::serialization::CUDA_SPECIAL_DECL_REFS
Record code for special CUDA declarations.
Definition: ASTBitCodes.h:549
clang::DiagnosticOptions
Options for controlling the compiler diagnostics engine.
Definition: DiagnosticOptions.h:63
clang::serialization::INTERESTING_IDENTIFIERS
A list of "interesting" identifiers.
Definition: ASTBitCodes.h:608
clang::Module::NameVisibility
NameVisibilityKind NameVisibility
The visibility of names within this particular module.
Definition: Module.h:281
OMPMappableExprListSizeTy
This structure contains all sizes needed for by an OMPMappableExprListClause.
Definition: OpenMPClause.h:4292
clang::ASTIdentifierIterator
An identifier-lookup iterator that enumerates all of the identifiers stored within a set of AST files...
Definition: ASTReader.cpp:7870
clang::ObjCTypeParamTypeLoc::setProtocolLAngleLoc
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:774
clang::serialization::OPTIONS_BLOCK_ID
The block of configuration options, used to check that a module is being used in a configuration comp...
Definition: ASTBitCodes.h:287
clang::ASTContext::SatFractTy
CanQualType SatFractTy
Definition: ASTContext.h:1037
clang::DeclarationNameInfo::getName
DeclarationName getName() const
getName - Returns the embedded declaration name.
Definition: DeclarationName.h:713
clang::TagDecl
Represents the declaration of a struct/union/class/enum.
Definition: Decl.h:3219
clang::OMPScheduleClause
This represents &#39;schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:1281
clang::serialization::PredefinedTypeIDs
PredefinedTypeIDs
Predefined type IDs.
Definition: ASTBitCodes.h:805
clang::Module::Hidden
All of the names in this module are hidden.
Definition: Module.h:275
clang::serialization::MK_ImplicitModule
File is an implicitly-loaded module.
Definition: ModuleFile.h:44
clang::OMPNumThreadsClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:632
clang::serialization::ReadMethodPoolVisitor::getInstanceBits
unsigned getInstanceBits() const
Definition: ASTReader.cpp:8032
clang::OMPSharedClause
This represents clause &#39;shared&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:2370
clang::ObjCObjectTypeLoc::setProtocolRAngleLoc
void setProtocolRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:966
clang::DeclarationNameLoc::NamedType
struct NT NamedType
Definition: DeclarationName.h:677
clang::serialization::PREDEF_TYPE_UCHAR_ID
The &#39;unsigned char&#39; type.
Definition: ASTBitCodes.h:819
clang::FileEntry
Cached information about one file (either on disk or in the virtual file system). ...
Definition: FileManager.h:78
clang::FieldDecl::getInClassInitializer
Expr * getInClassInitializer() const
Get the C++11 default member initializer for this member, or null if one has not been set...
Definition: Decl.h:2876
clang::serialization::ModuleFile::isModule
bool isModule() const
Is this a module file for a module (rather than a PCH or similar).
Definition: ModuleFile.h:479
clang::ASTContext::getObjCProtocolDecl
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
Definition: ASTContext.cpp:7484
clang::serialization::EXTENSION_METADATA
Metadata describing this particular extension.
Definition: ASTBitCodes.h:375
llvm::SmallSetVector
Definition: ExternalSemaSource.h:23
clang::ChainedASTReaderListener::ReadPreprocessorOptions
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:204
clang::MacroInfo::setIsC99Varargs
void setIsC99Varargs()
Varargs querying methods. This can only be set for function-like macros.
Definition: MacroInfo.h:203
clang::ASTReader::getMacro
MacroInfo * getMacro(serialization::MacroID ID)
Retrieve the macro with the given ID.
Definition: ASTReader.cpp:8387
clang::serialization::ModuleFile::SizeInBits
uint64_t SizeInBits
The size of this file, in bits.
Definition: ModuleFile.h:184
clang::ProcessWarningOptions
void ProcessWarningOptions(DiagnosticsEngine &Diags, const DiagnosticOptions &Opts, bool ReportDiags=true)
ProcessWarningOptions - Initialize the diagnostic client and process the warning options specified on...
Definition: Warnings.cpp:43
clang::serialization::PREDEF_TYPE_LONG_ID
The (signed) &#39;long&#39; type.
Definition: ASTBitCodes.h:849
DeclarationName.h
clang::CXXMethodDecl
Represents a static or instance method of a struct/union/class.
Definition: DeclCXX.h:1931
clang::ASTRecordReader::readAttr
Attr * readAttr()
Reads one attribute from the current stream position, advancing Idx.
Definition: ASTReaderDecl.cpp:2753
clang::serialization::ModuleManager::rbegin
ModuleReverseIterator rbegin()
Reverse iterator to traverse all loaded modules.
Definition: ModuleManager.h:160
clang::AS_public
Definition: Specifiers.h:114
clang::serialization::DECL_OFFSET
Record code for the offsets of each decl.
Definition: ASTBitCodes.h:417
clang::FriendDecl::getFriendLoc
SourceLocation getFriendLoc() const
Retrieves the location of the &#39;friend&#39; keyword.
Definition: DeclFriend.h:143
clang::ContinuousRangeMap::end
iterator end()
Definition: ContinuousRangeMap.h:89
clang::Token::setIdentifierInfo
void setIdentifierInfo(IdentifierInfo *II)
Definition: Token.h:188
GlobalModuleIndex.h
clang::ASTReader::ReadMethodPool
void ReadMethodPool(Selector Sel) override
Load the contents of the global method pool for a given selector.
Definition: ASTReader.cpp:8053
clang::serialization::ModuleFile::SelectorLookupTable
void * SelectorLookupTable
A pointer to an on-disk hash table of opaque type ASTSelectorLookupTable.
Definition: ModuleFile.h:401
clang::serialization::SUBMODULE_METADATA
Metadata for submodules as a whole.
Definition: ASTBitCodes.h:723
OMPMappableExprListClause::setMapperQualifierLoc
void setMapperQualifierLoc(NestedNameSpecifierLoc NNSL)
Set the nested name specifier of associated user-defined mapper.
Definition: OpenMPClause.h:4545
clang::SourceManager::getFileLoc
SourceLocation getFileLoc(SourceLocation Loc) const
Given Loc, if it is a macro location return the expansion location or the spelling location...
Definition: SourceManager.h:1169
clang::serialization::CTOR_INITIALIZER_BASE
Definition: ASTBitCodes.h:1896
clang::GlobalModuleIndex::readIndex
static std::pair< GlobalModuleIndex *, llvm::Error > readIndex(llvm::StringRef Path)
Read a global index file for the given directory.
Definition: GlobalModuleIndex.cpp:253
clang::serialization::ModuleFile::IdentifierOffsets
const uint32_t * IdentifierOffsets
Offsets into the identifier table data.
Definition: ModuleFile.h:275
clang::serialization::reader::ASTDeclContextNameLookupTrait::data_type_builder
Definition: ASTReaderInternals.h:55
clang::serialization::reader::ASTSelectorLookupTrait
Class that performs lookup for a selector&#39;s entries in the global method pool stored in an AST file...
Definition: ASTReaderInternals.h:191
clang::getClangFullRepositoryVersion
std::string getClangFullRepositoryVersion()
Retrieves the full repository version that is an amalgamation of the information in getClangRepositor...
Definition: Version.cpp:89
clang::serialization::LATE_PARSED_TEMPLATE
Record code for late parsed template functions.
Definition: ASTBitCodes.h:615
clang::ASTContext::FloatTy
CanQualType FloatTy
Definition: ASTContext.h:1028
clang::Module::Header::Entry
const FileEntry * Entry
Definition: Module.h:159
clang::ObjCObjectTypeLoc
Definition: TypeLoc.h:908
clang::serialization::PREDEF_TYPE_SHORT_ID
The (signed) &#39;short&#39; type.
Definition: ASTBitCodes.h:843
TargetOptions.h
Defines the clang::TargetOptions class.
clang::NestedNameSpecifierLocBuilder::MakeGlobal
void MakeGlobal(ASTContext &Context, SourceLocation ColonColonLoc)
Turn this (empty) nested-name-specifier into the global nested-name-specifier &#39;::&#39;.
Definition: NestedNameSpecifier.cpp:619
clang::FunctionDecl::getParamDecl
const ParmVarDecl * getParamDecl(unsigned i) const
Definition: Decl.h:2422
clang::MacroInfo::setDefinitionEndLoc
void setDefinitionEndLoc(SourceLocation EndLoc)
Set the location of the last token in the macro.
Definition: MacroInfo.h:126
clang::TagDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:4137
clang::IdentifierInfo::isPoisoned
bool isPoisoned() const
Return true if this token has been poisoned.
Definition: IdentifierTable.h:290
clang::ASTReaderListener::ReadFullVersionInformation
virtual bool ReadFullVersionInformation(StringRef FullVersion)
Receives the full Clang version information.
Definition: ASTReader.h:120
clang::ASTContext::SatUnsignedLongAccumTy
CanQualType SatUnsignedLongAccumTy
Definition: ASTContext.h:1035
clang::OMPLastprivateClause::setPrivateCopies
void setPrivateCopies(ArrayRef< Expr *> PrivateCopies)
Set list of helper expressions, required for generation of private copies of original lastprivate var...
Definition: OpenMPClause.cpp:377
clang::TargetOptions::Features
std::vector< std::string > Features
The list of target specific features to enable or disable – this should be a list of strings startin...
Definition: TargetOptions.h:55
clang::serialization::PREDEF_TYPE_SAT_ACCUM_ID
The &#39;_Sat _Accum&#39; type.
Definition: ASTBitCodes.h:984
clang::serialization::ModuleFile::LocalNumDecls
unsigned LocalNumDecls
The number of declarations in this AST file.
Definition: ModuleFile.h:411
clang::DiagnosticMapping::setUpgradedFromWarning
void setUpgradedFromWarning(bool Value)
Definition: DiagnosticIDs.h:140
clang::OMPClause
This is a basic class for representing single OpenMP clause.
Definition: OpenMPClause.h:51
clang::serialization::ModuleFile::NumFileSortedDecls
unsigned NumFileSortedDecls
Definition: ModuleFile.h:434
clang::serialization::reader::ASTSelectorLookupTrait::data_type::ID
SelectorID ID
Definition: ASTReaderInternals.h:197
clang::ASTReader::ReadSkippedRange
SourceRange ReadSkippedRange(unsigned Index) override
Read a preallocated skipped range from the external source.
Definition: ASTReader.cpp:5878
clang::DeclContext::hasExternalLexicalStorage
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition: DeclBase.h:2348
clang::serialization::PREDEF_DECL_OBJC_INSTANCETYPE_ID
The internal &#39;instancetype&#39; typedef.
Definition: ASTBitCodes.h:1117
clang::ASTContext::VoidTy
CanQualType VoidTy
Definition: ASTContext.h:1016
clang::EnumDecl::isScoped
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
Definition: Decl.h:3675
clang::serialization::OptionsRecordTypes
OptionsRecordTypes
Record types that occur within the options block inside the control block.
Definition: ASTBitCodes.h:338
clang::tok::TokenKind
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:24
PragmaKinds.h
clang::StringLiteral::getBeginLoc
SourceLocation getBeginLoc() const LLVM_READONLY
Definition: Expr.h:1886
clang::SanitizerMask
Definition: Sanitizers.h:29
clang::APValue::Float
Definition: APValue.h:125
clang::TemplateTemplateParmDecl::hasDefaultArgument
bool hasDefaultArgument() const
Determine whether this template parameter has a default argument.
Definition: DeclTemplate.h:1718
clang::ASTContext::Float16Ty
CanQualType Float16Ty
Definition: ASTContext.h:1041
clang::serialization::ObjCCategoriesInfo
Describes the categories of an Objective-C class.
Definition: ASTBitCodes.h:1932
llvm::SmallVector
Definition: LLVM.h:35
clang::ASTReader::isDeclIDFromModule
bool isDeclIDFromModule(serialization::GlobalDeclID ID, ModuleFile &M) const
Returns true if global DeclID ID originated from module M.
Definition: ASTReader.cpp:7204
clang::ASTContext::SatLongFractTy
CanQualType SatLongFractTy
Definition: ASTContext.h:1037
clang::TemplateParameterList::size
unsigned size() const
Definition: DeclTemplate.h:129
Module.h
Defines the clang::Module class, which describes a module in the source code.
clang::serialization::AST_BLOCK_ID
The AST block, which acts as a container around the full AST block.
Definition: ASTBitCodes.h:248
clang::serialization::ReadMethodPoolVisitor::getFactoryMethods
ArrayRef< ObjCMethodDecl * > getFactoryMethods() const
Retrieve the instance methods found by this visitor.
Definition: ASTReader.cpp:8028
clang::OMPVarListClause::setVarRefs
void setVarRefs(ArrayRef< Expr *> VL)
Sets the list of variables for this clause.
Definition: OpenMPClause.h:216
clang::serialization::reader::ASTIdentifierLookupTrait::ReadIdentifierID
IdentID ReadIdentifierID(const unsigned char *d)
Definition: ASTReader.cpp:923
clang::DependentTemplateSpecializationTypeLoc::setElaboratedKeywordLoc
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2212
clang::Decl::isFromASTFile
bool isFromASTFile() const
Determine whether this declaration came from an AST file (such as a precompiled header or module) rat...
Definition: DeclBase.h:702
clang::serialization::TypeID
uint32_t TypeID
An ID number that refers to a type in an AST file.
Definition: ASTBitCodes.h:85
UnresolvedSet.h
clang::FunctionProtoTypeLoc
Definition: TypeLoc.h:1466
clang::BuiltinTypeLoc::setWrittenTypeSpec
void setWrittenTypeSpec(TypeSpecifierType written)
Definition: TypeLoc.h:640
clang::serialization::SPECIAL_TYPE_OBJC_SEL_REDEFINITION
Objective-C "SEL" redefinition type.
Definition: ASTBitCodes.h:1076
clang::TargetOptions::FeaturesAsWritten
std::vector< std::string > FeaturesAsWritten
The list of target specific features to enable or disable, as written on the command line...
Definition: TargetOptions.h:51
clang::serialization::PREDEF_TYPE_EVENT_ID
OpenCL event type.
Definition: ASTBitCodes.h:918
clang::serialization::PREDEF_TYPE_VOID_ID
The void type.
Definition: ASTBitCodes.h:810
clang::FunctionDecl::getODRHash
unsigned getODRHash()
Returns ODRHash of the function.
Definition: Decl.cpp:3985
clang::LValueReferenceTypeLoc::setAmpLoc
void setAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1324
clang::serialization::UnhashedControlBlockRecordTypes
UnhashedControlBlockRecordTypes
Record codes for the unhashed control block.
Definition: ASTBitCodes.h:361
clang::serialization::ModuleFile::ImportedBy
llvm::SetVector< ModuleFile * > ImportedBy
List of modules which depend on this module.
Definition: ModuleFile.h:469
clang::ExternalASTSource::ExtKind
ExtKind
Definition: ExternalASTSource.h:196
clang::ArrayTypeLoc::setLBracketLoc
void setLBracketLoc(SourceLocation Loc)
Definition: TypeLoc.h:1493
clang::APValue::AddrLabelDiff
Definition: APValue.h:135
Weak.h
clang::serialization::ModuleFile::dump
void dump()
Dump debugging output for this module.
Definition: ModuleFile.cpp:47
checkLanguageOptions
static bool checkLanguageOptions(const LangOptions &LangOpts, const LangOptions &ExistingLangOpts, DiagnosticsEngine *Diags, bool AllowCompatibleDifferences=true)
Compare the given set of language options against an existing set of language options.
Definition: ASTReader.cpp:270
clang::ASTReader::SetGloballyVisibleDecls
void SetGloballyVisibleDecls(IdentifierInfo *II, const SmallVectorImpl< uint32_t > &DeclIDs, SmallVectorImpl< Decl *> *Decls=nullptr)
Set the globally-visible declarations associated with the given identifier.
Definition: ASTReader.cpp:8301
clang::serialization::ModuleFile::FileSortedDecls
const serialization::DeclID * FileSortedDecls
Array of file-level DeclIDs sorted by file.
Definition: ModuleFile.h:433
clang::LangOptions::PragmaMSPointersToMembersKind
PragmaMSPointersToMembersKind
Definition: LangOptions.h:91
clang::serialization::STATISTICS
Record code for the extra statistics we gather while generating an AST file.
Definition: ASTBitCodes.h:467
getPredefinedDecl
static Decl * getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID)
Definition: ASTReader.cpp:7241
clang::VarDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:2020
clang::FunctionDecl::isExplicitlyDefaulted
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
Definition: Decl.h:2135
clang::StaticAssertDecl
Represents a C++11 static_assert declaration.
Definition: DeclCXX.h:3763
checkDiagnosticGroupMappings
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool Complain)
Definition: ASTReader.cpp:459
clang::ASTReaderListener::visitImport
virtual void visitImport(StringRef ModuleName, StringRef Filename)
If needsImportVisitation returns true, this is called for each AST file imported by this AST file...
Definition: ASTReader.h:221
clang::serialization::ModuleFile::InputFilesLoaded
std::vector< InputFile > InputFilesLoaded
The input files that have been loaded from this AST file.
Definition: ModuleFile.h:229
clang::ASTContext::SatUnsignedFractTy
CanQualType SatUnsignedFractTy
Definition: ASTContext.h:1038
clang::PreprocessorOptions::PCHThroughHeader
std::string PCHThroughHeader
If non-empty, the filename used in an #include directive in the primary source file (or command-line ...
Definition: PreprocessorOptions.h:74
clang::serialization::PreprocessedEntityID
uint32_t PreprocessedEntityID
An ID number that refers to an entity in the detailed preprocessing record.
Definition: ASTBitCodes.h:168
clang::serialization::ModuleManager::NewlyLoaded
The module file was just loaded in response to this call.
Definition: ModuleManager.h:203
clang::serialization::PREDEF_TYPE_SCHAR_ID
The &#39;signed char&#39; type.
Definition: ASTBitCodes.h:837
clang::serialization::ModuleFile::LocalNumSubmodules
unsigned LocalNumSubmodules
The number of submodules in this module.
Definition: ModuleFile.h:366
clang::serialization::ComputeHash
unsigned ComputeHash(Selector Sel)
Definition: ASTCommon.cpp:251
clang::ASTReader::ConfigurationMismatch
The AST file was writtten with a different language/target configuration.
Definition: ASTReader.h:385
clang::OMPClauseReader::VisitOMPClauseWithPreInit
void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C)
Definition: ASTReader.cpp:11734
clang::ASTContext::SatUnsignedShortFractTy
CanQualType SatUnsignedShortFractTy
Definition: ASTContext.h:1038
clang::ASTReader::getGlobalSelectorID
serialization::SelectorID getGlobalSelectorID(ModuleFile &F, unsigned LocalID) const
Retrieve the global selector ID that corresponds to this the local selector ID in a given module...
Definition: ASTReader.cpp:8560
clang::LValueReferenceTypeLoc
Definition: TypeLoc.h:1315
clang::serialization::ModuleFile::HeaderFileInfoTableData
const char * HeaderFileInfoTableData
Actual data for the on-disk hash table of header file information.
Definition: ModuleFile.h:357
clang::ASTReader::markIdentifierUpToDate
void markIdentifierUpToDate(IdentifierInfo *II)
Note that this identifier is up-to-date.
Definition: ASTReader.cpp:2083
clang::serialization::ModuleFile::InputFileOffsets
const llvm::support::unaligned_uint64_t * InputFileOffsets
Offsets for all of the input file entries in the AST file.
Definition: ModuleFile.h:226
clang::TemplateArgumentListInfo::addArgument
void addArgument(const TemplateArgumentLoc &Loc)
Definition: TemplateBase.h:594
clang::serialization::SIGNATURE
Record code for the signature that identifiers this AST file.
Definition: ASTBitCodes.h:363
clang::ModuleMap::addHeader
void addHeader(Module *Mod, Module::Header Header, ModuleHeaderRole Role, bool Imported=false)
Adds this header to the given module.
Definition: ModuleMap.cpp:1184
clang::serialization::MK_MainFile
File is a PCH file treated as the actual main file.
Definition: ModuleFile.h:56
clang::serialization::REFERENCED_SELECTOR_POOL
Record code for referenced selector pool.
Definition: ASTBitCodes.h:513
clang::MultiVersionKind::None
clang::serialization::InputFile
The input file that has been loaded from this AST file, along with bools indicating whether this was ...
Definition: ModuleFile.h:65
clang::ODRHash::AddSubDecl
void AddSubDecl(const Decl *D)
Definition: ODRHash.cpp:466
clang::PreprocessorOptions::MacroIncludes
std::vector< std::string > MacroIncludes
Definition: PreprocessorOptions.h:49
clang::DecayedType
Represents a pointer type decayed from an array or function type.
Definition: Type.h:2699
clang::ASTContext::SatAccumTy
CanQualType SatAccumTy
Definition: ASTContext.h:1034
clang::ASTReader::getLocalModuleFile
ModuleFile * getLocalModuleFile(ModuleFile &M, unsigned ID)
Retrieve the module file with a given local ID within the specified ModuleFile.
Definition: ASTReader.cpp:8466
clang::ExternalASTSource::MemoryBufferSizes
Definition: ExternalASTSource.h:309
clang::serialization::SPECIAL_TYPES
Record code for the set of non-builtin, special types.
Definition: ASTBitCodes.h:463
Specifiers.h
Defines various enumerations that describe declaration and type specifiers.
clang::DeclarationNameLoc
DeclarationNameLoc - Additional source/type location info for a declaration name. ...
Definition: DeclarationName.h:650
clang::FunctionTypeLoc::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1390
clang::ASTContext::Allocate
void * Allocate(size_t Size, unsigned Align=8) const
Definition: ASTContext.h:686
clang::TemplateSpecializationTypeLoc::setTemplateKeywordLoc
void setTemplateKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:1584
clang::serialization::PPSkippedRange::getBegin
SourceLocation getBegin() const
Definition: ASTBitCodes.h:211
clang::IdentifierInfo::getName
StringRef getName() const
Return the actual identifier string.
Definition: IdentifierTable.h:155
clang::SourceManager::bypassFileContentsOverride
const FileEntry * bypassFileContentsOverride(const FileEntry &File)
Bypass the overridden contents of a file.
Definition: SourceManager.cpp:683
NestedNameSpecifier.h
clang::ObjCObjectTypeLoc::setTypeArgsLAngleLoc
void setTypeArgsLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:928
clang::serialization::ModuleFile::InputFilesValidationTimestamp
uint64_t InputFilesValidationTimestamp
If non-zero, specifies the time when we last validated input files.
Definition: ModuleFile.h:239
clang::ASTContext::UnsignedShortTy
CanQualType UnsignedShortTy
Definition: ASTContext.h:1026
clang::serialization::ModuleFile::MacroOffsets
const uint32_t * MacroOffsets
Offsets of macros in the preprocessor block.
Definition: ModuleFile.h:311
clang::serialization::PREDEF_TYPE_OBJC_ID
The ObjC &#39;id&#39; type.
Definition: ASTBitCodes.h:885
clang::serialization::reader::HeaderFileInfoTrait::internal_key_type
Definition: ASTReaderInternals.h:253
clang::TypedefNameDecl
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3071
clang::serialization::ModuleFile::LocalNumSelectors
unsigned LocalNumSelectors
The number of selectors new to this file.
Definition: ModuleFile.h:379
clang::IdentifierInfo::getObjCOrBuiltinID
unsigned getObjCOrBuiltinID() const
Definition: IdentifierTable.h:250
clang::serialization::ModuleFile::PreprocessedSkippedRangeOffsets
const PPSkippedRange * PreprocessedSkippedRangeOffsets
Definition: ModuleFile.h:344
clang::FileID
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Definition: SourceLocation.h:38
clang::ASTContext::CharTy
CanQualType CharTy
Definition: ASTContext.h:1018
clang::HeaderFileInfo::ControllingMacroID
unsigned ControllingMacroID
The ID number of the controlling macro.
Definition: HeaderSearch.h:97
clang::TemplateArgument
Represents a template argument.
Definition: TemplateBase.h:50
clang::serialization::IMPORTS
Record code for the list of other AST files imported by this AST file.
Definition: ASTBitCodes.h:307
clang::ASTReader::getLocalSelector
Selector getLocalSelector(ModuleFile &M, unsigned LocalID)
Retrieve a selector from the given module with its local ID number.
Definition: ASTReader.cpp:8521
clang::serialization::INPUT_FILE_HASH
The input file content hash.
Definition: ASTBitCodes.h:388
clang::serialization::PPD_MACRO_DEFINITION
Describes a macro definition within the preprocessing record.
Definition: ASTBitCodes.h:713
clang::Module::Conflict
A conflict between two modules.
Definition: Module.h:366
clang::MemberPointerTypeLoc::setClassTInfo
void setClassTInfo(TypeSourceInfo *TI)
Definition: TypeLoc.h:1276
clang::ASTReader::ReadSLocEntry
bool ReadSLocEntry(int ID) override
Read the source location entry with index ID.
Definition: ASTReader.cpp:1417
clang::PCHValidator::ReadHeaderSearchOptions
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain) override
Receives the header search options.
Definition: ASTReader.cpp:794
clang::serialization::PREDEF_DECL_CF_CONSTANT_STRING_ID
The internal &#39;__NSConstantString&#39; typedef.
Definition: ASTBitCodes.h:1135
clang::serialization::MODULE_NAME
Record code for the module name.
Definition: ASTBitCodes.h:326
OMPPriorityClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:5278
clang::serialization::SelectorID
uint32_t SelectorID
An ID number that refers to an ObjC selector in an AST file.
Definition: ASTBitCodes.h:153
clang::Decl::redecls
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Definition: DeclBase.h:948
clang::ASTContext::ObjCBuiltinIdTy
CanQualType ObjCBuiltinIdTy
Definition: ASTContext.h:1048
clang::IdentifierInfo::hadMacroDefinition
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
Definition: IdentifierTable.h:178
Decl.h
clang::ASTReader::ResolveImportedPath
void ResolveImportedPath(ModuleFile &M, std::string &Filename)
If we are loading a relocatable PCH or module file, and the filename is not an absolute path...
Definition: ASTReader.cpp:2444
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:21
clang::DiagnosticsEngine::getDiagnosticLevel
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
Definition: Diagnostic.h:840
OMPDeviceClause
This represents &#39;device&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:4089
clang::SourceLocation::isValid
bool isValid() const
Return true if this is a valid SourceLocation object.
Definition: SourceLocation.h:106
clang::ASTReader::setDeserializationListener
void setDeserializationListener(ASTDeserializationListener *Listener, bool TakeOwnership=false)
Set the AST deserialization listener.
Definition: ASTReader.cpp:811
clang::serialization::PPD_INCLUSION_DIRECTIVE
Describes an inclusion directive within the preprocessing record.
Definition: ASTBitCodes.h:717
clang::serialization::PREDEF_DECL_BUILTIN_MS_VA_LIST_ID
The internal &#39;__builtin_ms_va_list&#39; typedef.
Definition: ASTBitCodes.h:1126
clang::serialization::ModuleFile::DeclsCursor
llvm::BitstreamCursor DeclsCursor
DeclsCursor - This is a cursor to the start of the DECLS_BLOCK block.
Definition: ModuleFile.h:408
clang::Module::IsMissingRequirement
unsigned IsMissingRequirement
Whether this module is missing a feature from Requirements.
Definition: Module.h:210
clang::TemplateArgumentLoc::getArgument
const TemplateArgument & getArgument() const
Definition: TemplateBase.h:498
clang::DeclContext
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1271
clang::serialization::PREDEF_TYPE_ACCUM_ID
The &#39;_Accum&#39; type.
Definition: ASTBitCodes.h:948
clang::serialization::FILE_SORTED_DECLS
Record code for a file sorted array of DeclIDs in a module.
Definition: ASTBitCodes.h:582
clang::RValueReferenceTypeLoc::setAmpAmpLoc
void setAmpAmpLoc(SourceLocation Loc)
Definition: TypeLoc.h:1338
clang::ASTContext::NullPtrTy
CanQualType NullPtrTy
Definition: ASTContext.h:1044
clang::serialization::OBJC_CATEGORIES
Record code for the array of Objective-C categories (including extensions).
Definition: ASTBitCodes.h:596
clang::ASTReader::updateOutOfDateIdentifier
void updateOutOfDateIdentifier(IdentifierInfo &II) override
Update an out-of-date identifier.
Definition: ASTReader.cpp:2058
clang::LazyASTUnresolvedSet::reserve
void reserve(ASTContext &C, unsigned N)
Definition: ASTUnresolvedSet.h:105
clang::serialization::SUBMODULE_CONFIG_MACRO
Specifies a configuration macro for this module.
Definition: ASTBitCodes.h:761
clang::ASTReader::ReadDefinedMacros
void ReadDefinedMacros() override
Read the set of macros defined by this external macro source.
Definition: ASTReader.cpp:1940
OMPDeviceClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:4126
getName
static std::string getName(const CallEvent &Call)
Definition: ReturnValueChecker.cpp:60
clang::ObjCImplDecl
Definition: DeclObjC.h:2439
clang::serialization::PreprocessorDetailRecordTypes
PreprocessorDetailRecordTypes
Record types used within a preprocessor detail block.
Definition: ASTBitCodes.h:708
clang::OverloadedOperatorKind
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
Definition: OperatorKinds.h:21
clang::serialization::PREDEF_TYPE_QUEUE_ID
OpenCL queue type.
Definition: ASTBitCodes.h:927
moduleKindForDiagnostic
static unsigned moduleKindForDiagnostic(ModuleKind Kind)
Definition: ASTReader.cpp:4429
clang::ChainedASTReaderListener::ReadFileSystemOptions
bool ReadFileSystemOptions(const FileSystemOptions &FSOpts, bool Complain) override
Receives the file system options.
Definition: ASTReader.cpp:189
clang::serialization::PREDEF_TYPE_FRACT_ID
The &#39;_Fract&#39; type.
Definition: ASTBitCodes.h:966
clang::ObjCRuntime
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:27
clang::PreprocessorOptions::UsePredefines
bool UsePredefines
Initialize the preprocessor with the compiler and target specific predefines.
Definition: PreprocessorOptions.h:53
clang::serialization::ModuleFile::MacroStartOffset
uint64_t MacroStartOffset
The offset of the start of the set of defined macros.
Definition: ModuleFile.h:320
clang::ASTContext::UnsignedShortAccumTy
CanQualType UnsignedShortAccumTy
Definition: ASTContext.h:1031
clang::TemplateArgument::TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
Definition: TemplateBase.h:79
clang::ASTReader::TranslateSourceLocation
SourceLocation TranslateSourceLocation(ModuleFile &ModuleFile, SourceLocation Loc) const
Translate a source location from another module file&#39;s source location space into ours...
Definition: ASTReader.h:2114
clang::serialization::UNUSED_FILESCOPED_DECLS
Record code for the array of unused file scoped decls.
Definition: ASTBitCodes.h:501
clang::FileEntry::getSize
off_t getSize() const
Definition: FileManager.h:105
llvm::SaveAndRestore
Definition: LLVM.h:41
clang::LangOptions::OMPTargetTriples
std::vector< llvm::Triple > OMPTargetTriples
Triples of the OpenMP targets that the host code codegen should take into account in order to generat...
Definition: LangOptions.h:293
clang::serialization::PREDEF_TYPE_SAT_USHORT_ACCUM_ID
The &#39;_Sat unsigned short _Accum&#39; type.
Definition: ASTBitCodes.h:990
SkipCursorToBlock
static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID)
Given a cursor at the start of an AST file, scan ahead and drop the cursor into the start of the give...
Definition: ASTReader.cpp:4120
clang::ASTReader
Reads an AST files chain containing the contents of a translation unit.
Definition: ASTReader.h:340
clang::serialization::MK_ExplicitModule
File is an explicitly-loaded module.
Definition: ModuleFile.h:47
clang::IndirectFieldDecl
Represents a field injected from an anonymous union/struct into the parent scope. ...
Definition: Decl.h:2980
clang::PCHValidator::ReadLanguageOptions
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:433
clang::ASTRecordReader::readQualType
QualType readQualType()
Definition: ASTRecordReader.h:176
clang::TypedefNameDecl::getUnderlyingType
QualType getUnderlyingType() const
Definition: Decl.h:3126
clang::ASTContext::UnsignedLongLongTy
CanQualType UnsignedLongLongTy
Definition: ASTContext.h:1027
clang::ChainedASTReaderListener::visitInputFile
bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule) override
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
Definition: ASTReader.cpp:234
clang::VarDecl::getInit
const Expr * getInit() const
Definition: Decl.h:1229
clang::Decl::getAccess
AccessSpecifier getAccess() const
Definition: DeclBase.h:473
clang::DependentSizedExtVectorTypeLoc
Definition: TypeLoc.h:1771
clang::PipeTypeLoc
Definition: TypeLoc.h:2417
clang::serialization::PREDEF_TYPE_SAT_LONG_ACCUM_ID
The &#39;_Sat long _Accum&#39; type.
Definition: ASTBitCodes.h:987
clang::ASTReader::ReadExtVectorDecls
void ReadExtVectorDecls(SmallVectorImpl< TypedefNameDecl *> &Decls) override
Read the set of ext_vector type declarations known to the external Sema source.
Definition: ASTReader.cpp:8163
clang::DeclarationName
The name of a declaration.
Definition: DeclarationName.h:145
clang::DeclGroupRef
Definition: DeclGroup.h:51
clang::serialization::METHOD_POOL
Record code for the Objective-C method pool,.
Definition: ASTBitCodes.h:479
clang::Module::ExportDecl
llvm::PointerIntPair< Module *, 1, bool > ExportDecl
Describes an exported module.
Definition: Module.h:294
clang::IdentifierInfo::isExtensionToken
bool isExtensionToken() const
get/setExtension - Initialize information about whether or not this language token is an extension...
Definition: IdentifierTable.h:256
clang::ASTReaderListener::ReadModuleMapFile
virtual void ReadModuleMapFile(StringRef ModuleMapPath)
Definition: ASTReader.h:125
clang::Decl::getKind
Kind getKind() const
Definition: DeclBase.h:432
clang::serialization::SUBMODULE_PRIVATE_HEADER
Specifies a header that is private to this submodule.
Definition: ASTBitCodes.h:767
clang::Qualifiers::FastMask
The fast qualifier mask.
Definition: Type.h:189
clang::ChainedASTReaderListener::needsInputFileVisitation
bool needsInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
Definition: ASTReader.cpp:218
clang::cast
U cast(CodeGen::Address addr)
Definition: Address.h:108
clang::APValue::ComplexFloat
Definition: APValue.h:128
clang::serialization::reader::HeaderFileInfoTrait::internal_key_type::Imported
bool Imported
Definition: ASTReaderInternals.h:257
clang::serialization::PPD_MACRO_EXPANSION
Describes a macro expansion within the preprocessing record.
Definition: ASTBitCodes.h:710
clang::OMPUnifiedSharedMemoryClause
This represents &#39;unified_shared_memory&#39; clause in the &#39;#pragma omp requires&#39; directive.
Definition: OpenMPClause.h:1065
clang::serialization::reader::ASTSelectorLookupTable
llvm::OnDiskChainedHashTable< ASTSelectorLookupTrait > ASTSelectorLookupTable
The on-disk hash table used for the global method pool.
Definition: ASTReaderInternals.h:233
clang::OMPLinearClause
This represents clause &#39;linear&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:3166
OMPNontemporalClause::CreateEmpty
static OMPNontemporalClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:1175
clang::EnumDecl
Represents an enum.
Definition: Decl.h:3481
clang::IdentifierInfo::getFETokenInfo
void * getFETokenInfo() const
Get and set FETokenInfo.
Definition: IdentifierTable.h:308
clang::serialization::CTOR_INITIALIZER_INDIRECT_MEMBER
Definition: ASTBitCodes.h:1899
clang::ASTReader::isGlobalIndexUnavailable
bool isGlobalIndexUnavailable() const
Determine whether we tried to load the global index, but failed, e.g., because it is out-of-date or d...
Definition: ASTReader.cpp:4100
clang::ASTReader::getIdentifierTable
IdentifierTable & getIdentifierTable()
Retrieve the identifier table associated with the preprocessor.
Definition: ASTReader.cpp:8934
clang::NonTypeTemplateParmDecl::getDefaultArgument
Expr * getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1465
clang::Sema::IdResolver
IdentifierResolver IdResolver
Definition: Sema.h:929
clang::DeclarationName::CXXDestructorName
Definition: DeclarationName.h:207
OMPClauseVisitor
Definition: OpenMPClause.h:6402
clang::ContinuousRangeMap
A map from continuous integer ranges to some value, with a very specialized interface.
Definition: ContinuousRangeMap.h:37
clang::DeclarationName::CXXConversionFunctionName
Definition: DeclarationName.h:208
clang::serialization::reader::ASTIdentifierLookupTrait
Class that performs lookup for an identifier stored in an AST file.
Definition: ASTReaderInternals.h:159
clang::TemplateTypeParmDecl::defaultArgumentWasInherited
bool defaultArgumentWasInherited() const
Determines whether the default argument was inherited from a previous declaration of this template...
Definition: DeclTemplate.h:1265
clang::SourceManager::setExternalSLocEntrySource
void setExternalSLocEntrySource(ExternalSLocEntrySource *Source)
Definition: SourceManager.h:1710
clang::serialization::ModuleFile::MacroRemap
ContinuousRangeMap< uint32_t, int, 2 > MacroRemap
Remapping table for macro IDs in this module.
Definition: ModuleFile.h:317
clang::DeclarationNameInfo
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Definition: DeclarationName.h:690
clang::OMPClause::setLocStart
void setLocStart(SourceLocation Loc)
Sets the starting location of the clause.
Definition: OpenMPClause.h:73
clang::NestedNameSpecifier::TypeSpecWithTemplate
A type that was preceded by the &#39;template&#39; keyword, stored as a Type*.
Definition: NestedNameSpecifier.h:92
clang::ASTRecordReader::readTypeLoc
void readTypeLoc(TypeLoc TL)
Reads the location information for a type.
Definition: ASTReader.cpp:6713
clang::ASTReader::ClearSwitchCaseIDs
void ClearSwitchCaseIDs()
Definition: ASTReader.cpp:8952
OMPMappableExprListSizeTy::NumUniqueDeclarations
unsigned NumUniqueDeclarations
Number of unique base declarations.
Definition: OpenMPClause.h:4296
clang::OMPSharedClause::CreateEmpty
static OMPSharedClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: OpenMPClause.cpp:441
clang::ModuleFileExtensionMetadata::BlockName
std::string BlockName
The name used to identify this particular extension block within the resulting module file...
Definition: ModuleFileExtension.h:39
clang::Decl::isHidden
bool isHidden() const
Determine whether this declaration might be hidden from name lookup.
Definition: DeclBase.h:774
clang::serialization::DeclID
uint32_t DeclID
An ID number that refers to a declaration in an AST file.
Definition: ASTBitCodes.h:68
clang::ASTReader::ReadLateParsedTemplates
void ReadLateParsedTemplates(llvm::MapVector< const FunctionDecl *, std::unique_ptr< LateParsedTemplate >> &LPTMap) override
Read the set of late parsed template functions for this source.
Definition: ASTReader.cpp:8247
PassObjCImplDeclToConsumer
static void PassObjCImplDeclToConsumer(ObjCImplDecl *ImplD, ASTConsumer *Consumer)
Under non-PCH compilation the consumer receives the objc methods before receiving the implementation...
Definition: ASTReader.cpp:7569
clang::serialization::PREDEF_TYPE_DEPENDENT_ID
The placeholder type for dependent types.
Definition: ASTBitCodes.h:867
clang::Module::AllVisible
All of the names in this module are visible.
Definition: Module.h:277
clang::ASTRecordReader::readInt
uint64_t readInt()
Returns the current value in this record, and advances to the next value.
Definition: ASTRecordReader.h:69
clang::FunctionTypeLoc::getNumParams
unsigned getNumParams() const
Definition: TypeLoc.h:1426
clang::AutoTypeLoc
Definition: TypeLoc.h:1942
clang::DependentNameTypeLoc::setNameLoc
void setNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2175
OMPMappableExprListClause::setComponentListSizes
void setComponentListSizes(ArrayRef< unsigned > CLSs)
Set the cumulative component lists sizes that are in the trailing objects of the class.
Definition: OpenMPClause.h:4434
clang::serialization::CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH
Number of unmatched #pragma clang cuda_force_host_device begin directives we&#39;ve seen.
Definition: ASTBitCodes.h:636
clang::ASTRecordReader::readTemplateArgumentLocInfo
TemplateArgumentLocInfo readTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind)
Reads a TemplateArgumentLocInfo appropriate for the given TemplateArgument kind, advancing Idx...
Definition: ASTReader.cpp:7008
clang::Module::ModuleMapIsPrivate
unsigned ModuleMapIsPrivate
Whether this module came from a "private" module map, found next to a regular (public) module map...
Definition: Module.h:269
clang::MacroInfo
Encapsulates the data about a macro definition (e.g.
Definition: MacroInfo.h:39
clang::ASTReader::GetExternalDecl
Decl * GetExternalDecl(uint32_t ID) override
Resolve a declaration ID into a declaration, potentially building a new declaration.
Definition: ASTReader.cpp:7060
OMPClauseMappableExprCommon::MappableComponent
Class that represents a component of a mappable expression.
Definition: OpenMPClause.h:4242
clang::DeclarationName::ObjCMultiArgSelector
Definition: DeclarationName.h:217
clang::ASTReader::getIdResolver
IdentifierResolver & getIdResolver()
Get the identifier resolver used for name lookup / updates in the translation unit scope...
Definition: ASTReader.cpp:11481
clang::serialization::reader::ASTIdentifierLookupTraitBase::ReadKeyDataLength
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
Definition: ASTReader.cpp:892
clang::FileManager::getFile
llvm::ErrorOr< const FileEntry * > getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
Definition: FileManager.cpp:195
clang::serialization::ReadMethodPoolVisitor::instanceHasMoreThanOneDecl
bool instanceHasMoreThanOneDecl() const
Definition: ASTReader.cpp:8035
clang::DeclarationNameLoc::CXXLiteralOperatorName
struct CXXLitOpName CXXLiteralOperatorName
Definition: DeclarationName.h:679
clang::ASTReaderListener
Abstract interface for callback invocations by the ASTReader.
Definition: ASTReader.h:112
clang::ModuleMap::addLinkAsDependency
void addLinkAsDependency(Module *Mod)
Make module to use export_as as the link dependency name if enough information is available or add it...
Definition: ModuleMap.cpp:69
clang::RecordType
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: Type.h:4495
clang::TemplateArgumentLoc
Location wrapper for a TemplateArgument.
Definition: TemplateBase.h:449
clang::ASTContext::getTypePackElementDecl
BuiltinTemplateDecl * getTypePackElementDecl() const
Definition: ASTContext.cpp:1266
clang::ASTRecordReader::readTemplateArgumentLoc
TemplateArgumentLoc readTemplateArgumentLoc()
Reads a TemplateArgumentLoc, advancing Idx.
Definition: ASTReader.cpp:7039
clang::serialization::SPECIAL_TYPE_SIGJMP_BUF
C sigjmp_buf typedef type.
Definition: ASTBitCodes.h:1067
TemplateBase.h
clang::ASTContext::UnknownAnyTy
CanQualType UnknownAnyTy
Definition: ASTContext.h:1045
clang::HeaderSearchOptions::ModulesValidateDiagnosticOptions
unsigned ModulesValidateDiagnosticOptions
Definition: HeaderSearchOptions.h:206
clang::serialization::PREDEF_TYPE_UFRACT_ID
The &#39;unsigned _Fract&#39; type.
Definition: ASTBitCodes.h:975
clang::Module::Conflicts
std::vector< Conflict > Conflicts
The list of conflicts.
Definition: Module.h:375
DeclFriend.h
clang::ASTReader::findPreprocessedEntitiesInRange
std::pair< unsigned, unsigned > findPreprocessedEntitiesInRange(SourceRange Range) override
Returns a pair of [Begin, End) indices of preallocated preprocessed entities that Range encompasses...
Definition: ASTReader.cpp:6099
clang::DiagnosticsEngine::Error
Definition: Diagnostic.h:157
clang::serialization::SELECTOR_OFFSETS
Record code for the table of offsets into the Objective-C method pool.
Definition: ASTBitCodes.h:476
clang::serialization::reader::ASTSelectorLookupTrait::data_type
Definition: ASTReaderInternals.h:196
FileSystemOptions.h
Defines the clang::FileSystemOptions interface.
clang::ConstantArrayTypeLoc
Definition: TypeLoc.h:1534
clang::CXXCtorInitializer
Represents a C++ base or member initializer.
Definition: DeclCXX.h:2155
clang::DependentNameTypeLoc
Definition: TypeLoc.h:2146
SLocRemap
ContinuousRangeMap< unsigned, int, 2 > SLocRemap
Definition: ASTUnit.cpp:2350
clang::ASTContext::UnsignedLongTy
CanQualType UnsignedLongTy
Definition: ASTContext.h:1026
clang::serialization::MODULE_OFFSET_MAP
Record code for the remapping information used to relate loaded modules to the various offsets and ID...
Definition: ASTBitCodes.h:571
clang::TemplateSpecializationType::getArg
const TemplateArgument & getArg(unsigned Idx) const
Retrieve a specific template argument as a type.
Definition: TemplateBase.h:694
clang::serialization::IdentID
uint32_t IdentID
An ID number that refers to an identifier in an AST file.
Definition: ASTBitCodes.h:134
clang::serialization::reader::ASTSelectorLookupTrait::data_type::InstanceHasMoreThanOneDecl
bool InstanceHasMoreThanOneDecl
Definition: ASTReaderInternals.h:200
clang::serialization::DeclarationNameKey
A key used when looking up entities by DeclarationName.
Definition: ASTBitCodes.h:1965
OMPCopyprivateClause::CreateEmpty
static OMPCopyprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with N variables.
Definition: OpenMPClause.cpp:617
clang::SelectorTable::getSelector
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
Definition: IdentifierTable.cpp:651
clang::ChainedASTReaderListener::readModuleFileExtension
void readModuleFileExtension(const ModuleFileExtensionMetadata &Metadata) override
Indicates that a particular module file extension has been read.
Definition: ASTReader.cpp:250
clang::serialization::SEMA_DECL_REFS
Record code for declarations that Sema keeps references of.
Definition: ASTBitCodes.h:522
clang::IdentifierInfo::setIsFromAST
void setIsFromAST()
Definition: IdentifierTable.h:322
clang::ExternalASTSource::MemoryBufferSizes::malloc_bytes
size_t malloc_bytes
Definition: ExternalASTSource.h:310
clang::serialization::InputFile::isOutOfDate
bool isOutOfDate() const
Definition: ModuleFile.h:96
clang::ASTContext::DependentTy
CanQualType DependentTy
Definition: ASTContext.h:1045
clang::DeducedTemplateSpecializationTypeLoc::setTemplateNameLoc
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:2075
clang::serialization::ModuleFile::HeaderFileInfoTable
void * HeaderFileInfoTable
The on-disk hash table that contains information about each of the header files.
Definition: ModuleFile.h:361
clang::APValue::Vector
Definition: APValue.h:130
clang::ASTContext::WCharTy
CanQualType WCharTy
Definition: ASTContext.h:1019
clang::serialization::NUM_PREDEF_MACRO_IDS
const unsigned int NUM_PREDEF_MACRO_IDS
The number of predefined macro IDs.
Definition: ASTBitCodes.h:150
clang::ASTReader::visitTopLevelModuleMaps
void visitTopLevelModuleMaps(serialization::ModuleFile &MF, llvm::function_ref< void(const FileEntry *)> Visitor)
Visit all the top-level module maps loaded when building the given module file.
Definition: ASTReader.cpp:9043
clang::ObjCMethodDecl::hasBody
bool hasBody() const override
Determine whether this method has a body.
Definition: DeclObjC.h:516
clang::serialization::INPUT_FILE_OFFSETS
Offsets into the input-files block where input files reside.
Definition: ASTBitCodes.h:323
clang::serialization::reader::ASTSelectorLookupTrait::data_type::FactoryHasMoreThanOneDecl
bool FactoryHasMoreThanOneDecl
Definition: ASTReaderInternals.h:201
clang::ChainedASTReaderListener::ReadLanguageOptions
bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain, bool AllowCompatibleDifferences) override
Receives the language options.
Definition: ASTReader.cpp:164
clang::ASTContext::ObjCBuiltinClassTy
CanQualType ObjCBuiltinClassTy
Definition: ASTContext.h:1048
OMPMappableExprListClause::setUDMapperRefs
void setUDMapperRefs(ArrayRef< Expr *> DMDs)
Set the user-defined mappers that are in the trailing objects of the class.
Definition: OpenMPClause.h:4574
clang::Decl::getGlobalID
unsigned getGlobalID() const
Retrieve the global declaration ID associated with this declaration, which specifies where this Decl ...
Definition: DeclBase.h:706
clang::serialization::reader::ASTSelectorLookupTrait::ReadKeyDataLength
static std::pair< unsigned, unsigned > ReadKeyDataLength(const unsigned char *&d)
Definition: ASTReader.cpp:822
clang::DeclContext::getRedeclContext
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
Definition: DeclBase.cpp:1747
clang::serialization::PreprocessorRecordTypes
PreprocessorRecordTypes
Record types used within a preprocessor block.
Definition: ASTBitCodes.h:682
isExtHandlingFromDiagsError
static bool isExtHandlingFromDiagsError(DiagnosticsEngine &Diags)
Definition: ASTReader.cpp:489
clang::ASTContext::BoundMemberTy
CanQualType BoundMemberTy
Definition: ASTContext.h:1045
clang::serialization::PPSkippedRange::getEnd
SourceLocation getEnd() const
Definition: ASTBitCodes.h:214
clang::ContinuousRangeMap::find
iterator find(Int K)
Definition: ContinuousRangeMap.h:93
clang::serialization::SUBMODULE_BLOCK_ID
The block containing the submodule structure.
Definition: ASTBitCodes.h:266
clang::ASTContext::getAutoDeductType
QualType getAutoDeductType() const
C++11 deduction pattern for &#39;auto&#39; type.
Definition: ASTContext.cpp:5220
clang::HeaderSearch::lookupModule
Module * lookupModule(StringRef ModuleName, bool AllowSearch=true, bool AllowExtraModuleMapSearch=false)
Lookup a module Search for a module with the given name.
Definition: HeaderSearch.cpp:206
clang::ObjCObjectTypeLoc::setTypeArgsRAngleLoc
void setTypeArgsRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:936
clang::RecordTypeLoc
Wrapper for source info for record types.
Definition: TypeLoc.h:718
clang::serialization::ModuleFile::BaseDirectory
std::string BaseDirectory
The base directory of the module.
Definition: ModuleFile.h:128
clang::ODRHash::CalculateHash
unsigned CalculateHash()
Definition: ODRHash.cpp:204
clang::TemplateArgument::Type
The template argument is a type.
Definition: TemplateBase.h:59
clang::PragmaMSStructKind
PragmaMSStructKind
Definition: PragmaKinds.h:23
clang::ObjCObjectPointerTypeLoc
Wraps an ObjCPointerType with source location information.
Definition: TypeLoc.h:1294
clang::Module::getUmbrellaDir
DirectoryName getUmbrellaDir() const
Retrieve the directory for which this module serves as the umbrella.
Definition: Module.cpp:238
clang::DependentTemplateSpecializationTypeLoc::getNumArgs
unsigned getNumArgs() const
Definition: TypeLoc.h:2272
clang::serialization::ModuleFile::TypeRemap
ContinuousRangeMap< uint32_t, int, 2 > TypeRemap
Remapping table for type IDs in this module.
Definition: ModuleFile.h:461
clang::ASTReader::DecodeSelector
Selector DecodeSelector(serialization::SelectorID Idx)
Definition: ASTReader.cpp:8525
clang::PreprocessorOptions::ObjCXXARCStandardLibrary
ObjCXXARCStandardLibraryKind ObjCXXARCStandardLibrary
The Objective-C++ ARC standard library that we should support, by providing appropriate definitions t...
Definition: PreprocessorOptions.h:154
clang::TemplateArgument::Pack
The template argument is actually a parameter pack.
Definition: TemplateBase.h:90
clang::ASTReader::getPreprocessor
Preprocessor & getPreprocessor() const
Retrieve the preprocessor.
Definition: ASTReader.h:1658
clang::serialization::ModuleFile::BasePreprocessedEntityID
serialization::PreprocessedEntityID BasePreprocessedEntityID
Base preprocessed entity ID for preprocessed entities local to this module.
Definition: ModuleFile.h:333
clang::APValue
APValue - This class implements a discriminated union of [uninitialized] [APSInt] [APFloat]...
Definition: APValue.h:115
clang::TemplateTemplateParmDecl::getDefaultArgument
const TemplateArgumentLoc & getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1721
clang::CXXBaseSpecifier
Represents a base class of a C++ class.
Definition: DeclCXX.h:145
clang::OMPWriteClause
This represents &#39;write&#39; clause in the &#39;#pragma omp atomic&#39; directive.
Definition: OpenMPClause.h:1725
clang::ASTReader::GetNumExternalSelectors
uint32_t GetNumExternalSelectors() override
Returns the number of selectors known to the external AST source.
Definition: ASTReader.cpp:8554
clang::SrcMgr::ContentCache::BufferOverridden
unsigned BufferOverridden
Indicates whether the buffer itself was provided to override the actual file contents.
Definition: SourceManager.h:141
clang::ASTReader::PrintStats
void PrintStats() override
Print some statistics about AST usage.
Definition: ASTReader.cpp:7596
clang::DiagnosticMapping::setSeverity
void setSeverity(diag::Severity Value)
Definition: DiagnosticIDs.h:120
clang::serialization::ModuleManager::size
unsigned size() const
Number of modules loaded.
Definition: ModuleManager.h:195
OMPDependClause::setLoopData
void setLoopData(unsigned NumLoop, Expr *Cnt)
Set the loop data for the depend clauses with &#39;sink|source&#39; kind of dependency.
Definition: OpenMPClause.cpp:852
TokenKinds.h
Defines the clang::TokenKind enum and support functions.
clang::ContinuousRangeMap::insert
void insert(const value_type &Val)
Definition: ContinuousRangeMap.h:66
clang::ASTRecordReader::readQualifiers
Qualifiers readQualifiers()
Definition: ASTRecordReader.h:168
clang::ModuleFileExtensionMetadata
Metadata for a module file extension.
Definition: ModuleFileExtension.h:34
HeaderSearchOptions.h
clang::FileSystemOptions
Keeps track of options that affect how file operations are performed.
Definition: FileSystemOptions.h:22
clang::ASTContext::Char8Ty
CanQualType Char8Ty
Definition: ASTContext.h:1022
clang::AutoTypeLoc::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:2010
clang::serialization::reader::ASTIdentifierLookupTable
llvm::OnDiskIterableChainedHashTable< ASTIdentifierLookupTrait > ASTIdentifierLookupTable
The on-disk hash table used to contain information about all of the identifiers in the program...
Definition: ASTReaderInternals.h:187
clang::HeaderFileInfo::Framework
StringRef Framework
If this header came from a framework include, this is the name of the framework.
Definition: HeaderSearch.h:111
clang::ASTReader::ReadBlockAbbrevs
static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID)
ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the specified cursor.
Definition: ASTReader.cpp:1628
PCHContainerOperations.h
clang::ASTReader::GetType
QualType GetType(serialization::TypeID ID)
Resolve a type ID into a type, potentially building a new type.
Definition: ASTReader.cpp:6729
ObjCMethodList.h
clang::TemplateArgumentList
A template argument list.
Definition: DeclTemplate.h:239
clang::TypeSourceInfo::getTypeLoc
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Definition: TypeLoc.h:244
clang::CXXRecordDecl::getDescribedClassTemplate
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
Definition: DeclCXX.cpp:1692
clang::DeclarationNameInfo::setLoc
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
Definition: DeclarationName.h:722
clang::ASTContext::getExternCContextDecl
ExternCContextDecl * getExternCContextDecl() const
Definition: ASTContext.cpp:1240
clang::ASTReader::DecodeIdentifierInfo
IdentifierInfo * DecodeIdentifierInfo(serialization::IdentifierID ID)
Definition: ASTReader.cpp:8333
clang::QualifierInfo::QualifierLoc
NestedNameSpecifierLoc QualifierLoc
Definition: Decl.h:645
clang::ASTReaderListener::ReadHeaderSearchOptions
virtual bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts, StringRef SpecificModuleCachePath, bool Complain)
Receives the header search options.
Definition: ASTReader.h:168
clang::serialization::reader::HeaderFileInfoTrait::internal_key_type::ModTime
time_t ModTime
Definition: ASTReaderInternals.h:255
clang::TemplateArgument::getKind
ArgKind getKind() const
Return the kind of stored template argument.
Definition: TemplateBase.h:234
DeclCXX.h
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
clang::AtomicTypeLoc::setKWLoc
void setKWLoc(SourceLocation Loc)
Definition: TypeLoc.h:2373
clang::DeclarationName::getCXXDeductionGuideTemplate
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name...
Definition: DeclarationName.h:451
clang::ASTContext::getTranslationUnitDecl
TranslationUnitDecl * getTranslationUnitDecl() const
Definition: ASTContext.h:1009
clang::DiagnosticsEngine::getDiagnosticIDs
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
Definition: Diagnostic.h:501
clang::serialization::PREDEF_TYPE_CHAR16_ID
The C++ &#39;char16_t&#39; type.
Definition: ASTBitCodes.h:879
SourceLocation.h
Defines the clang::SourceLocation class and associated facilities.
clang::ASTRecordReader::readTemplateArgumentList
void readTemplateArgumentList(SmallVectorImpl< TemplateArgument > &TemplArgs, bool Canonicalize=false)
Read a template argument array, advancing Idx.
Definition: ASTReader.cpp:8648
clang::NestedNameSpecifierLocBuilder::getWithLocInContext
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Definition: NestedNameSpecifier.cpp:700
clang::IdentifierInfo::hasRevertedTokenIDToIdentifier
bool hasRevertedTokenIDToIdentifier() const
True if revertTokenIDToIdentifier() was called.
Definition: IdentifierTable.h:188
clang::DependentSizedArrayTypeLoc
Definition: TypeLoc.h:1546
clang::OMPNowaitClause
This represents &#39;nowait&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:1569
clang::FieldDecl::isMutable
bool isMutable() const
Determines whether this field is mutable (C++ only).
Definition: Decl.h:2804
clang::Module::InferSubmodules
unsigned InferSubmodules
Whether we should infer submodules for this module based on the headers.
Definition: Module.h:246
clang::TypeLocReader
Definition: ASTReader.cpp:6386
clang::CXXRecordDecl
Represents a C++ struct/union/class.
Definition: DeclCXX.h:253
clang::ASTReader::GetExternalSelector
Selector GetExternalSelector(serialization::SelectorID ID) override
Resolve a selector ID into a selector.
Definition: ASTReader.cpp:8550
clang::SourceRange::isValid
bool isValid() const
Definition: SourceLocation.h:222
clang::ASTReader::ReadDeclID
serialization::DeclID ReadDeclID(ModuleFile &F, const RecordData &Record, unsigned &Idx)
Reads a declaration ID from the given position in a record in the given module.
Definition: ASTReader.cpp:7360
clang::ASTRecordReader::readAPFloat
llvm::APFloat readAPFloat(const llvm::fltSemantics &Sem)
Read an integral value, advancing Idx.
Definition: ASTReader.cpp:8878
clang::ASTReaderListener::needsSystemInputFileVisitation
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.h:202
clang::ASTReader::ReadUnusedFileScopedDecls
void ReadUnusedFileScopedDecls(SmallVectorImpl< const DeclaratorDecl *> &Decls) override
Read the set of unused file-scope declarations known to the external Sema source. ...
Definition: ASTReader.cpp:8141
OMPNumTasksClause
This represents &#39;num_tasks&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5421
clang::TemplateArgument::Template
The template argument is a template name that was provided for a template template parameter...
Definition: TemplateBase.h:75
clang::ExplicitSpecKind::Unresolved
DeclGroup.h
clang::AutoTypeLoc::setArgLocInfo
void setArgLocInfo(unsigned i, TemplateArgumentLocInfo AI)
Definition: TypeLoc.h:2018
clang::ChainedASTReaderListener::needsSystemInputFileVisitation
bool needsSystemInputFileVisitation() override
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
Definition: ASTReader.cpp:223
clang::CXXTemporary::Create
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Definition: ExprCXX.cpp:1006
clang::serialization::ModuleFile::PragmaDiagMappings
SmallVector< uint64_t, 8 > PragmaDiagMappings
Diagnostic IDs and their mappings that the user changed.
Definition: ModuleFile.h:466
clang::serialization::FILE_SYSTEM_OPTIONS
Record code for the filesystem options table.
Definition: ASTBitCodes.h:351
OMPMapClause::CreateEmpty
static OMPMapClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars original expressions, NumUniqueDeclarations declar...
Definition: OpenMPClause.cpp:947
clang::SourceLocation::isInvalid
bool isInvalid() const
Definition: SourceLocation.h:107
clang::serialization::reader::ASTIdentifierLookupTraitBase::ComputeHash
static hash_value_type ComputeHash(const internal_key_type &a)
Definition: ASTReader.cpp:887
clang::ASTReader::ReadToken
Token ReadToken(ModuleFile &M, const RecordDataImpl &Record, unsigned &Idx)
Reads a token out of a record.
Definition: ASTReader.cpp:1662
clang::serialization::ModuleFile::IdentifierTableData
const char * IdentifierTableData
Actual data for the on-disk hash table of identifiers.
Definition: ModuleFile.h:287
clang::FunctionTypeLoc::setParam
void setParam(unsigned i, ParmVarDecl *VD)
Definition: TypeLoc.h:1433
clang::MacroDirective::MD_Visibility
Definition: MacroInfo.h:295
clang::APValue::None
There is no such object (it&#39;s outside its lifetime).
Definition: APValue.h:121
clang::serialization::needsAnonymousDeclarationNumber
bool needsAnonymousDeclarationNumber(const NamedDecl *D)
Determine whether the given declaration needs an anonymous declaration number.
Definition: ASTCommon.cpp:419
clang::ASTContext::Char16Ty
CanQualType Char16Ty
Definition: ASTContext.h:1023
clang::DiagnosticsEngine::Level
Level
The level of the diagnostic, after it has been through mapping.
Definition: Diagnostic.h:152
clang::AttrSyntax::C
clang::DiagnosticMapping::deserialize
static DiagnosticMapping deserialize(unsigned Bits)
Deserialize a mapping.
Definition: DiagnosticIDs.h:148
clang::IdentifierInfo::setOutOfDate
void setOutOfDate(bool OOD)
Set whether the information for this identifier is out of date with respect to the external source...
Definition: IdentifierTable.h:354
clang::ObjCObjectTypeLoc::getNumProtocols
unsigned getNumProtocols() const
Definition: TypeLoc.h:970
clang::ParenTypeLoc::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1125
LT
ASTImporterLookupTable & LT
Definition: ASTImporterLookupTable.cpp:23
clang::serialization::ModuleFile::DeclOffsets
const DeclOffset * DeclOffsets
Offset of each declaration within the bitstream, indexed by the declaration ID (-1).
Definition: ModuleFile.h:415
clang::TemplateArgumentLocInfo
Location information for a TemplateArgument.
Definition: TemplateBase.h:392
clang::ASTReaderListener::ReadTargetOptions
virtual bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain, bool AllowCompatibleDifferences)
Receives the target options.
Definition: ASTReader.h:140
clang::ClassTemplateDecl
Declaration of a class template.
Definition: DeclTemplate.h:2238
clang::serialization::TYPE_OFFSET
Record code for the offsets of each type.
Definition: ASTBitCodes.h:405
clang::TypeDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.h:3058
clang::ASTRecordReader::readNestedNameSpecifierLoc
NestedNameSpecifierLoc readNestedNameSpecifierLoc()
Return a nested name specifier, advancing Idx.
Definition: ASTReader.cpp:8749
clang::serialization::DECLTYPES_BLOCK_ID
The block containing the definitions of all of the types and decls used within the AST file...
Definition: ASTBitCodes.h:260
Expr.h
clang::serialization::PREDEF_DECL_VA_LIST_TAG
The internal &#39;__va_list_tag&#39; struct, if any.
Definition: ASTBitCodes.h:1123
clang::diag::kind
unsigned kind
All of the diagnostics that can be emitted by the frontend.
Definition: DiagnosticIDs.h:60
clang::IdentifierInfo::revertTokenIDToIdentifier
void revertTokenIDToIdentifier()
Revert TokenID to tok::identifier; used for GNU libstdc++ 4.2 compatibility.
Definition: IdentifierTable.h:196
clang::DeducedTemplateSpecializationTypeLoc
Definition: TypeLoc.h:2066
clang::ASTReaderListener::ReadModuleName
virtual void ReadModuleName(StringRef ModuleName)
Definition: ASTReader.h:124
clang::ASTContext::getObjCClassDecl
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C &#39;Class&#39; type...
Definition: ASTContext.cpp:7475
OMPFromClause::CreateEmpty
static OMPFromClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
Definition: OpenMPClause.cpp:1043
iterator
clang::PackExpansionTypeLoc
Definition: TypeLoc.h:2325
clang::Stmt::getSourceRange
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
Definition: Stmt.cpp:263
clang::PCHValidator::ReadDiagnosticOptions
bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain) override
Receives the diagnostic options.
Definition: ASTReader.cpp:558
clang::ASTIdentifierIterator::ASTIdentifierIterator
ASTIdentifierIterator(const ASTReader &Reader, bool SkipModules=false)
Definition: ASTReader.cpp:7898
clang::ModuleMap::resolveLinkAsDependencies
void resolveLinkAsDependencies(Module *Mod)
Use PendingLinkAsModule information to mark top level link names that are going to be replaced by exp...
Definition: ModuleMap.cpp:58
clang::serialization::ModuleManager::AlreadyLoaded
The module file had already been loaded.
Definition: ModuleManager.h:200
clang::UnaryTransformTypeLoc
Definition: TypeLoc.h:1891
clang::serialization::SUBMODULE_EXPORT_AS
Specifies the name of the module that will eventually re-export the entities in this module...
Definition: ASTBitCodes.h:783
clang::StringLiteral
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1711
TargetInfo.h
Defines the clang::TargetInfo interface.
clang::serialization::PREDEF_TYPE_DOUBLE_ID
The &#39;double&#39; type.
Definition: ASTBitCodes.h:858
clang::OMPSafelenClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:698
clang::ASTReader::OutOfDate
The AST file is out-of-date relative to its input files, and needs to be regenerated.
Definition: ASTReader.h:378
clang::Module::NameVisibilityKind
NameVisibilityKind
Describes the visibility of the various names within a particular module.
Definition: Module.h:273
clang::MacroDirective::setPrevious
void setPrevious(MacroDirective *Prev)
Set previous definition of the macro with the same name.
Definition: MacroInfo.h:325
DiagnosticOptions.h
clang::UnaryTransformTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1903
clang::APValue::MemberPointer
Definition: APValue.h:134
clang::serialization::PREDEF_TYPE_INT_ID
The (signed) &#39;int&#39; type.
Definition: ASTBitCodes.h:846
clang::ObjCMethodList
a linked list of methods with the same selector name but different signatures.
Definition: ObjCMethodList.h:25
clang::FunctionDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
Definition: Decl.cpp:3868
clang::ASTRecordReader
An object for streaming information from a record.
Definition: ASTRecordReader.h:27
clang::TemplateSpecializationTypeLoc::setRAngleLoc
void setRAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:1600
clang::NamedDecl::getName
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Definition: Decl.h:250
clang::Sema::GlobalMethods
std::pair< ObjCMethodList, ObjCMethodList > GlobalMethods
Definition: Sema.h:1247
clang::serialization::reader::ASTIdentifierLookupTrait::ReadData
data_type ReadData(const internal_key_type &k, const unsigned char *d, unsigned DataLen)
Definition: ASTReader.cpp:939
clang::Decl::Kind
Kind
Lists the kind of concrete classes of Decl.
Definition: DeclBase.h:91
clang::serialization::SUBMODULE_REQUIRES
Specifies a required feature.
Definition: ASTBitCodes.h:751
clang::HeaderSearchOptions
HeaderSearchOptions - Helper class for storing options related to the initialization of the HeaderSea...
Definition: HeaderSearchOptions.h:67
OMPDistScheduleClause
This represents &#39;dist_schedule&#39; clause in the &#39;#pragma omp ...&#39; directive.
Definition: OpenMPClause.h:5550
clang::ASTReader::getSourceLocationForDeclID
SourceLocation getSourceLocationForDeclID(serialization::GlobalDeclID ID)
Returns the source location for the decl ID.
Definition: ASTReader.cpp:7222
clang::Module::ConfigMacros
std::vector< std::string > ConfigMacros
The set of "configuration macros", which are macros that (intentionally) change how this module is bu...
Definition: Module.h:350
clang::ODRHash::AddStmt
void AddStmt(const Stmt *S)
Definition: ODRHash.cpp:24
clang::TypeOfExprTypeLoc
Definition: TypeLoc.h:1844
clang::FriendDecl::getSourceRange
SourceRange getSourceRange() const override LLVM_READONLY
Retrieves the source range for the friend declaration.
Definition: DeclFriend.h:148
clang::ObjCObjectTypeLoc::getNumTypeArgs
unsigned getNumTypeArgs() const
Definition: TypeLoc.h:940
clang::ASTContext::IntTy
CanQualType IntTy
Definition: ASTContext.h:1025
clang::ExternalASTSource::ASTSourceDescriptor
Abstracts clang modules and precompiled header files and holds everything needed to generate debug in...
Definition: ExternalASTSource.h:171
clang::ExternalVTableUse::Record
CXXRecordDecl * Record
Definition: ExternalSemaSource.h:44
clang::ASTReader::VersionMismatch
The AST file was written by a different version of Clang.
Definition: ASTReader.h:381
clang::serialization::DECL_UPDATE_OFFSETS
Record for offsets of DECL_UPDATES records for declarations that were modified after being deserializ...
Definition: ASTBitCodes.h:539
clang::HeaderSearchOptions::ModuleMapFileHomeIsCwd
unsigned ModuleMapFileHomeIsCwd
Set the &#39;home directory&#39; of a module map file to the current working directory (or the home directory...
Definition: HeaderSearchOptions.h:143
checkDiagnosticMappings
static bool checkDiagnosticMappings(DiagnosticsEngine &StoredDiags, DiagnosticsEngine &Diags, bool IsSystem, bool Complain)
Definition: ASTReader.cpp:496
clang::ASTReader::readASTFileControlBlock
static bool readASTFileControlBlock(StringRef Filename, FileManager &FileMgr, const PCHContainerReader &PCHContainerRdr, bool FindModuleFileExtensions, ASTReaderListener &Listener, bool ValidateDiagnosticOptions)
Read the control block for the named AST file.
Definition: ASTReader.cpp:5111
clang::serialization::ModuleFile::PreprocessorDetailCursor
llvm::BitstreamCursor PreprocessorDetailCursor
The cursor to the start of the (optional) detailed preprocessing record block.
Definition: ModuleFile.h:326
clang::serialization::PREDEF_TYPE_WCHAR_ID
The C++ &#39;wchar_t&#39; type.
Definition: ASTBitCodes.h:840
clang::serialization::PREDEF_TYPE_OBJC_CLASS
The ObjC &#39;Class&#39; type.
Definition: ASTBitCodes.h:888
clang::ObjCObjectTypeLoc::setProtocolLAngleLoc
void setProtocolLAngleLoc(SourceLocation Loc)
Definition: TypeLoc.h:958
clang::DeclContext::getPrimaryContext
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
Definition: DeclBase.cpp:1171
clang::NestedNameSpecifierLocBuilder::Extend
void Extend(ASTContext &Context, SourceLocation TemplateKWLoc, TypeLoc TL, SourceLocation ColonColonLoc)
Extend the current nested-name-specifier by another nested-name-specifier component of the form &#39;type...
Definition: NestedNameSpecifier.cpp:571
clang::HeaderFileInfo::IndexHeaderMapHeader
unsigned IndexHeaderMapHeader
Whether this is a header inside a framework that is currently being built.
Definition: HeaderSearch.h:84
clang::TypedefType
Definition: Type.h:4240
clang::ASTReader::ASTReader
ASTReader(Preprocessor &PP, InMemoryModuleCache &ModuleCache, ASTContext *Context, const PCHContainerReader &PCHContainerRdr, ArrayRef< std::shared_ptr< ModuleFileExtension >> Extensions, StringRef isysroot="", bool DisableValidation=false, bool AllowASTWithCompilerErrors=false, bool AllowConfigurationMismatch=false, bool ValidateSystemInputs=false, bool ValidateASTInputFilesContent=false, bool UseGlobalIndex=true, std::unique_ptr< llvm::Timer > ReadTimer={})
Load the AST file and validate its contents against the given Preprocessor.
Definition: ASTReader.cpp:11438
clang::HeaderSearchOptions::Sysroot
std::string Sysroot
If non-empty, the directory to use as a "virtual system root" for include paths.
Definition: HeaderSearchOptions.h:99
clang::ASTReader::getOwningModuleFile
ModuleFile * getOwningModuleFile(const Decl *D)
Retrieve the module file that owns the given declaration, or NULL if the declaration is not from a mo...
Definition: ASTReader.cpp:7214
clang::HeaderFileInfo::IsValid
unsigned IsValid
Whether this file has been looked up as a header.
Definition: HeaderSearch.h:87
clang::ODRHash::isWhitelistedDecl
static bool isWhitelistedDecl(const Decl *D, const DeclContext *Parent)
Definition: ODRHash.cpp:443
clang::serialization::WEAK_UNDECLARED_IDENTIFIERS
Record code for weak undeclared identifiers.
Definition: ASTBitCodes.h:525
clang::serialization::PREPROCESSOR_BLOCK_ID
The block containing information about the preprocessor.
Definition: ASTBitCodes.h:256
clang::ComplexTypeLoc
Definition: TypeLoc.h:1778
clang::SimpleASTReaderListener::ReadPreprocessorOptions
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts, bool Complain, std::string &SuggestedPredefines) override
Receives the preprocessor options.
Definition: ASTReader.cpp:760
clang::ASTReader::StartTranslationUnit
void StartTranslationUnit(ASTConsumer *Consumer) override
Function that will be invoked when we begin parsing a new translation unit involving this external AS...
Definition: ASTReader.cpp:7586
clang::TemplateTypeParmDecl::getDefaultArgument
QualType getDefaultArgument() const
Retrieve the default argument, if any.
Definition: DeclTemplate.h:1251
clang::Token::setLocation
void setLocation(SourceLocation L)
Definition: Token.h:134
clang::DiagnosticsEngine::getWarningsAsErrors
bool getWarningsAsErrors() const
Definition: Diagnostic.h:616
clang::DeclarationName::getCXXLiteralIdentifier
IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it...
Definition: DeclarationName.h:472
clang::ValueDecl::getType
QualType getType() const
Definition: Decl.h:630
clang::BuiltinTypeLoc
Wrapper for source info for builtin types.
Definition: TypeLoc.h:550
true
#define true
Definition: stdbool.h:16
clang::ParenTypeLoc::setRParenLoc
void setRParenLoc(SourceLocation Loc)
Definition: TypeLoc.h:1129
clang::TemplateTypeParmTypeLoc
Wrapper for template type parameters.
Definition: TypeLoc.h:734
clang::serialization::HEADER_SEARCH_OPTIONS
Record code for the headers search options table.
Definition: ASTBitCodes.h:354
clang::Module::Conflict::Other
Module * Other
The module that this module conflicts with.
Definition: Module.h:368
clang::serialization::PREDEF_TYPE_NULL_ID
The NULL type.
Definition: ASTBitCodes.h:807
clang::SourceRange
A trivial tuple used to represent a source range.
Definition: SourceLocation.h:207
clang::MacroInfo::setParameterList
void setParameterList(ArrayRef< IdentifierInfo *> List, llvm::BumpPtrAllocator &PPAllocator)
Set the specified list of identifiers as the parameter list for this macro.
Definition: MacroInfo.h:164
clang::serialization::ModuleFile::ModuleMapPath
std::string ModuleMapPath
Definition: ModuleFile.h:151
clang::DeclarationName::CXXOperatorName
Definition: DeclarationName.h:209
clang::NamedDecl
This represents a decl that may have a name.
Definition: Decl.h:223
clang::ASTContext::setsigjmp_bufDecl
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
Definition: ASTContext.h:1786
clang::ASTContext::setFILEDecl
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
Definition: ASTContext.h:1764
clang::TagType
Definition: Type.h:4471
clang::serialization::METADATA
AST file metadata, including the AST file version number and information about the compiler used to b...
Definition: ASTBitCodes.h:303
clang::serialization::INPUT_FILES_BLOCK_ID
The block of input files, which were used as inputs to create this AST file.
Definition: ASTBitCodes.h:280
clang::diag::Severity::Warning
Present this diagnostic as a warning.
clang::serialization::ModuleFile::MacroCursor
llvm::BitstreamCursor MacroCursor
The cursor to the start of the preprocessor block, which stores all of the macro definitions.
Definition: ModuleFile.h:301
clang::serialization::ModuleFile::SelectorOffsets
const uint32_t * SelectorOffsets
Offsets into the selector lookup table&#39;s data array where each selector resides.
Definition: ModuleFile.h:383
clang::ASTContext::BoolTy
CanQualType BoolTy
Definition: ASTContext.h:1017
clang::ASTReader::UpdateSema
void UpdateSema()
Update the state of Sema after loading some additional modules.
Definition: ASTReader.cpp:7769
clang::serialization::ModuleFile::LocalNumTypes
unsigned LocalNumTypes
The number of types in this AST file.
Definition: ModuleFile.h:450
clang::NamespaceAliasDecl
Represents a C++ namespace alias.
Definition: DeclCXX.h:2967
clang::TemplateSpecializationTypeLoc::setTemplateNameLoc
void setTemplateNameLoc(SourceLocation Loc)
Definition: TypeLoc.h:1624
clang::ObjCRuntime::Kind
Kind
The basic Objective-C runtimes that we know about.
Definition: ObjCRuntime.h:30
clang::serialization::PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID
The internal &#39;__NSConstantString&#39; tag type.
Definition: ASTBitCodes.h:1138
clang::serialization::TypeIdx::fromTypeID
static TypeIdx fromTypeID(TypeID ID)
Definition: ASTBitCodes.h:104
clang::ASTReader::mapGlobalIDToModuleFileGlobalID
serialization::DeclID mapGlobalIDToModuleFileGlobalID(ModuleFile &M, serialization::DeclID GlobalID)
Map a global declaration ID into the declaration ID used to refer to this declaration within the give...
Definition: ASTReader.cpp:7343
clang::serialization::InputFileRecordTypes
InputFileRecordTypes
Record types that occur within the input-files block inside the control block.
Definition: ASTBitCodes.h:383
clang::FileManager::getBufferForFile
llvm::ErrorOr< std::unique_ptr< llvm::MemoryBuffer > > getBufferForFile(const FileEntry *Entry, bool isVolatile=false)
Open the specified file as a MemoryBuffer, returning a new MemoryBuffer if successful, otherwise returning null.
Definition: FileManager.cpp:461
clang::ASTReader::FinishedDeserializing
void FinishedDeserializing() override
Notify ASTReader that we finished the deserialization of a decl or type.
Definition: ASTReader.cpp:11360
clang::ASTContext::DoubleTy
CanQualType DoubleTy
Definition: ASTContext.h:1028
clang::serialization::PP_MACRO_FUNCTION_LIKE
A function-like macro definition.
Definition: ASTBitCodes.h:693
clang::ExtVectorTypeLoc
Definition: TypeLoc.h:1764
clang::prec::Level
Level
Definition: OperatorPrecedence.h:26
clang::ASTReader::~ASTReader
~ASTReader() override
Definition: ASTReader.cpp:11476
clang::serialization::PREDEF_DECL_OBJC_PROTOCOL_ID
The Objective-C &#39;Protocol&#39; type.
Definition: ASTBitCodes.h:1108
clang::HeaderSearchOptions::UseStandardCXXIncludes
unsigned UseStandardCXXIncludes
Include the system standard C++ library include search directories.
Definition: HeaderSearchOptions.h:183
clang::OMPLastprivateClause::CreateEmpty
static OMPLastprivateClause * CreateEmpty(const ASTContext &C, unsigned N)
Creates an empty clause with the place for N variables.
Definition: OpenMPClause.cpp:423
Token.h
clang::NestedNameSpecifier::Global
The global specifier &#39;::&#39;. There is no stored value.
Definition: NestedNameSpecifier.h:95
clang::TypeLocReader::TypeLocReader
TypeLocReader(ASTRecordReader &Reader)
Definition: ASTReader.cpp:6406
clang::serialization::CONTROL_BLOCK_ID
The control block, which contains all of the information that needs to be validated prior to committi...
Definition: ASTBitCodes.h:274
clang::PointerTypeLoc
Wrapper for source info for pointers.
Definition: TypeLoc.h:1226
clang::SourceRange::getBegin
SourceLocation getBegin() const
Definition: SourceLocation.h:216
clang::serialization::ModuleFile::File
const FileEntry * File
The file entry for the module file.
Definition: ModuleFile.h:166
OMPMappableExprListSizeTy::NumComponents
unsigned NumComponents
Total number of expression components.
Definition: OpenMPClause.h:4300
clang::TargetOptions::Triple
std::string Triple
The name of the target triple to compile for.
Definition: TargetOptions.h:29
clang::IdentifierInfo::setObjCOrBuiltinID
void setObjCOrBuiltinID(unsigned ID)
Definition: IdentifierTable.h:251
OMPNontemporalClause
This represents clause &#39;nontemporal&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:6281
clang::serialization::reader::ASTIdentifierLookupTraitBase::internal_key_type
StringRef internal_key_type
Definition: ASTReaderInternals.h:134
clang::OMPIfClause::setLParenLoc
void setLParenLoc(SourceLocation Loc)
Sets the location of &#39;(&#39;.
Definition: OpenMPClause.h:484
clang::BlockPointerTypeLoc
Wrapper for source info for block pointers.
Definition: TypeLoc.h:1239
clang::ChainedASTReaderListener::ReadModuleName
void ReadModuleName(StringRef ModuleName) override
Definition: ASTReader.cpp:153
PreprocessingRecord.h
clang::ASTReader::ModuleDeclIterator
Definition: ASTReader.h:1379
clang::serialization::PREDEF_TYPE_SAT_USHORT_FRACT_ID
The &#39;_Sat unsigned short _Fract&#39; type.
Definition: ASTBitCodes.h:1008
clang::SrcMgr::isSystem
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
Definition: SourceManager.h:82
clang::SourceManager
This class handles loading and caching of source files into memory.
Definition: SourceManager.h:596
OMPToClause::CreateEmpty
static OMPToClause * CreateEmpty(const ASTContext &C, const OMPMappableExprListSizeTy &Sizes)
Creates an empty clause with the place for NumVars variables.
Definition: OpenMPClause.cpp:994
clang::FunctionProtoType::ExtProtoInfo::ExceptionSpec
ExceptionSpecInfo ExceptionSpec
Definition: Type.h:3843
clang::serialization::PredefinedDeclIDs
PredefinedDeclIDs
Predefined declaration IDs.
Definition: ASTBitCodes.h:1091
clang::FunctionTemplateDecl
Declaration of a template function.
Definition: DeclTemplate.h:977
clang::serialization::TU_UPDATE_LEXICAL
Record code for an update to the TU&#39;s lexically contained declarations.
Definition: ASTBitCodes.h:517
clang::serialization::PREDEF_TYPE_SAT_FRACT_ID
The &#39;_Sat _Fract&#39; type.
Definition: ASTBitCodes.h:1002
clang::ElaboratedTypeLoc::setElaboratedKeywordLoc
void setElaboratedKeywordLoc(SourceLocation Loc)
Definition: TypeLoc.h:2096
clang::serialization::DeclOffset
Source range/offset of a preprocessed entity.
Definition: ASTBitCodes.h:220
clang::ChainedASTReaderListener::visitModuleFile
void visitModuleFile(StringRef Filename, serialization::ModuleKind Kind) override
This is called for each AST file loaded.
Definition: ASTReader.cpp:228
clang::Attr
Attr - This represents one attribute.
Definition: Attr.h:45
clang::FunctionDecl::isDeletedAsWritten
bool isDeletedAsWritten() const
Definition: Decl.h:2263
clang::Decl::getLocation
SourceLocation getLocation() const
Definition: DeclBase.h:429
OMPUseDevicePtrClause
This represents clause &#39;use_device_ptr&#39; in the &#39;#pragma omp ...&#39; directives.
Definition: OpenMPClause.h:6016
clang::serialization::ModuleFile::ObjCCategoriesMap
const serialization::ObjCCategoriesInfo * ObjCCategoriesMap
Array of category list location information within this module file, sorted by the definition ID...
Definition: ModuleFile.h:438
clang::serialization::AbstractTypeReader
Definition: ASTContext.h:153
clang::ASTReader::loadGlobalIndex
bool loadGlobalIndex()
Attempts to load the global index.
Definition: ASTReader.cpp:4075
clang::Token::startToken
void startToken()
Reset all flags to cleared.
Definition: Token.h:171
clang::ASTReader::getModule
Module * getModule(unsigned ID) override
Retrieve the module that corresponds to the given module ID.
Definition: ASTReader.cpp:8457
clang::serialization::SPECIAL_TYPE_OBJC_CLASS_REDEFINITION
Objective-C "Class" redefinition type.
Definition: ASTBitCodes.h:1073
clang::ASTReader::ReadUnusedLocalTypedefNameCandidates
void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls) override
Read the set of potentially unused typedefs known to the source.
Definition: ASTReader.cpp:8173
clang::TypeSourceInfo::getType
QualType getType() const
Return the type wrapped by this type source info.
Definition: Type.h:6238
clang::ASTContext::OCLClkEventTy
CanQualType OCLClkEventTy
Definition: ASTContext.h:1053
clang::serialization::PREDEF_TYPE_PSEUDO_OBJECT
The pseudo-object placeholder type.
Definition: ASTBitCodes.h:912
clang::serialization::NUM_PREDEF_SUBMODULE_IDS
const unsigned int NUM_PREDEF_SUBMODULE_IDS
The number of predefined submodule IDs.
Definition: ASTBitCodes.h:174
clang::ASTReaderListener::ReadDiagnosticOptions
virtual bool ReadDiagnosticOptions(IntrusiveRefCntPtr< DiagnosticOptions > DiagOpts, bool Complain)
Receives the diagnostic options.
Definition: ASTReader.h:150
clang::TypeOfTypeLoc::setUnderlyingTInfo
void setUnderlyingTInfo(TypeSourceInfo *TI) const
Definition: TypeLoc.h:1869
clang::Module::InferExplicitSubmodules
unsigned InferExplicitSubmodules
Whether, when inferring submodules, the inferred submodules should be explicit.
Definition: Module.h:250
clang::serialization::POINTERS_TO_MEMBERS_PRAGMA_OPTIONS
Record code for #pragma ms_struct options.
Definition: ASTBitCodes.h:632
clang::ASTReader::RecordSwitchCaseID
void RecordSwitchCaseID(SwitchCase *SC, unsigned ID)
Record that the given ID maps to the given switch-case statement.
Definition: ASTReader.cpp:8940
clang::Preprocessor
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
Definition: Preprocessor.h:128
clang::ASTContext::UnsignedIntTy
CanQualType UnsignedIntTy
Definition: ASTContext.h:1026
clang::Create
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr *> VL, ArrayRef< Expr *> PL, ArrayRef< Expr *> IL, Expr *Step, Expr *CalcStep, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
ContinuousRangeMap.h
clang::CommentOptions::ParseAllComments
bool ParseAllComments
Treat ordinary comments as documentation comments.
Definition: CommentOptions.h:31
clang::serialization::reader::ASTDeclContextNameLookupTrait::data_type_builder::insert
void insert(DeclID ID)
Definition: ASTReaderInternals.h:61
clang::OMPClauseReader::readClause
OMPClause * readClause()
Definition: ASTReader.cpp:11520
clang::ASTReader::getGlobalIdentifierID
serialization::IdentifierID getGlobalIdentifierID(ModuleFile &M, unsigned LocalID)
Definition: ASTReader.cpp:8372
clang::serialization::TENTATIVE_DEFINITIONS
Record code for the array of tentative definitions.
Definition: ASTBitCodes.h:470
clang::serialization::PREDEF_TYPE_FLOAT128_ID
The &#39;__float128&#39; type.
Definition: ASTBitCodes.h:936
clang::ASTContext::getMakeIntegerSeqDecl
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
Definition: ASTContext.cpp:1258