Lines Matching +full:llvm +full:- +full:builddir
1 //===- ASTReader.cpp - AST File Reader ------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 //===----------------------------------------------------------------------===//
55 #include "clang/Basic/LLVM.h"
98 #include "llvm/ADT/APFloat.h"
99 #include "llvm/ADT/APInt.h"
100 #include "llvm/ADT/APSInt.h"
101 #include "llvm/ADT/ArrayRef.h"
102 #include "llvm/ADT/DenseMap.h"
103 #include "llvm/ADT/FloatingPointMode.h"
104 #include "llvm/ADT/FoldingSet.h"
105 #include "llvm/ADT/Hashing.h"
106 #include "llvm/ADT/IntrusiveRefCntPtr.h"
107 #include "llvm/ADT/STLExtras.h"
108 #include "llvm/ADT/ScopeExit.h"
109 #include "llvm/ADT/Sequence.h"
110 #include "llvm/ADT/SmallPtrSet.h"
111 #include "llvm/ADT/SmallString.h"
112 #include "llvm/ADT/SmallVector.h"
113 #include "llvm/ADT/StringExtras.h"
114 #include "llvm/ADT/StringMap.h"
115 #include "llvm/ADT/StringRef.h"
116 #include "llvm/ADT/iterator_range.h"
117 #include "llvm/Bitstream/BitstreamReader.h"
118 #include "llvm/Support/Casting.h"
119 #include "llvm/Support/Compiler.h"
120 #include "llvm/Support/Compression.h"
121 #include "llvm/Support/DJB.h"
122 #include "llvm/Support/Endian.h"
123 #include "llvm/Support/Error.h"
124 #include "llvm/Support/ErrorHandling.h"
125 #include "llvm/Support/FileSystem.h"
126 #include "llvm/Support/LEB128.h"
127 #include "llvm/Support/MemoryBuffer.h"
128 #include "llvm/Support/Path.h"
129 #include "llvm/Support/SaveAndRestore.h"
130 #include "llvm/Support/TimeProfiler.h"
131 #include "llvm/Support/Timer.h"
132 #include "llvm/Support/VersionTuple.h"
133 #include "llvm/Support/raw_ostream.h"
134 #include "llvm/TargetParser/Triple.h"
155 using llvm::BitstreamCursor;
157 //===----------------------------------------------------------------------===//
159 //===----------------------------------------------------------------------===//
163 return First->ReadFullVersionInformation(FullVersion) ||
164 Second->ReadFullVersionInformation(FullVersion);
168 First->ReadModuleName(ModuleName);
169 Second->ReadModuleName(ModuleName);
173 First->ReadModuleMapFile(ModuleMapPath);
174 Second->ReadModuleMapFile(ModuleMapPath);
180 return First->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
182 Second->ReadLanguageOptions(LangOpts, ModuleFilename, Complain,
189 return First->ReadTargetOptions(TargetOpts, ModuleFilename, Complain,
191 Second->ReadTargetOptions(TargetOpts, ModuleFilename, Complain,
198 return First->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain) ||
199 Second->ReadDiagnosticOptions(DiagOpts, ModuleFilename, Complain);
205 return First->ReadFileSystemOptions(FSOpts, Complain) ||
206 Second->ReadFileSystemOptions(FSOpts, Complain);
212 return First->ReadHeaderSearchOptions(HSOpts, ModuleFilename,
214 Second->ReadHeaderSearchOptions(HSOpts, ModuleFilename,
221 return First->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
223 Second->ReadPreprocessorOptions(PPOpts, ModuleFilename, ReadMacros,
229 First->ReadCounter(M, Value);
230 Second->ReadCounter(M, Value);
234 return First->needsInputFileVisitation() ||
235 Second->needsInputFileVisitation();
239 return First->needsSystemInputFileVisitation() ||
240 Second->needsSystemInputFileVisitation();
245 First->visitModuleFile(Filename, Kind);
246 Second->visitModuleFile(Filename, Kind);
254 if (First->needsInputFileVisitation() &&
255 (!isSystem || First->needsSystemInputFileVisitation()))
256 Continue |= First->visitInputFile(Filename, isSystem, isOverridden,
258 if (Second->needsInputFileVisitation() &&
259 (!isSystem || Second->needsSystemInputFileVisitation()))
260 Continue |= Second->visitInputFile(Filename, isSystem, isOverridden,
267 First->readModuleFileExtension(Metadata);
268 Second->readModuleFileExtension(Metadata);
271 //===----------------------------------------------------------------------===//
273 //===----------------------------------------------------------------------===//
280 /// \param Diags If non-NULL, diagnostics will be emitted via this engine.
284 /// \returns true if the languagae options mis-match, false otherwise.
294 Diags->Report(diag::err_ast_file_langopt_mismatch) \
298 Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
307 Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
315 Diags->Report(diag::err_ast_file_langopt_value_mismatch) \
339 Diags->Report(diag::err_ast_file_langopt_value_mismatch)
346 Diags->Report(diag::err_ast_file_langopt_value_mismatch)
347 << "target Objective-C runtime" << ModuleFilename;
354 Diags->Report(diag::err_ast_file_langopt_value_mismatch)
361 // mismatches of non-modular sanitizers (the only ones which can affect AST
370 const std::string Flag = "-fsanitize=";
377 Diags->Report(diag::err_ast_file_targetopt_feature_mismatch) \
392 /// \param Diags If non-NULL, diagnostics will be emitted via this engine.
394 /// \returns true if the target options mis-match, false otherwise.
403 Diags->Report(diag::err_ast_file_targetopt_mismatch) \
429 llvm::sort(ExistingFeatures);
430 llvm::sort(ReadFeatures);
449 Diags->Report(diag::err_ast_file_targetopt_feature_mismatch)
450 << /* is-existing-feature */ false << ModuleFilename << Feature;
452 Diags->Report(diag::err_ast_file_targetopt_feature_mismatch)
453 << /* is-existing-feature */ true << ModuleFilename << Feature;
480 llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>;
481 using DeclsMap = llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8>>;
491 // Check current mappings for new -Werror mappings, and the stored mappings
493 // errors because of options like -Werror.
497 for (auto DiagIDMappingPair : MappingSource->getDiagnosticMappings()) {
507 << "-Werror=" + Diags.getDiagnosticIDs()
508 ->getWarningOptionForDiag(DiagID)
531 // Top-level options
535 // If -Wsystem-headers was not enabled before, and it was not explicit,
541 << "-Wsystem-headers" << ModuleFilename;
549 << "-Werror" << ModuleFilename;
557 << "-Weverything -Werror" << ModuleFilename;
565 << "-pedantic-errors" << ModuleFilename;
579 // module import of an implicitly-loaded module file.
584 while (!TopImport->ImportedBy.empty())
585 TopImport = TopImport->ImportedBy[0];
586 if (TopImport->Kind != MK_ImplicitModule)
589 StringRef ModuleName = TopImport->ModuleName;
593 PP.getHeaderSearchInfo().lookupModule(ModuleName, TopImport->ImportLoc);
622 Importer && llvm::is_contained(ExistingOpts.SystemHeaderWarningsModules,
623 Importer->Name);
628 TopM->IsSystem, SystemHeaderWarningsInModule,
649 MacroNames->push_back(MacroName);
659 // Note: GCC drops anything following an end-of-line character.
665 MacroNames->push_back(MacroName);
679 /// \param Diags If non-null, produce diagnostics for any mismatches incurred.
683 /// line (-D or -U) match, but tolerate options missing in one or the
711 llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>::iterator Known =
718 Diags->Report(diag::err_ast_file_macro_def_undef)
743 if (Existing.second != Known->second.second) {
745 Diags->Report(diag::err_ast_file_macro_def_undef)
746 << MacroName << Known->second.second << ModuleFilename;
753 if (Existing.second || Existing.first == Known->second.first) {
760 Diags->Report(diag::err_ast_file_macro_def_conflict)
761 << MacroName << Known->second.first << Existing.first
767 // Leave the <command line> file and return to <built-in>.
768 SuggestedPredefines += "# 1 \"<built-in>\" 2\n";
775 Diags->Report(diag::err_ast_file_macro_def_undef)
787 Diags->Report(diag::err_ast_file_undef)
798 Diags->Report(diag::err_ast_file_pp_detailed_record)
821 if (llvm::is_contained(PPOpts.Includes, File))
831 if (llvm::is_contained(PPOpts.MacroIncludes, File))
865 /// \param Diags If non-null, produce diagnostics for any mismatches incurred.
867 static bool checkModuleCachePath(llvm::vfs::FileSystem &VFS,
882 Diags->Report(diag::err_ast_file_modulecache_mismatch)
902 //===----------------------------------------------------------------------===//
904 //===----------------------------------------------------------------------===//
910 uint64_t Val = llvm::decodeULEB128(P, &Length, nullptr, &Error);
912 llvm::report_fatal_error(Error);
917 /// Read ULEB-encoded key length and data length.
922 llvm::report_fatal_error("key too large");
926 llvm::report_fatal_error("data too large");
953 ModuleFileIndex == 0 ? &MF : MF.TransitiveImports[ModuleFileIndex - 1];
956 unsigned LocalNumDecls = OwningModuleFile->LocalNumDecls;
981 using namespace llvm::support;
984 unsigned N = endian::readNext<uint16_t, llvm::endianness::little>(d);
986 F, endian::readNext<IdentifierID, llvm::endianness::little>(d));
996 F, endian::readNext<IdentifierID, llvm::endianness::little>(d)));
1004 using namespace llvm::support;
1009 F, endian::readNext<uint32_t, llvm::endianness::little>(d));
1011 endian::readNext<uint16_t, llvm::endianness::little>(d);
1013 endian::readNext<uint16_t, llvm::endianness::little>(d);
1026 endian::readNext<DeclID, llvm::endianness::little>(d))))
1035 endian::readNext<DeclID, llvm::endianness::little>(d))))
1043 return llvm::djbHash(a);
1053 assert(n >= 2 && d[n-1] == '\0');
1054 return StringRef((const char*) d, n-1);
1077 using namespace llvm::support;
1080 endian::readNext<IdentifierID, llvm::endianness::little>(d);
1096 using namespace llvm::support;
1099 endian::readNext<IdentifierID, llvm::endianness::little>(d);
1102 DataLen -= sizeof(IdentifierID);
1126 endian::readNext<uint16_t, llvm::endianness::little>(d);
1127 unsigned Bits = endian::readNext<uint16_t, llvm::endianness::little>(d);
1135 DataLen -= sizeof(uint16_t) * 2;
1138 // Token IDs are read-only.
1139 if (HasRevertedTokenIDToIdentifier && II->getTokenID() != tok::identifier)
1140 II->revertTokenIDToIdentifier();
1142 II->setObjCOrBuiltinID(ObjCOrBuiltinID);
1143 assert(II->isExtensionToken() == ExtensionToken &&
1147 II->setIsPoisoned(true);
1148 assert(II->isCPlusPlusOperatorKeyword() == CPlusPlusOperatorKeyword &&
1156 endian::readNext<uint32_t, llvm::endianness::little>(d);
1157 DataLen -= 4;
1168 for (; DataLen > 0; DataLen -= sizeof(DeclID))
1172 endian::readNext<DeclID, llvm::endianness::little>(d))));
1198 ->getDeclName().getAsIdentifierInfo();
1210 llvm::FoldingSetNodeID ID;
1217 ID.AddString(((IdentifierInfo*)Data)->getName());
1239 using namespace llvm::support;
1242 endian::readNext<uint32_t, llvm::endianness::little>(d);
1253 using namespace llvm::support;
1262 F, endian::readNext<IdentifierID, llvm::endianness::little>(d));
1269 F, endian::readNext<uint32_t, llvm::endianness::little>(d))
1293 using namespace llvm::support;
1295 for (unsigned NumDecls = DataLen / sizeof(DeclID); NumDecls; --NumDecls) {
1297 Reader, F, endian::readNext<DeclID, llvm::endianness::little>(d));
1311 llvm::FoldingSetNodeID ID;
1332 llvm::support::endian::readNext<uint32_t, llvm::endianness::little>(d);
1345 using namespace llvm::support;
1348 endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
1354 using namespace llvm::support;
1355 return endian::readNext<uint32_t, llvm::endianness::little, unaligned>(d);
1367 using namespace llvm::support;
1371 NumDecls; --NumDecls) {
1374 endian::readNext<DeclID, llvm::endianness::little, unaligned>(d));
1386 if (llvm::Error Err = Cursor.JumpToBit(Offset)) {
1420 &M, llvm::ArrayRef(
1424 DC->setHasExternalLexicalStorage(true);
1434 if (llvm::Error Err = Cursor.JumpToBit(Offset)) {
1495 D = D->getCanonicalDecl();
1507 if (llvm::Error Err = Cursor.JumpToBit(Offset)) {
1552 void ASTReader::Error(llvm::Error &&Err) const {
1553 llvm::Error RemainingErr =
1557 // Ideally we'd just emit it, but have to handle a possible in-flight
1559 auto NumArgs = Diag.getStorage()->NumDiagArgs;
1578 //===----------------------------------------------------------------------===//
1580 //===----------------------------------------------------------------------===//
1589 FileIDs[-1] = -1; // For unspecified filenames.
1622 llvm::Error ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
1627 // Set the source-location entry cursor to the current position in
1630 // source-location entries as needed.
1634 if (llvm::Error Err = F.Stream.SkipBlock())
1638 if (llvm::Error Err = SLocEntryCursor.EnterSubBlock(SOURCE_MANAGER_BLOCK_ID))
1644 Expected<llvm::BitstreamEntry> MaybeE =
1648 llvm::BitstreamEntry E = MaybeE.get();
1651 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
1652 case llvm::BitstreamEntry::Error:
1653 return llvm::createStringError(std::errc::illegal_byte_sequence,
1655 case llvm::BitstreamEntry::EndBlock:
1656 return llvm::Error::success();
1657 case llvm::BitstreamEntry::Record:
1677 return llvm::Error::success();
1682 llvm::Expected<SourceLocation::UIntTy>
1684 BitstreamCursor &Cursor = F->SLocEntryCursor;
1686 if (llvm::Error Err = Cursor.JumpToBit(F->SLocEntryOffsetsBase +
1687 F->SLocEntryOffsets[Index]))
1690 Expected<llvm::BitstreamEntry> MaybeEntry = Cursor.advance();
1694 llvm::BitstreamEntry Entry = MaybeEntry.get();
1695 if (Entry.Kind != llvm::BitstreamEntry::Record)
1696 return llvm::createStringError(
1698 "incorrectly-formatted source location entry in AST file");
1708 return llvm::createStringError(
1710 "incorrectly-formatted source location entry in AST file");
1714 return F->SLocEntryBaseOffset + Record[0];
1720 GlobalSLocOffsetMap.find(SourceManager::MaxLoadedOffset - SLocOffset - 1);
1723 ModuleFile *F = SLocMapI->second;
1727 auto It = llvm::upper_bound(
1728 llvm::index_range(0, F->LocalNumSLocEntries), SLocOffset,
1730 int ID = F->SLocEntryBaseID + LocalIndex;
1731 std::size_t Index = -ID - 2;
1752 return F->SLocEntryBaseID + *std::prev(It);
1759 if (unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1760 Error("source location entry ID out-of-range for AST file");
1764 // Local helper to read the (possibly-compressed) buffer data following the
1768 StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
1788 // (little-endian 0xFD2FB528).
1789 const llvm::compression::Format F =
1791 ? llvm::compression::Format::Zlib
1792 : llvm::compression::Format::Zstd;
1793 if (const char *Reason = llvm::compression::getReasonIfUnsupported(F)) {
1798 if (llvm::Error E = llvm::compression::decompress(
1799 F, llvm::arrayRefFromStringRef(Blob), Decompressed, Record[0])) {
1801 llvm::toString(std::move(E)));
1804 return llvm::MemoryBuffer::getMemBufferCopy(
1805 llvm::toStringRef(Decompressed), Name);
1807 return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name, true);
1814 ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
1815 if (llvm::Error Err = F->SLocEntryCursor.JumpToBit(
1816 F->SLocEntryOffsetsBase +
1817 F->SLocEntryOffsets[ID - F->SLocEntryBaseID])) {
1822 BitstreamCursor &SLocEntryCursor = F->SLocEntryCursor;
1823 SourceLocation::UIntTy BaseOffset = F->SLocEntryBaseOffset;
1826 Expected<llvm::BitstreamEntry> MaybeEntry = SLocEntryCursor.advance();
1831 llvm::BitstreamEntry Entry = MaybeEntry.get();
1833 if (Entry.Kind != llvm::BitstreamEntry::Record) {
1834 Error("incorrectly-formatted source location entry in AST file");
1848 Error("incorrectly-formatted source location entry in AST file");
1859 // Note that we only check if a File was returned. If it was out-of-date
1866 if (IncludeLoc.isInvalid() && F->Kind != MK_MainFile) {
1881 const unaligned_decl_id_t *FirstDecl = F->FileSortedDecls + Record[6];
1882 assert(F->FileSortedDecls && "FILE_SORTED_DECLS not encountered yet ?");
1884 FileDeclsInfo(F, llvm::ArrayRef(FirstDecl, NumFileDecls));
1892 auto Buffer = ReadBuffer(SLocEntryCursor, File->getName());
1907 if (IncludeLoc.isInvalid() && F->isModule()) {
1942 if (unsigned(-ID) - 2 >= getTotalNumSLocs() || ID > 0) {
1943 Error("source location entry ID out-of-range for AST file");
1948 ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
1949 if (!M->isModule())
1954 return std::make_pair(M->ImportLoc, StringRef(M->ModuleName));
1959 if (F->ImportLoc.isValid())
1960 return F->ImportLoc;
1964 if (F->ImportedBy.empty() || !F->ImportedBy[0]) {
1969 return F->ImportedBy[0]->FirstLoc;
1975 llvm::Error ASTReader::ReadBlockAbbrevs(BitstreamCursor &Cursor,
1978 if (llvm::Error Err = Cursor.EnterSubBlock(BlockID))
1992 if (Code != llvm::bitc::DEFINE_ABBREV) {
1993 if (llvm::Error Err = Cursor.JumpToBit(Offset))
1995 return llvm::Error::success();
1997 if (llvm::Error Err = Cursor.ReadAbbrevRecord())
2015 Info->PragmaName = ReadToken(M, Record, Idx);
2016 Info->Option = ReadToken(M, Record, Idx);
2022 Info->Toks = llvm::ArrayRef(Toks).copy(PP.getPreprocessorAllocator());
2028 Info->Action = static_cast<Sema::PragmaMsStackAction>(Record[Idx++]);
2030 Info->SlotLabel =
2031 llvm::StringRef(SlotLabel).copy(PP.getPreprocessorAllocator());
2032 Info->Alignment = ReadToken(M, Record, Idx);
2062 if (llvm::Error Err = Stream.JumpToBit(Offset)) {
2070 llvm::MutableArrayRef<Token> MacroTokens;
2077 Expected<llvm::BitstreamEntry> MaybeEntry =
2083 llvm::BitstreamEntry Entry = MaybeEntry.get();
2086 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2087 case llvm::BitstreamEntry::Error:
2090 case llvm::BitstreamEntry::EndBlock:
2092 case llvm::BitstreamEntry::Record:
2122 MI->setDefinitionEndLoc(ReadSourceLocation(F, Record, NextIndex));
2123 MI->setIsUsed(Record[NextIndex++]);
2124 MI->setUsedForHeaderGuard(Record[NextIndex++]);
2125 MacroTokens = MI->allocateTokens(Record[NextIndex++],
2128 // Decode function-like macro info.
2137 // Install function-like macro info.
2138 MI->setIsFunctionLike();
2139 if (isC99VarArgs) MI->setIsC99Varargs();
2140 if (isGNUVarArgs) MI->setIsGNUVarargs();
2141 if (hasCommaPasting) MI->setHasCommaPasting();
2142 MI->setParameterList(MacroParams, PP.getPreprocessorAllocator());
2156 PPRec.getPPEntityID(GlobalID - 1, /*isLoaded=*/true);
2192 I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
2196 return LocalID + I->second;
2214 return llvm::xxh3_64bits(buf);
2229 if (llvm::sys::path::is_absolute(a.Filename) && a.Filename == b.Filename)
2245 using namespace llvm::support;
2248 ikey.Size = off_t(endian::readNext<uint64_t, llvm::endianness::little>(d));
2250 time_t(endian::readNext<uint64_t, llvm::endianness::little>(d));
2259 using namespace llvm::support;
2278 M, endian::readNext<IdentifierID, llvm::endianness::little>(d));
2280 assert((End - d) % 4 == 0 &&
2284 endian::readNext<uint32_t, llvm::endianness::little>(d);
2319 for (ModuleFile &I : llvm::reverse(ModuleMgr)) {
2327 if (llvm::Error Err = Cursor.JumpToBit(I.MacroStartOffset)) {
2334 Expected<llvm::BitstreamEntry> MaybeE = Cursor.advanceSkippingSubblocks();
2339 llvm::BitstreamEntry E = MaybeE.get();
2342 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
2343 case llvm::BitstreamEntry::Error:
2346 case llvm::BitstreamEntry::EndBlock:
2349 case llvm::BitstreamEntry::Record: {
2363 if (II->isOutOfDate())
2410 ASTIdentifierLookupTrait Trait(IdTable->getInfoObj().getReader(), M,
2414 IdTable->find_hashed(Name, NameHash, &Trait);
2415 if (Pos == IdTable->end())
2446 if (GlobalIndex->lookupIdentifier(II.getName(), Hits)) {
2462 const_cast<IdentifierInfo *>(II)->setOutOfDate(false);
2475 if (llvm::Error Err =
2486 llvm::SmallVector<ModuleMacroRecord, 8> ModuleMacros;
2493 Expected<llvm::BitstreamEntry> MaybeEntry =
2499 llvm::BitstreamEntry Entry = MaybeEntry.get();
2501 if (Entry.Kind != llvm::BitstreamEntry::Record) {
2539 llvm::SmallVector<ModuleMacro*, 8> Overrides;
2560 // Deserialize the macro directives history in reverse source-order.
2585 Earliest->setPrevious(MD);
2622 if (F.InputFileInfosLoaded[ID - 1].isValid())
2623 return F.InputFileInfosLoaded[ID - 1];
2628 if (llvm::Error Err = Cursor.JumpToBit(F.InputFilesOffsetBase +
2629 F.InputFileOffsets[ID - 1])) {
2665 Expected<llvm::BitstreamEntry> MaybeEntry = Cursor.advance();
2668 llvm::BitstreamEntry Entry = MaybeEntry.get();
2669 assert(Entry.Kind == llvm::BitstreamEntry::Record &&
2684 F.InputFileInfosLoaded[ID - 1] = R;
2695 if (F.InputFilesLoaded[ID-1].getFile())
2696 return F.InputFilesLoaded[ID-1];
2698 if (F.InputFilesLoaded[ID-1].isNotFound())
2704 if (llvm::Error Err = Cursor.JumpToBit(F.InputFilesOffsetBase +
2705 F.InputFileOffsets[ID - 1])) {
2749 F.InputFilesLoaded[ID-1] = InputFile::getNotFound();
2768 F.InputFilesLoaded[ID - 1] = InputFile::getNotFound();
2796 ErrorStr += File->getName();
2802 auto ContentHash = xxh3_64bits(MemBuffOrError.get()->getBuffer());
2809 if (StoredSize != File->getSize())
2810 return Change{Change::Size, StoredSize, File->getSize()};
2812 StoredTime != File->getModificationTime()) {
2814 File->getModificationTime()};
2848 while (!ImportStack.back()->ImportedBy.empty())
2849 ImportStack.push_back(ImportStack.back()->ImportedBy[0]);
2851 // The top-level PCH is stale.
2852 StringRef TopLevelPCHName(ImportStack.back()->FileName);
2854 << *Filename << moduleKindForDiagnostic(ImportStack.back()->Kind)
2857 << llvm::itostr(FileChange.Old.value_or(0))
2858 << llvm::itostr(FileChange.New.value_or(0));
2863 << *Filename << ImportStack[0]->FileName;
2866 << ImportStack[I-1]->FileName << ImportStack[I]->FileName;
2880 F.InputFilesLoaded[ID-1] = IF;
2895 if (Prefix.empty() || Path.empty() || llvm::sys::path::is_absolute(Path) ||
2896 Path == "<built-in>" || Path == "<command line>")
2900 llvm::sys::path::append(Buf, Prefix, Path);
2915 return ResolvedPath->str();
2937 if (llvm::Error Err = Stream.EnterSubBlock(OPTIONS_BLOCK_ID)) {
2947 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
2953 llvm::BitstreamEntry Entry = MaybeEntry.get();
2956 case llvm::BitstreamEntry::Error:
2957 case llvm::BitstreamEntry::SubBlock:
2960 case llvm::BitstreamEntry::EndBlock:
2963 case llvm::BitstreamEntry::Record:
3027 if (llvm::Error Err = Stream.EnterSubBlock(CONTROL_BLOCK_ID)) {
3057 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
3062 llvm::BitstreamEntry Entry = MaybeEntry.get();
3065 case llvm::BitstreamEntry::Error:
3068 case llvm::BitstreamEntry::EndBlock: {
3103 Listener->visitModuleFile(F.FileName, F.Kind);
3105 if (Listener && Listener->needsInputFileVisitation()) {
3106 unsigned N = Listener->needsSystemInputFileVisitation() ? NumInputs
3113 Listener->visitInputFile(
3122 case llvm::BitstreamEntry::SubBlock:
3126 if (llvm::Error Err = Stream.SkipBlock()) {
3146 // FIXME: Allow this for files explicitly specified with -include-pch.
3168 } else if (llvm::Error Err = Stream.SkipBlock()) {
3175 if (llvm::Error Err = Stream.SkipBlock()) {
3182 case llvm::BitstreamEntry::Record:
3209 // or compiled, mark modules on error as out-of-date.
3249 // them can be error-prone and expensive). A module will have a name and
3356 << (ImportedBy ? StringRef(ImportedBy->ModuleName) : StringRef());
3358 Listener->ReadModuleName(F.ModuleName);
3381 if (M && M->Directory) {
3384 // Don't emit module relocation error if we have -fno-validate-pch
3388 auto BuildDir = PP.getFileManager().getOptionalDirectoryRef(Blob);
3389 if (!BuildDir || *BuildDir != M->Directory) {
3392 << F.ModuleName << Blob << M->Directory->getName();
3396 F.BaseDirectory = std::string(M->Directory->getName());
3411 (const llvm::support::unaligned_uint64_t *)Blob.data();
3420 llvm::Error ASTReader::ReadASTBlock(ModuleFile &F,
3424 if (llvm::Error Err = Stream.EnterSubBlock(AST_BLOCK_ID))
3431 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
3434 llvm::BitstreamEntry Entry = MaybeEntry.get();
3437 case llvm::BitstreamEntry::Error:
3438 return llvm::createStringError(
3441 case llvm::BitstreamEntry::EndBlock:
3448 DeclContext *DC = Ctx->getTranslationUnitDecl();
3449 if (DC->hasExternalLexicalStorage() && !Ctx->getLangOpts().CPlusPlus)
3450 DC->setMustBuildLookupTable();
3453 return llvm::Error::success();
3454 case llvm::BitstreamEntry::SubBlock:
3462 if (llvm::Error Err = Stream.SkipBlock())
3464 if (llvm::Error Err = ReadBlockAbbrevs(
3474 if (llvm::Error Err = Stream.SkipBlock())
3476 if (llvm::Error Err =
3485 if (llvm::Error Err = Stream.SkipBlock()) {
3488 if (llvm::Error Err = ReadBlockAbbrevs(F.PreprocessorDetailCursor,
3496 if (!PP.getPreprocessingRecord()->getExternalSource())
3497 PP.getPreprocessingRecord()->SetExternalSource(*this);
3501 if (llvm::Error Err = ReadSourceManagerBlock(F))
3506 if (llvm::Error Err = ReadSubmoduleBlock(F, ClientLoadCapabilities))
3513 if (llvm::Error Err = Stream.SkipBlock())
3515 if (llvm::Error Err = ReadBlockAbbrevs(C, COMMENTS_BLOCK_ID))
3522 if (llvm::Error Err = Stream.SkipBlock())
3528 case llvm::BitstreamEntry::Record:
3571 return llvm::createStringError(
3586 return llvm::createStringError(
3600 DeclContext *TU = ContextObj->getTranslationUnitDecl();
3605 TU->setHasExternalLexicalStorage(true);
3692 return llvm::createStringError(
3736 return llvm::createStringError(std::errc::illegal_byte_sequence,
3737 "invalid special-types record");
3769 return llvm::createStringError(std::errc::illegal_byte_sequence,
3772 // FIXME: Ignore weak undeclared identifiers from non-original PCH
3794 // Introduce the global -> local mapping for selectors within this
3798 // Introduce the local -> global mapping for selectors within this
3802 F.BaseSelectorID - LocalBaseSelectorID));
3822 for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) {
3852 unsigned Idx = 0, End = Record.size() - 1;
3879 Listener->ReadCounter(F, Record[0]);
3898 return llvm::createStringError(std::errc::invalid_argument,
3905 unsigned(-F.SLocEntryBaseID) - F.LocalNumSLocEntries + 1;
3912 std::make_pair(SourceManager::MaxLoadedOffset - F.SLocEntryBaseOffset
3913 - SLocSpaceSize,&F));
3934 return llvm::createStringError(std::errc::illegal_byte_sequence,
3953 return llvm::createStringError(
3966 return llvm::createStringError(std::errc::illegal_byte_sequence,
3982 if (!PP.getPreprocessingRecord()->getExternalSource())
3983 PP.getPreprocessingRecord()->SetExternalSource(*this);
3986 ->allocateLoadedEntities(F.NumPreprocessedEntities);
3990 // Introduce the global -> local mapping for preprocessed entities in
3994 // Introduce the local -> global mapping for preprocessed entities in
3998 F.BasePreprocessedEntityID - LocalBasePreprocessedEntityID));
4011 if (!PP.getPreprocessingRecord()->getExternalSource())
4012 PP.getPreprocessingRecord()->SetExternalSource(*this);
4014 ->allocateSkippedRanges(F.NumPreprocessedSkippedRanges);
4024 return llvm::createStringError(
4041 return llvm::createStringError(
4086 return llvm::createStringError(
4156 return llvm::createStringError(std::errc::illegal_byte_sequence,
4157 "invalid undefined-but-used record");
4189 // FIXME: Deal with macros-only imports.
4196 DeserializationListener->ModuleImportRead(GlobalID, Loc);
4204 return llvm::createStringError(
4214 // Introduce the global -> local mapping for macros within this module.
4217 // Introduce the local -> global mapping for macros within this module.
4220 F.BaseMacroID - LocalBaseMacroID));
4235 return llvm::createStringError(std::errc::illegal_byte_sequence,
4242 return llvm::createStringError(std::errc::illegal_byte_sequence,
4249 return llvm::createStringError(
4263 return llvm::createStringError(std::errc::illegal_byte_sequence,
4270 return llvm::createStringError(std::errc::illegal_byte_sequence,
4292 return llvm::createStringError(std::errc::illegal_byte_sequence,
4341 using namespace llvm::support;
4343 endian::readNext<uint8_t, llvm::endianness::little>(Data));
4344 uint16_t Len = endian::readNext<uint16_t, llvm::endianness::little>(Data);
4361 endian::readNext<uint32_t, llvm::endianness::little>(Data);
4363 endian::readNext<uint32_t, llvm::endianness::little>(Data);
4365 endian::readNext<uint32_t, llvm::endianness::little>(Data);
4367 endian::readNext<uint32_t, llvm::endianness::little>(Data);
4374 static_cast<int>(BaseOffset - Offset)));
4377 mapOffset(MacroIDOffset, OM->BaseMacroID, MacroRemap);
4378 mapOffset(PreprocessedEntityIDOffset, OM->BasePreprocessedEntityID,
4380 mapOffset(SubmoduleIDOffset, OM->BaseSubmoduleID, SubmoduleRemap);
4381 mapOffset(SelectorIDOffset, OM->BaseSelectorID, SelectorRemap);
4394 // top-level AST file is a main file, skip this check because there is no
4399 F.Kind == MK_ImplicitModule && ModuleMgr.begin()->Kind != MK_MainFile) {
4400 // An implicitly-loaded module file should have its module listed in some
4407 // Don't emit module relocation error if we have -fno-validate-pch
4412 if (auto ASTFE = M ? M->getASTFile() : std::nullopt) {
4415 << ASTFE->getName();
4420 << (ImportedBy ? ImportedBy->FileName : "") << F.ModuleMapPath
4425 if (ImportedBy && ImportedBy->Kind == MK_PCH)
4427 << llvm::sys::path::parent_path(F.ModuleMapPath);
4433 assert(M && M->Name == F.ModuleName && "found module with different name");
4440 "top-level import should be verified");
4444 << F.ModuleName << (NotImported ? F.FileName : ImportedBy->FileName)
4445 << ModMap->getName() << F.ModuleMapPath << NotImported;
4488 Listener->ReadModuleMapFile(F.ModuleMapPath);
4496 S.ObjC().MethodPool.find(Method->getSelector());
4501 ObjCMethodList &Start = Method->isInstanceMethod()? Known->second.first
4502 : Known->second.second;
4504 for (ObjCMethodList *List = &Start; List; List = List->getNext()) {
4506 if (List->getMethod() == Method) {
4514 if (List->getNext())
4515 List->setMethod(List->getNext()->getMethod());
4517 List->setMethod(Method);
4522 assert(Owner->NameVisibility != Module::Hidden && "nothing to make visible?");
4524 bool wasHidden = !D->isUnconditionallyVisible();
4525 D->setVisibleDespiteOwningModule();
4538 llvm::SmallPtrSet<Module *, 4> Visited;
4544 if (NameVisibility <= Mod->NameVisibility) {
4550 if (Mod->isUnimportable()) {
4556 Mod->NameVisibility = NameVisibility;
4571 Mod->getExportedModules(Exports);
4586 if (!Def->isUnconditionallyVisible()) {
4588 if (MergedDef->isUnconditionallyVisible())
4589 Def->setVisibleDespiteOwningModule();
4592 Def, MergedDef->getImportedOwningModule(),
4611 std::pair<GlobalModuleIndex *, llvm::Error> Result =
4613 if (llvm::Error Err = std::move(Result.second)) {
4634 Expected<llvm::BitstreamEntry> MaybeEntry = Cursor.advance();
4640 llvm::BitstreamEntry Entry = MaybeEntry.get();
4643 case llvm::BitstreamEntry::Error:
4644 case llvm::BitstreamEntry::EndBlock:
4647 case llvm::BitstreamEntry::Record:
4648 // Ignore top-level records.
4657 case llvm::BitstreamEntry::SubBlock:
4659 if (llvm::Error Err = Cursor.EnterSubBlock(BlockID)) {
4668 if (llvm::Error Err = Cursor.SkipBlock()) {
4681 llvm::TimeTraceScope scope("ReadAST", FileName);
4683 llvm::SaveAndRestore SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
4684 llvm::SaveAndRestore<std::optional<ModuleKind>> SetCurModuleKindRAII(
4704 // to be out-of-date. Just remove it.
4724 llvm::TimeTraceScope Scope2("Read Loaded AST", F.ModuleName);
4727 if (llvm::Error Err = ReadASTBlock(F, ClientLoadCapabilities)) {
4740 if (llvm::Error Err = ReadExtensionBlock(F)) {
4772 // instance are marked out-of-date so that they can be deserialized
4780 II = It->second;
4784 // table of the importing instance and marked as out-of-date. This makes
4785 // ASTReader::get() a no-op, and deserialization will take place on
4790 II->setOutOfDate(true);
4803 // identifiers as out-of-date, so that they are deserialized on first use.
4806 Id.second->setOutOfDate(true);
4841 Unresolved.Mod->Conflicts.push_back(Conflict);
4847 Unresolved.Mod->Imports.insert(ResolvedMod);
4852 Unresolved.Mod->AffectingClangModules.insert(ResolvedMod);
4857 Unresolved.Mod->Exports.push_back(
4875 DeserializationListener->ReaderInitialized(this);
4889 // For any Objective-C class definitions we have already loaded, make sure
4893 loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
4901 // up-to-date. For implicitly-built module files, ensure the corresponding
4902 // timestamp files are up-to-date in this build session.
4905 if (M.Mod->Kind == MK_ImplicitModule &&
4906 M.Mod->InputFilesValidationTimestamp < HSOpts.BuildSessionTimestamp)
4907 updateModuleTimestamp(M.Mod->FileName);
4917 static llvm::Error doesntStartWithASTFileMagic(BitstreamCursor &Stream) {
4922 return llvm::createStringError(std::errc::illegal_byte_sequence,
4925 if (Expected<llvm::SimpleBitstreamCursor::word_t> Res = Stream.Read(8)) {
4927 return llvm::createStringError(
4932 return llvm::Error::success();
4970 << M->ModuleName << M->FileName << (ImportedBy ? true : false)
4971 << (ImportedBy ? StringRef(ImportedBy->ModuleName) : StringRef());
4991 // We couldn't load the module file because it is out-of-date. If the
4992 // client can handle out-of-date, return it.
5006 auto FinalizeOrDropPCM = llvm::make_scope_exit([&]() {
5016 F.SizeInBits = F.Buffer->getBufferSize() * 8;
5019 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
5028 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5033 llvm::BitstreamEntry Entry = MaybeEntry.get();
5036 case llvm::BitstreamEntry::Error:
5037 case llvm::BitstreamEntry::Record:
5038 case llvm::BitstreamEntry::EndBlock:
5039 Error("invalid record at top-level of AST file");
5042 case llvm::BitstreamEntry::SubBlock:
5051 // Check that we didn't try to load a non-module AST file as a module.
5089 if (llvm::Error Err = Stream.SkipBlock()) {
5134 // If -Wno-system-headers (the default), and the first import is as a
5135 // system module, then validation will fail during the as-user import,
5136 // since -Werror flags won't have been validated. However, it's reasonable
5139 // If -Wsystem-headers, the PCM on disk was built with
5140 // -Wno-system-headers, and the first import is as a user module, then
5141 // validation will fail during the as-system import since the PCM on disk
5142 // doesn't guarantee that -Werror was respected. However, the -Werror
5143 // flags were checked during the initial as-user import.
5154 ModuleFile *F, llvm::StringRef StreamData, StringRef Filename,
5161 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
5175 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5181 llvm::BitstreamEntry Entry = MaybeEntry.get();
5184 case llvm::BitstreamEntry::Error:
5185 case llvm::BitstreamEntry::SubBlock:
5188 case llvm::BitstreamEntry::EndBlock:
5191 case llvm::BitstreamEntry::Record:
5208 F->Signature = ASTFileSignature::create(Blob.begin(), Blob.end());
5209 assert(F->Signature != ASTFileSignature::createDummy() &&
5215 F->ASTBlockHash = ASTFileSignature::create(Blob.begin(), Blob.end());
5216 assert(F->ASTBlockHash != ASTFileSignature::createDummy() &&
5238 if (F->PragmaDiagMappings.empty())
5239 F->PragmaDiagMappings.swap(Record);
5241 F->PragmaDiagMappings.insert(F->PragmaDiagMappings.end(),
5246 F->SearchPathUsage = ReadBitVector(Record, Blob);
5250 F->VFSUsage = ReadBitVector(Record, Blob);
5277 llvm::Error ASTReader::ReadExtensionBlock(ModuleFile &F) {
5282 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5285 llvm::BitstreamEntry Entry = MaybeEntry.get();
5288 case llvm::BitstreamEntry::SubBlock:
5289 if (llvm::Error Err = Stream.SkipBlock())
5292 case llvm::BitstreamEntry::EndBlock:
5293 return llvm::Error::success();
5294 case llvm::BitstreamEntry::Error:
5295 return llvm::createStringError(std::errc::illegal_byte_sequence,
5297 case llvm::BitstreamEntry::Record:
5311 return llvm::createStringError(
5320 if (auto Reader = Known->second->createExtensionReader(Metadata, *this,
5330 return llvm::Error::success();
5339 DeserializationListener->DeclRead(
5344 // built-in types. Right now, we just ignore the problem.
5361 if (const TypedefType *Typedef = FileType->getAs<TypedefType>())
5362 Context.setFILEDecl(Typedef->getDecl());
5364 const TagType *Tag = FileType->getAs<TagType>();
5369 Context.setFILEDecl(Tag->getDecl());
5382 if (const TypedefType *Typedef = Jmp_bufType->getAs<TypedefType>())
5383 Context.setjmp_bufDecl(Typedef->getDecl());
5385 const TagType *Tag = Jmp_bufType->getAs<TagType>();
5390 Context.setjmp_bufDecl(Tag->getDecl());
5403 if (const TypedefType *Typedef = Sigjmp_bufType->getAs<TypedefType>())
5404 Context.setsigjmp_bufDecl(Typedef->getDecl());
5406 const TagType *Tag = Sigjmp_bufType->getAs<TagType>();
5408 Context.setsigjmp_bufDecl(Tag->getDecl());
5438 if (const TypedefType *Typedef = Ucontext_tType->getAs<TypedefType>())
5439 Context.setucontext_tDecl(Typedef->getDecl());
5441 const TagType *Tag = Ucontext_tType->getAs<TagType>();
5443 Context.setucontext_tDecl(Tag->getDecl());
5458 // Re-export any modules that were imported by a non-module AST file.
5459 // FIXME: This does not make macro-only imports visible again.
5484 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
5497 Expected<llvm::BitstreamEntry> MaybeEntry =
5504 llvm::BitstreamEntry Entry = MaybeEntry.get();
5506 if (Entry.Kind != llvm::BitstreamEntry::Record)
5547 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
5561 Expected<llvm::BitstreamEntry> MaybeEntry =
5568 llvm::BitstreamEntry Entry = MaybeEntry.get();
5570 if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
5573 if (Entry.Kind != llvm::BitstreamEntry::Record) {
5658 std::unique_ptr<llvm::MemoryBuffer> OwnedBuffer;
5659 llvm::MemoryBuffer *Buffer = ModuleCache.lookupPCM(Filename);
5679 if (llvm::Error Err = doesntStartWithASTFileMagic(Stream)) {
5700 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5706 llvm::BitstreamEntry Entry = MaybeEntry.get();
5709 case llvm::BitstreamEntry::SubBlock: {
5722 if (llvm::Error Err = Stream.SkipBlock()) {
5734 if (llvm::Error Err = Stream.SkipBlock()) {
5745 case llvm::BitstreamEntry::EndBlock:
5749 case llvm::BitstreamEntry::Error:
5752 case llvm::BitstreamEntry::Record:
5792 const llvm::support::unaligned_uint64_t *InputFileOffs =
5793 (const llvm::support::unaligned_uint64_t *)Blob.data();
5803 if (llvm::Error Err =
5888 Expected<llvm::BitstreamEntry> MaybeEntry = Stream.advance();
5893 llvm::BitstreamEntry Entry = MaybeEntry.get();
5896 case llvm::BitstreamEntry::SubBlock:
5897 if (llvm::Error Err = Stream.SkipBlock()) {
5904 case llvm::BitstreamEntry::EndBlock:
5908 case llvm::BitstreamEntry::Error:
5911 case llvm::BitstreamEntry::Record:
5965 llvm::Error ASTReader::ReadSubmoduleBlock(ModuleFile &F,
5968 if (llvm::Error Err = F.Stream.EnterSubBlock(SUBMODULE_BLOCK_ID))
5973 // If we don't know the top-level module, there's no point in doing qualified
5984 Expected<llvm::BitstreamEntry> MaybeEntry =
5988 llvm::BitstreamEntry Entry = MaybeEntry.get();
5991 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
5992 case llvm::BitstreamEntry::Error:
5993 return llvm::createStringError(std::errc::illegal_byte_sequence,
5995 case llvm::BitstreamEntry::EndBlock:
5996 return llvm::Error::success();
5997 case llvm::BitstreamEntry::Record:
6011 return llvm::createStringError(
6028 return llvm::createStringError(std::errc::illegal_byte_sequence,
6056 SubmoduleID GlobalIndex = GlobalID - NUM_PREDEF_SUBMODULE_IDS;
6059 return llvm::createStringError(std::errc::invalid_argument,
6063 if (OptionalFileEntryRef CurFile = CurrentModule->getASTFile()) {
6064 // Don't emit module relocation error if we have -fno-validate-pch
6070 ContextObj->DiagAllocator)
6071 << CurrentModule->getTopLevelModuleName() << CurFile->getName()
6078 CurrentModule->setASTFile(F.File);
6079 CurrentModule->PresumedModuleMapFile = F.ModuleMapPath;
6082 CurrentModule->Kind = Kind;
6089 CurrentModule->DefinitionLoc = DefinitionLoc;
6090 CurrentModule->Signature = F.Signature;
6091 CurrentModule->IsFromModuleFile = true;
6094 CurrentModule->IsSystem = IsSystem || CurrentModule->IsSystem;
6095 CurrentModule->IsExternC = IsExternC;
6096 CurrentModule->InferSubmodules = InferSubmodules;
6097 CurrentModule->InferExplicitSubmodules = InferExplicitSubmodules;
6098 CurrentModule->InferExportWildcard = InferExportWildcard;
6099 CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
6100 CurrentModule->ModuleMapIsPrivate = ModuleMapIsPrivate;
6101 CurrentModule->NamedModuleHasInit = NamedModuleHasInit;
6103 DeserializationListener->ModuleRead(GlobalID, CurrentModule);
6108 CurrentModule->LinkLibraries.clear();
6109 CurrentModule->ConfigMacros.clear();
6110 CurrentModule->UnresolvedConflicts.clear();
6111 CurrentModule->Conflicts.clear();
6114 // requirements will be (re-)added by SUBMODULE_REQUIRES records.
6116 // make it unavailable -- if we got this far, this must be an explicitly
6118 CurrentModule->Requirements.clear();
6119 CurrentModule->MissingHeaders.clear();
6120 CurrentModule->IsUnimportable =
6121 ParentModule && ParentModule->IsUnimportable;
6122 CurrentModule->IsAvailable = !CurrentModule->IsUnimportable;
6132 if (!CurrentModule->getUmbrellaHeaderAsWritten()) {
6148 // FIXME: Re-evaluate this section; maybe only store InputFile IDs instead
6160 CurrentModule->addTopHeaderFilename(*HeaderName);
6169 if (!CurrentModule->getUmbrellaDirAsWritten()) {
6182 // Introduce the global -> local mapping for submodules within this
6186 // Introduce the local -> global mapping for submodules within this
6190 F.BaseSubmoduleID - LocalBaseSubmoduleID));
6234 CurrentModule->UnresolvedExports.clear();
6238 CurrentModule->addRequirement(Blob, Record[0], PP.getLangOpts(),
6244 CurrentModule->LinkLibraries.push_back(
6249 CurrentModule->ConfigMacros.push_back(Blob.str());
6270 ContextObj->addLazyModuleInitializers(CurrentModule, Inits);
6275 CurrentModule->ExportAsModule = Blob.str();
6304 for (unsigned N = Record[Idx++]; N; --N)
6314 for (unsigned N = Record[Idx++]; N; --N) {
6321 for (unsigned N = Record[Idx++]; N; --N) {
6322 LangOpts.OMPTargetTriples.push_back(llvm::Triple(ReadString(Record, Idx)));
6341 for (unsigned N = Record[Idx++]; N; --N) {
6344 for (unsigned N = Record[Idx++]; N; --N) {
6357 #define DIAGOPT(Name, Bits, Default) DiagOpts->Name = Record[Idx++];
6359 DiagOpts->set##Name(static_cast<Type>(Record[Idx++]));
6362 for (unsigned N = Record[Idx++]; N; --N)
6363 DiagOpts->Warnings.push_back(ReadString(Record, Idx));
6364 for (unsigned N = Record[Idx++]; N; --N)
6365 DiagOpts->Remarks.push_back(ReadString(Record, Idx));
6409 for (unsigned N = Record[Idx++]; N; --N) {
6420 for (unsigned N = Record[Idx++]; N; --N) {
6427 for (unsigned N = Record[Idx++]; N; --N) {
6446 for (unsigned N = Record[Idx++]; N; --N) {
6454 for (unsigned N = Record[Idx++]; N; --N) {
6459 for (unsigned N = Record[Idx++]; N; --N) {
6479 ModuleFile *M = I->second;
6480 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID;
6484 llvm::iterator_range<PreprocessingRecord::iterator>
6487 return PPRec->getIteratorsForLoadedRange(Mod.BasePreprocessedEntityID,
6490 return llvm::make_range(PreprocessingRecord::iterator(),
6500 llvm::iterator_range<ASTReader::ModuleDeclIterator>
6502 return llvm::make_range(
6512 ModuleFile *M = I->second;
6513 unsigned LocalIndex = GlobalIndex - M->BasePreprocessedSkippedRangeID;
6514 assert(LocalIndex < M->NumPreprocessedSkippedRanges);
6515 PPSkippedRange RawRange = M->PreprocessedSkippedRangeOffsets[LocalIndex];
6535 if (llvm::Error Err = M.PreprocessorDetailCursor.JumpToBit(
6541 Expected<llvm::BitstreamEntry> MaybeEntry =
6547 llvm::BitstreamEntry Entry = MaybeEntry.get();
6549 if (Entry.Kind != llvm::BitstreamEntry::Record)
6575 PPRec.getLoadedPreprocessedEntity(GlobalID - 1));
6594 DeserializationListener->MacroDefinitionRead(PPID, MD);
6601 StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
6633 ModuleFile &M = *SLocMapI->second;
6678 SourceManager::MaxLoadedOffset - Loc.getOffset() - 1);
6682 if (SLocMapI->second->NumPreprocessedEntities == 0)
6685 ModuleFile &M = *SLocMapI->second;
6710 ReadSourceLocation(M, PPI->getEnd()), Loc)) {
6713 Count = Count - Half - 1;
6722 return M.BasePreprocessedEntityID + (PPI - pp_begin);
6777 // Look in the on-disk hash table for an entry for this file name.
6778 HeaderFileInfoLookupTable::iterator Pos = Table->find(FE);
6779 if (Pos == Table->end())
6816 return DiagStates[BackrefID - 1];
6825 while (Size--) {
6832 DiagnosticMapping &Mapping = NewState->getOrAddMapping(DiagID);
6850 // Implicitly-built modules are reused with different diagnostic
6864 // command line (-w, -Weverything, -Werror, ...) along with any explicit
6865 // -Wblah flags.
6892 while (NumLocations--) {
6940 return RecordLocation(M, M->TypeOffsets[Index - M->BaseTypeIndex].get() +
6941 M->DeclsBlockStartOffset);
6964 BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
6975 if (llvm::Error Err = DeclsCursor.JumpToBit(Loc.Offset)) {
7034 // We want compile-time assurance that we've enumerated all of
7036 // define them out-of-line.
7303 TL.getTypePtr()->template_arguments()[i].getKind()));
7337 TL.getTypePtr()->template_arguments()[I].getKind()));
7405 readTypeLoc(TInfo->getTypeLoc());
7410 return (ID & llvm::maskTrailingOnes<TypeID>(32)) >> Qualifiers::FastWidth;
7430 ModuleFile *OwningModuleFile = &getModuleManager()[ModuleFileIndex - 1];
7435 OwningModuleFile->BaseTypeIndex + getIndexForTypeID(ID)};
7726 assert(Index < TypesLoaded.size() && "Type index out-of-range");
7732 TypesLoaded[Index]->setFromAST();
7734 DeserializationListener->TypeRead(TypeIdx::fromTypeID(ID),
7754 LocalID &= llvm::maskTrailingOnes<TypeID>(32);
7757 LocalID -= NUM_PREDEF_TYPE_IDS << Qualifiers::FastWidth;
7760 ModuleFileIndex ? *F.TransitiveImports[ModuleFileIndex - 1] : F;
7836 if (!D->getDeclContext()) {
7841 const DeclContext *DC = D->getDeclContext()->getRedeclContext();
7849 if (DeclarationName Name = cast<NamedDecl>(D)->getDeclName()) {
7856 assert(II && "non-identifier name in C?");
7857 if (II->isOutOfDate())
7860 DC->lookup(Name);
7863 for (auto *DCDecl : cast<Decl>(D->getLexicalDeclContext())->redecls()) {
7867 DC, [&](Decl::Kind K) { return K == D->getKind(); }, Decls);
7875 Template = CTSD->getSpecializedTemplate();
7876 Args = CTSD->getTemplateArgs().asArray();
7878 Template = VTSD->getSpecializedTemplate();
7879 Args = VTSD->getTemplateArgs().asArray();
7881 if (auto *Tmplt = FD->getPrimaryTemplate()) {
7883 Args = FD->getTemplateSpecializationArgs()->asArray();
7891 Template->loadLazySpecializationsImpl();
7893 Template->loadLazySpecializationsImpl(Args);
7900 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
7902 if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7935 BitstreamCursor &Cursor = Loc.F->DeclsCursor;
7937 if (llvm::Error Err = Cursor.JumpToBit(Loc.Offset)) {
7986 : F.TransitiveImports[OwningModuleFileIndex - 1];
7989 ID -= NUM_PREDEF_DECL_IDS;
7991 uint64_t NewModuleFileIndex = OwningModuleFile->Index + 1;
8001 return M.Index == ModuleFileIndex - 1;
8012 return &getModuleManager()[ModuleFileIndex - 1];
8016 if (!D->isFromASTFile())
8019 return getOwningModuleFile(D->getGlobalID());
8027 return D->getLocation();
8153 DeserializationListener->PredefinedDeclBuilt(ID, NewLoaded);
8165 return OwningModuleFile->BaseDeclIndex + GlobalID.getLocalDeclIndex();
8175 // pre-existing predefined declaration \p D.
8176 auto &Merged = KeyDecls[D->getCanonicalDecl()];
8186 assert(0 && "declaration ID out-of-range for AST file");
8187 Error("declaration ID out-of-range for AST file");
8201 assert(0 && "declaration ID out-of-range for AST file");
8202 Error("declaration ID out-of-range for AST file");
8209 DeserializationListener->DeclRead(ID, DeclsLoaded[Index]);
8265 if (llvm::Error Err = Loc.F->DeclsCursor.JumpToBit(Loc.Offset)) {
8285 llvm::SmallVector<serialization::reader::LazySpecializationInfo, 8> Infos =
8286 It->second.Table.findAll();
8329 llvm::SmallVector<serialization::reader::LazySpecializationInfo, 8> Infos =
8330 It->second.Table.find(HashValue);
8356 const DeclContext *DC, llvm::function_ref<bool(Decl::Kind)> IsKindWeWant,
8379 assert(D->getKind() == K && "wrong kind for lexical decl");
8380 if (!DC->isDeclInLexicalTraversal(D))
8392 Visit(I->second.first, I->second.second);
8438 llvm::DenseMap<FileID, FileDeclsInfo>::iterator I = FileDeclIDs.find(File);
8442 FileDeclsInfo &DInfo = I->second;
8452 llvm::lower_bound(DInfo.Decls, BeginLoc, DIDComp);
8454 --BeginIt;
8456 // If we are pointing at a top-level decl inside an objc container, we need
8462 ->isTopLevelDeclInObjCContainer())
8463 --BeginIt;
8466 llvm::upper_bound(DInfo.Decls, EndLoc, DIDComp);
8479 assert(DC->hasExternalVisibleStorage() && DC == DC->getPrimaryContext() &&
8486 llvm::SmallPtrSet<NamedDecl *, 8> Found;
8494 for (GlobalDeclID ID : It->second.Table.find(Name)) {
8496 if (ND->getDeclName() == Name && Found.insert(ND).second)
8502 OriginalDC ? cast<Decl>(OriginalDC)->getTopLevelOwningNamedModule()
8506 for (GlobalDeclID ID : It->second.Table.find({Name, NamedModule})) {
8508 if (ND->getDeclName() == Name && Found.insert(ND).second)
8516 for (GlobalDeclID ID : It->second.Table.find(Name)) {
8518 if (ND->getDeclName() == Name && Found.insert(ND).second)
8528 if (!DC->hasExternalVisibleStorage())
8540 for (GlobalDeclID ID : It->second.Table.findAll()) {
8542 Decls[ND->getDeclName()].push_back(ND);
8553 SetExternalVisibleDeclsForName(DC, I->first, I->second);
8555 const_cast<DeclContext *>(DC)->setHasExternalVisibleStorage(false);
8561 return I == Lookups.end() ? nullptr : &I->second;
8567 return I == ModuleLocalLookups.end() ? nullptr : &I->second;
8573 return I == TULocalLookups.end() ? nullptr : &I->second;
8578 assert(D->isCanonicalDecl());
8582 return I == LookupTable.end() ? nullptr : &I->second;
8586 assert(D->isCanonicalDecl());
8592 /// Under non-PCH compilation the consumer receives the objc methods
8600 for (auto *I : ImplD->methods())
8601 Consumer->HandleInterestingDecl(DeclGroupRef(I));
8603 Consumer->HandleInterestingDecl(DeclGroupRef(ImplD));
8610 Consumer->HandleInterestingDecl(DeclGroupRef(D));
8614 Consumer->HandleVTable(RD);
8618 this->Consumer = Consumer;
8624 DeserializationListener->ReaderInitialized(this);
8631 TypesLoaded.size() - llvm::count(TypesLoaded.materialized(), QualType());
8633 DeclsLoaded.size() -
8634 llvm::count(DeclsLoaded.materialized(), (Decl *)nullptr);
8636 IdentifiersLoaded.size() -
8637 llvm::count(IdentifiersLoaded, (IdentifierInfo *)nullptr);
8639 MacrosLoaded.size() - llvm::count(MacrosLoaded, (MacroInfo *)nullptr);
8641 SelectorsLoaded.size() - llvm::count(SelectorsLoaded, Selector());
8718 GlobalIndex->printStats();
8736 llvm::errs() << Name << ":\n";
8739 llvm::errs() << " " << (DeclID)I->first << " -> " << I->second->FileName
8744 llvm::errs() << "*** PCH/ModuleFile Remappings:\n";
8753 llvm::errs() << "\n*** PCH/Modules Loaded:";
8759 /// by heap-backed versus mmap'ed memory.
8762 if (llvm::MemoryBuffer *buf = I.Buffer) {
8763 size_t bytes = buf->getBufferSize();
8764 switch (buf->getBufferKind()) {
8765 case llvm::MemoryBuffer::MemoryBuffer_Malloc:
8768 case llvm::MemoryBuffer::MemoryBuffer_MMap:
8784 pushExternalDeclIntoScope(D, D->getDeclName());
8793 SemaObj->CurFPFeatures =
8794 NewOverrides.applyOverrides(SemaObj->getLangOpts());
8800 SemaObj->addDeclWithEffects(FD, FD->getFunctionEffects());
8802 SemaObj->addDeclWithEffects(BD, BD->getFunctionEffects());
8808 SemaObj->OpenCLFeatures = OpenCLExtensions;
8821 if (!SemaObj->StdNamespace)
8822 SemaObj->StdNamespace = SemaDeclRefs[I].getRawValue();
8823 if (!SemaObj->StdBadAlloc)
8824 SemaObj->StdBadAlloc = SemaDeclRefs[I + 1].getRawValue();
8825 if (!SemaObj->StdAlignValT)
8826 SemaObj->StdAlignValT = SemaDeclRefs[I + 2].getRawValue();
8834 SemaObj->ActOnPragmaOptimize(/* On = */ false, OptimizeOffPragmaLocation);
8835 if (PragmaMSStructState != -1)
8836 SemaObj->ActOnPragmaMSStruct((PragmaMSStructKind)PragmaMSStructState);
8838 SemaObj->ActOnPragmaMSPointersToMembers(
8843 SemaObj->CUDA().ForceHostDeviceDepth = ForceHostDeviceDepth;
8853 SemaObj->AlignPackStack.DefaultValue &&
8855 SemaObj->AlignPackStack.Stack.emplace_back(
8857 SemaObj->AlignPackStack.CurrentValue,
8858 SemaObj->AlignPackStack.CurrentPragmaLocation,
8863 llvm::ArrayRef(PragmaAlignPackStack).drop_front(DropFirst ? 1 : 0)) {
8864 SemaObj->AlignPackStack.Stack.emplace_back(
8869 SemaObj->AlignPackStack.DefaultValue &&
8873 SemaObj->AlignPackStack.CurrentValue = *PragmaAlignPackCurrentValue;
8874 SemaObj->AlignPackStack.CurrentPragmaLocation =
8880 // to the current value to ensure that fp-pragma state is preserved after
8885 SemaObj->FpPragmaStack.DefaultValue &&
8887 SemaObj->FpPragmaStack.Stack.emplace_back(
8888 FpPragmaStack.front().SlotLabel, SemaObj->FpPragmaStack.CurrentValue,
8889 SemaObj->FpPragmaStack.CurrentPragmaLocation,
8894 llvm::ArrayRef(FpPragmaStack).drop_front(DropFirst ? 1 : 0))
8895 SemaObj->FpPragmaStack.Stack.emplace_back(
8898 assert(*FpPragmaCurrentValue == SemaObj->FpPragmaStack.DefaultValue &&
8902 SemaObj->FpPragmaStack.CurrentValue = *FpPragmaCurrentValue;
8903 SemaObj->FpPragmaStack.CurrentPragmaLocation = FpPragmaCurrentLocation;
8907 // For non-modular AST files, restore visiblity of modules.
8912 SemaObj->makeModuleVisible(Imported, Import.ImportLoc);
8940 if (GlobalIndex->lookupIdentifier(Name, Hits)) {
8955 /// An identifier-lookup iterator that enumerates all of the
8996 --Index;
9003 Current = IdTable->key_begin();
9004 End = IdTable->key_end();
9030 StringRef result = Current->Next();
9048 GlobalIndex->createIdentifierIterator());
9086 ASTSelectorLookupTable::iterator Pos = PoolTable->find(Sel);
9087 if (Pos == PoolTable->end())
9098 Reader.DeserializationListener->SelectorRead(Data.ID, Sel);
9138 for (ObjCMethodDecl *M : llvm::reverse(Methods))
9195 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
9205 void ASTReader::ReadMismatchingDeleteExpressions(llvm::MapVector<
9206 FieldDecl *, llvm::SmallVector<std::pair<SourceLocation, bool>, 4>> &
9264 llvm::SmallSetVector<const TypedefNameDecl *, 4> &Decls) {
9276 llvm::SmallSetVector<Decl *, 4> &Decls) {
9291 // implementation of -Wselector.
9292 unsigned int DataSize = ReferencedSelectorsData.size()-1;
9347 llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
9357 LT->D = ReadDecl(*FMod, LateParsed, Idx);
9358 LT->FPO = FPOptions::getFromOpaqueInt(LateParsed[Idx++]);
9360 ModuleFile *F = getOwningModuleFile(LT->D);
9364 LT->Toks.reserve(TokN);
9366 LT->Toks.push_back(ReadToken(*F, LateParsed, Idx));
9376 if (!Lambda->getLambdaContextDecl())
9380 std::make_pair(Lambda->getLambdaContextDecl()->getCanonicalDecl(),
9381 Lambda->getLambdaIndexInContext());
9386 Iter->second->isFromASTFile() && Lambda->getFirstDecl() == Lambda) {
9388 cast<CXXRecordDecl>(Iter->second)->getMostRecentDecl();
9389 Lambda->setPreviousDecl(Previous);
9394 const_cast<QualType &>(Lambda->TypeForDecl->CanonicalType) =
9395 Previous->TypeForDecl->CanonicalType;
9411 assert(ID && "Non-zero identifier ID required");
9416 DeserializationListener->IdentifierRead(ID, II);
9419 /// Set the globally-visible declarations associated with the given
9426 /// \param II an IdentifierInfo that refers to one or more globally-visible
9432 /// \param Decls if non-null, this vector will be populated with the set of
9456 Decls->push_back(D);
9460 // Introduce this declaration into the translation-unit scope
9473 unsigned LocalID = ID & llvm::maskTrailingOnes<IdentifierID>(32);
9476 assert(getModuleManager().size() > ModuleFileIndex - 1);
9478 ModuleFile &MF = getModuleManager()[ModuleFileIndex - 1];
9495 assert(Index >= M->BaseIdentifierID);
9496 unsigned LocalIndex = Index - M->BaseIdentifierID;
9498 M->IdentifierTableData + M->IdentifierOffsets[LocalIndex];
9508 DeserializationListener->IdentifierRead(ID, &II);
9526 LocalID &= llvm::maskTrailingOnes<IdentifierID>(32);
9528 ModuleFileIndex ? M.TransitiveImports[ModuleFileIndex - 1] : &M;
9532 LocalID -= NUM_PREDEF_IDENT_IDS;
9534 return ((IdentifierID)(MF->Index + 1) << 32) | LocalID;
9546 ID -= NUM_PREDEF_MACRO_IDS;
9551 ModuleFile *M = I->second;
9552 unsigned Index = ID - M->BaseMacroID;
9554 ReadMacroRecord(*M, M->MacroOffsetsBase + M->MacroOffsets[Index]);
9557 DeserializationListener->MacroRead(ID + NUM_PREDEF_MACRO_IDS,
9572 = M.MacroRemap.find(LocalID - NUM_PREDEF_MACRO_IDS);
9575 return LocalID + I->second;
9587 = M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS);
9591 return LocalID + I->second;
9605 return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS];
9616 return I == GlobalSubmoduleMap.end() ? nullptr : I->second;
9621 return getModuleManager().pch_modules().end()[-IndexFromEnd];
9629 // For a file representing a module, use the submodule ID of the top-level
9633 if (M->isModule())
9634 return ((M->BaseSubmoduleID + NUM_PREDEF_SUBMODULE_IDS) << 1) | 1;
9637 auto I = llvm::find(PCHModules, M);
9639 return (I - PCHModules.end()) << 1;
9651 StringRef ModuleName = llvm::sys::path::filename(MF.OriginalSourceFileName);
9652 StringRef FileName = llvm::sys::path::filename(MF.FileName);
9654 llvm::sys::path::parent_path(MF.FileName),
9664 return I->second ? EK_Never : EK_Always;
9680 if (SelectorsLoaded[ID - 1].getAsOpaquePtr() == nullptr) {
9684 ModuleFile &M = *I->second;
9686 unsigned Idx = ID - M.BaseSelectorID - NUM_PREDEF_SELECTOR_IDS;
9687 SelectorsLoaded[ID - 1] =
9690 DeserializationListener->SelectorRead(ID, SelectorsLoaded[ID - 1]);
9693 return SelectorsLoaded[ID - 1];
9714 = M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS);
9718 return LocalID + I->second;
9780 while (NumParams--)
9796 while (NumTemplateArgs--)
9804 while (NumDecls--) {
9882 BOMInit->setSourceOrder(SourceOrder);
9930 Template? T->getTypeLoc().getBeginLoc() : SourceLocation(),
9931 T->getTypeLoc(), ColonColonLoc);
9960 llvm::BitVector ASTReader::ReadBitVector(const RecordData &Record,
9964 llvm::BitVector Ret = llvm::BitVector(Count, false);
9972 /// Read a floating-point value
9973 llvm::APFloat ASTRecordReader::readAPFloat(const llvm::fltSemantics &Sem) {
9974 return llvm::APFloat(Sem, readAPInt());
10019 return VersionTuple(Major, Minor - 1);
10020 return VersionTuple(Major, Minor - 1, Subminor - 1);
10039 llvm::function_ref<void()> Fn) {
10042 SemaObj->runWithSufficientStackSpace(Loc, Fn);
10055 /// Record that the given ID maps to the given switch-case
10063 /// Retrieve the switch-case statement with the given ID.
10070 CurrSwitchCaseStmts->clear();
10082 BitstreamCursor &Cursor = I->first;
10083 serialization::ModuleFile &F = *I->second;
10088 Expected<llvm::BitstreamEntry> MaybeEntry =
10095 llvm::BitstreamEntry Entry = MaybeEntry.get();
10098 case llvm::BitstreamEntry::SubBlock: // Handled for us already.
10099 case llvm::BitstreamEntry::Error:
10102 case llvm::BitstreamEntry::EndBlock:
10104 case llvm::BitstreamEntry::Record:
10131 llvm::DenseMap<FileID, std::map<unsigned, RawComment *>>
10134 SourceLocation CommentLoc = C->getBeginLoc();
10147 llvm::function_ref<void(const serialization::InputFileInfo &IFI,
10163 llvm::function_ref<void(const serialization::InputFile &IF,
10178 llvm::function_ref<void(FileEntryRef FE)> Visitor) {
10195 // If any identifiers with corresponding top-level declarations have
10198 llvm::DenseMap<IdentifierInfo *, SmallVector<Decl *, 2>>;
10214 FD->setType(GetType(PendingDeducedFunctionTypes[I].second));
10216 if (auto *DT = FD->getReturnType()->getContainedDeducedType()) {
10219 if (DT->isDeduced()) {
10221 {FD->getCanonicalDecl(), FD->getReturnType()});
10238 VD->setType(GetType(PendingDeducedVarTypes[I].second));
10255 // Make the most recent of the top-level declarations visible.
10258 IdentifierInfo *II = TLD->first;
10259 for (unsigned I = 0, N = TLD->second.size(); I != N; ++I) {
10260 pushExternalDeclIntoScope(cast<NamedDecl>(TLD->second[I]), II);
10269 // Initialize the macro history from chained-PCHs ahead of module imports.
10273 if (!Info.M->isModule())
10280 if (Info.M->isModule())
10293 Info.D->setDeclContextsImpl(SemaDC, LexicalDC, getContext());
10309 ExtensionsPair.first->getASTContext(),
10310 ExtensionsPair.second->getASTContext(), NonEquivalentDecls,
10319 Ivar->setDeclContextsImpl(PrevIvar->getDeclContext(),
10320 Ivar->getLexicalDeclContext(),
10322 getContext().setPrimaryMergedDecl(Ivar, PrevIvar->getCanonicalDecl());
10325 ExtensionsPair.first->setInvalidDecl();
10326 ExtensionsPair.second->getClassInterface()
10327 ->getDefinition()
10328 ->setIvarList(nullptr);
10331 Diag(IvarPair.first->getLocation(),
10333 << IvarPair.first->getIdentifier();
10334 Diag(IvarPair.second->getLocation(), diag::note_previous_definition);
10346 // If we deserialized any C++ or Objective-C class definitions, any
10347 // Objective-C protocol definitions, or any redeclarable templates, make sure
10352 if (const TagType *TagT = dyn_cast<TagType>(TD->getTypeForDecl())) {
10354 const_cast<TagType*>(TagT)->decl = TD;
10359 R = R->getPreviousDecl()) {
10361 cast<CXXRecordDecl>(R)->isThisDeclarationADefinition() &&
10363 cast<CXXRecordDecl>(R)->DefinitionData = RD->DefinitionData;
10372 const_cast<ObjCInterfaceType *>(cast<ObjCInterfaceType>(ID->TypeForDecl))
10373 ->Decl = ID;
10375 for (auto *R = getMostRecentExistingDecl(ID); R; R = R->getPreviousDecl())
10376 cast<ObjCInterfaceDecl>(R)->Data = ID->Data;
10382 for (auto *R = getMostRecentExistingDecl(PD); R; R = R->getPreviousDecl())
10383 cast<ObjCProtocolDecl>(R)->Data = PD->Data;
10388 auto RTD = cast<RedeclarableTemplateDecl>(D)->getCanonicalDecl();
10389 for (auto *R = getMostRecentExistingDecl(RTD); R; R = R->getPreviousDecl())
10390 cast<RedeclarableTemplateDecl>(R)->Common = RTD->Common;
10397 return VD->isThisDeclarationADefinition() ||
10398 VD->isThisDeclarationADemotedDefinition();
10401 return TD->isThisDeclarationADefinition() ||
10402 TD->isThisDeclarationADemotedDefinition();
10405 return FD->isThisDeclarationADefinition() || PendingBodies.count(FD);
10408 return hasDefinitionImpl(RTD->getTemplatedDecl(), hasDefinitionImpl);
10424 Module *PM = Previous->getOwningModule();
10425 Module *DM = D->getOwningModule();
10426 Diag(D->getLocation(), diag::warn_decls_in_multiple_modules)
10427 << cast<NamedDecl>(Previous) << PM->getTopLevelModuleName()
10428 << (DM ? DM->getTopLevelModuleName() : "global module");
10429 Diag(Previous->getLocation(), diag::note_also_found);
10440 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
10443 if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn)) {
10444 FD->setLazyBody(PB->second);
10449 if (!FD->isLateTemplateParsed() &&
10450 !NonConstDefn->isLateTemplateParsed() &&
10455 FD->getODRHash() != NonConstDefn->getODRHash()) {
10458 } else if (FD->getLexicalParent()->isFileContext() &&
10459 NonConstDefn->getLexicalParent()->isFileContext()) {
10460 // Only diagnose out-of-line method definitions. If they are
10470 ObjCMethodDecl *MD = cast<ObjCMethodDecl>(PB->first);
10471 if (!getContext().getLangOpts().Modules || !MD->hasBody())
10472 MD->setLazyBody(PB->second);
10478 RD->addedMember(MD);
10498 // odr-merging problems, so we can produce better diagnostics for them.
10504 Merge.first->buildLookup();
10505 Merge.first->decls_begin();
10506 Merge.first->bases_begin();
10507 Merge.first->vbases_begin();
10510 RD->decls_begin();
10511 RD->bases_begin();
10512 RD->vbases_begin();
10520 Merge.first->decls_begin();
10522 D->decls_begin();
10530 Merge.first->decls_begin();
10532 InterfacePair.first->decls_begin();
10539 Merge.first->buildLookup();
10540 Merge.first->decls_begin();
10541 Merge.first->getBody();
10543 FD->buildLookup();
10544 FD->decls_begin();
10545 FD->getBody();
10553 Merge.first->decls_begin();
10555 Enum->decls_begin();
10564 Merge.first->decls_begin();
10566 ProtocolPair.first->decls_begin();
10574 // PendingOdrMergeChecks. Don't turn this into a range-based for loop!
10579 // like implicitly-declared special member functions. This isn't entirely
10582 if (D->isImplicit())
10585 DeclContext *CanonDef = D->getDeclContext();
10588 const Decl *DCanon = D->getCanonicalDecl();
10590 for (auto *RI : D->redecls()) {
10591 if (RI->getLexicalDeclContext() == CanonDef) {
10605 llvm::SmallVector<const NamedDecl*, 4> Candidates;
10606 for (auto *CanonMember : CanonDef->decls()) {
10607 if (CanonMember->getCanonicalDecl() == DCanon) {
10617 if (ND->getDeclName() == D->getDeclName())
10625 D->setInvalidDecl();
10634 Diag(D->getLocation(), diag::err_module_odr_violation_missing_decl)
10639 Diag(cast<Decl>(CanonDef)->getLocation(),
10643 Diag(Candidates[I]->getLocation(),
10661 // Issue any pending ODR-failure diagnostics.
10685 Diag(Merge.first->getLocation(),
10691 // Issue any pending ODR-failure diagnostics for RecordDecl in C/ObjC. Note
10785 ReadTimer->startTimer();
10793 // are finished, to avoid recursively re-calling finishPendingActions().
10796 --NumCurrentElementsDeserializing;
10811 auto *FPT = Update.second->getType()->castAs<FunctionProtoType>();
10812 auto ESI = FPT->getExtProtoInfo().ExceptionSpec;
10814 Listener->ResolvedExceptionSpec(cast<FunctionDecl>(Update.second));
10815 for (auto *Redecl : Update.second->redecls())
10833 (void)UndeducedFD->getMostRecentDecl();
10837 ReadTimer->stopTimer();
10853 for (auto *ND : It->second)
10854 SemaObj->IdResolver.RemoveDecl(ND);
10858 It->second.clear();
10862 if (SemaObj->IdResolver.tryAddTopLevelDecl(D, Name) && SemaObj->TUScope) {
10863 SemaObj->TUScope->AddDecl(D);
10864 } else if (SemaObj->TUScope) {
10868 if (llvm::is_contained(SemaObj->IdResolver.decls(Name), D))
10869 SemaObj->TUScope->AddDecl(D);
10882 std::unique_ptr<llvm::Timer> ReadTimer)
10903 auto BlockName = Ext->getExtensionMetadata().BlockName;
10921 return SemaObj ? SemaObj->IdResolver : DummyIdResolver;
10924 Expected<unsigned> ASTRecordReader::readRecord(llvm::BitstreamCursor &Cursor,
10930 //===----------------------------------------------------------------------===//
10932 ////===----------------------------------------------------------------------===//
10947 #include "llvm/Frontend/OpenMP/OMP.inc"
10961 switch (llvm::omp::Clause(Record.readInt())) {
10962 case llvm::omp::OMPC_if:
10965 case llvm::omp::OMPC_final:
10968 case llvm::omp::OMPC_num_threads:
10971 case llvm::omp::OMPC_safelen:
10974 case llvm::omp::OMPC_simdlen:
10977 case llvm::omp::OMPC_sizes: {
10982 case llvm::omp::OMPC_permutation: {
10987 case llvm::omp::OMPC_full:
10990 case llvm::omp::OMPC_partial:
10993 case llvm::omp::OMPC_allocator:
10996 case llvm::omp::OMPC_collapse:
10999 case llvm::omp::OMPC_default:
11002 case llvm::omp::OMPC_proc_bind:
11005 case llvm::omp::OMPC_schedule:
11008 case llvm::omp::OMPC_ordered:
11011 case llvm::omp::OMPC_nowait:
11014 case llvm::omp::OMPC_untied:
11017 case llvm::omp::OMPC_mergeable:
11020 case llvm::omp::OMPC_read:
11023 case llvm::omp::OMPC_write:
11026 case llvm::omp::OMPC_update:
11029 case llvm::omp::OMPC_capture:
11032 case llvm::omp::OMPC_compare:
11035 case llvm::omp::OMPC_fail:
11038 case llvm::omp::OMPC_seq_cst:
11041 case llvm::omp::OMPC_acq_rel:
11044 case llvm::omp::OMPC_absent: {
11049 case llvm::omp::OMPC_holds:
11052 case llvm::omp::OMPC_contains: {
11057 case llvm::omp::OMPC_no_openmp:
11060 case llvm::omp::OMPC_no_openmp_routines:
11063 case llvm::omp::OMPC_no_parallelism:
11066 case llvm::omp::OMPC_acquire:
11069 case llvm::omp::OMPC_release:
11072 case llvm::omp::OMPC_relaxed:
11075 case llvm::omp::OMPC_weak:
11078 case llvm::omp::OMPC_threads:
11081 case llvm::omp::OMPC_simd:
11084 case llvm::omp::OMPC_nogroup:
11087 case llvm::omp::OMPC_unified_address:
11090 case llvm::omp::OMPC_unified_shared_memory:
11093 case llvm::omp::OMPC_reverse_offload:
11096 case llvm::omp::OMPC_dynamic_allocators:
11099 case llvm::omp::OMPC_atomic_default_mem_order:
11102 case llvm::omp::OMPC_at:
11105 case llvm::omp::OMPC_severity:
11108 case llvm::omp::OMPC_message:
11111 case llvm::omp::OMPC_private:
11114 case llvm::omp::OMPC_firstprivate:
11117 case llvm::omp::OMPC_lastprivate:
11120 case llvm::omp::OMPC_shared:
11123 case llvm::omp::OMPC_reduction: {
11129 case llvm::omp::OMPC_task_reduction:
11132 case llvm::omp::OMPC_in_reduction:
11135 case llvm::omp::OMPC_linear:
11138 case llvm::omp::OMPC_aligned:
11141 case llvm::omp::OMPC_copyin:
11144 case llvm::omp::OMPC_copyprivate:
11147 case llvm::omp::OMPC_flush:
11150 case llvm::omp::OMPC_depobj:
11153 case llvm::omp::OMPC_depend: {
11159 case llvm::omp::OMPC_device:
11162 case llvm::omp::OMPC_map: {
11171 case llvm::omp::OMPC_num_teams:
11174 case llvm::omp::OMPC_thread_limit:
11177 case llvm::omp::OMPC_priority:
11180 case llvm::omp::OMPC_grainsize:
11183 case llvm::omp::OMPC_num_tasks:
11186 case llvm::omp::OMPC_hint:
11189 case llvm::omp::OMPC_dist_schedule:
11192 case llvm::omp::OMPC_defaultmap:
11195 case llvm::omp::OMPC_to: {
11204 case llvm::omp::OMPC_from: {
11213 case llvm::omp::OMPC_use_device_ptr: {
11222 case llvm::omp::OMPC_use_device_addr: {
11231 case llvm::omp::OMPC_is_device_ptr: {
11240 case llvm::omp::OMPC_has_device_addr: {
11249 case llvm::omp::OMPC_allocate:
11252 case llvm::omp::OMPC_nontemporal:
11255 case llvm::omp::OMPC_inclusive:
11258 case llvm::omp::OMPC_exclusive:
11261 case llvm::omp::OMPC_order:
11264 case llvm::omp::OMPC_init:
11267 case llvm::omp::OMPC_use:
11270 case llvm::omp::OMPC_destroy:
11273 case llvm::omp::OMPC_novariants:
11276 case llvm::omp::OMPC_nocontext:
11279 case llvm::omp::OMPC_detach:
11282 case llvm::omp::OMPC_uses_allocators:
11285 case llvm::omp::OMPC_affinity:
11288 case llvm::omp::OMPC_filter:
11291 case llvm::omp::OMPC_bind:
11294 case llvm::omp::OMPC_align:
11297 case llvm::omp::OMPC_ompx_dyn_cgroup_mem:
11300 case llvm::omp::OMPC_doacross: {
11306 case llvm::omp::OMPC_ompx_attribute:
11309 case llvm::omp::OMPC_ompx_bare:
11313 case llvm::omp::Enum: \
11315 #include "llvm/Frontend/OpenMP/OMPKinds.def"
11322 C->setLocStart(Record.readSourceLocation());
11323 C->setLocEnd(Record.readSourceLocation());
11329 C->setPreInitStmt(Record.readSubStmt(),
11335 C->setPostUpdateExpr(Record.readSubExpr());
11340 C->setNameModifier(static_cast<OpenMPDirectiveKind>(Record.readInt()));
11341 C->setNameModifierLoc(Record.readSourceLocation());
11342 C->setColonLoc(Record.readSourceLocation());
11343 C->setCondition(Record.readSubExpr());
11344 C->setLParenLoc(Record.readSourceLocation());
11349 C->setCondition(Record.readSubExpr());
11350 C->setLParenLoc(Record.readSourceLocation());
11355 C->setNumThreads(Record.readSubExpr());
11356 C->setLParenLoc(Record.readSourceLocation());
11360 C->setSafelen(Record.readSubExpr());
11361 C->setLParenLoc(Record.readSourceLocation());
11365 C->setSimdlen(Record.readSubExpr());
11366 C->setLParenLoc(Record.readSourceLocation());
11370 for (Expr *&E : C->getSizesRefs())
11372 C->setLParenLoc(Record.readSourceLocation());
11376 for (Expr *&E : C->getArgsRefs())
11378 C->setLParenLoc(Record.readSourceLocation());
11384 C->setFactor(Record.readSubExpr());
11385 C->setLParenLoc(Record.readSourceLocation());
11389 C->setAllocator(Record.readExpr());
11390 C->setLParenLoc(Record.readSourceLocation());
11394 C->setNumForLoops(Record.readSubExpr());
11395 C->setLParenLoc(Record.readSourceLocation());
11399 C->setDefaultKind(static_cast<llvm::omp::DefaultKind>(Record.readInt()));
11400 C->setLParenLoc(Record.readSourceLocation());
11401 C->setDefaultKindKwLoc(Record.readSourceLocation());
11405 C->setProcBindKind(static_cast<llvm::omp::ProcBindKind>(Record.readInt()));
11406 C->setLParenLoc(Record.readSourceLocation());
11407 C->setProcBindKindKwLoc(Record.readSourceLocation());
11412 C->setScheduleKind(
11414 C->setFirstScheduleModifier(
11416 C->setSecondScheduleModifier(
11418 C->setChunkSize(Record.readSubExpr());
11419 C->setLParenLoc(Record.readSourceLocation());
11420 C->setFirstScheduleModifierLoc(Record.readSourceLocation());
11421 C->setSecondScheduleModifierLoc(Record.readSourceLocation());
11422 C->setScheduleKindLoc(Record.readSourceLocation());
11423 C->setCommaLoc(Record.readSourceLocation());
11427 C->setNumForLoops(Record.readSubExpr());
11428 for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11429 C->setLoopNumIterations(I, Record.readSubExpr());
11430 for (unsigned I = 0, E = C->NumberOfLoops; I < E; ++I)
11431 C->setLoopCounter(I, Record.readSubExpr());
11432 C->setLParenLoc(Record.readSourceLocation());
11436 C->setEventHandler(Record.readSubExpr());
11437 C->setLParenLoc(Record.readSourceLocation());
11451 if (C->isExtended()) {
11452 C->setLParenLoc(Record.readSourceLocation());
11453 C->setArgumentLoc(Record.readSourceLocation());
11454 C->setDependencyKind(Record.readEnum<OpenMPDependClauseKind>());
11465 C->setLParenLoc(Record.readSourceLocation());
11467 C->setFailParameterLoc(FailParameterLoc);
11469 C->setFailParameter(CKind);
11473 unsigned Count = C->getDirectiveKinds().size();
11474 C->setLParenLoc(Record.readSourceLocation());
11475 llvm::SmallVector<OpenMPDirectiveKind, 4> DKVec;
11480 C->setDirectiveKinds(DKVec);
11484 C->setExpr(Record.readExpr());
11485 C->setLParenLoc(Record.readSourceLocation());
11489 unsigned Count = C->getDirectiveKinds().size();
11490 C->setLParenLoc(Record.readSourceLocation());
11491 llvm::SmallVector<OpenMPDirectiveKind, 4> DKVec;
11496 C->setDirectiveKinds(DKVec);
11525 unsigned NumVars = C->varlist_size();
11530 C->setVarRefs(Vars);
11531 C->setIsTarget(Record.readBool());
11532 C->setIsTargetSync(Record.readBool());
11533 C->setLParenLoc(Record.readSourceLocation());
11534 C->setVarLoc(Record.readSourceLocation());
11538 C->setInteropVar(Record.readSubExpr());
11539 C->setLParenLoc(Record.readSourceLocation());
11540 C->setVarLoc(Record.readSourceLocation());
11544 C->setInteropVar(Record.readSubExpr());
11545 C->setLParenLoc(Record.readSourceLocation());
11546 C->setVarLoc(Record.readSourceLocation());
11551 C->setCondition(Record.readSubExpr());
11552 C->setLParenLoc(Record.readSourceLocation());
11557 C->setCondition(Record.readSubExpr());
11558 C->setLParenLoc(Record.readSourceLocation());
11574 C->setAtomicDefaultMemOrderKind(
11576 C->setLParenLoc(Record.readSourceLocation());
11577 C->setAtomicDefaultMemOrderKindKwLoc(Record.readSourceLocation());
11581 C->setAtKind(static_cast<OpenMPAtClauseKind>(Record.readInt()));
11582 C->setLParenLoc(Record.readSourceLocation());
11583 C->setAtKindKwLoc(Record.readSourceLocation());
11587 C->setSeverityKind(static_cast<OpenMPSeverityClauseKind>(Record.readInt()));
11588 C->setLParenLoc(Record.readSourceLocation());
11589 C->setSeverityKindKwLoc(Record.readSourceLocation());
11593 C->setMessageString(Record.readSubExpr());
11594 C->setLParenLoc(Record.readSourceLocation());
11598 C->setLParenLoc(Record.readSourceLocation());
11599 unsigned NumVars = C->varlist_size();
11604 C->setVarRefs(Vars);
11608 C->setPrivateCopies(Vars);
11613 C->setLParenLoc(Record.readSourceLocation());
11614 unsigned NumVars = C->varlist_size();
11619 C->setVarRefs(Vars);
11623 C->setPrivateCopies(Vars);
11627 C->setInits(Vars);
11632 C->setLParenLoc(Record.readSourceLocation());
11633 C->setKind(Record.readEnum<OpenMPLastprivateModifier>());
11634 C->setKindLoc(Record.readSourceLocation());
11635 C->setColonLoc(Record.readSourceLocation());
11636 unsigned NumVars = C->varlist_size();
11641 C->setVarRefs(Vars);
11645 C->setPrivateCopies(Vars);
11649 C->setSourceExprs(Vars);
11653 C->setDestinationExprs(Vars);
11657 C->setAssignmentOps(Vars);
11661 C->setLParenLoc(Record.readSourceLocation());
11662 unsigned NumVars = C->varlist_size();
11667 C->setVarRefs(Vars);
11672 C->setLParenLoc(Record.readSourceLocation());
11673 C->setModifierLoc(Record.readSourceLocation());
11674 C->setColonLoc(Record.readSourceLocation());
11677 C->setQualifierLoc(NNSL);
11678 C->setNameInfo(DNI);
11680 unsigned NumVars = C->varlist_size();
11685 C->setVarRefs(Vars);
11689 C->setPrivates(Vars);
11693 C->setLHSExprs(Vars);
11697 C->setRHSExprs(Vars);
11701 C->setReductionOps(Vars);
11702 if (C->getModifier() == OMPC_REDUCTION_inscan) {
11706 C->setInscanCopyOps(Vars);
11710 C->setInscanCopyArrayTemps(Vars);
11714 C->setInscanCopyArrayElems(Vars);
11720 C->setLParenLoc(Record.readSourceLocation());
11721 C->setColonLoc(Record.readSourceLocation());
11724 C->setQualifierLoc(NNSL);
11725 C->setNameInfo(DNI);
11727 unsigned NumVars = C->varlist_size();
11732 C->setVarRefs(Vars);
11736 C->setPrivates(Vars);
11740 C->setLHSExprs(Vars);
11744 C->setRHSExprs(Vars);
11748 C->setReductionOps(Vars);
11753 C->setLParenLoc(Record.readSourceLocation());
11754 C->setColonLoc(Record.readSourceLocation());
11757 C->setQualifierLoc(NNSL);
11758 C->setNameInfo(DNI);
11760 unsigned NumVars = C->varlist_size();
11765 C->setVarRefs(Vars);
11769 C->setPrivates(Vars);
11773 C->setLHSExprs(Vars);
11777 C->setRHSExprs(Vars);
11781 C->setReductionOps(Vars);
11785 C->setTaskgroupDescriptors(Vars);
11790 C->setLParenLoc(Record.readSourceLocation());
11791 C->setColonLoc(Record.readSourceLocation());
11792 C->setModifier(static_cast<OpenMPLinearClauseKind>(Record.readInt()));
11793 C->setModifierLoc(Record.readSourceLocation());
11794 unsigned NumVars = C->varlist_size();
11799 C->setVarRefs(Vars);
11803 C->setPrivates(Vars);
11807 C->setInits(Vars);
11811 C->setUpdates(Vars);
11815 C->setFinals(Vars);
11816 C->setStep(Record.readSubExpr());
11817 C->setCalcStep(Record.readSubExpr());
11821 C->setUsedExprs(Vars);
11825 C->setLParenLoc(Record.readSourceLocation());
11826 C->setColonLoc(Record.readSourceLocation());
11827 unsigned NumVars = C->varlist_size();
11832 C->setVarRefs(Vars);
11833 C->setAlignment(Record.readSubExpr());
11837 C->setLParenLoc(Record.readSourceLocation());
11838 unsigned NumVars = C->varlist_size();
11843 C->setVarRefs(Exprs);
11847 C->setSourceExprs(Exprs);
11851 C->setDestinationExprs(Exprs);
11855 C->setAssignmentOps(Exprs);
11859 C->setLParenLoc(Record.readSourceLocation());
11860 unsigned NumVars = C->varlist_size();
11865 C->setVarRefs(Exprs);
11869 C->setSourceExprs(Exprs);
11873 C->setDestinationExprs(Exprs);
11877 C->setAssignmentOps(Exprs);
11881 C->setLParenLoc(Record.readSourceLocation());
11882 unsigned NumVars = C->varlist_size();
11887 C->setVarRefs(Vars);
11891 C->setDepobj(Record.readSubExpr());
11892 C->setLParenLoc(Record.readSourceLocation());
11896 C->setLParenLoc(Record.readSourceLocation());
11897 C->setModifier(Record.readSubExpr());
11898 C->setDependencyKind(
11900 C->setDependencyLoc(Record.readSourceLocation());
11901 C->setColonLoc(Record.readSourceLocation());
11902 C->setOmpAllMemoryLoc(Record.readSourceLocation());
11903 unsigned NumVars = C->varlist_size();
11908 C->setVarRefs(Vars);
11909 for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I)
11910 C->setLoopData(I, Record.readSubExpr());
11915 C->setModifier(Record.readEnum<OpenMPDeviceClauseModifier>());
11916 C->setDevice(Record.readSubExpr());
11917 C->setModifierLoc(Record.readSourceLocation());
11918 C->setLParenLoc(Record.readSourceLocation());
11922 C->setLParenLoc(Record.readSourceLocation());
11925 C->setMapTypeModifier(
11927 C->setMapTypeModifierLoc(I, Record.readSourceLocation());
11928 if (C->getMapTypeModifier(I) == OMPC_MAP_MODIFIER_iterator)
11931 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
11932 C->setMapperIdInfo(Record.readDeclarationNameInfo());
11933 C->setMapType(
11935 C->setMapLoc(Record.readSourceLocation());
11936 C->setColonLoc(Record.readSourceLocation());
11937 auto NumVars = C->varlist_size();
11938 auto UniqueDecls = C->getUniqueDeclarationsNum();
11939 auto TotalLists = C->getTotalComponentListNum();
11940 auto TotalComponents = C->getTotalComponentsNum();
11946 C->setVarRefs(Vars);
11952 C->setUDMapperRefs(UDMappers);
11955 C->setIteratorModifier(Record.readExpr());
11961 C->setUniqueDecls(Decls);
11967 C->setDeclNumLists(ListsPerDecl);
11973 C->setComponentListSizes(ListSizes);
11983 C->setComponents(Components, ListSizes);
11987 C->setFirstAllocateModifier(Record.readEnum<OpenMPAllocateClauseModifier>());
11988 C->setSecondAllocateModifier(Record.readEnum<OpenMPAllocateClauseModifier>());
11989 C->setLParenLoc(Record.readSourceLocation());
11990 C->setColonLoc(Record.readSourceLocation());
11991 C->setAllocator(Record.readSubExpr());
11992 C->setAlignment(Record.readSubExpr());
11993 unsigned NumVars = C->varlist_size();
11998 C->setVarRefs(Vars);
12003 C->setLParenLoc(Record.readSourceLocation());
12004 unsigned NumVars = C->varlist_size();
12009 C->setVarRefs(Vars);
12014 C->setLParenLoc(Record.readSourceLocation());
12015 unsigned NumVars = C->varlist_size();
12020 C->setVarRefs(Vars);
12025 C->setPriority(Record.readSubExpr());
12026 C->setLParenLoc(Record.readSourceLocation());
12031 C->setModifier(Record.readEnum<OpenMPGrainsizeClauseModifier>());
12032 C->setGrainsize(Record.readSubExpr());
12033 C->setModifierLoc(Record.readSourceLocation());
12034 C->setLParenLoc(Record.readSourceLocation());
12039 C->setModifier(Record.readEnum<OpenMPNumTasksClauseModifier>());
12040 C->setNumTasks(Record.readSubExpr());
12041 C->setModifierLoc(Record.readSourceLocation());
12042 C->setLParenLoc(Record.readSourceLocation());
12046 C->setHint(Record.readSubExpr());
12047 C->setLParenLoc(Record.readSourceLocation());
12052 C->setDistScheduleKind(
12054 C->setChunkSize(Record.readSubExpr());
12055 C->setLParenLoc(Record.readSourceLocation());
12056 C->setDistScheduleKindLoc(Record.readSourceLocation());
12057 C->setCommaLoc(Record.readSourceLocation());
12061 C->setDefaultmapKind(
12063 C->setDefaultmapModifier(
12065 C->setLParenLoc(Record.readSourceLocation());
12066 C->setDefaultmapModifierLoc(Record.readSourceLocation());
12067 C->setDefaultmapKindLoc(Record.readSourceLocation());
12071 C->setLParenLoc(Record.readSourceLocation());
12073 C->setMotionModifier(
12075 C->setMotionModifierLoc(I, Record.readSourceLocation());
12077 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12078 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12079 C->setColonLoc(Record.readSourceLocation());
12080 auto NumVars = C->varlist_size();
12081 auto UniqueDecls = C->getUniqueDeclarationsNum();
12082 auto TotalLists = C->getTotalComponentListNum();
12083 auto TotalComponents = C->getTotalComponentsNum();
12089 C->setVarRefs(Vars);
12095 C->setUDMapperRefs(UDMappers);
12101 C->setUniqueDecls(Decls);
12107 C->setDeclNumLists(ListsPerDecl);
12113 C->setComponentListSizes(ListSizes);
12123 C->setComponents(Components, ListSizes);
12127 C->setLParenLoc(Record.readSourceLocation());
12129 C->setMotionModifier(
12131 C->setMotionModifierLoc(I, Record.readSourceLocation());
12133 C->setMapperQualifierLoc(Record.readNestedNameSpecifierLoc());
12134 C->setMapperIdInfo(Record.readDeclarationNameInfo());
12135 C->setColonLoc(Record.readSourceLocation());
12136 auto NumVars = C->varlist_size();
12137 auto UniqueDecls = C->getUniqueDeclarationsNum();
12138 auto TotalLists = C->getTotalComponentListNum();
12139 auto TotalComponents = C->getTotalComponentsNum();
12145 C->setVarRefs(Vars);
12151 C->setUDMapperRefs(UDMappers);
12157 C->setUniqueDecls(Decls);
12163 C->setDeclNumLists(ListsPerDecl);
12169 C->setComponentListSizes(ListSizes);
12179 C->setComponents(Components, ListSizes);
12183 C->setLParenLoc(Record.readSourceLocation());
12184 auto NumVars = C->varlist_size();
12185 auto UniqueDecls = C->getUniqueDeclarationsNum();
12186 auto TotalLists = C->getTotalComponentListNum();
12187 auto TotalComponents = C->getTotalComponentsNum();
12193 C->setVarRefs(Vars);
12197 C->setPrivateCopies(Vars);
12201 C->setInits(Vars);
12207 C->setUniqueDecls(Decls);
12213 C->setDeclNumLists(ListsPerDecl);
12219 C->setComponentListSizes(ListSizes);
12229 C->setComponents(Components, ListSizes);
12233 C->setLParenLoc(Record.readSourceLocation());
12234 auto NumVars = C->varlist_size();
12235 auto UniqueDecls = C->getUniqueDeclarationsNum();
12236 auto TotalLists = C->getTotalComponentListNum();
12237 auto TotalComponents = C->getTotalComponentsNum();
12243 C->setVarRefs(Vars);
12249 C->setUniqueDecls(Decls);
12255 C->setDeclNumLists(ListsPerDecl);
12261 C->setComponentListSizes(ListSizes);
12271 C->setComponents(Components, ListSizes);
12275 C->setLParenLoc(Record.readSourceLocation());
12276 auto NumVars = C->varlist_size();
12277 auto UniqueDecls = C->getUniqueDeclarationsNum();
12278 auto TotalLists = C->getTotalComponentListNum();
12279 auto TotalComponents = C->getTotalComponentsNum();
12285 C->setVarRefs(Vars);
12292 C->setUniqueDecls(Decls);
12298 C->setDeclNumLists(ListsPerDecl);
12304 C->setComponentListSizes(ListSizes);
12314 C->setComponents(Components, ListSizes);
12318 C->setLParenLoc(Record.readSourceLocation());
12319 auto NumVars = C->varlist_size();
12320 auto UniqueDecls = C->getUniqueDeclarationsNum();
12321 auto TotalLists = C->getTotalComponentListNum();
12322 auto TotalComponents = C->getTotalComponentsNum();
12328 C->setVarRefs(Vars);
12335 C->setUniqueDecls(Decls);
12341 C->setDeclNumLists(ListsPerDecl);
12347 C->setComponentListSizes(ListSizes);
12357 C->setComponents(Components, ListSizes);
12361 C->setLParenLoc(Record.readSourceLocation());
12362 unsigned NumVars = C->varlist_size();
12367 C->setVarRefs(Vars);
12372 C->setPrivateRefs(Vars);
12376 C->setLParenLoc(Record.readSourceLocation());
12377 unsigned NumVars = C->varlist_size();
12382 C->setVarRefs(Vars);
12386 C->setLParenLoc(Record.readSourceLocation());
12387 unsigned NumVars = C->varlist_size();
12392 C->setVarRefs(Vars);
12396 C->setLParenLoc(Record.readSourceLocation());
12397 unsigned NumOfAllocators = C->getNumberOfAllocators();
12407 C->setAllocatorsData(Data);
12411 C->setLParenLoc(Record.readSourceLocation());
12412 C->setModifier(Record.readSubExpr());
12413 C->setColonLoc(Record.readSourceLocation());
12414 unsigned NumOfLocators = C->varlist_size();
12419 C->setVarRefs(Locators);
12423 C->setKind(Record.readEnum<OpenMPOrderClauseKind>());
12424 C->setModifier(Record.readEnum<OpenMPOrderClauseModifier>());
12425 C->setLParenLoc(Record.readSourceLocation());
12426 C->setKindKwLoc(Record.readSourceLocation());
12427 C->setModifierKwLoc(Record.readSourceLocation());
12432 C->setThreadID(Record.readSubExpr());
12433 C->setLParenLoc(Record.readSourceLocation());
12437 C->setBindKind(Record.readEnum<OpenMPBindClauseKind>());
12438 C->setLParenLoc(Record.readSourceLocation());
12439 C->setBindKindLoc(Record.readSourceLocation());
12443 C->setAlignment(Record.readExpr());
12444 C->setLParenLoc(Record.readSourceLocation());
12449 C->setSize(Record.readSubExpr());
12450 C->setLParenLoc(Record.readSourceLocation());
12454 C->setLParenLoc(Record.readSourceLocation());
12455 C->setDependenceType(
12457 C->setDependenceLoc(Record.readSourceLocation());
12458 C->setColonLoc(Record.readSourceLocation());
12459 unsigned NumVars = C->varlist_size();
12464 C->setVarRefs(Vars);
12465 for (unsigned I = 0, E = C->getNumLoops(); I < E; ++I)
12466 C->setLoopData(I, Record.readSubExpr());
12472 C->setAttrs(Attrs);
12473 C->setLocStart(Record.readSourceLocation());
12474 C->setLParenLoc(Record.readSourceLocation());
12475 C->setLocEnd(Record.readSourceLocation());
12484 Set.Kind = readEnum<llvm::omp::TraitSet>();
12487 Selector.Kind = readEnum<llvm::omp::TraitSelector>();
12493 Property.Kind = readEnum<llvm::omp::TraitProperty>();
12502 if (Reader->ReadingKind == ASTReader::Read_Stmt) {
12506 SmallVector<OMPClause *, 4> Clauses(Data->getNumClauses());
12507 for (unsigned I = 0, E = Data->getNumClauses(); I < E; ++I)
12509 Data->setClauses(Clauses);
12510 if (Data->hasAssociatedStmt())
12511 Data->setAssociatedStmt(readStmt());
12512 for (unsigned I = 0, E = Data->getNumChildren(); I < E; ++I)
12513 Data->getChildren()[I] = readStmt();
12518 llvm::SmallVector<Expr *> VarList;
12526 llvm::SmallVector<Expr *> ExprList;
12559 llvm::SmallVector<Expr *> VarList;
12568 llvm::SmallVector<Expr *> IntExprs;
12600 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12606 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12612 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12618 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12624 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12630 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12636 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12642 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12648 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12654 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12660 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12668 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12677 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12686 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12695 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12709 llvm::SmallVector<Expr *> QueueIdExprs = readOpenACCIntExprList();
12717 llvm::SmallVector<DeviceTypeArgument> Archs;
12732 llvm::SmallVector<Expr *> VarList = readOpenACCVarList();
12756 llvm::SmallVector<Expr *> SizeExprs;
12765 llvm::SmallVector<OpenACCGangKind> GangKinds;
12766 llvm::SmallVector<Expr *> Exprs;
12806 llvm::FoldingSetNodeID ID;
12815 if (M->isHeaderLikeModule())
12818 if (M->isGlobalModule())
12821 StringRef PrimaryModuleName = M->getPrimaryModuleInterfaceName();