summaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:08 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:08 +0000
commitbab175ec4b075c8076ba14c762900392533f6ee4 (patch)
tree01f4f29419a2cb10abe13c1e63cd2a66068b0137 /lib/Serialization
parent8b7a8012d223fac5d17d16a66bb39168a9a1dfc0 (diff)
downloadsrc-test2-bab175ec4b075c8076ba14c762900392533f6ee4.tar.gz
src-test2-bab175ec4b075c8076ba14c762900392533f6ee4.zip
Notes
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTCommon.cpp5
-rw-r--r--lib/Serialization/ASTCommon.h1
-rw-r--r--lib/Serialization/ASTReader.cpp1067
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp1427
-rw-r--r--lib/Serialization/ASTReaderInternals.h17
-rw-r--r--lib/Serialization/ASTReaderStmt.cpp2196
-rw-r--r--lib/Serialization/ASTWriter.cpp297
-rw-r--r--lib/Serialization/ASTWriterDecl.cpp75
-rw-r--r--lib/Serialization/ASTWriterStmt.cpp109
-rw-r--r--lib/Serialization/GeneratePCH.cpp27
-rw-r--r--lib/Serialization/GlobalModuleIndex.cpp12
-rw-r--r--lib/Serialization/Module.cpp1
-rw-r--r--lib/Serialization/ModuleFileExtension.cpp1
-rw-r--r--lib/Serialization/ModuleManager.cpp101
-rw-r--r--lib/Serialization/MultiOnDiskHashTable.h4
15 files changed, 3050 insertions, 2290 deletions
diff --git a/lib/Serialization/ASTCommon.cpp b/lib/Serialization/ASTCommon.cpp
index 22ead2b57c72..ecd249cc5025 100644
--- a/lib/Serialization/ASTCommon.cpp
+++ b/lib/Serialization/ASTCommon.cpp
@@ -183,6 +183,7 @@ serialization::getDefinitiveDeclContext(const DeclContext *DC) {
case Decl::ExternCContext:
case Decl::Namespace:
case Decl::LinkageSpec:
+ case Decl::Export:
return nullptr;
// C/C++ tag types can only be defined in one place.
@@ -284,6 +285,7 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) {
case Decl::NonTypeTemplateParm:
case Decl::TemplateTemplateParm:
case Decl::Using:
+ case Decl::UsingPack:
case Decl::ObjCMethod:
case Decl::ObjCCategory:
case Decl::ObjCCategoryImpl:
@@ -291,6 +293,7 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) {
case Decl::ObjCProperty:
case Decl::ObjCCompatibleAlias:
case Decl::LinkageSpec:
+ case Decl::Export:
case Decl::ObjCPropertyImpl:
case Decl::PragmaComment:
case Decl::PragmaDetectMismatch:
@@ -307,6 +310,8 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) {
case Decl::OMPCapturedExpr:
case Decl::OMPDeclareReduction:
case Decl::BuiltinTemplate:
+ case Decl::Decomposition:
+ case Decl::Binding:
return false;
// These indirectly derive from Redeclarable<T> but are not actually
diff --git a/lib/Serialization/ASTCommon.h b/lib/Serialization/ASTCommon.h
index 641165e4178f..cbc5f04738b1 100644
--- a/lib/Serialization/ASTCommon.h
+++ b/lib/Serialization/ASTCommon.h
@@ -30,6 +30,7 @@ enum DeclUpdateKind {
UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER,
UPD_CXX_INSTANTIATED_CLASS_DEFINITION,
UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT,
+ UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER,
UPD_CXX_RESOLVED_DTOR_DELETE,
UPD_CXX_RESOLVED_EXCEPTION_SPEC,
UPD_CXX_DEDUCED_RETURN_TYPE,
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 9d1554a826aa..fe2c53b77e1d 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -1,4 +1,4 @@
-//===-- ASTReader.cpp - AST File Reader ----------------------------------===//
+//===-- ASTReader.cpp - AST File Reader -----------------------------------===//
//
// The LLVM Compiler Infrastructure
//
@@ -16,39 +16,62 @@
#include "ASTReaderInternals.h"
#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTMutationListener.h"
+#include "clang/AST/ASTUnresolvedSet.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclGroup.h"
+#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
-#include "clang/Frontend/PCHContainerOperations.h"
-#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/RawCommentList.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeLocVisitor.h"
+#include "clang/AST/UnresolvedSet.h"
+#include "clang/Basic/CommentOptions.h"
#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/ExceptionSpecificationType.h"
#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/ObjCRuntime.h"
+#include "clang/Basic/OperatorKinds.h"
+#include "clang/Basic/Sanitizers.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SourceManagerInternals.h"
+#include "clang/Basic/Specifiers.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Basic/TargetOptions.h"
+#include "clang/Basic/TokenKinds.h"
#include "clang/Basic/Version.h"
#include "clang/Basic/VersionTuple.h"
-#include "clang/Frontend/Utils.h"
+#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/ModuleMap.h"
#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/Sema.h"
+#include "clang/Sema/Weak.h"
#include "clang/Serialization/ASTDeserializationListener.h"
#include "clang/Serialization/GlobalModuleIndex.h"
#include "clang/Serialization/ModuleManager.h"
#include "clang/Serialization/SerializationDiagnostic.h"
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/Triple.h"
#include "llvm/Bitcode/BitstreamReader.h"
#include "llvm/Support/Compression.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -56,16 +79,27 @@
#include "llvm/Support/SaveAndRestore.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
+#include <cassert>
+#include <cstdint>
#include <cstdio>
+#include <cstring>
+#include <ctime>
#include <iterator>
+#include <limits>
+#include <map>
+#include <memory>
+#include <new>
+#include <string>
#include <system_error>
+#include <tuple>
+#include <utility>
+#include <vector>
using namespace clang;
using namespace clang::serialization;
using namespace clang::serialization::reader;
using llvm::BitstreamCursor;
-
//===----------------------------------------------------------------------===//
// ChainedASTReaderListener implementation
//===----------------------------------------------------------------------===//
@@ -75,14 +109,17 @@ ChainedASTReaderListener::ReadFullVersionInformation(StringRef FullVersion) {
return First->ReadFullVersionInformation(FullVersion) ||
Second->ReadFullVersionInformation(FullVersion);
}
+
void ChainedASTReaderListener::ReadModuleName(StringRef ModuleName) {
First->ReadModuleName(ModuleName);
Second->ReadModuleName(ModuleName);
}
+
void ChainedASTReaderListener::ReadModuleMapFile(StringRef ModuleMapPath) {
First->ReadModuleMapFile(ModuleMapPath);
Second->ReadModuleMapFile(ModuleMapPath);
}
+
bool
ChainedASTReaderListener::ReadLanguageOptions(const LangOptions &LangOpts,
bool Complain,
@@ -92,6 +129,7 @@ ChainedASTReaderListener::ReadLanguageOptions(const LangOptions &LangOpts,
Second->ReadLanguageOptions(LangOpts, Complain,
AllowCompatibleDifferences);
}
+
bool ChainedASTReaderListener::ReadTargetOptions(
const TargetOptions &TargetOpts, bool Complain,
bool AllowCompatibleDifferences) {
@@ -100,11 +138,13 @@ bool ChainedASTReaderListener::ReadTargetOptions(
Second->ReadTargetOptions(TargetOpts, Complain,
AllowCompatibleDifferences);
}
+
bool ChainedASTReaderListener::ReadDiagnosticOptions(
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts, bool Complain) {
return First->ReadDiagnosticOptions(DiagOpts, Complain) ||
Second->ReadDiagnosticOptions(DiagOpts, Complain);
}
+
bool
ChainedASTReaderListener::ReadFileSystemOptions(const FileSystemOptions &FSOpts,
bool Complain) {
@@ -120,6 +160,7 @@ bool ChainedASTReaderListener::ReadHeaderSearchOptions(
Second->ReadHeaderSearchOptions(HSOpts, SpecificModuleCachePath,
Complain);
}
+
bool ChainedASTReaderListener::ReadPreprocessorOptions(
const PreprocessorOptions &PPOpts, bool Complain,
std::string &SuggestedPredefines) {
@@ -145,6 +186,7 @@ void ChainedASTReaderListener::visitModuleFile(StringRef Filename,
First->visitModuleFile(Filename, Kind);
Second->visitModuleFile(Filename, Kind);
}
+
bool ChainedASTReaderListener::visitInputFile(StringRef Filename,
bool isSystem,
bool isOverridden,
@@ -336,11 +378,13 @@ bool PCHValidator::ReadTargetOptions(const TargetOptions &TargetOpts,
}
namespace {
+
typedef llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/> >
MacroDefinitionsMap;
typedef llvm::DenseMap<DeclarationName, SmallVector<NamedDecl *, 8> >
DeclsMap;
-}
+
+} // end anonymous namespace
static bool checkDiagnosticGroupMappings(DiagnosticsEngine &StoredDiags,
DiagnosticsEngine &Diags,
@@ -496,12 +540,16 @@ collectMacroDefinitions(const PreprocessorOptions &PPOpts,
/// against the preprocessor options in an existing preprocessor.
///
/// \param Diags If non-null, produce diagnostics for any mismatches incurred.
+/// \param Validate If true, validate preprocessor options. If false, allow
+/// macros defined by \p ExistingPPOpts to override those defined by
+/// \p PPOpts in SuggestedPredefines.
static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
const PreprocessorOptions &ExistingPPOpts,
DiagnosticsEngine *Diags,
FileManager &FileMgr,
std::string &SuggestedPredefines,
- const LangOptions &LangOpts) {
+ const LangOptions &LangOpts,
+ bool Validate = true) {
// Check macro definitions.
MacroDefinitionsMap ASTFileMacros;
collectMacroDefinitions(PPOpts, ASTFileMacros);
@@ -517,7 +565,7 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
// Check whether we know anything about this macro name or not.
llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/> >::iterator Known
= ASTFileMacros.find(MacroName);
- if (Known == ASTFileMacros.end()) {
+ if (!Validate || Known == ASTFileMacros.end()) {
// FIXME: Check whether this identifier was referenced anywhere in the
// AST file. If so, we should reject the AST file. Unfortunately, this
// information isn't in the control block. What shall we do about it?
@@ -560,7 +608,7 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
}
// Check whether we're using predefines.
- if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines) {
+ if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines && Validate) {
if (Diags) {
Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines;
}
@@ -569,7 +617,7 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
// Detailed record is important since it is used for the module cache hash.
if (LangOpts.Modules &&
- PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord) {
+ PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord && Validate) {
if (Diags) {
Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord;
}
@@ -618,6 +666,19 @@ bool PCHValidator::ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
PP.getLangOpts());
}
+bool SimpleASTReaderListener::ReadPreprocessorOptions(
+ const PreprocessorOptions &PPOpts,
+ bool Complain,
+ std::string &SuggestedPredefines) {
+ return checkPreprocessorOptions(PPOpts,
+ PP.getPreprocessorOpts(),
+ nullptr,
+ PP.getFileManager(),
+ SuggestedPredefines,
+ PP.getLangOpts(),
+ false);
+}
+
/// Check the header search options deserialized from the control block
/// against the header search options in an existing preprocessor.
///
@@ -662,13 +723,10 @@ void ASTReader::setDeserializationListener(ASTDeserializationListener *Listener,
OwnsDeserializationListener = TakeOwnership;
}
-
-
unsigned ASTSelectorLookupTrait::ComputeHash(Selector Sel) {
return serialization::ComputeHash(Sel);
}
-
std::pair<unsigned, unsigned>
ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
using namespace llvm::support;
@@ -677,7 +735,7 @@ ASTSelectorLookupTrait::ReadKeyDataLength(const unsigned char*& d) {
return std::make_pair(KeyLen, DataLen);
}
-ASTSelectorLookupTrait::internal_key_type
+ASTSelectorLookupTrait::internal_key_type
ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
using namespace llvm::support;
SelectorTable &SelTable = Reader.getContext().Selectors;
@@ -698,8 +756,8 @@ ASTSelectorLookupTrait::ReadKey(const unsigned char* d, unsigned) {
return SelTable.getSelector(N, Args.data());
}
-ASTSelectorLookupTrait::data_type
-ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
+ASTSelectorLookupTrait::data_type
+ASTSelectorLookupTrait::ReadData(Selector, const unsigned char* d,
unsigned DataLen) {
using namespace llvm::support;
@@ -1138,7 +1196,7 @@ bool ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
RecordData Record;
while (true) {
llvm::BitstreamEntry E = SLocEntryCursor.advanceSkippingSubblocks();
-
+
switch (E.Kind) {
case llvm::BitstreamEntry::SubBlock: // Handled for us already.
case llvm::BitstreamEntry::Error:
@@ -1150,7 +1208,7 @@ bool ASTReader::ReadSourceManagerBlock(ModuleFile &F) {
// The interesting case.
break;
}
-
+
// Read a record.
Record.clear();
StringRef Blob;
@@ -1246,7 +1304,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
Error("incorrectly-formatted source location entry in AST file");
return true;
}
-
+
RecordData Record;
StringRef Blob;
switch (SLocEntryCursor.readRecord(Entry.ID, Record, &Blob)) {
@@ -1312,8 +1370,7 @@ bool ASTReader::ReadSLocEntry(int ID) {
SrcMgr::CharacteristicKind
FileCharacter = (SrcMgr::CharacteristicKind)Record[2];
SourceLocation IncludeLoc = ReadSourceLocation(*F, Record[1]);
- if (IncludeLoc.isInvalid() &&
- (F->Kind == MK_ImplicitModule || F->Kind == MK_ExplicitModule)) {
+ if (IncludeLoc.isInvalid() && F->isModule()) {
IncludeLoc = getImportLocation(F);
}
@@ -1351,7 +1408,7 @@ std::pair<SourceLocation, StringRef> ASTReader::getModuleImportLoc(int ID) {
// Find which module file this entry lands in.
ModuleFile *M = GlobalSLocEntryMap.find(-ID)->second;
- if (M->Kind != MK_ImplicitModule && M->Kind != MK_ExplicitModule)
+ if (!M->isModule())
return std::make_pair(SourceLocation(), "");
// FIXME: Can we map this down to a particular submodule? That would be
@@ -1363,7 +1420,7 @@ std::pair<SourceLocation, StringRef> ASTReader::getModuleImportLoc(int ID) {
SourceLocation ASTReader::getImportLocation(ModuleFile *F) {
if (F->ImportLoc.isValid())
return F->ImportLoc;
-
+
// Otherwise we have a PCH. It's considered to be "imported" at the first
// location of its includer.
if (F->ImportedBy.empty() || !F->ImportedBy[0]) {
@@ -1425,7 +1482,7 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
// be able to reseek within the block and read entries.
unsigned Flags = BitstreamCursor::AF_DontPopBlockAtEnd;
llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks(Flags);
-
+
switch (Entry.Kind) {
case llvm::BitstreamEntry::SubBlock: // Handled for us already.
case llvm::BitstreamEntry::Error:
@@ -1517,13 +1574,13 @@ MacroInfo *ASTReader::ReadMacroRecord(ModuleFile &F, uint64_t Offset) {
}
}
-PreprocessedEntityID
+PreprocessedEntityID
ASTReader::getGlobalPreprocessedEntityID(ModuleFile &M, unsigned LocalID) const {
- ContinuousRangeMap<uint32_t, int, 2>::const_iterator
+ ContinuousRangeMap<uint32_t, int, 2>::const_iterator
I = M.PreprocessedEntityRemap.find(LocalID - NUM_PREDEF_PP_ENTITY_IDS);
- assert(I != M.PreprocessedEntityRemap.end()
+ assert(I != M.PreprocessedEntityRemap.end()
&& "Invalid index into preprocessed entity index remap");
-
+
return LocalID + I->second;
}
@@ -1531,22 +1588,21 @@ unsigned HeaderFileInfoTrait::ComputeHash(internal_key_ref ikey) {
return llvm::hash_combine(ikey.Size, ikey.ModTime);
}
-HeaderFileInfoTrait::internal_key_type
+HeaderFileInfoTrait::internal_key_type
HeaderFileInfoTrait::GetInternalKey(const FileEntry *FE) {
internal_key_type ikey = {FE->getSize(),
M.HasTimestamps ? FE->getModificationTime() : 0,
FE->getName(), /*Imported*/ false};
return ikey;
}
-
+
bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
if (a.Size != b.Size || (a.ModTime && b.ModTime && a.ModTime != b.ModTime))
return false;
- if (llvm::sys::path::is_absolute(a.Filename) &&
- strcmp(a.Filename, b.Filename) == 0)
+ if (llvm::sys::path::is_absolute(a.Filename) && a.Filename == b.Filename)
return true;
-
+
// Determine whether the actual files are equivalent.
FileManager &FileMgr = Reader.getFileManager();
auto GetFile = [&](const internal_key_type &Key) -> const FileEntry* {
@@ -1562,7 +1618,7 @@ bool HeaderFileInfoTrait::EqualKey(internal_key_ref a, internal_key_ref b) {
const FileEntry *FEB = GetFile(b);
return FEA && FEA == FEB;
}
-
+
std::pair<unsigned, unsigned>
HeaderFileInfoTrait::ReadKeyDataLength(const unsigned char*& d) {
using namespace llvm::support;
@@ -1582,7 +1638,7 @@ HeaderFileInfoTrait::ReadKey(const unsigned char *d, unsigned) {
return ikey;
}
-HeaderFileInfoTrait::data_type
+HeaderFileInfoTrait::data_type
HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
unsigned DataLen) {
const unsigned char *End = d + DataLen;
@@ -1602,7 +1658,7 @@ HeaderFileInfoTrait::ReadData(internal_key_ref key, const unsigned char *d,
M, endian::readNext<uint32_t, little, unaligned>(d));
if (unsigned FrameworkOffset =
endian::readNext<uint32_t, little, unaligned>(d)) {
- // The framework offset is 1 greater than the actual offset,
+ // The framework offset is 1 greater than the actual offset,
// since 0 is used as an indicator for "no framework name".
StringRef FrameworkName(FrameworkStrings + FrameworkOffset - 1);
HFI.Framework = HS->getUniqueFrameworkName(FrameworkName);
@@ -1655,7 +1711,7 @@ void ASTReader::ReadDefinedMacros() {
BitstreamCursor &MacroCursor = I->MacroCursor;
// If there was no preprocessor block, skip this file.
- if (!MacroCursor.getBitStreamReader())
+ if (MacroCursor.getBitcodeBytes().empty())
continue;
BitstreamCursor Cursor = MacroCursor;
@@ -1664,7 +1720,7 @@ void ASTReader::ReadDefinedMacros() {
RecordData Record;
while (true) {
llvm::BitstreamEntry E = Cursor.advanceSkippingSubblocks();
-
+
switch (E.Kind) {
case llvm::BitstreamEntry::SubBlock: // Handled for us already.
case llvm::BitstreamEntry::Error:
@@ -1672,13 +1728,13 @@ void ASTReader::ReadDefinedMacros() {
return;
case llvm::BitstreamEntry::EndBlock:
goto NextCursor;
-
+
case llvm::BitstreamEntry::Record:
Record.clear();
switch (Cursor.readRecord(E.ID, Record)) {
default: // Default behavior: ignore.
break;
-
+
case PP_MACRO_OBJECT_LIKE:
case PP_MACRO_FUNCTION_LIKE: {
IdentifierInfo *II = getLocalIdentifier(*I, Record[0]);
@@ -1686,7 +1742,7 @@ void ASTReader::ReadDefinedMacros() {
updateOutOfDateIdentifier(*II);
break;
}
-
+
case PP_TOKEN:
// Ignore tokens.
break;
@@ -1699,6 +1755,7 @@ void ASTReader::ReadDefinedMacros() {
}
namespace {
+
/// \brief Visitor class used to look up identifirs in an AST file.
class IdentifierLookupVisitor {
StringRef Name;
@@ -1737,7 +1794,7 @@ namespace {
IdTable->find_hashed(Name, NameHash, &Trait);
if (Pos == IdTable->end())
return false;
-
+
// Dereferencing the iterator has the effect of building the
// IdentifierInfo node and populating it with the various
// declarations it needs.
@@ -1745,12 +1802,13 @@ namespace {
Found = *Pos;
return true;
}
-
+
// \brief Retrieve the identifier info found within the module
// files.
IdentifierInfo *getIdentifierInfo() const { return Found; }
};
-}
+
+} // end anonymous namespace
void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) {
// Note that we are loading an identifier.
@@ -1780,7 +1838,7 @@ void ASTReader::updateOutOfDateIdentifier(IdentifierInfo &II) {
void ASTReader::markIdentifierUpToDate(IdentifierInfo *II) {
if (!II)
return;
-
+
II->setOutOfDate(false);
// Update the generation for this identifier.
@@ -1861,7 +1919,7 @@ void ASTReader::resolvePendingMacro(IdentifierInfo *II,
// Don't read the directive history for a module; we don't have anywhere
// to put it.
- if (M.Kind == MK_ImplicitModule || M.Kind == MK_ExplicitModule)
+ if (M.isModule())
return;
// Deserialize the macro directives history in reverse source-order.
@@ -1895,7 +1953,7 @@ void ASTReader::resolvePendingMacro(IdentifierInfo *II,
}
if (Latest)
- PP.setLoadedMacroDirective(II, Latest);
+ PP.setLoadedMacroDirective(II, Earliest, Latest);
}
ASTReader::InputFileInfo
@@ -1925,6 +1983,7 @@ ASTReader::readInputFileInfo(ModuleFile &F, unsigned ID) {
return R;
}
+static unsigned moduleKindForDiagnostic(ModuleKind Kind);
InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// If this ID is bogus, just return an empty input file.
if (ID == 0 || ID > F.InputFilesLoaded.size())
@@ -1941,7 +2000,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
BitstreamCursor &Cursor = F.InputFilesCursor;
SavedStreamPosition SavedPosition(Cursor);
Cursor.JumpToBit(F.InputFileOffsets[ID-1]);
-
+
InputFileInfo FI = readInputFileInfo(F, ID);
off_t StoredSize = FI.StoredSize;
time_t StoredTime = FI.StoredTime;
@@ -1974,7 +2033,7 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
ErrorStr += "' referenced by AST file '";
ErrorStr += F.FileName;
ErrorStr += "'";
- Error(ErrorStr.c_str());
+ Error(ErrorStr);
}
// Record that we didn't find the file.
F.InputFilesLoaded[ID-1] = InputFile::getNotFound();
@@ -2021,7 +2080,13 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// The top-level PCH is stale.
StringRef TopLevelPCHName(ImportStack.back()->FileName);
- Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+ unsigned DiagnosticKind = moduleKindForDiagnostic(ImportStack.back()->Kind);
+ if (DiagnosticKind == 0)
+ Error(diag::err_fe_pch_file_modified, Filename, TopLevelPCHName);
+ else if (DiagnosticKind == 1)
+ Error(diag::err_fe_module_file_modified, Filename, TopLevelPCHName);
+ else
+ Error(diag::err_fe_ast_file_modified, Filename, TopLevelPCHName);
// Print the import stack.
if (ImportStack.size() > 1 && !Diags.isDiagnosticInFlight()) {
@@ -2084,16 +2149,16 @@ static bool isDiagnosedResult(ASTReader::ASTReadResult ARR, unsigned Caps) {
ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
BitstreamCursor &Stream, unsigned ClientLoadCapabilities,
bool AllowCompatibleConfigurationMismatch, ASTReaderListener &Listener,
- std::string &SuggestedPredefines) {
+ std::string &SuggestedPredefines, bool ValidateDiagnosticOptions) {
if (Stream.EnterSubBlock(OPTIONS_BLOCK_ID))
return Failure;
// Read all of the records in the options block.
RecordData Record;
ASTReadResult Result = Success;
- while (1) {
+ while (true) {
llvm::BitstreamEntry Entry = Stream.advance();
-
+
switch (Entry.Kind) {
case llvm::BitstreamEntry::Error:
case llvm::BitstreamEntry::SubBlock:
@@ -2128,7 +2193,8 @@ ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
case DIAGNOSTIC_OPTIONS: {
bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
- if (!AllowCompatibleConfigurationMismatch &&
+ if (ValidateDiagnosticOptions &&
+ !AllowCompatibleConfigurationMismatch &&
ParseDiagnosticOptions(Record, Complain, Listener))
return OutOfDate;
break;
@@ -2178,9 +2244,9 @@ ASTReader::ReadControlBlock(ModuleFile &F,
RecordData Record;
unsigned NumInputs = 0;
unsigned NumUserInputs = 0;
- while (1) {
+ while (true) {
llvm::BitstreamEntry Entry = Stream.advance();
-
+
switch (Entry.Kind) {
case llvm::BitstreamEntry::Error:
Error("malformed block record in AST file");
@@ -2193,7 +2259,8 @@ ASTReader::ReadControlBlock(ModuleFile &F,
// All user input files reside at the index range [0, NumUserInputs), and
// system input files reside at [NumUserInputs, NumInputs). For explicitly
// loaded module files, ignore missing inputs.
- if (!DisableValidation && F.Kind != MK_ExplicitModule) {
+ if (!DisableValidation && F.Kind != MK_ExplicitModule &&
+ F.Kind != MK_PrebuiltModule) {
bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
// If we are reading a module, we will create a verification timestamp,
@@ -2224,7 +2291,8 @@ ASTReader::ReadControlBlock(ModuleFile &F,
bool IsSystem = I >= NumUserInputs;
InputFileInfo FI = readInputFileInfo(F, I+1);
Listener->visitInputFile(FI.Filename, IsSystem, FI.Overridden,
- F.Kind == MK_ExplicitModule);
+ F.Kind == MK_ExplicitModule ||
+ F.Kind == MK_PrebuiltModule);
}
}
@@ -2254,11 +2322,14 @@ ASTReader::ReadControlBlock(ModuleFile &F,
//
// FIXME: Allow this for files explicitly specified with -include-pch.
bool AllowCompatibleConfigurationMismatch =
- F.Kind == MK_ExplicitModule;
+ F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule;
+ const HeaderSearchOptions &HSOpts =
+ PP.getHeaderSearchInfo().getHeaderSearchOpts();
Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,
AllowCompatibleConfigurationMismatch,
- *Listener, SuggestedPredefines);
+ *Listener, SuggestedPredefines,
+ HSOpts.ModulesValidateDiagnosticOptions);
if (Result == Failure) {
Error("malformed block record in AST file");
return Result;
@@ -2278,7 +2349,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
return Failure;
}
continue;
-
+
default:
if (Stream.SkipBlock()) {
Error("malformed block record in AST file");
@@ -2286,7 +2357,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
}
continue;
}
-
+
case llvm::BitstreamEntry::Record:
// The interesting case.
break;
@@ -2338,7 +2409,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
break;
case IMPORTS: {
- // Load each of the imported PCH files.
+ // Load each of the imported PCH files.
unsigned Idx = 0, N = Record.size();
while (Idx < N) {
// Read information about the AST file.
@@ -2413,7 +2484,7 @@ ASTReader::ReadControlBlock(ModuleFile &F,
if (M && M->Directory) {
// If we're implicitly loading a module, the base directory can't
// change between the build and use.
- if (F.Kind != MK_ExplicitModule) {
+ if (F.Kind != MK_ExplicitModule && F.Kind != MK_PrebuiltModule) {
const DirectoryEntry *BuildDir =
PP.getFileManager().getDirectory(Blob);
if (!BuildDir || BuildDir != M->Directory) {
@@ -2458,9 +2529,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
// Read all of the records and blocks for the AST file.
RecordData Record;
- while (1) {
+ while (true) {
llvm::BitstreamEntry Entry = Stream.advance();
-
+
switch (Entry.Kind) {
case llvm::BitstreamEntry::Error:
Error("error at end of module block in AST file");
@@ -2475,7 +2546,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
if (DC->hasExternalLexicalStorage() &&
!getContext().getLangOpts().CPlusPlus)
DC->setMustBuildLookupTable();
-
+
return Success;
}
case llvm::BitstreamEntry::SubBlock:
@@ -2498,7 +2569,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.MacroCursor = Stream;
if (!PP.getExternalSource())
PP.setExternalSource(this);
-
+
if (Stream.SkipBlock() ||
ReadBlockAbbrevs(F.MacroCursor, PREPROCESSOR_BLOCK_ID)) {
Error("malformed block record in AST file");
@@ -2506,7 +2577,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
F.MacroStartOffset = F.MacroCursor.GetCurrentBitNo();
break;
-
+
case PREPROCESSOR_DETAIL_BLOCK_ID:
F.PreprocessorDetailCursor = Stream;
if (Stream.SkipBlock() ||
@@ -2517,23 +2588,23 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
F.PreprocessorDetailStartOffset
= F.PreprocessorDetailCursor.GetCurrentBitNo();
-
+
if (!PP.getPreprocessingRecord())
PP.createPreprocessingRecord();
if (!PP.getPreprocessingRecord()->getExternalSource())
PP.getPreprocessingRecord()->SetExternalSource(*this);
break;
-
+
case SOURCE_MANAGER_BLOCK_ID:
if (ReadSourceManagerBlock(F))
return Failure;
break;
-
+
case SUBMODULE_BLOCK_ID:
if (ASTReadResult Result = ReadSubmoduleBlock(F, ClientLoadCapabilities))
return Result;
break;
-
+
case COMMENTS_BLOCK_ID: {
BitstreamCursor C = Stream;
if (Stream.SkipBlock() ||
@@ -2544,7 +2615,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
CommentsCursors.push_back(std::make_pair(C, &F));
break;
}
-
+
default:
if (Stream.SkipBlock()) {
Error("malformed block record in AST file");
@@ -2553,7 +2624,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
break;
}
continue;
-
+
case llvm::BitstreamEntry::Record:
// The interesting case.
break;
@@ -2575,21 +2646,21 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.LocalNumTypes = Record[0];
unsigned LocalBaseTypeIndex = Record[1];
F.BaseTypeIndex = getTotalNumTypes();
-
+
if (F.LocalNumTypes > 0) {
// Introduce the global -> local mapping for types within this module.
GlobalTypeMap.insert(std::make_pair(getTotalNumTypes(), &F));
-
+
// Introduce the local -> global mapping for types within this module.
F.TypeRemap.insertOrReplace(
- std::make_pair(LocalBaseTypeIndex,
+ std::make_pair(LocalBaseTypeIndex,
F.BaseTypeIndex - LocalBaseTypeIndex));
TypesLoaded.resize(TypesLoaded.size() + F.LocalNumTypes);
}
break;
}
-
+
case DECL_OFFSET: {
if (F.LocalNumDecls != 0) {
Error("duplicate DECL_OFFSET record in AST file");
@@ -2599,18 +2670,18 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.LocalNumDecls = Record[0];
unsigned LocalBaseDeclID = Record[1];
F.BaseDeclID = getTotalNumDecls();
-
+
if (F.LocalNumDecls > 0) {
- // Introduce the global -> local mapping for declarations within this
+ // Introduce the global -> local mapping for declarations within this
// module.
GlobalDeclMap.insert(
std::make_pair(getTotalNumDecls() + NUM_PREDEF_DECL_IDS, &F));
-
+
// Introduce the local -> global mapping for declarations within this
// module.
F.DeclRemap.insertOrReplace(
std::make_pair(LocalBaseDeclID, F.BaseDeclID - LocalBaseDeclID));
-
+
// Introduce the global -> local mapping for declarations within this
// module.
F.GlobalToLocalDeclIDs[&F] = LocalBaseDeclID;
@@ -2619,7 +2690,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
break;
}
-
+
case TU_UPDATE_LEXICAL: {
DeclContext *TU = Context.getTranslationUnitDecl();
LexicalContents Contents(
@@ -2651,7 +2722,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
(const unsigned char *)F.IdentifierTableData + sizeof(uint32_t),
(const unsigned char *)F.IdentifierTableData,
ASTIdentifierLookupTrait(*this, F));
-
+
PP.getIdentifierTable().setExternalIdentifierLookup(this);
}
break;
@@ -2665,13 +2736,13 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.LocalNumIdentifiers = Record[0];
unsigned LocalBaseIdentifierID = Record[1];
F.BaseIdentifierID = getTotalNumIdentifiers();
-
+
if (F.LocalNumIdentifiers > 0) {
// Introduce the global -> local mapping for identifiers within this
// module.
- GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
+ GlobalIdentifierMap.insert(std::make_pair(getTotalNumIdentifiers() + 1,
&F));
-
+
// Introduce the local -> global mapping for identifiers within this
// module.
F.IdentifierRemap.insertOrReplace(
@@ -2738,11 +2809,11 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
Error("invalid weak identifiers record");
return Failure;
}
-
- // FIXME: Ignore weak undeclared identifiers from non-original PCH
+
+ // FIXME: Ignore weak undeclared identifiers from non-original PCH
// files. This isn't the way to do it :)
WeakUndeclaredIdentifiers.clear();
-
+
// Translate the weak, undeclared identifiers into global IDs.
for (unsigned I = 0, N = Record.size(); I < N; /* in loop */) {
WeakUndeclaredIdentifiers.push_back(
@@ -2760,13 +2831,13 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.LocalNumSelectors = Record[0];
unsigned LocalBaseSelectorID = Record[1];
F.BaseSelectorID = getTotalNumSelectors();
-
+
if (F.LocalNumSelectors > 0) {
- // Introduce the global -> local mapping for selectors within this
+ // Introduce the global -> local mapping for selectors within this
// module.
GlobalSelectorMap.insert(std::make_pair(getTotalNumSelectors()+1, &F));
-
- // Introduce the local -> global mapping for selectors within this
+
+ // Introduce the local -> global mapping for selectors within this
// module.
F.SelectorRemap.insertOrReplace(
std::make_pair(LocalBaseSelectorID,
@@ -2776,7 +2847,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
break;
}
-
+
case METHOD_POOL:
F.SelectorLookupTableData = (const unsigned char *)Blob.data();
if (Record[0])
@@ -2791,7 +2862,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
case REFERENCED_SELECTOR_POOL:
if (!Record.empty()) {
for (unsigned Idx = 0, N = Record.size() - 1; Idx < N; /* in loop */) {
- ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
+ ReferencedSelectorsData.push_back(getGlobalSelectorID(F,
Record[Idx++]));
ReferencedSelectorsData.push_back(ReadSourceLocation(F, Record, Idx).
getRawEncoding());
@@ -2803,7 +2874,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
if (!Record.empty() && Listener)
Listener->ReadCounter(F, Record[0]);
break;
-
+
case FILE_SORTED_DECLS:
F.FileSortedDecls = (const DeclID *)Blob.data();
F.NumFileSortedDecls = Record[0];
@@ -2840,7 +2911,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
// This module. Base was 2 when being compiled.
F.SLocRemap.insertOrReplace(std::make_pair(2U,
static_cast<int>(F.SLocEntryBaseOffset - 2)));
-
+
TotalNumSLocEntries += F.LocalNumSLocEntries;
break;
}
@@ -2932,7 +3003,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
Error("Multiple SOURCE_LOCATION_PRELOADS records in AST file");
return Failure;
}
-
+
F.PreloadSLocEntries.swap(Record);
break;
}
@@ -2947,12 +3018,12 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
Error("Invalid VTABLE_USES record");
return Failure;
}
-
+
// Later tables overwrite earlier ones.
// FIXME: Modules will have some trouble with this. This is clearly not
// the right way to do this.
VTableUses.clear();
-
+
for (unsigned Idx = 0, N = Record.size(); Idx != N; /* In loop */) {
VTableUses.push_back(getGlobalDeclID(F, Record[Idx++]));
VTableUses.push_back(
@@ -2980,7 +3051,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
break;
case SEMA_DECL_REFS:
- if (Record.size() != 2) {
+ if (Record.size() != 3) {
Error("Invalid SEMA_DECL_REFS block");
return Failure;
}
@@ -2994,13 +3065,13 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.NumPreprocessedEntities = Blob.size() / sizeof(PPEntityOffset);
unsigned LocalBasePreprocessedEntityID = Record[0];
-
+
unsigned StartingID;
if (!PP.getPreprocessingRecord())
PP.createPreprocessingRecord();
if (!PP.getPreprocessingRecord()->getExternalSource())
PP.getPreprocessingRecord()->SetExternalSource(*this);
- StartingID
+ StartingID
= PP.getPreprocessingRecord()
->allocateLoadedEntities(F.NumPreprocessedEntities);
F.BasePreprocessedEntityID = StartingID;
@@ -3009,7 +3080,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
// Introduce the global -> local mapping for preprocessed entities in
// this module.
GlobalPreprocessedEntityMap.insert(std::make_pair(StartingID, &F));
-
+
// Introduce the local -> global mapping for preprocessed entities in
// this module.
F.PreprocessedEntityRemap.insertOrReplace(
@@ -3019,7 +3090,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
break;
}
-
+
case DECL_UPDATE_OFFSETS: {
if (Record.size() % 2 != 0) {
Error("invalid DECL_UPDATE_OFFSETS block in AST file");
@@ -3042,12 +3113,12 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
Error("duplicate OBJC_CATEGORIES_MAP record in AST file");
return Failure;
}
-
+
F.LocalNumObjCCategoriesInMap = Record[0];
F.ObjCCategoriesMap = (const ObjCCategoriesInfo *)Blob.data();
break;
}
-
+
case OBJC_CATEGORIES:
F.ObjCCategories.swap(Record);
break;
@@ -3059,7 +3130,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.PragmaDiagMappings.insert(F.PragmaDiagMappings.end(),
Record.begin(), Record.end());
break;
-
+
case CUDA_SPECIAL_DECL_REFS:
// Later tables overwrite earlier ones.
// FIXME: Modules will have trouble with this.
@@ -3076,32 +3147,62 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
= HeaderFileInfoLookupTable::Create(
(const unsigned char *)F.HeaderFileInfoTableData + Record[0],
(const unsigned char *)F.HeaderFileInfoTableData,
- HeaderFileInfoTrait(*this, F,
+ HeaderFileInfoTrait(*this, F,
&PP.getHeaderSearchInfo(),
Blob.data() + Record[2]));
-
+
PP.getHeaderSearchInfo().SetExternalSource(this);
if (!PP.getHeaderSearchInfo().getExternalLookup())
PP.getHeaderSearchInfo().SetExternalLookup(this);
}
break;
}
-
+
case FP_PRAGMA_OPTIONS:
// Later tables overwrite earlier ones.
FPPragmaOptions.swap(Record);
break;
case OPENCL_EXTENSIONS:
- // Later tables overwrite earlier ones.
- OpenCLExtensions.swap(Record);
+ for (unsigned I = 0, E = Record.size(); I != E; ) {
+ auto Name = ReadString(Record, I);
+ auto &Opt = OpenCLExtensions.OptMap[Name];
+ Opt.Supported = Record[I++] != 0;
+ Opt.Enabled = Record[I++] != 0;
+ Opt.Avail = Record[I++];
+ Opt.Core = Record[I++];
+ }
+ break;
+
+ case OPENCL_EXTENSION_TYPES:
+ for (unsigned I = 0, E = Record.size(); I != E;) {
+ auto TypeID = static_cast<::TypeID>(Record[I++]);
+ auto *Type = GetType(TypeID).getTypePtr();
+ auto NumExt = static_cast<unsigned>(Record[I++]);
+ for (unsigned II = 0; II != NumExt; ++II) {
+ auto Ext = ReadString(Record, I);
+ OpenCLTypeExtMap[Type].insert(Ext);
+ }
+ }
+ break;
+
+ case OPENCL_EXTENSION_DECLS:
+ for (unsigned I = 0, E = Record.size(); I != E;) {
+ auto DeclID = static_cast<::DeclID>(Record[I++]);
+ auto *Decl = GetDecl(DeclID);
+ auto NumExt = static_cast<unsigned>(Record[I++]);
+ for (unsigned II = 0; II != NumExt; ++II) {
+ auto Ext = ReadString(Record, I);
+ OpenCLDeclExtMap[Decl].insert(Ext);
+ }
+ }
break;
case TENTATIVE_DEFINITIONS:
for (unsigned I = 0, N = Record.size(); I != N; ++I)
TentativeDefinitions.push_back(getGlobalDeclID(F, Record[I]));
break;
-
+
case KNOWN_NAMESPACES:
for (unsigned I = 0, N = Record.size(); I != N; ++I)
KnownNamespaces.push_back(getGlobalDeclID(F, Record[I]));
@@ -3137,7 +3238,7 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
break;
case IMPORTED_MODULES: {
- if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule) {
+ if (!F.isModule()) {
// If we aren't loading a module (which has its own exports), make
// all of the imported modules visible.
// FIXME: Deal with macros-only imports.
@@ -3210,6 +3311,14 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
UnusedLocalTypedefNameCandidates.push_back(
getGlobalDeclID(F, Record[I]));
break;
+
+ case CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH:
+ if (Record.size() != 1) {
+ Error("invalid cuda pragma options record");
+ return Failure;
+ }
+ ForceCUDAHostDeviceDepth = Record[0];
+ break;
}
}
}
@@ -3221,7 +3330,7 @@ ASTReader::ReadModuleMapFileBlock(RecordData &Record, ModuleFile &F,
unsigned Idx = 0;
F.ModuleMapPath = ReadPath(F, Record, Idx);
- if (F.Kind == MK_ExplicitModule) {
+ if (F.Kind == MK_ExplicitModule || F.Kind == MK_PrebuiltModule) {
// For an explicitly-loaded module, we don't care whether the original
// module map file exists or matches.
return Success;
@@ -3404,6 +3513,31 @@ void ASTReader::makeModuleVisible(Module *Mod,
}
}
+/// We've merged the definition \p MergedDef into the existing definition
+/// \p Def. Ensure that \p Def is made visible whenever \p MergedDef is made
+/// visible.
+void ASTReader::mergeDefinitionVisibility(NamedDecl *Def,
+ NamedDecl *MergedDef) {
+ // FIXME: This doesn't correctly handle the case where MergedDef is visible
+ // in modules other than its owning module. We should instead give the
+ // ASTContext a list of merged definitions for Def.
+ if (Def->isHidden()) {
+ // If MergedDef is visible or becomes visible, make the definition visible.
+ if (!MergedDef->isHidden())
+ Def->Hidden = false;
+ else if (getContext().getLangOpts().ModulesLocalVisibility) {
+ getContext().mergeDefinitionIntoModule(
+ Def, MergedDef->getImportedOwningModule(),
+ /*NotifyListeners*/ false);
+ PendingMergedDefinitionsToDeduplicate.insert(Def);
+ } else {
+ auto SubmoduleID = MergedDef->getOwningModuleID();
+ assert(SubmoduleID && "hidden definition in no module");
+ HiddenNamesMap[getSubmodule(SubmoduleID)].push_back(Def);
+ }
+ }
+}
+
bool ASTReader::loadGlobalIndex() {
if (GlobalIndex)
return false;
@@ -3411,7 +3545,7 @@ bool ASTReader::loadGlobalIndex() {
if (TriedLoadingGlobalIndex || !UseGlobalIndex ||
!Context.getLangOpts().Modules)
return true;
-
+
// Try to load the global index.
TriedLoadingGlobalIndex = true;
StringRef ModuleCachePath
@@ -3445,7 +3579,7 @@ static void updateModuleTimestamp(ModuleFile &MF) {
/// cursor into the start of the given block ID, returning false on success and
/// true on failure.
static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID) {
- while (1) {
+ while (true) {
llvm::BitstreamEntry Entry = Cursor.advance();
switch (Entry.Kind) {
case llvm::BitstreamEntry::Error:
@@ -3474,7 +3608,8 @@ static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID) {
ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
ModuleKind Type,
SourceLocation ImportLoc,
- unsigned ClientLoadCapabilities) {
+ unsigned ClientLoadCapabilities,
+ SmallVectorImpl<ImportedSubmodule> *Imported) {
llvm::SaveAndRestore<SourceLocation>
SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
@@ -3534,12 +3669,12 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
return Result;
}
- // Once read, set the ModuleFile bit base offset and update the size in
+ // Once read, set the ModuleFile bit base offset and update the size in
// bits of all files we've seen.
F.GlobalBitOffset = TotalModulesSizeInBits;
TotalModulesSizeInBits += F.SizeInBits;
GlobalBitOffsetsMap.insert(std::make_pair(F.GlobalBitOffset, &F));
-
+
// Preload SLocEntries.
for (unsigned I = 0, N = F.PreloadSLocEntries.size(); I != N; ++I) {
int Index = int(F.PreloadSLocEntries[I] - 1) + F.SLocEntryBaseID;
@@ -3592,7 +3727,8 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
}
if (!Context.getLangOpts().CPlusPlus ||
- (Type != MK_ImplicitModule && Type != MK_ExplicitModule)) {
+ (Type != MK_ImplicitModule && Type != MK_ExplicitModule &&
+ Type != MK_PrebuiltModule)) {
// Mark all of the identifiers in the identifier table as being out of date,
// so that various accessors know to check the loaded modules when the
// identifier is used.
@@ -3608,7 +3744,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
// Mark selectors as out of date.
for (auto Sel : SelectorGeneration)
SelectorOutOfDate[Sel.first] = true;
-
+
// Resolve any unresolved module exports.
for (unsigned I = 0, N = UnresolvedModuleRefs.size(); I != N; ++I) {
UnresolvedModuleRef &Unresolved = UnresolvedModuleRefs[I];
@@ -3639,10 +3775,14 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
}
UnresolvedModuleRefs.clear();
+ if (Imported)
+ Imported->append(ImportedModules.begin(),
+ ImportedModules.end());
+
// FIXME: How do we load the 'use'd modules? They may not be submodules.
// Might be unnecessary as use declarations are only used to build the
// module itself.
-
+
InitializeContext();
if (SemaObj)
@@ -3653,7 +3793,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
ModuleFile &PrimaryModule = ModuleMgr.getPrimaryModule();
if (PrimaryModule.OriginalSourceFileID.isValid()) {
- PrimaryModule.OriginalSourceFileID
+ PrimaryModule.OriginalSourceFileID
= FileID::get(PrimaryModule.SLocEntryBaseID
+ PrimaryModule.OriginalSourceFileID.getOpaqueValue() - 1);
@@ -3666,11 +3806,11 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
SourceMgr.setMainFileID(PrimaryModule.OriginalSourceFileID);
}
}
-
+
// For any Objective-C class definitions we have already loaded, make sure
// that we load any additional categories.
for (unsigned I = 0, N = ObjCClassesLoaded.size(); I != N; ++I) {
- loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
+ loadObjCCategories(ObjCClassesLoaded[I]->getGlobalID(),
ObjCClassesLoaded[I],
PreviousGeneration);
}
@@ -3693,11 +3833,12 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
return Success;
}
-static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile);
+static ASTFileSignature readASTFileSignature(StringRef PCH);
/// \brief Whether \p Stream starts with the AST/PCH file magic number 'CPCH'.
static bool startsWithASTFileMagic(BitstreamCursor &Stream) {
- return Stream.Read(8) == 'C' &&
+ return Stream.canSkipToPos(4) &&
+ Stream.Read(8) == 'C' &&
Stream.Read(8) == 'P' &&
Stream.Read(8) == 'C' &&
Stream.Read(8) == 'H';
@@ -3709,6 +3850,7 @@ static unsigned moduleKindForDiagnostic(ModuleKind Kind) {
return 0; // PCH
case MK_ImplicitModule:
case MK_ExplicitModule:
+ case MK_PrebuiltModule:
return 1; // module
case MK_MainFile:
case MK_Preamble:
@@ -3750,7 +3892,7 @@ ASTReader::ReadASTCore(StringRef FileName,
// Otherwise, return an error.
Diag(diag::err_module_file_not_found) << moduleKindForDiagnostic(Type)
- << FileName << ErrorStr.empty()
+ << FileName << !ErrorStr.empty()
<< ErrorStr;
return Failure;
@@ -3762,7 +3904,7 @@ ASTReader::ReadASTCore(StringRef FileName,
// Otherwise, return an error.
Diag(diag::err_module_file_out_of_date) << moduleKindForDiagnostic(Type)
- << FileName << ErrorStr.empty()
+ << FileName << !ErrorStr.empty()
<< ErrorStr;
return Failure;
}
@@ -3778,10 +3920,9 @@ ASTReader::ReadASTCore(StringRef FileName,
ModuleFile &F = *M;
BitstreamCursor &Stream = F.Stream;
- PCHContainerRdr.ExtractPCH(F.Buffer->getMemBufferRef(), F.StreamFile);
- Stream.init(&F.StreamFile);
+ Stream = BitstreamCursor(PCHContainerRdr.ExtractPCH(*F.Buffer));
F.SizeInBits = F.Buffer->getBufferSize() * 8;
-
+
// Sniff for the signature.
if (!startsWithASTFileMagic(Stream)) {
Diag(diag::err_module_file_invalid) << moduleKindForDiagnostic(Type)
@@ -3791,16 +3932,16 @@ ASTReader::ReadASTCore(StringRef FileName,
// This is used for compatibility with older PCH formats.
bool HaveReadControlBlock = false;
- while (1) {
+ while (true) {
llvm::BitstreamEntry Entry = Stream.advance();
-
+
switch (Entry.Kind) {
case llvm::BitstreamEntry::Error:
case llvm::BitstreamEntry::Record:
case llvm::BitstreamEntry::EndBlock:
Error("invalid record at top-level of AST file");
return Failure;
-
+
case llvm::BitstreamEntry::SubBlock:
break;
}
@@ -3814,7 +3955,8 @@ ASTReader::ReadASTCore(StringRef FileName,
//
// FIXME: Should we also perform the converse check? Loading a module as
// a PCH file sort of works, but it's a bit wonky.
- if ((Type == MK_ImplicitModule || Type == MK_ExplicitModule) &&
+ if ((Type == MK_ImplicitModule || Type == MK_ExplicitModule ||
+ Type == MK_PrebuiltModule) &&
F.ModuleName.empty()) {
auto Result = (Type == MK_ImplicitModule) ? OutOfDate : Failure;
if (Result != OutOfDate ||
@@ -3930,26 +4072,26 @@ ASTReader::ASTReadResult ASTReader::ReadExtensionBlock(ModuleFile &F) {
void ASTReader::InitializeContext() {
// If there's a listener, notify them that we "read" the translation unit.
if (DeserializationListener)
- DeserializationListener->DeclRead(PREDEF_DECL_TRANSLATION_UNIT_ID,
+ DeserializationListener->DeclRead(PREDEF_DECL_TRANSLATION_UNIT_ID,
Context.getTranslationUnitDecl());
// FIXME: Find a better way to deal with collisions between these
// built-in types. Right now, we just ignore the problem.
-
+
// Load the special types.
if (SpecialTypes.size() >= NumSpecialTypeIDs) {
if (unsigned String = SpecialTypes[SPECIAL_TYPE_CF_CONSTANT_STRING]) {
if (!Context.CFConstantStringTypeDecl)
Context.setCFConstantStringType(GetType(String));
}
-
+
if (unsigned File = SpecialTypes[SPECIAL_TYPE_FILE]) {
QualType FileType = GetType(File);
if (FileType.isNull()) {
Error("FILE type is NULL");
return;
}
-
+
if (!Context.FILEDecl) {
if (const TypedefType *Typedef = FileType->getAs<TypedefType>())
Context.setFILEDecl(Typedef->getDecl());
@@ -3963,14 +4105,14 @@ void ASTReader::InitializeContext() {
}
}
}
-
+
if (unsigned Jmp_buf = SpecialTypes[SPECIAL_TYPE_JMP_BUF]) {
QualType Jmp_bufType = GetType(Jmp_buf);
if (Jmp_bufType.isNull()) {
Error("jmp_buf type is NULL");
return;
}
-
+
if (!Context.jmp_bufDecl) {
if (const TypedefType *Typedef = Jmp_bufType->getAs<TypedefType>())
Context.setjmp_bufDecl(Typedef->getDecl());
@@ -3984,14 +4126,14 @@ void ASTReader::InitializeContext() {
}
}
}
-
+
if (unsigned Sigjmp_buf = SpecialTypes[SPECIAL_TYPE_SIGJMP_BUF]) {
QualType Sigjmp_bufType = GetType(Sigjmp_buf);
if (Sigjmp_bufType.isNull()) {
Error("sigjmp_buf type is NULL");
return;
}
-
+
if (!Context.sigjmp_bufDecl) {
if (const TypedefType *Typedef = Sigjmp_bufType->getAs<TypedefType>())
Context.setsigjmp_bufDecl(Typedef->getDecl());
@@ -4039,7 +4181,7 @@ void ASTReader::InitializeContext() {
}
}
}
-
+
ReadPragmaDiagnosticMappings(Context.getDiagnostics());
// If there were any CUDA special declarations, deserialize them.
@@ -4067,10 +4209,10 @@ void ASTReader::finalizeForWriting() {
// Nothing to do for now.
}
-/// \brief Reads and return the signature record from \p StreamFile's control
-/// block, or else returns 0.
-static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile){
- BitstreamCursor Stream(StreamFile);
+/// \brief Reads and return the signature record from \p PCH's control block, or
+/// else returns 0.
+static ASTFileSignature readASTFileSignature(StringRef PCH) {
+ BitstreamCursor Stream(PCH);
if (!startsWithASTFileMagic(Stream))
return 0;
@@ -4080,10 +4222,9 @@ static ASTFileSignature readASTFileSignature(llvm::BitstreamReader &StreamFile){
// Scan for SIGNATURE inside the control block.
ASTReader::RecordData Record;
- while (1) {
+ while (true) {
llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
- if (Entry.Kind == llvm::BitstreamEntry::EndBlock ||
- Entry.Kind != llvm::BitstreamEntry::Record)
+ if (Entry.Kind != llvm::BitstreamEntry::Record)
return 0;
Record.clear();
@@ -4108,16 +4249,14 @@ std::string ASTReader::getOriginalSourceFile(
}
// Initialize the stream
- llvm::BitstreamReader StreamFile;
- PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
- BitstreamCursor Stream(StreamFile);
+ BitstreamCursor Stream(PCHContainerRdr.ExtractPCH(**Buffer));
// Sniff for the signature.
if (!startsWithASTFileMagic(Stream)) {
Diags.Report(diag::err_fe_not_a_pch_file) << ASTFileName;
return std::string();
}
-
+
// Scan for the CONTROL_BLOCK_ID block.
if (SkipCursorToBlock(Stream, CONTROL_BLOCK_ID)) {
Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
@@ -4126,16 +4265,16 @@ std::string ASTReader::getOriginalSourceFile(
// Scan for ORIGINAL_FILE inside the control block.
RecordData Record;
- while (1) {
+ while (true) {
llvm::BitstreamEntry Entry = Stream.advanceSkippingSubblocks();
if (Entry.Kind == llvm::BitstreamEntry::EndBlock)
return std::string();
-
+
if (Entry.Kind != llvm::BitstreamEntry::Record) {
Diags.Report(diag::err_fe_pch_malformed_block) << ASTFileName;
return std::string();
}
-
+
Record.clear();
StringRef Blob;
if (Stream.readRecord(Entry.ID, Record, &Blob) == ORIGINAL_FILE)
@@ -4144,6 +4283,7 @@ std::string ASTReader::getOriginalSourceFile(
}
namespace {
+
class SimplePCHValidator : public ASTReaderListener {
const LangOptions &ExistingLangOpts;
const TargetOptions &ExistingTargetOpts;
@@ -4170,11 +4310,13 @@ namespace {
return checkLanguageOptions(ExistingLangOpts, LangOpts, nullptr,
AllowCompatibleDifferences);
}
+
bool ReadTargetOptions(const TargetOptions &TargetOpts, bool Complain,
bool AllowCompatibleDifferences) override {
return checkTargetOptions(ExistingTargetOpts, TargetOpts, nullptr,
AllowCompatibleDifferences);
}
+
bool ReadHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
StringRef SpecificModuleCachePath,
bool Complain) override {
@@ -4182,6 +4324,7 @@ namespace {
ExistingModuleCachePath,
nullptr, ExistingLangOpts);
}
+
bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
bool Complain,
std::string &SuggestedPredefines) override {
@@ -4189,13 +4332,14 @@ namespace {
SuggestedPredefines, ExistingLangOpts);
}
};
-}
+
+} // end anonymous namespace
bool ASTReader::readASTFileControlBlock(
StringRef Filename, FileManager &FileMgr,
const PCHContainerReader &PCHContainerRdr,
bool FindModuleFileExtensions,
- ASTReaderListener &Listener) {
+ ASTReaderListener &Listener, bool ValidateDiagnosticOptions) {
// Open the AST file.
// FIXME: This allows use of the VFS; we do not allow use of the
// VFS when actually loading a module.
@@ -4205,9 +4349,7 @@ bool ASTReader::readASTFileControlBlock(
}
// Initialize the stream
- llvm::BitstreamReader StreamFile;
- PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), StreamFile);
- BitstreamCursor Stream(StreamFile);
+ BitstreamCursor Stream(PCHContainerRdr.ExtractPCH(**Buffer));
// Sniff for the signature.
if (!startsWithASTFileMagic(Stream))
@@ -4235,7 +4377,8 @@ bool ASTReader::readASTFileControlBlock(
std::string IgnoredSuggestedPredefines;
if (ReadOptionsBlock(Stream, ARR_ConfigurationMismatch | ARR_OutOfDate,
/*AllowCompatibleConfigurationMismatch*/ false,
- Listener, IgnoredSuggestedPredefines) != Success)
+ Listener, IgnoredSuggestedPredefines,
+ ValidateDiagnosticOptions) != Success)
return true;
break;
}
@@ -4280,7 +4423,7 @@ bool ASTReader::readASTFileControlBlock(
if (Listener.ReadFullVersionInformation(Blob))
return true;
-
+
break;
}
case MODULE_NAME:
@@ -4408,7 +4551,8 @@ bool ASTReader::isAcceptableASTFile(
ExistingModuleCachePath, FileMgr);
return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
/*FindModuleFileExtensions=*/false,
- validator);
+ validator,
+ /*ValidateDiagnosticOptions=*/true);
}
ASTReader::ASTReadResult
@@ -4425,7 +4569,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
RecordData Record;
while (true) {
llvm::BitstreamEntry Entry = F.Stream.advanceSkippingSubblocks();
-
+
switch (Entry.Kind) {
case llvm::BitstreamEntry::SubBlock: // Handled for us already.
case llvm::BitstreamEntry::Error:
@@ -4523,7 +4667,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
CurrentModule->ConfigMacrosExhaustive = ConfigMacrosExhaustive;
if (DeserializationListener)
DeserializationListener->ModuleRead(GlobalID, CurrentModule);
-
+
SubmodulesLoaded[GlobalIndex] = CurrentModule;
// Clear out data that will be replaced by what is in the module file.
@@ -4563,7 +4707,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
break;
}
-
+
case SUBMODULE_HEADER:
case SUBMODULE_EXCLUDED_HEADER:
case SUBMODULE_PRIVATE_HEADER:
@@ -4597,17 +4741,17 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
break;
}
-
+
case SUBMODULE_METADATA: {
F.BaseSubmoduleID = getTotalNumSubmodules();
F.LocalNumSubmodules = Record[0];
unsigned LocalBaseSubmoduleID = Record[1];
if (F.LocalNumSubmodules > 0) {
- // Introduce the global -> local mapping for submodules within this
+ // Introduce the global -> local mapping for submodules within this
// module.
GlobalSubmoduleMap.insert(std::make_pair(getTotalNumSubmodules()+1,&F));
-
- // Introduce the local -> global mapping for submodules within this
+
+ // Introduce the local -> global mapping for submodules within this
// module.
F.SubmoduleRemap.insertOrReplace(
std::make_pair(LocalBaseSubmoduleID,
@@ -4617,7 +4761,7 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
}
break;
}
-
+
case SUBMODULE_IMPORTS: {
for (unsigned Idx = 0; Idx != Record.size(); ++Idx) {
UnresolvedModuleRef Unresolved;
@@ -4641,8 +4785,8 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
Unresolved.IsWildcard = Record[Idx + 1];
UnresolvedModuleRefs.push_back(Unresolved);
}
-
- // Once we've loaded the set of exports, there's no reason to keep
+
+ // Once we've loaded the set of exports, there's no reason to keep
// the parsed, unresolved exports around.
CurrentModule->UnresolvedExports.clear();
break;
@@ -4673,6 +4817,13 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
UnresolvedModuleRefs.push_back(Unresolved);
break;
}
+
+ case SUBMODULE_INITIALIZERS:
+ SmallVector<uint32_t, 16> Inits;
+ for (auto &ID : Record)
+ Inits.push_back(getGlobalDeclID(F, ID));
+ Context.addLazyModuleInitializers(CurrentModule, Inits);
+ break;
}
}
}
@@ -4848,7 +4999,7 @@ std::pair<ModuleFile *, unsigned>
ASTReader::getModulePreprocessedEntity(unsigned GlobalIndex) {
GlobalPreprocessedEntityMapType::iterator
I = GlobalPreprocessedEntityMap.find(GlobalIndex);
- assert(I != GlobalPreprocessedEntityMap.end() &&
+ assert(I != GlobalPreprocessedEntityMap.end() &&
"Corrupted global preprocessed entity map");
ModuleFile *M = I->second;
unsigned LocalIndex = GlobalIndex - M->BasePreprocessedEntityID;
@@ -4884,8 +5035,8 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
Error("no preprocessing record");
return nullptr;
}
-
- SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor);
+
+ SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor);
M.PreprocessorDetailCursor.JumpToBit(PPOffs.BitOffset);
llvm::BitstreamEntry Entry =
@@ -4924,7 +5075,7 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
return ME;
}
-
+
case PPD_MACRO_DEFINITION: {
// Decode the identifier info and then check again; if the macro is
// still defined and associated with the identifier,
@@ -4936,14 +5087,14 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
return MD;
}
-
+
case PPD_INCLUSION_DIRECTIVE: {
const char *FullFileNameStart = Blob.data() + Record[0];
StringRef FullFileName(FullFileNameStart, Blob.size() - Record[0]);
const FileEntry *File = nullptr;
if (!FullFileName.empty())
File = PP.getFileManager().getFile(FullFileName);
-
+
// FIXME: Stable encoding
InclusionDirective::InclusionKind Kind
= static_cast<InclusionDirective::InclusionKind>(Record[2]);
@@ -5006,7 +5157,7 @@ struct PPEntityComp {
}
};
-}
+} // end anonymous namespace
PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
bool EndsAfter) const {
@@ -5084,11 +5235,11 @@ Optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index,
ModuleFile &M = *PPInfo.first;
unsigned LocalIndex = PPInfo.second;
const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
-
+
SourceLocation Loc = TranslateSourceLocation(M, PPOffs.getBegin());
if (Loc.isInvalid())
return false;
-
+
if (SourceMgr.isInFileID(SourceMgr.getFileLoc(Loc), FID))
return true;
else
@@ -5096,12 +5247,13 @@ Optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index,
}
namespace {
+
/// \brief Visitor used to search for information about a header file.
class HeaderFileInfoVisitor {
const FileEntry *FE;
-
+
Optional<HeaderFileInfo> HFI;
-
+
public:
explicit HeaderFileInfoVisitor(const FileEntry *FE)
: FE(FE) { }
@@ -5120,17 +5272,18 @@ namespace {
HFI = *Pos;
return true;
}
-
+
Optional<HeaderFileInfo> getHeaderFileInfo() const { return HFI; }
};
-}
+
+} // end anonymous namespace
HeaderFileInfo ASTReader::GetHeaderFileInfo(const FileEntry *FE) {
HeaderFileInfoVisitor Visitor(FE);
ModuleMgr.visit(Visitor);
if (Optional<HeaderFileInfo> HFI = Visitor.getHeaderFileInfo())
return *HFI;
-
+
return HeaderFileInfo();
}
@@ -5152,7 +5305,7 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
FullSourceLoc(Loc, SourceMgr)));
continue;
}
-
+
assert(DiagStateID == 0);
// A new DiagState was created here.
Diag.DiagStates.push_back(*Diag.GetCurDiagState());
@@ -5161,7 +5314,7 @@ void ASTReader::ReadPragmaDiagnosticMappings(DiagnosticsEngine &Diag) {
Diag.DiagStatePoints.push_back(
DiagnosticsEngine::DiagStatePoint(NewState,
FullSourceLoc(Loc, SourceMgr)));
- while (1) {
+ while (true) {
assert(Idx < F.PragmaDiagMappings.size() &&
"Invalid data, didn't find '-1' marking end of diag/map pairs");
if (Idx >= F.PragmaDiagMappings.size()) {
@@ -5298,7 +5451,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
QualType ClassType = readType(*Loc.F, Record, Idx);
if (PointeeType.isNull() || ClassType.isNull())
return QualType();
-
+
return Context.getMemberPointerType(PointeeType, ClassType.getTypePtr());
}
@@ -5408,7 +5561,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
return Context.getTypeDeclType(
ReadDeclAs<UnresolvedUsingTypenameDecl>(*Loc.F, Record, Idx));
}
-
+
case TYPE_TYPEDEF: {
if (Record.size() != 2) {
Error("incorrect encoding of typedef type");
@@ -5529,6 +5682,16 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
return Context.getObjCInterfaceType(ItfD->getCanonicalDecl());
}
+ case TYPE_OBJC_TYPE_PARAM: {
+ unsigned Idx = 0;
+ ObjCTypeParamDecl *Decl
+ = ReadDeclAs<ObjCTypeParamDecl>(*Loc.F, Record, Idx);
+ unsigned NumProtos = Record[Idx++];
+ SmallVector<ObjCProtocolDecl*, 4> Protos;
+ for (unsigned I = 0; I != NumProtos; ++I)
+ Protos.push_back(ReadDeclAs<ObjCProtocolDecl>(*Loc.F, Record, Idx));
+ return Context.getObjCTypeParamType(Decl, Protos);
+ }
case TYPE_OBJC_OBJECT: {
unsigned Idx = 0;
QualType Base = readType(*Loc.F, Record, Idx);
@@ -5666,15 +5829,17 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
}
case TYPE_PIPE: {
- if (Record.size() != 1) {
+ if (Record.size() != 2) {
Error("Incorrect encoding of pipe type");
return QualType();
}
// Reading the pipe element type.
QualType ElementType = readType(*Loc.F, Record, Idx);
- return Context.getPipeType(ElementType);
+ unsigned ReadOnly = Record[1];
+ return Context.getPipeType(ElementType, ReadOnly);
}
+
}
llvm_unreachable("Invalid TypeCode!");
}
@@ -5701,26 +5866,27 @@ void ASTReader::readExceptionSpec(ModuleFile &ModuleFile,
}
class clang::TypeLocReader : public TypeLocVisitor<TypeLocReader> {
- ASTReader &Reader;
- ModuleFile &F;
+ ModuleFile *F;
+ ASTReader *Reader;
const ASTReader::RecordData &Record;
unsigned &Idx;
- SourceLocation ReadSourceLocation(const ASTReader::RecordData &R,
- unsigned &I) {
- return Reader.ReadSourceLocation(F, R, I);
+ SourceLocation ReadSourceLocation() {
+ return Reader->ReadSourceLocation(*F, Record, Idx);
}
- template<typename T>
- T *ReadDeclAs(const ASTReader::RecordData &Record, unsigned &Idx) {
- return Reader.ReadDeclAs<T>(F, Record, Idx);
+ TypeSourceInfo *GetTypeSourceInfo() {
+ return Reader->GetTypeSourceInfo(*F, Record, Idx);
}
-
+
+ NestedNameSpecifierLoc ReadNestedNameSpecifierLoc() {
+ return Reader->ReadNestedNameSpecifierLoc(*F, Record, Idx);
+ }
+
public:
- TypeLocReader(ASTReader &Reader, ModuleFile &F,
+ TypeLocReader(ModuleFile &F, ASTReader &Reader,
const ASTReader::RecordData &Record, unsigned &Idx)
- : Reader(Reader), F(F), Record(Record), Idx(Idx)
- { }
+ : F(&F), Reader(&Reader), Record(Record), Idx(Idx) {}
// We want compile-time assurance that we've enumerated all of
// these, so unfortunately we have to declare them first, then
@@ -5737,8 +5903,9 @@ public:
void TypeLocReader::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
// nothing to do
}
+
void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
- TL.setBuiltinLoc(ReadSourceLocation(Record, Idx));
+ TL.setBuiltinLoc(ReadSourceLocation());
if (TL.needsExtraLocalData()) {
TL.setWrittenTypeSpec(static_cast<DeclSpec::TST>(Record[Idx++]));
TL.setWrittenSignSpec(static_cast<DeclSpec::TSS>(Record[Idx++]));
@@ -5746,219 +5913,264 @@ void TypeLocReader::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
TL.setModeAttr(Record[Idx++]);
}
}
+
void TypeLocReader::VisitComplexTypeLoc(ComplexTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitPointerTypeLoc(PointerTypeLoc TL) {
- TL.setStarLoc(ReadSourceLocation(Record, Idx));
+ TL.setStarLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
// nothing to do
}
+
void TypeLocReader::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
// nothing to do
}
+
void TypeLocReader::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
- TL.setCaretLoc(ReadSourceLocation(Record, Idx));
+ TL.setCaretLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
- TL.setAmpLoc(ReadSourceLocation(Record, Idx));
+ TL.setAmpLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
- TL.setAmpAmpLoc(ReadSourceLocation(Record, Idx));
+ TL.setAmpAmpLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
- TL.setStarLoc(ReadSourceLocation(Record, Idx));
- TL.setClassTInfo(Reader.GetTypeSourceInfo(F, Record, Idx));
+ TL.setStarLoc(ReadSourceLocation());
+ TL.setClassTInfo(GetTypeSourceInfo());
}
+
void TypeLocReader::VisitArrayTypeLoc(ArrayTypeLoc TL) {
- TL.setLBracketLoc(ReadSourceLocation(Record, Idx));
- TL.setRBracketLoc(ReadSourceLocation(Record, Idx));
+ TL.setLBracketLoc(ReadSourceLocation());
+ TL.setRBracketLoc(ReadSourceLocation());
if (Record[Idx++])
- TL.setSizeExpr(Reader.ReadExpr(F));
+ TL.setSizeExpr(Reader->ReadExpr(*F));
else
TL.setSizeExpr(nullptr);
}
+
void TypeLocReader::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocReader::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocReader::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocReader::VisitDependentSizedArrayTypeLoc(
DependentSizedArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocReader::VisitDependentSizedExtVectorTypeLoc(
DependentSizedExtVectorTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitVectorTypeLoc(VectorTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
- TL.setLocalRangeBegin(ReadSourceLocation(Record, Idx));
- TL.setLParenLoc(ReadSourceLocation(Record, Idx));
- TL.setRParenLoc(ReadSourceLocation(Record, Idx));
- TL.setLocalRangeEnd(ReadSourceLocation(Record, Idx));
+ TL.setLocalRangeBegin(ReadSourceLocation());
+ TL.setLParenLoc(ReadSourceLocation());
+ TL.setRParenLoc(ReadSourceLocation());
+ TL.setLocalRangeEnd(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i) {
- TL.setParam(i, ReadDeclAs<ParmVarDecl>(Record, Idx));
+ TL.setParam(i, Reader->ReadDeclAs<ParmVarDecl>(*F, Record, Idx));
}
}
+
void TypeLocReader::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
VisitFunctionTypeLoc(TL);
}
+
void TypeLocReader::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
VisitFunctionTypeLoc(TL);
}
void TypeLocReader::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
void TypeLocReader::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
void TypeLocReader::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
- TL.setTypeofLoc(ReadSourceLocation(Record, Idx));
- TL.setLParenLoc(ReadSourceLocation(Record, Idx));
- TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+ TL.setTypeofLoc(ReadSourceLocation());
+ TL.setLParenLoc(ReadSourceLocation());
+ TL.setRParenLoc(ReadSourceLocation());
}
void TypeLocReader::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
- TL.setTypeofLoc(ReadSourceLocation(Record, Idx));
- TL.setLParenLoc(ReadSourceLocation(Record, Idx));
- TL.setRParenLoc(ReadSourceLocation(Record, Idx));
- TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(F, Record, Idx));
+ TL.setTypeofLoc(ReadSourceLocation());
+ TL.setLParenLoc(ReadSourceLocation());
+ TL.setRParenLoc(ReadSourceLocation());
+ TL.setUnderlyingTInfo(GetTypeSourceInfo());
}
void TypeLocReader::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
- TL.setKWLoc(ReadSourceLocation(Record, Idx));
- TL.setLParenLoc(ReadSourceLocation(Record, Idx));
- TL.setRParenLoc(ReadSourceLocation(Record, Idx));
- TL.setUnderlyingTInfo(Reader.GetTypeSourceInfo(F, Record, Idx));
+ TL.setKWLoc(ReadSourceLocation());
+ TL.setLParenLoc(ReadSourceLocation());
+ TL.setRParenLoc(ReadSourceLocation());
+ TL.setUnderlyingTInfo(GetTypeSourceInfo());
}
+
void TypeLocReader::VisitAutoTypeLoc(AutoTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitRecordTypeLoc(RecordTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitEnumTypeLoc(EnumTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
- TL.setAttrNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setAttrNameLoc(ReadSourceLocation());
if (TL.hasAttrOperand()) {
SourceRange range;
- range.setBegin(ReadSourceLocation(Record, Idx));
- range.setEnd(ReadSourceLocation(Record, Idx));
+ range.setBegin(ReadSourceLocation());
+ range.setEnd(ReadSourceLocation());
TL.setAttrOperandParensRange(range);
}
if (TL.hasAttrExprOperand()) {
if (Record[Idx++])
- TL.setAttrExprOperand(Reader.ReadExpr(F));
+ TL.setAttrExprOperand(Reader->ReadExpr(*F));
else
TL.setAttrExprOperand(nullptr);
} else if (TL.hasAttrEnumOperand())
- TL.setAttrEnumOperandLoc(ReadSourceLocation(Record, Idx));
+ TL.setAttrEnumOperandLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitSubstTemplateTypeParmTypeLoc(
SubstTemplateTypeParmTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
void TypeLocReader::VisitSubstTemplateTypeParmPackTypeLoc(
SubstTemplateTypeParmPackTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
void TypeLocReader::VisitTemplateSpecializationTypeLoc(
TemplateSpecializationTypeLoc TL) {
- TL.setTemplateKeywordLoc(ReadSourceLocation(Record, Idx));
- TL.setTemplateNameLoc(ReadSourceLocation(Record, Idx));
- TL.setLAngleLoc(ReadSourceLocation(Record, Idx));
- TL.setRAngleLoc(ReadSourceLocation(Record, Idx));
+ TL.setTemplateKeywordLoc(ReadSourceLocation());
+ TL.setTemplateNameLoc(ReadSourceLocation());
+ TL.setLAngleLoc(ReadSourceLocation());
+ TL.setRAngleLoc(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
- TL.setArgLocInfo(i,
- Reader.GetTemplateArgumentLocInfo(F,
- TL.getTypePtr()->getArg(i).getKind(),
- Record, Idx));
+ TL.setArgLocInfo(
+ i,
+ Reader->GetTemplateArgumentLocInfo(
+ *F, TL.getTypePtr()->getArg(i).getKind(), Record, Idx));
}
void TypeLocReader::VisitParenTypeLoc(ParenTypeLoc TL) {
- TL.setLParenLoc(ReadSourceLocation(Record, Idx));
- TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+ TL.setLParenLoc(ReadSourceLocation());
+ TL.setRParenLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
- TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx));
- TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
+ TL.setElaboratedKeywordLoc(ReadSourceLocation());
+ TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
}
+
void TypeLocReader::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
- TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx));
- TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setElaboratedKeywordLoc(ReadSourceLocation());
+ TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
+ TL.setNameLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitDependentTemplateSpecializationTypeLoc(
DependentTemplateSpecializationTypeLoc TL) {
- TL.setElaboratedKeywordLoc(ReadSourceLocation(Record, Idx));
- TL.setQualifierLoc(Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
- TL.setTemplateKeywordLoc(ReadSourceLocation(Record, Idx));
- TL.setTemplateNameLoc(ReadSourceLocation(Record, Idx));
- TL.setLAngleLoc(ReadSourceLocation(Record, Idx));
- TL.setRAngleLoc(ReadSourceLocation(Record, Idx));
+ TL.setElaboratedKeywordLoc(ReadSourceLocation());
+ TL.setQualifierLoc(ReadNestedNameSpecifierLoc());
+ TL.setTemplateKeywordLoc(ReadSourceLocation());
+ TL.setTemplateNameLoc(ReadSourceLocation());
+ TL.setLAngleLoc(ReadSourceLocation());
+ TL.setRAngleLoc(ReadSourceLocation());
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
- TL.setArgLocInfo(I,
- Reader.GetTemplateArgumentLocInfo(F,
- TL.getTypePtr()->getArg(I).getKind(),
- Record, Idx));
+ TL.setArgLocInfo(
+ I,
+ Reader->GetTemplateArgumentLocInfo(
+ *F, TL.getTypePtr()->getArg(I).getKind(), Record, Idx));
}
+
void TypeLocReader::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
- TL.setEllipsisLoc(ReadSourceLocation(Record, Idx));
+ TL.setEllipsisLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
- TL.setNameLoc(ReadSourceLocation(Record, Idx));
+ TL.setNameLoc(ReadSourceLocation());
}
+
+void TypeLocReader::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+ if (TL.getNumProtocols()) {
+ TL.setProtocolLAngleLoc(ReadSourceLocation());
+ TL.setProtocolRAngleLoc(ReadSourceLocation());
+ }
+ for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+ TL.setProtocolLoc(i, ReadSourceLocation());
+}
+
void TypeLocReader::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
TL.setHasBaseTypeAsWritten(Record[Idx++]);
- TL.setTypeArgsLAngleLoc(ReadSourceLocation(Record, Idx));
- TL.setTypeArgsRAngleLoc(ReadSourceLocation(Record, Idx));
+ TL.setTypeArgsLAngleLoc(ReadSourceLocation());
+ TL.setTypeArgsRAngleLoc(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumTypeArgs(); i != e; ++i)
- TL.setTypeArgTInfo(i, Reader.GetTypeSourceInfo(F, Record, Idx));
- TL.setProtocolLAngleLoc(ReadSourceLocation(Record, Idx));
- TL.setProtocolRAngleLoc(ReadSourceLocation(Record, Idx));
+ TL.setTypeArgTInfo(i, GetTypeSourceInfo());
+ TL.setProtocolLAngleLoc(ReadSourceLocation());
+ TL.setProtocolRAngleLoc(ReadSourceLocation());
for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
- TL.setProtocolLoc(i, ReadSourceLocation(Record, Idx));
+ TL.setProtocolLoc(i, ReadSourceLocation());
}
+
void TypeLocReader::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
- TL.setStarLoc(ReadSourceLocation(Record, Idx));
+ TL.setStarLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
- TL.setKWLoc(ReadSourceLocation(Record, Idx));
- TL.setLParenLoc(ReadSourceLocation(Record, Idx));
- TL.setRParenLoc(ReadSourceLocation(Record, Idx));
+ TL.setKWLoc(ReadSourceLocation());
+ TL.setLParenLoc(ReadSourceLocation());
+ TL.setRParenLoc(ReadSourceLocation());
}
+
void TypeLocReader::VisitPipeTypeLoc(PipeTypeLoc TL) {
- TL.setKWLoc(ReadSourceLocation(Record, Idx));
+ TL.setKWLoc(ReadSourceLocation());
}
-TypeSourceInfo *ASTReader::GetTypeSourceInfo(ModuleFile &F,
- const RecordData &Record,
- unsigned &Idx) {
+TypeSourceInfo *
+ASTReader::GetTypeSourceInfo(ModuleFile &F, const ASTReader::RecordData &Record,
+ unsigned &Idx) {
QualType InfoTy = readType(F, Record, Idx);
if (InfoTy.isNull())
return nullptr;
TypeSourceInfo *TInfo = getContext().CreateTypeSourceInfo(InfoTy);
- TypeLocReader TLR(*this, F, Record, Idx);
+ TypeLocReader TLR(F, *this, Record, Idx);
for (TypeLoc TL = TInfo->getTypeLoc(); !TL.isNull(); TL = TL.getNextTypeLoc())
TLR.Visit(TL);
return TInfo;
@@ -6141,18 +6353,18 @@ QualType ASTReader::getLocalType(ModuleFile &F, unsigned LocalID) {
return GetType(getGlobalTypeID(F, LocalID));
}
-serialization::TypeID
+serialization::TypeID
ASTReader::getGlobalTypeID(ModuleFile &F, unsigned LocalID) const {
unsigned FastQuals = LocalID & Qualifiers::FastMask;
unsigned LocalIndex = LocalID >> Qualifiers::FastWidth;
-
+
if (LocalIndex < NUM_PREDEF_TYPE_IDS)
return LocalID;
ContinuousRangeMap<uint32_t, int, 2>::iterator I
= F.TypeRemap.find(LocalIndex - NUM_PREDEF_TYPE_IDS);
assert(I != F.TypeRemap.end() && "Invalid index into type index remap");
-
+
unsigned GlobalIndex = LocalIndex + I->second;
return (GlobalIndex << Qualifiers::FastWidth) | FastQuals;
}
@@ -6168,18 +6380,18 @@ ASTReader::GetTemplateArgumentLocInfo(ModuleFile &F,
case TemplateArgument::Type:
return GetTypeSourceInfo(F, Record, Index);
case TemplateArgument::Template: {
- NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record,
+ NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record,
Index);
SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc,
SourceLocation());
}
case TemplateArgument::TemplateExpansion: {
- NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record,
+ NestedNameSpecifierLoc QualifierLoc = ReadNestedNameSpecifierLoc(F, Record,
Index);
SourceLocation TemplateNameLoc = ReadSourceLocation(F, Record, Index);
SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Index);
- return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc,
+ return TemplateArgumentLocInfo(QualifierLoc, TemplateNameLoc,
EllipsisLoc);
}
case TemplateArgument::Null:
@@ -6324,7 +6536,7 @@ CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
return Bases;
}
-serialization::DeclID
+serialization::DeclID
ASTReader::getGlobalDeclID(ModuleFile &F, LocalDeclID LocalID) const {
if (LocalID < NUM_PREDEF_DECL_IDS)
return LocalID;
@@ -6332,7 +6544,7 @@ ASTReader::getGlobalDeclID(ModuleFile &F, LocalDeclID LocalID) const {
ContinuousRangeMap<uint32_t, int, 2>::iterator I
= F.DeclRemap.find(LocalID - NUM_PREDEF_DECL_IDS);
assert(I != F.DeclRemap.end() && "Invalid index into decl index remap");
-
+
return LocalID + I->second;
}
@@ -6342,7 +6554,7 @@ bool ASTReader::isDeclIDFromModule(serialization::GlobalDeclID ID,
if (ID < NUM_PREDEF_DECL_IDS)
return false;
- return ID - NUM_PREDEF_DECL_IDS >= M.BaseDeclID &&
+ return ID - NUM_PREDEF_DECL_IDS >= M.BaseDeclID &&
ID - NUM_PREDEF_DECL_IDS < M.BaseDeclID + M.LocalNumDecls;
}
@@ -6474,11 +6686,11 @@ Decl *ASTReader::GetDecl(DeclID ID) {
return DeclsLoaded[Index];
}
-DeclID ASTReader::mapGlobalIDToModuleFileGlobalID(ModuleFile &M,
+DeclID ASTReader::mapGlobalIDToModuleFileGlobalID(ModuleFile &M,
DeclID GlobalID) {
if (GlobalID < NUM_PREDEF_DECL_IDS)
return GlobalID;
-
+
GlobalDeclMapType::const_iterator I = GlobalDeclMap.find(GlobalID);
assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
ModuleFile *Owner = I->second;
@@ -6487,18 +6699,18 @@ DeclID ASTReader::mapGlobalIDToModuleFileGlobalID(ModuleFile &M,
= M.GlobalToLocalDeclIDs.find(Owner);
if (Pos == M.GlobalToLocalDeclIDs.end())
return 0;
-
+
return GlobalID - Owner->BaseDeclID + Pos->second;
}
-serialization::DeclID ASTReader::ReadDeclID(ModuleFile &F,
+serialization::DeclID ASTReader::ReadDeclID(ModuleFile &F,
const RecordData &Record,
unsigned &Idx) {
if (Idx >= Record.size()) {
Error("Corrupted AST file");
return 0;
}
-
+
return getGlobalDeclID(F, Record[Idx++]);
}
@@ -6591,7 +6803,7 @@ public:
}
};
-}
+} // end anonymous namespace
void ASTReader::FindFileRegionDecls(FileID File,
unsigned Offset, unsigned Length,
@@ -6630,7 +6842,7 @@ void ASTReader::FindFileRegionDecls(FileID File,
EndLoc, DIDComp);
if (EndIt != DInfo.Decls.end())
++EndIt;
-
+
for (ArrayRef<serialization::LocalDeclID>::iterator
DIt = BeginIt; DIt != EndIt; ++DIt)
Decls.push_back(GetDecl(getGlobalDeclID(*DInfo.Mod, *DIt)));
@@ -6841,23 +7053,23 @@ void ASTReader::PrintStats() {
std::fprintf(stderr, "\n");
GlobalIndex->printStats();
}
-
+
std::fprintf(stderr, "\n");
dump();
std::fprintf(stderr, "\n");
}
template<typename Key, typename ModuleFile, unsigned InitialCapacity>
-static void
+static void
dumpModuleIDMap(StringRef Name,
- const ContinuousRangeMap<Key, ModuleFile *,
+ const ContinuousRangeMap<Key, ModuleFile *,
InitialCapacity> &Map) {
if (Map.begin() == Map.end())
return;
-
+
typedef ContinuousRangeMap<Key, ModuleFile *, InitialCapacity> MapType;
llvm::errs() << Name << ":\n";
- for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
+ for (typename MapType::const_iterator I = Map.begin(), IEnd = Map.end();
I != IEnd; ++I) {
llvm::errs() << " " << I->first << " -> " << I->second->FileName
<< "\n";
@@ -6874,11 +7086,11 @@ LLVM_DUMP_METHOD void ASTReader::dump() {
dumpModuleIDMap("Global macro map", GlobalMacroMap);
dumpModuleIDMap("Global submodule map", GlobalSubmoduleMap);
dumpModuleIDMap("Global selector map", GlobalSelectorMap);
- dumpModuleIDMap("Global preprocessed entity map",
+ dumpModuleIDMap("Global preprocessed entity map",
GlobalPreprocessedEntityMap);
-
+
llvm::errs() << "\n*** PCH/Modules Loaded:";
- for (ModuleManager::ModuleConstIterator M = ModuleMgr.begin(),
+ for (ModuleManager::ModuleConstIterator M = ModuleMgr.begin(),
MEnd = ModuleMgr.end();
M != MEnd; ++M)
(*M)->dump();
@@ -6921,14 +7133,9 @@ void ASTReader::InitializeSema(Sema &S) {
SemaObj->FPFeatures.fp_contract = FPPragmaOptions[0];
}
- // FIXME: What happens if these are changed by a module import?
- if (!OpenCLExtensions.empty()) {
- unsigned I = 0;
-#define OPENCLEXT(nm) SemaObj->OpenCLFeatures.nm = OpenCLExtensions[I++];
-#include "clang/Basic/OpenCLExtensions.def"
-
- assert(OpenCLExtensions.size() == I && "Wrong number of OPENCL_EXTENSIONS");
- }
+ SemaObj->OpenCLFeatures.copy(OpenCLExtensions);
+ SemaObj->OpenCLTypeExtMap = OpenCLTypeExtMap;
+ SemaObj->OpenCLDeclExtMap = OpenCLDeclExtMap;
UpdateSema();
}
@@ -6939,12 +7146,14 @@ void ASTReader::UpdateSema() {
// Load the offsets of the declarations that Sema references.
// They will be lazily deserialized when needed.
if (!SemaDeclRefs.empty()) {
- assert(SemaDeclRefs.size() % 2 == 0);
- for (unsigned I = 0; I != SemaDeclRefs.size(); I += 2) {
+ assert(SemaDeclRefs.size() % 3 == 0);
+ for (unsigned I = 0; I != SemaDeclRefs.size(); I += 3) {
if (!SemaObj->StdNamespace)
SemaObj->StdNamespace = SemaDeclRefs[I];
if (!SemaObj->StdBadAlloc)
SemaObj->StdBadAlloc = SemaDeclRefs[I+1];
+ if (!SemaObj->StdAlignValT)
+ SemaObj->StdAlignValT = SemaDeclRefs[I+2];
}
SemaDeclRefs.clear();
}
@@ -6961,6 +7170,7 @@ void ASTReader::UpdateSema() {
PragmaMSPointersToMembersState,
PointersToMembersPragmaLocation);
}
+ SemaObj->ForceCUDAHostDeviceDepth = ForceCUDAHostDeviceDepth;
}
IdentifierInfo *ASTReader::get(StringRef Name) {
@@ -6999,6 +7209,7 @@ IdentifierInfo *ASTReader::get(StringRef Name) {
}
namespace clang {
+
/// \brief An identifier-lookup iterator that enumerates all of the
/// identifiers stored within a set of AST files.
class ASTIdentifierIterator : public IdentifierIterator {
@@ -7026,7 +7237,8 @@ namespace clang {
StringRef Next() override;
};
-}
+
+} // end namespace clang
ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader &Reader,
bool SkipModules)
@@ -7058,6 +7270,7 @@ StringRef ASTIdentifierIterator::Next() {
}
namespace {
+
/// A utility for appending two IdentifierIterators.
class ChainedIdentifierIterator : public IdentifierIterator {
std::unique_ptr<IdentifierIterator> Current;
@@ -7082,6 +7295,7 @@ public:
return Next();
}
};
+
} // end anonymous namespace.
IdentifierIterator *ASTReader::getIdentifiers() {
@@ -7097,7 +7311,9 @@ IdentifierIterator *ASTReader::getIdentifiers() {
return new ASTIdentifierIterator(*this);
}
-namespace clang { namespace serialization {
+namespace clang {
+namespace serialization {
+
class ReadMethodPoolVisitor {
ASTReader &Reader;
Selector Sel;
@@ -7119,7 +7335,7 @@ namespace clang { namespace serialization {
bool operator()(ModuleFile &M) {
if (!M.SelectorLookupTable)
return false;
-
+
// If we've already searched this module file, skip it now.
if (M.Generation <= PriorGeneration)
return true;
@@ -7149,14 +7365,14 @@ namespace clang { namespace serialization {
FactoryHasMoreThanOneDecl = Data.FactoryHasMoreThanOneDecl;
return true;
}
-
+
/// \brief Retrieve the instance methods found by this visitor.
- ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
- return InstanceMethods;
+ ArrayRef<ObjCMethodDecl *> getInstanceMethods() const {
+ return InstanceMethods;
}
/// \brief Retrieve the instance methods found by this visitor.
- ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
+ ArrayRef<ObjCMethodDecl *> getFactoryMethods() const {
return FactoryMethods;
}
@@ -7167,7 +7383,9 @@ namespace clang { namespace serialization {
}
bool factoryHasMoreThanOneDecl() const { return FactoryHasMoreThanOneDecl; }
};
-} } // end namespace clang::serialization
+
+} // end namespace serialization
+} // end namespace clang
/// \brief Add the given set of methods to the method list.
static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods,
@@ -7176,14 +7394,14 @@ static void addMethodsToPool(Sema &S, ArrayRef<ObjCMethodDecl *> Methods,
S.addMethodToGlobalList(&List, Methods[I]);
}
}
-
+
void ASTReader::ReadMethodPool(Selector Sel) {
// Get the selector generation and update it to the current generation.
unsigned &Generation = SelectorGeneration[Sel];
unsigned PriorGeneration = Generation;
Generation = getGeneration();
SelectorOutOfDate[Sel] = false;
-
+
// Search for methods defined with this selector.
++NumMethodPoolLookups;
ReadMethodPoolVisitor Visitor(*this, Sel, PriorGeneration);
@@ -7197,7 +7415,7 @@ void ASTReader::ReadMethodPool(Selector Sel) {
if (!getSema())
return;
-
+
Sema &S = *getSema();
Sema::GlobalMethodPool::iterator Pos
= S.MethodPool.insert(std::make_pair(Sel, Sema::GlobalMethods())).first;
@@ -7222,9 +7440,9 @@ void ASTReader::updateOutOfDateSelector(Selector Sel) {
void ASTReader::ReadKnownNamespaces(
SmallVectorImpl<NamespaceDecl *> &Namespaces) {
Namespaces.clear();
-
+
for (unsigned I = 0, N = KnownNamespaces.size(); I != N; ++I) {
- if (NamespaceDecl *Namespace
+ if (NamespaceDecl *Namespace
= dyn_cast_or_null<NamespaceDecl>(GetDecl(KnownNamespaces[I])))
Namespaces.push_back(Namespace);
}
@@ -7313,7 +7531,7 @@ void ASTReader::ReadReferencedSelectors(
SmallVectorImpl<std::pair<Selector, SourceLocation> > &Sels) {
if (ReferencedSelectorsData.empty())
return;
-
+
// If there are @selector references added them to its pool. This is for
// implementation of -Wselector.
unsigned int DataSize = ReferencedSelectorsData.size()-1;
@@ -7333,9 +7551,9 @@ void ASTReader::ReadWeakUndeclaredIdentifiers(
return;
for (unsigned I = 0, N = WeakUndeclaredIdentifiers.size(); I < N; /*none*/) {
- IdentifierInfo *WeakId
+ IdentifierInfo *WeakId
= DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
- IdentifierInfo *AliasId
+ IdentifierInfo *AliasId
= DecodeIdentifierInfo(WeakUndeclaredIdentifiers[I++]);
SourceLocation Loc
= SourceLocation::getFromRawEncoding(WeakUndeclaredIdentifiers[I++]);
@@ -7355,7 +7573,7 @@ void ASTReader::ReadUsedVTables(SmallVectorImpl<ExternalVTableUse> &VTables) {
VT.DefinitionRequired = VTableUses[Idx++];
VTables.push_back(VT);
}
-
+
VTableUses.clear();
}
@@ -7367,17 +7585,18 @@ void ASTReader::ReadPendingInstantiations(
= SourceLocation::getFromRawEncoding(PendingInstantiations[Idx++]);
Pending.push_back(std::make_pair(D, Loc));
- }
+ }
PendingInstantiations.clear();
}
void ASTReader::ReadLateParsedTemplates(
- llvm::MapVector<const FunctionDecl *, LateParsedTemplate *> &LPTMap) {
+ llvm::MapVector<const FunctionDecl *, std::unique_ptr<LateParsedTemplate>>
+ &LPTMap) {
for (unsigned Idx = 0, N = LateParsedTemplates.size(); Idx < N;
/* In loop */) {
FunctionDecl *FD = cast<FunctionDecl>(GetDecl(LateParsedTemplates[Idx++]));
- LateParsedTemplate *LT = new LateParsedTemplate;
+ auto LT = llvm::make_unique<LateParsedTemplate>();
LT->D = GetDecl(LateParsedTemplates[Idx++]);
ModuleFile *F = getOwningModuleFile(LT->D);
@@ -7388,7 +7607,7 @@ void ASTReader::ReadLateParsedTemplates(
for (unsigned T = 0; T < TokN; ++T)
LT->Toks.push_back(ReadToken(*F, LateParsedTemplates, Idx));
- LPTMap.insert(std::make_pair(FD, LT));
+ LPTMap.insert(std::make_pair(FD, std::move(LT)));
}
LateParsedTemplates.clear();
@@ -7498,12 +7717,12 @@ IdentifierInfo *ASTReader::getLocalIdentifier(ModuleFile &M, unsigned LocalID) {
IdentifierID ASTReader::getGlobalIdentifierID(ModuleFile &M, unsigned LocalID) {
if (LocalID < NUM_PREDEF_IDENT_IDS)
return LocalID;
-
+
ContinuousRangeMap<uint32_t, int, 2>::iterator I
= M.IdentifierRemap.find(LocalID - NUM_PREDEF_IDENT_IDS);
- assert(I != M.IdentifierRemap.end()
+ assert(I != M.IdentifierRemap.end()
&& "Invalid index into identifier index remap");
-
+
return LocalID + I->second;
}
@@ -7524,7 +7743,7 @@ MacroInfo *ASTReader::getMacro(MacroID ID) {
ModuleFile *M = I->second;
unsigned Index = ID - M->BaseMacroID;
MacrosLoaded[ID] = ReadMacroRecord(*M, M->MacroOffsets[Index]);
-
+
if (DeserializationListener)
DeserializationListener->MacroRead(ID + NUM_PREDEF_MACRO_IDS,
MacrosLoaded[ID]);
@@ -7548,12 +7767,12 @@ serialization::SubmoduleID
ASTReader::getGlobalSubmoduleID(ModuleFile &M, unsigned LocalID) {
if (LocalID < NUM_PREDEF_SUBMODULE_IDS)
return LocalID;
-
+
ContinuousRangeMap<uint32_t, int, 2>::iterator I
= M.SubmoduleRemap.find(LocalID - NUM_PREDEF_SUBMODULE_IDS);
- assert(I != M.SubmoduleRemap.end()
+ assert(I != M.SubmoduleRemap.end()
&& "Invalid index into submodule index remap");
-
+
return LocalID + I->second;
}
@@ -7562,12 +7781,12 @@ Module *ASTReader::getSubmodule(SubmoduleID GlobalID) {
assert(GlobalID == 0 && "Unhandled global submodule ID");
return nullptr;
}
-
+
if (GlobalID > SubmodulesLoaded.size()) {
Error("submodule ID out of range in AST file");
return nullptr;
}
-
+
return SubmodulesLoaded[GlobalID - NUM_PREDEF_SUBMODULE_IDS];
}
@@ -7664,17 +7883,17 @@ serialization::SelectorID
ASTReader::getGlobalSelectorID(ModuleFile &M, unsigned LocalID) const {
if (LocalID < NUM_PREDEF_SELECTOR_IDS)
return LocalID;
-
+
ContinuousRangeMap<uint32_t, int, 2>::iterator I
= M.SelectorRemap.find(LocalID - NUM_PREDEF_SELECTOR_IDS);
- assert(I != M.SelectorRemap.end()
+ assert(I != M.SelectorRemap.end()
&& "Invalid index into selector index remap");
-
+
return LocalID + I->second;
}
DeclarationName
-ASTReader::ReadDeclarationName(ModuleFile &F,
+ASTReader::ReadDeclarationName(ModuleFile &F,
const RecordData &Record, unsigned &Idx) {
DeclarationName::NameKind Kind = (DeclarationName::NameKind)Record[Idx++];
switch (Kind) {
@@ -7762,13 +7981,13 @@ void ASTReader::ReadQualifierInfo(ModuleFile &F, QualifierInfo &Info,
Info.NumTemplParamLists = NumTPLists;
if (NumTPLists) {
Info.TemplParamLists = new (Context) TemplateParameterList*[NumTPLists];
- for (unsigned i=0; i != NumTPLists; ++i)
+ for (unsigned i = 0; i != NumTPLists; ++i)
Info.TemplParamLists[i] = ReadTemplateParameterList(F, Record, Idx);
}
}
TemplateName
-ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record,
+ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record,
unsigned &Idx) {
TemplateName::NameKind Kind = (TemplateName::NameKind)Record[Idx++];
switch (Kind) {
@@ -7795,7 +8014,7 @@ ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record,
NestedNameSpecifier *NNS = ReadNestedNameSpecifier(F, Record, Idx);
if (Record[Idx++]) // isIdentifier
return Context.getDependentTemplateName(NNS,
- GetIdentifierInfo(F, Record,
+ GetIdentifierInfo(F, Record,
Idx));
return Context.getDependentTemplateName(NNS,
(OverloadedOperatorKind)Record[Idx++]);
@@ -7808,17 +8027,17 @@ ASTReader::ReadTemplateName(ModuleFile &F, const RecordData &Record,
TemplateName replacement = ReadTemplateName(F, Record, Idx);
return Context.getSubstTemplateTemplateParm(param, replacement);
}
-
+
case TemplateName::SubstTemplateTemplateParmPack: {
- TemplateTemplateParmDecl *Param
+ TemplateTemplateParmDecl *Param
= ReadDeclAs<TemplateTemplateParmDecl>(F, Record, Idx);
if (!Param)
return TemplateName();
-
+
TemplateArgument ArgPack = ReadTemplateArgument(F, Record, Idx);
if (ArgPack.getKind() != TemplateArgument::Pack)
return TemplateName();
-
+
return Context.getSubstTemplateTemplateParmPack(Param, ArgPack);
}
}
@@ -7856,7 +8075,7 @@ TemplateArgument ASTReader::ReadTemplateArgument(ModuleFile &F,
QualType T = readType(F, Record, Idx);
return TemplateArgument(Context, Value, T);
}
- case TemplateArgument::Template:
+ case TemplateArgument::Template:
return TemplateArgument(ReadTemplateName(F, Record, Idx));
case TemplateArgument::TemplateExpansion: {
TemplateName Name = ReadTemplateName(F, Record, Idx);
@@ -7892,9 +8111,10 @@ ASTReader::ReadTemplateParameterList(ModuleFile &F,
while (NumParams--)
Params.push_back(ReadDeclAs<NamedDecl>(F, Record, Idx));
+ // TODO: Concepts
TemplateParameterList* TemplateParams =
TemplateParameterList::Create(Context, TemplateLoc, LAngleLoc,
- Params, RAngleLoc);
+ Params, RAngleLoc, nullptr);
return TemplateParams;
}
@@ -7931,7 +8151,7 @@ ASTReader::ReadCXXBaseSpecifier(ModuleFile &F,
TypeSourceInfo *TInfo = GetTypeSourceInfo(F, Record, Idx);
SourceRange Range = ReadSourceRange(F, Record, Idx);
SourceLocation EllipsisLoc = ReadSourceLocation(F, Record, Idx);
- CXXBaseSpecifier Result(Range, isVirtual, isBaseOfClass, AS, TInfo,
+ CXXBaseSpecifier Result(Range, isVirtual, isBaseOfClass, AS, TInfo,
EllipsisLoc);
Result.setInheritConstructors(inheritConstructors);
return Result;
@@ -7973,49 +8193,29 @@ ASTReader::ReadCXXCtorInitializers(ModuleFile &F, const RecordData &Record,
Expr *Init = ReadExpr(F);
SourceLocation LParenLoc = ReadSourceLocation(F, Record, Idx);
SourceLocation RParenLoc = ReadSourceLocation(F, Record, Idx);
- bool IsWritten = Record[Idx++];
- unsigned SourceOrderOrNumArrayIndices;
- SmallVector<VarDecl *, 8> Indices;
- if (IsWritten) {
- SourceOrderOrNumArrayIndices = Record[Idx++];
- } else {
- SourceOrderOrNumArrayIndices = Record[Idx++];
- Indices.reserve(SourceOrderOrNumArrayIndices);
- for (unsigned i=0; i != SourceOrderOrNumArrayIndices; ++i)
- Indices.push_back(ReadDeclAs<VarDecl>(F, Record, Idx));
- }
CXXCtorInitializer *BOMInit;
- if (Type == CTOR_INITIALIZER_BASE) {
+ if (Type == CTOR_INITIALIZER_BASE)
BOMInit = new (Context)
CXXCtorInitializer(Context, TInfo, IsBaseVirtual, LParenLoc, Init,
RParenLoc, MemberOrEllipsisLoc);
- } else if (Type == CTOR_INITIALIZER_DELEGATING) {
+ else if (Type == CTOR_INITIALIZER_DELEGATING)
BOMInit = new (Context)
CXXCtorInitializer(Context, TInfo, LParenLoc, Init, RParenLoc);
- } else if (IsWritten) {
- if (Member)
- BOMInit = new (Context) CXXCtorInitializer(
- Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc);
- else
- BOMInit = new (Context)
- CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
- LParenLoc, Init, RParenLoc);
- } else {
- if (IndirectMember) {
- assert(Indices.empty() && "Indirect field improperly initialized");
- BOMInit = new (Context)
- CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
- LParenLoc, Init, RParenLoc);
- } else {
- BOMInit = CXXCtorInitializer::Create(
- Context, Member, MemberOrEllipsisLoc, LParenLoc, Init, RParenLoc,
- Indices.data(), Indices.size());
- }
+ else if (Member)
+ BOMInit = new (Context)
+ CXXCtorInitializer(Context, Member, MemberOrEllipsisLoc, LParenLoc,
+ Init, RParenLoc);
+ else
+ BOMInit = new (Context)
+ CXXCtorInitializer(Context, IndirectMember, MemberOrEllipsisLoc,
+ LParenLoc, Init, RParenLoc);
+
+ if (/*IsWritten*/Record[Idx++]) {
+ unsigned SourceOrder = Record[Idx++];
+ BOMInit->setSourceOrder(SourceOrder);
}
- if (IsWritten)
- BOMInit->setSourceOrder(SourceOrderOrNumArrayIndices);
CtorInitializers[i] = BOMInit;
}
@@ -8078,7 +8278,7 @@ ASTReader::ReadNestedNameSpecifier(ModuleFile &F,
}
NestedNameSpecifierLoc
-ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record,
+ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record,
unsigned &Idx) {
unsigned N = Record[Idx++];
NestedNameSpecifierLocBuilder Builder;
@@ -8087,7 +8287,7 @@ ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record,
= (NestedNameSpecifier::SpecifierKind)Record[Idx++];
switch (Kind) {
case NestedNameSpecifier::Identifier: {
- IdentifierInfo *II = GetIdentifierInfo(F, Record, Idx);
+ IdentifierInfo *II = GetIdentifierInfo(F, Record, Idx);
SourceRange Range = ReadSourceRange(F, Record, Idx);
Builder.Extend(Context, II, Range.getBegin(), Range.getEnd());
break;
@@ -8116,7 +8316,7 @@ ASTReader::ReadNestedNameSpecifierLoc(ModuleFile &F, const RecordData &Record,
SourceLocation ColonColonLoc = ReadSourceLocation(F, Record, Idx);
// FIXME: 'template' keyword location not saved anywhere, so we fake it.
- Builder.Extend(Context,
+ Builder.Extend(Context,
Template? T->getTypeLoc().getBeginLoc() : SourceLocation(),
T->getTypeLoc(), ColonColonLoc);
break;
@@ -8185,7 +8385,7 @@ std::string ASTReader::ReadPath(ModuleFile &F, const RecordData &Record,
return Filename;
}
-VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record,
+VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record,
unsigned &Idx) {
unsigned Major = Record[Idx++];
unsigned Minor = Record[Idx++];
@@ -8197,7 +8397,7 @@ VersionTuple ASTReader::ReadVersionTuple(const RecordData &Record,
return VersionTuple(Major, Minor - 1, Subminor - 1);
}
-CXXTemporary *ASTReader::ReadCXXTemporary(ModuleFile &F,
+CXXTemporary *ASTReader::ReadCXXTemporary(ModuleFile &F,
const RecordData &Record,
unsigned &Idx) {
CXXDestructorDecl *Decl = ReadDeclAs<CXXDestructorDecl>(F, Record, Idx);
@@ -8283,6 +8483,10 @@ void ASTReader::ReadComments() {
}
}
NextCursor:
+ // De-serialized SourceLocations get negative FileIDs for other modules,
+ // potentially invalidating the original order. Sort it again.
+ std::sort(Comments.begin(), Comments.end(),
+ BeforeThanCompare<RawComment>(SourceMgr));
Context.Comments.addDeserializedComments(Comments);
}
}
@@ -8350,16 +8554,14 @@ void ASTReader::finishPendingActions() {
for (unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
++IDIdx) {
const PendingMacroInfo &Info = GlobalIDs[IDIdx];
- if (Info.M->Kind != MK_ImplicitModule &&
- Info.M->Kind != MK_ExplicitModule)
+ if (!Info.M->isModule())
resolvePendingMacro(II, Info);
}
// Handle module imports.
for (unsigned IDIdx = 0, NumIDs = GlobalIDs.size(); IDIdx != NumIDs;
++IDIdx) {
const PendingMacroInfo &Info = GlobalIDs[IDIdx];
- if (Info.M->Kind == MK_ImplicitModule ||
- Info.M->Kind == MK_ExplicitModule)
+ if (Info.M->isModule())
resolvePendingMacro(II, Info);
}
}
@@ -8390,7 +8592,7 @@ void ASTReader::finishPendingActions() {
// If we deserialized any C++ or Objective-C class definitions, any
// Objective-C protocol definitions, or any redeclarable templates, make sure
- // that all redeclarations point to the definitions. Note that this can only
+ // that all redeclarations point to the definitions. Note that this can only
// happen now, after the redeclaration chains have been fully wired.
for (Decl *D : PendingDefinitions) {
if (TagDecl *TD = dyn_cast<TagDecl>(D)) {
@@ -8446,8 +8648,11 @@ void ASTReader::finishPendingActions() {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(PB->first)) {
// FIXME: Check for =delete/=default?
// FIXME: Complain about ODR violations here?
- if (!getContext().getLangOpts().Modules || !FD->hasBody())
+ const FunctionDecl *Defn = nullptr;
+ if (!getContext().getLangOpts().Modules || !FD->hasBody(Defn))
FD->setLazyBody(PB->second);
+ else
+ mergeDefinitionVisibility(const_cast<FunctionDecl*>(Defn), FD);
continue;
}
@@ -8542,7 +8747,7 @@ void ASTReader::diagnoseOdrViolations() {
// completed. We only really need to mark FieldDecls as invalid here.
if (!isa<TagDecl>(D))
D->setInvalidDecl();
-
+
// Ensure we don't accidentally recursively enter deserialization while
// we're producing our diagnostic.
Deserializing RecursionGuard(this);
@@ -8617,7 +8822,7 @@ void ASTReader::diagnoseOdrViolations() {
}
void ASTReader::StartedDeserializing() {
- if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
+ if (++NumCurrentElementsDeserializing == 1 && ReadTimer.get())
ReadTimer->startTimer();
}
@@ -8694,7 +8899,10 @@ ASTReader::ASTReader(
bool AllowConfigurationMismatch, bool ValidateSystemInputs,
bool UseGlobalIndex,
std::unique_ptr<llvm::Timer> ReadTimer)
- : Listener(new PCHValidator(PP, *this)), DeserializationListener(nullptr),
+ : Listener(DisableValidation ?
+ cast<ASTReaderListener>(new SimpleASTReaderListener(PP)) :
+ cast<ASTReaderListener>(new PCHValidator(PP, *this))),
+ DeserializationListener(nullptr),
OwnsDeserializationListener(false), SourceMgr(PP.getSourceManager()),
FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
@@ -8743,3 +8951,10 @@ ASTReader::~ASTReader() {
IdentifierResolver &ASTReader::getIdResolver() {
return SemaObj ? SemaObj->IdResolver : DummyIdResolver;
}
+
+unsigned ASTRecordReader::readRecord(llvm::BitstreamCursor &Cursor,
+ unsigned AbbrevID) {
+ Idx = 0;
+ Record.clear();
+ return Cursor.readRecord(AbbrevID, Record);
+}
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index 35da8f3ebcfe..6e18b208a9ae 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -12,10 +12,8 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Serialization/ASTReader.h"
#include "ASTCommon.h"
#include "ASTReaderInternals.h"
-#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclGroup.h"
@@ -24,6 +22,7 @@
#include "clang/AST/Expr.h"
#include "clang/Sema/IdentifierResolver.h"
#include "clang/Sema/SemaDiagnostic.h"
+#include "clang/Serialization/ASTReader.h"
#include "llvm/Support/SaveAndRestore.h"
using namespace clang;
@@ -36,13 +35,11 @@ using namespace clang::serialization;
namespace clang {
class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
ASTReader &Reader;
- ModuleFile &F;
- uint64_t Offset;
+ ASTRecordReader &Record;
+ ASTReader::RecordLocation Loc;
const DeclID ThisDeclID;
const SourceLocation ThisDeclLoc;
typedef ASTReader::RecordData RecordData;
- const RecordData &Record;
- unsigned &Idx;
TypeID TypeIDForTypeDecl;
unsigned AnonymousDeclNumber;
GlobalDeclID NamedDeclForTagDecl;
@@ -57,83 +54,77 @@ namespace clang {
uint64_t GetCurrentCursorOffset();
- uint64_t ReadLocalOffset(const RecordData &R, unsigned &I) {
- uint64_t LocalOffset = R[I++];
- assert(LocalOffset < Offset && "offset point after current record");
- return LocalOffset ? Offset - LocalOffset : 0;
+ uint64_t ReadLocalOffset() {
+ uint64_t LocalOffset = Record.readInt();
+ assert(LocalOffset < Loc.Offset && "offset point after current record");
+ return LocalOffset ? Loc.Offset - LocalOffset : 0;
}
- uint64_t ReadGlobalOffset(ModuleFile &F, const RecordData &R, unsigned &I) {
- uint64_t Local = ReadLocalOffset(R, I);
- return Local ? Reader.getGlobalBitOffset(F, Local) : 0;
+ uint64_t ReadGlobalOffset() {
+ uint64_t Local = ReadLocalOffset();
+ return Local ? Record.getGlobalBitOffset(Local) : 0;
}
- SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
- return Reader.ReadSourceLocation(F, R, I);
+ SourceLocation ReadSourceLocation() {
+ return Record.readSourceLocation();
}
- SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
- return Reader.ReadSourceRange(F, R, I);
+ SourceRange ReadSourceRange() {
+ return Record.readSourceRange();
}
- TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
- return Reader.GetTypeSourceInfo(F, R, I);
+ TypeSourceInfo *GetTypeSourceInfo() {
+ return Record.getTypeSourceInfo();
}
- serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
- return Reader.ReadDeclID(F, R, I);
+ serialization::DeclID ReadDeclID() {
+ return Record.readDeclID();
}
- std::string ReadString(const RecordData &R, unsigned &I) {
- return Reader.ReadString(R, I);
+ std::string ReadString() {
+ return Record.readString();
}
void ReadDeclIDList(SmallVectorImpl<DeclID> &IDs) {
- for (unsigned I = 0, Size = Record[Idx++]; I != Size; ++I)
- IDs.push_back(ReadDeclID(Record, Idx));
+ for (unsigned I = 0, Size = Record.readInt(); I != Size; ++I)
+ IDs.push_back(ReadDeclID());
}
- Decl *ReadDecl(const RecordData &R, unsigned &I) {
- return Reader.ReadDecl(F, R, I);
+ Decl *ReadDecl() {
+ return Record.readDecl();
}
template<typename T>
- T *ReadDeclAs(const RecordData &R, unsigned &I) {
- return Reader.ReadDeclAs<T>(F, R, I);
+ T *ReadDeclAs() {
+ return Record.readDeclAs<T>();
}
- void ReadQualifierInfo(QualifierInfo &Info,
- const RecordData &R, unsigned &I) {
- Reader.ReadQualifierInfo(F, Info, R, I);
- }
-
- void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
- const RecordData &R, unsigned &I) {
- Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
+ void ReadQualifierInfo(QualifierInfo &Info) {
+ Record.readQualifierInfo(Info);
}
-
- void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
- const RecordData &R, unsigned &I) {
- Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
+
+ void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name) {
+ Record.readDeclarationNameLoc(DNLoc, Name);
}
- serialization::SubmoduleID readSubmoduleID(const RecordData &R,
- unsigned &I) {
- if (I >= R.size())
+ serialization::SubmoduleID readSubmoduleID() {
+ if (Record.getIdx() == Record.size())
return 0;
-
- return Reader.getGlobalSubmoduleID(F, R[I++]);
+
+ return Record.getGlobalSubmoduleID(Record.readInt());
}
-
- Module *readModule(const RecordData &R, unsigned &I) {
- return Reader.getSubmodule(readSubmoduleID(R, I));
+
+ Module *readModule() {
+ return Record.getSubmodule(readSubmoduleID());
}
void ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update);
- void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data,
- const RecordData &R, unsigned &I);
+ void ReadCXXDefinitionData(struct CXXRecordDecl::DefinitionData &Data);
void MergeDefinitionData(CXXRecordDecl *D,
struct CXXRecordDecl::DefinitionData &&NewDD);
+ void ReadObjCDefinitionData(struct ObjCInterfaceDecl::DefinitionData &Data);
+ void MergeDefinitionData(ObjCInterfaceDecl *D,
+ struct ObjCInterfaceDecl::DefinitionData &&NewDD);
static NamedDecl *getAnonymousDeclForMerging(ASTReader &Reader,
DeclContext *DC,
@@ -143,13 +134,13 @@ namespace clang {
/// Results from loading a RedeclarableDecl.
class RedeclarableResult {
- GlobalDeclID FirstID;
Decl *MergeWith;
+ GlobalDeclID FirstID;
bool IsKeyDecl;
public:
- RedeclarableResult(GlobalDeclID FirstID, Decl *MergeWith, bool IsKeyDecl)
- : FirstID(FirstID), MergeWith(MergeWith), IsKeyDecl(IsKeyDecl) {}
+ RedeclarableResult(Decl *MergeWith, GlobalDeclID FirstID, bool IsKeyDecl)
+ : MergeWith(MergeWith), FirstID(FirstID), IsKeyDecl(IsKeyDecl) {}
/// \brief Retrieve the first ID.
GlobalDeclID getFirstID() const { return FirstID; }
@@ -171,12 +162,12 @@ namespace clang {
ASTReader &Reader;
NamedDecl *New;
NamedDecl *Existing;
- mutable bool AddResult;
+ bool AddResult;
unsigned AnonymousDeclNumber;
IdentifierInfo *TypedefNameForLinkage;
- void operator=(FindExistingResult&) = delete;
+ void operator=(FindExistingResult &&) = delete;
public:
FindExistingResult(ASTReader &Reader)
@@ -190,7 +181,7 @@ namespace clang {
AnonymousDeclNumber(AnonymousDeclNumber),
TypedefNameForLinkage(TypedefNameForLinkage) {}
- FindExistingResult(const FindExistingResult &Other)
+ FindExistingResult(FindExistingResult &&Other)
: Reader(Other.Reader), New(Other.New), Existing(Other.Existing),
AddResult(Other.AddResult),
AnonymousDeclNumber(Other.AnonymousDeclNumber),
@@ -215,11 +206,11 @@ namespace clang {
FindExistingResult findExisting(NamedDecl *D);
public:
- ASTDeclReader(ASTReader &Reader, ASTReader::RecordLocation Loc,
- DeclID thisDeclID, SourceLocation ThisDeclLoc,
- const RecordData &Record, unsigned &Idx)
- : Reader(Reader), F(*Loc.F), Offset(Loc.Offset), ThisDeclID(thisDeclID),
- ThisDeclLoc(ThisDeclLoc), Record(Record), Idx(Idx),
+ ASTDeclReader(ASTReader &Reader, ASTRecordReader &Record,
+ ASTReader::RecordLocation Loc,
+ DeclID thisDeclID, SourceLocation ThisDeclLoc)
+ : Reader(Reader), Record(Record), Loc(Loc),
+ ThisDeclID(thisDeclID), ThisDeclLoc(ThisDeclLoc),
TypeIDForTypeDecl(0), NamedDeclForTagDecl(0),
TypedefNameForLinkage(nullptr), HasPendingBody(false),
IsDeclMarkedUsed(false) {}
@@ -251,8 +242,7 @@ namespace clang {
void Visit(Decl *D);
- void UpdateDecl(Decl *D, ModuleFile &ModuleFile,
- const RecordData &Record);
+ void UpdateDecl(Decl *D);
static void setNextObjCCategory(ObjCCategoryDecl *Cat,
ObjCCategoryDecl *Next) {
@@ -313,6 +303,8 @@ namespace clang {
void VisitVarDecl(VarDecl *VD) { VisitVarDeclImpl(VD); }
void VisitImplicitParamDecl(ImplicitParamDecl *PD);
void VisitParmVarDecl(ParmVarDecl *PD);
+ void VisitDecompositionDecl(DecompositionDecl *DD);
+ void VisitBindingDecl(BindingDecl *BD);
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
DeclID VisitTemplateDecl(TemplateDecl *D);
RedeclarableResult VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
@@ -323,9 +315,11 @@ namespace clang {
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
void VisitUsingDecl(UsingDecl *D);
+ void VisitUsingPackDecl(UsingPackDecl *D);
void VisitUsingShadowDecl(UsingShadowDecl *D);
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
+ void VisitExportDecl(ExportDecl *D);
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
void VisitImportDecl(ImportDecl *D);
void VisitAccessSpecDecl(AccessSpecDecl *D);
@@ -377,27 +371,6 @@ namespace clang {
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
-
- /// We've merged the definition \p MergedDef into the existing definition
- /// \p Def. Ensure that \p Def is made visible whenever \p MergedDef is made
- /// visible.
- void mergeDefinitionVisibility(NamedDecl *Def, NamedDecl *MergedDef) {
- if (Def->isHidden()) {
- // If MergedDef is visible or becomes visible, make the definition visible.
- if (!MergedDef->isHidden())
- Def->Hidden = false;
- else if (Reader.getContext().getLangOpts().ModulesLocalVisibility) {
- Reader.getContext().mergeDefinitionIntoModule(
- Def, MergedDef->getImportedOwningModule(),
- /*NotifyListeners*/ false);
- Reader.PendingMergedDefinitionsToDeduplicate.insert(Def);
- } else {
- auto SubmoduleID = MergedDef->getOwningModuleID();
- assert(SubmoduleID && "hidden definition in no module");
- Reader.HiddenNamesMap[Reader.getSubmodule(SubmoduleID)].push_back(Def);
- }
- }
- }
};
} // end namespace clang
@@ -437,14 +410,15 @@ public:
};
} // end anonymous namespace
-template<typename DeclT>
-llvm::iterator_range<MergedRedeclIterator<DeclT>> merged_redecls(DeclT *D) {
+template <typename DeclT>
+static llvm::iterator_range<MergedRedeclIterator<DeclT>>
+merged_redecls(DeclT *D) {
return llvm::make_range(MergedRedeclIterator<DeclT>(D),
MergedRedeclIterator<DeclT>());
}
uint64_t ASTDeclReader::GetCurrentCursorOffset() {
- return F.DeclsCursor.GetCurrentBitNo() + F.GlobalBitOffset;
+ return Loc.F->DeclsCursor.GetCurrentBitNo() + Loc.F->GlobalBitOffset;
}
void ASTDeclReader::Visit(Decl *D) {
@@ -459,11 +433,10 @@ void ASTDeclReader::Visit(Decl *D) {
if (DD->DeclInfo) {
DeclaratorDecl::ExtInfo *Info =
DD->DeclInfo.get<DeclaratorDecl::ExtInfo *>();
- Info->TInfo =
- GetTypeSourceInfo(Record, Idx);
+ Info->TInfo = GetTypeSourceInfo();
}
else {
- DD->DeclInfo = GetTypeSourceInfo(Record, Idx);
+ DD->DeclInfo = GetTypeSourceInfo();
}
}
@@ -484,11 +457,11 @@ void ASTDeclReader::Visit(Decl *D) {
// We only read it if FD doesn't already have a body (e.g., from another
// module).
// FIXME: Can we diagnose ODR violations somehow?
- if (Record[Idx++]) {
+ if (Record.readInt()) {
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
- CD->NumCtorInitializers = Record[Idx++];
+ CD->NumCtorInitializers = Record.readInt();
if (CD->NumCtorInitializers)
- CD->CtorInitializers = ReadGlobalOffset(F, Record, Idx);
+ CD->CtorInitializers = ReadGlobalOffset();
}
Reader.PendingBodies[FD] = GetCurrentCursorOffset();
HasPendingBody = true;
@@ -505,8 +478,8 @@ void ASTDeclReader::VisitDecl(Decl *D) {
// example, a function parameter can be used in decltype() in trailing
// return type of the function). Use the translation unit DeclContext as a
// placeholder.
- GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
- GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID(Record, Idx);
+ GlobalDeclID SemaDCIDForTemplateParmDecl = ReadDeclID();
+ GlobalDeclID LexicalDCIDForTemplateParmDecl = ReadDeclID();
if (!LexicalDCIDForTemplateParmDecl)
LexicalDCIDForTemplateParmDecl = SemaDCIDForTemplateParmDecl;
Reader.addPendingDeclContextInfo(D,
@@ -514,8 +487,8 @@ void ASTDeclReader::VisitDecl(Decl *D) {
LexicalDCIDForTemplateParmDecl);
D->setDeclContext(Reader.getContext().getTranslationUnitDecl());
} else {
- DeclContext *SemaDC = ReadDeclAs<DeclContext>(Record, Idx);
- DeclContext *LexicalDC = ReadDeclAs<DeclContext>(Record, Idx);
+ DeclContext *SemaDC = ReadDeclAs<DeclContext>();
+ DeclContext *LexicalDC = ReadDeclAs<DeclContext>();
if (!LexicalDC)
LexicalDC = SemaDC;
DeclContext *MergedSemaDC = Reader.MergedDeclContexts.lookup(SemaDC);
@@ -525,27 +498,27 @@ void ASTDeclReader::VisitDecl(Decl *D) {
Reader.getContext());
}
D->setLocation(ThisDeclLoc);
- D->setInvalidDecl(Record[Idx++]);
- if (Record[Idx++]) { // hasAttrs
+ D->setInvalidDecl(Record.readInt());
+ if (Record.readInt()) { // hasAttrs
AttrVec Attrs;
- Reader.ReadAttributes(F, Attrs, Record, Idx);
+ Record.readAttributes(Attrs);
// Avoid calling setAttrs() directly because it uses Decl::getASTContext()
// internally which is unsafe during derialization.
D->setAttrsImpl(Attrs, Reader.getContext());
}
- D->setImplicit(Record[Idx++]);
- D->Used = Record[Idx++];
+ D->setImplicit(Record.readInt());
+ D->Used = Record.readInt();
IsDeclMarkedUsed |= D->Used;
- D->setReferenced(Record[Idx++]);
- D->setTopLevelDeclInObjCContainer(Record[Idx++]);
- D->setAccess((AccessSpecifier)Record[Idx++]);
+ D->setReferenced(Record.readInt());
+ D->setTopLevelDeclInObjCContainer(Record.readInt());
+ D->setAccess((AccessSpecifier)Record.readInt());
D->FromASTFile = true;
- D->setModulePrivate(Record[Idx++]);
+ D->setModulePrivate(Record.readInt());
D->Hidden = D->isModulePrivate();
// Determine whether this declaration is part of a (sub)module. If so, it
// may not yet be visible.
- if (unsigned SubmoduleID = readSubmoduleID(Record, Idx)) {
+ if (unsigned SubmoduleID = readSubmoduleID()) {
// Store the owning submodule ID in the declaration.
D->setOwningModuleID(SubmoduleID);
@@ -571,22 +544,22 @@ void ASTDeclReader::VisitDecl(Decl *D) {
void ASTDeclReader::VisitPragmaCommentDecl(PragmaCommentDecl *D) {
VisitDecl(D);
- D->setLocation(ReadSourceLocation(Record, Idx));
- D->CommentKind = (PragmaMSCommentKind)Record[Idx++];
- std::string Arg = ReadString(Record, Idx);
+ D->setLocation(ReadSourceLocation());
+ D->CommentKind = (PragmaMSCommentKind)Record.readInt();
+ std::string Arg = ReadString();
memcpy(D->getTrailingObjects<char>(), Arg.data(), Arg.size());
D->getTrailingObjects<char>()[Arg.size()] = '\0';
}
void ASTDeclReader::VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D) {
VisitDecl(D);
- D->setLocation(ReadSourceLocation(Record, Idx));
- std::string Name = ReadString(Record, Idx);
+ D->setLocation(ReadSourceLocation());
+ std::string Name = ReadString();
memcpy(D->getTrailingObjects<char>(), Name.data(), Name.size());
D->getTrailingObjects<char>()[Name.size()] = '\0';
D->ValueStart = Name.size() + 1;
- std::string Value = ReadString(Record, Idx);
+ std::string Value = ReadString();
memcpy(D->getTrailingObjects<char>() + D->ValueStart, Value.data(),
Value.size());
D->getTrailingObjects<char>()[D->ValueStart + Value.size()] = '\0';
@@ -598,24 +571,24 @@ void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
void ASTDeclReader::VisitNamedDecl(NamedDecl *ND) {
VisitDecl(ND);
- ND->setDeclName(Reader.ReadDeclarationName(F, Record, Idx));
- AnonymousDeclNumber = Record[Idx++];
+ ND->setDeclName(Record.readDeclarationName());
+ AnonymousDeclNumber = Record.readInt();
}
void ASTDeclReader::VisitTypeDecl(TypeDecl *TD) {
VisitNamedDecl(TD);
- TD->setLocStart(ReadSourceLocation(Record, Idx));
+ TD->setLocStart(ReadSourceLocation());
// Delay type reading until after we have fully initialized the decl.
- TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]);
+ TypeIDForTypeDecl = Record.getGlobalTypeID(Record.readInt());
}
ASTDeclReader::RedeclarableResult
ASTDeclReader::VisitTypedefNameDecl(TypedefNameDecl *TD) {
RedeclarableResult Redecl = VisitRedeclarable(TD);
VisitTypeDecl(TD);
- TypeSourceInfo *TInfo = GetTypeSourceInfo(Record, Idx);
- if (Record[Idx++]) { // isModed
- QualType modedT = Reader.readType(F, Record, Idx);
+ TypeSourceInfo *TInfo = GetTypeSourceInfo();
+ if (Record.readInt()) { // isModed
+ QualType modedT = Record.readType();
TD->setModedTypeSourceInfo(TInfo, modedT);
} else
TD->setTypeSourceInfo(TInfo);
@@ -629,7 +602,7 @@ void ASTDeclReader::VisitTypedefDecl(TypedefDecl *TD) {
void ASTDeclReader::VisitTypeAliasDecl(TypeAliasDecl *TD) {
RedeclarableResult Redecl = VisitTypedefNameDecl(TD);
- if (auto *Template = ReadDeclAs<TypeAliasTemplateDecl>(Record, Idx))
+ if (auto *Template = ReadDeclAs<TypeAliasTemplateDecl>())
// Merged when we merge the template.
TD->setDescribedAliasTemplate(Template);
else
@@ -640,27 +613,27 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) {
RedeclarableResult Redecl = VisitRedeclarable(TD);
VisitTypeDecl(TD);
- TD->IdentifierNamespace = Record[Idx++];
- TD->setTagKind((TagDecl::TagKind)Record[Idx++]);
+ TD->IdentifierNamespace = Record.readInt();
+ TD->setTagKind((TagDecl::TagKind)Record.readInt());
if (!isa<CXXRecordDecl>(TD))
- TD->setCompleteDefinition(Record[Idx++]);
- TD->setEmbeddedInDeclarator(Record[Idx++]);
- TD->setFreeStanding(Record[Idx++]);
- TD->setCompleteDefinitionRequired(Record[Idx++]);
- TD->setBraceRange(ReadSourceRange(Record, Idx));
+ TD->setCompleteDefinition(Record.readInt());
+ TD->setEmbeddedInDeclarator(Record.readInt());
+ TD->setFreeStanding(Record.readInt());
+ TD->setCompleteDefinitionRequired(Record.readInt());
+ TD->setBraceRange(ReadSourceRange());
- switch (Record[Idx++]) {
+ switch (Record.readInt()) {
case 0:
break;
case 1: { // ExtInfo
TagDecl::ExtInfo *Info = new (Reader.getContext()) TagDecl::ExtInfo();
- ReadQualifierInfo(*Info, Record, Idx);
+ ReadQualifierInfo(*Info);
TD->TypedefNameDeclOrQualifier = Info;
break;
}
case 2: // TypedefNameForAnonDecl
- NamedDeclForTagDecl = ReadDeclID(Record, Idx);
- TypedefNameForLinkage = Reader.GetIdentifierInfo(F, Record, Idx);
+ NamedDeclForTagDecl = ReadDeclID();
+ TypedefNameForLinkage = Record.getIdentifierInfo();
break;
default:
llvm_unreachable("unexpected tag info kind");
@@ -673,16 +646,16 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) {
void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
VisitTagDecl(ED);
- if (TypeSourceInfo *TI = Reader.GetTypeSourceInfo(F, Record, Idx))
+ if (TypeSourceInfo *TI = GetTypeSourceInfo())
ED->setIntegerTypeSourceInfo(TI);
else
- ED->setIntegerType(Reader.readType(F, Record, Idx));
- ED->setPromotionType(Reader.readType(F, Record, Idx));
- ED->setNumPositiveBits(Record[Idx++]);
- ED->setNumNegativeBits(Record[Idx++]);
- ED->IsScoped = Record[Idx++];
- ED->IsScopedUsingClassTag = Record[Idx++];
- ED->IsFixed = Record[Idx++];
+ ED->setIntegerType(Record.readType());
+ ED->setPromotionType(Record.readType());
+ ED->setNumPositiveBits(Record.readInt());
+ ED->setNumNegativeBits(Record.readInt());
+ ED->IsScoped = Record.readInt();
+ ED->IsScopedUsingClassTag = Record.readInt();
+ ED->IsFixed = Record.readInt();
// If this is a definition subject to the ODR, and we already have a
// definition, merge this one into it.
@@ -703,15 +676,16 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
if (OldDef) {
Reader.MergedDeclContexts.insert(std::make_pair(ED, OldDef));
ED->IsCompleteDefinition = false;
- mergeDefinitionVisibility(OldDef, ED);
+ Reader.mergeDefinitionVisibility(OldDef, ED);
} else {
OldDef = ED;
}
}
- if (EnumDecl *InstED = ReadDeclAs<EnumDecl>(Record, Idx)) {
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
- SourceLocation POI = ReadSourceLocation(Record, Idx);
+ if (EnumDecl *InstED = ReadDeclAs<EnumDecl>()) {
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
+ SourceLocation POI = ReadSourceLocation();
ED->setInstantiationOfMemberEnum(Reader.getContext(), InstED, TSK);
ED->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
}
@@ -720,33 +694,33 @@ void ASTDeclReader::VisitEnumDecl(EnumDecl *ED) {
ASTDeclReader::RedeclarableResult
ASTDeclReader::VisitRecordDeclImpl(RecordDecl *RD) {
RedeclarableResult Redecl = VisitTagDecl(RD);
- RD->setHasFlexibleArrayMember(Record[Idx++]);
- RD->setAnonymousStructOrUnion(Record[Idx++]);
- RD->setHasObjectMember(Record[Idx++]);
- RD->setHasVolatileMember(Record[Idx++]);
+ RD->setHasFlexibleArrayMember(Record.readInt());
+ RD->setAnonymousStructOrUnion(Record.readInt());
+ RD->setHasObjectMember(Record.readInt());
+ RD->setHasVolatileMember(Record.readInt());
return Redecl;
}
void ASTDeclReader::VisitValueDecl(ValueDecl *VD) {
VisitNamedDecl(VD);
- VD->setType(Reader.readType(F, Record, Idx));
+ VD->setType(Record.readType());
}
void ASTDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) {
VisitValueDecl(ECD);
- if (Record[Idx++])
- ECD->setInitExpr(Reader.ReadExpr(F));
- ECD->setInitVal(Reader.ReadAPSInt(Record, Idx));
+ if (Record.readInt())
+ ECD->setInitExpr(Record.readExpr());
+ ECD->setInitVal(Record.readAPSInt());
mergeMergeable(ECD);
}
void ASTDeclReader::VisitDeclaratorDecl(DeclaratorDecl *DD) {
VisitValueDecl(DD);
- DD->setInnerLocStart(ReadSourceLocation(Record, Idx));
- if (Record[Idx++]) { // hasExtInfo
+ DD->setInnerLocStart(ReadSourceLocation());
+ if (Record.readInt()) { // hasExtInfo
DeclaratorDecl::ExtInfo *Info
= new (Reader.getContext()) DeclaratorDecl::ExtInfo();
- ReadQualifierInfo(*Info, Record, Idx);
+ ReadQualifierInfo(*Info);
DD->DeclInfo = Info;
}
}
@@ -755,74 +729,72 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
RedeclarableResult Redecl = VisitRedeclarable(FD);
VisitDeclaratorDecl(FD);
- ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName(), Record, Idx);
- FD->IdentifierNamespace = Record[Idx++];
-
+ ReadDeclarationNameLoc(FD->DNLoc, FD->getDeclName());
+ FD->IdentifierNamespace = Record.readInt();
+
// FunctionDecl's body is handled last at ASTDeclReader::Visit,
// after everything else is read.
- FD->SClass = (StorageClass)Record[Idx++];
- FD->IsInline = Record[Idx++];
- FD->IsInlineSpecified = Record[Idx++];
- FD->IsVirtualAsWritten = Record[Idx++];
- FD->IsPure = Record[Idx++];
- FD->HasInheritedPrototype = Record[Idx++];
- FD->HasWrittenPrototype = Record[Idx++];
- FD->IsDeleted = Record[Idx++];
- FD->IsTrivial = Record[Idx++];
- FD->IsDefaulted = Record[Idx++];
- FD->IsExplicitlyDefaulted = Record[Idx++];
- FD->HasImplicitReturnZero = Record[Idx++];
- FD->IsConstexpr = Record[Idx++];
- FD->HasSkippedBody = Record[Idx++];
- FD->IsLateTemplateParsed = Record[Idx++];
- FD->setCachedLinkage(Linkage(Record[Idx++]));
- FD->EndRangeLoc = ReadSourceLocation(Record, Idx);
-
- switch ((FunctionDecl::TemplatedKind)Record[Idx++]) {
+ FD->SClass = (StorageClass)Record.readInt();
+ FD->IsInline = Record.readInt();
+ FD->IsInlineSpecified = Record.readInt();
+ FD->IsVirtualAsWritten = Record.readInt();
+ FD->IsPure = Record.readInt();
+ FD->HasInheritedPrototype = Record.readInt();
+ FD->HasWrittenPrototype = Record.readInt();
+ FD->IsDeleted = Record.readInt();
+ FD->IsTrivial = Record.readInt();
+ FD->IsDefaulted = Record.readInt();
+ FD->IsExplicitlyDefaulted = Record.readInt();
+ FD->HasImplicitReturnZero = Record.readInt();
+ FD->IsConstexpr = Record.readInt();
+ FD->HasSkippedBody = Record.readInt();
+ FD->IsLateTemplateParsed = Record.readInt();
+ FD->setCachedLinkage(Linkage(Record.readInt()));
+ FD->EndRangeLoc = ReadSourceLocation();
+
+ switch ((FunctionDecl::TemplatedKind)Record.readInt()) {
case FunctionDecl::TK_NonTemplate:
mergeRedeclarable(FD, Redecl);
break;
case FunctionDecl::TK_FunctionTemplate:
// Merged when we merge the template.
- FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>(Record,
- Idx));
+ FD->setDescribedFunctionTemplate(ReadDeclAs<FunctionTemplateDecl>());
break;
case FunctionDecl::TK_MemberSpecialization: {
- FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>(Record, Idx);
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
- SourceLocation POI = ReadSourceLocation(Record, Idx);
+ FunctionDecl *InstFD = ReadDeclAs<FunctionDecl>();
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
+ SourceLocation POI = ReadSourceLocation();
FD->setInstantiationOfMemberFunction(Reader.getContext(), InstFD, TSK);
FD->getMemberSpecializationInfo()->setPointOfInstantiation(POI);
mergeRedeclarable(FD, Redecl);
break;
}
case FunctionDecl::TK_FunctionTemplateSpecialization: {
- FunctionTemplateDecl *Template = ReadDeclAs<FunctionTemplateDecl>(Record,
- Idx);
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
-
+ FunctionTemplateDecl *Template = ReadDeclAs<FunctionTemplateDecl>();
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
+
// Template arguments.
SmallVector<TemplateArgument, 8> TemplArgs;
- Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
- /*Canonicalize*/ true);
+ Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
// Template args as written.
SmallVector<TemplateArgumentLoc, 8> TemplArgLocs;
SourceLocation LAngleLoc, RAngleLoc;
- bool HasTemplateArgumentsAsWritten = Record[Idx++];
+ bool HasTemplateArgumentsAsWritten = Record.readInt();
if (HasTemplateArgumentsAsWritten) {
- unsigned NumTemplateArgLocs = Record[Idx++];
+ unsigned NumTemplateArgLocs = Record.readInt();
TemplArgLocs.reserve(NumTemplateArgLocs);
for (unsigned i=0; i != NumTemplateArgLocs; ++i)
- TemplArgLocs.push_back(
- Reader.ReadTemplateArgumentLoc(F, Record, Idx));
-
- LAngleLoc = ReadSourceLocation(Record, Idx);
- RAngleLoc = ReadSourceLocation(Record, Idx);
+ TemplArgLocs.push_back(Record.readTemplateArgumentLoc());
+
+ LAngleLoc = ReadSourceLocation();
+ RAngleLoc = ReadSourceLocation();
}
-
- SourceLocation POI = ReadSourceLocation(Record, Idx);
+
+ SourceLocation POI = ReadSourceLocation();
ASTContext &C = Reader.getContext();
TemplateArgumentList *TemplArgList
@@ -841,8 +813,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
if (FD->isCanonicalDecl()) { // if canonical add to template's set.
// The template that contains the specializations set. It's not safe to
// use getCanonicalDecl on Template since it may still be initializing.
- FunctionTemplateDecl *CanonTemplate
- = ReadDeclAs<FunctionTemplateDecl>(Record, Idx);
+ FunctionTemplateDecl *CanonTemplate = ReadDeclAs<FunctionTemplateDecl>();
// Get the InsertPos by FindNodeOrInsertPos() instead of calling
// InsertNode(FTInfo) directly to avoid the getASTContext() call in
// FunctionTemplateSpecializationInfo's Profile().
@@ -867,18 +838,18 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
case FunctionDecl::TK_DependentFunctionTemplateSpecialization: {
// Templates.
UnresolvedSet<8> TemplDecls;
- unsigned NumTemplates = Record[Idx++];
+ unsigned NumTemplates = Record.readInt();
while (NumTemplates--)
- TemplDecls.addDecl(ReadDeclAs<NamedDecl>(Record, Idx));
-
+ TemplDecls.addDecl(ReadDeclAs<NamedDecl>());
+
// Templates args.
TemplateArgumentListInfo TemplArgs;
- unsigned NumArgs = Record[Idx++];
+ unsigned NumArgs = Record.readInt();
while (NumArgs--)
- TemplArgs.addArgument(Reader.ReadTemplateArgumentLoc(F, Record, Idx));
- TemplArgs.setLAngleLoc(ReadSourceLocation(Record, Idx));
- TemplArgs.setRAngleLoc(ReadSourceLocation(Record, Idx));
-
+ TemplArgs.addArgument(Record.readTemplateArgumentLoc());
+ TemplArgs.setLAngleLoc(ReadSourceLocation());
+ TemplArgs.setRAngleLoc(ReadSourceLocation());
+
FD->setDependentTemplateSpecialization(Reader.getContext(),
TemplDecls, TemplArgs);
// These are not merged; we don't need to merge redeclarations of dependent
@@ -888,55 +859,55 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
}
// Read in the parameters.
- unsigned NumParams = Record[Idx++];
+ unsigned NumParams = Record.readInt();
SmallVector<ParmVarDecl *, 16> Params;
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
- Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
+ Params.push_back(ReadDeclAs<ParmVarDecl>());
FD->setParams(Reader.getContext(), Params);
}
void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
VisitNamedDecl(MD);
- if (Record[Idx++]) {
+ if (Record.readInt()) {
// Load the body on-demand. Most clients won't care, because method
// definitions rarely show up in headers.
Reader.PendingBodies[MD] = GetCurrentCursorOffset();
HasPendingBody = true;
- MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
- MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>(Record, Idx));
- }
- MD->setInstanceMethod(Record[Idx++]);
- MD->setVariadic(Record[Idx++]);
- MD->setPropertyAccessor(Record[Idx++]);
- MD->setDefined(Record[Idx++]);
- MD->IsOverriding = Record[Idx++];
- MD->HasSkippedBody = Record[Idx++];
-
- MD->IsRedeclaration = Record[Idx++];
- MD->HasRedeclaration = Record[Idx++];
+ MD->setSelfDecl(ReadDeclAs<ImplicitParamDecl>());
+ MD->setCmdDecl(ReadDeclAs<ImplicitParamDecl>());
+ }
+ MD->setInstanceMethod(Record.readInt());
+ MD->setVariadic(Record.readInt());
+ MD->setPropertyAccessor(Record.readInt());
+ MD->setDefined(Record.readInt());
+ MD->IsOverriding = Record.readInt();
+ MD->HasSkippedBody = Record.readInt();
+
+ MD->IsRedeclaration = Record.readInt();
+ MD->HasRedeclaration = Record.readInt();
if (MD->HasRedeclaration)
Reader.getContext().setObjCMethodRedeclaration(MD,
- ReadDeclAs<ObjCMethodDecl>(Record, Idx));
-
- MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record[Idx++]);
- MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record[Idx++]);
- MD->SetRelatedResultType(Record[Idx++]);
- MD->setReturnType(Reader.readType(F, Record, Idx));
- MD->setReturnTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
- MD->DeclEndLoc = ReadSourceLocation(Record, Idx);
- unsigned NumParams = Record[Idx++];
+ ReadDeclAs<ObjCMethodDecl>());
+
+ MD->setDeclImplementation((ObjCMethodDecl::ImplementationControl)Record.readInt());
+ MD->setObjCDeclQualifier((Decl::ObjCDeclQualifier)Record.readInt());
+ MD->SetRelatedResultType(Record.readInt());
+ MD->setReturnType(Record.readType());
+ MD->setReturnTypeSourceInfo(GetTypeSourceInfo());
+ MD->DeclEndLoc = ReadSourceLocation();
+ unsigned NumParams = Record.readInt();
SmallVector<ParmVarDecl *, 16> Params;
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
- Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
+ Params.push_back(ReadDeclAs<ParmVarDecl>());
- MD->SelLocsKind = Record[Idx++];
- unsigned NumStoredSelLocs = Record[Idx++];
+ MD->SelLocsKind = Record.readInt();
+ unsigned NumStoredSelLocs = Record.readInt();
SmallVector<SourceLocation, 16> SelLocs;
SelLocs.reserve(NumStoredSelLocs);
for (unsigned i = 0; i != NumStoredSelLocs; ++i)
- SelLocs.push_back(ReadSourceLocation(Record, Idx));
+ SelLocs.push_back(ReadSourceLocation());
MD->setParamsAndSelLocs(Reader.getContext(), Params, SelLocs);
}
@@ -944,91 +915,106 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
void ASTDeclReader::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) {
VisitTypedefNameDecl(D);
- D->Variance = Record[Idx++];
- D->Index = Record[Idx++];
- D->VarianceLoc = ReadSourceLocation(Record, Idx);
- D->ColonLoc = ReadSourceLocation(Record, Idx);
+ D->Variance = Record.readInt();
+ D->Index = Record.readInt();
+ D->VarianceLoc = ReadSourceLocation();
+ D->ColonLoc = ReadSourceLocation();
}
void ASTDeclReader::VisitObjCContainerDecl(ObjCContainerDecl *CD) {
VisitNamedDecl(CD);
- CD->setAtStartLoc(ReadSourceLocation(Record, Idx));
- CD->setAtEndRange(ReadSourceRange(Record, Idx));
+ CD->setAtStartLoc(ReadSourceLocation());
+ CD->setAtEndRange(ReadSourceRange());
}
ObjCTypeParamList *ASTDeclReader::ReadObjCTypeParamList() {
- unsigned numParams = Record[Idx++];
+ unsigned numParams = Record.readInt();
if (numParams == 0)
return nullptr;
SmallVector<ObjCTypeParamDecl *, 4> typeParams;
typeParams.reserve(numParams);
for (unsigned i = 0; i != numParams; ++i) {
- auto typeParam = ReadDeclAs<ObjCTypeParamDecl>(Record, Idx);
+ auto typeParam = ReadDeclAs<ObjCTypeParamDecl>();
if (!typeParam)
return nullptr;
typeParams.push_back(typeParam);
}
- SourceLocation lAngleLoc = ReadSourceLocation(Record, Idx);
- SourceLocation rAngleLoc = ReadSourceLocation(Record, Idx);
+ SourceLocation lAngleLoc = ReadSourceLocation();
+ SourceLocation rAngleLoc = ReadSourceLocation();
return ObjCTypeParamList::create(Reader.getContext(), lAngleLoc,
typeParams, rAngleLoc);
}
+void ASTDeclReader::ReadObjCDefinitionData(
+ struct ObjCInterfaceDecl::DefinitionData &Data) {
+ // Read the superclass.
+ Data.SuperClassTInfo = GetTypeSourceInfo();
+
+ Data.EndLoc = ReadSourceLocation();
+ Data.HasDesignatedInitializers = Record.readInt();
+
+ // Read the directly referenced protocols and their SourceLocations.
+ unsigned NumProtocols = Record.readInt();
+ SmallVector<ObjCProtocolDecl *, 16> Protocols;
+ Protocols.reserve(NumProtocols);
+ for (unsigned I = 0; I != NumProtocols; ++I)
+ Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
+ SmallVector<SourceLocation, 16> ProtoLocs;
+ ProtoLocs.reserve(NumProtocols);
+ for (unsigned I = 0; I != NumProtocols; ++I)
+ ProtoLocs.push_back(ReadSourceLocation());
+ Data.ReferencedProtocols.set(Protocols.data(), NumProtocols, ProtoLocs.data(),
+ Reader.getContext());
+
+ // Read the transitive closure of protocols referenced by this class.
+ NumProtocols = Record.readInt();
+ Protocols.clear();
+ Protocols.reserve(NumProtocols);
+ for (unsigned I = 0; I != NumProtocols; ++I)
+ Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>());
+ Data.AllReferencedProtocols.set(Protocols.data(), NumProtocols,
+ Reader.getContext());
+}
+
+void ASTDeclReader::MergeDefinitionData(ObjCInterfaceDecl *D,
+ struct ObjCInterfaceDecl::DefinitionData &&NewDD) {
+ // FIXME: odr checking?
+}
+
void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
RedeclarableResult Redecl = VisitRedeclarable(ID);
VisitObjCContainerDecl(ID);
- TypeIDForTypeDecl = Reader.getGlobalTypeID(F, Record[Idx++]);
+ TypeIDForTypeDecl = Record.getGlobalTypeID(Record.readInt());
mergeRedeclarable(ID, Redecl);
ID->TypeParamList = ReadObjCTypeParamList();
- if (Record[Idx++]) {
+ if (Record.readInt()) {
// Read the definition.
ID->allocateDefinitionData();
-
- // Set the definition data of the canonical declaration, so other
- // redeclarations will see it.
- ID->getCanonicalDecl()->Data = ID->Data;
-
- ObjCInterfaceDecl::DefinitionData &Data = ID->data();
-
- // Read the superclass.
- Data.SuperClassTInfo = GetTypeSourceInfo(Record, Idx);
- Data.EndLoc = ReadSourceLocation(Record, Idx);
- Data.HasDesignatedInitializers = Record[Idx++];
-
- // Read the directly referenced protocols and their SourceLocations.
- unsigned NumProtocols = Record[Idx++];
- SmallVector<ObjCProtocolDecl *, 16> Protocols;
- Protocols.reserve(NumProtocols);
- for (unsigned I = 0; I != NumProtocols; ++I)
- Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
- SmallVector<SourceLocation, 16> ProtoLocs;
- ProtoLocs.reserve(NumProtocols);
- for (unsigned I = 0; I != NumProtocols; ++I)
- ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
- ID->setProtocolList(Protocols.data(), NumProtocols, ProtoLocs.data(),
- Reader.getContext());
-
- // Read the transitive closure of protocols referenced by this class.
- NumProtocols = Record[Idx++];
- Protocols.clear();
- Protocols.reserve(NumProtocols);
- for (unsigned I = 0; I != NumProtocols; ++I)
- Protocols.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
- ID->data().AllReferencedProtocols.set(Protocols.data(), NumProtocols,
- Reader.getContext());
-
- // We will rebuild this list lazily.
- ID->setIvarList(nullptr);
+ ReadObjCDefinitionData(ID->data());
+ ObjCInterfaceDecl *Canon = ID->getCanonicalDecl();
+ if (Canon->Data.getPointer()) {
+ // If we already have a definition, keep the definition invariant and
+ // merge the data.
+ MergeDefinitionData(Canon, std::move(ID->data()));
+ ID->Data = Canon->Data;
+ } else {
+ // Set the definition data of the canonical declaration, so other
+ // redeclarations will see it.
+ ID->getCanonicalDecl()->Data = ID->Data;
+
+ // We will rebuild this list lazily.
+ ID->setIvarList(nullptr);
+ }
// Note that we have deserialized a definition.
Reader.PendingDefinitions.insert(ID);
-
+
// Note that we've loaded this Objective-C class.
Reader.ObjCClassesLoaded.push_back(ID);
} else {
@@ -1038,10 +1024,10 @@ void ASTDeclReader::VisitObjCInterfaceDecl(ObjCInterfaceDecl *ID) {
void ASTDeclReader::VisitObjCIvarDecl(ObjCIvarDecl *IVD) {
VisitFieldDecl(IVD);
- IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record[Idx++]);
+ IVD->setAccessControl((ObjCIvarDecl::AccessControl)Record.readInt());
// This field will be built lazily.
IVD->setNextIvar(nullptr);
- bool synth = Record[Idx++];
+ bool synth = Record.readInt();
IVD->setSynthesize(synth);
}
@@ -1049,27 +1035,27 @@ void ASTDeclReader::VisitObjCProtocolDecl(ObjCProtocolDecl *PD) {
RedeclarableResult Redecl = VisitRedeclarable(PD);
VisitObjCContainerDecl(PD);
mergeRedeclarable(PD, Redecl);
-
- if (Record[Idx++]) {
+
+ if (Record.readInt()) {
// Read the definition.
PD->allocateDefinitionData();
-
+
// Set the definition data of the canonical declaration, so other
// redeclarations will see it.
PD->getCanonicalDecl()->Data = PD->Data;
- unsigned NumProtoRefs = Record[Idx++];
+ unsigned NumProtoRefs = Record.readInt();
SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
ProtoRefs.reserve(NumProtoRefs);
for (unsigned I = 0; I != NumProtoRefs; ++I)
- ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
+ ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
SmallVector<SourceLocation, 16> ProtoLocs;
ProtoLocs.reserve(NumProtoRefs);
for (unsigned I = 0; I != NumProtoRefs; ++I)
- ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
+ ProtoLocs.push_back(ReadSourceLocation());
PD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
Reader.getContext());
-
+
// Note that we have deserialized a definition.
Reader.PendingDefinitions.insert(PD);
} else {
@@ -1083,105 +1069,104 @@ void ASTDeclReader::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *FD) {
void ASTDeclReader::VisitObjCCategoryDecl(ObjCCategoryDecl *CD) {
VisitObjCContainerDecl(CD);
- CD->setCategoryNameLoc(ReadSourceLocation(Record, Idx));
- CD->setIvarLBraceLoc(ReadSourceLocation(Record, Idx));
- CD->setIvarRBraceLoc(ReadSourceLocation(Record, Idx));
-
+ CD->setCategoryNameLoc(ReadSourceLocation());
+ CD->setIvarLBraceLoc(ReadSourceLocation());
+ CD->setIvarRBraceLoc(ReadSourceLocation());
+
// Note that this category has been deserialized. We do this before
// deserializing the interface declaration, so that it will consider this
/// category.
Reader.CategoriesDeserialized.insert(CD);
- CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>(Record, Idx);
+ CD->ClassInterface = ReadDeclAs<ObjCInterfaceDecl>();
CD->TypeParamList = ReadObjCTypeParamList();
- unsigned NumProtoRefs = Record[Idx++];
+ unsigned NumProtoRefs = Record.readInt();
SmallVector<ObjCProtocolDecl *, 16> ProtoRefs;
ProtoRefs.reserve(NumProtoRefs);
for (unsigned I = 0; I != NumProtoRefs; ++I)
- ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
+ ProtoRefs.push_back(ReadDeclAs<ObjCProtocolDecl>());
SmallVector<SourceLocation, 16> ProtoLocs;
ProtoLocs.reserve(NumProtoRefs);
for (unsigned I = 0; I != NumProtoRefs; ++I)
- ProtoLocs.push_back(ReadSourceLocation(Record, Idx));
+ ProtoLocs.push_back(ReadSourceLocation());
CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
Reader.getContext());
}
void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) {
VisitNamedDecl(CAD);
- CAD->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
+ CAD->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>());
}
void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
VisitNamedDecl(D);
- D->setAtLoc(ReadSourceLocation(Record, Idx));
- D->setLParenLoc(ReadSourceLocation(Record, Idx));
- QualType T = Reader.readType(F, Record, Idx);
- TypeSourceInfo *TSI = GetTypeSourceInfo(Record, Idx);
+ D->setAtLoc(ReadSourceLocation());
+ D->setLParenLoc(ReadSourceLocation());
+ QualType T = Record.readType();
+ TypeSourceInfo *TSI = GetTypeSourceInfo();
D->setType(T, TSI);
D->setPropertyAttributes(
- (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
+ (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
D->setPropertyAttributesAsWritten(
- (ObjCPropertyDecl::PropertyAttributeKind)Record[Idx++]);
+ (ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
D->setPropertyImplementation(
- (ObjCPropertyDecl::PropertyControl)Record[Idx++]);
- D->setGetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector());
- D->setSetterName(Reader.ReadDeclarationName(F,Record, Idx).getObjCSelector());
- D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
- D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
- D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
+ (ObjCPropertyDecl::PropertyControl)Record.readInt());
+ D->setGetterName(Record.readDeclarationName().getObjCSelector());
+ D->setSetterName(Record.readDeclarationName().getObjCSelector());
+ D->setGetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
+ D->setSetterMethodDecl(ReadDeclAs<ObjCMethodDecl>());
+ D->setPropertyIvarDecl(ReadDeclAs<ObjCIvarDecl>());
}
void ASTDeclReader::VisitObjCImplDecl(ObjCImplDecl *D) {
VisitObjCContainerDecl(D);
- D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
+ D->setClassInterface(ReadDeclAs<ObjCInterfaceDecl>());
}
void ASTDeclReader::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
VisitObjCImplDecl(D);
- D->setIdentifier(Reader.GetIdentifierInfo(F, Record, Idx));
- D->CategoryNameLoc = ReadSourceLocation(Record, Idx);
+ D->setIdentifier(Record.getIdentifierInfo());
+ D->CategoryNameLoc = ReadSourceLocation();
}
void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
VisitObjCImplDecl(D);
- D->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
- D->SuperLoc = ReadSourceLocation(Record, Idx);
- D->setIvarLBraceLoc(ReadSourceLocation(Record, Idx));
- D->setIvarRBraceLoc(ReadSourceLocation(Record, Idx));
- D->setHasNonZeroConstructors(Record[Idx++]);
- D->setHasDestructors(Record[Idx++]);
- D->NumIvarInitializers = Record[Idx++];
+ D->setSuperClass(ReadDeclAs<ObjCInterfaceDecl>());
+ D->SuperLoc = ReadSourceLocation();
+ D->setIvarLBraceLoc(ReadSourceLocation());
+ D->setIvarRBraceLoc(ReadSourceLocation());
+ D->setHasNonZeroConstructors(Record.readInt());
+ D->setHasDestructors(Record.readInt());
+ D->NumIvarInitializers = Record.readInt();
if (D->NumIvarInitializers)
- D->IvarInitializers = ReadGlobalOffset(F, Record, Idx);
+ D->IvarInitializers = ReadGlobalOffset();
}
void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
VisitDecl(D);
- D->setAtLoc(ReadSourceLocation(Record, Idx));
- D->setPropertyDecl(ReadDeclAs<ObjCPropertyDecl>(Record, Idx));
- D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>(Record, Idx);
- D->IvarLoc = ReadSourceLocation(Record, Idx);
- D->setGetterCXXConstructor(Reader.ReadExpr(F));
- D->setSetterCXXAssignment(Reader.ReadExpr(F));
+ D->setAtLoc(ReadSourceLocation());
+ D->setPropertyDecl(ReadDeclAs<ObjCPropertyDecl>());
+ D->PropertyIvarDecl = ReadDeclAs<ObjCIvarDecl>();
+ D->IvarLoc = ReadSourceLocation();
+ D->setGetterCXXConstructor(Record.readExpr());
+ D->setSetterCXXAssignment(Record.readExpr());
}
void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) {
VisitDeclaratorDecl(FD);
- FD->Mutable = Record[Idx++];
- if (int BitWidthOrInitializer = Record[Idx++]) {
+ FD->Mutable = Record.readInt();
+ if (int BitWidthOrInitializer = Record.readInt()) {
FD->InitStorage.setInt(
static_cast<FieldDecl::InitStorageKind>(BitWidthOrInitializer - 1));
if (FD->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
// Read captured variable length array.
- FD->InitStorage.setPointer(
- Reader.readType(F, Record, Idx).getAsOpaquePtr());
+ FD->InitStorage.setPointer(Record.readType().getAsOpaquePtr());
} else {
- FD->InitStorage.setPointer(Reader.ReadExpr(F));
+ FD->InitStorage.setPointer(Record.readExpr());
}
}
if (!FD->getDeclName()) {
- if (FieldDecl *Tmpl = ReadDeclAs<FieldDecl>(Record, Idx))
+ if (FieldDecl *Tmpl = ReadDeclAs<FieldDecl>())
Reader.getContext().setInstantiatedFromUnnamedFieldDecl(FD, Tmpl);
}
mergeMergeable(FD);
@@ -1189,19 +1174,19 @@ void ASTDeclReader::VisitFieldDecl(FieldDecl *FD) {
void ASTDeclReader::VisitMSPropertyDecl(MSPropertyDecl *PD) {
VisitDeclaratorDecl(PD);
- PD->GetterId = Reader.GetIdentifierInfo(F, Record, Idx);
- PD->SetterId = Reader.GetIdentifierInfo(F, Record, Idx);
+ PD->GetterId = Record.getIdentifierInfo();
+ PD->SetterId = Record.getIdentifierInfo();
}
void ASTDeclReader::VisitIndirectFieldDecl(IndirectFieldDecl *FD) {
VisitValueDecl(FD);
- FD->ChainingSize = Record[Idx++];
+ FD->ChainingSize = Record.readInt();
assert(FD->ChainingSize >= 2 && "Anonymous chaining must be >= 2");
FD->Chaining = new (Reader.getContext())NamedDecl*[FD->ChainingSize];
for (unsigned I = 0; I != FD->ChainingSize; ++I)
- FD->Chaining[I] = ReadDeclAs<NamedDecl>(Record, Idx);
+ FD->Chaining[I] = ReadDeclAs<NamedDecl>();
mergeMergeable(FD);
}
@@ -1210,21 +1195,23 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
RedeclarableResult Redecl = VisitRedeclarable(VD);
VisitDeclaratorDecl(VD);
- VD->VarDeclBits.SClass = (StorageClass)Record[Idx++];
- VD->VarDeclBits.TSCSpec = Record[Idx++];
- VD->VarDeclBits.InitStyle = Record[Idx++];
+ VD->VarDeclBits.SClass = (StorageClass)Record.readInt();
+ VD->VarDeclBits.TSCSpec = Record.readInt();
+ VD->VarDeclBits.InitStyle = Record.readInt();
if (!isa<ParmVarDecl>(VD)) {
- VD->NonParmVarDeclBits.ExceptionVar = Record[Idx++];
- VD->NonParmVarDeclBits.NRVOVariable = Record[Idx++];
- VD->NonParmVarDeclBits.CXXForRangeDecl = Record[Idx++];
- VD->NonParmVarDeclBits.ARCPseudoStrong = Record[Idx++];
- VD->NonParmVarDeclBits.IsInline = Record[Idx++];
- VD->NonParmVarDeclBits.IsInlineSpecified = Record[Idx++];
- VD->NonParmVarDeclBits.IsConstexpr = Record[Idx++];
- VD->NonParmVarDeclBits.IsInitCapture = Record[Idx++];
- VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope = Record[Idx++];
- }
- Linkage VarLinkage = Linkage(Record[Idx++]);
+ VD->NonParmVarDeclBits.IsThisDeclarationADemotedDefinition =
+ Record.readInt();
+ VD->NonParmVarDeclBits.ExceptionVar = Record.readInt();
+ VD->NonParmVarDeclBits.NRVOVariable = Record.readInt();
+ VD->NonParmVarDeclBits.CXXForRangeDecl = Record.readInt();
+ VD->NonParmVarDeclBits.ARCPseudoStrong = Record.readInt();
+ VD->NonParmVarDeclBits.IsInline = Record.readInt();
+ VD->NonParmVarDeclBits.IsInlineSpecified = Record.readInt();
+ VD->NonParmVarDeclBits.IsConstexpr = Record.readInt();
+ VD->NonParmVarDeclBits.IsInitCapture = Record.readInt();
+ VD->NonParmVarDeclBits.PreviousDeclInSameBlockScope = Record.readInt();
+ }
+ Linkage VarLinkage = Linkage(Record.readInt());
VD->setCachedLinkage(VarLinkage);
// Reconstruct the one piece of the IdentifierNamespace that we need.
@@ -1232,9 +1219,9 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
VD->getLexicalDeclContext()->isFunctionOrMethod())
VD->setLocalExternDecl();
- if (uint64_t Val = Record[Idx++]) {
- VD->setInit(Reader.ReadExpr(F));
- if (Val > 1) {
+ if (uint64_t Val = Record.readInt()) {
+ VD->setInit(Record.readExpr());
+ if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3
EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
Eval->CheckedICE = true;
Eval->IsICE = Val == 3;
@@ -1244,7 +1231,7 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
enum VarKind {
VarNotTemplate = 0, VarTemplate, StaticDataMemberSpecialization
};
- switch ((VarKind)Record[Idx++]) {
+ switch ((VarKind)Record.readInt()) {
case VarNotTemplate:
// Only true variables (not parameters or implicit parameters) can be
// merged; the other kinds are not really redeclarable at all.
@@ -1254,12 +1241,13 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
break;
case VarTemplate:
// Merged when we merge the template.
- VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>(Record, Idx));
+ VD->setDescribedVarTemplate(ReadDeclAs<VarTemplateDecl>());
break;
case StaticDataMemberSpecialization: { // HasMemberSpecializationInfo.
- VarDecl *Tmpl = ReadDeclAs<VarDecl>(Record, Idx);
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
- SourceLocation POI = ReadSourceLocation(Record, Idx);
+ VarDecl *Tmpl = ReadDeclAs<VarDecl>();
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
+ SourceLocation POI = ReadSourceLocation();
Reader.getContext().setInstantiatedFromStaticDataMember(VD, Tmpl, TSK,POI);
mergeRedeclarable(VD, Redecl);
break;
@@ -1275,10 +1263,10 @@ void ASTDeclReader::VisitImplicitParamDecl(ImplicitParamDecl *PD) {
void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
VisitVarDecl(PD);
- unsigned isObjCMethodParam = Record[Idx++];
- unsigned scopeDepth = Record[Idx++];
- unsigned scopeIndex = Record[Idx++];
- unsigned declQualifier = Record[Idx++];
+ unsigned isObjCMethodParam = Record.readInt();
+ unsigned scopeDepth = Record.readInt();
+ unsigned scopeIndex = Record.readInt();
+ unsigned declQualifier = Record.readInt();
if (isObjCMethodParam) {
assert(scopeDepth == 0);
PD->setObjCMethodScopeInfo(scopeIndex);
@@ -1286,46 +1274,58 @@ void ASTDeclReader::VisitParmVarDecl(ParmVarDecl *PD) {
} else {
PD->setScopeInfo(scopeDepth, scopeIndex);
}
- PD->ParmVarDeclBits.IsKNRPromoted = Record[Idx++];
- PD->ParmVarDeclBits.HasInheritedDefaultArg = Record[Idx++];
- if (Record[Idx++]) // hasUninstantiatedDefaultArg.
- PD->setUninstantiatedDefaultArg(Reader.ReadExpr(F));
+ PD->ParmVarDeclBits.IsKNRPromoted = Record.readInt();
+ PD->ParmVarDeclBits.HasInheritedDefaultArg = Record.readInt();
+ if (Record.readInt()) // hasUninstantiatedDefaultArg.
+ PD->setUninstantiatedDefaultArg(Record.readExpr());
// FIXME: If this is a redeclaration of a function from another module, handle
// inheritance of default arguments.
}
+void ASTDeclReader::VisitDecompositionDecl(DecompositionDecl *DD) {
+ VisitVarDecl(DD);
+ BindingDecl **BDs = DD->getTrailingObjects<BindingDecl*>();
+ for (unsigned I = 0; I != DD->NumBindings; ++I)
+ BDs[I] = ReadDeclAs<BindingDecl>();
+}
+
+void ASTDeclReader::VisitBindingDecl(BindingDecl *BD) {
+ VisitValueDecl(BD);
+ BD->Binding = Record.readExpr();
+}
+
void ASTDeclReader::VisitFileScopeAsmDecl(FileScopeAsmDecl *AD) {
VisitDecl(AD);
- AD->setAsmString(cast<StringLiteral>(Reader.ReadExpr(F)));
- AD->setRParenLoc(ReadSourceLocation(Record, Idx));
+ AD->setAsmString(cast<StringLiteral>(Record.readExpr()));
+ AD->setRParenLoc(ReadSourceLocation());
}
void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) {
VisitDecl(BD);
- BD->setBody(cast_or_null<CompoundStmt>(Reader.ReadStmt(F)));
- BD->setSignatureAsWritten(GetTypeSourceInfo(Record, Idx));
- unsigned NumParams = Record[Idx++];
+ BD->setBody(cast_or_null<CompoundStmt>(Record.readStmt()));
+ BD->setSignatureAsWritten(GetTypeSourceInfo());
+ unsigned NumParams = Record.readInt();
SmallVector<ParmVarDecl *, 16> Params;
Params.reserve(NumParams);
for (unsigned I = 0; I != NumParams; ++I)
- Params.push_back(ReadDeclAs<ParmVarDecl>(Record, Idx));
+ Params.push_back(ReadDeclAs<ParmVarDecl>());
BD->setParams(Params);
- BD->setIsVariadic(Record[Idx++]);
- BD->setBlockMissingReturnType(Record[Idx++]);
- BD->setIsConversionFromLambda(Record[Idx++]);
+ BD->setIsVariadic(Record.readInt());
+ BD->setBlockMissingReturnType(Record.readInt());
+ BD->setIsConversionFromLambda(Record.readInt());
- bool capturesCXXThis = Record[Idx++];
- unsigned numCaptures = Record[Idx++];
+ bool capturesCXXThis = Record.readInt();
+ unsigned numCaptures = Record.readInt();
SmallVector<BlockDecl::Capture, 16> captures;
captures.reserve(numCaptures);
for (unsigned i = 0; i != numCaptures; ++i) {
- VarDecl *decl = ReadDeclAs<VarDecl>(Record, Idx);
- unsigned flags = Record[Idx++];
+ VarDecl *decl = ReadDeclAs<VarDecl>();
+ unsigned flags = Record.readInt();
bool byRef = (flags & 1);
bool nested = (flags & 2);
- Expr *copyExpr = ((flags & 4) ? Reader.ReadExpr(F) : nullptr);
+ Expr *copyExpr = ((flags & 4) ? Record.readExpr() : nullptr);
captures.push_back(BlockDecl::Capture(decl, byRef, nested, copyExpr));
}
@@ -1334,35 +1334,40 @@ void ASTDeclReader::VisitBlockDecl(BlockDecl *BD) {
void ASTDeclReader::VisitCapturedDecl(CapturedDecl *CD) {
VisitDecl(CD);
- unsigned ContextParamPos = Record[Idx++];
- CD->setNothrow(Record[Idx++] != 0);
+ unsigned ContextParamPos = Record.readInt();
+ CD->setNothrow(Record.readInt() != 0);
// Body is set by VisitCapturedStmt.
for (unsigned I = 0; I < CD->NumParams; ++I) {
if (I != ContextParamPos)
- CD->setParam(I, ReadDeclAs<ImplicitParamDecl>(Record, Idx));
+ CD->setParam(I, ReadDeclAs<ImplicitParamDecl>());
else
- CD->setContextParam(I, ReadDeclAs<ImplicitParamDecl>(Record, Idx));
+ CD->setContextParam(I, ReadDeclAs<ImplicitParamDecl>());
}
}
void ASTDeclReader::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
VisitDecl(D);
- D->setLanguage((LinkageSpecDecl::LanguageIDs)Record[Idx++]);
- D->setExternLoc(ReadSourceLocation(Record, Idx));
- D->setRBraceLoc(ReadSourceLocation(Record, Idx));
+ D->setLanguage((LinkageSpecDecl::LanguageIDs)Record.readInt());
+ D->setExternLoc(ReadSourceLocation());
+ D->setRBraceLoc(ReadSourceLocation());
+}
+
+void ASTDeclReader::VisitExportDecl(ExportDecl *D) {
+ VisitDecl(D);
+ D->RBraceLoc = ReadSourceLocation();
}
void ASTDeclReader::VisitLabelDecl(LabelDecl *D) {
VisitNamedDecl(D);
- D->setLocStart(ReadSourceLocation(Record, Idx));
+ D->setLocStart(ReadSourceLocation());
}
void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
RedeclarableResult Redecl = VisitRedeclarable(D);
VisitNamedDecl(D);
- D->setInline(Record[Idx++]);
- D->LocStart = ReadSourceLocation(Record, Idx);
- D->RBraceLoc = ReadSourceLocation(Record, Idx);
+ D->setInline(Record.readInt());
+ D->LocStart = ReadSourceLocation();
+ D->RBraceLoc = ReadSourceLocation();
// Defer loading the anonymous namespace until we've finished merging
// this namespace; loading it might load a later declaration of the
@@ -1370,7 +1375,7 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
// get merged before newer ones try to merge.
GlobalDeclID AnonNamespace = 0;
if (Redecl.getFirstID() == ThisDeclID) {
- AnonNamespace = ReadDeclID(Record, Idx);
+ AnonNamespace = ReadDeclID();
} else {
// Link this namespace back to the first declaration, which has already
// been deserialized.
@@ -1384,7 +1389,7 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
// any other module's anonymous namespaces, so don't attach the anonymous
// namespace at all.
NamespaceDecl *Anon = cast<NamespaceDecl>(Reader.GetDecl(AnonNamespace));
- if (F.Kind != MK_ImplicitModule && F.Kind != MK_ExplicitModule)
+ if (!Record.isModule())
D->setAnonymousNamespace(Anon);
}
}
@@ -1392,31 +1397,40 @@ void ASTDeclReader::VisitNamespaceDecl(NamespaceDecl *D) {
void ASTDeclReader::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
RedeclarableResult Redecl = VisitRedeclarable(D);
VisitNamedDecl(D);
- D->NamespaceLoc = ReadSourceLocation(Record, Idx);
- D->IdentLoc = ReadSourceLocation(Record, Idx);
- D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- D->Namespace = ReadDeclAs<NamedDecl>(Record, Idx);
+ D->NamespaceLoc = ReadSourceLocation();
+ D->IdentLoc = ReadSourceLocation();
+ D->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ D->Namespace = ReadDeclAs<NamedDecl>();
mergeRedeclarable(D, Redecl);
}
void ASTDeclReader::VisitUsingDecl(UsingDecl *D) {
VisitNamedDecl(D);
- D->setUsingLoc(ReadSourceLocation(Record, Idx));
- D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx);
- D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>(Record, Idx));
- D->setTypename(Record[Idx++]);
- if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>(Record, Idx))
+ D->setUsingLoc(ReadSourceLocation());
+ D->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ ReadDeclarationNameLoc(D->DNLoc, D->getDeclName());
+ D->FirstUsingShadow.setPointer(ReadDeclAs<UsingShadowDecl>());
+ D->setTypename(Record.readInt());
+ if (NamedDecl *Pattern = ReadDeclAs<NamedDecl>())
Reader.getContext().setInstantiatedFromUsingDecl(D, Pattern);
mergeMergeable(D);
}
+void ASTDeclReader::VisitUsingPackDecl(UsingPackDecl *D) {
+ VisitNamedDecl(D);
+ D->InstantiatedFrom = ReadDeclAs<NamedDecl>();
+ NamedDecl **Expansions = D->getTrailingObjects<NamedDecl*>();
+ for (unsigned I = 0; I != D->NumExpansions; ++I)
+ Expansions[I] = ReadDeclAs<NamedDecl>();
+ mergeMergeable(D);
+}
+
void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
RedeclarableResult Redecl = VisitRedeclarable(D);
VisitNamedDecl(D);
- D->setTargetDecl(ReadDeclAs<NamedDecl>(Record, Idx));
- D->UsingOrNextShadow = ReadDeclAs<NamedDecl>(Record, Idx);
- UsingShadowDecl *Pattern = ReadDeclAs<UsingShadowDecl>(Record, Idx);
+ D->setTargetDecl(ReadDeclAs<NamedDecl>());
+ D->UsingOrNextShadow = ReadDeclAs<NamedDecl>();
+ UsingShadowDecl *Pattern = ReadDeclAs<UsingShadowDecl>();
if (Pattern)
Reader.getContext().setInstantiatedFromUsingShadowDecl(D, Pattern);
mergeRedeclarable(D, Redecl);
@@ -1425,115 +1439,114 @@ void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
void ASTDeclReader::VisitConstructorUsingShadowDecl(
ConstructorUsingShadowDecl *D) {
VisitUsingShadowDecl(D);
- D->NominatedBaseClassShadowDecl =
- ReadDeclAs<ConstructorUsingShadowDecl>(Record, Idx);
- D->ConstructedBaseClassShadowDecl =
- ReadDeclAs<ConstructorUsingShadowDecl>(Record, Idx);
- D->IsVirtual = Record[Idx++];
+ D->NominatedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
+ D->ConstructedBaseClassShadowDecl = ReadDeclAs<ConstructorUsingShadowDecl>();
+ D->IsVirtual = Record.readInt();
}
void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
VisitNamedDecl(D);
- D->UsingLoc = ReadSourceLocation(Record, Idx);
- D->NamespaceLoc = ReadSourceLocation(Record, Idx);
- D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- D->NominatedNamespace = ReadDeclAs<NamedDecl>(Record, Idx);
- D->CommonAncestor = ReadDeclAs<DeclContext>(Record, Idx);
+ D->UsingLoc = ReadSourceLocation();
+ D->NamespaceLoc = ReadSourceLocation();
+ D->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ D->NominatedNamespace = ReadDeclAs<NamedDecl>();
+ D->CommonAncestor = ReadDeclAs<DeclContext>();
}
void ASTDeclReader::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
VisitValueDecl(D);
- D->setUsingLoc(ReadSourceLocation(Record, Idx));
- D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- ReadDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record, Idx);
+ D->setUsingLoc(ReadSourceLocation());
+ D->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ ReadDeclarationNameLoc(D->DNLoc, D->getDeclName());
+ D->EllipsisLoc = ReadSourceLocation();
mergeMergeable(D);
}
void ASTDeclReader::VisitUnresolvedUsingTypenameDecl(
UnresolvedUsingTypenameDecl *D) {
VisitTypeDecl(D);
- D->TypenameLocation = ReadSourceLocation(Record, Idx);
- D->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
+ D->TypenameLocation = ReadSourceLocation();
+ D->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ D->EllipsisLoc = ReadSourceLocation();
mergeMergeable(D);
}
void ASTDeclReader::ReadCXXDefinitionData(
- struct CXXRecordDecl::DefinitionData &Data,
- const RecordData &Record, unsigned &Idx) {
+ struct CXXRecordDecl::DefinitionData &Data) {
// Note: the caller has deserialized the IsLambda bit already.
- Data.UserDeclaredConstructor = Record[Idx++];
- Data.UserDeclaredSpecialMembers = Record[Idx++];
- Data.Aggregate = Record[Idx++];
- Data.PlainOldData = Record[Idx++];
- Data.Empty = Record[Idx++];
- Data.Polymorphic = Record[Idx++];
- Data.Abstract = Record[Idx++];
- Data.IsStandardLayout = Record[Idx++];
- Data.HasNoNonEmptyBases = Record[Idx++];
- Data.HasPrivateFields = Record[Idx++];
- Data.HasProtectedFields = Record[Idx++];
- Data.HasPublicFields = Record[Idx++];
- Data.HasMutableFields = Record[Idx++];
- Data.HasVariantMembers = Record[Idx++];
- Data.HasOnlyCMembers = Record[Idx++];
- Data.HasInClassInitializer = Record[Idx++];
- Data.HasUninitializedReferenceMember = Record[Idx++];
- Data.HasUninitializedFields = Record[Idx++];
- Data.HasInheritedConstructor = Record[Idx++];
- Data.HasInheritedAssignment = Record[Idx++];
- Data.NeedOverloadResolutionForMoveConstructor = Record[Idx++];
- Data.NeedOverloadResolutionForMoveAssignment = Record[Idx++];
- Data.NeedOverloadResolutionForDestructor = Record[Idx++];
- Data.DefaultedMoveConstructorIsDeleted = Record[Idx++];
- Data.DefaultedMoveAssignmentIsDeleted = Record[Idx++];
- Data.DefaultedDestructorIsDeleted = Record[Idx++];
- Data.HasTrivialSpecialMembers = Record[Idx++];
- Data.DeclaredNonTrivialSpecialMembers = Record[Idx++];
- Data.HasIrrelevantDestructor = Record[Idx++];
- Data.HasConstexprNonCopyMoveConstructor = Record[Idx++];
- Data.HasDefaultedDefaultConstructor = Record[Idx++];
- Data.DefaultedDefaultConstructorIsConstexpr = Record[Idx++];
- Data.HasConstexprDefaultConstructor = Record[Idx++];
- Data.HasNonLiteralTypeFieldsOrBases = Record[Idx++];
- Data.ComputedVisibleConversions = Record[Idx++];
- Data.UserProvidedDefaultConstructor = Record[Idx++];
- Data.DeclaredSpecialMembers = Record[Idx++];
- Data.ImplicitCopyConstructorHasConstParam = Record[Idx++];
- Data.ImplicitCopyAssignmentHasConstParam = Record[Idx++];
- Data.HasDeclaredCopyConstructorWithConstParam = Record[Idx++];
- Data.HasDeclaredCopyAssignmentWithConstParam = Record[Idx++];
-
- Data.NumBases = Record[Idx++];
+ Data.UserDeclaredConstructor = Record.readInt();
+ Data.UserDeclaredSpecialMembers = Record.readInt();
+ Data.Aggregate = Record.readInt();
+ Data.PlainOldData = Record.readInt();
+ Data.Empty = Record.readInt();
+ Data.Polymorphic = Record.readInt();
+ Data.Abstract = Record.readInt();
+ Data.IsStandardLayout = Record.readInt();
+ Data.HasNoNonEmptyBases = Record.readInt();
+ Data.HasPrivateFields = Record.readInt();
+ Data.HasProtectedFields = Record.readInt();
+ Data.HasPublicFields = Record.readInt();
+ Data.HasMutableFields = Record.readInt();
+ Data.HasVariantMembers = Record.readInt();
+ Data.HasOnlyCMembers = Record.readInt();
+ Data.HasInClassInitializer = Record.readInt();
+ Data.HasUninitializedReferenceMember = Record.readInt();
+ Data.HasUninitializedFields = Record.readInt();
+ Data.HasInheritedConstructor = Record.readInt();
+ Data.HasInheritedAssignment = Record.readInt();
+ Data.NeedOverloadResolutionForMoveConstructor = Record.readInt();
+ Data.NeedOverloadResolutionForMoveAssignment = Record.readInt();
+ Data.NeedOverloadResolutionForDestructor = Record.readInt();
+ Data.DefaultedMoveConstructorIsDeleted = Record.readInt();
+ Data.DefaultedMoveAssignmentIsDeleted = Record.readInt();
+ Data.DefaultedDestructorIsDeleted = Record.readInt();
+ Data.HasTrivialSpecialMembers = Record.readInt();
+ Data.DeclaredNonTrivialSpecialMembers = Record.readInt();
+ Data.HasIrrelevantDestructor = Record.readInt();
+ Data.HasConstexprNonCopyMoveConstructor = Record.readInt();
+ Data.HasDefaultedDefaultConstructor = Record.readInt();
+ Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt();
+ Data.HasConstexprDefaultConstructor = Record.readInt();
+ Data.HasNonLiteralTypeFieldsOrBases = Record.readInt();
+ Data.ComputedVisibleConversions = Record.readInt();
+ Data.UserProvidedDefaultConstructor = Record.readInt();
+ Data.DeclaredSpecialMembers = Record.readInt();
+ Data.ImplicitCopyConstructorHasConstParam = Record.readInt();
+ Data.ImplicitCopyAssignmentHasConstParam = Record.readInt();
+ Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
+ Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
+
+ Data.NumBases = Record.readInt();
if (Data.NumBases)
- Data.Bases = ReadGlobalOffset(F, Record, Idx);
- Data.NumVBases = Record[Idx++];
+ Data.Bases = ReadGlobalOffset();
+ Data.NumVBases = Record.readInt();
if (Data.NumVBases)
- Data.VBases = ReadGlobalOffset(F, Record, Idx);
-
- Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx);
- Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx);
+ Data.VBases = ReadGlobalOffset();
+
+ Record.readUnresolvedSet(Data.Conversions);
+ Record.readUnresolvedSet(Data.VisibleConversions);
assert(Data.Definition && "Data.Definition should be already set!");
- Data.FirstFriend = ReadDeclID(Record, Idx);
+ Data.FirstFriend = ReadDeclID();
if (Data.IsLambda) {
typedef LambdaCapture Capture;
CXXRecordDecl::LambdaDefinitionData &Lambda
= static_cast<CXXRecordDecl::LambdaDefinitionData &>(Data);
- Lambda.Dependent = Record[Idx++];
- Lambda.IsGenericLambda = Record[Idx++];
- Lambda.CaptureDefault = Record[Idx++];
- Lambda.NumCaptures = Record[Idx++];
- Lambda.NumExplicitCaptures = Record[Idx++];
- Lambda.ManglingNumber = Record[Idx++];
- Lambda.ContextDecl = ReadDecl(Record, Idx);
+ Lambda.Dependent = Record.readInt();
+ Lambda.IsGenericLambda = Record.readInt();
+ Lambda.CaptureDefault = Record.readInt();
+ Lambda.NumCaptures = Record.readInt();
+ Lambda.NumExplicitCaptures = Record.readInt();
+ Lambda.ManglingNumber = Record.readInt();
+ Lambda.ContextDecl = ReadDeclID();
Lambda.Captures
= (Capture*)Reader.Context.Allocate(sizeof(Capture)*Lambda.NumCaptures);
Capture *ToCapture = Lambda.Captures;
- Lambda.MethodTyInfo = GetTypeSourceInfo(Record, Idx);
+ Lambda.MethodTyInfo = GetTypeSourceInfo();
for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
- SourceLocation Loc = ReadSourceLocation(Record, Idx);
- bool IsImplicit = Record[Idx++];
- LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record[Idx++]);
+ SourceLocation Loc = ReadSourceLocation();
+ bool IsImplicit = Record.readInt();
+ LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record.readInt());
switch (Kind) {
case LCK_StarThis:
case LCK_This:
@@ -1542,8 +1555,8 @@ void ASTDeclReader::ReadCXXDefinitionData(
break;
case LCK_ByCopy:
case LCK_ByRef:
- VarDecl *Var = ReadDeclAs<VarDecl>(Record, Idx);
- SourceLocation EllipsisLoc = ReadSourceLocation(Record, Idx);
+ VarDecl *Var = ReadDeclAs<VarDecl>();
+ SourceLocation EllipsisLoc = ReadSourceLocation();
*ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
break;
}
@@ -1563,7 +1576,7 @@ void ASTDeclReader::MergeDefinitionData(
DD.Definition));
Reader.PendingDefinitions.erase(MergeDD.Definition);
MergeDD.Definition->IsCompleteDefinition = false;
- mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
+ Reader.mergeDefinitionVisibility(DD.Definition, MergeDD.Definition);
assert(Reader.Lookups.find(MergeDD.Definition) == Reader.Lookups.end() &&
"already loaded pending lookups for merged definition");
}
@@ -1665,14 +1678,14 @@ void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update) {
// Determine whether this is a lambda closure type, so that we can
// allocate the appropriate DefinitionData structure.
- bool IsLambda = Record[Idx++];
+ bool IsLambda = Record.readInt();
if (IsLambda)
DD = new (C) CXXRecordDecl::LambdaDefinitionData(D, nullptr, false, false,
LCD_None);
else
DD = new (C) struct CXXRecordDecl::DefinitionData(D);
- ReadCXXDefinitionData(*DD, Record, Idx);
+ ReadCXXDefinitionData(*DD);
// We might already have a definition for this record. This can happen either
// because we're reading an update record, or because we've already done some
@@ -1706,7 +1719,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
enum CXXRecKind {
CXXRecNotTemplate = 0, CXXRecTemplate, CXXRecMemberSpecialization
};
- switch ((CXXRecKind)Record[Idx++]) {
+ switch ((CXXRecKind)Record.readInt()) {
case CXXRecNotTemplate:
// Merged when we merge the folding set entry in the primary template.
if (!isa<ClassTemplateSpecializationDecl>(D))
@@ -1714,7 +1727,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
break;
case CXXRecTemplate: {
// Merged when we merge the template.
- ClassTemplateDecl *Template = ReadDeclAs<ClassTemplateDecl>(Record, Idx);
+ ClassTemplateDecl *Template = ReadDeclAs<ClassTemplateDecl>();
D->TemplateOrInstantiation = Template;
if (!Template->getTemplatedDecl()) {
// We've not actually loaded the ClassTemplateDecl yet, because we're
@@ -1728,9 +1741,10 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
break;
}
case CXXRecMemberSpecialization: {
- CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>(Record, Idx);
- TemplateSpecializationKind TSK = (TemplateSpecializationKind)Record[Idx++];
- SourceLocation POI = ReadSourceLocation(Record, Idx);
+ CXXRecordDecl *RD = ReadDeclAs<CXXRecordDecl>();
+ TemplateSpecializationKind TSK =
+ (TemplateSpecializationKind)Record.readInt();
+ SourceLocation POI = ReadSourceLocation();
MemberSpecializationInfo *MSI = new (C) MemberSpecializationInfo(RD, TSK);
MSI->setPointOfInstantiation(POI);
D->TemplateOrInstantiation = MSI;
@@ -1739,7 +1753,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
}
}
- bool WasDefinition = Record[Idx++];
+ bool WasDefinition = Record.readInt();
if (WasDefinition)
ReadCXXRecordDefinition(D, /*Update*/false);
else
@@ -1749,7 +1763,7 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
// Lazily load the key function to avoid deserializing every method so we can
// compute it.
if (WasDefinition) {
- DeclID KeyFn = ReadDeclID(Record, Idx);
+ DeclID KeyFn = ReadDeclID();
if (KeyFn && D->IsCompleteDefinition)
// FIXME: This is wrong for the ARM ABI, where some other module may have
// made this function no longer be a key function. We need an update
@@ -1763,18 +1777,18 @@ ASTDeclReader::VisitCXXRecordDeclImpl(CXXRecordDecl *D) {
void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
VisitFunctionDecl(D);
- unsigned NumOverridenMethods = Record[Idx++];
+ unsigned NumOverridenMethods = Record.readInt();
if (D->isCanonicalDecl()) {
while (NumOverridenMethods--) {
// Avoid invariant checking of CXXMethodDecl::addOverriddenMethod,
// MD may be initializing.
- if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>(Record, Idx))
+ if (CXXMethodDecl *MD = ReadDeclAs<CXXMethodDecl>())
Reader.getContext().addOverriddenMethod(D, MD->getCanonicalDecl());
}
} else {
// We don't care about which declarations this used to override; we get
// the relevant information from the canonical declaration.
- Idx += NumOverridenMethods;
+ Record.skipInts(NumOverridenMethods);
}
}
@@ -1782,21 +1796,21 @@ void ASTDeclReader::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
// We need the inherited constructor information to merge the declaration,
// so we have to read it before we call VisitCXXMethodDecl.
if (D->isInheritingConstructor()) {
- auto *Shadow = ReadDeclAs<ConstructorUsingShadowDecl>(Record, Idx);
- auto *Ctor = ReadDeclAs<CXXConstructorDecl>(Record, Idx);
+ auto *Shadow = ReadDeclAs<ConstructorUsingShadowDecl>();
+ auto *Ctor = ReadDeclAs<CXXConstructorDecl>();
*D->getTrailingObjects<InheritedConstructor>() =
InheritedConstructor(Shadow, Ctor);
}
VisitCXXMethodDecl(D);
- D->IsExplicitSpecified = Record[Idx++];
+ D->IsExplicitSpecified = Record.readInt();
}
void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
VisitCXXMethodDecl(D);
- if (auto *OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx)) {
+ if (auto *OperatorDelete = ReadDeclAs<FunctionDecl>()) {
auto *Canon = cast<CXXDestructorDecl>(D->getCanonicalDecl());
// FIXME: Check consistency if we have an old and new operator delete.
if (!Canon->OperatorDelete)
@@ -1806,65 +1820,64 @@ void ASTDeclReader::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
void ASTDeclReader::VisitCXXConversionDecl(CXXConversionDecl *D) {
VisitCXXMethodDecl(D);
- D->IsExplicitSpecified = Record[Idx++];
+ D->IsExplicitSpecified = Record.readInt();
}
void ASTDeclReader::VisitImportDecl(ImportDecl *D) {
VisitDecl(D);
- D->ImportedAndComplete.setPointer(readModule(Record, Idx));
- D->ImportedAndComplete.setInt(Record[Idx++]);
+ D->ImportedAndComplete.setPointer(readModule());
+ D->ImportedAndComplete.setInt(Record.readInt());
SourceLocation *StoredLocs = D->getTrailingObjects<SourceLocation>();
for (unsigned I = 0, N = Record.back(); I != N; ++I)
- StoredLocs[I] = ReadSourceLocation(Record, Idx);
- ++Idx; // The number of stored source locations.
+ StoredLocs[I] = ReadSourceLocation();
+ (void)Record.readInt(); // The number of stored source locations.
}
void ASTDeclReader::VisitAccessSpecDecl(AccessSpecDecl *D) {
VisitDecl(D);
- D->setColonLoc(ReadSourceLocation(Record, Idx));
+ D->setColonLoc(ReadSourceLocation());
}
void ASTDeclReader::VisitFriendDecl(FriendDecl *D) {
VisitDecl(D);
- if (Record[Idx++]) // hasFriendDecl
- D->Friend = ReadDeclAs<NamedDecl>(Record, Idx);
+ if (Record.readInt()) // hasFriendDecl
+ D->Friend = ReadDeclAs<NamedDecl>();
else
- D->Friend = GetTypeSourceInfo(Record, Idx);
+ D->Friend = GetTypeSourceInfo();
for (unsigned i = 0; i != D->NumTPLists; ++i)
D->getTrailingObjects<TemplateParameterList *>()[i] =
- Reader.ReadTemplateParameterList(F, Record, Idx);
- D->NextFriend = ReadDeclID(Record, Idx);
- D->UnsupportedFriend = (Record[Idx++] != 0);
- D->FriendLoc = ReadSourceLocation(Record, Idx);
+ Record.readTemplateParameterList();
+ D->NextFriend = ReadDeclID();
+ D->UnsupportedFriend = (Record.readInt() != 0);
+ D->FriendLoc = ReadSourceLocation();
}
void ASTDeclReader::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
VisitDecl(D);
- unsigned NumParams = Record[Idx++];
+ unsigned NumParams = Record.readInt();
D->NumParams = NumParams;
D->Params = new TemplateParameterList*[NumParams];
for (unsigned i = 0; i != NumParams; ++i)
- D->Params[i] = Reader.ReadTemplateParameterList(F, Record, Idx);
- if (Record[Idx++]) // HasFriendDecl
- D->Friend = ReadDeclAs<NamedDecl>(Record, Idx);
+ D->Params[i] = Record.readTemplateParameterList();
+ if (Record.readInt()) // HasFriendDecl
+ D->Friend = ReadDeclAs<NamedDecl>();
else
- D->Friend = GetTypeSourceInfo(Record, Idx);
- D->FriendLoc = ReadSourceLocation(Record, Idx);
+ D->Friend = GetTypeSourceInfo();
+ D->FriendLoc = ReadSourceLocation();
}
DeclID ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) {
VisitNamedDecl(D);
- DeclID PatternID = ReadDeclID(Record, Idx);
+ DeclID PatternID = ReadDeclID();
NamedDecl *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
- TemplateParameterList* TemplateParams
- = Reader.ReadTemplateParameterList(F, Record, Idx);
+ TemplateParameterList *TemplateParams = Record.readTemplateParameterList();
D->init(TemplatedDecl, TemplateParams);
return PatternID;
}
-ASTDeclReader::RedeclarableResult
+ASTDeclReader::RedeclarableResult
ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
RedeclarableResult Redecl = VisitRedeclarable(D);
@@ -1881,17 +1894,17 @@ ASTDeclReader::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
// for the 'common' pointer.
if (ThisDeclID == Redecl.getFirstID()) {
if (RedeclarableTemplateDecl *RTD
- = ReadDeclAs<RedeclarableTemplateDecl>(Record, Idx)) {
+ = ReadDeclAs<RedeclarableTemplateDecl>()) {
assert(RTD->getKind() == D->getKind() &&
"InstantiatedFromMemberTemplate kind mismatch");
D->setInstantiatedFromMemberTemplate(RTD);
- if (Record[Idx++])
+ if (Record.readInt())
D->setMemberSpecialization();
}
}
DeclID PatternID = VisitTemplateDecl(D);
- D->IdentifierNamespace = Record[Idx++];
+ D->IdentifierNamespace = Record.readInt();
mergeRedeclarable(D, Redecl, PatternID);
@@ -1971,14 +1984,14 @@ ASTDeclReader::RedeclarableResult
ASTDeclReader::VisitClassTemplateSpecializationDeclImpl(
ClassTemplateSpecializationDecl *D) {
RedeclarableResult Redecl = VisitCXXRecordDeclImpl(D);
-
+
ASTContext &C = Reader.getContext();
- if (Decl *InstD = ReadDecl(Record, Idx)) {
+ if (Decl *InstD = ReadDecl()) {
if (ClassTemplateDecl *CTD = dyn_cast<ClassTemplateDecl>(InstD)) {
D->SpecializedTemplate = CTD;
} else {
SmallVector<TemplateArgument, 8> TemplArgs;
- Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
+ Record.readTemplateArgumentList(TemplArgs);
TemplateArgumentList *ArgList
= TemplateArgumentList::CreateCopy(C, TemplArgs);
ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
@@ -1992,15 +2005,14 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl(
}
SmallVector<TemplateArgument, 8> TemplArgs;
- Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
- /*Canonicalize*/ true);
+ Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
- D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
- D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
+ D->PointOfInstantiation = ReadSourceLocation();
+ D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
- bool writtenAsCanonicalDecl = Record[Idx++];
+ bool writtenAsCanonicalDecl = Record.readInt();
if (writtenAsCanonicalDecl) {
- ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>(Record,Idx);
+ ClassTemplateDecl *CanonPattern = ReadDeclAs<ClassTemplateDecl>();
if (D->isCanonicalDecl()) { // It's kept in the folding set.
// Set this as, or find, the canonical declaration for this specialization
ClassTemplateSpecializationDecl *CanonSpec;
@@ -2030,12 +2042,12 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl(
}
// Explicit info.
- if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) {
+ if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) {
ClassTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo
= new (C) ClassTemplateSpecializationDecl::ExplicitSpecializationInfo;
ExplicitInfo->TypeAsWritten = TyInfo;
- ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx);
- ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx);
+ ExplicitInfo->ExternLoc = ReadSourceLocation();
+ ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
D->ExplicitInfo = ExplicitInfo;
}
@@ -2046,21 +2058,21 @@ void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *D) {
RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
- D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx);
- D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx);
+ D->TemplateParams = Record.readTemplateParameterList();
+ D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
// These are read/set from/to the first declaration.
if (ThisDeclID == Redecl.getFirstID()) {
D->InstantiatedFromMember.setPointer(
- ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx));
- D->InstantiatedFromMember.setInt(Record[Idx++]);
+ ReadDeclAs<ClassTemplatePartialSpecializationDecl>());
+ D->InstantiatedFromMember.setInt(Record.readInt());
}
}
void ASTDeclReader::VisitClassScopeFunctionSpecializationDecl(
ClassScopeFunctionSpecializationDecl *D) {
VisitDecl(D);
- D->Specialization = ReadDeclAs<CXXMethodDecl>(Record, Idx);
+ D->Specialization = ReadDeclAs<CXXMethodDecl>();
}
void ASTDeclReader::VisitFunctionTemplateDecl(FunctionTemplateDecl *D) {
@@ -2090,12 +2102,12 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl(
RedeclarableResult Redecl = VisitVarDeclImpl(D);
ASTContext &C = Reader.getContext();
- if (Decl *InstD = ReadDecl(Record, Idx)) {
+ if (Decl *InstD = ReadDecl()) {
if (VarTemplateDecl *VTD = dyn_cast<VarTemplateDecl>(InstD)) {
D->SpecializedTemplate = VTD;
} else {
SmallVector<TemplateArgument, 8> TemplArgs;
- Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
+ Record.readTemplateArgumentList(TemplArgs);
TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy(
C, TemplArgs);
VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS =
@@ -2109,25 +2121,24 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl(
}
// Explicit info.
- if (TypeSourceInfo *TyInfo = GetTypeSourceInfo(Record, Idx)) {
+ if (TypeSourceInfo *TyInfo = GetTypeSourceInfo()) {
VarTemplateSpecializationDecl::ExplicitSpecializationInfo *ExplicitInfo =
new (C) VarTemplateSpecializationDecl::ExplicitSpecializationInfo;
ExplicitInfo->TypeAsWritten = TyInfo;
- ExplicitInfo->ExternLoc = ReadSourceLocation(Record, Idx);
- ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation(Record, Idx);
+ ExplicitInfo->ExternLoc = ReadSourceLocation();
+ ExplicitInfo->TemplateKeywordLoc = ReadSourceLocation();
D->ExplicitInfo = ExplicitInfo;
}
SmallVector<TemplateArgument, 8> TemplArgs;
- Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
- /*Canonicalize*/ true);
+ Record.readTemplateArgumentList(TemplArgs, /*Canonicalize*/ true);
D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
- D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
- D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
+ D->PointOfInstantiation = ReadSourceLocation();
+ D->SpecializationKind = (TemplateSpecializationKind)Record.readInt();
- bool writtenAsCanonicalDecl = Record[Idx++];
+ bool writtenAsCanonicalDecl = Record.readInt();
if (writtenAsCanonicalDecl) {
- VarTemplateDecl *CanonPattern = ReadDeclAs<VarTemplateDecl>(Record, Idx);
+ VarTemplateDecl *CanonPattern = ReadDeclAs<VarTemplateDecl>();
if (D->isCanonicalDecl()) { // It's kept in the folding set.
// FIXME: If it's already present, merge it.
if (VarTemplatePartialSpecializationDecl *Partial =
@@ -2152,63 +2163,63 @@ void ASTDeclReader::VisitVarTemplatePartialSpecializationDecl(
VarTemplatePartialSpecializationDecl *D) {
RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
- D->TemplateParams = Reader.ReadTemplateParameterList(F, Record, Idx);
- D->ArgsAsWritten = Reader.ReadASTTemplateArgumentListInfo(F, Record, Idx);
+ D->TemplateParams = Record.readTemplateParameterList();
+ D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
// These are read/set from/to the first declaration.
if (ThisDeclID == Redecl.getFirstID()) {
D->InstantiatedFromMember.setPointer(
- ReadDeclAs<VarTemplatePartialSpecializationDecl>(Record, Idx));
- D->InstantiatedFromMember.setInt(Record[Idx++]);
+ ReadDeclAs<VarTemplatePartialSpecializationDecl>());
+ D->InstantiatedFromMember.setInt(Record.readInt());
}
}
void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
VisitTypeDecl(D);
- D->setDeclaredWithTypename(Record[Idx++]);
+ D->setDeclaredWithTypename(Record.readInt());
- if (Record[Idx++])
- D->setDefaultArgument(GetTypeSourceInfo(Record, Idx));
+ if (Record.readInt())
+ D->setDefaultArgument(GetTypeSourceInfo());
}
void ASTDeclReader::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
VisitDeclaratorDecl(D);
// TemplateParmPosition.
- D->setDepth(Record[Idx++]);
- D->setPosition(Record[Idx++]);
+ D->setDepth(Record.readInt());
+ D->setPosition(Record.readInt());
if (D->isExpandedParameterPack()) {
auto TypesAndInfos =
D->getTrailingObjects<std::pair<QualType, TypeSourceInfo *>>();
for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
- new (&TypesAndInfos[I].first) QualType(Reader.readType(F, Record, Idx));
- TypesAndInfos[I].second = GetTypeSourceInfo(Record, Idx);
+ new (&TypesAndInfos[I].first) QualType(Record.readType());
+ TypesAndInfos[I].second = GetTypeSourceInfo();
}
} else {
// Rest of NonTypeTemplateParmDecl.
- D->ParameterPack = Record[Idx++];
- if (Record[Idx++])
- D->setDefaultArgument(Reader.ReadExpr(F));
+ D->ParameterPack = Record.readInt();
+ if (Record.readInt())
+ D->setDefaultArgument(Record.readExpr());
}
}
void ASTDeclReader::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
VisitTemplateDecl(D);
// TemplateParmPosition.
- D->setDepth(Record[Idx++]);
- D->setPosition(Record[Idx++]);
+ D->setDepth(Record.readInt());
+ D->setPosition(Record.readInt());
if (D->isExpandedParameterPack()) {
TemplateParameterList **Data =
D->getTrailingObjects<TemplateParameterList *>();
for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
I != N; ++I)
- Data[I] = Reader.ReadTemplateParameterList(F, Record, Idx);
+ Data[I] = Record.readTemplateParameterList();
} else {
// Rest of TemplateTemplateParmDecl.
- D->ParameterPack = Record[Idx++];
- if (Record[Idx++])
+ D->ParameterPack = Record.readInt();
+ if (Record.readInt())
D->setDefaultArgument(Reader.getContext(),
- Reader.ReadTemplateArgumentLoc(F, Record, Idx));
+ Record.readTemplateArgumentLoc());
}
}
@@ -2218,10 +2229,10 @@ void ASTDeclReader::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
void ASTDeclReader::VisitStaticAssertDecl(StaticAssertDecl *D) {
VisitDecl(D);
- D->AssertExprAndFailed.setPointer(Reader.ReadExpr(F));
- D->AssertExprAndFailed.setInt(Record[Idx++]);
- D->Message = cast_or_null<StringLiteral>(Reader.ReadExpr(F));
- D->RParenLoc = ReadSourceLocation(Record, Idx);
+ D->AssertExprAndFailed.setPointer(Record.readExpr());
+ D->AssertExprAndFailed.setInt(Record.readInt());
+ D->Message = cast_or_null<StringLiteral>(Record.readExpr());
+ D->RParenLoc = ReadSourceLocation();
}
void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) {
@@ -2230,15 +2241,15 @@ void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) {
std::pair<uint64_t, uint64_t>
ASTDeclReader::VisitDeclContext(DeclContext *DC) {
- uint64_t LexicalOffset = ReadLocalOffset(Record, Idx);
- uint64_t VisibleOffset = ReadLocalOffset(Record, Idx);
+ uint64_t LexicalOffset = ReadLocalOffset();
+ uint64_t VisibleOffset = ReadLocalOffset();
return std::make_pair(LexicalOffset, VisibleOffset);
}
template <typename T>
ASTDeclReader::RedeclarableResult
ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
- DeclID FirstDeclID = ReadDeclID(Record, Idx);
+ DeclID FirstDeclID = ReadDeclID();
Decl *MergeWith = nullptr;
bool IsKeyDecl = ThisDeclID == FirstDeclID;
@@ -2252,7 +2263,7 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
FirstDeclID = ThisDeclID;
IsKeyDecl = true;
IsFirstLocalDecl = true;
- } else if (unsigned N = Record[Idx++]) {
+ } else if (unsigned N = Record.readInt()) {
// This declaration was the first local declaration, but may have imported
// other declarations.
IsKeyDecl = N == 1;
@@ -2264,13 +2275,13 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
// FIXME: Provide a known merge target to the second and subsequent such
// declaration.
for (unsigned I = 0; I != N - 1; ++I)
- MergeWith = ReadDecl(Record, Idx/*, MergeWith*/);
+ MergeWith = ReadDecl();
- RedeclOffset = ReadLocalOffset(Record, Idx);
+ RedeclOffset = ReadLocalOffset();
} else {
// This declaration was not the first local declaration. Read the first
// local declaration now, to trigger the import of other redeclarations.
- (void)ReadDecl(Record, Idx);
+ (void)ReadDecl();
}
T *FirstDecl = cast_or_null<T>(Reader.GetDecl(FirstDeclID));
@@ -2281,7 +2292,7 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
// loaded & attached later on.
D->RedeclLink = Redeclarable<T>::PreviousDeclLink(FirstDecl);
D->First = FirstDecl->getCanonicalDecl();
- }
+ }
T *DAsT = static_cast<T*>(D);
@@ -2292,7 +2303,7 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
if (IsFirstLocalDecl)
Reader.PendingDeclChains.push_back(std::make_pair(DAsT, RedeclOffset));
- return RedeclarableResult(FirstDeclID, MergeWith, IsKeyDecl);
+ return RedeclarableResult(MergeWith, FirstDeclID, IsKeyDecl);
}
/// \brief Attempts to merge the given declaration (D) with another declaration
@@ -2301,8 +2312,6 @@ template<typename T>
void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase,
RedeclarableResult &Redecl,
DeclID TemplatePatternID) {
- T *D = static_cast<T*>(DBase);
-
// If modules are not available, there is no reason to perform this merge.
if (!Reader.getContext().getLangOpts().Modules)
return;
@@ -2311,6 +2320,8 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase,
if (!DBase->isFirstDecl())
return;
+ T *D = static_cast<T*>(DBase);
+
if (auto *Existing = Redecl.getKnownMergeTarget())
// We already know of an existing declaration we should merge with.
mergeRedeclarable(D, cast<T>(Existing), Redecl, TemplatePatternID);
@@ -2334,8 +2345,9 @@ void ASTDeclReader::mergeTemplatePattern(RedeclarableTemplateDecl *D,
DeclID DsID, bool IsKeyDecl) {
auto *DPattern = D->getTemplatedDecl();
auto *ExistingPattern = Existing->getTemplatedDecl();
- RedeclarableResult Result(DPattern->getCanonicalDecl()->getGlobalID(),
- /*MergeWith*/ ExistingPattern, IsKeyDecl);
+ RedeclarableResult Result(/*MergeWith*/ ExistingPattern,
+ DPattern->getCanonicalDecl()->getGlobalID(),
+ IsKeyDecl);
if (auto *DClass = dyn_cast<CXXRecordDecl>(DPattern)) {
// Merge with any existing definition.
@@ -2436,17 +2448,17 @@ void ASTDeclReader::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) {
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i) {
- Vars.push_back(Reader.ReadExpr(F));
+ Vars.push_back(Record.readExpr());
}
D->setVars(Vars);
}
void ASTDeclReader::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
VisitValueDecl(D);
- D->setLocation(Reader.ReadSourceLocation(F, Record, Idx));
- D->setCombiner(Reader.ReadExpr(F));
- D->setInitializer(Reader.ReadExpr(F));
- D->PrevDeclInScope = Reader.ReadDeclID(F, Record, Idx);
+ D->setLocation(ReadSourceLocation());
+ D->setCombiner(Record.readExpr());
+ D->setInitializer(Record.readExpr());
+ D->PrevDeclInScope = ReadDeclID();
}
void ASTDeclReader::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) {
@@ -2494,10 +2506,16 @@ inline void ASTReader::LoadedDecl(unsigned Index, Decl *D) {
/// This routine should return true for anything that might affect
/// code generation, e.g., inline function definitions, Objective-C
/// declarations with metadata, etc.
-static bool isConsumerInterestedIn(Decl *D, bool HasBody) {
+static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) {
// An ObjCMethodDecl is never considered as "interesting" because its
// implementation container always is.
+ // An ImportDecl or VarDecl imported from a module will get emitted when
+ // we import the relevant module.
+ if ((isa<ImportDecl>(D) || isa<VarDecl>(D)) && Ctx.DeclMustBeEmitted(D) &&
+ D->getImportedOwningModule())
+ return false;
+
if (isa<FileScopeAsmDecl>(D) ||
isa<ObjCProtocolDecl>(D) ||
isa<ObjCImplDecl>(D) ||
@@ -2867,7 +2885,7 @@ static NamedDecl *getDeclForMerging(NamedDecl *Found,
return nullptr;
if (auto *TND = dyn_cast<TypedefNameDecl>(Found))
- return TND->getAnonDeclWithTypedefName();
+ return TND->getAnonDeclWithTypedefName(/*AnyRedecl*/true);
return nullptr;
}
@@ -3043,6 +3061,29 @@ void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
namespace clang {
template<>
void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
+ Redeclarable<VarDecl> *D,
+ Decl *Previous, Decl *Canon) {
+ VarDecl *VD = static_cast<VarDecl*>(D);
+ VarDecl *PrevVD = cast<VarDecl>(Previous);
+ D->RedeclLink.setPrevious(PrevVD);
+ D->First = PrevVD->First;
+
+ // We should keep at most one definition on the chain.
+ // FIXME: Cache the definition once we've found it. Building a chain with
+ // N definitions currently takes O(N^2) time here.
+ if (VD->isThisDeclarationADefinition() == VarDecl::Definition) {
+ for (VarDecl *CurD = PrevVD; CurD; CurD = CurD->getPreviousDecl()) {
+ if (CurD->isThisDeclarationADefinition() == VarDecl::Definition) {
+ Reader.mergeDefinitionVisibility(CurD, VD);
+ VD->demoteThisDefinitionToDeclaration();
+ break;
+ }
+ }
+ }
+}
+
+template<>
+void ASTDeclReader::attachPreviousDeclImpl(ASTReader &Reader,
Redeclarable<FunctionDecl> *D,
Decl *Previous, Decl *Canon) {
FunctionDecl *FD = static_cast<FunctionDecl*>(D);
@@ -3215,13 +3256,12 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
Deserializing ADecl(this);
DeclsCursor.JumpToBit(Loc.Offset);
- RecordData Record;
+ ASTRecordReader Record(*this, *Loc.F);
+ ASTDeclReader Reader(*this, Record, Loc, ID, DeclLoc);
unsigned Code = DeclsCursor.ReadCode();
- unsigned Idx = 0;
- ASTDeclReader Reader(*this, Loc, ID, DeclLoc, Record,Idx);
Decl *D = nullptr;
- switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) {
+ switch ((DeclCode)Record.readRecord(DeclsCursor, Code)) {
case DECL_CONTEXT_LEXICAL:
case DECL_CONTEXT_VISIBLE:
llvm_unreachable("Record cannot be de-serialized with ReadDeclRecord");
@@ -3246,6 +3286,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
case DECL_LINKAGE_SPEC:
D = LinkageSpecDecl::CreateDeserialized(Context, ID);
break;
+ case DECL_EXPORT:
+ D = ExportDecl::CreateDeserialized(Context, ID);
+ break;
case DECL_LABEL:
D = LabelDecl::CreateDeserialized(Context, ID);
break;
@@ -3258,6 +3301,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
case DECL_USING:
D = UsingDecl::CreateDeserialized(Context, ID);
break;
+ case DECL_USING_PACK:
+ D = UsingPackDecl::CreateDeserialized(Context, ID, Record.readInt());
+ break;
case DECL_USING_SHADOW:
D = UsingShadowDecl::CreateDeserialized(Context, ID);
break;
@@ -3295,7 +3341,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
D = AccessSpecDecl::CreateDeserialized(Context, ID);
break;
case DECL_FRIEND:
- D = FriendDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = FriendDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_FRIEND_TEMPLATE:
D = FriendTemplateDecl::CreateDeserialized(Context, ID);
@@ -3331,14 +3377,15 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID);
break;
case DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK:
- D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = NonTypeTemplateParmDecl::CreateDeserialized(Context, ID,
+ Record.readInt());
break;
case DECL_TEMPLATE_TEMPLATE_PARM:
D = TemplateTemplateParmDecl::CreateDeserialized(Context, ID);
break;
case DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK:
D = TemplateTemplateParmDecl::CreateDeserialized(Context, ID,
- Record[Idx++]);
+ Record.readInt());
break;
case DECL_TYPE_ALIAS_TEMPLATE:
D = TypeAliasTemplateDecl::CreateDeserialized(Context, ID);
@@ -3394,6 +3441,12 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
case DECL_PARM_VAR:
D = ParmVarDecl::CreateDeserialized(Context, ID);
break;
+ case DECL_DECOMPOSITION:
+ D = DecompositionDecl::CreateDeserialized(Context, ID, Record.readInt());
+ break;
+ case DECL_BINDING:
+ D = BindingDecl::CreateDeserialized(Context, ID);
+ break;
case DECL_FILE_SCOPE_ASM:
D = FileScopeAsmDecl::CreateDeserialized(Context, ID);
break;
@@ -3404,7 +3457,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
D = MSPropertyDecl::CreateDeserialized(Context, ID);
break;
case DECL_CAPTURED:
- D = CapturedDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = CapturedDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_CXX_BASE_SPECIFIERS:
Error("attempt to read a C++ base-specifier record as a declaration");
@@ -3418,7 +3471,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
D = ImportDecl::CreateDeserialized(Context, ID, Record.back());
break;
case DECL_OMP_THREADPRIVATE:
- D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_OMP_DECLARE_REDUCTION:
D = OMPDeclareReductionDecl::CreateDeserialized(Context, ID);
@@ -3427,11 +3480,11 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
D = OMPCapturedExprDecl::CreateDeserialized(Context, ID);
break;
case DECL_PRAGMA_COMMENT:
- D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record.readInt());
break;
case DECL_PRAGMA_DETECT_MISMATCH:
D = PragmaDetectMismatchDecl::CreateDeserialized(Context, ID,
- Record[Idx++]);
+ Record.readInt());
break;
case DECL_EMPTY:
D = EmptyDecl::CreateDeserialized(Context, ID);
@@ -3460,21 +3513,24 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
ReadVisibleDeclContextStorage(*Loc.F, DeclsCursor, Offsets.second, ID))
return nullptr;
}
- assert(Idx == Record.size());
+ assert(Record.getIdx() == Record.size());
// Load any relevant update records.
PendingUpdateRecords.push_back(std::make_pair(ID, D));
// Load the categories after recursive loading is finished.
if (ObjCInterfaceDecl *Class = dyn_cast<ObjCInterfaceDecl>(D))
- if (Class->isThisDeclarationADefinition())
+ // If we already have a definition when deserializing the ObjCInterfaceDecl,
+ // we put the Decl in PendingDefinitions so we can pull the categories here.
+ if (Class->isThisDeclarationADefinition() ||
+ PendingDefinitions.count(Class))
loadObjCCategories(ID, Class);
// If we have deserialized a declaration that has a definition the
// AST consumer might need to know about, queue it.
// We don't pass it to the consumer immediately because we may be in recursive
// loading, and some declarations may still be initializing.
- if (isConsumerInterestedIn(D, Reader.hasPendingBody()))
+ if (isConsumerInterestedIn(Context, D, Reader.hasPendingBody()))
InterestingDecls.push_back(D);
return D;
@@ -3490,28 +3546,27 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
auto UpdateOffsets = std::move(UpdI->second);
DeclUpdateOffsets.erase(UpdI);
- bool WasInteresting = isConsumerInterestedIn(D, false);
+ bool WasInteresting = isConsumerInterestedIn(Context, D, false);
for (auto &FileAndOffset : UpdateOffsets) {
ModuleFile *F = FileAndOffset.first;
uint64_t Offset = FileAndOffset.second;
llvm::BitstreamCursor &Cursor = F->DeclsCursor;
SavedStreamPosition SavedPosition(Cursor);
Cursor.JumpToBit(Offset);
- RecordData Record;
unsigned Code = Cursor.ReadCode();
- unsigned RecCode = Cursor.readRecord(Code, Record);
+ ASTRecordReader Record(*this, *F);
+ unsigned RecCode = Record.readRecord(Cursor, Code);
(void)RecCode;
assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!");
- unsigned Idx = 0;
- ASTDeclReader Reader(*this, RecordLocation(F, Offset), ID,
- SourceLocation(), Record, Idx);
- Reader.UpdateDecl(D, *F, Record);
+ ASTDeclReader Reader(*this, Record, RecordLocation(F, Offset), ID,
+ SourceLocation());
+ Reader.UpdateDecl(D);
// We might have made this declaration interesting. If so, remember that
// we need to hand it off to the consumer.
if (!WasInteresting &&
- isConsumerInterestedIn(D, Reader.hasPendingBody())) {
+ isConsumerInterestedIn(Context, D, Reader.hasPendingBody())) {
InterestingDecls.push_back(D);
WasInteresting = true;
}
@@ -3578,12 +3633,12 @@ namespace {
/// interface all the categories for it.
class ObjCCategoriesVisitor {
ASTReader &Reader;
- serialization::GlobalDeclID InterfaceID;
ObjCInterfaceDecl *Interface;
llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized;
- unsigned PreviousGeneration;
ObjCCategoryDecl *Tail;
llvm::DenseMap<DeclarationName, ObjCCategoryDecl *> NameCategoryMap;
+ serialization::GlobalDeclID InterfaceID;
+ unsigned PreviousGeneration;
void add(ObjCCategoryDecl *Cat) {
// Only process each category once.
@@ -3626,13 +3681,13 @@ namespace {
public:
ObjCCategoriesVisitor(ASTReader &Reader,
- serialization::GlobalDeclID InterfaceID,
ObjCInterfaceDecl *Interface,
- llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
+ llvm::SmallPtrSetImpl<ObjCCategoryDecl *> &Deserialized,
+ serialization::GlobalDeclID InterfaceID,
unsigned PreviousGeneration)
- : Reader(Reader), InterfaceID(InterfaceID), Interface(Interface),
- Deserialized(Deserialized), PreviousGeneration(PreviousGeneration),
- Tail(nullptr)
+ : Reader(Reader), Interface(Interface), Deserialized(Deserialized),
+ Tail(nullptr), InterfaceID(InterfaceID),
+ PreviousGeneration(PreviousGeneration)
{
// Populate the name -> category map with the set of known categories.
for (auto *Cat : Interface->known_categories()) {
@@ -3687,7 +3742,7 @@ namespace {
void ASTReader::loadObjCCategories(serialization::GlobalDeclID ID,
ObjCInterfaceDecl *D,
unsigned PreviousGeneration) {
- ObjCCategoriesVisitor Visitor(*this, ID, D, CategoriesDeserialized,
+ ObjCCategoriesVisitor Visitor(*this, D, CategoriesDeserialized, ID,
PreviousGeneration);
ModuleMgr.visit(Visitor);
}
@@ -3713,15 +3768,14 @@ static void forAllLaterRedecls(DeclT *D, Fn F) {
}
}
-void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
- const RecordData &Record) {
- while (Idx < Record.size()) {
- switch ((DeclUpdateKind)Record[Idx++]) {
+void ASTDeclReader::UpdateDecl(Decl *D) {
+ while (Record.getIdx() < Record.size()) {
+ switch ((DeclUpdateKind)Record.readInt()) {
case UPD_CXX_ADDED_IMPLICIT_MEMBER: {
auto *RD = cast<CXXRecordDecl>(D);
// FIXME: If we also have an update record for instantiating the
// definition of D, we need that to happen before we get here.
- Decl *MD = Reader.ReadDecl(ModuleFile, Record, Idx);
+ Decl *MD = Record.readDecl();
assert(MD && "couldn't read decl from update record");
// FIXME: We should call addHiddenDecl instead, to add the member
// to its DeclContext.
@@ -3731,18 +3785,16 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
// It will be added to the template's specializations set when loaded.
- (void)Reader.ReadDecl(ModuleFile, Record, Idx);
+ (void)Record.readDecl();
break;
case UPD_CXX_ADDED_ANONYMOUS_NAMESPACE: {
- NamespaceDecl *Anon
- = Reader.ReadDeclAs<NamespaceDecl>(ModuleFile, Record, Idx);
-
+ NamespaceDecl *Anon = ReadDeclAs<NamespaceDecl>();
+
// Each module has its own anonymous namespace, which is disjoint from
// any other module's anonymous namespaces, so don't attach the anonymous
// namespace at all.
- if (ModuleFile.Kind != MK_ImplicitModule &&
- ModuleFile.Kind != MK_ExplicitModule) {
+ if (!Record.isModule()) {
if (TranslationUnitDecl *TU = dyn_cast<TranslationUnitDecl>(D))
TU->setAnonymousNamespace(Anon);
else
@@ -3753,7 +3805,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER:
cast<VarDecl>(D)->getMemberSpecializationInfo()->setPointOfInstantiation(
- Reader.ReadSourceLocation(ModuleFile, Record, Idx));
+ ReadSourceLocation());
break;
case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT: {
@@ -3762,7 +3814,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
// We have to read the default argument regardless of whether we use it
// so that hypothetical further update records aren't messed up.
// TODO: Add a function to skip over the next expr record.
- auto DefaultArg = Reader.ReadExpr(F);
+ auto DefaultArg = Record.readExpr();
// Only apply the update if the parameter still has an uninstantiated
// default argument.
@@ -3771,6 +3823,23 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
break;
}
+ case UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER: {
+ auto FD = cast<FieldDecl>(D);
+ auto DefaultInit = Record.readExpr();
+
+ // Only apply the update if the field still has an uninstantiated
+ // default member initializer.
+ if (FD->hasInClassInitializer() && !FD->getInClassInitializer()) {
+ if (DefaultInit)
+ FD->setInClassInitializer(DefaultInit);
+ else
+ // Instantiation failed. We can get here if we serialized an AST for
+ // an invalid program.
+ FD->removeInClassInitializer();
+ }
+ break;
+ }
+
case UPD_CXX_ADDED_FUNCTION_DEFINITION: {
FunctionDecl *FD = cast<FunctionDecl>(D);
if (Reader.PendingBodies[FD]) {
@@ -3779,7 +3848,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
return;
}
- if (Record[Idx++]) {
+ if (Record.readInt()) {
// Maintain AST consistency: any later redeclarations of this function
// are inline if this one is. (We might have merged another declaration
// into this one.)
@@ -3787,16 +3856,16 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
FD->setImplicitlyInline();
});
}
- FD->setInnerLocStart(Reader.ReadSourceLocation(ModuleFile, Record, Idx));
+ FD->setInnerLocStart(ReadSourceLocation());
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
- CD->NumCtorInitializers = Record[Idx++];
+ CD->NumCtorInitializers = Record.readInt();
if (CD->NumCtorInitializers)
- CD->CtorInitializers = ReadGlobalOffset(F, Record, Idx);
+ CD->CtorInitializers = ReadGlobalOffset();
}
// Store the offset of the body so we can lazily load it later.
Reader.PendingBodies[FD] = GetCurrentCursorOffset();
HasPendingBody = true;
- assert(Idx == Record.size() && "lazy body must be last");
+ assert(Record.getIdx() == Record.size() && "lazy body must be last");
break;
}
@@ -3809,15 +3878,14 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
ReadCXXRecordDefinition(RD, /*Update*/true);
// Visible update is handled separately.
- uint64_t LexicalOffset = ReadLocalOffset(Record, Idx);
+ uint64_t LexicalOffset = ReadLocalOffset();
if (!HadRealDefinition && LexicalOffset) {
- Reader.ReadLexicalDeclContextStorage(ModuleFile, ModuleFile.DeclsCursor,
- LexicalOffset, RD);
+ Record.readLexicalDeclContextStorage(LexicalOffset, RD);
Reader.PendingFakeDefinitionData.erase(OldDD);
}
- auto TSK = (TemplateSpecializationKind)Record[Idx++];
- SourceLocation POI = Reader.ReadSourceLocation(ModuleFile, Record, Idx);
+ auto TSK = (TemplateSpecializationKind)Record.readInt();
+ SourceLocation POI = ReadSourceLocation();
if (MemberSpecializationInfo *MSInfo =
RD->getMemberSpecializationInfo()) {
MSInfo->setTemplateSpecializationKind(TSK);
@@ -3828,11 +3896,11 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
Spec->setTemplateSpecializationKind(TSK);
Spec->setPointOfInstantiation(POI);
- if (Record[Idx++]) {
+ if (Record.readInt()) {
auto PartialSpec =
- ReadDeclAs<ClassTemplatePartialSpecializationDecl>(Record, Idx);
+ ReadDeclAs<ClassTemplatePartialSpecializationDecl>();
SmallVector<TemplateArgument, 8> TemplArgs;
- Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
+ Record.readTemplateArgumentList(TemplArgs);
auto *TemplArgList = TemplateArgumentList::CreateCopy(
Reader.getContext(), TemplArgs);
@@ -3844,15 +3912,18 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
}
}
- RD->setTagKind((TagTypeKind)Record[Idx++]);
- RD->setLocation(Reader.ReadSourceLocation(ModuleFile, Record, Idx));
- RD->setLocStart(Reader.ReadSourceLocation(ModuleFile, Record, Idx));
- RD->setBraceRange(Reader.ReadSourceRange(ModuleFile, Record, Idx));
+ RD->setTagKind((TagTypeKind)Record.readInt());
+ RD->setLocation(ReadSourceLocation());
+ RD->setLocStart(ReadSourceLocation());
+ RD->setBraceRange(ReadSourceRange());
- if (Record[Idx++]) {
+ if (Record.readInt()) {
AttrVec Attrs;
- Reader.ReadAttributes(F, Attrs, Record, Idx);
- D->setAttrsImpl(Attrs, Reader.getContext());
+ Record.readAttributes(Attrs);
+ // If the declaration already has attributes, we assume that some other
+ // AST file already loaded them.
+ if (!D->hasAttrs())
+ D->setAttrsImpl(Attrs, Reader.getContext());
}
break;
}
@@ -3860,7 +3931,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_CXX_RESOLVED_DTOR_DELETE: {
// Set the 'operator delete' directly to avoid emitting another update
// record.
- auto *Del = Reader.ReadDeclAs<FunctionDecl>(ModuleFile, Record, Idx);
+ auto *Del = ReadDeclAs<FunctionDecl>();
auto *First = cast<CXXDestructorDecl>(D->getCanonicalDecl());
// FIXME: Check consistency if we have an old and new operator delete.
if (!First->OperatorDelete)
@@ -3871,7 +3942,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_CXX_RESOLVED_EXCEPTION_SPEC: {
FunctionProtoType::ExceptionSpecInfo ESI;
SmallVector<QualType, 8> ExceptionStorage;
- Reader.readExceptionSpec(ModuleFile, ExceptionStorage, ESI, Record, Idx);
+ Record.readExceptionSpec(ExceptionStorage, ESI);
// Update this declaration's exception specification, if needed.
auto *FD = cast<FunctionDecl>(D);
@@ -3893,7 +3964,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_CXX_DEDUCED_RETURN_TYPE: {
// FIXME: Also do this when merging redecls.
- QualType DeducedResultType = Reader.readType(ModuleFile, Record, Idx);
+ QualType DeducedResultType = Record.readType();
for (auto *Redecl : merged_redecls(D)) {
// FIXME: If the return type is already deduced, check that it matches.
FunctionDecl *FD = cast<FunctionDecl>(Redecl);
@@ -3909,20 +3980,20 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
}
case UPD_MANGLING_NUMBER:
- Reader.Context.setManglingNumber(cast<NamedDecl>(D), Record[Idx++]);
+ Reader.Context.setManglingNumber(cast<NamedDecl>(D), Record.readInt());
break;
case UPD_STATIC_LOCAL_NUMBER:
- Reader.Context.setStaticLocalNumber(cast<VarDecl>(D), Record[Idx++]);
+ Reader.Context.setStaticLocalNumber(cast<VarDecl>(D), Record.readInt());
break;
case UPD_DECL_MARKED_OPENMP_THREADPRIVATE:
D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(
- Reader.Context, ReadSourceRange(Record, Idx)));
+ Reader.Context, ReadSourceRange()));
break;
case UPD_DECL_EXPORTED: {
- unsigned SubmoduleID = readSubmoduleID(Record, Idx);
+ unsigned SubmoduleID = readSubmoduleID();
auto *Exported = cast<NamedDecl>(D);
if (auto *TD = dyn_cast<TagDecl>(Exported))
Exported = TD->getDefinition();
@@ -3946,7 +4017,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_DECL_MARKED_OPENMP_DECLARETARGET:
case UPD_ADDED_ATTR_TO_RECORD:
AttrVec Attrs;
- Reader.ReadAttributes(F, Attrs, Record, Idx);
+ Record.readAttributes(Attrs);
assert(Attrs.size() == 1);
D->addAttr(Attrs[0]);
break;
diff --git a/lib/Serialization/ASTReaderInternals.h b/lib/Serialization/ASTReaderInternals.h
index d392364a971b..6cb4d662e338 100644
--- a/lib/Serialization/ASTReaderInternals.h
+++ b/lib/Serialization/ASTReaderInternals.h
@@ -13,14 +13,12 @@
#ifndef LLVM_CLANG_LIB_SERIALIZATION_ASTREADERINTERNALS_H
#define LLVM_CLANG_LIB_SERIALIZATION_ASTREADERINTERNALS_H
+#include "MultiOnDiskHashTable.h"
#include "clang/AST/DeclarationName.h"
#include "clang/Serialization/ASTBitCodes.h"
#include "llvm/ADT/DenseSet.h"
-#include "llvm/ADT/PointerUnion.h"
-#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/OnDiskHashTable.h"
-#include "MultiOnDiskHashTable.h"
#include <utility>
namespace clang {
@@ -112,17 +110,6 @@ public:
struct DeclContextLookupTable {
MultiOnDiskHashTable<ASTDeclContextNameLookupTrait> Table;
-
- // These look redundant, but don't remove them -- they work around MSVC 2013's
- // inability to synthesize move operations. Without them, the
- // MultiOnDiskHashTable will be copied (despite being move-only!).
- DeclContextLookupTable() : Table() {}
- DeclContextLookupTable(DeclContextLookupTable &&O)
- : Table(std::move(O.Table)) {}
- DeclContextLookupTable &operator=(DeclContextLookupTable &&O) {
- Table = std::move(O.Table);
- return *this;
- }
};
/// \brief Base class for the trait describing the on-disk hash table for the
@@ -259,7 +246,7 @@ public:
struct internal_key_type {
off_t Size;
time_t ModTime;
- const char *Filename;
+ StringRef Filename;
bool Imported;
};
typedef const internal_key_type &internal_key_ref;
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp
index 395da42d4f24..5607f764a9c3 100644
--- a/lib/Serialization/ASTReaderStmt.cpp
+++ b/lib/Serialization/ASTReaderStmt.cpp
@@ -26,62 +26,47 @@ namespace clang {
class ASTStmtReader : public StmtVisitor<ASTStmtReader> {
friend class OMPClauseReader;
- typedef ASTReader::RecordData RecordData;
-
- ASTReader &Reader;
- ModuleFile &F;
+
+ ASTRecordReader &Record;
llvm::BitstreamCursor &DeclsCursor;
- const ASTReader::RecordData &Record;
- unsigned &Idx;
- Token ReadToken(const RecordData &R, unsigned &I) {
- return Reader.ReadToken(F, R, I);
+ SourceLocation ReadSourceLocation() {
+ return Record.readSourceLocation();
}
- SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
- return Reader.ReadSourceLocation(F, R, I);
+ SourceRange ReadSourceRange() {
+ return Record.readSourceRange();
}
- SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
- return Reader.ReadSourceRange(F, R, I);
+ std::string ReadString() {
+ return Record.readString();
}
- std::string ReadString(const RecordData &R, unsigned &I) {
- return Reader.ReadString(R, I);
- }
-
- TypeSourceInfo *GetTypeSourceInfo(const RecordData &R, unsigned &I) {
- return Reader.GetTypeSourceInfo(F, R, I);
- }
-
- serialization::DeclID ReadDeclID(const RecordData &R, unsigned &I) {
- return Reader.ReadDeclID(F, R, I);
+ TypeSourceInfo *GetTypeSourceInfo() {
+ return Record.getTypeSourceInfo();
}
-
- Decl *ReadDecl(const RecordData &R, unsigned &I) {
- return Reader.ReadDecl(F, R, I);
+
+ Decl *ReadDecl() {
+ return Record.readDecl();
}
-
+
template<typename T>
- T *ReadDeclAs(const RecordData &R, unsigned &I) {
- return Reader.ReadDeclAs<T>(F, R, I);
+ T *ReadDeclAs() {
+ return Record.readDeclAs<T>();
}
- void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc, DeclarationName Name,
- const ASTReader::RecordData &R, unsigned &I) {
- Reader.ReadDeclarationNameLoc(F, DNLoc, Name, R, I);
+ void ReadDeclarationNameLoc(DeclarationNameLoc &DNLoc,
+ DeclarationName Name) {
+ Record.readDeclarationNameLoc(DNLoc, Name);
}
-
- void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo,
- const ASTReader::RecordData &R, unsigned &I) {
- Reader.ReadDeclarationNameInfo(F, NameInfo, R, I);
+
+ void ReadDeclarationNameInfo(DeclarationNameInfo &NameInfo) {
+ Record.readDeclarationNameInfo(NameInfo);
}
public:
- ASTStmtReader(ASTReader &Reader, ModuleFile &F,
- llvm::BitstreamCursor &Cursor,
- const ASTReader::RecordData &Record, unsigned &Idx)
- : Reader(Reader), F(F), DeclsCursor(Cursor), Record(Record), Idx(Idx) { }
+ ASTStmtReader(ASTRecordReader &Record, llvm::BitstreamCursor &Cursor)
+ : Record(Record), DeclsCursor(Cursor) {}
/// \brief The number of record fields required for the Stmt class
/// itself.
@@ -109,106 +94,103 @@ namespace clang {
void ASTStmtReader::ReadTemplateKWAndArgsInfo(ASTTemplateKWAndArgsInfo &Args,
TemplateArgumentLoc *ArgsLocArray,
unsigned NumTemplateArgs) {
- SourceLocation TemplateKWLoc = ReadSourceLocation(Record, Idx);
+ SourceLocation TemplateKWLoc = ReadSourceLocation();
TemplateArgumentListInfo ArgInfo;
- ArgInfo.setLAngleLoc(ReadSourceLocation(Record, Idx));
- ArgInfo.setRAngleLoc(ReadSourceLocation(Record, Idx));
+ ArgInfo.setLAngleLoc(ReadSourceLocation());
+ ArgInfo.setRAngleLoc(ReadSourceLocation());
for (unsigned i = 0; i != NumTemplateArgs; ++i)
- ArgInfo.addArgument(
- Reader.ReadTemplateArgumentLoc(F, Record, Idx));
+ ArgInfo.addArgument(Record.readTemplateArgumentLoc());
Args.initializeFrom(TemplateKWLoc, ArgInfo, ArgsLocArray);
}
void ASTStmtReader::VisitStmt(Stmt *S) {
- assert(Idx == NumStmtFields && "Incorrect statement field count");
+ assert(Record.getIdx() == NumStmtFields && "Incorrect statement field count");
}
void ASTStmtReader::VisitNullStmt(NullStmt *S) {
VisitStmt(S);
- S->setSemiLoc(ReadSourceLocation(Record, Idx));
- S->HasLeadingEmptyMacro = Record[Idx++];
+ S->setSemiLoc(ReadSourceLocation());
+ S->HasLeadingEmptyMacro = Record.readInt();
}
void ASTStmtReader::VisitCompoundStmt(CompoundStmt *S) {
VisitStmt(S);
SmallVector<Stmt *, 16> Stmts;
- unsigned NumStmts = Record[Idx++];
+ unsigned NumStmts = Record.readInt();
while (NumStmts--)
- Stmts.push_back(Reader.ReadSubStmt());
- S->setStmts(Reader.getContext(), Stmts);
- S->LBraceLoc = ReadSourceLocation(Record, Idx);
- S->RBraceLoc = ReadSourceLocation(Record, Idx);
+ Stmts.push_back(Record.readSubStmt());
+ S->setStmts(Record.getContext(), Stmts);
+ S->LBraceLoc = ReadSourceLocation();
+ S->RBraceLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitSwitchCase(SwitchCase *S) {
VisitStmt(S);
- Reader.RecordSwitchCaseID(S, Record[Idx++]);
- S->setKeywordLoc(ReadSourceLocation(Record, Idx));
- S->setColonLoc(ReadSourceLocation(Record, Idx));
+ Record.recordSwitchCaseID(S, Record.readInt());
+ S->setKeywordLoc(ReadSourceLocation());
+ S->setColonLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitCaseStmt(CaseStmt *S) {
VisitSwitchCase(S);
- S->setLHS(Reader.ReadSubExpr());
- S->setRHS(Reader.ReadSubExpr());
- S->setSubStmt(Reader.ReadSubStmt());
- S->setEllipsisLoc(ReadSourceLocation(Record, Idx));
+ S->setLHS(Record.readSubExpr());
+ S->setRHS(Record.readSubExpr());
+ S->setSubStmt(Record.readSubStmt());
+ S->setEllipsisLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitDefaultStmt(DefaultStmt *S) {
VisitSwitchCase(S);
- S->setSubStmt(Reader.ReadSubStmt());
+ S->setSubStmt(Record.readSubStmt());
}
void ASTStmtReader::VisitLabelStmt(LabelStmt *S) {
VisitStmt(S);
- LabelDecl *LD = ReadDeclAs<LabelDecl>(Record, Idx);
+ LabelDecl *LD = ReadDeclAs<LabelDecl>();
LD->setStmt(S);
S->setDecl(LD);
- S->setSubStmt(Reader.ReadSubStmt());
- S->setIdentLoc(ReadSourceLocation(Record, Idx));
+ S->setSubStmt(Record.readSubStmt());
+ S->setIdentLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
VisitStmt(S);
- uint64_t NumAttrs = Record[Idx++];
+ uint64_t NumAttrs = Record.readInt();
AttrVec Attrs;
- Reader.ReadAttributes(F, Attrs, Record, Idx);
+ Record.readAttributes(Attrs);
(void)NumAttrs;
assert(NumAttrs == S->NumAttrs);
assert(NumAttrs == Attrs.size());
std::copy(Attrs.begin(), Attrs.end(), S->getAttrArrayPtr());
- S->SubStmt = Reader.ReadSubStmt();
- S->AttrLoc = ReadSourceLocation(Record, Idx);
+ S->SubStmt = Record.readSubStmt();
+ S->AttrLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitIfStmt(IfStmt *S) {
VisitStmt(S);
- S->setConstexpr(Record[Idx++]);
- S->setInit(Reader.ReadSubStmt());
- S->setConditionVariable(Reader.getContext(),
- ReadDeclAs<VarDecl>(Record, Idx));
- S->setCond(Reader.ReadSubExpr());
- S->setThen(Reader.ReadSubStmt());
- S->setElse(Reader.ReadSubStmt());
- S->setIfLoc(ReadSourceLocation(Record, Idx));
- S->setElseLoc(ReadSourceLocation(Record, Idx));
+ S->setConstexpr(Record.readInt());
+ S->setInit(Record.readSubStmt());
+ S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
+ S->setCond(Record.readSubExpr());
+ S->setThen(Record.readSubStmt());
+ S->setElse(Record.readSubStmt());
+ S->setIfLoc(ReadSourceLocation());
+ S->setElseLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
VisitStmt(S);
- S->setInit(Reader.ReadSubStmt());
- S->setConditionVariable(Reader.getContext(),
- ReadDeclAs<VarDecl>(Record, Idx));
- S->setCond(Reader.ReadSubExpr());
- S->setBody(Reader.ReadSubStmt());
- S->setSwitchLoc(ReadSourceLocation(Record, Idx));
- if (Record[Idx++])
+ S->setInit(Record.readSubStmt());
+ S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
+ S->setCond(Record.readSubExpr());
+ S->setBody(Record.readSubStmt());
+ S->setSwitchLoc(ReadSourceLocation());
+ if (Record.readInt())
S->setAllEnumCasesCovered();
SwitchCase *PrevSC = nullptr;
- for (unsigned N = Record.size(); Idx != N; ++Idx) {
- SwitchCase *SC = Reader.getSwitchCaseWithID(Record[Idx]);
+ for (auto E = Record.size(); Record.getIdx() != E; ) {
+ SwitchCase *SC = Record.getSwitchCaseWithID(Record.readInt());
if (PrevSC)
PrevSC->setNextSwitchCase(SC);
else
@@ -220,81 +202,80 @@ void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
void ASTStmtReader::VisitWhileStmt(WhileStmt *S) {
VisitStmt(S);
- S->setConditionVariable(Reader.getContext(),
- ReadDeclAs<VarDecl>(Record, Idx));
+ S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
- S->setCond(Reader.ReadSubExpr());
- S->setBody(Reader.ReadSubStmt());
- S->setWhileLoc(ReadSourceLocation(Record, Idx));
+ S->setCond(Record.readSubExpr());
+ S->setBody(Record.readSubStmt());
+ S->setWhileLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitDoStmt(DoStmt *S) {
VisitStmt(S);
- S->setCond(Reader.ReadSubExpr());
- S->setBody(Reader.ReadSubStmt());
- S->setDoLoc(ReadSourceLocation(Record, Idx));
- S->setWhileLoc(ReadSourceLocation(Record, Idx));
- S->setRParenLoc(ReadSourceLocation(Record, Idx));
+ S->setCond(Record.readSubExpr());
+ S->setBody(Record.readSubStmt());
+ S->setDoLoc(ReadSourceLocation());
+ S->setWhileLoc(ReadSourceLocation());
+ S->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitForStmt(ForStmt *S) {
VisitStmt(S);
- S->setInit(Reader.ReadSubStmt());
- S->setCond(Reader.ReadSubExpr());
- S->setConditionVariable(Reader.getContext(),
- ReadDeclAs<VarDecl>(Record, Idx));
- S->setInc(Reader.ReadSubExpr());
- S->setBody(Reader.ReadSubStmt());
- S->setForLoc(ReadSourceLocation(Record, Idx));
- S->setLParenLoc(ReadSourceLocation(Record, Idx));
- S->setRParenLoc(ReadSourceLocation(Record, Idx));
+ S->setInit(Record.readSubStmt());
+ S->setCond(Record.readSubExpr());
+ S->setConditionVariable(Record.getContext(), ReadDeclAs<VarDecl>());
+ S->setInc(Record.readSubExpr());
+ S->setBody(Record.readSubStmt());
+ S->setForLoc(ReadSourceLocation());
+ S->setLParenLoc(ReadSourceLocation());
+ S->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitGotoStmt(GotoStmt *S) {
VisitStmt(S);
- S->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
- S->setGotoLoc(ReadSourceLocation(Record, Idx));
- S->setLabelLoc(ReadSourceLocation(Record, Idx));
+ S->setLabel(ReadDeclAs<LabelDecl>());
+ S->setGotoLoc(ReadSourceLocation());
+ S->setLabelLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
VisitStmt(S);
- S->setGotoLoc(ReadSourceLocation(Record, Idx));
- S->setStarLoc(ReadSourceLocation(Record, Idx));
- S->setTarget(Reader.ReadSubExpr());
+ S->setGotoLoc(ReadSourceLocation());
+ S->setStarLoc(ReadSourceLocation());
+ S->setTarget(Record.readSubExpr());
}
void ASTStmtReader::VisitContinueStmt(ContinueStmt *S) {
VisitStmt(S);
- S->setContinueLoc(ReadSourceLocation(Record, Idx));
+ S->setContinueLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitBreakStmt(BreakStmt *S) {
VisitStmt(S);
- S->setBreakLoc(ReadSourceLocation(Record, Idx));
+ S->setBreakLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {
VisitStmt(S);
- S->setRetValue(Reader.ReadSubExpr());
- S->setReturnLoc(ReadSourceLocation(Record, Idx));
- S->setNRVOCandidate(ReadDeclAs<VarDecl>(Record, Idx));
+ S->setRetValue(Record.readSubExpr());
+ S->setReturnLoc(ReadSourceLocation());
+ S->setNRVOCandidate(ReadDeclAs<VarDecl>());
}
void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
VisitStmt(S);
- S->setStartLoc(ReadSourceLocation(Record, Idx));
- S->setEndLoc(ReadSourceLocation(Record, Idx));
+ S->setStartLoc(ReadSourceLocation());
+ S->setEndLoc(ReadSourceLocation());
- if (Idx + 1 == Record.size()) {
+ if (Record.size() - Record.getIdx() == 1) {
// Single declaration
- S->setDeclGroup(DeclGroupRef(ReadDecl(Record, Idx)));
+ S->setDeclGroup(DeclGroupRef(ReadDecl()));
} else {
SmallVector<Decl *, 16> Decls;
- Decls.reserve(Record.size() - Idx);
- for (unsigned N = Record.size(); Idx != N; )
- Decls.push_back(ReadDecl(Record, Idx));
- S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Reader.getContext(),
+ int N = Record.size() - Record.getIdx();
+ Decls.reserve(N);
+ for (int I = 0; I < N; ++I)
+ Decls.push_back(ReadDecl());
+ S->setDeclGroup(DeclGroupRef(DeclGroup::Create(Record.getContext(),
Decls.data(),
Decls.size())));
}
@@ -302,18 +283,18 @@ void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
void ASTStmtReader::VisitAsmStmt(AsmStmt *S) {
VisitStmt(S);
- S->NumOutputs = Record[Idx++];
- S->NumInputs = Record[Idx++];
- S->NumClobbers = Record[Idx++];
- S->setAsmLoc(ReadSourceLocation(Record, Idx));
- S->setVolatile(Record[Idx++]);
- S->setSimple(Record[Idx++]);
+ S->NumOutputs = Record.readInt();
+ S->NumInputs = Record.readInt();
+ S->NumClobbers = Record.readInt();
+ S->setAsmLoc(ReadSourceLocation());
+ S->setVolatile(Record.readInt());
+ S->setSimple(Record.readInt());
}
void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
VisitAsmStmt(S);
- S->setRParenLoc(ReadSourceLocation(Record, Idx));
- S->setAsmString(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
+ S->setRParenLoc(ReadSourceLocation());
+ S->setAsmString(cast_or_null<StringLiteral>(Record.readSubStmt()));
unsigned NumOutputs = S->getNumOutputs();
unsigned NumInputs = S->getNumInputs();
@@ -324,34 +305,34 @@ void ASTStmtReader::VisitGCCAsmStmt(GCCAsmStmt *S) {
SmallVector<StringLiteral*, 16> Constraints;
SmallVector<Stmt*, 16> Exprs;
for (unsigned I = 0, N = NumOutputs + NumInputs; I != N; ++I) {
- Names.push_back(Reader.GetIdentifierInfo(F, Record, Idx));
- Constraints.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
- Exprs.push_back(Reader.ReadSubStmt());
+ Names.push_back(Record.getIdentifierInfo());
+ Constraints.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
+ Exprs.push_back(Record.readSubStmt());
}
// Constraints
SmallVector<StringLiteral*, 16> Clobbers;
for (unsigned I = 0; I != NumClobbers; ++I)
- Clobbers.push_back(cast_or_null<StringLiteral>(Reader.ReadSubStmt()));
+ Clobbers.push_back(cast_or_null<StringLiteral>(Record.readSubStmt()));
- S->setOutputsAndInputsAndClobbers(Reader.getContext(),
- Names.data(), Constraints.data(),
- Exprs.data(), NumOutputs, NumInputs,
+ S->setOutputsAndInputsAndClobbers(Record.getContext(),
+ Names.data(), Constraints.data(),
+ Exprs.data(), NumOutputs, NumInputs,
Clobbers.data(), NumClobbers);
}
void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
VisitAsmStmt(S);
- S->LBraceLoc = ReadSourceLocation(Record, Idx);
- S->EndLoc = ReadSourceLocation(Record, Idx);
- S->NumAsmToks = Record[Idx++];
- std::string AsmStr = ReadString(Record, Idx);
+ S->LBraceLoc = ReadSourceLocation();
+ S->EndLoc = ReadSourceLocation();
+ S->NumAsmToks = Record.readInt();
+ std::string AsmStr = ReadString();
// Read the tokens.
SmallVector<Token, 16> AsmToks;
AsmToks.reserve(S->NumAsmToks);
for (unsigned i = 0, e = S->NumAsmToks; i != e; ++i) {
- AsmToks.push_back(ReadToken(Record, Idx));
+ AsmToks.push_back(Record.readToken());
}
// The calls to reserve() for the FooData vectors are mandatory to
@@ -363,7 +344,7 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
ClobbersData.reserve(S->NumClobbers);
Clobbers.reserve(S->NumClobbers);
for (unsigned i = 0, e = S->NumClobbers; i != e; ++i) {
- ClobbersData.push_back(ReadString(Record, Idx));
+ ClobbersData.push_back(ReadString());
Clobbers.push_back(ClobbersData.back());
}
@@ -376,12 +357,12 @@ void ASTStmtReader::VisitMSAsmStmt(MSAsmStmt *S) {
ConstraintsData.reserve(NumOperands);
Constraints.reserve(NumOperands);
for (unsigned i = 0; i != NumOperands; ++i) {
- Exprs.push_back(cast<Expr>(Reader.ReadSubStmt()));
- ConstraintsData.push_back(ReadString(Record, Idx));
+ Exprs.push_back(cast<Expr>(Record.readSubStmt()));
+ ConstraintsData.push_back(ReadString());
Constraints.push_back(ConstraintsData.back());
}
- S->initialize(Reader.getContext(), AsmStr, AsmToks,
+ S->initialize(Record.getContext(), AsmStr, AsmToks,
Constraints, Exprs, Clobbers);
}
@@ -407,229 +388,229 @@ void ASTStmtReader::VisitCoyieldExpr(CoyieldExpr *S) {
void ASTStmtReader::VisitCapturedStmt(CapturedStmt *S) {
VisitStmt(S);
- ++Idx;
- S->setCapturedDecl(ReadDeclAs<CapturedDecl>(Record, Idx));
- S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record[Idx++]));
- S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>(Record, Idx));
+ Record.skipInts(1);
+ S->setCapturedDecl(ReadDeclAs<CapturedDecl>());
+ S->setCapturedRegionKind(static_cast<CapturedRegionKind>(Record.readInt()));
+ S->setCapturedRecordDecl(ReadDeclAs<RecordDecl>());
// Capture inits
for (CapturedStmt::capture_init_iterator I = S->capture_init_begin(),
E = S->capture_init_end();
I != E; ++I)
- *I = Reader.ReadSubExpr();
+ *I = Record.readSubExpr();
// Body
- S->setCapturedStmt(Reader.ReadSubStmt());
+ S->setCapturedStmt(Record.readSubStmt());
S->getCapturedDecl()->setBody(S->getCapturedStmt());
// Captures
for (auto &I : S->captures()) {
- I.VarAndKind.setPointer(ReadDeclAs<VarDecl>(Record, Idx));
- I.VarAndKind
- .setInt(static_cast<CapturedStmt::VariableCaptureKind>(Record[Idx++]));
- I.Loc = ReadSourceLocation(Record, Idx);
+ I.VarAndKind.setPointer(ReadDeclAs<VarDecl>());
+ I.VarAndKind.setInt(
+ static_cast<CapturedStmt::VariableCaptureKind>(Record.readInt()));
+ I.Loc = ReadSourceLocation();
}
}
void ASTStmtReader::VisitExpr(Expr *E) {
VisitStmt(E);
- E->setType(Reader.readType(F, Record, Idx));
- E->setTypeDependent(Record[Idx++]);
- E->setValueDependent(Record[Idx++]);
- E->setInstantiationDependent(Record[Idx++]);
- E->ExprBits.ContainsUnexpandedParameterPack = Record[Idx++];
- E->setValueKind(static_cast<ExprValueKind>(Record[Idx++]));
- E->setObjectKind(static_cast<ExprObjectKind>(Record[Idx++]));
- assert(Idx == NumExprFields && "Incorrect expression field count");
+ E->setType(Record.readType());
+ E->setTypeDependent(Record.readInt());
+ E->setValueDependent(Record.readInt());
+ E->setInstantiationDependent(Record.readInt());
+ E->ExprBits.ContainsUnexpandedParameterPack = Record.readInt();
+ E->setValueKind(static_cast<ExprValueKind>(Record.readInt()));
+ E->setObjectKind(static_cast<ExprObjectKind>(Record.readInt()));
+ assert(Record.getIdx() == NumExprFields &&
+ "Incorrect expression field count");
}
void ASTStmtReader::VisitPredefinedExpr(PredefinedExpr *E) {
VisitExpr(E);
- E->setLocation(ReadSourceLocation(Record, Idx));
- E->Type = (PredefinedExpr::IdentType)Record[Idx++];
- E->FnName = cast_or_null<StringLiteral>(Reader.ReadSubExpr());
+ E->setLocation(ReadSourceLocation());
+ E->Type = (PredefinedExpr::IdentType)Record.readInt();
+ E->FnName = cast_or_null<StringLiteral>(Record.readSubExpr());
}
void ASTStmtReader::VisitDeclRefExpr(DeclRefExpr *E) {
VisitExpr(E);
- E->DeclRefExprBits.HasQualifier = Record[Idx++];
- E->DeclRefExprBits.HasFoundDecl = Record[Idx++];
- E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record[Idx++];
- E->DeclRefExprBits.HadMultipleCandidates = Record[Idx++];
- E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record[Idx++];
+ E->DeclRefExprBits.HasQualifier = Record.readInt();
+ E->DeclRefExprBits.HasFoundDecl = Record.readInt();
+ E->DeclRefExprBits.HasTemplateKWAndArgsInfo = Record.readInt();
+ E->DeclRefExprBits.HadMultipleCandidates = Record.readInt();
+ E->DeclRefExprBits.RefersToEnclosingVariableOrCapture = Record.readInt();
unsigned NumTemplateArgs = 0;
if (E->hasTemplateKWAndArgsInfo())
- NumTemplateArgs = Record[Idx++];
+ NumTemplateArgs = Record.readInt();
if (E->hasQualifier())
new (E->getTrailingObjects<NestedNameSpecifierLoc>())
- NestedNameSpecifierLoc(
- Reader.ReadNestedNameSpecifierLoc(F, Record, Idx));
+ NestedNameSpecifierLoc(Record.readNestedNameSpecifierLoc());
if (E->hasFoundDecl())
- *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>(Record, Idx);
+ *E->getTrailingObjects<NamedDecl *>() = ReadDeclAs<NamedDecl>();
if (E->hasTemplateKWAndArgsInfo())
ReadTemplateKWAndArgsInfo(
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
E->getTrailingObjects<TemplateArgumentLoc>(), NumTemplateArgs);
- E->setDecl(ReadDeclAs<ValueDecl>(Record, Idx));
- E->setLocation(ReadSourceLocation(Record, Idx));
- ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record, Idx);
+ E->setDecl(ReadDeclAs<ValueDecl>());
+ E->setLocation(ReadSourceLocation());
+ ReadDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
}
void ASTStmtReader::VisitIntegerLiteral(IntegerLiteral *E) {
VisitExpr(E);
- E->setLocation(ReadSourceLocation(Record, Idx));
- E->setValue(Reader.getContext(), Reader.ReadAPInt(Record, Idx));
+ E->setLocation(ReadSourceLocation());
+ E->setValue(Record.getContext(), Record.readAPInt());
}
void ASTStmtReader::VisitFloatingLiteral(FloatingLiteral *E) {
VisitExpr(E);
- E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record[Idx++]));
- E->setExact(Record[Idx++]);
- E->setValue(Reader.getContext(),
- Reader.ReadAPFloat(Record, E->getSemantics(), Idx));
- E->setLocation(ReadSourceLocation(Record, Idx));
+ E->setRawSemantics(static_cast<Stmt::APFloatSemantics>(Record.readInt()));
+ E->setExact(Record.readInt());
+ E->setValue(Record.getContext(), Record.readAPFloat(E->getSemantics()));
+ E->setLocation(ReadSourceLocation());
}
void ASTStmtReader::VisitImaginaryLiteral(ImaginaryLiteral *E) {
VisitExpr(E);
- E->setSubExpr(Reader.ReadSubExpr());
+ E->setSubExpr(Record.readSubExpr());
}
void ASTStmtReader::VisitStringLiteral(StringLiteral *E) {
VisitExpr(E);
- unsigned Len = Record[Idx++];
- assert(Record[Idx] == E->getNumConcatenated() &&
+ unsigned Len = Record.readInt();
+ assert(Record.peekInt() == E->getNumConcatenated() &&
"Wrong number of concatenated tokens!");
- ++Idx;
+ Record.skipInts(1);
StringLiteral::StringKind kind =
- static_cast<StringLiteral::StringKind>(Record[Idx++]);
- bool isPascal = Record[Idx++];
+ static_cast<StringLiteral::StringKind>(Record.readInt());
+ bool isPascal = Record.readInt();
// Read string data
- SmallString<16> Str(&Record[Idx], &Record[Idx] + Len);
- E->setString(Reader.getContext(), Str, kind, isPascal);
- Idx += Len;
+ auto B = &Record.peekInt();
+ SmallString<16> Str(B, B + Len);
+ E->setString(Record.getContext(), Str, kind, isPascal);
+ Record.skipInts(Len);
// Read source locations
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
- E->setStrTokenLoc(I, ReadSourceLocation(Record, Idx));
+ E->setStrTokenLoc(I, ReadSourceLocation());
}
void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {
VisitExpr(E);
- E->setValue(Record[Idx++]);
- E->setLocation(ReadSourceLocation(Record, Idx));
- E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record[Idx++]));
+ E->setValue(Record.readInt());
+ E->setLocation(ReadSourceLocation());
+ E->setKind(static_cast<CharacterLiteral::CharacterKind>(Record.readInt()));
}
void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
VisitExpr(E);
- E->setLParen(ReadSourceLocation(Record, Idx));
- E->setRParen(ReadSourceLocation(Record, Idx));
- E->setSubExpr(Reader.ReadSubExpr());
+ E->setLParen(ReadSourceLocation());
+ E->setRParen(ReadSourceLocation());
+ E->setSubExpr(Record.readSubExpr());
}
void ASTStmtReader::VisitParenListExpr(ParenListExpr *E) {
VisitExpr(E);
- unsigned NumExprs = Record[Idx++];
- E->Exprs = new (Reader.getContext()) Stmt*[NumExprs];
+ unsigned NumExprs = Record.readInt();
+ E->Exprs = new (Record.getContext()) Stmt*[NumExprs];
for (unsigned i = 0; i != NumExprs; ++i)
- E->Exprs[i] = Reader.ReadSubStmt();
+ E->Exprs[i] = Record.readSubStmt();
E->NumExprs = NumExprs;
- E->LParenLoc = ReadSourceLocation(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
+ E->LParenLoc = ReadSourceLocation();
+ E->RParenLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitUnaryOperator(UnaryOperator *E) {
VisitExpr(E);
- E->setSubExpr(Reader.ReadSubExpr());
- E->setOpcode((UnaryOperator::Opcode)Record[Idx++]);
- E->setOperatorLoc(ReadSourceLocation(Record, Idx));
+ E->setSubExpr(Record.readSubExpr());
+ E->setOpcode((UnaryOperator::Opcode)Record.readInt());
+ E->setOperatorLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitOffsetOfExpr(OffsetOfExpr *E) {
VisitExpr(E);
- assert(E->getNumComponents() == Record[Idx]);
- ++Idx;
- assert(E->getNumExpressions() == Record[Idx]);
- ++Idx;
- E->setOperatorLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
- E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
+ assert(E->getNumComponents() == Record.peekInt());
+ Record.skipInts(1);
+ assert(E->getNumExpressions() == Record.peekInt());
+ Record.skipInts(1);
+ E->setOperatorLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
+ E->setTypeSourceInfo(GetTypeSourceInfo());
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
- OffsetOfNode::Kind Kind = static_cast<OffsetOfNode::Kind>(Record[Idx++]);
- SourceLocation Start = ReadSourceLocation(Record, Idx);
- SourceLocation End = ReadSourceLocation(Record, Idx);
+ OffsetOfNode::Kind Kind = static_cast<OffsetOfNode::Kind>(Record.readInt());
+ SourceLocation Start = ReadSourceLocation();
+ SourceLocation End = ReadSourceLocation();
switch (Kind) {
case OffsetOfNode::Array:
- E->setComponent(I, OffsetOfNode(Start, Record[Idx++], End));
+ E->setComponent(I, OffsetOfNode(Start, Record.readInt(), End));
break;
case OffsetOfNode::Field:
E->setComponent(
- I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(Record, Idx), End));
+ I, OffsetOfNode(Start, ReadDeclAs<FieldDecl>(), End));
break;
case OffsetOfNode::Identifier:
E->setComponent(
I,
- OffsetOfNode(Start, Reader.GetIdentifierInfo(F, Record, Idx), End));
+ OffsetOfNode(Start, Record.getIdentifierInfo(), End));
break;
case OffsetOfNode::Base: {
- CXXBaseSpecifier *Base = new (Reader.getContext()) CXXBaseSpecifier();
- *Base = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
+ CXXBaseSpecifier *Base = new (Record.getContext()) CXXBaseSpecifier();
+ *Base = Record.readCXXBaseSpecifier();
E->setComponent(I, OffsetOfNode(Base));
break;
}
}
}
-
+
for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
- E->setIndexExpr(I, Reader.ReadSubExpr());
+ E->setIndexExpr(I, Record.readSubExpr());
}
void ASTStmtReader::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
VisitExpr(E);
- E->setKind(static_cast<UnaryExprOrTypeTrait>(Record[Idx++]));
- if (Record[Idx] == 0) {
- E->setArgument(Reader.ReadSubExpr());
- ++Idx;
+ E->setKind(static_cast<UnaryExprOrTypeTrait>(Record.readInt()));
+ if (Record.peekInt() == 0) {
+ E->setArgument(Record.readSubExpr());
+ Record.skipInts(1);
} else {
- E->setArgument(GetTypeSourceInfo(Record, Idx));
+ E->setArgument(GetTypeSourceInfo());
}
- E->setOperatorLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->setOperatorLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
VisitExpr(E);
- E->setLHS(Reader.ReadSubExpr());
- E->setRHS(Reader.ReadSubExpr());
- E->setRBracketLoc(ReadSourceLocation(Record, Idx));
+ E->setLHS(Record.readSubExpr());
+ E->setRHS(Record.readSubExpr());
+ E->setRBracketLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadSubExpr());
- E->setLowerBound(Reader.ReadSubExpr());
- E->setLength(Reader.ReadSubExpr());
- E->setColonLoc(ReadSourceLocation(Record, Idx));
- E->setRBracketLoc(ReadSourceLocation(Record, Idx));
+ E->setBase(Record.readSubExpr());
+ E->setLowerBound(Record.readSubExpr());
+ E->setLength(Record.readSubExpr());
+ E->setColonLoc(ReadSourceLocation());
+ E->setRBracketLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitCallExpr(CallExpr *E) {
VisitExpr(E);
- E->setNumArgs(Reader.getContext(), Record[Idx++]);
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
- E->setCallee(Reader.ReadSubExpr());
+ E->setNumArgs(Record.getContext(), Record.readInt());
+ E->setRParenLoc(ReadSourceLocation());
+ E->setCallee(Record.readSubExpr());
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, Reader.ReadSubExpr());
+ E->setArg(I, Record.readSubExpr());
}
void ASTStmtReader::VisitCXXMemberCallExpr(CXXMemberCallExpr *E) {
@@ -644,74 +625,74 @@ void ASTStmtReader::VisitMemberExpr(MemberExpr *E) {
void ASTStmtReader::VisitObjCIsaExpr(ObjCIsaExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadSubExpr());
- E->setIsaMemberLoc(ReadSourceLocation(Record, Idx));
- E->setOpLoc(ReadSourceLocation(Record, Idx));
- E->setArrow(Record[Idx++]);
+ E->setBase(Record.readSubExpr());
+ E->setIsaMemberLoc(ReadSourceLocation());
+ E->setOpLoc(ReadSourceLocation());
+ E->setArrow(Record.readInt());
}
void ASTStmtReader::
VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
VisitExpr(E);
- E->Operand = Reader.ReadSubExpr();
- E->setShouldCopy(Record[Idx++]);
+ E->Operand = Record.readSubExpr();
+ E->setShouldCopy(Record.readInt());
}
void ASTStmtReader::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
VisitExplicitCastExpr(E);
- E->LParenLoc = ReadSourceLocation(Record, Idx);
- E->BridgeKeywordLoc = ReadSourceLocation(Record, Idx);
- E->Kind = Record[Idx++];
+ E->LParenLoc = ReadSourceLocation();
+ E->BridgeKeywordLoc = ReadSourceLocation();
+ E->Kind = Record.readInt();
}
void ASTStmtReader::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
- unsigned NumBaseSpecs = Record[Idx++];
+ unsigned NumBaseSpecs = Record.readInt();
assert(NumBaseSpecs == E->path_size());
- E->setSubExpr(Reader.ReadSubExpr());
- E->setCastKind((CastKind)Record[Idx++]);
+ E->setSubExpr(Record.readSubExpr());
+ E->setCastKind((CastKind)Record.readInt());
CastExpr::path_iterator BaseI = E->path_begin();
while (NumBaseSpecs--) {
- CXXBaseSpecifier *BaseSpec = new (Reader.getContext()) CXXBaseSpecifier;
- *BaseSpec = Reader.ReadCXXBaseSpecifier(F, Record, Idx);
+ CXXBaseSpecifier *BaseSpec = new (Record.getContext()) CXXBaseSpecifier;
+ *BaseSpec = Record.readCXXBaseSpecifier();
*BaseI++ = BaseSpec;
}
}
void ASTStmtReader::VisitBinaryOperator(BinaryOperator *E) {
VisitExpr(E);
- E->setLHS(Reader.ReadSubExpr());
- E->setRHS(Reader.ReadSubExpr());
- E->setOpcode((BinaryOperator::Opcode)Record[Idx++]);
- E->setOperatorLoc(ReadSourceLocation(Record, Idx));
- E->setFPContractable((bool)Record[Idx++]);
+ E->setLHS(Record.readSubExpr());
+ E->setRHS(Record.readSubExpr());
+ E->setOpcode((BinaryOperator::Opcode)Record.readInt());
+ E->setOperatorLoc(ReadSourceLocation());
+ E->setFPContractable((bool)Record.readInt());
}
void ASTStmtReader::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
VisitBinaryOperator(E);
- E->setComputationLHSType(Reader.readType(F, Record, Idx));
- E->setComputationResultType(Reader.readType(F, Record, Idx));
+ E->setComputationLHSType(Record.readType());
+ E->setComputationResultType(Record.readType());
}
void ASTStmtReader::VisitConditionalOperator(ConditionalOperator *E) {
VisitExpr(E);
- E->SubExprs[ConditionalOperator::COND] = Reader.ReadSubExpr();
- E->SubExprs[ConditionalOperator::LHS] = Reader.ReadSubExpr();
- E->SubExprs[ConditionalOperator::RHS] = Reader.ReadSubExpr();
- E->QuestionLoc = ReadSourceLocation(Record, Idx);
- E->ColonLoc = ReadSourceLocation(Record, Idx);
+ E->SubExprs[ConditionalOperator::COND] = Record.readSubExpr();
+ E->SubExprs[ConditionalOperator::LHS] = Record.readSubExpr();
+ E->SubExprs[ConditionalOperator::RHS] = Record.readSubExpr();
+ E->QuestionLoc = ReadSourceLocation();
+ E->ColonLoc = ReadSourceLocation();
}
void
ASTStmtReader::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
VisitExpr(E);
- E->OpaqueValue = cast<OpaqueValueExpr>(Reader.ReadSubExpr());
- E->SubExprs[BinaryConditionalOperator::COMMON] = Reader.ReadSubExpr();
- E->SubExprs[BinaryConditionalOperator::COND] = Reader.ReadSubExpr();
- E->SubExprs[BinaryConditionalOperator::LHS] = Reader.ReadSubExpr();
- E->SubExprs[BinaryConditionalOperator::RHS] = Reader.ReadSubExpr();
- E->QuestionLoc = ReadSourceLocation(Record, Idx);
- E->ColonLoc = ReadSourceLocation(Record, Idx);
+ E->OpaqueValue = cast<OpaqueValueExpr>(Record.readSubExpr());
+ E->SubExprs[BinaryConditionalOperator::COMMON] = Record.readSubExpr();
+ E->SubExprs[BinaryConditionalOperator::COND] = Record.readSubExpr();
+ E->SubExprs[BinaryConditionalOperator::LHS] = Record.readSubExpr();
+ E->SubExprs[BinaryConditionalOperator::RHS] = Record.readSubExpr();
+ E->QuestionLoc = ReadSourceLocation();
+ E->ColonLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
@@ -720,54 +701,54 @@ void ASTStmtReader::VisitImplicitCastExpr(ImplicitCastExpr *E) {
void ASTStmtReader::VisitExplicitCastExpr(ExplicitCastExpr *E) {
VisitCastExpr(E);
- E->setTypeInfoAsWritten(GetTypeSourceInfo(Record, Idx));
+ E->setTypeInfoAsWritten(GetTypeSourceInfo());
}
void ASTStmtReader::VisitCStyleCastExpr(CStyleCastExpr *E) {
VisitExplicitCastExpr(E);
- E->setLParenLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->setLParenLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
VisitExpr(E);
- E->setLParenLoc(ReadSourceLocation(Record, Idx));
- E->setTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
- E->setInitializer(Reader.ReadSubExpr());
- E->setFileScope(Record[Idx++]);
+ E->setLParenLoc(ReadSourceLocation());
+ E->setTypeSourceInfo(GetTypeSourceInfo());
+ E->setInitializer(Record.readSubExpr());
+ E->setFileScope(Record.readInt());
}
void ASTStmtReader::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadSubExpr());
- E->setAccessor(Reader.GetIdentifierInfo(F, Record, Idx));
- E->setAccessorLoc(ReadSourceLocation(Record, Idx));
+ E->setBase(Record.readSubExpr());
+ E->setAccessor(Record.getIdentifierInfo());
+ E->setAccessorLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitInitListExpr(InitListExpr *E) {
VisitExpr(E);
- if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Reader.ReadSubStmt()))
+ if (InitListExpr *SyntForm = cast_or_null<InitListExpr>(Record.readSubStmt()))
E->setSyntacticForm(SyntForm);
- E->setLBraceLoc(ReadSourceLocation(Record, Idx));
- E->setRBraceLoc(ReadSourceLocation(Record, Idx));
- bool isArrayFiller = Record[Idx++];
+ E->setLBraceLoc(ReadSourceLocation());
+ E->setRBraceLoc(ReadSourceLocation());
+ bool isArrayFiller = Record.readInt();
Expr *filler = nullptr;
if (isArrayFiller) {
- filler = Reader.ReadSubExpr();
+ filler = Record.readSubExpr();
E->ArrayFillerOrUnionFieldInit = filler;
} else
- E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>(Record, Idx);
- E->sawArrayRangeDesignator(Record[Idx++]);
- unsigned NumInits = Record[Idx++];
- E->reserveInits(Reader.getContext(), NumInits);
+ E->ArrayFillerOrUnionFieldInit = ReadDeclAs<FieldDecl>();
+ E->sawArrayRangeDesignator(Record.readInt());
+ unsigned NumInits = Record.readInt();
+ E->reserveInits(Record.getContext(), NumInits);
if (isArrayFiller) {
for (unsigned I = 0; I != NumInits; ++I) {
- Expr *init = Reader.ReadSubExpr();
- E->updateInit(Reader.getContext(), I, init ? init : filler);
+ Expr *init = Record.readSubExpr();
+ E->updateInit(Record.getContext(), I, init ? init : filler);
}
} else {
for (unsigned I = 0; I != NumInits; ++I)
- E->updateInit(Reader.getContext(), I, Reader.ReadSubExpr());
+ E->updateInit(Record.getContext(), I, Record.readSubExpr());
}
}
@@ -775,22 +756,20 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
typedef DesignatedInitExpr::Designator Designator;
VisitExpr(E);
- unsigned NumSubExprs = Record[Idx++];
+ unsigned NumSubExprs = Record.readInt();
assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
for (unsigned I = 0; I != NumSubExprs; ++I)
- E->setSubExpr(I, Reader.ReadSubExpr());
- E->setEqualOrColonLoc(ReadSourceLocation(Record, Idx));
- E->setGNUSyntax(Record[Idx++]);
+ E->setSubExpr(I, Record.readSubExpr());
+ E->setEqualOrColonLoc(ReadSourceLocation());
+ E->setGNUSyntax(Record.readInt());
SmallVector<Designator, 4> Designators;
- while (Idx < Record.size()) {
- switch ((DesignatorTypes)Record[Idx++]) {
+ while (Record.getIdx() < Record.size()) {
+ switch ((DesignatorTypes)Record.readInt()) {
case DESIG_FIELD_DECL: {
- FieldDecl *Field = ReadDeclAs<FieldDecl>(Record, Idx);
- SourceLocation DotLoc
- = ReadSourceLocation(Record, Idx);
- SourceLocation FieldLoc
- = ReadSourceLocation(Record, Idx);
+ FieldDecl *Field = ReadDeclAs<FieldDecl>();
+ SourceLocation DotLoc = ReadSourceLocation();
+ SourceLocation FieldLoc = ReadSourceLocation();
Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
FieldLoc));
Designators.back().setField(Field);
@@ -798,162 +777,165 @@ void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
}
case DESIG_FIELD_NAME: {
- const IdentifierInfo *Name = Reader.GetIdentifierInfo(F, Record, Idx);
- SourceLocation DotLoc
- = ReadSourceLocation(Record, Idx);
- SourceLocation FieldLoc
- = ReadSourceLocation(Record, Idx);
+ const IdentifierInfo *Name = Record.getIdentifierInfo();
+ SourceLocation DotLoc = ReadSourceLocation();
+ SourceLocation FieldLoc = ReadSourceLocation();
Designators.push_back(Designator(Name, DotLoc, FieldLoc));
break;
}
case DESIG_ARRAY: {
- unsigned Index = Record[Idx++];
- SourceLocation LBracketLoc
- = ReadSourceLocation(Record, Idx);
- SourceLocation RBracketLoc
- = ReadSourceLocation(Record, Idx);
+ unsigned Index = Record.readInt();
+ SourceLocation LBracketLoc = ReadSourceLocation();
+ SourceLocation RBracketLoc = ReadSourceLocation();
Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
break;
}
case DESIG_ARRAY_RANGE: {
- unsigned Index = Record[Idx++];
- SourceLocation LBracketLoc
- = ReadSourceLocation(Record, Idx);
- SourceLocation EllipsisLoc
- = ReadSourceLocation(Record, Idx);
- SourceLocation RBracketLoc
- = ReadSourceLocation(Record, Idx);
+ unsigned Index = Record.readInt();
+ SourceLocation LBracketLoc = ReadSourceLocation();
+ SourceLocation EllipsisLoc = ReadSourceLocation();
+ SourceLocation RBracketLoc = ReadSourceLocation();
Designators.push_back(Designator(Index, LBracketLoc, EllipsisLoc,
RBracketLoc));
break;
}
}
}
- E->setDesignators(Reader.getContext(),
+ E->setDesignators(Record.getContext(),
Designators.data(), Designators.size());
}
void ASTStmtReader::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadSubExpr());
- E->setUpdater(Reader.ReadSubExpr());
+ E->setBase(Record.readSubExpr());
+ E->setUpdater(Record.readSubExpr());
}
void ASTStmtReader::VisitNoInitExpr(NoInitExpr *E) {
VisitExpr(E);
}
+void ASTStmtReader::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
+ VisitExpr(E);
+ E->SubExprs[0] = Record.readSubExpr();
+ E->SubExprs[1] = Record.readSubExpr();
+}
+
+void ASTStmtReader::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
+ VisitExpr(E);
+}
+
void ASTStmtReader::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
VisitExpr(E);
}
void ASTStmtReader::VisitVAArgExpr(VAArgExpr *E) {
VisitExpr(E);
- E->setSubExpr(Reader.ReadSubExpr());
- E->setWrittenTypeInfo(GetTypeSourceInfo(Record, Idx));
- E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
- E->setIsMicrosoftABI(Record[Idx++]);
+ E->setSubExpr(Record.readSubExpr());
+ E->setWrittenTypeInfo(GetTypeSourceInfo());
+ E->setBuiltinLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
+ E->setIsMicrosoftABI(Record.readInt());
}
void ASTStmtReader::VisitAddrLabelExpr(AddrLabelExpr *E) {
VisitExpr(E);
- E->setAmpAmpLoc(ReadSourceLocation(Record, Idx));
- E->setLabelLoc(ReadSourceLocation(Record, Idx));
- E->setLabel(ReadDeclAs<LabelDecl>(Record, Idx));
+ E->setAmpAmpLoc(ReadSourceLocation());
+ E->setLabelLoc(ReadSourceLocation());
+ E->setLabel(ReadDeclAs<LabelDecl>());
}
void ASTStmtReader::VisitStmtExpr(StmtExpr *E) {
VisitExpr(E);
- E->setLParenLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
- E->setSubStmt(cast_or_null<CompoundStmt>(Reader.ReadSubStmt()));
+ E->setLParenLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
+ E->setSubStmt(cast_or_null<CompoundStmt>(Record.readSubStmt()));
}
void ASTStmtReader::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
- E->setCond(Reader.ReadSubExpr());
- E->setLHS(Reader.ReadSubExpr());
- E->setRHS(Reader.ReadSubExpr());
- E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
- E->setIsConditionTrue(Record[Idx++]);
+ E->setCond(Record.readSubExpr());
+ E->setLHS(Record.readSubExpr());
+ E->setRHS(Record.readSubExpr());
+ E->setBuiltinLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
+ E->setIsConditionTrue(Record.readInt());
}
void ASTStmtReader::VisitGNUNullExpr(GNUNullExpr *E) {
VisitExpr(E);
- E->setTokenLocation(ReadSourceLocation(Record, Idx));
+ E->setTokenLocation(ReadSourceLocation());
}
void ASTStmtReader::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
VisitExpr(E);
SmallVector<Expr *, 16> Exprs;
- unsigned NumExprs = Record[Idx++];
+ unsigned NumExprs = Record.readInt();
while (NumExprs--)
- Exprs.push_back(Reader.ReadSubExpr());
- E->setExprs(Reader.getContext(), Exprs);
- E->setBuiltinLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ Exprs.push_back(Record.readSubExpr());
+ E->setExprs(Record.getContext(), Exprs);
+ E->setBuiltinLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitConvertVectorExpr(ConvertVectorExpr *E) {
VisitExpr(E);
- E->BuiltinLoc = ReadSourceLocation(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
- E->TInfo = GetTypeSourceInfo(Record, Idx);
- E->SrcExpr = Reader.ReadSubExpr();
+ E->BuiltinLoc = ReadSourceLocation();
+ E->RParenLoc = ReadSourceLocation();
+ E->TInfo = GetTypeSourceInfo();
+ E->SrcExpr = Record.readSubExpr();
}
void ASTStmtReader::VisitBlockExpr(BlockExpr *E) {
VisitExpr(E);
- E->setBlockDecl(ReadDeclAs<BlockDecl>(Record, Idx));
+ E->setBlockDecl(ReadDeclAs<BlockDecl>());
}
void ASTStmtReader::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
VisitExpr(E);
- E->NumAssocs = Record[Idx++];
- E->AssocTypes = new (Reader.getContext()) TypeSourceInfo*[E->NumAssocs];
+ E->NumAssocs = Record.readInt();
+ E->AssocTypes = new (Record.getContext()) TypeSourceInfo*[E->NumAssocs];
E->SubExprs =
- new(Reader.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
+ new(Record.getContext()) Stmt*[GenericSelectionExpr::END_EXPR+E->NumAssocs];
- E->SubExprs[GenericSelectionExpr::CONTROLLING] = Reader.ReadSubExpr();
+ E->SubExprs[GenericSelectionExpr::CONTROLLING] = Record.readSubExpr();
for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
- E->AssocTypes[I] = GetTypeSourceInfo(Record, Idx);
- E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Reader.ReadSubExpr();
+ E->AssocTypes[I] = GetTypeSourceInfo();
+ E->SubExprs[GenericSelectionExpr::END_EXPR+I] = Record.readSubExpr();
}
- E->ResultIndex = Record[Idx++];
+ E->ResultIndex = Record.readInt();
- E->GenericLoc = ReadSourceLocation(Record, Idx);
- E->DefaultLoc = ReadSourceLocation(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
+ E->GenericLoc = ReadSourceLocation();
+ E->DefaultLoc = ReadSourceLocation();
+ E->RParenLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
VisitExpr(E);
- unsigned numSemanticExprs = Record[Idx++];
+ unsigned numSemanticExprs = Record.readInt();
assert(numSemanticExprs + 1 == E->PseudoObjectExprBits.NumSubExprs);
- E->PseudoObjectExprBits.ResultIndex = Record[Idx++];
+ E->PseudoObjectExprBits.ResultIndex = Record.readInt();
// Read the syntactic expression.
- E->getSubExprsBuffer()[0] = Reader.ReadSubExpr();
+ E->getSubExprsBuffer()[0] = Record.readSubExpr();
// Read all the semantic expressions.
for (unsigned i = 0; i != numSemanticExprs; ++i) {
- Expr *subExpr = Reader.ReadSubExpr();
+ Expr *subExpr = Record.readSubExpr();
E->getSubExprsBuffer()[i+1] = subExpr;
}
}
void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
VisitExpr(E);
- E->Op = AtomicExpr::AtomicOp(Record[Idx++]);
+ E->Op = AtomicExpr::AtomicOp(Record.readInt());
E->NumSubExprs = AtomicExpr::getNumSubExprs(E->Op);
for (unsigned I = 0; I != E->NumSubExprs; ++I)
- E->SubExprs[I] = Reader.ReadSubExpr();
- E->BuiltinLoc = ReadSourceLocation(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
+ E->SubExprs[I] = Record.readSubExpr();
+ E->BuiltinLoc = ReadSourceLocation();
+ E->RParenLoc = ReadSourceLocation();
}
//===----------------------------------------------------------------------===//
@@ -961,142 +943,141 @@ void ASTStmtReader::VisitAtomicExpr(AtomicExpr *E) {
void ASTStmtReader::VisitObjCStringLiteral(ObjCStringLiteral *E) {
VisitExpr(E);
- E->setString(cast<StringLiteral>(Reader.ReadSubStmt()));
- E->setAtLoc(ReadSourceLocation(Record, Idx));
+ E->setString(cast<StringLiteral>(Record.readSubStmt()));
+ E->setAtLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
VisitExpr(E);
// could be one of several IntegerLiteral, FloatLiteral, etc.
- E->SubExpr = Reader.ReadSubStmt();
- E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
- E->Range = ReadSourceRange(Record, Idx);
+ E->SubExpr = Record.readSubStmt();
+ E->BoxingMethod = ReadDeclAs<ObjCMethodDecl>();
+ E->Range = ReadSourceRange();
}
void ASTStmtReader::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
VisitExpr(E);
- unsigned NumElements = Record[Idx++];
+ unsigned NumElements = Record.readInt();
assert(NumElements == E->getNumElements() && "Wrong number of elements");
Expr **Elements = E->getElements();
for (unsigned I = 0, N = NumElements; I != N; ++I)
- Elements[I] = Reader.ReadSubExpr();
- E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
- E->Range = ReadSourceRange(Record, Idx);
+ Elements[I] = Record.readSubExpr();
+ E->ArrayWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
+ E->Range = ReadSourceRange();
}
void ASTStmtReader::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
VisitExpr(E);
- unsigned NumElements = Record[Idx++];
+ unsigned NumElements = Record.readInt();
assert(NumElements == E->getNumElements() && "Wrong number of elements");
- bool HasPackExpansions = Record[Idx++];
+ bool HasPackExpansions = Record.readInt();
assert(HasPackExpansions == E->HasPackExpansions &&"Pack expansion mismatch");
ObjCDictionaryLiteral::KeyValuePair *KeyValues =
E->getTrailingObjects<ObjCDictionaryLiteral::KeyValuePair>();
ObjCDictionaryLiteral::ExpansionData *Expansions =
E->getTrailingObjects<ObjCDictionaryLiteral::ExpansionData>();
for (unsigned I = 0; I != NumElements; ++I) {
- KeyValues[I].Key = Reader.ReadSubExpr();
- KeyValues[I].Value = Reader.ReadSubExpr();
+ KeyValues[I].Key = Record.readSubExpr();
+ KeyValues[I].Value = Record.readSubExpr();
if (HasPackExpansions) {
- Expansions[I].EllipsisLoc = ReadSourceLocation(Record, Idx);
- Expansions[I].NumExpansionsPlusOne = Record[Idx++];
+ Expansions[I].EllipsisLoc = ReadSourceLocation();
+ Expansions[I].NumExpansionsPlusOne = Record.readInt();
}
}
- E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
- E->Range = ReadSourceRange(Record, Idx);
+ E->DictWithObjectsMethod = ReadDeclAs<ObjCMethodDecl>();
+ E->Range = ReadSourceRange();
}
void ASTStmtReader::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
VisitExpr(E);
- E->setEncodedTypeSourceInfo(GetTypeSourceInfo(Record, Idx));
- E->setAtLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->setEncodedTypeSourceInfo(GetTypeSourceInfo());
+ E->setAtLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
VisitExpr(E);
- E->setSelector(Reader.ReadSelector(F, Record, Idx));
- E->setAtLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->setSelector(Record.readSelector());
+ E->setAtLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
VisitExpr(E);
- E->setProtocol(ReadDeclAs<ObjCProtocolDecl>(Record, Idx));
- E->setAtLoc(ReadSourceLocation(Record, Idx));
- E->ProtoLoc = ReadSourceLocation(Record, Idx);
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->setProtocol(ReadDeclAs<ObjCProtocolDecl>());
+ E->setAtLoc(ReadSourceLocation());
+ E->ProtoLoc = ReadSourceLocation();
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
VisitExpr(E);
- E->setDecl(ReadDeclAs<ObjCIvarDecl>(Record, Idx));
- E->setLocation(ReadSourceLocation(Record, Idx));
- E->setOpLoc(ReadSourceLocation(Record, Idx));
- E->setBase(Reader.ReadSubExpr());
- E->setIsArrow(Record[Idx++]);
- E->setIsFreeIvar(Record[Idx++]);
+ E->setDecl(ReadDeclAs<ObjCIvarDecl>());
+ E->setLocation(ReadSourceLocation());
+ E->setOpLoc(ReadSourceLocation());
+ E->setBase(Record.readSubExpr());
+ E->setIsArrow(Record.readInt());
+ E->setIsFreeIvar(Record.readInt());
}
void ASTStmtReader::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
VisitExpr(E);
- unsigned MethodRefFlags = Record[Idx++];
- bool Implicit = Record[Idx++] != 0;
+ unsigned MethodRefFlags = Record.readInt();
+ bool Implicit = Record.readInt() != 0;
if (Implicit) {
- ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
- ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
+ ObjCMethodDecl *Getter = ReadDeclAs<ObjCMethodDecl>();
+ ObjCMethodDecl *Setter = ReadDeclAs<ObjCMethodDecl>();
E->setImplicitProperty(Getter, Setter, MethodRefFlags);
} else {
- E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(Record, Idx),
- MethodRefFlags);
+ E->setExplicitProperty(ReadDeclAs<ObjCPropertyDecl>(), MethodRefFlags);
}
- E->setLocation(ReadSourceLocation(Record, Idx));
- E->setReceiverLocation(ReadSourceLocation(Record, Idx));
- switch (Record[Idx++]) {
+ E->setLocation(ReadSourceLocation());
+ E->setReceiverLocation(ReadSourceLocation());
+ switch (Record.readInt()) {
case 0:
- E->setBase(Reader.ReadSubExpr());
+ E->setBase(Record.readSubExpr());
break;
case 1:
- E->setSuperReceiver(Reader.readType(F, Record, Idx));
+ E->setSuperReceiver(Record.readType());
break;
case 2:
- E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>(Record, Idx));
+ E->setClassReceiver(ReadDeclAs<ObjCInterfaceDecl>());
break;
}
}
void ASTStmtReader::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
VisitExpr(E);
- E->setRBracket(ReadSourceLocation(Record, Idx));
- E->setBaseExpr(Reader.ReadSubExpr());
- E->setKeyExpr(Reader.ReadSubExpr());
- E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
- E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>(Record, Idx);
+ E->setRBracket(ReadSourceLocation());
+ E->setBaseExpr(Record.readSubExpr());
+ E->setKeyExpr(Record.readSubExpr());
+ E->GetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
+ E->SetAtIndexMethodDecl = ReadDeclAs<ObjCMethodDecl>();
}
void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
VisitExpr(E);
- assert(Record[Idx] == E->getNumArgs());
- ++Idx;
- unsigned NumStoredSelLocs = Record[Idx++];
- E->SelLocsKind = Record[Idx++];
- E->setDelegateInitCall(Record[Idx++]);
- E->IsImplicit = Record[Idx++];
+ assert(Record.peekInt() == E->getNumArgs());
+ Record.skipInts(1);
+ unsigned NumStoredSelLocs = Record.readInt();
+ E->SelLocsKind = Record.readInt();
+ E->setDelegateInitCall(Record.readInt());
+ E->IsImplicit = Record.readInt();
ObjCMessageExpr::ReceiverKind Kind
- = static_cast<ObjCMessageExpr::ReceiverKind>(Record[Idx++]);
+ = static_cast<ObjCMessageExpr::ReceiverKind>(Record.readInt());
switch (Kind) {
case ObjCMessageExpr::Instance:
- E->setInstanceReceiver(Reader.ReadSubExpr());
+ E->setInstanceReceiver(Record.readSubExpr());
break;
case ObjCMessageExpr::Class:
- E->setClassReceiver(GetTypeSourceInfo(Record, Idx));
+ E->setClassReceiver(GetTypeSourceInfo());
break;
case ObjCMessageExpr::SuperClass:
case ObjCMessageExpr::SuperInstance: {
- QualType T = Reader.readType(F, Record, Idx);
- SourceLocation SuperLoc = ReadSourceLocation(Record, Idx);
+ QualType T = Record.readType();
+ SourceLocation SuperLoc = ReadSourceLocation();
E->setSuper(SuperLoc, T, Kind == ObjCMessageExpr::SuperInstance);
break;
}
@@ -1104,90 +1085,90 @@ void ASTStmtReader::VisitObjCMessageExpr(ObjCMessageExpr *E) {
assert(Kind == E->getReceiverKind());
- if (Record[Idx++])
- E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>(Record, Idx));
+ if (Record.readInt())
+ E->setMethodDecl(ReadDeclAs<ObjCMethodDecl>());
else
- E->setSelector(Reader.ReadSelector(F, Record, Idx));
+ E->setSelector(Record.readSelector());
- E->LBracLoc = ReadSourceLocation(Record, Idx);
- E->RBracLoc = ReadSourceLocation(Record, Idx);
+ E->LBracLoc = ReadSourceLocation();
+ E->RBracLoc = ReadSourceLocation();
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, Reader.ReadSubExpr());
+ E->setArg(I, Record.readSubExpr());
SourceLocation *Locs = E->getStoredSelLocs();
for (unsigned I = 0; I != NumStoredSelLocs; ++I)
- Locs[I] = ReadSourceLocation(Record, Idx);
+ Locs[I] = ReadSourceLocation();
}
void ASTStmtReader::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
VisitStmt(S);
- S->setElement(Reader.ReadSubStmt());
- S->setCollection(Reader.ReadSubExpr());
- S->setBody(Reader.ReadSubStmt());
- S->setForLoc(ReadSourceLocation(Record, Idx));
- S->setRParenLoc(ReadSourceLocation(Record, Idx));
+ S->setElement(Record.readSubStmt());
+ S->setCollection(Record.readSubExpr());
+ S->setBody(Record.readSubStmt());
+ S->setForLoc(ReadSourceLocation());
+ S->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
VisitStmt(S);
- S->setCatchBody(Reader.ReadSubStmt());
- S->setCatchParamDecl(ReadDeclAs<VarDecl>(Record, Idx));
- S->setAtCatchLoc(ReadSourceLocation(Record, Idx));
- S->setRParenLoc(ReadSourceLocation(Record, Idx));
+ S->setCatchBody(Record.readSubStmt());
+ S->setCatchParamDecl(ReadDeclAs<VarDecl>());
+ S->setAtCatchLoc(ReadSourceLocation());
+ S->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
VisitStmt(S);
- S->setFinallyBody(Reader.ReadSubStmt());
- S->setAtFinallyLoc(ReadSourceLocation(Record, Idx));
+ S->setFinallyBody(Record.readSubStmt());
+ S->setAtFinallyLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
VisitStmt(S);
- S->setSubStmt(Reader.ReadSubStmt());
- S->setAtLoc(ReadSourceLocation(Record, Idx));
+ S->setSubStmt(Record.readSubStmt());
+ S->setAtLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
VisitStmt(S);
- assert(Record[Idx] == S->getNumCatchStmts());
- ++Idx;
- bool HasFinally = Record[Idx++];
- S->setTryBody(Reader.ReadSubStmt());
+ assert(Record.peekInt() == S->getNumCatchStmts());
+ Record.skipInts(1);
+ bool HasFinally = Record.readInt();
+ S->setTryBody(Record.readSubStmt());
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
- S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Reader.ReadSubStmt()));
+ S->setCatchStmt(I, cast_or_null<ObjCAtCatchStmt>(Record.readSubStmt()));
if (HasFinally)
- S->setFinallyStmt(Reader.ReadSubStmt());
- S->setAtTryLoc(ReadSourceLocation(Record, Idx));
+ S->setFinallyStmt(Record.readSubStmt());
+ S->setAtTryLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
VisitStmt(S);
- S->setSynchExpr(Reader.ReadSubStmt());
- S->setSynchBody(Reader.ReadSubStmt());
- S->setAtSynchronizedLoc(ReadSourceLocation(Record, Idx));
+ S->setSynchExpr(Record.readSubStmt());
+ S->setSynchBody(Record.readSubStmt());
+ S->setAtSynchronizedLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
VisitStmt(S);
- S->setThrowExpr(Reader.ReadSubStmt());
- S->setThrowLoc(ReadSourceLocation(Record, Idx));
+ S->setThrowExpr(Record.readSubStmt());
+ S->setThrowLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
VisitExpr(E);
- E->setValue(Record[Idx++]);
- E->setLocation(ReadSourceLocation(Record, Idx));
+ E->setValue(Record.readInt());
+ E->setLocation(ReadSourceLocation());
}
void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
VisitExpr(E);
- SourceRange R = Reader.ReadSourceRange(F, Record, Idx);
+ SourceRange R = Record.readSourceRange();
E->AtLoc = R.getBegin();
E->RParen = R.getEnd();
- E->VersionToCheck = Reader.ReadVersionTuple(Record, Idx);
+ E->VersionToCheck = Record.readVersionTuple();
}
//===----------------------------------------------------------------------===//
@@ -1196,125 +1177,113 @@ void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E)
void ASTStmtReader::VisitCXXCatchStmt(CXXCatchStmt *S) {
VisitStmt(S);
- S->CatchLoc = ReadSourceLocation(Record, Idx);
- S->ExceptionDecl = ReadDeclAs<VarDecl>(Record, Idx);
- S->HandlerBlock = Reader.ReadSubStmt();
+ S->CatchLoc = ReadSourceLocation();
+ S->ExceptionDecl = ReadDeclAs<VarDecl>();
+ S->HandlerBlock = Record.readSubStmt();
}
void ASTStmtReader::VisitCXXTryStmt(CXXTryStmt *S) {
VisitStmt(S);
- assert(Record[Idx] == S->getNumHandlers() && "NumStmtFields is wrong ?");
- ++Idx;
- S->TryLoc = ReadSourceLocation(Record, Idx);
- S->getStmts()[0] = Reader.ReadSubStmt();
+ assert(Record.peekInt() == S->getNumHandlers() && "NumStmtFields is wrong ?");
+ Record.skipInts(1);
+ S->TryLoc = ReadSourceLocation();
+ S->getStmts()[0] = Record.readSubStmt();
for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
- S->getStmts()[i + 1] = Reader.ReadSubStmt();
+ S->getStmts()[i + 1] = Record.readSubStmt();
}
void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
VisitStmt(S);
- S->ForLoc = ReadSourceLocation(Record, Idx);
- S->CoawaitLoc = ReadSourceLocation(Record, Idx);
- S->ColonLoc = ReadSourceLocation(Record, Idx);
- S->RParenLoc = ReadSourceLocation(Record, Idx);
- S->setRangeStmt(Reader.ReadSubStmt());
- S->setBeginStmt(Reader.ReadSubStmt());
- S->setEndStmt(Reader.ReadSubStmt());
- S->setCond(Reader.ReadSubExpr());
- S->setInc(Reader.ReadSubExpr());
- S->setLoopVarStmt(Reader.ReadSubStmt());
- S->setBody(Reader.ReadSubStmt());
+ S->ForLoc = ReadSourceLocation();
+ S->CoawaitLoc = ReadSourceLocation();
+ S->ColonLoc = ReadSourceLocation();
+ S->RParenLoc = ReadSourceLocation();
+ S->setRangeStmt(Record.readSubStmt());
+ S->setBeginStmt(Record.readSubStmt());
+ S->setEndStmt(Record.readSubStmt());
+ S->setCond(Record.readSubExpr());
+ S->setInc(Record.readSubExpr());
+ S->setLoopVarStmt(Record.readSubStmt());
+ S->setBody(Record.readSubStmt());
}
void ASTStmtReader::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
VisitStmt(S);
- S->KeywordLoc = ReadSourceLocation(Record, Idx);
- S->IsIfExists = Record[Idx++];
- S->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- ReadDeclarationNameInfo(S->NameInfo, Record, Idx);
- S->SubStmt = Reader.ReadSubStmt();
+ S->KeywordLoc = ReadSourceLocation();
+ S->IsIfExists = Record.readInt();
+ S->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ ReadDeclarationNameInfo(S->NameInfo);
+ S->SubStmt = Record.readSubStmt();
}
void ASTStmtReader::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
VisitCallExpr(E);
- E->Operator = (OverloadedOperatorKind)Record[Idx++];
- E->Range = Reader.ReadSourceRange(F, Record, Idx);
- E->setFPContractable((bool)Record[Idx++]);
+ E->Operator = (OverloadedOperatorKind)Record.readInt();
+ E->Range = Record.readSourceRange();
+ E->setFPContractable((bool)Record.readInt());
}
void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
VisitExpr(E);
- E->NumArgs = Record[Idx++];
+ E->NumArgs = Record.readInt();
if (E->NumArgs)
- E->Args = new (Reader.getContext()) Stmt*[E->NumArgs];
+ E->Args = new (Record.getContext()) Stmt*[E->NumArgs];
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- E->setArg(I, Reader.ReadSubExpr());
- E->setConstructor(ReadDeclAs<CXXConstructorDecl>(Record, Idx));
- E->setLocation(ReadSourceLocation(Record, Idx));
- E->setElidable(Record[Idx++]);
- E->setHadMultipleCandidates(Record[Idx++]);
- E->setListInitialization(Record[Idx++]);
- E->setStdInitListInitialization(Record[Idx++]);
- E->setRequiresZeroInitialization(Record[Idx++]);
- E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record[Idx++]);
- E->ParenOrBraceRange = ReadSourceRange(Record, Idx);
+ E->setArg(I, Record.readSubExpr());
+ E->setConstructor(ReadDeclAs<CXXConstructorDecl>());
+ E->setLocation(ReadSourceLocation());
+ E->setElidable(Record.readInt());
+ E->setHadMultipleCandidates(Record.readInt());
+ E->setListInitialization(Record.readInt());
+ E->setStdInitListInitialization(Record.readInt());
+ E->setRequiresZeroInitialization(Record.readInt());
+ E->setConstructionKind((CXXConstructExpr::ConstructionKind)Record.readInt());
+ E->ParenOrBraceRange = ReadSourceRange();
}
void ASTStmtReader::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
VisitExpr(E);
- E->Constructor = ReadDeclAs<CXXConstructorDecl>(Record, Idx);
- E->Loc = ReadSourceLocation(Record, Idx);
- E->ConstructsVirtualBase = Record[Idx++];
- E->InheritedFromVirtualBase = Record[Idx++];
+ E->Constructor = ReadDeclAs<CXXConstructorDecl>();
+ E->Loc = ReadSourceLocation();
+ E->ConstructsVirtualBase = Record.readInt();
+ E->InheritedFromVirtualBase = Record.readInt();
}
void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
VisitCXXConstructExpr(E);
- E->Type = GetTypeSourceInfo(Record, Idx);
+ E->Type = GetTypeSourceInfo();
}
void ASTStmtReader::VisitLambdaExpr(LambdaExpr *E) {
VisitExpr(E);
- unsigned NumCaptures = Record[Idx++];
+ unsigned NumCaptures = Record.readInt();
assert(NumCaptures == E->NumCaptures);(void)NumCaptures;
- unsigned NumArrayIndexVars = Record[Idx++];
- E->IntroducerRange = ReadSourceRange(Record, Idx);
- E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record[Idx++]);
- E->CaptureDefaultLoc = ReadSourceLocation(Record, Idx);
- E->ExplicitParams = Record[Idx++];
- E->ExplicitResultType = Record[Idx++];
- E->ClosingBrace = ReadSourceLocation(Record, Idx);
-
+ E->IntroducerRange = ReadSourceRange();
+ E->CaptureDefault = static_cast<LambdaCaptureDefault>(Record.readInt());
+ E->CaptureDefaultLoc = ReadSourceLocation();
+ E->ExplicitParams = Record.readInt();
+ E->ExplicitResultType = Record.readInt();
+ E->ClosingBrace = ReadSourceLocation();
+
// Read capture initializers.
for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
CEnd = E->capture_init_end();
C != CEnd; ++C)
- *C = Reader.ReadSubExpr();
-
- // Read array capture index variables.
- if (NumArrayIndexVars > 0) {
- unsigned *ArrayIndexStarts = E->getArrayIndexStarts();
- for (unsigned I = 0; I != NumCaptures + 1; ++I)
- ArrayIndexStarts[I] = Record[Idx++];
-
- VarDecl **ArrayIndexVars = E->getArrayIndexVars();
- for (unsigned I = 0; I != NumArrayIndexVars; ++I)
- ArrayIndexVars[I] = ReadDeclAs<VarDecl>(Record, Idx);
- }
+ *C = Record.readSubExpr();
}
void
ASTStmtReader::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
VisitExpr(E);
- E->SubExpr = Reader.ReadSubExpr();
+ E->SubExpr = Record.readSubExpr();
}
void ASTStmtReader::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
VisitExplicitCastExpr(E);
- SourceRange R = ReadSourceRange(Record, Idx);
+ SourceRange R = ReadSourceRange();
E->Loc = R.getBegin();
E->RParenLoc = R.getEnd();
- R = ReadSourceRange(Record, Idx);
+ R = ReadSourceRange();
E->AngleBrackets = R;
}
@@ -1336,342 +1305,345 @@ void ASTStmtReader::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
void ASTStmtReader::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
VisitExplicitCastExpr(E);
- E->setLParenLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->setLParenLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
VisitCallExpr(E);
- E->UDSuffixLoc = ReadSourceLocation(Record, Idx);
+ E->UDSuffixLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
VisitExpr(E);
- E->setValue(Record[Idx++]);
- E->setLocation(ReadSourceLocation(Record, Idx));
+ E->setValue(Record.readInt());
+ E->setLocation(ReadSourceLocation());
}
void ASTStmtReader::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
VisitExpr(E);
- E->setLocation(ReadSourceLocation(Record, Idx));
+ E->setLocation(ReadSourceLocation());
}
void ASTStmtReader::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
VisitExpr(E);
- E->setSourceRange(ReadSourceRange(Record, Idx));
+ E->setSourceRange(ReadSourceRange());
if (E->isTypeOperand()) { // typeid(int)
E->setTypeOperandSourceInfo(
- GetTypeSourceInfo(Record, Idx));
+ GetTypeSourceInfo());
return;
}
-
+
// typeid(42+2)
- E->setExprOperand(Reader.ReadSubExpr());
+ E->setExprOperand(Record.readSubExpr());
}
void ASTStmtReader::VisitCXXThisExpr(CXXThisExpr *E) {
VisitExpr(E);
- E->setLocation(ReadSourceLocation(Record, Idx));
- E->setImplicit(Record[Idx++]);
+ E->setLocation(ReadSourceLocation());
+ E->setImplicit(Record.readInt());
}
void ASTStmtReader::VisitCXXThrowExpr(CXXThrowExpr *E) {
VisitExpr(E);
- E->ThrowLoc = ReadSourceLocation(Record, Idx);
- E->Op = Reader.ReadSubExpr();
- E->IsThrownVariableInScope = Record[Idx++];
+ E->ThrowLoc = ReadSourceLocation();
+ E->Op = Record.readSubExpr();
+ E->IsThrownVariableInScope = Record.readInt();
}
void ASTStmtReader::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
VisitExpr(E);
- E->Param = ReadDeclAs<ParmVarDecl>(Record, Idx);
- E->Loc = ReadSourceLocation(Record, Idx);
+ E->Param = ReadDeclAs<ParmVarDecl>();
+ E->Loc = ReadSourceLocation();
}
void ASTStmtReader::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
VisitExpr(E);
- E->Field = ReadDeclAs<FieldDecl>(Record, Idx);
- E->Loc = ReadSourceLocation(Record, Idx);
+ E->Field = ReadDeclAs<FieldDecl>();
+ E->Loc = ReadSourceLocation();
}
void ASTStmtReader::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
VisitExpr(E);
- E->setTemporary(Reader.ReadCXXTemporary(F, Record, Idx));
- E->setSubExpr(Reader.ReadSubExpr());
+ E->setTemporary(Record.readCXXTemporary());
+ E->setSubExpr(Record.readSubExpr());
}
void ASTStmtReader::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
VisitExpr(E);
- E->TypeInfo = GetTypeSourceInfo(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
+ E->TypeInfo = GetTypeSourceInfo();
+ E->RParenLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitCXXNewExpr(CXXNewExpr *E) {
VisitExpr(E);
- E->GlobalNew = Record[Idx++];
- bool isArray = Record[Idx++];
- E->UsualArrayDeleteWantsSize = Record[Idx++];
- unsigned NumPlacementArgs = Record[Idx++];
- E->StoredInitializationStyle = Record[Idx++];
- E->setOperatorNew(ReadDeclAs<FunctionDecl>(Record, Idx));
- E->setOperatorDelete(ReadDeclAs<FunctionDecl>(Record, Idx));
- E->AllocatedTypeInfo = GetTypeSourceInfo(Record, Idx);
- E->TypeIdParens = ReadSourceRange(Record, Idx);
- E->Range = ReadSourceRange(Record, Idx);
- E->DirectInitRange = ReadSourceRange(Record, Idx);
-
- E->AllocateArgsArray(Reader.getContext(), isArray, NumPlacementArgs,
+ E->GlobalNew = Record.readInt();
+ bool isArray = Record.readInt();
+ E->PassAlignment = Record.readInt();
+ E->UsualArrayDeleteWantsSize = Record.readInt();
+ unsigned NumPlacementArgs = Record.readInt();
+ E->StoredInitializationStyle = Record.readInt();
+ E->setOperatorNew(ReadDeclAs<FunctionDecl>());
+ E->setOperatorDelete(ReadDeclAs<FunctionDecl>());
+ E->AllocatedTypeInfo = GetTypeSourceInfo();
+ E->TypeIdParens = ReadSourceRange();
+ E->Range = ReadSourceRange();
+ E->DirectInitRange = ReadSourceRange();
+
+ E->AllocateArgsArray(Record.getContext(), isArray, NumPlacementArgs,
E->StoredInitializationStyle != 0);
// Install all the subexpressions.
for (CXXNewExpr::raw_arg_iterator I = E->raw_arg_begin(),e = E->raw_arg_end();
I != e; ++I)
- *I = Reader.ReadSubStmt();
+ *I = Record.readSubStmt();
}
void ASTStmtReader::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
VisitExpr(E);
- E->GlobalDelete = Record[Idx++];
- E->ArrayForm = Record[Idx++];
- E->ArrayFormAsWritten = Record[Idx++];
- E->UsualArrayDeleteWantsSize = Record[Idx++];
- E->OperatorDelete = ReadDeclAs<FunctionDecl>(Record, Idx);
- E->Argument = Reader.ReadSubExpr();
- E->Loc = ReadSourceLocation(Record, Idx);
+ E->GlobalDelete = Record.readInt();
+ E->ArrayForm = Record.readInt();
+ E->ArrayFormAsWritten = Record.readInt();
+ E->UsualArrayDeleteWantsSize = Record.readInt();
+ E->OperatorDelete = ReadDeclAs<FunctionDecl>();
+ E->Argument = Record.readSubExpr();
+ E->Loc = ReadSourceLocation();
}
void ASTStmtReader::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
VisitExpr(E);
- E->Base = Reader.ReadSubExpr();
- E->IsArrow = Record[Idx++];
- E->OperatorLoc = ReadSourceLocation(Record, Idx);
- E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- E->ScopeType = GetTypeSourceInfo(Record, Idx);
- E->ColonColonLoc = ReadSourceLocation(Record, Idx);
- E->TildeLoc = ReadSourceLocation(Record, Idx);
-
- IdentifierInfo *II = Reader.GetIdentifierInfo(F, Record, Idx);
+ E->Base = Record.readSubExpr();
+ E->IsArrow = Record.readInt();
+ E->OperatorLoc = ReadSourceLocation();
+ E->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ E->ScopeType = GetTypeSourceInfo();
+ E->ColonColonLoc = ReadSourceLocation();
+ E->TildeLoc = ReadSourceLocation();
+
+ IdentifierInfo *II = Record.getIdentifierInfo();
if (II)
- E->setDestroyedType(II, ReadSourceLocation(Record, Idx));
+ E->setDestroyedType(II, ReadSourceLocation());
else
- E->setDestroyedType(GetTypeSourceInfo(Record, Idx));
+ E->setDestroyedType(GetTypeSourceInfo());
}
void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
VisitExpr(E);
- unsigned NumObjects = Record[Idx++];
+ unsigned NumObjects = Record.readInt();
assert(NumObjects == E->getNumObjects());
for (unsigned i = 0; i != NumObjects; ++i)
E->getTrailingObjects<BlockDecl *>()[i] =
- ReadDeclAs<BlockDecl>(Record, Idx);
+ ReadDeclAs<BlockDecl>();
- E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++];
- E->SubExpr = Reader.ReadSubExpr();
+ E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record.readInt();
+ E->SubExpr = Record.readSubExpr();
}
void
ASTStmtReader::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
VisitExpr(E);
- if (Record[Idx++]) // HasTemplateKWAndArgsInfo
+ if (Record.readInt()) // HasTemplateKWAndArgsInfo
ReadTemplateKWAndArgsInfo(
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
E->getTrailingObjects<TemplateArgumentLoc>(),
- /*NumTemplateArgs=*/Record[Idx++]);
+ /*NumTemplateArgs=*/Record.readInt());
- E->Base = Reader.ReadSubExpr();
- E->BaseType = Reader.readType(F, Record, Idx);
- E->IsArrow = Record[Idx++];
- E->OperatorLoc = ReadSourceLocation(Record, Idx);
- E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>(Record, Idx);
- ReadDeclarationNameInfo(E->MemberNameInfo, Record, Idx);
+ E->Base = Record.readSubExpr();
+ E->BaseType = Record.readType();
+ E->IsArrow = Record.readInt();
+ E->OperatorLoc = ReadSourceLocation();
+ E->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ E->FirstQualifierFoundInScope = ReadDeclAs<NamedDecl>();
+ ReadDeclarationNameInfo(E->MemberNameInfo);
}
void
ASTStmtReader::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
VisitExpr(E);
- if (Record[Idx++]) // HasTemplateKWAndArgsInfo
+ if (Record.readInt()) // HasTemplateKWAndArgsInfo
ReadTemplateKWAndArgsInfo(
*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
E->getTrailingObjects<TemplateArgumentLoc>(),
- /*NumTemplateArgs=*/Record[Idx++]);
+ /*NumTemplateArgs=*/Record.readInt());
- E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
+ E->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ ReadDeclarationNameInfo(E->NameInfo);
}
void
ASTStmtReader::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
VisitExpr(E);
- assert(Record[Idx] == E->arg_size() && "Read wrong record during creation ?");
- ++Idx; // NumArgs;
+ assert(Record.peekInt() == E->arg_size() &&
+ "Read wrong record during creation ?");
+ Record.skipInts(1);
for (unsigned I = 0, N = E->arg_size(); I != N; ++I)
- E->setArg(I, Reader.ReadSubExpr());
- E->Type = GetTypeSourceInfo(Record, Idx);
- E->setLParenLoc(ReadSourceLocation(Record, Idx));
- E->setRParenLoc(ReadSourceLocation(Record, Idx));
+ E->setArg(I, Record.readSubExpr());
+ E->Type = GetTypeSourceInfo();
+ E->setLParenLoc(ReadSourceLocation());
+ E->setRParenLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitOverloadExpr(OverloadExpr *E) {
VisitExpr(E);
- if (Record[Idx++]) // HasTemplateKWAndArgsInfo
+ if (Record.readInt()) // HasTemplateKWAndArgsInfo
ReadTemplateKWAndArgsInfo(*E->getTrailingASTTemplateKWAndArgsInfo(),
E->getTrailingTemplateArgumentLoc(),
- /*NumTemplateArgs=*/Record[Idx++]);
+ /*NumTemplateArgs=*/Record.readInt());
- unsigned NumDecls = Record[Idx++];
+ unsigned NumDecls = Record.readInt();
UnresolvedSet<8> Decls;
for (unsigned i = 0; i != NumDecls; ++i) {
- NamedDecl *D = ReadDeclAs<NamedDecl>(Record, Idx);
- AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
+ NamedDecl *D = ReadDeclAs<NamedDecl>();
+ AccessSpecifier AS = (AccessSpecifier)Record.readInt();
Decls.addDecl(D, AS);
}
- E->initializeResults(Reader.getContext(), Decls.begin(), Decls.end());
+ E->initializeResults(Record.getContext(), Decls.begin(), Decls.end());
- ReadDeclarationNameInfo(E->NameInfo, Record, Idx);
- E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
+ ReadDeclarationNameInfo(E->NameInfo);
+ E->QualifierLoc = Record.readNestedNameSpecifierLoc();
}
void ASTStmtReader::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
VisitOverloadExpr(E);
- E->IsArrow = Record[Idx++];
- E->HasUnresolvedUsing = Record[Idx++];
- E->Base = Reader.ReadSubExpr();
- E->BaseType = Reader.readType(F, Record, Idx);
- E->OperatorLoc = ReadSourceLocation(Record, Idx);
+ E->IsArrow = Record.readInt();
+ E->HasUnresolvedUsing = Record.readInt();
+ E->Base = Record.readSubExpr();
+ E->BaseType = Record.readType();
+ E->OperatorLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
VisitOverloadExpr(E);
- E->RequiresADL = Record[Idx++];
- E->Overloaded = Record[Idx++];
- E->NamingClass = ReadDeclAs<CXXRecordDecl>(Record, Idx);
+ E->RequiresADL = Record.readInt();
+ E->Overloaded = Record.readInt();
+ E->NamingClass = ReadDeclAs<CXXRecordDecl>();
}
void ASTStmtReader::VisitTypeTraitExpr(TypeTraitExpr *E) {
VisitExpr(E);
- E->TypeTraitExprBits.NumArgs = Record[Idx++];
- E->TypeTraitExprBits.Kind = Record[Idx++];
- E->TypeTraitExprBits.Value = Record[Idx++];
- SourceRange Range = ReadSourceRange(Record, Idx);
+ E->TypeTraitExprBits.NumArgs = Record.readInt();
+ E->TypeTraitExprBits.Kind = Record.readInt();
+ E->TypeTraitExprBits.Value = Record.readInt();
+ SourceRange Range = ReadSourceRange();
E->Loc = Range.getBegin();
E->RParenLoc = Range.getEnd();
TypeSourceInfo **Args = E->getTrailingObjects<TypeSourceInfo *>();
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- Args[I] = GetTypeSourceInfo(Record, Idx);
+ Args[I] = GetTypeSourceInfo();
}
void ASTStmtReader::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
VisitExpr(E);
- E->ATT = (ArrayTypeTrait)Record[Idx++];
- E->Value = (unsigned int)Record[Idx++];
- SourceRange Range = ReadSourceRange(Record, Idx);
+ E->ATT = (ArrayTypeTrait)Record.readInt();
+ E->Value = (unsigned int)Record.readInt();
+ SourceRange Range = ReadSourceRange();
E->Loc = Range.getBegin();
E->RParen = Range.getEnd();
- E->QueriedType = GetTypeSourceInfo(Record, Idx);
+ E->QueriedType = GetTypeSourceInfo();
+ E->Dimension = Record.readSubExpr();
}
void ASTStmtReader::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
VisitExpr(E);
- E->ET = (ExpressionTrait)Record[Idx++];
- E->Value = (bool)Record[Idx++];
- SourceRange Range = ReadSourceRange(Record, Idx);
- E->QueriedExpression = Reader.ReadSubExpr();
+ E->ET = (ExpressionTrait)Record.readInt();
+ E->Value = (bool)Record.readInt();
+ SourceRange Range = ReadSourceRange();
+ E->QueriedExpression = Record.readSubExpr();
E->Loc = Range.getBegin();
E->RParen = Range.getEnd();
}
void ASTStmtReader::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
VisitExpr(E);
- E->Value = (bool)Record[Idx++];
- E->Range = ReadSourceRange(Record, Idx);
- E->Operand = Reader.ReadSubExpr();
+ E->Value = (bool)Record.readInt();
+ E->Range = ReadSourceRange();
+ E->Operand = Record.readSubExpr();
}
void ASTStmtReader::VisitPackExpansionExpr(PackExpansionExpr *E) {
VisitExpr(E);
- E->EllipsisLoc = ReadSourceLocation(Record, Idx);
- E->NumExpansions = Record[Idx++];
- E->Pattern = Reader.ReadSubExpr();
+ E->EllipsisLoc = ReadSourceLocation();
+ E->NumExpansions = Record.readInt();
+ E->Pattern = Record.readSubExpr();
}
void ASTStmtReader::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
VisitExpr(E);
- unsigned NumPartialArgs = Record[Idx++];
- E->OperatorLoc = ReadSourceLocation(Record, Idx);
- E->PackLoc = ReadSourceLocation(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
- E->Pack = Reader.ReadDeclAs<NamedDecl>(F, Record, Idx);
+ unsigned NumPartialArgs = Record.readInt();
+ E->OperatorLoc = ReadSourceLocation();
+ E->PackLoc = ReadSourceLocation();
+ E->RParenLoc = ReadSourceLocation();
+ E->Pack = Record.readDeclAs<NamedDecl>();
if (E->isPartiallySubstituted()) {
assert(E->Length == NumPartialArgs);
for (auto *I = E->getTrailingObjects<TemplateArgument>(),
*E = I + NumPartialArgs;
I != E; ++I)
- new (I) TemplateArgument(Reader.ReadTemplateArgument(F, Record, Idx));
+ new (I) TemplateArgument(Record.readTemplateArgument());
} else if (!E->isValueDependent()) {
- E->Length = Record[Idx++];
+ E->Length = Record.readInt();
}
}
void ASTStmtReader::VisitSubstNonTypeTemplateParmExpr(
SubstNonTypeTemplateParmExpr *E) {
VisitExpr(E);
- E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
- E->NameLoc = ReadSourceLocation(Record, Idx);
- E->Replacement = Reader.ReadSubExpr();
+ E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
+ E->NameLoc = ReadSourceLocation();
+ E->Replacement = Record.readSubExpr();
}
void ASTStmtReader::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *E) {
VisitExpr(E);
- E->Param = ReadDeclAs<NonTypeTemplateParmDecl>(Record, Idx);
- TemplateArgument ArgPack = Reader.ReadTemplateArgument(F, Record, Idx);
+ E->Param = ReadDeclAs<NonTypeTemplateParmDecl>();
+ TemplateArgument ArgPack = Record.readTemplateArgument();
if (ArgPack.getKind() != TemplateArgument::Pack)
return;
-
+
E->Arguments = ArgPack.pack_begin();
E->NumArguments = ArgPack.pack_size();
- E->NameLoc = ReadSourceLocation(Record, Idx);
+ E->NameLoc = ReadSourceLocation();
}
void ASTStmtReader::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
VisitExpr(E);
- E->NumParameters = Record[Idx++];
- E->ParamPack = ReadDeclAs<ParmVarDecl>(Record, Idx);
- E->NameLoc = ReadSourceLocation(Record, Idx);
+ E->NumParameters = Record.readInt();
+ E->ParamPack = ReadDeclAs<ParmVarDecl>();
+ E->NameLoc = ReadSourceLocation();
ParmVarDecl **Parms = E->getTrailingObjects<ParmVarDecl *>();
for (unsigned i = 0, n = E->NumParameters; i != n; ++i)
- Parms[i] = ReadDeclAs<ParmVarDecl>(Record, Idx);
+ Parms[i] = ReadDeclAs<ParmVarDecl>();
}
void ASTStmtReader::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
VisitExpr(E);
- E->State = Reader.ReadSubExpr();
- auto VD = ReadDeclAs<ValueDecl>(Record, Idx);
- unsigned ManglingNumber = Record[Idx++];
+ E->State = Record.readSubExpr();
+ auto VD = ReadDeclAs<ValueDecl>();
+ unsigned ManglingNumber = Record.readInt();
E->setExtendingDecl(VD, ManglingNumber);
}
void ASTStmtReader::VisitCXXFoldExpr(CXXFoldExpr *E) {
VisitExpr(E);
- E->LParenLoc = ReadSourceLocation(Record, Idx);
- E->EllipsisLoc = ReadSourceLocation(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
- E->SubExprs[0] = Reader.ReadSubExpr();
- E->SubExprs[1] = Reader.ReadSubExpr();
- E->Opcode = (BinaryOperatorKind)Record[Idx++];
+ E->LParenLoc = ReadSourceLocation();
+ E->EllipsisLoc = ReadSourceLocation();
+ E->RParenLoc = ReadSourceLocation();
+ E->SubExprs[0] = Record.readSubExpr();
+ E->SubExprs[1] = Record.readSubExpr();
+ E->Opcode = (BinaryOperatorKind)Record.readInt();
}
void ASTStmtReader::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
VisitExpr(E);
- E->SourceExpr = Reader.ReadSubExpr();
- E->Loc = ReadSourceLocation(Record, Idx);
+ E->SourceExpr = Record.readSubExpr();
+ E->Loc = ReadSourceLocation();
}
void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
@@ -1683,59 +1655,59 @@ void ASTStmtReader::VisitTypoExpr(TypoExpr *E) {
//===----------------------------------------------------------------------===//
void ASTStmtReader::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
VisitExpr(E);
- E->IsArrow = (Record[Idx++] != 0);
- E->BaseExpr = Reader.ReadSubExpr();
- E->QualifierLoc = Reader.ReadNestedNameSpecifierLoc(F, Record, Idx);
- E->MemberLoc = ReadSourceLocation(Record, Idx);
- E->TheDecl = ReadDeclAs<MSPropertyDecl>(Record, Idx);
+ E->IsArrow = (Record.readInt() != 0);
+ E->BaseExpr = Record.readSubExpr();
+ E->QualifierLoc = Record.readNestedNameSpecifierLoc();
+ E->MemberLoc = ReadSourceLocation();
+ E->TheDecl = ReadDeclAs<MSPropertyDecl>();
}
void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
VisitExpr(E);
- E->setBase(Reader.ReadSubExpr());
- E->setIdx(Reader.ReadSubExpr());
- E->setRBracketLoc(ReadSourceLocation(Record, Idx));
+ E->setBase(Record.readSubExpr());
+ E->setIdx(Record.readSubExpr());
+ E->setRBracketLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
VisitExpr(E);
- E->setSourceRange(ReadSourceRange(Record, Idx));
- std::string UuidStr = ReadString(Record, Idx);
- E->setUuidStr(StringRef(UuidStr).copy(Reader.getContext()));
+ E->setSourceRange(ReadSourceRange());
+ std::string UuidStr = ReadString();
+ E->setUuidStr(StringRef(UuidStr).copy(Record.getContext()));
if (E->isTypeOperand()) { // __uuidof(ComType)
E->setTypeOperandSourceInfo(
- GetTypeSourceInfo(Record, Idx));
+ GetTypeSourceInfo());
return;
}
-
+
// __uuidof(expr)
- E->setExprOperand(Reader.ReadSubExpr());
+ E->setExprOperand(Record.readSubExpr());
}
void ASTStmtReader::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
VisitStmt(S);
- S->setLeaveLoc(ReadSourceLocation(Record, Idx));
+ S->setLeaveLoc(ReadSourceLocation());
}
void ASTStmtReader::VisitSEHExceptStmt(SEHExceptStmt *S) {
VisitStmt(S);
- S->Loc = ReadSourceLocation(Record, Idx);
- S->Children[SEHExceptStmt::FILTER_EXPR] = Reader.ReadSubStmt();
- S->Children[SEHExceptStmt::BLOCK] = Reader.ReadSubStmt();
+ S->Loc = ReadSourceLocation();
+ S->Children[SEHExceptStmt::FILTER_EXPR] = Record.readSubStmt();
+ S->Children[SEHExceptStmt::BLOCK] = Record.readSubStmt();
}
void ASTStmtReader::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
VisitStmt(S);
- S->Loc = ReadSourceLocation(Record, Idx);
- S->Block = Reader.ReadSubStmt();
+ S->Loc = ReadSourceLocation();
+ S->Block = Record.readSubStmt();
}
void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
VisitStmt(S);
- S->IsCXXTry = Record[Idx++];
- S->TryLoc = ReadSourceLocation(Record, Idx);
- S->Children[SEHTryStmt::TRY] = Reader.ReadSubStmt();
- S->Children[SEHTryStmt::HANDLER] = Reader.ReadSubStmt();
+ S->IsCXXTry = Record.readInt();
+ S->TryLoc = ReadSourceLocation();
+ S->Children[SEHTryStmt::TRY] = Record.readSubStmt();
+ S->Children[SEHTryStmt::HANDLER] = Record.readSubStmt();
}
//===----------------------------------------------------------------------===//
@@ -1744,7 +1716,7 @@ void ASTStmtReader::VisitSEHTryStmt(SEHTryStmt *S) {
void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
VisitCallExpr(E);
- E->setConfig(cast<CallExpr>(Reader.ReadSubExpr()));
+ E->setConfig(cast<CallExpr>(Record.readSubExpr()));
}
//===----------------------------------------------------------------------===//
@@ -1752,9 +1724,9 @@ void ASTStmtReader::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
//===----------------------------------------------------------------------===//
void ASTStmtReader::VisitAsTypeExpr(AsTypeExpr *E) {
VisitExpr(E);
- E->BuiltinLoc = ReadSourceLocation(Record, Idx);
- E->RParenLoc = ReadSourceLocation(Record, Idx);
- E->SrcExpr = Reader.ReadSubExpr();
+ E->BuiltinLoc = ReadSourceLocation();
+ E->RParenLoc = ReadSourceLocation();
+ E->SrcExpr = Record.readSubExpr();
}
//===----------------------------------------------------------------------===//
@@ -1765,12 +1737,9 @@ namespace clang {
class OMPClauseReader : public OMPClauseVisitor<OMPClauseReader> {
ASTStmtReader *Reader;
ASTContext &Context;
- const ASTReader::RecordData &Record;
- unsigned &Idx;
public:
- OMPClauseReader(ASTStmtReader *R, ASTContext &C,
- const ASTReader::RecordData &Record, unsigned &Idx)
- : Reader(R), Context(C), Record(Record), Idx(Idx) { }
+ OMPClauseReader(ASTStmtReader *R, ASTRecordReader &Record)
+ : Reader(R), Context(Record.getContext()) {}
#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
#include "clang/Basic/OpenMPKinds.def"
OMPClause *readClause();
@@ -1781,7 +1750,7 @@ public:
OMPClause *OMPClauseReader::readClause() {
OMPClause *C;
- switch (Record[Idx++]) {
+ switch (Reader->Record.readInt()) {
case OMPC_if:
C = new (Context) OMPIfClause();
break;
@@ -1846,46 +1815,46 @@ OMPClause *OMPClauseReader::readClause() {
C = new (Context) OMPNogroupClause();
break;
case OMPC_private:
- C = OMPPrivateClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPPrivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_firstprivate:
- C = OMPFirstprivateClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPFirstprivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_lastprivate:
- C = OMPLastprivateClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPLastprivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_shared:
- C = OMPSharedClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPSharedClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_reduction:
- C = OMPReductionClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPReductionClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_linear:
- C = OMPLinearClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPLinearClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_aligned:
- C = OMPAlignedClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPAlignedClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_copyin:
- C = OMPCopyinClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPCopyinClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_copyprivate:
- C = OMPCopyprivateClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPCopyprivateClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_flush:
- C = OMPFlushClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPFlushClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_depend:
- C = OMPDependClause::CreateEmpty(Context, Record[Idx++]);
+ C = OMPDependClause::CreateEmpty(Context, Reader->Record.readInt());
break;
case OMPC_device:
C = new (Context) OMPDeviceClause();
break;
case OMPC_map: {
- unsigned NumVars = Record[Idx++];
- unsigned NumDeclarations = Record[Idx++];
- unsigned NumLists = Record[Idx++];
- unsigned NumComponents = Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
NumComponents);
break;
@@ -1915,112 +1884,124 @@ OMPClause *OMPClauseReader::readClause() {
C = new (Context) OMPDefaultmapClause();
break;
case OMPC_to: {
- unsigned NumVars = Record[Idx++];
- unsigned NumDeclarations = Record[Idx++];
- unsigned NumLists = Record[Idx++];
- unsigned NumComponents = Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPToClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
NumComponents);
break;
}
case OMPC_from: {
- unsigned NumVars = Record[Idx++];
- unsigned NumDeclarations = Record[Idx++];
- unsigned NumLists = Record[Idx++];
- unsigned NumComponents = Record[Idx++];
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
NumComponents);
break;
}
- case OMPC_use_device_ptr:
- C = OMPUseDevicePtrClause::CreateEmpty(Context, Record[Idx++]);
+ case OMPC_use_device_ptr: {
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
+ C = OMPUseDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
+ NumLists, NumComponents);
break;
- case OMPC_is_device_ptr:
- C = OMPIsDevicePtrClause::CreateEmpty(Context, Record[Idx++]);
+ }
+ case OMPC_is_device_ptr: {
+ unsigned NumVars = Reader->Record.readInt();
+ unsigned NumDeclarations = Reader->Record.readInt();
+ unsigned NumLists = Reader->Record.readInt();
+ unsigned NumComponents = Reader->Record.readInt();
+ C = OMPIsDevicePtrClause::CreateEmpty(Context, NumVars, NumDeclarations,
+ NumLists, NumComponents);
break;
}
+ }
Visit(C);
- C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
- C->setLocEnd(Reader->ReadSourceLocation(Record, Idx));
+ C->setLocStart(Reader->ReadSourceLocation());
+ C->setLocEnd(Reader->ReadSourceLocation());
return C;
}
void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
- C->setPreInitStmt(Reader->Reader.ReadSubStmt());
+ C->setPreInitStmt(Reader->Record.readSubStmt());
}
void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
VisitOMPClauseWithPreInit(C);
- C->setPostUpdateExpr(Reader->Reader.ReadSubExpr());
+ C->setPostUpdateExpr(Reader->Record.readSubExpr());
}
void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
- C->setNameModifier(static_cast<OpenMPDirectiveKind>(Record[Idx++]));
- C->setNameModifierLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setCondition(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setNameModifier(static_cast<OpenMPDirectiveKind>(Reader->Record.readInt()));
+ C->setNameModifierLoc(Reader->ReadSourceLocation());
+ C->setColonLoc(Reader->ReadSourceLocation());
+ C->setCondition(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPFinalClause(OMPFinalClause *C) {
- C->setCondition(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setCondition(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
- C->setNumThreads(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setNumThreads(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPSafelenClause(OMPSafelenClause *C) {
- C->setSafelen(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setSafelen(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
- C->setSimdlen(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setSimdlen(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPCollapseClause(OMPCollapseClause *C) {
- C->setNumForLoops(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setNumForLoops(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPDefaultClause(OMPDefaultClause *C) {
C->setDefaultKind(
- static_cast<OpenMPDefaultClauseKind>(Record[Idx++]));
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setDefaultKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
+ static_cast<OpenMPDefaultClauseKind>(Reader->Record.readInt()));
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setDefaultKindKwLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
C->setProcBindKind(
- static_cast<OpenMPProcBindClauseKind>(Record[Idx++]));
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setProcBindKindKwLoc(Reader->ReadSourceLocation(Record, Idx));
+ static_cast<OpenMPProcBindClauseKind>(Reader->Record.readInt()));
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setProcBindKindKwLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
VisitOMPClauseWithPreInit(C);
C->setScheduleKind(
- static_cast<OpenMPScheduleClauseKind>(Record[Idx++]));
+ static_cast<OpenMPScheduleClauseKind>(Reader->Record.readInt()));
C->setFirstScheduleModifier(
- static_cast<OpenMPScheduleClauseModifier>(Record[Idx++]));
+ static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
C->setSecondScheduleModifier(
- static_cast<OpenMPScheduleClauseModifier>(Record[Idx++]));
- C->setChunkSize(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setScheduleKindLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx));
+ static_cast<OpenMPScheduleClauseModifier>(Reader->Record.readInt()));
+ C->setChunkSize(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation());
+ C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation());
+ C->setScheduleKindLoc(Reader->ReadSourceLocation());
+ C->setCommaLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPOrderedClause(OMPOrderedClause *C) {
- C->setNumForLoops(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setNumForLoops(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPNowaitClause(OMPNowaitClause *) {}
@@ -2046,83 +2027,82 @@ void OMPClauseReader::VisitOMPSIMDClause(OMPSIMDClause *) {}
void OMPClauseReader::VisitOMPNogroupClause(OMPNogroupClause *) {}
void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setPrivateCopies(Vars);
}
void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
VisitOMPClauseWithPreInit(C);
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setPrivateCopies(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setInits(Vars);
}
void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
VisitOMPClauseWithPostUpdate(C);
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setPrivateCopies(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setSourceExprs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setDestinationExprs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setAssignmentOps(Vars);
}
void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
}
void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
VisitOMPClauseWithPostUpdate(C);
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
- NestedNameSpecifierLoc NNSL =
- Reader->Reader.ReadNestedNameSpecifierLoc(Reader->F, Record, Idx);
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setColonLoc(Reader->ReadSourceLocation());
+ NestedNameSpecifierLoc NNSL = Reader->Record.readNestedNameSpecifierLoc();
DeclarationNameInfo DNI;
- Reader->ReadDeclarationNameInfo(DNI, Record, Idx);
+ Reader->ReadDeclarationNameInfo(DNI);
C->setQualifierLoc(NNSL);
C->setNameInfo(DNI);
@@ -2130,151 +2110,152 @@ void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setPrivates(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setLHSExprs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setRHSExprs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setReductionOps(Vars);
}
void OMPClauseReader::VisitOMPLinearClause(OMPLinearClause *C) {
VisitOMPClauseWithPostUpdate(C);
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setModifier(static_cast<OpenMPLinearClauseKind>(Record[Idx++]));
- C->setModifierLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setColonLoc(Reader->ReadSourceLocation());
+ C->setModifier(static_cast<OpenMPLinearClauseKind>(Reader->Record.readInt()));
+ C->setModifierLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setPrivates(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setInits(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setUpdates(Vars);
Vars.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setFinals(Vars);
- C->setStep(Reader->Reader.ReadSubExpr());
- C->setCalcStep(Reader->Reader.ReadSubExpr());
+ C->setStep(Reader->Record.readSubExpr());
+ C->setCalcStep(Reader->Record.readSubExpr());
}
void OMPClauseReader::VisitOMPAlignedClause(OMPAlignedClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setColonLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
- C->setAlignment(Reader->Reader.ReadSubExpr());
+ C->setAlignment(Reader->Record.readSubExpr());
}
void OMPClauseReader::VisitOMPCopyinClause(OMPCopyinClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Exprs;
Exprs.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Exprs);
Exprs.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setSourceExprs(Exprs);
Exprs.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setDestinationExprs(Exprs);
Exprs.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setAssignmentOps(Exprs);
}
void OMPClauseReader::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Exprs;
Exprs.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Exprs);
Exprs.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setSourceExprs(Exprs);
Exprs.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setDestinationExprs(Exprs);
Exprs.clear();
for (unsigned i = 0; i != NumVars; ++i)
- Exprs.push_back(Reader->Reader.ReadSubExpr());
+ Exprs.push_back(Reader->Record.readSubExpr());
C->setAssignmentOps(Exprs);
}
void OMPClauseReader::VisitOMPFlushClause(OMPFlushClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
}
void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setDependencyKind(static_cast<OpenMPDependClauseKind>(Record[Idx++]));
- C->setDependencyLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setDependencyKind(
+ static_cast<OpenMPDependClauseKind>(Reader->Record.readInt()));
+ C->setDependencyLoc(Reader->ReadSourceLocation());
+ C->setColonLoc(Reader->ReadSourceLocation());
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
- C->setCounterValue(Reader->Reader.ReadSubExpr());
+ C->setCounterValue(Reader->Record.readSubExpr());
}
void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) {
- C->setDevice(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setDevice(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
C->setMapTypeModifier(
- static_cast<OpenMPMapClauseKind>(Record[Idx++]));
+ static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
C->setMapType(
- static_cast<OpenMPMapClauseKind>(Record[Idx++]));
- C->setMapLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
+ static_cast<OpenMPMapClauseKind>(Reader->Record.readInt()));
+ C->setMapLoc(Reader->ReadSourceLocation());
+ C->setColonLoc(Reader->ReadSourceLocation());
auto NumVars = C->varlist_size();
auto UniqueDecls = C->getUniqueDeclarationsNum();
auto TotalLists = C->getTotalComponentListNum();
@@ -2283,34 +2264,32 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(
- Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+ Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
- Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
- ValueDecl *AssociatedDecl =
- Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+ Expr *AssociatedExpr = Reader->Record.readSubExpr();
+ ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2318,57 +2297,57 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
}
void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
- C->setNumTeams(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setNumTeams(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) {
- C->setThreadLimit(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setThreadLimit(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPPriorityClause(OMPPriorityClause *C) {
- C->setPriority(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setPriority(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
- C->setGrainsize(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setGrainsize(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
- C->setNumTasks(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setNumTasks(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) {
- C->setHint(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setHint(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
VisitOMPClauseWithPreInit(C);
C->setDistScheduleKind(
- static_cast<OpenMPDistScheduleClauseKind>(Record[Idx++]));
- C->setChunkSize(Reader->Reader.ReadSubExpr());
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setDistScheduleKindLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setCommaLoc(Reader->ReadSourceLocation(Record, Idx));
+ static_cast<OpenMPDistScheduleClauseKind>(Reader->Record.readInt()));
+ C->setChunkSize(Reader->Record.readSubExpr());
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setDistScheduleKindLoc(Reader->ReadSourceLocation());
+ C->setCommaLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
C->setDefaultmapKind(
- static_cast<OpenMPDefaultmapClauseKind>(Record[Idx++]));
+ static_cast<OpenMPDefaultmapClauseKind>(Reader->Record.readInt()));
C->setDefaultmapModifier(
- static_cast<OpenMPDefaultmapClauseModifier>(Record[Idx++]));
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setDefaultmapModifierLoc(Reader->ReadSourceLocation(Record, Idx));
- C->setDefaultmapKindLoc(Reader->ReadSourceLocation(Record, Idx));
+ static_cast<OpenMPDefaultmapClauseModifier>(Reader->Record.readInt()));
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ C->setDefaultmapModifierLoc(Reader->ReadSourceLocation());
+ C->setDefaultmapKindLoc(Reader->ReadSourceLocation());
}
void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
auto NumVars = C->varlist_size();
auto UniqueDecls = C->getUniqueDeclarationsNum();
auto TotalLists = C->getTotalComponentListNum();
@@ -2377,34 +2356,32 @@ void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(
- Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+ Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
- Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
- ValueDecl *AssociatedDecl =
- Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+ Expr *AssociatedExpr = Reader->Record.readSubExpr();
+ ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2412,7 +2389,7 @@ void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
}
void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ C->setLParenLoc(Reader->ReadSourceLocation());
auto NumVars = C->varlist_size();
auto UniqueDecls = C->getUniqueDeclarationsNum();
auto TotalLists = C->getTotalComponentListNum();
@@ -2421,34 +2398,32 @@ void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
SmallVector<ValueDecl *, 16> Decls;
Decls.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- Decls.push_back(
- Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx));
+ Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
C->setUniqueDecls(Decls);
SmallVector<unsigned, 16> ListsPerDecl;
ListsPerDecl.reserve(UniqueDecls);
for (unsigned i = 0; i < UniqueDecls; ++i)
- ListsPerDecl.push_back(Record[Idx++]);
+ ListsPerDecl.push_back(Reader->Record.readInt());
C->setDeclNumLists(ListsPerDecl);
SmallVector<unsigned, 32> ListSizes;
ListSizes.reserve(TotalLists);
for (unsigned i = 0; i < TotalLists; ++i)
- ListSizes.push_back(Record[Idx++]);
+ ListSizes.push_back(Reader->Record.readInt());
C->setComponentListSizes(ListSizes);
SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
Components.reserve(TotalComponents);
for (unsigned i = 0; i < TotalComponents; ++i) {
- Expr *AssociatedExpr = Reader->Reader.ReadSubExpr();
- ValueDecl *AssociatedDecl =
- Reader->Reader.ReadDeclAs<ValueDecl>(Reader->F, Record, Idx);
+ Expr *AssociatedExpr = Reader->Record.readSubExpr();
+ ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
AssociatedExpr, AssociatedDecl));
}
@@ -2456,101 +2431,172 @@ void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
}
void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- unsigned NumVars = C->varlist_size();
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ auto NumVars = C->varlist_size();
+ auto UniqueDecls = C->getUniqueDeclarationsNum();
+ auto TotalLists = C->getTotalComponentListNum();
+ auto TotalComponents = C->getTotalComponentsNum();
+
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
Vars.clear();
+ for (unsigned i = 0; i != NumVars; ++i)
+ Vars.push_back(Reader->Record.readSubExpr());
+ C->setPrivateCopies(Vars);
+ Vars.clear();
+ for (unsigned i = 0; i != NumVars; ++i)
+ Vars.push_back(Reader->Record.readSubExpr());
+ C->setInits(Vars);
+
+ SmallVector<ValueDecl *, 16> Decls;
+ Decls.reserve(UniqueDecls);
+ for (unsigned i = 0; i < UniqueDecls; ++i)
+ Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
+ C->setUniqueDecls(Decls);
+
+ SmallVector<unsigned, 16> ListsPerDecl;
+ ListsPerDecl.reserve(UniqueDecls);
+ for (unsigned i = 0; i < UniqueDecls; ++i)
+ ListsPerDecl.push_back(Reader->Record.readInt());
+ C->setDeclNumLists(ListsPerDecl);
+
+ SmallVector<unsigned, 32> ListSizes;
+ ListSizes.reserve(TotalLists);
+ for (unsigned i = 0; i < TotalLists; ++i)
+ ListSizes.push_back(Reader->Record.readInt());
+ C->setComponentListSizes(ListSizes);
+
+ SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
+ Components.reserve(TotalComponents);
+ for (unsigned i = 0; i < TotalComponents; ++i) {
+ Expr *AssociatedExpr = Reader->Record.readSubExpr();
+ ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
+ Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+ AssociatedExpr, AssociatedDecl));
+ }
+ C->setComponents(Components, ListSizes);
}
void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
- C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
- unsigned NumVars = C->varlist_size();
+ C->setLParenLoc(Reader->ReadSourceLocation());
+ auto NumVars = C->varlist_size();
+ auto UniqueDecls = C->getUniqueDeclarationsNum();
+ auto TotalLists = C->getTotalComponentListNum();
+ auto TotalComponents = C->getTotalComponentsNum();
+
SmallVector<Expr *, 16> Vars;
Vars.reserve(NumVars);
for (unsigned i = 0; i != NumVars; ++i)
- Vars.push_back(Reader->Reader.ReadSubExpr());
+ Vars.push_back(Reader->Record.readSubExpr());
C->setVarRefs(Vars);
Vars.clear();
+
+ SmallVector<ValueDecl *, 16> Decls;
+ Decls.reserve(UniqueDecls);
+ for (unsigned i = 0; i < UniqueDecls; ++i)
+ Decls.push_back(Reader->Record.readDeclAs<ValueDecl>());
+ C->setUniqueDecls(Decls);
+
+ SmallVector<unsigned, 16> ListsPerDecl;
+ ListsPerDecl.reserve(UniqueDecls);
+ for (unsigned i = 0; i < UniqueDecls; ++i)
+ ListsPerDecl.push_back(Reader->Record.readInt());
+ C->setDeclNumLists(ListsPerDecl);
+
+ SmallVector<unsigned, 32> ListSizes;
+ ListSizes.reserve(TotalLists);
+ for (unsigned i = 0; i < TotalLists; ++i)
+ ListSizes.push_back(Reader->Record.readInt());
+ C->setComponentListSizes(ListSizes);
+
+ SmallVector<OMPClauseMappableExprCommon::MappableComponent, 32> Components;
+ Components.reserve(TotalComponents);
+ for (unsigned i = 0; i < TotalComponents; ++i) {
+ Expr *AssociatedExpr = Reader->Record.readSubExpr();
+ ValueDecl *AssociatedDecl = Reader->Record.readDeclAs<ValueDecl>();
+ Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+ AssociatedExpr, AssociatedDecl));
+ }
+ C->setComponents(Components, ListSizes);
}
//===----------------------------------------------------------------------===//
// OpenMP Directives.
//===----------------------------------------------------------------------===//
void ASTStmtReader::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
- E->setLocStart(ReadSourceLocation(Record, Idx));
- E->setLocEnd(ReadSourceLocation(Record, Idx));
- OMPClauseReader ClauseReader(this, Reader.getContext(), Record, Idx);
+ E->setLocStart(ReadSourceLocation());
+ E->setLocEnd(ReadSourceLocation());
+ OMPClauseReader ClauseReader(this, Record);
SmallVector<OMPClause *, 5> Clauses;
for (unsigned i = 0; i < E->getNumClauses(); ++i)
Clauses.push_back(ClauseReader.readClause());
E->setClauses(Clauses);
if (E->hasAssociatedStmt())
- E->setAssociatedStmt(Reader.ReadSubStmt());
+ E->setAssociatedStmt(Record.readSubStmt());
}
void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
VisitStmt(D);
// Two fields (NumClauses and CollapsedNum) were read in ReadStmtFromStream.
- Idx += 2;
+ Record.skipInts(2);
VisitOMPExecutableDirective(D);
- D->setIterationVariable(Reader.ReadSubExpr());
- D->setLastIteration(Reader.ReadSubExpr());
- D->setCalcLastIteration(Reader.ReadSubExpr());
- D->setPreCond(Reader.ReadSubExpr());
- D->setCond(Reader.ReadSubExpr());
- D->setInit(Reader.ReadSubExpr());
- D->setInc(Reader.ReadSubExpr());
- D->setPreInits(Reader.ReadSubStmt());
+ D->setIterationVariable(Record.readSubExpr());
+ D->setLastIteration(Record.readSubExpr());
+ D->setCalcLastIteration(Record.readSubExpr());
+ D->setPreCond(Record.readSubExpr());
+ D->setCond(Record.readSubExpr());
+ D->setInit(Record.readSubExpr());
+ D->setInc(Record.readSubExpr());
+ D->setPreInits(Record.readSubStmt());
if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
isOpenMPDistributeDirective(D->getDirectiveKind())) {
- D->setIsLastIterVariable(Reader.ReadSubExpr());
- D->setLowerBoundVariable(Reader.ReadSubExpr());
- D->setUpperBoundVariable(Reader.ReadSubExpr());
- D->setStrideVariable(Reader.ReadSubExpr());
- D->setEnsureUpperBound(Reader.ReadSubExpr());
- D->setNextLowerBound(Reader.ReadSubExpr());
- D->setNextUpperBound(Reader.ReadSubExpr());
- D->setNumIterations(Reader.ReadSubExpr());
+ D->setIsLastIterVariable(Record.readSubExpr());
+ D->setLowerBoundVariable(Record.readSubExpr());
+ D->setUpperBoundVariable(Record.readSubExpr());
+ D->setStrideVariable(Record.readSubExpr());
+ D->setEnsureUpperBound(Record.readSubExpr());
+ D->setNextLowerBound(Record.readSubExpr());
+ D->setNextUpperBound(Record.readSubExpr());
+ D->setNumIterations(Record.readSubExpr());
}
if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
- D->setPrevLowerBoundVariable(Reader.ReadSubExpr());
- D->setPrevUpperBoundVariable(Reader.ReadSubExpr());
+ D->setPrevLowerBoundVariable(Record.readSubExpr());
+ D->setPrevUpperBoundVariable(Record.readSubExpr());
}
SmallVector<Expr *, 4> Sub;
unsigned CollapsedNum = D->getCollapsedNumber();
Sub.reserve(CollapsedNum);
for (unsigned i = 0; i < CollapsedNum; ++i)
- Sub.push_back(Reader.ReadSubExpr());
+ Sub.push_back(Record.readSubExpr());
D->setCounters(Sub);
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
- Sub.push_back(Reader.ReadSubExpr());
+ Sub.push_back(Record.readSubExpr());
D->setPrivateCounters(Sub);
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
- Sub.push_back(Reader.ReadSubExpr());
+ Sub.push_back(Record.readSubExpr());
D->setInits(Sub);
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
- Sub.push_back(Reader.ReadSubExpr());
+ Sub.push_back(Record.readSubExpr());
D->setUpdates(Sub);
Sub.clear();
for (unsigned i = 0; i < CollapsedNum; ++i)
- Sub.push_back(Reader.ReadSubExpr());
+ Sub.push_back(Record.readSubExpr());
D->setFinals(Sub);
}
void ASTStmtReader::VisitOMPParallelDirective(OMPParallelDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
@@ -2559,7 +2605,7 @@ void ASTStmtReader::VisitOMPSimdDirective(OMPSimdDirective *D) {
void ASTStmtReader::VisitOMPForDirective(OMPForDirective *D) {
VisitOMPLoopDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
@@ -2569,21 +2615,21 @@ void ASTStmtReader::VisitOMPForSimdDirective(OMPForSimdDirective *D) {
void ASTStmtReader::VisitOMPSectionsDirective(OMPSectionsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPSectionDirective(OMPSectionDirective *D) {
VisitStmt(D);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPSingleDirective(OMPSingleDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
@@ -2595,14 +2641,14 @@ void ASTStmtReader::VisitOMPMasterDirective(OMPMasterDirective *D) {
void ASTStmtReader::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- ReadDeclarationNameInfo(D->DirName, Record, Idx);
+ ReadDeclarationNameInfo(D->DirName);
}
void ASTStmtReader::VisitOMPParallelForDirective(OMPParallelForDirective *D) {
VisitOMPLoopDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPParallelForSimdDirective(
@@ -2614,17 +2660,17 @@ void ASTStmtReader::VisitOMPParallelSectionsDirective(
OMPParallelSectionsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPTaskDirective(OMPTaskDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
@@ -2650,74 +2696,74 @@ void ASTStmtReader::VisitOMPTaskgroupDirective(OMPTaskgroupDirective *D) {
void ASTStmtReader::VisitOMPFlushDirective(OMPFlushDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPOrderedDirective(OMPOrderedDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setX(Reader.ReadSubExpr());
- D->setV(Reader.ReadSubExpr());
- D->setExpr(Reader.ReadSubExpr());
- D->setUpdateExpr(Reader.ReadSubExpr());
- D->IsXLHSInRHSPart = Record[Idx++] != 0;
- D->IsPostfixUpdate = Record[Idx++] != 0;
+ D->setX(Record.readSubExpr());
+ D->setV(Record.readSubExpr());
+ D->setExpr(Record.readSubExpr());
+ D->setUpdateExpr(Record.readSubExpr());
+ D->IsXLHSInRHSPart = Record.readInt() != 0;
+ D->IsPostfixUpdate = Record.readInt() != 0;
}
void ASTStmtReader::VisitOMPTargetDirective(OMPTargetDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetEnterDataDirective(
OMPTargetEnterDataDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetExitDataDirective(
OMPTargetExitDataDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetParallelDirective(
OMPTargetParallelDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPTargetParallelForDirective(
OMPTargetParallelForDirective *D) {
VisitOMPLoopDirective(D);
- D->setHasCancel(Record[Idx++]);
+ D->setHasCancel(Record.readInt());
}
void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
@@ -2725,15 +2771,15 @@ void ASTStmtReader::VisitOMPCancellationPointDirective(
OMPCancellationPointDirective *D) {
VisitStmt(D);
VisitOMPExecutableDirective(D);
- D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record[Idx++]));
+ D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
}
void ASTStmtReader::VisitOMPCancelDirective(OMPCancelDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
- D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record[Idx++]));
+ D->setCancelRegion(static_cast<OpenMPDirectiveKind>(Record.readInt()));
}
void ASTStmtReader::VisitOMPTaskLoopDirective(OMPTaskLoopDirective *D) {
@@ -2750,7 +2796,7 @@ void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
VisitStmt(D);
- ++Idx;
+ Record.skipInts(1);
VisitOMPExecutableDirective(D);
}
void ASTStmtReader::VisitOMPDistributeParallelForDirective(
@@ -2773,6 +2819,47 @@ void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
VisitOMPLoopDirective(D);
}
+void ASTStmtReader::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTeamsDistributeDirective(
+ OMPTeamsDistributeDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTeamsDistributeSimdDirective(
+ OMPTeamsDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTeamsDistributeParallelForSimdDirective(
+ OMPTeamsDistributeParallelForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTeamsDistributeParallelForDirective(
+ OMPTeamsDistributeParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
+ VisitStmt(D);
+ // The NumClauses field was read in ReadStmtFromStream.
+ Record.skipInts(1);
+ VisitOMPExecutableDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTargetTeamsDistributeDirective(
+ OMPTargetTeamsDistributeDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTargetTeamsDistributeParallelForDirective(
+ OMPTargetTeamsDistributeParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
//===----------------------------------------------------------------------===//
// ASTReader Implementation
//===----------------------------------------------------------------------===//
@@ -2810,7 +2897,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
ReadingKindTracker ReadingKind(Read_Stmt, *this);
llvm::BitstreamCursor &Cursor = F.DeclsCursor;
-
+
// Map of offset to previously deserialized stmt. The offset points
/// just after the stmt record.
llvm::DenseMap<uint64_t, Stmt *> StmtEntries;
@@ -2819,14 +2906,13 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
unsigned PrevNumStmts = StmtStack.size();
#endif
- RecordData Record;
- unsigned Idx;
- ASTStmtReader Reader(*this, F, Cursor, Record, Idx);
+ ASTRecordReader Record(*this, F);
+ ASTStmtReader Reader(Record, Cursor);
Stmt::EmptyShell Empty;
while (true) {
llvm::BitstreamEntry Entry = Cursor.advanceSkippingSubblocks();
-
+
switch (Entry.Kind) {
case llvm::BitstreamEntry::SubBlock: // Handled for us already.
case llvm::BitstreamEntry::Error:
@@ -2840,11 +2926,9 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
}
Stmt *S = nullptr;
- Idx = 0;
- Record.clear();
bool Finished = false;
bool IsStmtReference = false;
- switch ((StmtCode)Cursor.readRecord(Entry.ID, Record)) {
+ switch ((StmtCode)Record.readRecord(Cursor, Entry.ID)) {
case STMT_STOP:
Finished = true;
break;
@@ -2853,7 +2937,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
IsStmtReference = true;
assert(StmtEntries.find(Record[0]) != StmtEntries.end() &&
"No stmt was recorded for this offset reference!");
- S = StmtEntries[Record[Idx++]];
+ S = StmtEntries[Record.readInt()];
break;
case STMT_NULL_PTR:
@@ -2991,11 +3075,11 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break;
case EXPR_OFFSETOF:
- S = OffsetOfExpr::CreateEmpty(Context,
+ S = OffsetOfExpr::CreateEmpty(Context,
Record[ASTStmtReader::NumExprFields],
Record[ASTStmtReader::NumExprFields + 1]);
break;
-
+
case EXPR_SIZEOF_ALIGN_OF:
S = new (Context) UnaryExprOrTypeTraitExpr(Empty);
break;
@@ -3017,46 +3101,46 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
// That way we can use MemberExpr::Create and don't have to duplicate its
// logic with a MemberExpr::CreateEmpty.
- assert(Idx == 0);
+ assert(Record.getIdx() == 0);
NestedNameSpecifierLoc QualifierLoc;
- if (Record[Idx++]) { // HasQualifier.
- QualifierLoc = ReadNestedNameSpecifierLoc(F, Record, Idx);
+ if (Record.readInt()) { // HasQualifier.
+ QualifierLoc = Record.readNestedNameSpecifierLoc();
}
SourceLocation TemplateKWLoc;
TemplateArgumentListInfo ArgInfo;
- bool HasTemplateKWAndArgsInfo = Record[Idx++];
+ bool HasTemplateKWAndArgsInfo = Record.readInt();
if (HasTemplateKWAndArgsInfo) {
- TemplateKWLoc = ReadSourceLocation(F, Record, Idx);
- unsigned NumTemplateArgs = Record[Idx++];
- ArgInfo.setLAngleLoc(ReadSourceLocation(F, Record, Idx));
- ArgInfo.setRAngleLoc(ReadSourceLocation(F, Record, Idx));
+ TemplateKWLoc = Record.readSourceLocation();
+ unsigned NumTemplateArgs = Record.readInt();
+ ArgInfo.setLAngleLoc(Record.readSourceLocation());
+ ArgInfo.setRAngleLoc(Record.readSourceLocation());
for (unsigned i = 0; i != NumTemplateArgs; ++i)
- ArgInfo.addArgument(ReadTemplateArgumentLoc(F, Record, Idx));
+ ArgInfo.addArgument(Record.readTemplateArgumentLoc());
}
- bool HadMultipleCandidates = Record[Idx++];
+ bool HadMultipleCandidates = Record.readInt();
- NamedDecl *FoundD = ReadDeclAs<NamedDecl>(F, Record, Idx);
- AccessSpecifier AS = (AccessSpecifier)Record[Idx++];
+ NamedDecl *FoundD = Record.readDeclAs<NamedDecl>();
+ AccessSpecifier AS = (AccessSpecifier)Record.readInt();
DeclAccessPair FoundDecl = DeclAccessPair::make(FoundD, AS);
- QualType T = readType(F, Record, Idx);
- ExprValueKind VK = static_cast<ExprValueKind>(Record[Idx++]);
- ExprObjectKind OK = static_cast<ExprObjectKind>(Record[Idx++]);
+ QualType T = Record.readType();
+ ExprValueKind VK = static_cast<ExprValueKind>(Record.readInt());
+ ExprObjectKind OK = static_cast<ExprObjectKind>(Record.readInt());
Expr *Base = ReadSubExpr();
- ValueDecl *MemberD = ReadDeclAs<ValueDecl>(F, Record, Idx);
- SourceLocation MemberLoc = ReadSourceLocation(F, Record, Idx);
+ ValueDecl *MemberD = Record.readDeclAs<ValueDecl>();
+ SourceLocation MemberLoc = Record.readSourceLocation();
DeclarationNameInfo MemberNameInfo(MemberD->getDeclName(), MemberLoc);
- bool IsArrow = Record[Idx++];
- SourceLocation OperatorLoc = ReadSourceLocation(F, Record, Idx);
+ bool IsArrow = Record.readInt();
+ SourceLocation OperatorLoc = Record.readSourceLocation();
S = MemberExpr::Create(Context, Base, IsArrow, OperatorLoc, QualifierLoc,
TemplateKWLoc, MemberD, FoundDecl, MemberNameInfo,
HasTemplateKWAndArgsInfo ? &ArgInfo : nullptr, T,
VK, OK);
- ReadDeclarationNameLoc(F, cast<MemberExpr>(S)->MemberDNLoc,
- MemberD->getDeclName(), Record, Idx);
+ Record.readDeclarationNameLoc(cast<MemberExpr>(S)->MemberDNLoc,
+ MemberD->getDeclName());
if (HadMultipleCandidates)
cast<MemberExpr>(S)->setHadMultipleCandidates(true);
break;
@@ -3118,6 +3202,14 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = new (Context) NoInitExpr(Empty);
break;
+ case EXPR_ARRAY_INIT_LOOP:
+ S = new (Context) ArrayInitLoopExpr(Empty);
+ break;
+
+ case EXPR_ARRAY_INIT_INDEX:
+ S = new (Context) ArrayInitIndexExpr(Empty);
+ break;
+
case EXPR_VA_ARG:
S = new (Context) VAArgExpr(Empty);
break;
@@ -3213,7 +3305,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = new (Context) ObjCAtFinallyStmt(Empty);
break;
case STMT_OBJC_AT_TRY:
- S = ObjCAtTryStmt::CreateEmpty(Context,
+ S = ObjCAtTryStmt::CreateEmpty(Context,
Record[ASTStmtReader::NumStmtFields],
Record[ASTStmtReader::NumStmtFields + 1]);
break;
@@ -3484,6 +3576,68 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break;
}
+ case STMT_OMP_TARGET_SIMD_DIRECTIVE: {
+ auto NumClauses = Record[ASTStmtReader::NumStmtFields];
+ auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTargetSimdDirective::CreateEmpty(Context, NumClauses, CollapsedNum,
+ Empty);
+ break;
+ }
+
+ case STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE: {
+ auto NumClauses = Record[ASTStmtReader::NumStmtFields];
+ auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE: {
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
+ unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTeamsDistributeSimdDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
+ auto NumClauses = Record[ASTStmtReader::NumStmtFields];
+ auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTeamsDistributeParallelForSimdDirective::CreateEmpty(
+ Context, NumClauses, CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
+ auto NumClauses = Record[ASTStmtReader::NumStmtFields];
+ auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTeamsDistributeParallelForDirective::CreateEmpty(
+ Context, NumClauses, CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_TARGET_TEAMS_DIRECTIVE: {
+ S = OMPTargetTeamsDirective::CreateEmpty(
+ Context, Record[ASTStmtReader::NumStmtFields], Empty);
+ break;
+ }
+
+ case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE: {
+ auto NumClauses = Record[ASTStmtReader::NumStmtFields];
+ auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTargetTeamsDistributeDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
+ auto NumClauses = Record[ASTStmtReader::NumStmtFields];
+ auto CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTargetTeamsDistributeParallelForDirective::CreateEmpty(
+ Context, NumClauses, CollapsedNum, Empty);
+ break;
+ }
+
case EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(Context, Empty);
break;
@@ -3576,7 +3730,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
case EXPR_CXX_BIND_TEMPORARY:
S = new (Context) CXXBindTemporaryExpr(Empty);
break;
-
+
case EXPR_CXX_SCALAR_VALUE_INIT:
S = new (Context) CXXScalarValueInitExpr(Empty);
break;
@@ -3589,54 +3743,54 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
case EXPR_CXX_PSEUDO_DESTRUCTOR:
S = new (Context) CXXPseudoDestructorExpr(Empty);
break;
-
+
case EXPR_EXPR_WITH_CLEANUPS:
S = ExprWithCleanups::Create(Context, Empty,
Record[ASTStmtReader::NumExprFields]);
break;
-
+
case EXPR_CXX_DEPENDENT_SCOPE_MEMBER:
S = CXXDependentScopeMemberExpr::CreateEmpty(Context,
/*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
- ? Record[ASTStmtReader::NumExprFields + 1]
+ ? Record[ASTStmtReader::NumExprFields + 1]
: 0);
break;
-
+
case EXPR_CXX_DEPENDENT_SCOPE_DECL_REF:
S = DependentScopeDeclRefExpr::CreateEmpty(Context,
/*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
- ? Record[ASTStmtReader::NumExprFields + 1]
+ ? Record[ASTStmtReader::NumExprFields + 1]
: 0);
break;
-
+
case EXPR_CXX_UNRESOLVED_CONSTRUCT:
S = CXXUnresolvedConstructExpr::CreateEmpty(Context,
/*NumArgs=*/Record[ASTStmtReader::NumExprFields]);
break;
-
+
case EXPR_CXX_UNRESOLVED_MEMBER:
S = UnresolvedMemberExpr::CreateEmpty(Context,
/*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
- ? Record[ASTStmtReader::NumExprFields + 1]
+ ? Record[ASTStmtReader::NumExprFields + 1]
: 0);
break;
-
+
case EXPR_CXX_UNRESOLVED_LOOKUP:
S = UnresolvedLookupExpr::CreateEmpty(Context,
/*HasTemplateKWAndArgsInfo=*/Record[ASTStmtReader::NumExprFields],
/*NumTemplateArgs=*/Record[ASTStmtReader::NumExprFields]
- ? Record[ASTStmtReader::NumExprFields + 1]
+ ? Record[ASTStmtReader::NumExprFields + 1]
: 0);
break;
case EXPR_TYPE_TRAIT:
- S = TypeTraitExpr::CreateDeserialized(Context,
+ S = TypeTraitExpr::CreateDeserialized(Context,
Record[ASTStmtReader::NumExprFields]);
break;
-
+
case EXPR_ARRAY_TYPE_TRAIT:
S = new (Context) ArrayTypeTraitExpr(Empty);
break;
@@ -3652,17 +3806,17 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
case EXPR_PACK_EXPANSION:
S = new (Context) PackExpansionExpr(Empty);
break;
-
+
case EXPR_SIZEOF_PACK:
S = SizeOfPackExpr::CreateDeserialized(
Context,
/*NumPartialArgs=*/Record[ASTStmtReader::NumExprFields]);
break;
-
+
case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM:
S = new (Context) SubstNonTypeTemplateParmExpr(Empty);
break;
-
+
case EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK:
S = new (Context) SubstNonTypeTemplateParmPackExpr(Empty);
break;
@@ -3671,7 +3825,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = FunctionParmPackExpr::CreateEmpty(Context,
Record[ASTStmtReader::NumExprFields]);
break;
-
+
case EXPR_MATERIALIZE_TEMPORARY:
S = new (Context) MaterializeTemporaryExpr(Empty);
break;
@@ -3687,7 +3841,7 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
case EXPR_CUDA_KERNEL_CALL:
S = new (Context) CUDAKernelCallExpr(Context, Empty);
break;
-
+
case EXPR_ASTYPE:
S = new (Context) AsTypeExpr(Empty);
break;
@@ -3701,16 +3855,14 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
case EXPR_ATOMIC:
S = new (Context) AtomicExpr(Empty);
break;
-
+
case EXPR_LAMBDA: {
unsigned NumCaptures = Record[ASTStmtReader::NumExprFields];
- unsigned NumArrayIndexVars = Record[ASTStmtReader::NumExprFields + 1];
- S = LambdaExpr::CreateDeserialized(Context, NumCaptures,
- NumArrayIndexVars);
+ S = LambdaExpr::CreateDeserialized(Context, NumCaptures);
break;
}
}
-
+
// We hit a STMT_STOP, so we're done with this expression.
if (Finished)
break;
@@ -3722,8 +3874,8 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
StmtEntries[Cursor.GetCurrentBitNo()] = S;
}
-
- assert(Idx == Record.size() && "Invalid deserialization of statement");
+ assert(Record.getIdx() == Record.size() &&
+ "Invalid deserialization of statement");
StmtStack.push_back(S);
}
Done:
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 7589b0c5dd52..6d79ea53b659 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -12,23 +12,31 @@
//===----------------------------------------------------------------------===//
#include "clang/Serialization/ASTWriter.h"
-#include "clang/Serialization/ModuleFileExtension.h"
#include "ASTCommon.h"
#include "ASTReaderInternals.h"
#include "MultiOnDiskHashTable.h"
#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTUnresolvedSet.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclContextInternals.h"
+#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclFriend.h"
-#include "clang/AST/DeclLookups.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
+#include "clang/AST/LambdaCapture.h"
+#include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/RawCommentList.h"
+#include "clang/AST/TemplateName.h"
#include "clang/AST/Type.h"
#include "clang/AST/TypeLocVisitor.h"
#include "clang/Basic/DiagnosticOptions.h"
#include "clang/Basic/FileManager.h"
-#include "clang/Basic/FileSystemStatCache.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/Module.h"
+#include "clang/Basic/ObjCRuntime.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/SourceManagerInternals.h"
#include "clang/Basic/TargetInfo.h"
@@ -38,28 +46,48 @@
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/Lex/MacroInfo.h"
+#include "clang/Lex/ModuleMap.h"
#include "clang/Lex/PreprocessingRecord.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Lex/Token.h"
#include "clang/Sema/IdentifierResolver.h"
+#include "clang/Sema/ObjCMethodList.h"
#include "clang/Sema/Sema.h"
+#include "clang/Sema/Weak.h"
#include "clang/Serialization/ASTReader.h"
+#include "clang/Serialization/Module.h"
+#include "clang/Serialization/ModuleFileExtension.h"
#include "clang/Serialization/SerializationDiagnostic.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/Hashing.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallSet.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
+#include "llvm/Bitcode/BitCodes.h"
#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Support/Casting.h"
#include "llvm/Support/Compression.h"
#include "llvm/Support/EndianStream.h"
-#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/OnDiskHashTable.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Process.h"
+#include "llvm/Support/raw_ostream.h"
#include <algorithm>
-#include <cstdio>
-#include <string.h>
+#include <cassert>
+#include <cstdint>
+#include <cstdlib>
+#include <cstring>
+#include <deque>
+#include <limits>
+#include <new>
+#include <tuple>
#include <utility>
using namespace clang;
@@ -83,6 +111,7 @@ static StringRef bytes(const SmallVectorImpl<T> &v) {
//===----------------------------------------------------------------------===//
namespace clang {
+
class ASTTypeWriter {
ASTWriter &Writer;
ASTRecordWriter Record;
@@ -127,6 +156,7 @@ namespace clang {
#define ABSTRACT_TYPE(Class, Base)
#include "clang/AST/TypeNodes.def"
};
+
} // end namespace clang
void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
@@ -451,6 +481,14 @@ void ASTTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
Code = TYPE_OBJC_INTERFACE;
}
+void ASTTypeWriter::VisitObjCTypeParamType(const ObjCTypeParamType *T) {
+ Record.AddDeclRef(T->getDecl());
+ Record.push_back(T->getNumProtocols());
+ for (const auto *I : T->quals())
+ Record.AddDeclRef(I);
+ Code = TYPE_OBJC_TYPE_PARAM;
+}
+
void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
Record.AddTypeRef(T->getBaseType());
Record.push_back(T->getTypeArgsAsWritten().size());
@@ -478,6 +516,7 @@ ASTTypeWriter::VisitAtomicType(const AtomicType *T) {
void
ASTTypeWriter::VisitPipeType(const PipeType *T) {
Record.AddTypeRef(T->getElementType());
+ Record.push_back(T->isReadOnly());
Code = TYPE_PIPE;
}
@@ -504,6 +543,7 @@ public:
void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
// nothing to do
}
+
void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
Record.AddSourceLocation(TL.getBuiltinLoc());
if (TL.needsExtraLocalData()) {
@@ -513,31 +553,40 @@ void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
Record.push_back(TL.hasModeAttr());
}
}
+
void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {
Record.AddSourceLocation(TL.getStarLoc());
}
+
void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
// nothing to do
}
+
void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
// nothing to do
}
+
void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
Record.AddSourceLocation(TL.getCaretLoc());
}
+
void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
Record.AddSourceLocation(TL.getAmpLoc());
}
+
void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
Record.AddSourceLocation(TL.getAmpAmpLoc());
}
+
void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
Record.AddSourceLocation(TL.getStarLoc());
Record.AddTypeSourceInfo(TL.getClassTInfo());
}
+
void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
Record.AddSourceLocation(TL.getLBracketLoc());
Record.AddSourceLocation(TL.getRBracketLoc());
@@ -545,29 +594,37 @@ void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
if (TL.getSizeExpr())
Record.AddStmt(TL.getSizeExpr());
}
+
void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocWriter::VisitIncompleteArrayTypeLoc(IncompleteArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocWriter::VisitVariableArrayTypeLoc(VariableArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
DependentSizedArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
}
+
void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
DependentSizedExtVectorTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
Record.AddSourceLocation(TL.getLocalRangeBegin());
Record.AddSourceLocation(TL.getLParenLoc());
@@ -588,35 +645,50 @@ void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+void TypeLocWriter::VisitObjCTypeParamTypeLoc(ObjCTypeParamTypeLoc TL) {
+ if (TL.getNumProtocols()) {
+ Record.AddSourceLocation(TL.getProtocolLAngleLoc());
+ Record.AddSourceLocation(TL.getProtocolRAngleLoc());
+ }
+ for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
+ Record.AddSourceLocation(TL.getProtocolLoc(i));
+}
void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
Record.AddSourceLocation(TL.getTypeofLoc());
Record.AddSourceLocation(TL.getLParenLoc());
Record.AddSourceLocation(TL.getRParenLoc());
}
+
void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
Record.AddSourceLocation(TL.getTypeofLoc());
Record.AddSourceLocation(TL.getLParenLoc());
Record.AddSourceLocation(TL.getRParenLoc());
Record.AddTypeSourceInfo(TL.getUnderlyingTInfo());
}
+
void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
Record.AddSourceLocation(TL.getKWLoc());
Record.AddSourceLocation(TL.getLParenLoc());
Record.AddSourceLocation(TL.getRParenLoc());
Record.AddTypeSourceInfo(TL.getUnderlyingTInfo());
}
+
void TypeLocWriter::VisitAutoTypeLoc(AutoTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
Record.AddSourceLocation(TL.getAttrNameLoc());
if (TL.hasAttrOperand()) {
@@ -632,17 +704,21 @@ void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
Record.AddSourceLocation(TL.getAttrEnumOperandLoc());
}
}
+
void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
SubstTemplateTypeParmTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
SubstTemplateTypeParmPackTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
TemplateSpecializationTypeLoc TL) {
Record.AddSourceLocation(TL.getTemplateKeywordLoc());
@@ -653,22 +729,27 @@ void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
Record.AddTemplateArgumentLocInfo(TL.getArgLoc(i).getArgument().getKind(),
TL.getArgLoc(i).getLocInfo());
}
+
void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) {
Record.AddSourceLocation(TL.getLParenLoc());
Record.AddSourceLocation(TL.getRParenLoc());
}
+
void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
Record.AddSourceLocation(TL.getElaboratedKeywordLoc());
Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());
}
+
void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
Record.AddSourceLocation(TL.getElaboratedKeywordLoc());
Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
DependentTemplateSpecializationTypeLoc TL) {
Record.AddSourceLocation(TL.getElaboratedKeywordLoc());
@@ -681,12 +762,15 @@ void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
Record.AddTemplateArgumentLocInfo(TL.getArgLoc(I).getArgument().getKind(),
TL.getArgLoc(I).getLocInfo());
}
+
void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
Record.AddSourceLocation(TL.getEllipsisLoc());
}
+
void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
Record.AddSourceLocation(TL.getNameLoc());
}
+
void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
Record.push_back(TL.hasBaseTypeAsWritten());
Record.AddSourceLocation(TL.getTypeArgsLAngleLoc());
@@ -698,14 +782,17 @@ void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
Record.AddSourceLocation(TL.getProtocolLoc(i));
}
+
void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
Record.AddSourceLocation(TL.getStarLoc());
}
+
void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
Record.AddSourceLocation(TL.getKWLoc());
Record.AddSourceLocation(TL.getLParenLoc());
Record.AddSourceLocation(TL.getRParenLoc());
}
+
void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
Record.AddSourceLocation(TL.getKWLoc());
}
@@ -905,7 +992,7 @@ static void AddStmtsExprs(llvm::BitstreamWriter &Stream,
void ASTWriter::WriteBlockInfoBlock() {
RecordData Record;
- Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
+ Stream.EnterBlockInfoBlock();
#define BLOCK(X) EmitBlockID(X ## _ID, #X, Stream, Record)
#define RECORD(X) EmitRecordID(X, #X, Stream, Record)
@@ -966,6 +1053,8 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(HEADER_SEARCH_TABLE);
RECORD(FP_PRAGMA_OPTIONS);
RECORD(OPENCL_EXTENSIONS);
+ RECORD(OPENCL_EXTENSION_TYPES);
+ RECORD(OPENCL_EXTENSION_DECLS);
RECORD(DELEGATING_CTORS);
RECORD(KNOWN_NAMESPACES);
RECORD(MODULE_OFFSET_MAP);
@@ -983,6 +1072,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(POINTERS_TO_MEMBERS_PRAGMA_OPTIONS);
RECORD(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES);
RECORD(DELETE_EXPRS_TO_ANALYZE);
+ RECORD(CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH);
// SourceManager Block.
BLOCK(SOURCE_MANAGER_BLOCK);
@@ -1018,6 +1108,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(SUBMODULE_PRIVATE_HEADER);
RECORD(SUBMODULE_TEXTUAL_HEADER);
RECORD(SUBMODULE_PRIVATE_TEXTUAL_HEADER);
+ RECORD(SUBMODULE_INITIALIZERS);
// Comments Block.
BLOCK(COMMENTS_BLOCK);
@@ -1066,6 +1157,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(TYPE_ATOMIC);
RECORD(TYPE_DECAYED);
RECORD(TYPE_ADJUSTED);
+ RECORD(TYPE_OBJC_TYPE_PARAM);
RECORD(LOCAL_REDECLARATIONS);
RECORD(DECL_TYPEDEF);
RECORD(DECL_TYPEALIAS);
@@ -1212,7 +1304,7 @@ adjustFilenameForRelocatableAST(const char *Filename, StringRef BaseDir) {
}
static ASTFileSignature getSignature() {
- while (1) {
+ while (true) {
if (ASTFileSignature S = llvm::sys::Process::GetRandomNumber())
return S;
// Rely on GetRandomNumber to eventually return non-zero...
@@ -1534,6 +1626,7 @@ uint64_t ASTWriter::WriteControlBlock(Preprocessor &PP,
}
namespace {
+
/// \brief An input file.
struct InputFileEntry {
const FileEntry *File;
@@ -1541,6 +1634,7 @@ namespace {
bool IsTransient;
bool BufferOverridden;
};
+
} // end anonymous namespace
void ASTWriter::WriteInputFiles(SourceManager &SourceMgr,
@@ -1701,6 +1795,7 @@ static unsigned CreateSLocExpansionAbbrev(llvm::BitstreamWriter &Stream) {
}
namespace {
+
// Trait used for the on-disk hash table of header search information.
class HeaderFileInfoTrait {
ASTWriter &Writer;
@@ -1716,7 +1811,7 @@ namespace {
struct key_type {
const FileEntry *FE;
- const char *Filename;
+ StringRef Filename;
};
typedef const key_type &key_type_ref;
@@ -1737,7 +1832,7 @@ namespace {
EmitKeyDataLength(raw_ostream& Out, key_type_ref key, data_type_ref Data) {
using namespace llvm::support;
endian::Writer<little> LE(Out);
- unsigned KeyLen = strlen(key.Filename) + 1 + 8 + 8;
+ unsigned KeyLen = key.Filename.size() + 1 + 8 + 8;
LE.write<uint16_t>(KeyLen);
unsigned DataLen = 1 + 2 + 4 + 4;
for (auto ModInfo : HS.getModuleMap().findAllModulesForHeader(key.FE))
@@ -1754,7 +1849,7 @@ namespace {
KeyLen -= 8;
LE.write<uint64_t>(Writer.getTimestampForOutput(key.FE));
KeyLen -= 8;
- Out.write(key.Filename, KeyLen);
+ Out.write(key.Filename.data(), KeyLen);
}
void EmitData(raw_ostream &Out, key_type_ref key,
@@ -1809,6 +1904,7 @@ namespace {
const char *strings_begin() const { return FrameworkStringData.begin(); }
const char *strings_end() const { return FrameworkStringData.end(); }
};
+
} // end anonymous namespace
/// \brief Write the header search block for the list of files that
@@ -1842,13 +1938,13 @@ void ASTWriter::WriteHeaderSearch(const HeaderSearch &HS) {
continue;
// Massage the file path into an appropriate form.
- const char *Filename = File->getName();
+ StringRef Filename = File->getName();
SmallString<128> FilenameTmp(Filename);
if (PreparePathForOutput(FilenameTmp)) {
// If we performed any translation on the file name at all, we need to
// save this string, since the generator will refer to it later.
- Filename = strdup(FilenameTmp.c_str());
- SavedStrings.push_back(Filename);
+ Filename = StringRef(strdup(FilenameTmp.c_str()));
+ SavedStrings.push_back(Filename.data());
}
HeaderFileInfoTrait::key_type key = { File, Filename };
@@ -1982,14 +2078,13 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
// the reader side).
const llvm::MemoryBuffer *Buffer
= Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager());
- const char *Name = Buffer->getBufferIdentifier();
+ StringRef Name = Buffer->getBufferIdentifier();
Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
- StringRef(Name, strlen(Name) + 1));
+ StringRef(Name.data(), Name.size() + 1));
EmitBlob = true;
- if (strcmp(Name, "<built-in>") == 0) {
+ if (Name == "<built-in>")
PreloadSLocs.push_back(SLocEntryOffsets.size());
- }
}
if (EmitBlob) {
@@ -2418,7 +2513,9 @@ unsigned ASTWriter::getLocalOrImportedSubmoduleID(Module *Mod) {
if (Known != SubmoduleIDs.end())
return Known->second;
- if (Mod->getTopLevelModule() != WritingModule)
+ auto *Top = Mod->getTopLevelModule();
+ if (Top != WritingModule &&
+ !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule)))
return 0;
return SubmoduleIDs[Mod] = NextSubmoduleID++;
@@ -2650,6 +2747,13 @@ void ASTWriter::WriteSubmodules(Module *WritingModule) {
Stream.EmitRecordWithBlob(ConfigMacroAbbrev, Record, CM);
}
+ // Emit the initializers, if any.
+ RecordData Inits;
+ for (Decl *D : Context->getModuleInitializers(Mod))
+ Inits.push_back(GetDeclRef(D));
+ if (!Inits.empty())
+ Stream.EmitRecord(SUBMODULE_INITIALIZERS, Inits);
+
// Queue up the submodules of this module.
for (auto *M : Mod->submodules())
Q.push(M);
@@ -2860,6 +2964,7 @@ void ASTWriter::WriteComments() {
//===----------------------------------------------------------------------===//
namespace {
+
// Trait used for the on-disk hash table used in the method pool.
class ASTMethodPoolTrait {
ASTWriter &Writer;
@@ -2964,6 +3069,7 @@ public:
assert(Out.tell() - Start == DataLen && "Data length is wrong");
}
};
+
} // end anonymous namespace
/// \brief Write ObjC data: selectors and the method pool.
@@ -3135,6 +3241,7 @@ static NamedDecl *getDeclForLocalLookup(const LangOptions &LangOpts,
}
namespace {
+
class ASTIdentifierTableTrait {
ASTWriter &Writer;
Preprocessor &PP;
@@ -3185,6 +3292,7 @@ public:
auto MacroOffset = Writer.getMacroDirectivesOffset(II);
return isInterestingIdentifier(II, MacroOffset);
}
+
bool isInterestingNonMacroIdentifier(const IdentifierInfo *II) {
return isInterestingIdentifier(II, 0);
}
@@ -3278,6 +3386,7 @@ public:
}
}
};
+
} // end anonymous namespace
/// \brief Write the identifier table into the AST file.
@@ -3384,6 +3493,7 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
//===----------------------------------------------------------------------===//
namespace {
+
// Trait used for the on-disk hash table used in the method pool.
class ASTDeclContextNameLookupTrait {
ASTWriter &Writer;
@@ -3509,6 +3619,7 @@ public:
assert(Out.tell() - Start == DataLen && "Data length is wrong");
}
};
+
} // end anonymous namespace
bool ASTWriter::isLookupResultExternal(StoredDeclsList &Result,
@@ -3830,11 +3941,53 @@ void ASTWriter::WriteOpenCLExtensions(Sema &SemaRef) {
const OpenCLOptions &Opts = SemaRef.getOpenCLOptions();
RecordData Record;
-#define OPENCLEXT(nm) Record.push_back(Opts.nm);
-#include "clang/Basic/OpenCLExtensions.def"
+ for (const auto &I:Opts.OptMap) {
+ AddString(I.getKey(), Record);
+ auto V = I.getValue();
+ Record.push_back(V.Supported ? 1 : 0);
+ Record.push_back(V.Enabled ? 1 : 0);
+ Record.push_back(V.Avail);
+ Record.push_back(V.Core);
+ }
Stream.EmitRecord(OPENCL_EXTENSIONS, Record);
}
+void ASTWriter::WriteOpenCLExtensionTypes(Sema &SemaRef) {
+ if (!SemaRef.Context.getLangOpts().OpenCL)
+ return;
+
+ RecordData Record;
+ for (const auto &I : SemaRef.OpenCLTypeExtMap) {
+ Record.push_back(
+ static_cast<unsigned>(getTypeID(I.first->getCanonicalTypeInternal())));
+ Record.push_back(I.second.size());
+ for (auto Ext : I.second)
+ AddString(Ext, Record);
+ }
+ Stream.EmitRecord(OPENCL_EXTENSION_TYPES, Record);
+}
+
+void ASTWriter::WriteOpenCLExtensionDecls(Sema &SemaRef) {
+ if (!SemaRef.Context.getLangOpts().OpenCL)
+ return;
+
+ RecordData Record;
+ for (const auto &I : SemaRef.OpenCLDeclExtMap) {
+ Record.push_back(getDeclID(I.first));
+ Record.push_back(static_cast<unsigned>(I.second.size()));
+ for (auto Ext : I.second)
+ AddString(Ext, Record);
+ }
+ Stream.EmitRecord(OPENCL_EXTENSION_DECLS, Record);
+}
+
+void ASTWriter::WriteCUDAPragmas(Sema &SemaRef) {
+ if (SemaRef.ForceCUDAHostDeviceDepth > 0) {
+ RecordData::value_type Record[] = {SemaRef.ForceCUDAHostDeviceDepth};
+ Stream.EmitRecord(CUDA_PRAGMA_FORCE_HOST_DEVICE_DEPTH, Record);
+ }
+}
+
void ASTWriter::WriteObjCCategories() {
SmallVector<ObjCCategoriesInfo, 2> CategoriesMap;
RecordData Categories;
@@ -3894,14 +4047,14 @@ void ASTWriter::WriteLateParsedTemplates(Sema &SemaRef) {
return;
RecordData Record;
- for (auto LPTMapEntry : LPTMap) {
+ for (auto &LPTMapEntry : LPTMap) {
const FunctionDecl *FD = LPTMapEntry.first;
- LateParsedTemplate *LPT = LPTMapEntry.second;
+ LateParsedTemplate &LPT = *LPTMapEntry.second;
AddDeclRef(FD, Record);
- AddDeclRef(LPT->D, Record);
- Record.push_back(LPT->Toks.size());
+ AddDeclRef(LPT.D, Record);
+ Record.push_back(LPT.Toks.size());
- for (const auto &Tok : LPT->Toks) {
+ for (const auto &Tok : LPT.Toks) {
AddToken(Tok, Record);
}
}
@@ -4255,9 +4408,10 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
// Build a record containing some declaration references.
RecordData SemaDeclRefs;
- if (SemaRef.StdNamespace || SemaRef.StdBadAlloc) {
+ if (SemaRef.StdNamespace || SemaRef.StdBadAlloc || SemaRef.StdAlignValT) {
AddDeclRef(SemaRef.getStdNamespace(), SemaDeclRefs);
AddDeclRef(SemaRef.getStdBadAlloc(), SemaDeclRefs);
+ AddDeclRef(SemaRef.getStdAlignValT(), SemaDeclRefs);
}
RecordData CUDASpecialDeclRefs;
@@ -4364,8 +4518,9 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
Number.second));
// Make sure visible decls, added to DeclContexts previously loaded from
- // an AST file, are registered for serialization.
- for (const auto *I : UpdatingVisibleDecls) {
+ // an AST file, are registered for serialization. Likewise for template
+ // specializations added to imported templates.
+ for (const auto *I : DeclsToEmitEvenIfUnreferenced) {
GetDeclRef(I);
}
@@ -4510,11 +4665,25 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
WriteIdentifierTable(PP, SemaRef.IdResolver, isModule);
WriteFPPragmaOptions(SemaRef.getFPOptions());
WriteOpenCLExtensions(SemaRef);
+ WriteOpenCLExtensionTypes(SemaRef);
+ WriteOpenCLExtensionDecls(SemaRef);
+ WriteCUDAPragmas(SemaRef);
WritePragmaDiagnosticMappings(Context.getDiagnostics(), isModule);
// If we're emitting a module, write out the submodule information.
if (WritingModule)
WriteSubmodules(WritingModule);
+ else if (!getLangOpts().CurrentModule.empty()) {
+ // If we're building a PCH in the implementation of a module, we may need
+ // the description of the current module.
+ //
+ // FIXME: We may need other modules that we did not load from an AST file,
+ // such as if a module declares a 'conflicts' on a different module.
+ Module *M = PP.getHeaderSearchInfo().getModuleMap().findModule(
+ getLangOpts().CurrentModule);
+ if (M && !M->IsFromModuleFile)
+ WriteSubmodules(M);
+ }
Stream.EmitRecord(SPECIAL_TYPES, SpecialTypes);
@@ -4682,6 +4851,11 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
break;
+ case UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER:
+ Record.AddStmt(
+ cast<FieldDecl>(Update.getDecl())->getInClassInitializer());
+ break;
+
case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
auto *RD = cast<CXXRecordDecl>(D);
UpdatedDeclContexts.insert(RD->getPrimaryContext());
@@ -5159,7 +5333,7 @@ void ASTRecordWriter::AddDeclarationNameInfo(
void ASTRecordWriter::AddQualifierInfo(const QualifierInfo &Info) {
AddNestedNameSpecifierLoc(Info.QualifierLoc);
Record->push_back(Info.NumTemplParamLists);
- for (unsigned i=0, e=Info.NumTemplParamLists; i != e; ++i)
+ for (unsigned i = 0, e = Info.NumTemplParamLists; i != e; ++i)
AddTemplateParameterList(Info.TemplParamLists[i]);
}
@@ -5361,6 +5535,7 @@ void ASTRecordWriter::AddTemplateParameterList(
AddSourceLocation(TemplateParams->getTemplateLoc());
AddSourceLocation(TemplateParams->getLAngleLoc());
AddSourceLocation(TemplateParams->getRAngleLoc());
+ // TODO: Concepts
Record->push_back(TemplateParams->size());
for (const auto &P : *TemplateParams)
AddDeclRef(P);
@@ -5371,7 +5546,7 @@ void ASTRecordWriter::AddTemplateArgumentList(
const TemplateArgumentList *TemplateArgs) {
assert(TemplateArgs && "No TemplateArgs!");
Record->push_back(TemplateArgs->size());
- for (int i=0, e = TemplateArgs->size(); i != e; ++i)
+ for (int i = 0, e = TemplateArgs->size(); i != e; ++i)
AddTemplateArgument(TemplateArgs->get(i));
}
@@ -5382,7 +5557,7 @@ void ASTRecordWriter::AddASTTemplateArgumentListInfo(
AddSourceLocation(ASTTemplArgList->RAngleLoc);
Record->push_back(ASTTemplArgList->NumTemplateArgs);
const TemplateArgumentLoc *TemplArgs = ASTTemplArgList->getTemplateArgs();
- for (int i=0, e = ASTTemplArgList->NumTemplateArgs; i != e; ++i)
+ for (int i = 0, e = ASTTemplArgList->NumTemplateArgs; i != e; ++i)
AddTemplateArgumentLoc(TemplArgs[i]);
}
@@ -5452,13 +5627,8 @@ EmitCXXCtorInitializers(ASTWriter &W,
Writer.AddSourceLocation(Init->getLParenLoc());
Writer.AddSourceLocation(Init->getRParenLoc());
Writer.push_back(Init->isWritten());
- if (Init->isWritten()) {
+ if (Init->isWritten())
Writer.push_back(Init->getSourceOrder());
- } else {
- Writer.push_back(Init->getNumArrayIndices());
- for (auto *VD : Init->getArrayIndices())
- Writer.AddDeclRef(VD);
- }
}
return Writer.Emit(serialization::DECL_CXX_CTOR_INITIALIZERS);
@@ -5539,7 +5709,7 @@ void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
Record->push_back(Lambda.NumCaptures);
Record->push_back(Lambda.NumExplicitCaptures);
Record->push_back(Lambda.ManglingNumber);
- AddDeclRef(Lambda.ContextDecl);
+ AddDeclRef(D->getLambdaContextDecl());
AddTypeSourceInfo(Lambda.MethodTyInfo);
for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
const LambdaCapture &Capture = Lambda.Captures[I];
@@ -5693,9 +5863,9 @@ void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
// that we write out all of its lookup results so we don't get a nasty
// surprise when we try to emit its lookup table.
for (auto *Child : DC->decls())
- UpdatingVisibleDecls.push_back(Child);
+ DeclsToEmitEvenIfUnreferenced.push_back(Child);
}
- UpdatingVisibleDecls.push_back(D);
+ DeclsToEmitEvenIfUnreferenced.push_back(D);
}
void ASTWriter::AddedCXXImplicitMember(const CXXRecordDecl *RD, const Decl *D) {
@@ -5794,6 +5964,15 @@ void ASTWriter::DefaultArgumentInstantiated(const ParmVarDecl *D) {
DeclUpdate(UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT, D));
}
+void ASTWriter::DefaultMemberInitializerInstantiated(const FieldDecl *D) {
+ assert(!WritingAST && "Already writing the AST!");
+ if (!D->isFromASTFile())
+ return;
+
+ DeclUpdates[D].push_back(
+ DeclUpdate(UPD_CXX_INSTANTIATED_DEFAULT_MEMBER_INITIALIZER, D));
+}
+
void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
const ObjCInterfaceDecl *IFD) {
if (Chain && Chain->isProcessingUpdateRecords()) return;
@@ -5855,3 +6034,39 @@ void ASTWriter::AddedAttributeToRecord(const Attr *Attr,
return;
DeclUpdates[Record].push_back(DeclUpdate(UPD_ADDED_ATTR_TO_RECORD, Attr));
}
+
+void ASTWriter::AddedCXXTemplateSpecialization(
+ const ClassTemplateDecl *TD, const ClassTemplateSpecializationDecl *D) {
+ assert(!WritingAST && "Already writing the AST!");
+
+ if (!TD->getFirstDecl()->isFromASTFile())
+ return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
+
+ DeclsToEmitEvenIfUnreferenced.push_back(D);
+}
+
+void ASTWriter::AddedCXXTemplateSpecialization(
+ const VarTemplateDecl *TD, const VarTemplateSpecializationDecl *D) {
+ assert(!WritingAST && "Already writing the AST!");
+
+ if (!TD->getFirstDecl()->isFromASTFile())
+ return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
+
+ DeclsToEmitEvenIfUnreferenced.push_back(D);
+}
+
+void ASTWriter::AddedCXXTemplateSpecialization(const FunctionTemplateDecl *TD,
+ const FunctionDecl *D) {
+ assert(!WritingAST && "Already writing the AST!");
+
+ if (!TD->getFirstDecl()->isFromASTFile())
+ return;
+ if (Chain && Chain->isProcessingUpdateRecords())
+ return;
+
+ DeclsToEmitEvenIfUnreferenced.push_back(D);
+}
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp
index 23d18540e822..ee220f00a81f 100644
--- a/lib/Serialization/ASTWriterDecl.cpp
+++ b/lib/Serialization/ASTWriterDecl.cpp
@@ -11,7 +11,6 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Serialization/ASTWriter.h"
#include "ASTCommon.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclContextInternals.h"
@@ -20,7 +19,7 @@
#include "clang/AST/Expr.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Serialization/ASTReader.h"
-#include "llvm/ADT/Twine.h"
+#include "clang/Serialization/ASTWriter.h"
#include "llvm/Bitcode/BitstreamWriter.h"
#include "llvm/Support/ErrorHandling.h"
using namespace clang;
@@ -97,6 +96,8 @@ namespace clang {
void VisitVarDecl(VarDecl *D);
void VisitImplicitParamDecl(ImplicitParamDecl *D);
void VisitParmVarDecl(ParmVarDecl *D);
+ void VisitDecompositionDecl(DecompositionDecl *D);
+ void VisitBindingDecl(BindingDecl *D);
void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
void VisitTemplateDecl(TemplateDecl *D);
void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
@@ -106,9 +107,11 @@ namespace clang {
void VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D);
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
void VisitUsingDecl(UsingDecl *D);
+ void VisitUsingPackDecl(UsingPackDecl *D);
void VisitUsingShadowDecl(UsingShadowDecl *D);
void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
+ void VisitExportDecl(ExportDecl *D);
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
void VisitImportDecl(ImportDecl *D);
void VisitAccessSpecDecl(AccessSpecDecl *D);
@@ -892,6 +895,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
Record.push_back(D->getTSCSpec());
Record.push_back(D->getInitStyle());
if (!isa<ParmVarDecl>(D)) {
+ Record.push_back(D->isThisDeclarationADemotedDefinition());
Record.push_back(D->isExceptionVariable());
Record.push_back(D->isNRVOVariable());
Record.push_back(D->isCXXForRangeDecl());
@@ -940,10 +944,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
D->getDeclName().getNameKind() == DeclarationName::Identifier &&
!D->hasExtInfo() &&
D->getFirstDecl() == D->getMostRecentDecl() &&
- D->getInitStyle() == VarDecl::CInit &&
- D->getInit() == nullptr &&
- !isa<ParmVarDecl>(D) &&
- !isa<VarTemplateSpecializationDecl>(D) &&
+ D->getKind() == Decl::Var &&
!D->isInline() &&
!D->isConstexpr() &&
!D->isInitCapture() &&
@@ -999,6 +1000,8 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
// Check things we know are true of *every* PARM_VAR_DECL, which is more than
// just us assuming it.
assert(!D->getTSCSpec() && "PARM_VAR_DECL can't use TLS");
+ assert(!D->isThisDeclarationADemotedDefinition()
+ && "PARM_VAR_DECL can't be demoted definition.");
assert(D->getAccess() == AS_none && "PARM_VAR_DECL can't be public/private");
assert(!D->isExceptionVariable() && "PARM_VAR_DECL can't be exception var");
assert(D->getPreviousDecl() == nullptr && "PARM_VAR_DECL can't be redecl");
@@ -1006,6 +1009,22 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
"PARM_VAR_DECL can't be static data member");
}
+void ASTDeclWriter::VisitDecompositionDecl(DecompositionDecl *D) {
+ // Record the number of bindings first to simplify deserialization.
+ Record.push_back(D->bindings().size());
+
+ VisitVarDecl(D);
+ for (auto *B : D->bindings())
+ Record.AddDeclRef(B);
+ Code = serialization::DECL_DECOMPOSITION;
+}
+
+void ASTDeclWriter::VisitBindingDecl(BindingDecl *D) {
+ VisitValueDecl(D);
+ Record.AddStmt(D->getBinding());
+ Code = serialization::DECL_BINDING;
+}
+
void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
VisitDecl(D);
Record.AddStmt(D->getAsmString());
@@ -1064,6 +1083,12 @@ void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
Code = serialization::DECL_LINKAGE_SPEC;
}
+void ASTDeclWriter::VisitExportDecl(ExportDecl *D) {
+ VisitDecl(D);
+ Record.AddSourceLocation(D->getRBraceLoc());
+ Code = serialization::DECL_EXPORT;
+}
+
void ASTDeclWriter::VisitLabelDecl(LabelDecl *D) {
VisitNamedDecl(D);
Record.AddSourceLocation(D->getLocStart());
@@ -1118,6 +1143,15 @@ void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) {
Code = serialization::DECL_USING;
}
+void ASTDeclWriter::VisitUsingPackDecl(UsingPackDecl *D) {
+ Record.push_back(D->NumExpansions);
+ VisitNamedDecl(D);
+ Record.AddDeclRef(D->getInstantiatedFromUsingDecl());
+ for (auto *E : D->expansions())
+ Record.AddDeclRef(E);
+ Code = serialization::DECL_USING_PACK;
+}
+
void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {
VisitRedeclarable(D);
VisitNamedDecl(D);
@@ -1151,6 +1185,7 @@ void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
Record.AddSourceLocation(D->getUsingLoc());
Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
+ Record.AddSourceLocation(D->getEllipsisLoc());
Code = serialization::DECL_UNRESOLVED_USING_VALUE;
}
@@ -1159,6 +1194,7 @@ void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl(
VisitTypeDecl(D);
Record.AddSourceLocation(D->getTypenameLoc());
Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
+ Record.AddSourceLocation(D->getEllipsisLoc());
Code = serialization::DECL_UNRESOLVED_USING_TYPENAME;
}
@@ -1857,9 +1893,9 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
// VarDecl
- Abv->Add(BitCodeAbbrevOp(0)); // StorageClass
- Abv->Add(BitCodeAbbrevOp(0)); // getTSCSpec
- Abv->Add(BitCodeAbbrevOp(0)); // hasCXXDirectInitializer
+ Abv->Add(BitCodeAbbrevOp(0)); // SClass
+ Abv->Add(BitCodeAbbrevOp(0)); // TSCSpec
+ Abv->Add(BitCodeAbbrevOp(0)); // InitStyle
Abv->Add(BitCodeAbbrevOp(0)); // Linkage
Abv->Add(BitCodeAbbrevOp(0)); // HasInit
Abv->Add(BitCodeAbbrevOp(0)); // HasMemberSpecializationInfo
@@ -1933,9 +1969,10 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // InnerStartLoc
Abv->Add(BitCodeAbbrevOp(0)); // hasExtInfo
// VarDecl
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // StorageClass
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // getTSCSpec
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // CXXDirectInitializer
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // SClass
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // TSCSpec
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // InitStyle
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsThisDeclarationADemotedDefinition
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isExceptionVariable
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
@@ -1946,8 +1983,8 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasInit
- Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // HasMemberSpecInfo
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // IsInitICE (local)
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // VarKind (local enum)
// Type Source Info
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
@@ -2123,11 +2160,11 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context,
D->hasAttr<OMPDeclareTargetDeclAttr>())
return true;
- // ImportDecl is used by codegen to determine the set of imported modules to
- // search for inputs for automatic linking; include it if it has a semantic
- // effect.
- if (isa<ImportDecl>(D) && !WritingModule)
- return true;
+ if (WritingModule && (isa<VarDecl>(D) || isa<ImportDecl>(D))) {
+ // These declarations are part of the module initializer, and are emitted
+ // if and when the module is imported, rather than being emitted eagerly.
+ return false;
+ }
return Context.DeclMustBeEmitted(D);
}
diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp
index 84e718e9ef23..3993be146edf 100644
--- a/lib/Serialization/ASTWriterStmt.cpp
+++ b/lib/Serialization/ASTWriterStmt.cpp
@@ -792,6 +792,18 @@ void ASTStmtWriter::VisitNoInitExpr(NoInitExpr *E) {
Code = serialization::EXPR_NO_INIT;
}
+void ASTStmtWriter::VisitArrayInitLoopExpr(ArrayInitLoopExpr *E) {
+ VisitExpr(E);
+ Record.AddStmt(E->SubExprs[0]);
+ Record.AddStmt(E->SubExprs[1]);
+ Code = serialization::EXPR_ARRAY_INIT_LOOP;
+}
+
+void ASTStmtWriter::VisitArrayInitIndexExpr(ArrayInitIndexExpr *E) {
+ VisitExpr(E);
+ Code = serialization::EXPR_ARRAY_INIT_INDEX;
+}
+
void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
VisitExpr(E);
Code = serialization::EXPR_IMPLICIT_VALUE_INIT;
@@ -1245,10 +1257,6 @@ void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
VisitExpr(E);
Record.push_back(E->NumCaptures);
- unsigned NumArrayIndexVars = 0;
- if (E->HasArrayIndexVars)
- NumArrayIndexVars = E->getArrayIndexStarts()[E->NumCaptures];
- Record.push_back(NumArrayIndexVars);
Record.AddSourceRange(E->IntroducerRange);
Record.push_back(E->CaptureDefault); // FIXME: stable encoding
Record.AddSourceLocation(E->CaptureDefaultLoc);
@@ -1263,15 +1271,6 @@ void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
Record.AddStmt(*C);
}
- // Add array index variables, if any.
- if (NumArrayIndexVars) {
- Record.append(E->getArrayIndexStarts(),
- E->getArrayIndexStarts() + E->NumCaptures + 1);
- VarDecl **ArrayIndexVars = E->getArrayIndexVars();
- for (unsigned I = 0; I != NumArrayIndexVars; ++I)
- Record.AddDeclRef(ArrayIndexVars[I]);
- }
-
Code = serialization::EXPR_LAMBDA;
}
@@ -1392,6 +1391,7 @@ void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
VisitExpr(E);
Record.push_back(E->isGlobalNew());
Record.push_back(E->isArray());
+ Record.push_back(E->passAlignment());
Record.push_back(E->doesUsualArrayDeleteWantSize());
Record.push_back(E->getNumPlacementArgs());
Record.push_back(E->StoredInitializationStyle);
@@ -1576,6 +1576,7 @@ void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
Record.push_back(E->getValue());
Record.AddSourceRange(E->getSourceRange());
Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo());
+ Record.AddStmt(E->getDimensionExpression());
Code = serialization::EXPR_ARRAY_TYPE_TRAIT;
}
@@ -2151,17 +2152,45 @@ void OMPClauseWriter::VisitOMPFromClause(OMPFromClause *C) {
void OMPClauseWriter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
Record.push_back(C->varlist_size());
+ Record.push_back(C->getUniqueDeclarationsNum());
+ Record.push_back(C->getTotalComponentListNum());
+ Record.push_back(C->getTotalComponentsNum());
Record.AddSourceLocation(C->getLParenLoc());
- for (auto *VE : C->varlists()) {
+ for (auto *E : C->varlists())
+ Record.AddStmt(E);
+ for (auto *VE : C->private_copies())
+ Record.AddStmt(VE);
+ for (auto *VE : C->inits())
Record.AddStmt(VE);
+ for (auto *D : C->all_decls())
+ Record.AddDeclRef(D);
+ for (auto N : C->all_num_lists())
+ Record.push_back(N);
+ for (auto N : C->all_lists_sizes())
+ Record.push_back(N);
+ for (auto &M : C->all_components()) {
+ Record.AddStmt(M.getAssociatedExpression());
+ Record.AddDeclRef(M.getAssociatedDeclaration());
}
}
void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
Record.push_back(C->varlist_size());
+ Record.push_back(C->getUniqueDeclarationsNum());
+ Record.push_back(C->getTotalComponentListNum());
+ Record.push_back(C->getTotalComponentsNum());
Record.AddSourceLocation(C->getLParenLoc());
- for (auto *VE : C->varlists()) {
- Record.AddStmt(VE);
+ for (auto *E : C->varlists())
+ Record.AddStmt(E);
+ for (auto *D : C->all_decls())
+ Record.AddDeclRef(D);
+ for (auto N : C->all_num_lists())
+ Record.push_back(N);
+ for (auto N : C->all_lists_sizes())
+ Record.push_back(N);
+ for (auto &M : C->all_components()) {
+ Record.AddStmt(M.getAssociatedExpression());
+ Record.AddDeclRef(M.getAssociatedDeclaration());
}
}
@@ -2479,6 +2508,54 @@ void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective(
Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE;
}
+void ASTStmtWriter::VisitOMPTargetSimdDirective(OMPTargetSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TARGET_SIMD_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTeamsDistributeDirective(
+ OMPTeamsDistributeDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTeamsDistributeSimdDirective(
+ OMPTeamsDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_SIMD_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTeamsDistributeParallelForSimdDirective(
+ OMPTeamsDistributeParallelForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTeamsDistributeParallelForDirective(
+ OMPTeamsDistributeParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTargetTeamsDirective(OMPTargetTeamsDirective *D) {
+ VisitStmt(D);
+ Record.push_back(D->getNumClauses());
+ VisitOMPExecutableDirective(D);
+ Code = serialization::STMT_OMP_TARGET_TEAMS_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTargetTeamsDistributeDirective(
+ OMPTargetTeamsDistributeDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTargetTeamsDistributeParallelForDirective(
+ OMPTargetTeamsDistributeParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TARGET_TEAMS_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
+}
+
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp
index 308fde8b1dd7..e1765dafd96f 100644
--- a/lib/Serialization/GeneratePCH.cpp
+++ b/lib/Serialization/GeneratePCH.cpp
@@ -12,24 +12,21 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/Serialization/ASTWriter.h"
-#include "clang/AST/ASTConsumer.h"
#include "clang/AST/ASTContext.h"
-#include "clang/Basic/FileManager.h"
+#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/SemaConsumer.h"
+#include "clang/Serialization/ASTWriter.h"
#include "llvm/Bitcode/BitstreamWriter.h"
-#include <string>
using namespace clang;
PCHGenerator::PCHGenerator(
- const Preprocessor &PP, StringRef OutputFile,
- clang::Module *Module, StringRef isysroot,
- std::shared_ptr<PCHBuffer> Buffer,
- ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
- bool AllowASTWithErrors, bool IncludeTimestamps)
- : PP(PP), OutputFile(OutputFile), Module(Module), isysroot(isysroot.str()),
+ const Preprocessor &PP, StringRef OutputFile, StringRef isysroot,
+ std::shared_ptr<PCHBuffer> Buffer,
+ ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>> Extensions,
+ bool AllowASTWithErrors, bool IncludeTimestamps)
+ : PP(PP), OutputFile(OutputFile), isysroot(isysroot.str()),
SemaPtr(nullptr), Buffer(Buffer), Stream(Buffer->Data),
Writer(Stream, Extensions, IncludeTimestamps),
AllowASTWithErrors(AllowASTWithErrors) {
@@ -48,6 +45,16 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
if (hasErrors && !AllowASTWithErrors)
return;
+ Module *Module = nullptr;
+ if (PP.getLangOpts().isCompilingModule()) {
+ Module = PP.getHeaderSearchInfo().lookupModule(
+ PP.getLangOpts().CurrentModule, /*AllowSearch*/ false);
+ if (!Module) {
+ assert(hasErrors && "emitting module but current module doesn't exist");
+ return;
+ }
+ }
+
// Emit the PCH file to the Buffer.
assert(SemaPtr && "No Sema?");
Buffer->Signature =
diff --git a/lib/Serialization/GlobalModuleIndex.cpp b/lib/Serialization/GlobalModuleIndex.cpp
index 581e894d9150..9f986d54a989 100644
--- a/lib/Serialization/GlobalModuleIndex.cpp
+++ b/lib/Serialization/GlobalModuleIndex.cpp
@@ -245,12 +245,8 @@ GlobalModuleIndex::readIndex(StringRef Path) {
return std::make_pair(nullptr, EC_NotFound);
std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(BufferOrErr.get());
- /// \brief The bitstream reader from which we'll read the AST file.
- llvm::BitstreamReader Reader((const unsigned char *)Buffer->getBufferStart(),
- (const unsigned char *)Buffer->getBufferEnd());
-
/// \brief The main bitstream cursor for the main block.
- llvm::BitstreamCursor Cursor(Reader);
+ llvm::BitstreamCursor Cursor(*Buffer);
// Sniff for the signature.
if (Cursor.Read(8) != 'B' ||
@@ -460,7 +456,7 @@ static void emitRecordID(unsigned ID, const char *Name,
void
GlobalModuleIndexBuilder::emitBlockInfoBlock(llvm::BitstreamWriter &Stream) {
SmallVector<uint64_t, 64> Record;
- Stream.EnterSubblock(llvm::bitc::BLOCKINFO_BLOCK_ID, 3);
+ Stream.EnterBlockInfoBlock();
#define BLOCK(X) emitBlockID(X ## _ID, #X, Stream, Record)
#define RECORD(X) emitRecordID(X, #X, Stream, Record)
@@ -504,9 +500,7 @@ bool GlobalModuleIndexBuilder::loadModuleFile(const FileEntry *File) {
}
// Initialize the input stream
- llvm::BitstreamReader InStreamFile;
- PCHContainerRdr.ExtractPCH((*Buffer)->getMemBufferRef(), InStreamFile);
- llvm::BitstreamCursor InStream(InStreamFile);
+ llvm::BitstreamCursor InStream(PCHContainerRdr.ExtractPCH(**Buffer));
// Sniff for the signature.
if (InStream.Read(8) != 'C' ||
diff --git a/lib/Serialization/Module.cpp b/lib/Serialization/Module.cpp
index ca0cb3c8ea17..72b08610bb4d 100644
--- a/lib/Serialization/Module.cpp
+++ b/lib/Serialization/Module.cpp
@@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//
#include "clang/Serialization/Module.h"
#include "ASTReaderInternals.h"
-#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
using namespace clang;
diff --git a/lib/Serialization/ModuleFileExtension.cpp b/lib/Serialization/ModuleFileExtension.cpp
index 81dcfd60ce8e..5bd0a1ce660b 100644
--- a/lib/Serialization/ModuleFileExtension.cpp
+++ b/lib/Serialization/ModuleFileExtension.cpp
@@ -8,7 +8,6 @@
//===----------------------------------------------------------------------===//
#include "clang/Serialization/ModuleFileExtension.h"
#include "llvm/ADT/Hashing.h"
-#include "llvm/Support/raw_ostream.h"
using namespace clang;
ModuleFileExtension::~ModuleFileExtension() { }
diff --git a/lib/Serialization/ModuleManager.cpp b/lib/Serialization/ModuleManager.cpp
index 292f36dfeb2a..722b547e803e 100644
--- a/lib/Serialization/ModuleManager.cpp
+++ b/lib/Serialization/ModuleManager.cpp
@@ -11,14 +11,13 @@
// modules for the ASTReader.
//
//===----------------------------------------------------------------------===//
+#include "clang/Serialization/ModuleManager.h"
#include "clang/Frontend/PCHContainerOperations.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/ModuleMap.h"
#include "clang/Serialization/GlobalModuleIndex.h"
-#include "clang/Serialization/ModuleManager.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/raw_ostream.h"
#include <system_error>
#ifndef NDEBUG
@@ -67,7 +66,7 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
// Look for the file entry. This only fails if the expected size or
// modification time differ.
const FileEntry *Entry;
- if (Type == MK_ExplicitModule) {
+ if (Type == MK_ExplicitModule || Type == MK_PrebuiltModule) {
// If we're not expecting to pull this file out of the module cache, it
// might have a different mtime due to being moved across filesystems in
// a distributed build. The size must still match, though. (As must the
@@ -85,37 +84,31 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
}
// Check whether we already loaded this module, before
- ModuleFile *&ModuleEntry = Modules[Entry];
+ ModuleFile *ModuleEntry = Modules[Entry];
bool NewModule = false;
if (!ModuleEntry) {
// Allocate a new module.
- ModuleFile *New = new ModuleFile(Type, Generation);
- New->Index = Chain.size();
- New->FileName = FileName.str();
- New->File = Entry;
- New->ImportLoc = ImportLoc;
- Chain.push_back(New);
- if (!New->isModule())
- PCHChain.push_back(New);
- if (!ImportedBy)
- Roots.push_back(New);
NewModule = true;
- ModuleEntry = New;
-
- New->InputFilesValidationTimestamp = 0;
- if (New->Kind == MK_ImplicitModule) {
- std::string TimestampFilename = New->getTimestampFilename();
+ ModuleEntry = new ModuleFile(Type, Generation);
+ ModuleEntry->Index = Chain.size();
+ ModuleEntry->FileName = FileName.str();
+ ModuleEntry->File = Entry;
+ ModuleEntry->ImportLoc = ImportLoc;
+ ModuleEntry->InputFilesValidationTimestamp = 0;
+
+ if (ModuleEntry->Kind == MK_ImplicitModule) {
+ std::string TimestampFilename = ModuleEntry->getTimestampFilename();
vfs::Status Status;
// A cached stat value would be fine as well.
if (!FileMgr.getNoncachedStatValue(TimestampFilename, Status))
- New->InputFilesValidationTimestamp =
- Status.getLastModificationTime().toEpochTime();
+ ModuleEntry->InputFilesValidationTimestamp =
+ llvm::sys::toTimeT(Status.getLastModificationTime());
}
// Load the contents of the module
if (std::unique_ptr<llvm::MemoryBuffer> Buffer = lookupBuffer(FileName)) {
// The buffer was already provided for us.
- New->Buffer = std::move(Buffer);
+ ModuleEntry->Buffer = std::move(Buffer);
} else {
// Open the AST file.
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> Buf(
@@ -127,52 +120,40 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
// ModuleManager it must be the same underlying file.
// FIXME: Because FileManager::getFile() doesn't guarantee that it will
// give us an open file, this may not be 100% reliable.
- Buf = FileMgr.getBufferForFile(New->File,
+ Buf = FileMgr.getBufferForFile(ModuleEntry->File,
/*IsVolatile=*/false,
/*ShouldClose=*/false);
}
if (!Buf) {
ErrorStr = Buf.getError().message();
+ delete ModuleEntry;
return Missing;
}
- New->Buffer = std::move(*Buf);
+ ModuleEntry->Buffer = std::move(*Buf);
}
// Initialize the stream.
- PCHContainerRdr.ExtractPCH(New->Buffer->getMemBufferRef(), New->StreamFile);
+ ModuleEntry->Data = PCHContainerRdr.ExtractPCH(*ModuleEntry->Buffer);
}
if (ExpectedSignature) {
- if (NewModule)
- ModuleEntry->Signature = ReadSignature(ModuleEntry->StreamFile);
- else
- assert(ModuleEntry->Signature == ReadSignature(ModuleEntry->StreamFile));
+ // If we've not read the control block yet, read the signature eagerly now
+ // so that we can check it.
+ if (!ModuleEntry->Signature)
+ ModuleEntry->Signature = ReadSignature(ModuleEntry->Data);
if (ModuleEntry->Signature != ExpectedSignature) {
ErrorStr = ModuleEntry->Signature ? "signature mismatch"
: "could not read module signature";
- if (NewModule) {
- // Remove the module file immediately, since removeModules might try to
- // invalidate the file cache for Entry, and that is not safe if this
- // module is *itself* up to date, but has an out-of-date importer.
- Modules.erase(Entry);
- assert(Chain.back() == ModuleEntry);
- Chain.pop_back();
- if (!ModuleEntry->isModule())
- PCHChain.pop_back();
- if (Roots.back() == ModuleEntry)
- Roots.pop_back();
- else
- assert(ImportedBy);
+ if (NewModule)
delete ModuleEntry;
- }
return OutOfDate;
}
}
-
+
if (ImportedBy) {
ModuleEntry->ImportedBy.insert(ImportedBy);
ImportedBy->Imports.insert(ModuleEntry);
@@ -184,7 +165,20 @@ ModuleManager::addModule(StringRef FileName, ModuleKind Type,
}
Module = ModuleEntry;
- return NewModule? NewlyLoaded : AlreadyLoaded;
+
+ if (!NewModule)
+ return AlreadyLoaded;
+
+ assert(!Modules[Entry] && "module loaded twice");
+ Modules[Entry] = ModuleEntry;
+
+ Chain.push_back(ModuleEntry);
+ if (!ModuleEntry->isModule())
+ PCHChain.push_back(ModuleEntry);
+ if (!ImportedBy)
+ Roots.push_back(ModuleEntry);
+
+ return NewlyLoaded;
}
void ModuleManager::removeModules(
@@ -413,13 +407,16 @@ bool ModuleManager::lookupModuleFile(StringRef FileName,
off_t ExpectedSize,
time_t ExpectedModTime,
const FileEntry *&File) {
+ if (FileName == "-") {
+ File = nullptr;
+ return false;
+ }
+
// Open the file immediately to ensure there is no race between stat'ing and
// opening the file.
File = FileMgr.getFile(FileName, /*openFile=*/true, /*cacheFailure=*/false);
-
- if (!File && FileName != "-") {
+ if (!File)
return false;
- }
if ((ExpectedSize && ExpectedSize != File->getSize()) ||
(ExpectedModTime && ExpectedModTime != File->getModificationTime()))
@@ -434,15 +431,15 @@ bool ModuleManager::lookupModuleFile(StringRef FileName,
namespace llvm {
template<>
struct GraphTraits<ModuleManager> {
- typedef ModuleFile NodeType;
+ typedef ModuleFile *NodeRef;
typedef llvm::SetVector<ModuleFile *>::const_iterator ChildIteratorType;
typedef ModuleManager::ModuleConstIterator nodes_iterator;
-
- static ChildIteratorType child_begin(NodeType *Node) {
+
+ static ChildIteratorType child_begin(NodeRef Node) {
return Node->Imports.begin();
}
- static ChildIteratorType child_end(NodeType *Node) {
+ static ChildIteratorType child_end(NodeRef Node) {
return Node->Imports.end();
}
diff --git a/lib/Serialization/MultiOnDiskHashTable.h b/lib/Serialization/MultiOnDiskHashTable.h
index 04dea831695c..fdbbb602b537 100644
--- a/lib/Serialization/MultiOnDiskHashTable.h
+++ b/lib/Serialization/MultiOnDiskHashTable.h
@@ -18,7 +18,11 @@
#ifndef LLVM_CLANG_LIB_SERIALIZATION_MULTIONDISKHASHTABLE_H
#define LLVM_CLANG_LIB_SERIALIZATION_MULTIONDISKHASHTABLE_H
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/OnDiskHashTable.h"