summaryrefslogtreecommitdiff
path: root/lib/Serialization
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-07-23 20:44:14 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-07-23 20:44:14 +0000
commit2b6b257f4e5503a7a2675bdb8735693db769f75c (patch)
treee85e046ae7003fe3bcc8b5454cd0fa3f7407b470 /lib/Serialization
parentb4348ed0b7e90c0831b925fbee00b5f179a99796 (diff)
Notes
Diffstat (limited to 'lib/Serialization')
-rw-r--r--lib/Serialization/ASTCommon.cpp47
-rw-r--r--lib/Serialization/ASTCommon.h1
-rw-r--r--lib/Serialization/ASTReader.cpp410
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp313
-rw-r--r--lib/Serialization/ASTReaderStmt.cpp383
-rw-r--r--lib/Serialization/ASTWriter.cpp1341
-rw-r--r--lib/Serialization/ASTWriterDecl.cpp699
-rw-r--r--lib/Serialization/ASTWriterStmt.cpp1485
-rw-r--r--lib/Serialization/GeneratePCH.cpp5
-rw-r--r--lib/Serialization/GlobalModuleIndex.cpp2
-rw-r--r--lib/Serialization/Makefile19
-rw-r--r--lib/Serialization/Module.cpp4
-rw-r--r--lib/Serialization/ModuleManager.cpp8
13 files changed, 2697 insertions, 2020 deletions
diff --git a/lib/Serialization/ASTCommon.cpp b/lib/Serialization/ASTCommon.cpp
index 2b78d745864a..22ead2b57c72 100644
--- a/lib/Serialization/ASTCommon.cpp
+++ b/lib/Serialization/ASTCommon.cpp
@@ -91,6 +91,9 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
case BuiltinType::LongDouble:
ID = PREDEF_TYPE_LONGDOUBLE_ID;
break;
+ case BuiltinType::Float128:
+ ID = PREDEF_TYPE_FLOAT128_ID;
+ break;
case BuiltinType::NullPtr:
ID = PREDEF_TYPE_NULLPTR_ID;
break;
@@ -127,42 +130,11 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
case BuiltinType::ObjCSel:
ID = PREDEF_TYPE_OBJC_SEL;
break;
- case BuiltinType::OCLImage1d:
- ID = PREDEF_TYPE_IMAGE1D_ID;
- break;
- case BuiltinType::OCLImage1dArray:
- ID = PREDEF_TYPE_IMAGE1D_ARR_ID;
- break;
- case BuiltinType::OCLImage1dBuffer:
- ID = PREDEF_TYPE_IMAGE1D_BUFF_ID;
- break;
- case BuiltinType::OCLImage2d:
- ID = PREDEF_TYPE_IMAGE2D_ID;
- break;
- case BuiltinType::OCLImage2dArray:
- ID = PREDEF_TYPE_IMAGE2D_ARR_ID;
- break;
- case BuiltinType::OCLImage2dDepth:
- ID = PREDEF_TYPE_IMAGE2D_DEP_ID;
- break;
- case BuiltinType::OCLImage2dArrayDepth:
- ID = PREDEF_TYPE_IMAGE2D_ARR_DEP_ID;
- break;
- case BuiltinType::OCLImage2dMSAA:
- ID = PREDEF_TYPE_IMAGE2D_MSAA_ID;
- break;
- case BuiltinType::OCLImage2dArrayMSAA:
- ID = PREDEF_TYPE_IMAGE2D_ARR_MSAA_ID;
- break;
- case BuiltinType::OCLImage2dMSAADepth:
- ID = PREDEF_TYPE_IMAGE2D_MSAA_DEP_ID;
- break;
- case BuiltinType::OCLImage2dArrayMSAADepth:
- ID = PREDEF_TYPE_IMAGE2D_ARR_MSAA_DEPTH_ID;
- break;
- case BuiltinType::OCLImage3d:
- ID = PREDEF_TYPE_IMAGE3D_ID;
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+ case BuiltinType::Id: \
+ ID = PREDEF_TYPE_##Id##_ID; \
break;
+#include "clang/Basic/OpenCLImageTypes.def"
case BuiltinType::OCLSampler:
ID = PREDEF_TYPE_SAMPLER_ID;
break;
@@ -286,6 +258,7 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) {
case Decl::CXXDestructor:
case Decl::CXXConversion:
case Decl::UsingShadow:
+ case Decl::ConstructorUsingShadow:
case Decl::Var:
case Decl::FunctionTemplate:
case Decl::ClassTemplate:
@@ -319,6 +292,8 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) {
case Decl::ObjCCompatibleAlias:
case Decl::LinkageSpec:
case Decl::ObjCPropertyImpl:
+ case Decl::PragmaComment:
+ case Decl::PragmaDetectMismatch:
case Decl::FileScopeAsm:
case Decl::AccessSpec:
case Decl::Friend:
@@ -329,6 +304,8 @@ bool serialization::isRedeclarableDeclKind(unsigned Kind) {
case Decl::ClassScopeFunctionSpecialization:
case Decl::Import:
case Decl::OMPThreadPrivate:
+ case Decl::OMPCapturedExpr:
+ case Decl::OMPDeclareReduction:
case Decl::BuiltinTemplate:
return false;
diff --git a/lib/Serialization/ASTCommon.h b/lib/Serialization/ASTCommon.h
index 64f583c98728..641165e4178f 100644
--- a/lib/Serialization/ASTCommon.h
+++ b/lib/Serialization/ASTCommon.h
@@ -37,6 +37,7 @@ enum DeclUpdateKind {
UPD_MANGLING_NUMBER,
UPD_STATIC_LOCAL_NUMBER,
UPD_DECL_MARKED_OPENMP_THREADPRIVATE,
+ UPD_DECL_MARKED_OPENMP_DECLARETARGET,
UPD_DECL_EXPORTED,
UPD_ADDED_ATTR_TO_RECORD
};
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index 833ff57e4d0b..b35bd7bd329b 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -48,6 +48,7 @@
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Support/Compression.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -216,8 +217,13 @@ static bool checkLanguageOptions(const LangOptions &LangOpts,
if (!AllowCompatibleDifferences) \
ENUM_LANGOPT(Name, Bits, Default, Description)
+#define COMPATIBLE_VALUE_LANGOPT(Name, Bits, Default, Description) \
+ if (!AllowCompatibleDifferences) \
+ VALUE_LANGOPT(Name, Bits, Default, Description)
+
#define BENIGN_LANGOPT(Name, Bits, Default, Description)
#define BENIGN_ENUM_LANGOPT(Name, Type, Bits, Default, Description)
+#define BENIGN_VALUE_LANGOPT(Name, Type, Bits, Default, Description)
#include "clang/Basic/LangOptions.def"
if (ExistingLangOpts.ModuleFeatures != LangOpts.ModuleFeatures) {
@@ -768,6 +774,15 @@ IdentID ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d) {
return Reader.getGlobalIdentifierID(F, RawID >> 1);
}
+static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II) {
+ if (!II.isFromAST()) {
+ II.setIsFromAST();
+ bool IsModule = Reader.getPreprocessor().getCurrentModule() != nullptr;
+ if (isInterestingIdentifier(Reader, II, IsModule))
+ II.setChangedSinceDeserialization();
+ }
+}
+
IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
const unsigned char* d,
unsigned DataLen) {
@@ -784,12 +799,7 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const internal_key_type& k,
II = &Reader.getIdentifierTable().getOwn(k);
KnownII = II;
}
- if (!II->isFromAST()) {
- II->setIsFromAST();
- bool IsModule = Reader.PP.getCurrentModule() != nullptr;
- if (isInterestingIdentifier(Reader, *II, IsModule))
- II->setChangedSinceDeserialization();
- }
+ markIdentifierFromAST(Reader, *II);
Reader.markIdentifierUpToDate(II);
IdentID ID = Reader.getGlobalIdentifierID(F, RawID);
@@ -1199,6 +1209,32 @@ bool ASTReader::ReadSLocEntry(int ID) {
return true;
}
+ // Local helper to read the (possibly-compressed) buffer data following the
+ // entry record.
+ auto ReadBuffer = [this](
+ BitstreamCursor &SLocEntryCursor,
+ StringRef Name) -> std::unique_ptr<llvm::MemoryBuffer> {
+ RecordData Record;
+ StringRef Blob;
+ unsigned Code = SLocEntryCursor.ReadCode();
+ unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
+
+ if (RecCode == SM_SLOC_BUFFER_BLOB_COMPRESSED) {
+ SmallString<0> Uncompressed;
+ if (llvm::zlib::uncompress(Blob, Uncompressed, Record[0]) !=
+ llvm::zlib::StatusOK) {
+ Error("could not decompress embedded file contents");
+ return nullptr;
+ }
+ return llvm::MemoryBuffer::getMemBufferCopy(Uncompressed, Name);
+ } else if (RecCode == SM_SLOC_BUFFER_BLOB) {
+ return llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name, true);
+ } else {
+ Error("AST record has invalid code");
+ return nullptr;
+ }
+ };
+
ModuleFile *F = GlobalSLocEntryMap.find(-ID)->second;
F->SLocEntryCursor.JumpToBit(F->SLocEntryOffsets[ID - F->SLocEntryBaseID]);
BitstreamCursor &SLocEntryCursor = F->SLocEntryCursor;
@@ -1254,24 +1290,16 @@ bool ASTReader::ReadSLocEntry(int ID) {
FileDeclIDs[FID] = FileDeclsInfo(F, llvm::makeArrayRef(FirstDecl,
NumFileDecls));
}
-
+
const SrcMgr::ContentCache *ContentCache
= SourceMgr.getOrCreateContentCache(File,
/*isSystemFile=*/FileCharacter != SrcMgr::C_User);
if (OverriddenBuffer && !ContentCache->BufferOverridden &&
ContentCache->ContentsEntry == ContentCache->OrigEntry &&
!ContentCache->getRawBuffer()) {
- unsigned Code = SLocEntryCursor.ReadCode();
- Record.clear();
- unsigned RecCode = SLocEntryCursor.readRecord(Code, Record, &Blob);
-
- if (RecCode != SM_SLOC_BUFFER_BLOB) {
- Error("AST record has invalid code");
+ auto Buffer = ReadBuffer(SLocEntryCursor, File->getName());
+ if (!Buffer)
return true;
- }
-
- std::unique_ptr<llvm::MemoryBuffer> Buffer
- = llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), File->getName());
SourceMgr.overrideFileContents(File, std::move(Buffer));
}
@@ -1288,18 +1316,10 @@ bool ASTReader::ReadSLocEntry(int ID) {
(F->Kind == MK_ImplicitModule || F->Kind == MK_ExplicitModule)) {
IncludeLoc = getImportLocation(F);
}
- unsigned Code = SLocEntryCursor.ReadCode();
- Record.clear();
- unsigned RecCode
- = SLocEntryCursor.readRecord(Code, Record, &Blob);
- if (RecCode != SM_SLOC_BUFFER_BLOB) {
- Error("AST record has invalid code");
+ auto Buffer = ReadBuffer(SLocEntryCursor, Name);
+ if (!Buffer)
return true;
- }
-
- std::unique_ptr<llvm::MemoryBuffer> Buffer =
- llvm::MemoryBuffer::getMemBuffer(Blob.drop_back(1), Name);
SourceMgr.createFileID(std::move(Buffer), FileCharacter, ID,
BaseOffset + Offset, IncludeLoc);
break;
@@ -1660,9 +1680,12 @@ void ASTReader::ReadDefinedMacros() {
break;
case PP_MACRO_OBJECT_LIKE:
- case PP_MACRO_FUNCTION_LIKE:
- getLocalIdentifier(*I, Record[0]);
+ case PP_MACRO_FUNCTION_LIKE: {
+ IdentifierInfo *II = getLocalIdentifier(*I, Record[0]);
+ if (II->isOutOfDate())
+ updateOutOfDateIdentifier(*II);
break;
+ }
case PP_TOKEN:
// Ignore tokens.
@@ -1987,17 +2010,8 @@ InputFile ASTReader::getInputFile(ModuleFile &F, unsigned ID, bool Complain) {
// For an overridden file, there is nothing to validate.
if (!Overridden && //
(StoredSize != File->getSize() ||
-#if defined(LLVM_ON_WIN32)
- false
-#else
- // In our regression testing, the Windows file system seems to
- // have inconsistent modification times that sometimes
- // erroneously trigger this error-handling path.
- //
- // FIXME: This probably also breaks HeaderFileInfo lookups on Windows.
(StoredTime && StoredTime != File->getModificationTime() &&
!DisableValidation)
-#endif
)) {
if (Complain) {
// Build a list of the PCH imports that got us here (in reverse).
@@ -2254,9 +2268,10 @@ ASTReader::ReadControlBlock(ModuleFile &F,
(AllowConfigurationMismatch && Result == ConfigurationMismatch))
Result = Success;
- // If we've diagnosed a problem, we're done.
- if (Result != Success &&
- isDiagnosedResult(Result, ClientLoadCapabilities))
+ // If we can't load the module, exit early since we likely
+ // will rebuild the module anyway. The stream may be in the
+ // middle of a block.
+ if (Result != Success)
return Result;
} else if (Stream.SkipBlock()) {
Error("malformed block record in AST file");
@@ -2294,6 +2309,11 @@ ASTReader::ReadControlBlock(ModuleFile &F,
Diag(diag::err_pch_with_compiler_errors);
return HadErrors;
}
+ if (hasErrors) {
+ Diags.ErrorOccurred = true;
+ Diags.UncompilableErrorOccurred = true;
+ Diags.UnrecoverableErrorOccurred = true;
+ }
F.RelocatablePCH = Record[4];
// Relative paths in a relocatable PCH are relative to our sysroot.
@@ -2325,9 +2345,9 @@ ASTReader::ReadControlBlock(ModuleFile &F,
ModuleKind ImportedKind = (ModuleKind)Record[Idx++];
// The import location will be the local one for now; we will adjust
// all import locations of module imports after the global source
- // location info are setup.
+ // location info are setup, in ReadAST.
SourceLocation ImportLoc =
- SourceLocation::getFromRawEncoding(Record[Idx++]);
+ ReadUntranslatedSourceLocation(Record[Idx++]);
off_t StoredSize = (off_t)Record[Idx++];
time_t StoredModTime = (time_t)Record[Idx++];
ASTFileSignature StoredSignature = Record[Idx++];
@@ -3017,17 +3037,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
break;
}
- case DECL_REPLACEMENTS: {
- if (Record.size() % 3 != 0) {
- Error("invalid DECL_REPLACEMENTS block in AST file");
- return Failure;
- }
- for (unsigned I = 0, N = Record.size(); I != N; I += 3)
- ReplacedDecls[getGlobalDeclID(F, Record[I])]
- = ReplacedDeclInfo(&F, Record[I+1], Record[I+2]);
- break;
- }
-
case OBJC_CATEGORIES_MAP: {
if (F.LocalNumObjCCategoriesInMap != 0) {
Error("duplicate OBJC_CATEGORIES_MAP record in AST file");
@@ -3043,28 +3052,6 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
F.ObjCCategories.swap(Record);
break;
- case CXX_BASE_SPECIFIER_OFFSETS: {
- if (F.LocalNumCXXBaseSpecifiers != 0) {
- Error("duplicate CXX_BASE_SPECIFIER_OFFSETS record in AST file");
- return Failure;
- }
-
- F.LocalNumCXXBaseSpecifiers = Record[0];
- F.CXXBaseSpecifiersOffsets = (const uint32_t *)Blob.data();
- break;
- }
-
- case CXX_CTOR_INITIALIZERS_OFFSETS: {
- if (F.LocalNumCXXCtorInitializers != 0) {
- Error("duplicate CXX_CTOR_INITIALIZERS_OFFSETS record in AST file");
- return Failure;
- }
-
- F.LocalNumCXXCtorInitializers = Record[0];
- F.CXXCtorInitializersOffsets = (const uint32_t *)Blob.data();
- break;
- }
-
case DIAG_PRAGMA_MAPPINGS:
if (F.PragmaDiagMappings.empty())
F.PragmaDiagMappings.swap(Record);
@@ -3201,6 +3188,23 @@ ASTReader::ReadASTBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
OptimizeOffPragmaLocation = ReadSourceLocation(F, Record[0]);
break;
+ case MSSTRUCT_PRAGMA_OPTIONS:
+ if (Record.size() != 1) {
+ Error("invalid pragma ms_struct record");
+ return Failure;
+ }
+ PragmaMSStructState = Record[0];
+ break;
+
+ case POINTERS_TO_MEMBERS_PRAGMA_OPTIONS:
+ if (Record.size() != 2) {
+ Error("invalid pragma ms_struct record");
+ return Failure;
+ }
+ PragmaMSPointersToMembersState = Record[0];
+ PointersToMembersPragmaLocation = ReadSourceLocation(F, Record[1]);
+ break;
+
case UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES:
for (unsigned I = 0, N = Record.size(); I != N; ++I)
UnusedLocalTypedefNameCandidates.push_back(
@@ -3467,7 +3471,7 @@ static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID) {
}
}
-ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
+ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
ModuleKind Type,
SourceLocation ImportLoc,
unsigned ClientLoadCapabilities) {
@@ -3560,12 +3564,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
// Mark this identifier as being from an AST file so that we can track
// whether we need to serialize it.
- if (!II.isFromAST()) {
- II.setIsFromAST();
- bool IsModule = PP.getCurrentModule() != nullptr;
- if (isInterestingIdentifier(*this, II, IsModule))
- II.setChangedSinceDeserialization();
- }
+ markIdentifierFromAST(*this, II);
// Associate the ID with the identifier so that the writer can reuse it.
auto ID = Trait.ReadIdentifierID(Data + KeyDataLen.first);
@@ -3584,11 +3583,12 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
// Set the import location.
F.DirectImportLoc = ImportLoc;
+ // FIXME: We assume that locations from PCH / preamble do not need
+ // any translation.
if (!M->ImportedBy)
F.ImportLoc = M->ImportLoc;
else
- F.ImportLoc = ReadSourceLocation(*M->ImportedBy,
- M->ImportLoc.getRawEncoding());
+ F.ImportLoc = TranslateSourceLocation(*M->ImportedBy, M->ImportLoc);
}
if (!Context.getLangOpts().CPlusPlus ||
@@ -3605,6 +3605,9 @@ ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
Id != IdEnd; ++Id)
Id->second->setOutOfDate(true);
}
+ // 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) {
@@ -4052,7 +4055,9 @@ void ASTReader::InitializeContext() {
if (Module *Imported = getSubmodule(Import.ID)) {
makeModuleVisible(Imported, Module::AllVisible,
/*ImportLoc=*/Import.ImportLoc);
- PP.makeModuleVisible(Imported, Import.ImportLoc);
+ if (Import.ImportLoc.isValid())
+ PP.makeModuleVisible(Imported, Import.ImportLoc);
+ // FIXME: should we tell Sema to make the module visible too?
}
}
ImportedModules.clear();
@@ -4521,14 +4526,25 @@ ASTReader::ReadSubmoduleBlock(ModuleFile &F, unsigned ClientLoadCapabilities) {
SubmodulesLoaded[GlobalIndex] = CurrentModule;
- // Clear out data that will be replaced by what is the module file.
+ // Clear out data that will be replaced by what is in the module file.
CurrentModule->LinkLibraries.clear();
CurrentModule->ConfigMacros.clear();
CurrentModule->UnresolvedConflicts.clear();
CurrentModule->Conflicts.clear();
+
+ // The module is available unless it's missing a requirement; relevant
+ // requirements will be (re-)added by SUBMODULE_REQUIRES records.
+ // Missing headers that were present when the module was built do not
+ // make it unavailable -- if we got this far, this must be an explicitly
+ // imported module file.
+ CurrentModule->Requirements.clear();
+ CurrentModule->MissingHeaders.clear();
+ CurrentModule->IsMissingRequirement =
+ ParentModule && ParentModule->IsMissingRequirement;
+ CurrentModule->IsAvailable = !CurrentModule->IsMissingRequirement;
break;
}
-
+
case SUBMODULE_UMBRELLA_HEADER: {
std::string Filename = Blob;
ResolveImportedPath(F, Filename);
@@ -4878,8 +4894,8 @@ PreprocessedEntity *ASTReader::ReadPreprocessedEntity(unsigned Index) {
return nullptr;
// Read the record.
- SourceRange Range(ReadSourceLocation(M, PPOffs.Begin),
- ReadSourceLocation(M, PPOffs.End));
+ SourceRange Range(TranslateSourceLocation(M, PPOffs.getBegin()),
+ TranslateSourceLocation(M, PPOffs.getEnd()));
PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
StringRef Blob;
RecordData Record;
@@ -4963,7 +4979,6 @@ PreprocessedEntityID ASTReader::findNextPreprocessedEntity(
namespace {
-template <unsigned PPEntityOffset::*PPLoc>
struct PPEntityComp {
const ASTReader &Reader;
ModuleFile &M;
@@ -4987,7 +5002,7 @@ struct PPEntityComp {
}
SourceLocation getLoc(const PPEntityOffset &PPE) const {
- return Reader.ReadSourceLocation(M, PPE.*PPLoc);
+ return Reader.TranslateSourceLocation(M, PPE.getBegin());
}
};
@@ -5018,7 +5033,7 @@ PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
if (EndsAfter) {
PPI = std::upper_bound(pp_begin, pp_end, Loc,
- PPEntityComp<&PPEntityOffset::Begin>(*this, M));
+ PPEntityComp(*this, M));
} else {
// Do a binary search manually instead of using std::lower_bound because
// The end locations of entities may be unordered (when a macro expansion
@@ -5028,8 +5043,8 @@ PreprocessedEntityID ASTReader::findPreprocessedEntity(SourceLocation Loc,
Half = Count / 2;
PPI = First;
std::advance(PPI, Half);
- if (SourceMgr.isBeforeInTranslationUnit(ReadSourceLocation(M, PPI->End),
- Loc)) {
+ if (SourceMgr.isBeforeInTranslationUnit(
+ TranslateSourceLocation(M, PPI->getEnd()), Loc)) {
First = PPI;
++First;
Count = Count - Half - 1;
@@ -5070,7 +5085,7 @@ Optional<bool> ASTReader::isPreprocessedEntityInFileID(unsigned Index,
unsigned LocalIndex = PPInfo.second;
const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
- SourceLocation Loc = ReadSourceLocation(M, PPOffs.Begin);
+ SourceLocation Loc = TranslateSourceLocation(M, PPOffs.getBegin());
if (Loc.isInvalid())
return false;
@@ -5374,6 +5389,17 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
for (unsigned I = 0; I != NumParams; ++I)
ParamTypes.push_back(readType(*Loc.F, Record, Idx));
+ SmallVector<FunctionProtoType::ExtParameterInfo, 4> ExtParameterInfos;
+ if (Idx != Record.size()) {
+ for (unsigned I = 0; I != NumParams; ++I)
+ ExtParameterInfos.push_back(
+ FunctionProtoType::ExtParameterInfo
+ ::getFromOpaqueValue(Record[Idx++]));
+ EPI.ExtParameterInfos = ExtParameterInfos.data();
+ }
+
+ assert(Idx == Record.size());
+
return Context.getFunctionType(ResultType, ParamTypes, EPI);
}
@@ -5594,7 +5620,7 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
while (NumArgs--)
Args.push_back(ReadTemplateArgument(*Loc.F, Record, Idx));
return Context.getDependentTemplateSpecializationType(Keyword, NNS, Name,
- Args.size(), Args.data());
+ Args);
}
case TYPE_DEPENDENT_SIZED_ARRAY: {
@@ -5623,11 +5649,9 @@ QualType ASTReader::readTypeRecord(unsigned Index) {
QualType Underlying = readType(*Loc.F, Record, Idx);
QualType T;
if (Underlying.isNull())
- T = Context.getCanonicalTemplateSpecializationType(Name, Args.data(),
- Args.size());
+ T = Context.getCanonicalTemplateSpecializationType(Name, Args);
else
- T = Context.getTemplateSpecializationType(Name, Args.data(),
- Args.size(), Underlying);
+ T = Context.getTemplateSpecializationType(Name, Args, Underlying);
const_cast<Type*>(T.getTypePtr())->setDependent(IsDependent);
return T;
}
@@ -6013,6 +6037,9 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_LONGDOUBLE_ID:
T = Context.LongDoubleTy;
break;
+ case PREDEF_TYPE_FLOAT128_ID:
+ T = Context.Float128Ty;
+ break;
case PREDEF_TYPE_OVERLOAD_ID:
T = Context.OverloadTy;
break;
@@ -6046,42 +6073,11 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_OBJC_SEL:
T = Context.ObjCBuiltinSelTy;
break;
- case PREDEF_TYPE_IMAGE1D_ID:
- T = Context.OCLImage1dTy;
- break;
- case PREDEF_TYPE_IMAGE1D_ARR_ID:
- T = Context.OCLImage1dArrayTy;
- break;
- case PREDEF_TYPE_IMAGE1D_BUFF_ID:
- T = Context.OCLImage1dBufferTy;
- break;
- case PREDEF_TYPE_IMAGE2D_ID:
- T = Context.OCLImage2dTy;
- break;
- case PREDEF_TYPE_IMAGE2D_ARR_ID:
- T = Context.OCLImage2dArrayTy;
- break;
- case PREDEF_TYPE_IMAGE2D_DEP_ID:
- T = Context.OCLImage2dDepthTy;
- break;
- case PREDEF_TYPE_IMAGE2D_ARR_DEP_ID:
- T = Context.OCLImage2dArrayDepthTy;
- break;
- case PREDEF_TYPE_IMAGE2D_MSAA_ID:
- T = Context.OCLImage2dMSAATy;
- break;
- case PREDEF_TYPE_IMAGE2D_ARR_MSAA_ID:
- T = Context.OCLImage2dArrayMSAATy;
- break;
- case PREDEF_TYPE_IMAGE2D_MSAA_DEP_ID:
- T = Context.OCLImage2dMSAADepthTy;
- break;
- case PREDEF_TYPE_IMAGE2D_ARR_MSAA_DEPTH_ID:
- T = Context.OCLImage2dArrayMSAADepthTy;
- break;
- case PREDEF_TYPE_IMAGE3D_ID:
- T = Context.OCLImage3dTy;
+#define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
+ case PREDEF_TYPE_##Id##_ID: \
+ T = Context.SingletonId; \
break;
+#include "clang/Basic/OpenCLImageTypes.def"
case PREDEF_TYPE_SAMPLER_ID:
T = Context.OCLSamplerTy;
break;
@@ -6285,18 +6281,6 @@ void ASTReader::CompleteRedeclChain(const Decl *D) {
}
}
-uint64_t ASTReader::ReadCXXCtorInitializersRef(ModuleFile &M,
- const RecordData &Record,
- unsigned &Idx) {
- if (Idx >= Record.size() || Record[Idx] > M.LocalNumCXXCtorInitializers) {
- Error("malformed AST file: missing C++ ctor initializers");
- return 0;
- }
-
- unsigned LocalID = Record[Idx++];
- return getGlobalBitOffset(M, M.CXXCtorInitializersOffsets[LocalID - 1]);
-}
-
CXXCtorInitializer **
ASTReader::GetExternalCXXCtorInitializers(uint64_t Offset) {
RecordLocation Loc = getLocalBitOffset(Offset);
@@ -6317,18 +6301,6 @@ ASTReader::GetExternalCXXCtorInitializers(uint64_t Offset) {
return ReadCXXCtorInitializers(*Loc.F, Record, Idx);
}
-uint64_t ASTReader::readCXXBaseSpecifiers(ModuleFile &M,
- const RecordData &Record,
- unsigned &Idx) {
- if (Idx >= Record.size() || Record[Idx] > M.LocalNumCXXBaseSpecifiers) {
- Error("malformed AST file: missing C++ base specifier");
- return 0;
- }
-
- unsigned LocalID = Record[Idx++];
- return getGlobalBitOffset(M, M.CXXBaseSpecifiersOffsets[LocalID - 1]);
-}
-
CXXBaseSpecifier *ASTReader::GetExternalCXXBaseSpecifiers(uint64_t Offset) {
RecordLocation Loc = getLocalBitOffset(Offset);
BitstreamCursor &Cursor = Loc.F->DeclsCursor;
@@ -6396,9 +6368,9 @@ SourceLocation ASTReader::getSourceLocationForDeclID(GlobalDeclID ID) {
if (Decl *D = DeclsLoaded[Index])
return D->getLocation();
- unsigned RawLocation = 0;
- RecordLocation Rec = DeclCursorForID(ID, RawLocation);
- return ReadSourceLocation(*Rec.F, RawLocation);
+ SourceLocation Loc;
+ DeclCursorForID(ID, Loc);
+ return Loc;
}
static Decl *getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID) {
@@ -6444,6 +6416,15 @@ static Decl *getPredefinedDecl(ASTContext &Context, PredefinedDeclIDs ID) {
case PREDEF_DECL_MAKE_INTEGER_SEQ_ID:
return Context.getMakeIntegerSeqDecl();
+
+ case PREDEF_DECL_CF_CONSTANT_STRING_ID:
+ return Context.getCFConstantStringDecl();
+
+ case PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID:
+ return Context.getCFConstantStringTagDecl();
+
+ case PREDEF_DECL_TYPE_PACK_ELEMENT_ID:
+ return Context.getTypePackElementDecl();
}
llvm_unreachable("PredefinedDeclIDs unknown enum value");
}
@@ -6883,7 +6864,7 @@ dumpModuleIDMap(StringRef Name,
}
}
-void ASTReader::dump() {
+LLVM_DUMP_METHOD void ASTReader::dump() {
llvm::errs() << "*** PCH/ModuleFile Remappings:\n";
dumpModuleIDMap("Global bit offset map", GlobalBitOffsetsMap);
dumpModuleIDMap("Global source location entry map", GlobalSLocEntryMap);
@@ -6968,10 +6949,18 @@ void ASTReader::UpdateSema() {
SemaDeclRefs.clear();
}
- // Update the state of 'pragma clang optimize'. Use the same API as if we had
- // encountered the pragma in the source.
+ // Update the state of pragmas. Use the same API as if we had encountered the
+ // pragma in the source.
if(OptimizeOffPragmaLocation.isValid())
SemaObj->ActOnPragmaOptimize(/* IsOn = */ false, OptimizeOffPragmaLocation);
+ if (PragmaMSStructState != -1)
+ SemaObj->ActOnPragmaMSStruct((PragmaMSStructKind)PragmaMSStructState);
+ if (PointersToMembersPragmaLocation.isValid()) {
+ SemaObj->ActOnPragmaMSPointersToMembers(
+ (LangOptions::PragmaMSPointersToMembersKind)
+ PragmaMSPointersToMembersState,
+ PointersToMembersPragmaLocation);
+ }
}
IdentifierInfo *ASTReader::get(StringRef Name) {
@@ -7028,19 +7017,20 @@ namespace clang {
/// the current AST file.
ASTIdentifierLookupTable::key_iterator End;
+ /// \brief Whether to skip any modules in the ASTReader.
+ bool SkipModules;
+
public:
- explicit ASTIdentifierIterator(const ASTReader &Reader);
+ explicit ASTIdentifierIterator(const ASTReader &Reader,
+ bool SkipModules = false);
StringRef Next() override;
};
}
-ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader &Reader)
- : Reader(Reader), Index(Reader.ModuleMgr.size() - 1) {
- ASTIdentifierLookupTable *IdTable
- = (ASTIdentifierLookupTable *)Reader.ModuleMgr[Index].IdentifierLookupTable;
- Current = IdTable->key_begin();
- End = IdTable->key_end();
+ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader &Reader,
+ bool SkipModules)
+ : Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) {
}
StringRef ASTIdentifierIterator::Next() {
@@ -7050,9 +7040,12 @@ StringRef ASTIdentifierIterator::Next() {
return StringRef();
--Index;
- ASTIdentifierLookupTable *IdTable
- = (ASTIdentifierLookupTable *)Reader.ModuleMgr[Index].
- IdentifierLookupTable;
+ ModuleFile &F = Reader.ModuleMgr[Index];
+ if (SkipModules && F.isModule())
+ continue;
+
+ ASTIdentifierLookupTable *IdTable =
+ (ASTIdentifierLookupTable *)F.IdentifierLookupTable;
Current = IdTable->key_begin();
End = IdTable->key_end();
}
@@ -7064,9 +7057,42 @@ StringRef ASTIdentifierIterator::Next() {
return Result;
}
+namespace {
+/// A utility for appending two IdentifierIterators.
+class ChainedIdentifierIterator : public IdentifierIterator {
+ std::unique_ptr<IdentifierIterator> Current;
+ std::unique_ptr<IdentifierIterator> Queued;
+
+public:
+ ChainedIdentifierIterator(std::unique_ptr<IdentifierIterator> First,
+ std::unique_ptr<IdentifierIterator> Second)
+ : Current(std::move(First)), Queued(std::move(Second)) {}
+
+ StringRef Next() override {
+ if (!Current)
+ return StringRef();
+
+ StringRef result = Current->Next();
+ if (!result.empty())
+ return result;
+
+ // Try the queued iterator, which may itself be empty.
+ Current.reset();
+ std::swap(Current, Queued);
+ return Next();
+ }
+};
+} // end anonymous namespace.
+
IdentifierIterator *ASTReader::getIdentifiers() {
- if (!loadGlobalIndex())
- return GlobalIndex->createIdentifierIterator();
+ if (!loadGlobalIndex()) {
+ std::unique_ptr<IdentifierIterator> ReaderIter(
+ new ASTIdentifierIterator(*this, /*SkipModules=*/true));
+ std::unique_ptr<IdentifierIterator> ModulesIter(
+ GlobalIndex->createIdentifierIterator());
+ return new ChainedIdentifierIterator(std::move(ReaderIter),
+ std::move(ModulesIter));
+ }
return new ASTIdentifierIterator(*this);
}
@@ -7156,6 +7182,7 @@ void ASTReader::ReadMethodPool(Selector Sel) {
unsigned &Generation = SelectorGeneration[Sel];
unsigned PriorGeneration = Generation;
Generation = getGeneration();
+ SelectorOutOfDate[Sel] = false;
// Search for methods defined with this selector.
++NumMethodPoolLookups;
@@ -7187,6 +7214,11 @@ void ASTReader::ReadMethodPool(Selector Sel) {
addMethodsToPool(S, Visitor.getFactoryMethods(), Pos->second.second);
}
+void ASTReader::updateOutOfDateSelector(Selector Sel) {
+ if (SelectorOutOfDate[Sel])
+ ReadMethodPool(Sel);
+}
+
void ASTReader::ReadKnownNamespaces(
SmallVectorImpl<NamespaceDecl *> &Namespaces) {
Namespaces.clear();
@@ -7199,7 +7231,7 @@ void ASTReader::ReadKnownNamespaces(
}
void ASTReader::ReadUndefinedButUsed(
- llvm::DenseMap<NamedDecl*, SourceLocation> &Undefined) {
+ llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {
for (unsigned Idx = 0, N = UndefinedButUsed.size(); Idx != N;) {
NamedDecl *D = cast<NamedDecl>(GetDecl(UndefinedButUsed[Idx++]));
SourceLocation Loc =
@@ -7449,10 +7481,11 @@ IdentifierInfo *ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
const unsigned char *StrLenPtr = (const unsigned char*) Str - 2;
unsigned StrLen = (((unsigned) StrLenPtr[0])
| (((unsigned) StrLenPtr[1]) << 8)) - 1;
- IdentifiersLoaded[ID]
- = &PP.getIdentifierTable().get(StringRef(Str, StrLen));
+ auto &II = PP.getIdentifierTable().get(StringRef(Str, StrLen));
+ IdentifiersLoaded[ID] = &II;
+ markIdentifierFromAST(*this, II);
if (DeserializationListener)
- DeserializationListener->IdentifierRead(ID + 1, IdentifiersLoaded[ID]);
+ DeserializationListener->IdentifierRead(ID + 1, &II);
}
return IdentifiersLoaded[ID];
@@ -7581,8 +7614,10 @@ ASTReader::getSourceDescriptor(unsigned ID) {
// Chained PCH are not suported.
if (ModuleMgr.size() == 1) {
ModuleFile &MF = ModuleMgr.getPrimaryModule();
- return ASTReader::ASTSourceDescriptor(
- MF.OriginalSourceFileName, MF.OriginalDir, MF.FileName, MF.Signature);
+ StringRef ModuleName = llvm::sys::path::filename(MF.OriginalSourceFileName);
+ StringRef FileName = llvm::sys::path::filename(MF.FileName);
+ return ASTReader::ASTSourceDescriptor(ModuleName, MF.OriginalDir, FileName,
+ MF.Signature);
}
return None;
}
@@ -8663,7 +8698,10 @@ ASTReader::ASTReader(
FileMgr(PP.getFileManager()), PCHContainerRdr(PCHContainerRdr),
Diags(PP.getDiagnostics()), SemaObj(nullptr), PP(PP), Context(Context),
Consumer(nullptr), ModuleMgr(PP.getFileManager(), PCHContainerRdr),
+ DummyIdResolver(PP),
ReadTimer(std::move(ReadTimer)),
+ PragmaMSStructState(-1),
+ PragmaMSPointersToMembersState(-1),
isysroot(isysroot), DisableValidation(DisableValidation),
AllowASTWithCompilerErrors(AllowASTWithCompilerErrors),
AllowConfigurationMismatch(AllowConfigurationMismatch),
@@ -8699,3 +8737,7 @@ ASTReader::~ASTReader() {
if (OwnsDeserializationListener)
delete DeserializationListener;
}
+
+IdentifierResolver &ASTReader::getIdResolver() {
+ return SemaObj ? SemaObj->IdResolver : DummyIdResolver;
+}
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index 5bf95f878d49..4fd7aeb83ac1 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -23,7 +23,6 @@
#include "clang/AST/DeclVisitor.h"
#include "clang/AST/Expr.h"
#include "clang/Sema/IdentifierResolver.h"
-#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaDiagnostic.h"
#include "llvm/Support/SaveAndRestore.h"
@@ -38,8 +37,9 @@ namespace clang {
class ASTDeclReader : public DeclVisitor<ASTDeclReader, void> {
ASTReader &Reader;
ModuleFile &F;
+ uint64_t Offset;
const DeclID ThisDeclID;
- const unsigned RawLocation;
+ const SourceLocation ThisDeclLoc;
typedef ASTReader::RecordData RecordData;
const RecordData &Record;
unsigned &Idx;
@@ -47,27 +47,47 @@ namespace clang {
unsigned AnonymousDeclNumber;
GlobalDeclID NamedDeclForTagDecl;
IdentifierInfo *TypedefNameForLinkage;
-
+
bool HasPendingBody;
+ ///\brief A flag to carry the information for a decl from the entity is
+ /// used. We use it to delay the marking of the canonical decl as used until
+ /// the entire declaration is deserialized and merged.
+ bool IsDeclMarkedUsed;
+
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 ReadGlobalOffset(ModuleFile &F, const RecordData &R, unsigned &I) {
+ uint64_t Local = ReadLocalOffset(R, I);
+ return Local ? Reader.getGlobalBitOffset(F, Local) : 0;
+ }
+
SourceLocation ReadSourceLocation(const RecordData &R, unsigned &I) {
return Reader.ReadSourceLocation(F, R, I);
}
-
+
SourceRange ReadSourceRange(const RecordData &R, unsigned &I) {
return Reader.ReadSourceRange(F, 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);
}
+ std::string ReadString(const RecordData &R, unsigned &I) {
+ return Reader.ReadString(R, I);
+ }
+
void ReadDeclIDList(SmallVectorImpl<DeclID> &IDs) {
for (unsigned I = 0, Size = Record[Idx++]; I != Size; ++I)
IDs.push_back(ReadDeclID(Record, Idx));
@@ -195,12 +215,14 @@ namespace clang {
FindExistingResult findExisting(NamedDecl *D);
public:
- ASTDeclReader(ASTReader &Reader, ModuleFile &F, DeclID thisDeclID,
- unsigned RawLocation, const RecordData &Record, unsigned &Idx)
- : Reader(Reader), F(F), ThisDeclID(thisDeclID),
- RawLocation(RawLocation), Record(Record), Idx(Idx),
+ 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),
TypeIDForTypeDecl(0), NamedDeclForTagDecl(0),
- TypedefNameForLinkage(nullptr), HasPendingBody(false) {}
+ TypedefNameForLinkage(nullptr), HasPendingBody(false),
+ IsDeclMarkedUsed(false) {}
template <typename DeclT>
static Decl *getMostRecentDeclImpl(Redeclarable<DeclT> *D);
@@ -238,6 +260,8 @@ namespace clang {
}
void VisitDecl(Decl *D);
+ void VisitPragmaCommentDecl(PragmaCommentDecl *D);
+ void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D);
void VisitTranslationUnitDecl(TranslationUnitDecl *TU);
void VisitNamedDecl(NamedDecl *ND);
void VisitLabelDecl(LabelDecl *LD);
@@ -300,6 +324,7 @@ namespace clang {
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
void VisitUsingDecl(UsingDecl *D);
void VisitUsingShadowDecl(UsingShadowDecl *D);
+ void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
void VisitFileScopeAsmDecl(FileScopeAsmDecl *AD);
void VisitImportDecl(ImportDecl *D);
@@ -350,6 +375,8 @@ namespace clang {
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
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
@@ -423,6 +450,11 @@ uint64_t ASTDeclReader::GetCurrentCursorOffset() {
void ASTDeclReader::Visit(Decl *D) {
DeclVisitor<ASTDeclReader, void>::Visit(D);
+ // At this point we have deserialized and merged the decl and it is safe to
+ // update its canonical decl to signal that the entire entity is used.
+ D->getCanonicalDecl()->Used |= IsDeclMarkedUsed;
+ IsDeclMarkedUsed = false;
+
if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
if (DD->DeclInfo) {
DeclaratorDecl::ExtInfo *Info =
@@ -456,8 +488,7 @@ void ASTDeclReader::Visit(Decl *D) {
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
CD->NumCtorInitializers = Record[Idx++];
if (CD->NumCtorInitializers)
- CD->CtorInitializers =
- Reader.ReadCXXCtorInitializersRef(F, Record, Idx);
+ CD->CtorInitializers = ReadGlobalOffset(F, Record, Idx);
}
Reader.PendingBodies[FD] = GetCurrentCursorOffset();
HasPendingBody = true;
@@ -493,7 +524,7 @@ void ASTDeclReader::VisitDecl(Decl *D) {
D->setDeclContextsImpl(MergedSemaDC ? MergedSemaDC : SemaDC, LexicalDC,
Reader.getContext());
}
- D->setLocation(Reader.ReadSourceLocation(F, RawLocation));
+ D->setLocation(ThisDeclLoc);
D->setInvalidDecl(Record[Idx++]);
if (Record[Idx++]) { // hasAttrs
AttrVec Attrs;
@@ -504,6 +535,7 @@ void ASTDeclReader::VisitDecl(Decl *D) {
}
D->setImplicit(Record[Idx++]);
D->Used = Record[Idx++];
+ IsDeclMarkedUsed |= D->Used;
D->setReferenced(Record[Idx++]);
D->setTopLevelDeclInObjCContainer(Record[Idx++]);
D->setAccess((AccessSpecifier)Record[Idx++]);
@@ -528,7 +560,7 @@ void ASTDeclReader::VisitDecl(Decl *D) {
if (Owner->NameVisibility != Module::AllVisible) {
// The owning module is not visible. Mark this declaration as hidden.
D->Hidden = true;
-
+
// Note that this declaration was hidden because its owning module is
// not yet visible.
Reader.HiddenNamesMap[Owner].push_back(D);
@@ -537,6 +569,29 @@ 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);
+ 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);
+ 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);
+ memcpy(D->getTrailingObjects<char>() + D->ValueStart, Value.data(),
+ Value.size());
+ D->getTrailingObjects<char>()[D->ValueStart + Value.size()] = '\0';
+}
+
void ASTDeclReader::VisitTranslationUnitDecl(TranslationUnitDecl *TU) {
llvm_unreachable("Translation units are not serialized");
}
@@ -592,7 +647,7 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitTagDecl(TagDecl *TD) {
TD->setEmbeddedInDeclarator(Record[Idx++]);
TD->setFreeStanding(Record[Idx++]);
TD->setCompleteDefinitionRequired(Record[Idx++]);
- TD->setRBraceLoc(ReadSourceLocation(Record, Idx));
+ TD->setBraceRange(ReadSourceRange(Record, Idx));
switch (Record[Idx++]) {
case 0:
@@ -771,7 +826,7 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
ASTContext &C = Reader.getContext();
TemplateArgumentList *TemplArgList
- = TemplateArgumentList::CreateCopy(C, TemplArgs.data(), TemplArgs.size());
+ = TemplateArgumentList::CreateCopy(C, TemplArgs);
TemplateArgumentListInfo TemplArgsInfo(LAngleLoc, RAngleLoc);
for (unsigned i=0, e = TemplArgLocs.size(); i != e; ++i)
TemplArgsInfo.addArgument(TemplArgLocs[i]);
@@ -1098,7 +1153,7 @@ void ASTDeclReader::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
D->setHasDestructors(Record[Idx++]);
D->NumIvarInitializers = Record[Idx++];
if (D->NumIvarInitializers)
- D->IvarInitializers = Reader.ReadCXXCtorInitializersRef(F, Record, Idx);
+ D->IvarInitializers = ReadGlobalOffset(F, Record, Idx);
}
void ASTDeclReader::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
@@ -1163,6 +1218,8 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
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++];
@@ -1365,6 +1422,16 @@ void ASTDeclReader::VisitUsingShadowDecl(UsingShadowDecl *D) {
mergeRedeclarable(D, Redecl);
}
+void ASTDeclReader::VisitConstructorUsingShadowDecl(
+ ConstructorUsingShadowDecl *D) {
+ VisitUsingShadowDecl(D);
+ D->NominatedBaseClassShadowDecl =
+ ReadDeclAs<ConstructorUsingShadowDecl>(Record, Idx);
+ D->ConstructedBaseClassShadowDecl =
+ ReadDeclAs<ConstructorUsingShadowDecl>(Record, Idx);
+ D->IsVirtual = Record[Idx++];
+}
+
void ASTDeclReader::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
VisitNamedDecl(D);
D->UsingLoc = ReadSourceLocation(Record, Idx);
@@ -1411,6 +1478,9 @@ void ASTDeclReader::ReadCXXDefinitionData(
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++];
@@ -1421,6 +1491,7 @@ void ASTDeclReader::ReadCXXDefinitionData(
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++];
@@ -1434,10 +1505,10 @@ void ASTDeclReader::ReadCXXDefinitionData(
Data.NumBases = Record[Idx++];
if (Data.NumBases)
- Data.Bases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
+ Data.Bases = ReadGlobalOffset(F, Record, Idx);
Data.NumVBases = Record[Idx++];
if (Data.NumVBases)
- Data.VBases = Reader.readCXXBaseSpecifiers(F, Record, Idx);
+ Data.VBases = ReadGlobalOffset(F, Record, Idx);
Reader.ReadUnresolvedSet(F, Data.Conversions, Record, Idx);
Reader.ReadUnresolvedSet(F, Data.VisibleConversions, Record, Idx);
@@ -1464,6 +1535,7 @@ void ASTDeclReader::ReadCXXDefinitionData(
bool IsImplicit = Record[Idx++];
LambdaCaptureKind Kind = static_cast<LambdaCaptureKind>(Record[Idx++]);
switch (Kind) {
+ case LCK_StarThis:
case LCK_This:
case LCK_VLAType:
*ToCapture++ = Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation());
@@ -1481,9 +1553,9 @@ void ASTDeclReader::ReadCXXDefinitionData(
void ASTDeclReader::MergeDefinitionData(
CXXRecordDecl *D, struct CXXRecordDecl::DefinitionData &&MergeDD) {
- assert(D->DefinitionData.getNotUpdated() &&
+ assert(D->DefinitionData &&
"merging class definition into non-definition");
- auto &DD = *D->DefinitionData.getNotUpdated();
+ auto &DD = *D->DefinitionData;
if (DD.Definition != MergeDD.Definition) {
// Track that we merged the definitions.
@@ -1535,6 +1607,9 @@ void ASTDeclReader::MergeDefinitionData(
MATCH_FIELD(HasOnlyCMembers)
MATCH_FIELD(HasInClassInitializer)
MATCH_FIELD(HasUninitializedReferenceMember)
+ MATCH_FIELD(HasUninitializedFields)
+ MATCH_FIELD(HasInheritedConstructor)
+ MATCH_FIELD(HasInheritedAssignment)
MATCH_FIELD(NeedOverloadResolutionForMoveConstructor)
MATCH_FIELD(NeedOverloadResolutionForMoveAssignment)
MATCH_FIELD(NeedOverloadResolutionForDestructor)
@@ -1545,6 +1620,7 @@ void ASTDeclReader::MergeDefinitionData(
OR_FIELD(DeclaredNonTrivialSpecialMembers)
MATCH_FIELD(HasIrrelevantDestructor)
OR_FIELD(HasConstexprNonCopyMoveConstructor)
+ OR_FIELD(HasDefaultedDefaultConstructor)
MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
OR_FIELD(HasConstexprDefaultConstructor)
MATCH_FIELD(HasNonLiteralTypeFieldsOrBases)
@@ -1602,7 +1678,7 @@ void ASTDeclReader::ReadCXXRecordDefinition(CXXRecordDecl *D, bool Update) {
// because we're reading an update record, or because we've already done some
// merging. Either way, just merge into it.
CXXRecordDecl *Canon = D->getCanonicalDecl();
- if (Canon->DefinitionData.getNotUpdated()) {
+ if (Canon->DefinitionData) {
MergeDefinitionData(Canon, std::move(*DD));
D->DefinitionData = Canon->DefinitionData;
return;
@@ -1703,11 +1779,17 @@ void ASTDeclReader::VisitCXXMethodDecl(CXXMethodDecl *D) {
}
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);
+ *D->getTrailingObjects<InheritedConstructor>() =
+ InheritedConstructor(Shadow, Ctor);
+ }
+
VisitCXXMethodDecl(D);
- if (auto *CD = ReadDeclAs<CXXConstructorDecl>(Record, Idx))
- if (D->isCanonicalDecl())
- D->setInheritedConstructor(CD->getCanonicalDecl());
D->IsExplicitSpecified = Record[Idx++];
}
@@ -1898,8 +1980,7 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl(
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
TemplateArgumentList *ArgList
- = TemplateArgumentList::CreateCopy(C, TemplArgs.data(),
- TemplArgs.size());
+ = TemplateArgumentList::CreateCopy(C, TemplArgs);
ClassTemplateSpecializationDecl::SpecializedPartialSpecialization *PS
= new (C) ClassTemplateSpecializationDecl::
SpecializedPartialSpecialization();
@@ -1913,8 +1994,7 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl(
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
/*Canonicalize*/ true);
- D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs.data(),
- TemplArgs.size());
+ D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
@@ -1938,8 +2018,8 @@ ASTDeclReader::VisitClassTemplateSpecializationDeclImpl(
// This declaration might be a definition. Merge with any existing
// definition.
- if (auto *DDD = D->DefinitionData.getNotUpdated()) {
- if (CanonSpec->DefinitionData.getNotUpdated())
+ if (auto *DDD = D->DefinitionData) {
+ if (CanonSpec->DefinitionData)
MergeDefinitionData(CanonSpec, std::move(*DDD));
else
CanonSpec->DefinitionData = D->DefinitionData;
@@ -2017,7 +2097,7 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl(
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
TemplateArgumentList *ArgList = TemplateArgumentList::CreateCopy(
- C, TemplArgs.data(), TemplArgs.size());
+ C, TemplArgs);
VarTemplateSpecializationDecl::SpecializedPartialSpecialization *PS =
new (C)
VarTemplateSpecializationDecl::SpecializedPartialSpecialization();
@@ -2041,8 +2121,7 @@ ASTDeclReader::VisitVarTemplateSpecializationDeclImpl(
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx,
/*Canonicalize*/ true);
- D->TemplateArgs =
- TemplateArgumentList::CreateCopy(C, TemplArgs.data(), TemplArgs.size());
+ D->TemplateArgs = TemplateArgumentList::CreateCopy(C, TemplArgs);
D->PointOfInstantiation = ReadSourceLocation(Record, Idx);
D->SpecializationKind = (TemplateSpecializationKind)Record[Idx++];
@@ -2151,8 +2230,8 @@ void ASTDeclReader::VisitEmptyDecl(EmptyDecl *D) {
std::pair<uint64_t, uint64_t>
ASTDeclReader::VisitDeclContext(DeclContext *DC) {
- uint64_t LexicalOffset = Record[Idx++];
- uint64_t VisibleOffset = Record[Idx++];
+ uint64_t LexicalOffset = ReadLocalOffset(Record, Idx);
+ uint64_t VisibleOffset = ReadLocalOffset(Record, Idx);
return std::make_pair(LexicalOffset, VisibleOffset);
}
@@ -2187,7 +2266,7 @@ ASTDeclReader::VisitRedeclarable(Redeclarable<T> *D) {
for (unsigned I = 0; I != N - 1; ++I)
MergeWith = ReadDecl(Record, Idx/*, MergeWith*/);
- RedeclOffset = Record[Idx++];
+ RedeclOffset = ReadLocalOffset(Record, Idx);
} else {
// This declaration was not the first local declaration. Read the first
// local declaration now, to trigger the import of other redeclarations.
@@ -2263,8 +2342,8 @@ void ASTDeclReader::mergeTemplatePattern(RedeclarableTemplateDecl *D,
// FIXME: This is duplicated in several places. Refactor.
auto *ExistingClass =
cast<CXXRecordDecl>(ExistingPattern)->getCanonicalDecl();
- if (auto *DDD = DClass->DefinitionData.getNotUpdated()) {
- if (ExistingClass->DefinitionData.getNotUpdated()) {
+ if (auto *DDD = DClass->DefinitionData) {
+ if (ExistingClass->DefinitionData) {
MergeDefinitionData(ExistingClass, std::move(*DDD));
} else {
ExistingClass->DefinitionData = DClass->DefinitionData;
@@ -2307,6 +2386,8 @@ void ASTDeclReader::mergeRedeclarable(Redeclarable<T> *DBase, T *Existing,
// appropriate canonical declaration.
D->RedeclLink = Redeclarable<T>::PreviousDeclLink(ExistingCanon);
D->First = ExistingCanon;
+ ExistingCanon->Used |= D->Used;
+ D->Used = false;
// When we merge a namespace, update its pointer to the first namespace.
// We cannot have loaded any redeclarations of this declaration yet, so
@@ -2360,6 +2441,18 @@ void ASTDeclReader::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) {
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);
+}
+
+void ASTDeclReader::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) {
+ VisitVarDecl(D);
+}
+
//===----------------------------------------------------------------------===//
// Attribute Reading
//===----------------------------------------------------------------------===//
@@ -2409,8 +2502,11 @@ static bool isConsumerInterestedIn(Decl *D, bool HasBody) {
isa<ObjCProtocolDecl>(D) ||
isa<ObjCImplDecl>(D) ||
isa<ImportDecl>(D) ||
- isa<OMPThreadPrivateDecl>(D))
+ isa<PragmaCommentDecl>(D) ||
+ isa<PragmaDetectMismatchDecl>(D))
return true;
+ if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D))
+ return !D->getDeclContext()->isFunctionOrMethod();
if (VarDecl *Var = dyn_cast<VarDecl>(D))
return Var->isFileVarDecl() &&
Var->isThisDeclarationADefinition() == VarDecl::Definition;
@@ -2422,20 +2518,13 @@ static bool isConsumerInterestedIn(Decl *D, bool HasBody) {
/// \brief Get the correct cursor and offset for loading a declaration.
ASTReader::RecordLocation
-ASTReader::DeclCursorForID(DeclID ID, unsigned &RawLocation) {
- // See if there's an override.
- DeclReplacementMap::iterator It = ReplacedDecls.find(ID);
- if (It != ReplacedDecls.end()) {
- RawLocation = It->second.RawLoc;
- return RecordLocation(It->second.Mod, It->second.Offset);
- }
-
+ASTReader::DeclCursorForID(DeclID ID, SourceLocation &Loc) {
GlobalDeclMapType::iterator I = GlobalDeclMap.find(ID);
assert(I != GlobalDeclMap.end() && "Corrupted global declaration map");
ModuleFile *M = I->second;
- const DeclOffset &
- DOffs = M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS];
- RawLocation = DOffs.Loc;
+ const DeclOffset &DOffs =
+ M->DeclOffsets[ID - M->BaseDeclID - NUM_PREDEF_DECL_IDS];
+ Loc = TranslateSourceLocation(*M, DOffs.getLocation());
return RecordLocation(M, DOffs.BitOffset);
}
@@ -2588,6 +2677,13 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
// functions, etc.
if (FunctionDecl *FuncX = dyn_cast<FunctionDecl>(X)) {
FunctionDecl *FuncY = cast<FunctionDecl>(Y);
+ if (CXXConstructorDecl *CtorX = dyn_cast<CXXConstructorDecl>(X)) {
+ CXXConstructorDecl *CtorY = cast<CXXConstructorDecl>(Y);
+ if (CtorX->getInheritedConstructor() &&
+ !isSameEntity(CtorX->getInheritedConstructor().getConstructor(),
+ CtorY->getInheritedConstructor().getConstructor()))
+ return false;
+ }
return (FuncX->getLinkageInternal() == FuncY->getLinkageInternal()) &&
FuncX->getASTContext().hasSameType(FuncX->getType(), FuncY->getType());
}
@@ -2595,8 +2691,24 @@ static bool isSameEntity(NamedDecl *X, NamedDecl *Y) {
// Variables with the same type and linkage match.
if (VarDecl *VarX = dyn_cast<VarDecl>(X)) {
VarDecl *VarY = cast<VarDecl>(Y);
- return (VarX->getLinkageInternal() == VarY->getLinkageInternal()) &&
- VarX->getASTContext().hasSameType(VarX->getType(), VarY->getType());
+ if (VarX->getLinkageInternal() == VarY->getLinkageInternal()) {
+ ASTContext &C = VarX->getASTContext();
+ if (C.hasSameType(VarX->getType(), VarY->getType()))
+ return true;
+
+ // We can get decls with different types on the redecl chain. Eg.
+ // template <typename T> struct S { static T Var[]; }; // #1
+ // template <typename T> T S<T>::Var[sizeof(T)]; // #2
+ // Only? happens when completing an incomplete array type. In this case
+ // when comparing #1 and #2 we should go through their element type.
+ const ArrayType *VarXTy = C.getAsArrayType(VarX->getType());
+ const ArrayType *VarYTy = C.getAsArrayType(VarY->getType());
+ if (!VarXTy || !VarYTy)
+ return false;
+ if (VarXTy->isIncompleteArrayType() || VarYTy->isIncompleteArrayType())
+ return C.hasSameType(VarXTy->getElementType(), VarYTy->getElementType());
+ }
+ return false;
}
// Namespaces with the same name and inlinedness match.
@@ -2676,9 +2788,9 @@ DeclContext *ASTDeclReader::getPrimaryContextForMerging(ASTReader &Reader,
if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
// Try to dig out the definition.
- auto *DD = RD->DefinitionData.getNotUpdated();
+ auto *DD = RD->DefinitionData;
if (!DD)
- DD = RD->getCanonicalDecl()->DefinitionData.getNotUpdated();
+ DD = RD->getCanonicalDecl()->DefinitionData;
// If there's no definition yet, then DC's definition is added by an update
// record, but we've not yet loaded that update record. In this case, we
@@ -2728,9 +2840,9 @@ ASTDeclReader::FindExistingResult::~FindExistingResult() {
if (needsAnonymousDeclarationNumber(New)) {
setAnonymousDeclForMerging(Reader, New->getLexicalDeclContext(),
AnonymousDeclNumber, New);
- } else if (DC->isTranslationUnit() && Reader.SemaObj &&
+ } else if (DC->isTranslationUnit() &&
!Reader.getContext().getLangOpts().CPlusPlus) {
- if (Reader.SemaObj->IdResolver.tryAddTopLevelDecl(New, Name))
+ if (Reader.getIdResolver().tryAddTopLevelDecl(New, Name))
Reader.PendingFakeLookupResults[Name.getAsIdentifierInfo()]
.push_back(New);
} else if (DeclContext *MergeDC = getPrimaryContextForMerging(Reader, DC)) {
@@ -2833,9 +2945,9 @@ ASTDeclReader::FindExistingResult ASTDeclReader::findExisting(NamedDecl *D) {
if (isSameEntity(Existing, D))
return FindExistingResult(Reader, D, Existing, AnonymousDeclNumber,
TypedefNameForLinkage);
- } else if (DC->isTranslationUnit() && Reader.SemaObj &&
+ } else if (DC->isTranslationUnit() &&
!Reader.getContext().getLangOpts().CPlusPlus) {
- IdentifierResolver &IdResolver = Reader.SemaObj->IdResolver;
+ IdentifierResolver &IdResolver = Reader.getIdResolver();
// Temporarily consider the identifier to be up-to-date. We don't want to
// cause additional lookups here.
@@ -3000,6 +3112,8 @@ static void inheritDefaultTemplateArguments(ASTContext &Context,
for (unsigned I = 0, N = FromTP->size(); I != N; ++I) {
NamedDecl *FromParam = FromTP->getParam(N - I - 1);
+ if (FromParam->isParameterPack())
+ continue;
NamedDecl *ToParam = ToTP->getParam(N - I - 1);
if (auto *FTTP = dyn_cast<TemplateTypeParmDecl>(FromParam)) {
@@ -3038,11 +3152,6 @@ void ASTDeclReader::attachPreviousDecl(ASTReader &Reader, Decl *D,
Previous->IdentifierNamespace &
(Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Type);
- // If the previous declaration is marked as used, then this declaration should
- // be too.
- if (Previous->Used)
- D->Used = true;
-
// If the declaration declares a template, it may inherit default arguments
// from the previous declaration.
if (TemplateDecl *TD = dyn_cast<TemplateDecl>(D))
@@ -3093,8 +3202,8 @@ void ASTReader::markIncompleteDeclChain(Decl *D) {
/// \brief Read the declaration at the given offset from the AST file.
Decl *ASTReader::ReadDeclRecord(DeclID ID) {
unsigned Index = ID - NUM_PREDEF_DECL_IDS;
- unsigned RawLocation = 0;
- RecordLocation Loc = DeclCursorForID(ID, RawLocation);
+ SourceLocation DeclLoc;
+ RecordLocation Loc = DeclCursorForID(ID, DeclLoc);
llvm::BitstreamCursor &DeclsCursor = Loc.F->DeclsCursor;
// Keep track of where we are in the stream, then jump back there
// after reading this declaration.
@@ -3109,7 +3218,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
RecordData Record;
unsigned Code = DeclsCursor.ReadCode();
unsigned Idx = 0;
- ASTDeclReader Reader(*this, *Loc.F, ID, RawLocation, Record,Idx);
+ ASTDeclReader Reader(*this, Loc, ID, DeclLoc, Record,Idx);
Decl *D = nullptr;
switch ((DeclCode)DeclsCursor.readRecord(Code, Record)) {
@@ -3152,6 +3261,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
case DECL_USING_SHADOW:
D = UsingShadowDecl::CreateDeserialized(Context, ID);
break;
+ case DECL_CONSTRUCTOR_USING_SHADOW:
+ D = ConstructorUsingShadowDecl::CreateDeserialized(Context, ID);
+ break;
case DECL_USING_DIRECTIVE:
D = UsingDirectiveDecl::CreateDeserialized(Context, ID);
break;
@@ -3168,7 +3280,10 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
D = CXXMethodDecl::CreateDeserialized(Context, ID);
break;
case DECL_CXX_CONSTRUCTOR:
- D = CXXConstructorDecl::CreateDeserialized(Context, ID);
+ D = CXXConstructorDecl::CreateDeserialized(Context, ID, false);
+ break;
+ case DECL_CXX_INHERITED_CONSTRUCTOR:
+ D = CXXConstructorDecl::CreateDeserialized(Context, ID, true);
break;
case DECL_CXX_DESTRUCTOR:
D = CXXDestructorDecl::CreateDeserialized(Context, ID);
@@ -3305,6 +3420,19 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
case DECL_OMP_THREADPRIVATE:
D = OMPThreadPrivateDecl::CreateDeserialized(Context, ID, Record[Idx++]);
break;
+ case DECL_OMP_DECLARE_REDUCTION:
+ D = OMPDeclareReductionDecl::CreateDeserialized(Context, ID);
+ break;
+ case DECL_OMP_CAPTUREDEXPR:
+ D = OMPCapturedExprDecl::CreateDeserialized(Context, ID);
+ break;
+ case DECL_PRAGMA_COMMENT:
+ D = PragmaCommentDecl::CreateDeserialized(Context, ID, Record[Idx++]);
+ break;
+ case DECL_PRAGMA_DETECT_MISMATCH:
+ D = PragmaDetectMismatchDecl::CreateDeserialized(Context, ID,
+ Record[Idx++]);
+ break;
case DECL_EMPTY:
D = EmptyDecl::CreateDeserialized(Context, ID);
break;
@@ -3353,20 +3481,6 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
}
void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
- // Load the pending visible updates for this decl context, if it has any.
- auto I = PendingVisibleUpdates.find(ID);
- if (I != PendingVisibleUpdates.end()) {
- auto VisibleUpdates = std::move(I->second);
- PendingVisibleUpdates.erase(I);
-
- auto *DC = cast<DeclContext>(D)->getPrimaryContext();
- for (const PendingVisibleUpdate &Update : VisibleUpdates)
- Lookups[DC].Table.add(
- Update.Mod, Update.Data,
- reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod));
- DC->setHasExternalVisibleStorage(true);
- }
-
// The declaration may have been modified by files later in the chain.
// If this is the case, read the record containing the updates from each file
// and pass it to ASTDeclReader to make the modifications.
@@ -3389,7 +3503,8 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
assert(RecCode == DECL_UPDATES && "Expected DECL_UPDATES record!");
unsigned Idx = 0;
- ASTDeclReader Reader(*this, *F, ID, 0, Record, Idx);
+ ASTDeclReader Reader(*this, RecordLocation(F, Offset), ID,
+ SourceLocation(), Record, Idx);
Reader.UpdateDecl(D, *F, Record);
// We might have made this declaration interesting. If so, remember that
@@ -3401,6 +3516,20 @@ void ASTReader::loadDeclUpdateRecords(serialization::DeclID ID, Decl *D) {
}
}
}
+
+ // Load the pending visible updates for this decl context, if it has any.
+ auto I = PendingVisibleUpdates.find(ID);
+ if (I != PendingVisibleUpdates.end()) {
+ auto VisibleUpdates = std::move(I->second);
+ PendingVisibleUpdates.erase(I);
+
+ auto *DC = cast<DeclContext>(D)->getPrimaryContext();
+ for (const PendingVisibleUpdate &Update : VisibleUpdates)
+ Lookups[DC].Table.add(
+ Update.Mod, Update.Data,
+ reader::ASTDeclContextNameLookupTrait(*this, *Update.Mod));
+ DC->setHasExternalVisibleStorage(true);
+ }
}
void ASTReader::loadPendingDeclChain(Decl *FirstLocal, uint64_t LocalOffset) {
@@ -3661,8 +3790,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
CD->NumCtorInitializers = Record[Idx++];
if (CD->NumCtorInitializers)
- CD->CtorInitializers =
- Reader.ReadCXXCtorInitializersRef(F, Record, Idx);
+ CD->CtorInitializers = ReadGlobalOffset(F, Record, Idx);
}
// Store the offset of the body so we can lazily load it later.
Reader.PendingBodies[FD] = GetCurrentCursorOffset();
@@ -3673,14 +3801,14 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
auto *RD = cast<CXXRecordDecl>(D);
- auto *OldDD = RD->DefinitionData.getNotUpdated();
+ auto *OldDD = RD->getCanonicalDecl()->DefinitionData;
bool HadRealDefinition =
OldDD && (OldDD->Definition != RD ||
!Reader.PendingFakeDefinitionData.count(OldDD));
ReadCXXRecordDefinition(RD, /*Update*/true);
// Visible update is handled separately.
- uint64_t LexicalOffset = Record[Idx++];
+ uint64_t LexicalOffset = ReadLocalOffset(Record, Idx);
if (!HadRealDefinition && LexicalOffset) {
Reader.ReadLexicalDeclContextStorage(ModuleFile, ModuleFile.DeclsCursor,
LexicalOffset, RD);
@@ -3705,7 +3833,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
SmallVector<TemplateArgument, 8> TemplArgs;
Reader.ReadTemplateArgumentList(TemplArgs, F, Record, Idx);
auto *TemplArgList = TemplateArgumentList::CreateCopy(
- Reader.getContext(), TemplArgs.data(), TemplArgs.size());
+ Reader.getContext(), TemplArgs);
// FIXME: If we already have a partial specialization set,
// check that it matches.
@@ -3718,7 +3846,7 @@ 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->setRBraceLoc(Reader.ReadSourceLocation(ModuleFile, Record, Idx));
+ RD->setBraceRange(Reader.ReadSourceRange(ModuleFile, Record, Idx));
if (Record[Idx++]) {
AttrVec Attrs;
@@ -3778,7 +3906,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
// ASTMutationListeners other than an ASTWriter.
// Maintain AST consistency: any later redeclarations are used too.
- forAllLaterRedecls(D, [](Decl *D) { D->Used = true; });
+ D->setIsUsed();
break;
}
@@ -3820,6 +3948,7 @@ void ASTDeclReader::UpdateDecl(Decl *D, ModuleFile &ModuleFile,
break;
}
+ case UPD_DECL_MARKED_OPENMP_DECLARETARGET:
case UPD_ADDED_ATTR_TO_RECORD:
AttrVec Attrs;
Reader.ReadAttributes(F, Attrs, Record, Idx);
diff --git a/lib/Serialization/ASTReaderStmt.cpp b/lib/Serialization/ASTReaderStmt.cpp
index ad81ac844209..395da42d4f24 100644
--- a/lib/Serialization/ASTReaderStmt.cpp
+++ b/lib/Serialization/ASTReaderStmt.cpp
@@ -184,6 +184,8 @@ void ASTStmtReader::VisitAttributedStmt(AttributedStmt *S) {
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());
@@ -195,6 +197,7 @@ void ASTStmtReader::VisitIfStmt(IfStmt *S) {
void ASTStmtReader::VisitSwitchStmt(SwitchStmt *S) {
VisitStmt(S);
+ S->setInit(Reader.ReadSubStmt());
S->setConditionVariable(Reader.getContext(),
ReadDeclAs<VarDecl>(Record, Idx));
S->setCond(Reader.ReadSubExpr());
@@ -1179,6 +1182,14 @@ void ASTStmtReader::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
E->setLocation(ReadSourceLocation(Record, Idx));
}
+void ASTStmtReader::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
+ VisitExpr(E);
+ SourceRange R = Reader.ReadSourceRange(F, Record, Idx);
+ E->AtLoc = R.getBegin();
+ E->RParen = R.getEnd();
+ E->VersionToCheck = Reader.ReadVersionTuple(Record, Idx);
+}
+
//===----------------------------------------------------------------------===//
// C++ Expressions and Statements
//===----------------------------------------------------------------------===//
@@ -1207,7 +1218,8 @@ void ASTStmtReader::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
S->ColonLoc = ReadSourceLocation(Record, Idx);
S->RParenLoc = ReadSourceLocation(Record, Idx);
S->setRangeStmt(Reader.ReadSubStmt());
- S->setBeginEndStmt(Reader.ReadSubStmt());
+ S->setBeginStmt(Reader.ReadSubStmt());
+ S->setEndStmt(Reader.ReadSubStmt());
S->setCond(Reader.ReadSubExpr());
S->setInc(Reader.ReadSubExpr());
S->setLoopVarStmt(Reader.ReadSubStmt());
@@ -1248,6 +1260,14 @@ void ASTStmtReader::VisitCXXConstructExpr(CXXConstructExpr *E) {
E->ParenOrBraceRange = ReadSourceRange(Record, Idx);
}
+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++];
+}
+
void ASTStmtReader::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
VisitCXXConstructExpr(E);
E->Type = GetTypeSourceInfo(Record, Idx);
@@ -1447,6 +1467,7 @@ void ASTStmtReader::VisitExprWithCleanups(ExprWithCleanups *E) {
E->getTrailingObjects<BlockDecl *>()[i] =
ReadDeclAs<BlockDecl>(Record, Idx);
+ E->ExprWithCleanupsBits.CleanupsHaveSideEffects = Record[Idx++];
E->SubExpr = Reader.ReadSubExpr();
}
@@ -1679,6 +1700,8 @@ void ASTStmtReader::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
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()));
if (E->isTypeOperand()) { // __uuidof(ComType)
E->setTypeOperandSourceInfo(
GetTypeSourceInfo(Record, Idx));
@@ -1748,10 +1771,11 @@ public:
OMPClauseReader(ASTStmtReader *R, ASTContext &C,
const ASTReader::RecordData &Record, unsigned &Idx)
: Reader(R), Context(C), Record(Record), Idx(Idx) { }
-#define OPENMP_CLAUSE(Name, Class) \
- void Visit##Class(Class *S);
+#define OPENMP_CLAUSE(Name, Class) void Visit##Class(Class *C);
#include "clang/Basic/OpenMPKinds.def"
OMPClause *readClause();
+ void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
+ void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
};
}
@@ -1857,9 +1881,15 @@ OMPClause *OMPClauseReader::readClause() {
case OMPC_device:
C = new (Context) OMPDeviceClause();
break;
- case OMPC_map:
- C = OMPMapClause::CreateEmpty(Context, Record[Idx++]);
+ case OMPC_map: {
+ unsigned NumVars = Record[Idx++];
+ unsigned NumDeclarations = Record[Idx++];
+ unsigned NumLists = Record[Idx++];
+ unsigned NumComponents = Record[Idx++];
+ C = OMPMapClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
+ NumComponents);
break;
+ }
case OMPC_num_teams:
C = new (Context) OMPNumTeamsClause();
break;
@@ -1878,6 +1908,36 @@ OMPClause *OMPClauseReader::readClause() {
case OMPC_hint:
C = new (Context) OMPHintClause();
break;
+ case OMPC_dist_schedule:
+ C = new (Context) OMPDistScheduleClause();
+ break;
+ case OMPC_defaultmap:
+ C = new (Context) OMPDefaultmapClause();
+ break;
+ case OMPC_to: {
+ unsigned NumVars = Record[Idx++];
+ unsigned NumDeclarations = Record[Idx++];
+ unsigned NumLists = Record[Idx++];
+ unsigned NumComponents = Record[Idx++];
+ 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++];
+ C = OMPFromClause::CreateEmpty(Context, NumVars, NumDeclarations, NumLists,
+ NumComponents);
+ break;
+ }
+ case OMPC_use_device_ptr:
+ C = OMPUseDevicePtrClause::CreateEmpty(Context, Record[Idx++]);
+ break;
+ case OMPC_is_device_ptr:
+ C = OMPIsDevicePtrClause::CreateEmpty(Context, Record[Idx++]);
+ break;
}
Visit(C);
C->setLocStart(Reader->ReadSourceLocation(Record, Idx));
@@ -1886,6 +1946,15 @@ OMPClause *OMPClauseReader::readClause() {
return C;
}
+void OMPClauseReader::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
+ C->setPreInitStmt(Reader->Reader.ReadSubStmt());
+}
+
+void OMPClauseReader::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
+ VisitOMPClauseWithPreInit(C);
+ C->setPostUpdateExpr(Reader->Reader.ReadSubExpr());
+}
+
void OMPClauseReader::VisitOMPIfClause(OMPIfClause *C) {
C->setNameModifier(static_cast<OpenMPDirectiveKind>(Record[Idx++]));
C->setNameModifierLoc(Reader->ReadSourceLocation(Record, Idx));
@@ -1934,6 +2003,7 @@ void OMPClauseReader::VisitOMPProcBindClause(OMPProcBindClause *C) {
}
void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
+ VisitOMPClauseWithPreInit(C);
C->setScheduleKind(
static_cast<OpenMPScheduleClauseKind>(Record[Idx++]));
C->setFirstScheduleModifier(
@@ -1941,7 +2011,6 @@ void OMPClauseReader::VisitOMPScheduleClause(OMPScheduleClause *C) {
C->setSecondScheduleModifier(
static_cast<OpenMPScheduleClauseModifier>(Record[Idx++]));
C->setChunkSize(Reader->Reader.ReadSubExpr());
- C->setHelperChunkSize(Reader->Reader.ReadSubExpr());
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
C->setFirstScheduleModifierLoc(Reader->ReadSourceLocation(Record, Idx));
C->setSecondScheduleModifierLoc(Reader->ReadSourceLocation(Record, Idx));
@@ -1991,6 +2060,7 @@ void OMPClauseReader::VisitOMPPrivateClause(OMPPrivateClause *C) {
}
void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
+ VisitOMPClauseWithPreInit(C);
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
@@ -2009,6 +2079,7 @@ void OMPClauseReader::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
}
void OMPClauseReader::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
+ VisitOMPClauseWithPostUpdate(C);
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
unsigned NumVars = C->varlist_size();
SmallVector<Expr *, 16> Vars;
@@ -2045,6 +2116,7 @@ void OMPClauseReader::VisitOMPSharedClause(OMPSharedClause *C) {
}
void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
+ VisitOMPClauseWithPostUpdate(C);
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
NestedNameSpecifierLoc NNSL =
@@ -2079,6 +2151,7 @@ void OMPClauseReader::VisitOMPReductionClause(OMPReductionClause *C) {
}
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++]));
@@ -2186,6 +2259,7 @@ void OMPClauseReader::VisitOMPDependClause(OMPDependClause *C) {
for (unsigned i = 0; i != NumVars; ++i)
Vars.push_back(Reader->Reader.ReadSubExpr());
C->setVarRefs(Vars);
+ C->setCounterValue(Reader->Reader.ReadSubExpr());
}
void OMPClauseReader::VisitOMPDeviceClause(OMPDeviceClause *C) {
@@ -2202,12 +2276,45 @@ void OMPClauseReader::VisitOMPMapClause(OMPMapClause *C) {
C->setMapLoc(Reader->ReadSourceLocation(Record, Idx));
C->setColonLoc(Reader->ReadSourceLocation(Record, Idx));
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) {
+ for (unsigned i = 0; i != NumVars; ++i)
Vars.push_back(Reader->Reader.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));
+ C->setUniqueDecls(Decls);
+
+ SmallVector<unsigned, 16> ListsPerDecl;
+ ListsPerDecl.reserve(UniqueDecls);
+ for (unsigned i = 0; i < UniqueDecls; ++i)
+ ListsPerDecl.push_back(Record[Idx++]);
+ C->setDeclNumLists(ListsPerDecl);
+
+ SmallVector<unsigned, 32> ListSizes;
+ ListSizes.reserve(TotalLists);
+ for (unsigned i = 0; i < TotalLists; ++i)
+ ListSizes.push_back(Record[Idx++]);
+ 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);
+ Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+ AssociatedExpr, AssociatedDecl));
+ }
+ C->setComponents(Components, ListSizes);
}
void OMPClauseReader::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
@@ -2240,6 +2347,136 @@ void OMPClauseReader::VisitOMPHintClause(OMPHintClause *C) {
C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
}
+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));
+}
+
+void OMPClauseReader::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
+ C->setDefaultmapKind(
+ static_cast<OpenMPDefaultmapClauseKind>(Record[Idx++]));
+ 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));
+}
+
+void OMPClauseReader::VisitOMPToClause(OMPToClause *C) {
+ C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ 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());
+ 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));
+ C->setUniqueDecls(Decls);
+
+ SmallVector<unsigned, 16> ListsPerDecl;
+ ListsPerDecl.reserve(UniqueDecls);
+ for (unsigned i = 0; i < UniqueDecls; ++i)
+ ListsPerDecl.push_back(Record[Idx++]);
+ C->setDeclNumLists(ListsPerDecl);
+
+ SmallVector<unsigned, 32> ListSizes;
+ ListSizes.reserve(TotalLists);
+ for (unsigned i = 0; i < TotalLists; ++i)
+ ListSizes.push_back(Record[Idx++]);
+ 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);
+ Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+ AssociatedExpr, AssociatedDecl));
+ }
+ C->setComponents(Components, ListSizes);
+}
+
+void OMPClauseReader::VisitOMPFromClause(OMPFromClause *C) {
+ C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ 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());
+ 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));
+ C->setUniqueDecls(Decls);
+
+ SmallVector<unsigned, 16> ListsPerDecl;
+ ListsPerDecl.reserve(UniqueDecls);
+ for (unsigned i = 0; i < UniqueDecls; ++i)
+ ListsPerDecl.push_back(Record[Idx++]);
+ C->setDeclNumLists(ListsPerDecl);
+
+ SmallVector<unsigned, 32> ListSizes;
+ ListSizes.reserve(TotalLists);
+ for (unsigned i = 0; i < TotalLists; ++i)
+ ListSizes.push_back(Record[Idx++]);
+ 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);
+ Components.push_back(OMPClauseMappableExprCommon::MappableComponent(
+ AssociatedExpr, AssociatedDecl));
+ }
+ C->setComponents(Components, ListSizes);
+}
+
+void OMPClauseReader::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
+ C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ 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());
+ C->setVarRefs(Vars);
+ Vars.clear();
+}
+
+void OMPClauseReader::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
+ C->setLParenLoc(Reader->ReadSourceLocation(Record, Idx));
+ 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());
+ C->setVarRefs(Vars);
+ Vars.clear();
+}
+
//===----------------------------------------------------------------------===//
// OpenMP Directives.
//===----------------------------------------------------------------------===//
@@ -2267,7 +2504,10 @@ void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
D->setCond(Reader.ReadSubExpr());
D->setInit(Reader.ReadSubExpr());
D->setInc(Reader.ReadSubExpr());
- if (isOpenMPWorksharingDirective(D->getDirectiveKind())) {
+ D->setPreInits(Reader.ReadSubStmt());
+ if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
+ isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
+ isOpenMPDistributeDirective(D->getDirectiveKind())) {
D->setIsLastIterVariable(Reader.ReadSubExpr());
D->setLowerBoundVariable(Reader.ReadSubExpr());
D->setUpperBoundVariable(Reader.ReadSubExpr());
@@ -2275,6 +2515,11 @@ void ASTStmtReader::VisitOMPLoopDirective(OMPLoopDirective *D) {
D->setEnsureUpperBound(Reader.ReadSubExpr());
D->setNextLowerBound(Reader.ReadSubExpr());
D->setNextUpperBound(Reader.ReadSubExpr());
+ D->setNumIterations(Reader.ReadSubExpr());
+ }
+ if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
+ D->setPrevLowerBoundVariable(Reader.ReadSubExpr());
+ D->setPrevUpperBoundVariable(Reader.ReadSubExpr());
}
SmallVector<Expr *, 4> Sub;
unsigned CollapsedNum = D->getCollapsedNumber();
@@ -2442,6 +2687,33 @@ void ASTStmtReader::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
VisitOMPExecutableDirective(D);
}
+void ASTStmtReader::VisitOMPTargetEnterDataDirective(
+ OMPTargetEnterDataDirective *D) {
+ VisitStmt(D);
+ ++Idx;
+ VisitOMPExecutableDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTargetExitDataDirective(
+ OMPTargetExitDataDirective *D) {
+ VisitStmt(D);
+ ++Idx;
+ VisitOMPExecutableDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTargetParallelDirective(
+ OMPTargetParallelDirective *D) {
+ VisitStmt(D);
+ ++Idx;
+ VisitOMPExecutableDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTargetParallelForDirective(
+ OMPTargetParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+ D->setHasCancel(Record[Idx++]);
+}
+
void ASTStmtReader::VisitOMPTeamsDirective(OMPTeamsDirective *D) {
VisitStmt(D);
// The NumClauses field was read in ReadStmtFromStream.
@@ -2476,6 +2748,31 @@ void ASTStmtReader::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
VisitOMPLoopDirective(D);
}
+void ASTStmtReader::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
+ VisitStmt(D);
+ ++Idx;
+ VisitOMPExecutableDirective(D);
+}
+void ASTStmtReader::VisitOMPDistributeParallelForDirective(
+ OMPDistributeParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPDistributeParallelForSimdDirective(
+ OMPDistributeParallelForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPDistributeSimdDirective(
+ OMPDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
+void ASTStmtReader::VisitOMPTargetParallelForSimdDirective(
+ OMPTargetParallelForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+}
+
//===----------------------------------------------------------------------===//
// ASTReader Implementation
//===----------------------------------------------------------------------===//
@@ -2932,6 +3229,9 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
case EXPR_OBJC_BOOL_LITERAL:
S = new (Context) ObjCBoolLiteralExpr(Empty);
break;
+ case EXPR_OBJC_AVAILABILITY_CHECK:
+ S = new (Context) ObjCAvailabilityCheckExpr(Empty);
+ break;
case STMT_SEH_LEAVE:
S = new (Context) SEHLeaveStmt(Empty);
break;
@@ -3085,6 +3385,34 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
Context, Record[ASTStmtReader::NumStmtFields], Empty);
break;
+ case STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE:
+ S = OMPTargetEnterDataDirective::CreateEmpty(
+ Context, Record[ASTStmtReader::NumStmtFields], Empty);
+ break;
+
+ case STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE:
+ S = OMPTargetExitDataDirective::CreateEmpty(
+ Context, Record[ASTStmtReader::NumStmtFields], Empty);
+ break;
+
+ case STMT_OMP_TARGET_PARALLEL_DIRECTIVE:
+ S = OMPTargetParallelDirective::CreateEmpty(
+ Context, Record[ASTStmtReader::NumStmtFields], Empty);
+ break;
+
+ case STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE: {
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
+ unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTargetParallelForDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_TARGET_UPDATE_DIRECTIVE:
+ S = OMPTargetUpdateDirective::CreateEmpty(
+ Context, Record[ASTStmtReader::NumStmtFields], Empty);
+ break;
+
case STMT_OMP_TEAMS_DIRECTIVE:
S = OMPTeamsDirective::CreateEmpty(
Context, Record[ASTStmtReader::NumStmtFields], Empty);
@@ -3123,6 +3451,39 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
break;
}
+ case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE: {
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
+ unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPDistributeParallelForDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE: {
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
+ unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPDistributeParallelForSimdDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum,
+ Empty);
+ break;
+ }
+
+ case STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE: {
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
+ unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPDistributeSimdDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
+ case STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE: {
+ unsigned NumClauses = Record[ASTStmtReader::NumStmtFields];
+ unsigned CollapsedNum = Record[ASTStmtReader::NumStmtFields + 1];
+ S = OMPTargetParallelForSimdDirective::CreateEmpty(Context, NumClauses,
+ CollapsedNum, Empty);
+ break;
+ }
+
case EXPR_CXX_OPERATOR_CALL:
S = new (Context) CXXOperatorCallExpr(Context, Empty);
break;
@@ -3135,6 +3496,10 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = new (Context) CXXConstructExpr(Empty);
break;
+ case EXPR_CXX_INHERITED_CTOR_INIT:
+ S = new (Context) CXXInheritedCtorInitExpr(Empty);
+ break;
+
case EXPR_CXX_TEMPORARY_OBJECT:
S = new (Context) CXXTemporaryObjectExpr(Empty);
break;
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index ec04cd6c1fa9..bb6a8ae8f628 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -50,6 +50,7 @@
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Support/Compression.h"
#include "llvm/Support/EndianStream.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/MemoryBuffer.h"
@@ -81,19 +82,42 @@ static StringRef bytes(const SmallVectorImpl<T> &v) {
// Type serialization
//===----------------------------------------------------------------------===//
-namespace {
+namespace clang {
class ASTTypeWriter {
ASTWriter &Writer;
- ASTWriter::RecordDataImpl &Record;
+ ASTRecordWriter Record;
- public:
/// \brief Type code that corresponds to the record generated.
TypeCode Code;
/// \brief Abbreviation to use for the record, if any.
unsigned AbbrevToUse;
+ public:
ASTTypeWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
- : Writer(Writer), Record(Record), Code(TYPE_EXT_QUAL) { }
+ : Writer(Writer), Record(Writer, Record), Code((TypeCode)0), AbbrevToUse(0) { }
+
+ uint64_t Emit() {
+ return Record.Emit(Code, AbbrevToUse);
+ }
+
+ void Visit(QualType T) {
+ if (T.hasLocalNonFastQualifiers()) {
+ Qualifiers Qs = T.getLocalQualifiers();
+ Record.AddTypeRef(T.getLocalUnqualifiedType());
+ Record.push_back(Qs.getAsOpaqueValue());
+ Code = TYPE_EXT_QUAL;
+ AbbrevToUse = Writer.TypeExtQualAbbrev;
+ } else {
+ switch (T->getTypeClass()) {
+ // For all of the concrete, non-dependent types, call the
+ // appropriate visitor function.
+#define TYPE(Class, Base) \
+ case Type::Class: Visit##Class##Type(cast<Class##Type>(T)); break;
+#define ABSTRACT_TYPE(Class, Base)
+#include "clang/AST/TypeNodes.def"
+ }
+ }
+ }
void VisitArrayType(const ArrayType *T);
void VisitFunctionType(const FunctionType *T);
@@ -103,64 +127,64 @@ namespace {
#define ABSTRACT_TYPE(Class, Base)
#include "clang/AST/TypeNodes.def"
};
-} // end anonymous namespace
+} // end namespace clang
void ASTTypeWriter::VisitBuiltinType(const BuiltinType *T) {
llvm_unreachable("Built-in types are never serialized");
}
void ASTTypeWriter::VisitComplexType(const ComplexType *T) {
- Writer.AddTypeRef(T->getElementType(), Record);
+ Record.AddTypeRef(T->getElementType());
Code = TYPE_COMPLEX;
}
void ASTTypeWriter::VisitPointerType(const PointerType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
+ Record.AddTypeRef(T->getPointeeType());
Code = TYPE_POINTER;
}
void ASTTypeWriter::VisitDecayedType(const DecayedType *T) {
- Writer.AddTypeRef(T->getOriginalType(), Record);
+ Record.AddTypeRef(T->getOriginalType());
Code = TYPE_DECAYED;
}
void ASTTypeWriter::VisitAdjustedType(const AdjustedType *T) {
- Writer.AddTypeRef(T->getOriginalType(), Record);
- Writer.AddTypeRef(T->getAdjustedType(), Record);
+ Record.AddTypeRef(T->getOriginalType());
+ Record.AddTypeRef(T->getAdjustedType());
Code = TYPE_ADJUSTED;
}
void ASTTypeWriter::VisitBlockPointerType(const BlockPointerType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
+ Record.AddTypeRef(T->getPointeeType());
Code = TYPE_BLOCK_POINTER;
}
void ASTTypeWriter::VisitLValueReferenceType(const LValueReferenceType *T) {
- Writer.AddTypeRef(T->getPointeeTypeAsWritten(), Record);
+ Record.AddTypeRef(T->getPointeeTypeAsWritten());
Record.push_back(T->isSpelledAsLValue());
Code = TYPE_LVALUE_REFERENCE;
}
void ASTTypeWriter::VisitRValueReferenceType(const RValueReferenceType *T) {
- Writer.AddTypeRef(T->getPointeeTypeAsWritten(), Record);
+ Record.AddTypeRef(T->getPointeeTypeAsWritten());
Code = TYPE_RVALUE_REFERENCE;
}
void ASTTypeWriter::VisitMemberPointerType(const MemberPointerType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
- Writer.AddTypeRef(QualType(T->getClass(), 0), Record);
+ Record.AddTypeRef(T->getPointeeType());
+ Record.AddTypeRef(QualType(T->getClass(), 0));
Code = TYPE_MEMBER_POINTER;
}
void ASTTypeWriter::VisitArrayType(const ArrayType *T) {
- Writer.AddTypeRef(T->getElementType(), Record);
+ Record.AddTypeRef(T->getElementType());
Record.push_back(T->getSizeModifier()); // FIXME: stable values
Record.push_back(T->getIndexTypeCVRQualifiers()); // FIXME: stable values
}
void ASTTypeWriter::VisitConstantArrayType(const ConstantArrayType *T) {
VisitArrayType(T);
- Writer.AddAPInt(T->getSize(), Record);
+ Record.AddAPInt(T->getSize());
Code = TYPE_CONSTANT_ARRAY;
}
@@ -171,14 +195,14 @@ void ASTTypeWriter::VisitIncompleteArrayType(const IncompleteArrayType *T) {
void ASTTypeWriter::VisitVariableArrayType(const VariableArrayType *T) {
VisitArrayType(T);
- Writer.AddSourceLocation(T->getLBracketLoc(), Record);
- Writer.AddSourceLocation(T->getRBracketLoc(), Record);
- Writer.AddStmt(T->getSizeExpr());
+ Record.AddSourceLocation(T->getLBracketLoc());
+ Record.AddSourceLocation(T->getRBracketLoc());
+ Record.AddStmt(T->getSizeExpr());
Code = TYPE_VARIABLE_ARRAY;
}
void ASTTypeWriter::VisitVectorType(const VectorType *T) {
- Writer.AddTypeRef(T->getElementType(), Record);
+ Record.AddTypeRef(T->getElementType());
Record.push_back(T->getNumElements());
Record.push_back(T->getVectorKind());
Code = TYPE_VECTOR;
@@ -190,7 +214,7 @@ void ASTTypeWriter::VisitExtVectorType(const ExtVectorType *T) {
}
void ASTTypeWriter::VisitFunctionType(const FunctionType *T) {
- Writer.AddTypeRef(T->getReturnType(), Record);
+ Record.AddTypeRef(T->getReturnType());
FunctionType::ExtInfo C = T->getExtInfo();
Record.push_back(C.getNoReturn());
Record.push_back(C.getHasRegParm());
@@ -208,20 +232,20 @@ void ASTTypeWriter::VisitFunctionNoProtoType(const FunctionNoProtoType *T) {
Code = TYPE_FUNCTION_NO_PROTO;
}
-static void addExceptionSpec(ASTWriter &Writer, const FunctionProtoType *T,
- ASTWriter::RecordDataImpl &Record) {
+static void addExceptionSpec(const FunctionProtoType *T,
+ ASTRecordWriter &Record) {
Record.push_back(T->getExceptionSpecType());
if (T->getExceptionSpecType() == EST_Dynamic) {
Record.push_back(T->getNumExceptions());
for (unsigned I = 0, N = T->getNumExceptions(); I != N; ++I)
- Writer.AddTypeRef(T->getExceptionType(I), Record);
+ Record.AddTypeRef(T->getExceptionType(I));
} else if (T->getExceptionSpecType() == EST_ComputedNoexcept) {
- Writer.AddStmt(T->getNoexceptExpr());
+ Record.AddStmt(T->getNoexceptExpr());
} else if (T->getExceptionSpecType() == EST_Uninstantiated) {
- Writer.AddDeclRef(T->getExceptionSpecDecl(), Record);
- Writer.AddDeclRef(T->getExceptionSpecTemplate(), Record);
+ Record.AddDeclRef(T->getExceptionSpecDecl());
+ Record.AddDeclRef(T->getExceptionSpecTemplate());
} else if (T->getExceptionSpecType() == EST_Unevaluated) {
- Writer.AddDeclRef(T->getExceptionSpecDecl(), Record);
+ Record.AddDeclRef(T->getExceptionSpecDecl());
}
}
@@ -232,56 +256,62 @@ void ASTTypeWriter::VisitFunctionProtoType(const FunctionProtoType *T) {
Record.push_back(T->hasTrailingReturn());
Record.push_back(T->getTypeQuals());
Record.push_back(static_cast<unsigned>(T->getRefQualifier()));
- addExceptionSpec(Writer, T, Record);
+ addExceptionSpec(T, Record);
Record.push_back(T->getNumParams());
for (unsigned I = 0, N = T->getNumParams(); I != N; ++I)
- Writer.AddTypeRef(T->getParamType(I), Record);
+ Record.AddTypeRef(T->getParamType(I));
+
+ if (T->hasExtParameterInfos()) {
+ for (unsigned I = 0, N = T->getNumParams(); I != N; ++I)
+ Record.push_back(T->getExtParameterInfo(I).getOpaqueValue());
+ }
if (T->isVariadic() || T->hasTrailingReturn() || T->getTypeQuals() ||
- T->getRefQualifier() || T->getExceptionSpecType() != EST_None)
+ T->getRefQualifier() || T->getExceptionSpecType() != EST_None ||
+ T->hasExtParameterInfos())
AbbrevToUse = 0;
Code = TYPE_FUNCTION_PROTO;
}
void ASTTypeWriter::VisitUnresolvedUsingType(const UnresolvedUsingType *T) {
- Writer.AddDeclRef(T->getDecl(), Record);
+ Record.AddDeclRef(T->getDecl());
Code = TYPE_UNRESOLVED_USING;
}
void ASTTypeWriter::VisitTypedefType(const TypedefType *T) {
- Writer.AddDeclRef(T->getDecl(), Record);
+ Record.AddDeclRef(T->getDecl());
assert(!T->isCanonicalUnqualified() && "Invalid typedef ?");
- Writer.AddTypeRef(T->getCanonicalTypeInternal(), Record);
+ Record.AddTypeRef(T->getCanonicalTypeInternal());
Code = TYPE_TYPEDEF;
}
void ASTTypeWriter::VisitTypeOfExprType(const TypeOfExprType *T) {
- Writer.AddStmt(T->getUnderlyingExpr());
+ Record.AddStmt(T->getUnderlyingExpr());
Code = TYPE_TYPEOF_EXPR;
}
void ASTTypeWriter::VisitTypeOfType(const TypeOfType *T) {
- Writer.AddTypeRef(T->getUnderlyingType(), Record);
+ Record.AddTypeRef(T->getUnderlyingType());
Code = TYPE_TYPEOF;
}
void ASTTypeWriter::VisitDecltypeType(const DecltypeType *T) {
- Writer.AddTypeRef(T->getUnderlyingType(), Record);
- Writer.AddStmt(T->getUnderlyingExpr());
+ Record.AddTypeRef(T->getUnderlyingType());
+ Record.AddStmt(T->getUnderlyingExpr());
Code = TYPE_DECLTYPE;
}
void ASTTypeWriter::VisitUnaryTransformType(const UnaryTransformType *T) {
- Writer.AddTypeRef(T->getBaseType(), Record);
- Writer.AddTypeRef(T->getUnderlyingType(), Record);
+ Record.AddTypeRef(T->getBaseType());
+ Record.AddTypeRef(T->getUnderlyingType());
Record.push_back(T->getUTTKind());
Code = TYPE_UNARY_TRANSFORM;
}
void ASTTypeWriter::VisitAutoType(const AutoType *T) {
- Writer.AddTypeRef(T->getDeducedType(), Record);
+ Record.AddTypeRef(T->getDeducedType());
Record.push_back((unsigned)T->getKeyword());
if (T->getDeducedType().isNull())
Record.push_back(T->isDependentType());
@@ -290,7 +320,7 @@ void ASTTypeWriter::VisitAutoType(const AutoType *T) {
void ASTTypeWriter::VisitTagType(const TagType *T) {
Record.push_back(T->isDependentType());
- Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record);
+ Record.AddDeclRef(T->getDecl()->getCanonicalDecl());
assert(!T->isBeingDefined() &&
"Cannot serialize in the middle of a type definition");
}
@@ -306,8 +336,8 @@ void ASTTypeWriter::VisitEnumType(const EnumType *T) {
}
void ASTTypeWriter::VisitAttributedType(const AttributedType *T) {
- Writer.AddTypeRef(T->getModifiedType(), Record);
- Writer.AddTypeRef(T->getEquivalentType(), Record);
+ Record.AddTypeRef(T->getModifiedType());
+ Record.AddTypeRef(T->getEquivalentType());
Record.push_back(T->getAttrKind());
Code = TYPE_ATTRIBUTED;
}
@@ -315,16 +345,16 @@ void ASTTypeWriter::VisitAttributedType(const AttributedType *T) {
void
ASTTypeWriter::VisitSubstTemplateTypeParmType(
const SubstTemplateTypeParmType *T) {
- Writer.AddTypeRef(QualType(T->getReplacedParameter(), 0), Record);
- Writer.AddTypeRef(T->getReplacementType(), Record);
+ Record.AddTypeRef(QualType(T->getReplacedParameter(), 0));
+ Record.AddTypeRef(T->getReplacementType());
Code = TYPE_SUBST_TEMPLATE_TYPE_PARM;
}
void
ASTTypeWriter::VisitSubstTemplateTypeParmPackType(
const SubstTemplateTypeParmPackType *T) {
- Writer.AddTypeRef(QualType(T->getReplacedParameter(), 0), Record);
- Writer.AddTemplateArgument(T->getArgumentPack(), Record);
+ Record.AddTypeRef(QualType(T->getReplacedParameter(), 0));
+ Record.AddTemplateArgument(T->getArgumentPack());
Code = TYPE_SUBST_TEMPLATE_TYPE_PARM_PACK;
}
@@ -332,22 +362,22 @@ void
ASTTypeWriter::VisitTemplateSpecializationType(
const TemplateSpecializationType *T) {
Record.push_back(T->isDependentType());
- Writer.AddTemplateName(T->getTemplateName(), Record);
+ Record.AddTemplateName(T->getTemplateName());
Record.push_back(T->getNumArgs());
for (const auto &ArgI : *T)
- Writer.AddTemplateArgument(ArgI, Record);
- Writer.AddTypeRef(T->isTypeAlias() ? T->getAliasedType() :
- T->isCanonicalUnqualified() ? QualType()
- : T->getCanonicalTypeInternal(),
- Record);
+ Record.AddTemplateArgument(ArgI);
+ Record.AddTypeRef(T->isTypeAlias() ? T->getAliasedType()
+ : T->isCanonicalUnqualified()
+ ? QualType()
+ : T->getCanonicalTypeInternal());
Code = TYPE_TEMPLATE_SPECIALIZATION;
}
void
ASTTypeWriter::VisitDependentSizedArrayType(const DependentSizedArrayType *T) {
VisitArrayType(T);
- Writer.AddStmt(T->getSizeExpr());
- Writer.AddSourceRange(T->getBracketsRange(), Record);
+ Record.AddStmt(T->getSizeExpr());
+ Record.AddSourceRange(T->getBracketsRange());
Code = TYPE_DEPENDENT_SIZED_ARRAY;
}
@@ -363,18 +393,17 @@ ASTTypeWriter::VisitTemplateTypeParmType(const TemplateTypeParmType *T) {
Record.push_back(T->getDepth());
Record.push_back(T->getIndex());
Record.push_back(T->isParameterPack());
- Writer.AddDeclRef(T->getDecl(), Record);
+ Record.AddDeclRef(T->getDecl());
Code = TYPE_TEMPLATE_TYPE_PARM;
}
void
ASTTypeWriter::VisitDependentNameType(const DependentNameType *T) {
Record.push_back(T->getKeyword());
- Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
- Writer.AddIdentifierRef(T->getIdentifier(), Record);
- Writer.AddTypeRef(T->isCanonicalUnqualified() ? QualType()
- : T->getCanonicalTypeInternal(),
- Record);
+ Record.AddNestedNameSpecifier(T->getQualifier());
+ Record.AddIdentifierRef(T->getIdentifier());
+ Record.AddTypeRef(
+ T->isCanonicalUnqualified() ? QualType() : T->getCanonicalTypeInternal());
Code = TYPE_DEPENDENT_NAME;
}
@@ -382,16 +411,16 @@ void
ASTTypeWriter::VisitDependentTemplateSpecializationType(
const DependentTemplateSpecializationType *T) {
Record.push_back(T->getKeyword());
- Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
- Writer.AddIdentifierRef(T->getIdentifier(), Record);
+ Record.AddNestedNameSpecifier(T->getQualifier());
+ Record.AddIdentifierRef(T->getIdentifier());
Record.push_back(T->getNumArgs());
for (const auto &I : *T)
- Writer.AddTemplateArgument(I, Record);
+ Record.AddTemplateArgument(I);
Code = TYPE_DEPENDENT_TEMPLATE_SPECIALIZATION;
}
void ASTTypeWriter::VisitPackExpansionType(const PackExpansionType *T) {
- Writer.AddTypeRef(T->getPattern(), Record);
+ Record.AddTypeRef(T->getPattern());
if (Optional<unsigned> NumExpansions = T->getNumExpansions())
Record.push_back(*NumExpansions + 1);
else
@@ -400,67 +429,66 @@ void ASTTypeWriter::VisitPackExpansionType(const PackExpansionType *T) {
}
void ASTTypeWriter::VisitParenType(const ParenType *T) {
- Writer.AddTypeRef(T->getInnerType(), Record);
+ Record.AddTypeRef(T->getInnerType());
Code = TYPE_PAREN;
}
void ASTTypeWriter::VisitElaboratedType(const ElaboratedType *T) {
Record.push_back(T->getKeyword());
- Writer.AddNestedNameSpecifier(T->getQualifier(), Record);
- Writer.AddTypeRef(T->getNamedType(), Record);
+ Record.AddNestedNameSpecifier(T->getQualifier());
+ Record.AddTypeRef(T->getNamedType());
Code = TYPE_ELABORATED;
}
void ASTTypeWriter::VisitInjectedClassNameType(const InjectedClassNameType *T) {
- Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record);
- Writer.AddTypeRef(T->getInjectedSpecializationType(), Record);
+ Record.AddDeclRef(T->getDecl()->getCanonicalDecl());
+ Record.AddTypeRef(T->getInjectedSpecializationType());
Code = TYPE_INJECTED_CLASS_NAME;
}
void ASTTypeWriter::VisitObjCInterfaceType(const ObjCInterfaceType *T) {
- Writer.AddDeclRef(T->getDecl()->getCanonicalDecl(), Record);
+ Record.AddDeclRef(T->getDecl()->getCanonicalDecl());
Code = TYPE_OBJC_INTERFACE;
}
void ASTTypeWriter::VisitObjCObjectType(const ObjCObjectType *T) {
- Writer.AddTypeRef(T->getBaseType(), Record);
+ Record.AddTypeRef(T->getBaseType());
Record.push_back(T->getTypeArgsAsWritten().size());
for (auto TypeArg : T->getTypeArgsAsWritten())
- Writer.AddTypeRef(TypeArg, Record);
+ Record.AddTypeRef(TypeArg);
Record.push_back(T->getNumProtocols());
for (const auto *I : T->quals())
- Writer.AddDeclRef(I, Record);
+ Record.AddDeclRef(I);
Record.push_back(T->isKindOfTypeAsWritten());
Code = TYPE_OBJC_OBJECT;
}
void
ASTTypeWriter::VisitObjCObjectPointerType(const ObjCObjectPointerType *T) {
- Writer.AddTypeRef(T->getPointeeType(), Record);
+ Record.AddTypeRef(T->getPointeeType());
Code = TYPE_OBJC_OBJECT_POINTER;
}
void
ASTTypeWriter::VisitAtomicType(const AtomicType *T) {
- Writer.AddTypeRef(T->getValueType(), Record);
+ Record.AddTypeRef(T->getValueType());
Code = TYPE_ATOMIC;
}
void
ASTTypeWriter::VisitPipeType(const PipeType *T) {
- Writer.AddTypeRef(T->getElementType(), Record);
+ Record.AddTypeRef(T->getElementType());
Code = TYPE_PIPE;
}
namespace {
class TypeLocWriter : public TypeLocVisitor<TypeLocWriter> {
- ASTWriter &Writer;
- ASTWriter::RecordDataImpl &Record;
+ ASTRecordWriter &Record;
public:
- TypeLocWriter(ASTWriter &Writer, ASTWriter::RecordDataImpl &Record)
- : Writer(Writer), Record(Record) { }
+ TypeLocWriter(ASTRecordWriter &Record)
+ : Record(Record) { }
#define ABSTRACT_TYPELOC(CLASS, PARENT)
#define TYPELOC(CLASS, PARENT) \
@@ -477,7 +505,7 @@ void TypeLocWriter::VisitQualifiedTypeLoc(QualifiedTypeLoc TL) {
// nothing to do
}
void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
- Writer.AddSourceLocation(TL.getBuiltinLoc(), Record);
+ Record.AddSourceLocation(TL.getBuiltinLoc());
if (TL.needsExtraLocalData()) {
Record.push_back(TL.getWrittenTypeSpec());
Record.push_back(TL.getWrittenSignSpec());
@@ -486,10 +514,10 @@ void TypeLocWriter::VisitBuiltinTypeLoc(BuiltinTypeLoc TL) {
}
}
void TypeLocWriter::VisitComplexTypeLoc(ComplexTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitPointerTypeLoc(PointerTypeLoc TL) {
- Writer.AddSourceLocation(TL.getStarLoc(), Record);
+ Record.AddSourceLocation(TL.getStarLoc());
}
void TypeLocWriter::VisitDecayedTypeLoc(DecayedTypeLoc TL) {
// nothing to do
@@ -498,24 +526,24 @@ void TypeLocWriter::VisitAdjustedTypeLoc(AdjustedTypeLoc TL) {
// nothing to do
}
void TypeLocWriter::VisitBlockPointerTypeLoc(BlockPointerTypeLoc TL) {
- Writer.AddSourceLocation(TL.getCaretLoc(), Record);
+ Record.AddSourceLocation(TL.getCaretLoc());
}
void TypeLocWriter::VisitLValueReferenceTypeLoc(LValueReferenceTypeLoc TL) {
- Writer.AddSourceLocation(TL.getAmpLoc(), Record);
+ Record.AddSourceLocation(TL.getAmpLoc());
}
void TypeLocWriter::VisitRValueReferenceTypeLoc(RValueReferenceTypeLoc TL) {
- Writer.AddSourceLocation(TL.getAmpAmpLoc(), Record);
+ Record.AddSourceLocation(TL.getAmpAmpLoc());
}
void TypeLocWriter::VisitMemberPointerTypeLoc(MemberPointerTypeLoc TL) {
- Writer.AddSourceLocation(TL.getStarLoc(), Record);
- Writer.AddTypeSourceInfo(TL.getClassTInfo(), Record);
+ Record.AddSourceLocation(TL.getStarLoc());
+ Record.AddTypeSourceInfo(TL.getClassTInfo());
}
void TypeLocWriter::VisitArrayTypeLoc(ArrayTypeLoc TL) {
- Writer.AddSourceLocation(TL.getLBracketLoc(), Record);
- Writer.AddSourceLocation(TL.getRBracketLoc(), Record);
+ Record.AddSourceLocation(TL.getLBracketLoc());
+ Record.AddSourceLocation(TL.getRBracketLoc());
Record.push_back(TL.getSizeExpr() ? 1 : 0);
if (TL.getSizeExpr())
- Writer.AddStmt(TL.getSizeExpr());
+ Record.AddStmt(TL.getSizeExpr());
}
void TypeLocWriter::VisitConstantArrayTypeLoc(ConstantArrayTypeLoc TL) {
VisitArrayTypeLoc(TL);
@@ -532,21 +560,21 @@ void TypeLocWriter::VisitDependentSizedArrayTypeLoc(
}
void TypeLocWriter::VisitDependentSizedExtVectorTypeLoc(
DependentSizedExtVectorTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitVectorTypeLoc(VectorTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitFunctionTypeLoc(FunctionTypeLoc TL) {
- Writer.AddSourceLocation(TL.getLocalRangeBegin(), Record);
- Writer.AddSourceLocation(TL.getLParenLoc(), Record);
- Writer.AddSourceLocation(TL.getRParenLoc(), Record);
- Writer.AddSourceLocation(TL.getLocalRangeEnd(), Record);
+ Record.AddSourceLocation(TL.getLocalRangeBegin());
+ Record.AddSourceLocation(TL.getLParenLoc());
+ Record.AddSourceLocation(TL.getRParenLoc());
+ Record.AddSourceLocation(TL.getLocalRangeEnd());
for (unsigned i = 0, e = TL.getNumParams(); i != e; ++i)
- Writer.AddDeclRef(TL.getParam(i), Record);
+ Record.AddDeclRef(TL.getParam(i));
}
void TypeLocWriter::VisitFunctionProtoTypeLoc(FunctionProtoTypeLoc TL) {
VisitFunctionTypeLoc(TL);
@@ -555,131 +583,131 @@ void TypeLocWriter::VisitFunctionNoProtoTypeLoc(FunctionNoProtoTypeLoc TL) {
VisitFunctionTypeLoc(TL);
}
void TypeLocWriter::VisitUnresolvedUsingTypeLoc(UnresolvedUsingTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitTypedefTypeLoc(TypedefTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitTypeOfExprTypeLoc(TypeOfExprTypeLoc TL) {
- Writer.AddSourceLocation(TL.getTypeofLoc(), Record);
- Writer.AddSourceLocation(TL.getLParenLoc(), Record);
- Writer.AddSourceLocation(TL.getRParenLoc(), Record);
+ Record.AddSourceLocation(TL.getTypeofLoc());
+ Record.AddSourceLocation(TL.getLParenLoc());
+ Record.AddSourceLocation(TL.getRParenLoc());
}
void TypeLocWriter::VisitTypeOfTypeLoc(TypeOfTypeLoc TL) {
- Writer.AddSourceLocation(TL.getTypeofLoc(), Record);
- Writer.AddSourceLocation(TL.getLParenLoc(), Record);
- Writer.AddSourceLocation(TL.getRParenLoc(), Record);
- Writer.AddTypeSourceInfo(TL.getUnderlyingTInfo(), Record);
+ Record.AddSourceLocation(TL.getTypeofLoc());
+ Record.AddSourceLocation(TL.getLParenLoc());
+ Record.AddSourceLocation(TL.getRParenLoc());
+ Record.AddTypeSourceInfo(TL.getUnderlyingTInfo());
}
void TypeLocWriter::VisitDecltypeTypeLoc(DecltypeTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
- Writer.AddSourceLocation(TL.getKWLoc(), Record);
- Writer.AddSourceLocation(TL.getLParenLoc(), Record);
- Writer.AddSourceLocation(TL.getRParenLoc(), Record);
- Writer.AddTypeSourceInfo(TL.getUnderlyingTInfo(), Record);
+ Record.AddSourceLocation(TL.getKWLoc());
+ Record.AddSourceLocation(TL.getLParenLoc());
+ Record.AddSourceLocation(TL.getRParenLoc());
+ Record.AddTypeSourceInfo(TL.getUnderlyingTInfo());
}
void TypeLocWriter::VisitAutoTypeLoc(AutoTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitRecordTypeLoc(RecordTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitEnumTypeLoc(EnumTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitAttributedTypeLoc(AttributedTypeLoc TL) {
- Writer.AddSourceLocation(TL.getAttrNameLoc(), Record);
+ Record.AddSourceLocation(TL.getAttrNameLoc());
if (TL.hasAttrOperand()) {
SourceRange range = TL.getAttrOperandParensRange();
- Writer.AddSourceLocation(range.getBegin(), Record);
- Writer.AddSourceLocation(range.getEnd(), Record);
+ Record.AddSourceLocation(range.getBegin());
+ Record.AddSourceLocation(range.getEnd());
}
if (TL.hasAttrExprOperand()) {
Expr *operand = TL.getAttrExprOperand();
Record.push_back(operand ? 1 : 0);
- if (operand) Writer.AddStmt(operand);
+ if (operand) Record.AddStmt(operand);
} else if (TL.hasAttrEnumOperand()) {
- Writer.AddSourceLocation(TL.getAttrEnumOperandLoc(), Record);
+ Record.AddSourceLocation(TL.getAttrEnumOperandLoc());
}
}
void TypeLocWriter::VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitSubstTemplateTypeParmTypeLoc(
SubstTemplateTypeParmTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitSubstTemplateTypeParmPackTypeLoc(
SubstTemplateTypeParmPackTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitTemplateSpecializationTypeLoc(
TemplateSpecializationTypeLoc TL) {
- Writer.AddSourceLocation(TL.getTemplateKeywordLoc(), Record);
- Writer.AddSourceLocation(TL.getTemplateNameLoc(), Record);
- Writer.AddSourceLocation(TL.getLAngleLoc(), Record);
- Writer.AddSourceLocation(TL.getRAngleLoc(), Record);
+ Record.AddSourceLocation(TL.getTemplateKeywordLoc());
+ Record.AddSourceLocation(TL.getTemplateNameLoc());
+ Record.AddSourceLocation(TL.getLAngleLoc());
+ Record.AddSourceLocation(TL.getRAngleLoc());
for (unsigned i = 0, e = TL.getNumArgs(); i != e; ++i)
- Writer.AddTemplateArgumentLocInfo(TL.getArgLoc(i).getArgument().getKind(),
- TL.getArgLoc(i).getLocInfo(), Record);
+ Record.AddTemplateArgumentLocInfo(TL.getArgLoc(i).getArgument().getKind(),
+ TL.getArgLoc(i).getLocInfo());
}
void TypeLocWriter::VisitParenTypeLoc(ParenTypeLoc TL) {
- Writer.AddSourceLocation(TL.getLParenLoc(), Record);
- Writer.AddSourceLocation(TL.getRParenLoc(), Record);
+ Record.AddSourceLocation(TL.getLParenLoc());
+ Record.AddSourceLocation(TL.getRParenLoc());
}
void TypeLocWriter::VisitElaboratedTypeLoc(ElaboratedTypeLoc TL) {
- Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record);
+ Record.AddSourceLocation(TL.getElaboratedKeywordLoc());
+ Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());
}
void TypeLocWriter::VisitInjectedClassNameTypeLoc(InjectedClassNameTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitDependentNameTypeLoc(DependentNameTypeLoc TL) {
- Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record);
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getElaboratedKeywordLoc());
+ Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitDependentTemplateSpecializationTypeLoc(
DependentTemplateSpecializationTypeLoc TL) {
- Writer.AddSourceLocation(TL.getElaboratedKeywordLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(TL.getQualifierLoc(), Record);
- Writer.AddSourceLocation(TL.getTemplateKeywordLoc(), Record);
- Writer.AddSourceLocation(TL.getTemplateNameLoc(), Record);
- Writer.AddSourceLocation(TL.getLAngleLoc(), Record);
- Writer.AddSourceLocation(TL.getRAngleLoc(), Record);
+ Record.AddSourceLocation(TL.getElaboratedKeywordLoc());
+ Record.AddNestedNameSpecifierLoc(TL.getQualifierLoc());
+ Record.AddSourceLocation(TL.getTemplateKeywordLoc());
+ Record.AddSourceLocation(TL.getTemplateNameLoc());
+ Record.AddSourceLocation(TL.getLAngleLoc());
+ Record.AddSourceLocation(TL.getRAngleLoc());
for (unsigned I = 0, E = TL.getNumArgs(); I != E; ++I)
- Writer.AddTemplateArgumentLocInfo(TL.getArgLoc(I).getArgument().getKind(),
- TL.getArgLoc(I).getLocInfo(), Record);
+ Record.AddTemplateArgumentLocInfo(TL.getArgLoc(I).getArgument().getKind(),
+ TL.getArgLoc(I).getLocInfo());
}
void TypeLocWriter::VisitPackExpansionTypeLoc(PackExpansionTypeLoc TL) {
- Writer.AddSourceLocation(TL.getEllipsisLoc(), Record);
+ Record.AddSourceLocation(TL.getEllipsisLoc());
}
void TypeLocWriter::VisitObjCInterfaceTypeLoc(ObjCInterfaceTypeLoc TL) {
- Writer.AddSourceLocation(TL.getNameLoc(), Record);
+ Record.AddSourceLocation(TL.getNameLoc());
}
void TypeLocWriter::VisitObjCObjectTypeLoc(ObjCObjectTypeLoc TL) {
Record.push_back(TL.hasBaseTypeAsWritten());
- Writer.AddSourceLocation(TL.getTypeArgsLAngleLoc(), Record);
- Writer.AddSourceLocation(TL.getTypeArgsRAngleLoc(), Record);
+ Record.AddSourceLocation(TL.getTypeArgsLAngleLoc());
+ Record.AddSourceLocation(TL.getTypeArgsRAngleLoc());
for (unsigned i = 0, e = TL.getNumTypeArgs(); i != e; ++i)
- Writer.AddTypeSourceInfo(TL.getTypeArgTInfo(i), Record);
- Writer.AddSourceLocation(TL.getProtocolLAngleLoc(), Record);
- Writer.AddSourceLocation(TL.getProtocolRAngleLoc(), Record);
+ Record.AddTypeSourceInfo(TL.getTypeArgTInfo(i));
+ Record.AddSourceLocation(TL.getProtocolLAngleLoc());
+ Record.AddSourceLocation(TL.getProtocolRAngleLoc());
for (unsigned i = 0, e = TL.getNumProtocols(); i != e; ++i)
- Writer.AddSourceLocation(TL.getProtocolLoc(i), Record);
+ Record.AddSourceLocation(TL.getProtocolLoc(i));
}
void TypeLocWriter::VisitObjCObjectPointerTypeLoc(ObjCObjectPointerTypeLoc TL) {
- Writer.AddSourceLocation(TL.getStarLoc(), Record);
+ Record.AddSourceLocation(TL.getStarLoc());
}
void TypeLocWriter::VisitAtomicTypeLoc(AtomicTypeLoc TL) {
- Writer.AddSourceLocation(TL.getKWLoc(), Record);
- Writer.AddSourceLocation(TL.getLParenLoc(), Record);
- Writer.AddSourceLocation(TL.getRParenLoc(), Record);
+ Record.AddSourceLocation(TL.getKWLoc());
+ Record.AddSourceLocation(TL.getLParenLoc());
+ Record.AddSourceLocation(TL.getRParenLoc());
}
void TypeLocWriter::VisitPipeTypeLoc(PipeTypeLoc TL) {
- Writer.AddSourceLocation(TL.getKWLoc(), Record);
+ Record.AddSourceLocation(TL.getKWLoc());
}
void ASTWriter::WriteTypeAbbrevs() {
@@ -930,11 +958,9 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(SEMA_DECL_REFS);
RECORD(WEAK_UNDECLARED_IDENTIFIERS);
RECORD(PENDING_IMPLICIT_INSTANTIATIONS);
- RECORD(DECL_REPLACEMENTS);
RECORD(UPDATE_VISIBLE);
RECORD(DECL_UPDATE_OFFSETS);
RECORD(DECL_UPDATES);
- RECORD(CXX_BASE_SPECIFIER_OFFSETS);
RECORD(DIAG_PRAGMA_MAPPINGS);
RECORD(CUDA_SPECIAL_DECL_REFS);
RECORD(HEADER_SEARCH_TABLE);
@@ -953,8 +979,9 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(UNDEFINED_BUT_USED);
RECORD(LATE_PARSED_TEMPLATE);
RECORD(OPTIMIZE_PRAGMA_OPTIONS);
+ RECORD(MSSTRUCT_PRAGMA_OPTIONS);
+ RECORD(POINTERS_TO_MEMBERS_PRAGMA_OPTIONS);
RECORD(UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES);
- RECORD(CXX_CTOR_INITIALIZERS_OFFSETS);
RECORD(DELETE_EXPRS_TO_ANALYZE);
// SourceManager Block.
@@ -962,6 +989,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(SM_SLOC_FILE_ENTRY);
RECORD(SM_SLOC_BUFFER_ENTRY);
RECORD(SM_SLOC_BUFFER_BLOB);
+ RECORD(SM_SLOC_BUFFER_BLOB_COMPRESSED);
RECORD(SM_SLOC_EXPANSION_ENTRY);
// Preprocessor Block.
@@ -1076,6 +1104,7 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(DECL_CXX_RECORD);
RECORD(DECL_CXX_METHOD);
RECORD(DECL_CXX_CONSTRUCTOR);
+ RECORD(DECL_CXX_INHERITED_CONSTRUCTOR);
RECORD(DECL_CXX_DESTRUCTOR);
RECORD(DECL_CXX_CONVERSION);
RECORD(DECL_ACCESS_SPEC);
@@ -1091,10 +1120,22 @@ void ASTWriter::WriteBlockInfoBlock() {
RECORD(DECL_TEMPLATE_TYPE_PARM);
RECORD(DECL_NON_TYPE_TEMPLATE_PARM);
RECORD(DECL_TEMPLATE_TEMPLATE_PARM);
+ RECORD(DECL_TYPE_ALIAS_TEMPLATE);
RECORD(DECL_STATIC_ASSERT);
RECORD(DECL_CXX_BASE_SPECIFIERS);
+ RECORD(DECL_CXX_CTOR_INITIALIZERS);
RECORD(DECL_INDIRECTFIELD);
RECORD(DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK);
+ RECORD(DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK);
+ RECORD(DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION);
+ RECORD(DECL_IMPORT);
+ RECORD(DECL_OMP_THREADPRIVATE);
+ RECORD(DECL_EMPTY);
+ RECORD(DECL_OBJC_TYPE_PARAM);
+ RECORD(DECL_OMP_CAPTUREDEXPR);
+ RECORD(DECL_PRAGMA_COMMENT);
+ RECORD(DECL_PRAGMA_DETECT_MISMATCH);
+ RECORD(DECL_OMP_DECLARE_REDUCTION);
// Statements and Exprs can occur in the Decls and Types block.
AddStmtsExprs(Stream, Record);
@@ -1631,11 +1672,15 @@ static unsigned CreateSLocBufferAbbrev(llvm::BitstreamWriter &Stream) {
/// \brief Create an abbreviation for the SLocEntry that refers to a
/// buffer's blob.
-static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream) {
+static unsigned CreateSLocBufferBlobAbbrev(llvm::BitstreamWriter &Stream,
+ bool Compressed) {
using namespace llvm;
auto *Abbrev = new BitCodeAbbrev();
- Abbrev->Add(BitCodeAbbrevOp(SM_SLOC_BUFFER_BLOB));
+ Abbrev->Add(BitCodeAbbrevOp(Compressed ? SM_SLOC_BUFFER_BLOB_COMPRESSED
+ : SM_SLOC_BUFFER_BLOB));
+ if (Compressed)
+ Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Uncompressed size
Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // Blob
return Stream.EmitAbbrev(Abbrev);
}
@@ -1857,12 +1902,14 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
RecordData Record;
// Enter the source manager block.
- Stream.EnterSubblock(SOURCE_MANAGER_BLOCK_ID, 3);
+ Stream.EnterSubblock(SOURCE_MANAGER_BLOCK_ID, 4);
// Abbreviations for the various kinds of source-location entries.
unsigned SLocFileAbbrv = CreateSLocFileAbbrev(Stream);
unsigned SLocBufferAbbrv = CreateSLocBufferAbbrev(Stream);
- unsigned SLocBufferBlobAbbrv = CreateSLocBufferBlobAbbrev(Stream);
+ unsigned SLocBufferBlobAbbrv = CreateSLocBufferBlobAbbrev(Stream, false);
+ unsigned SLocBufferBlobCompressedAbbrv =
+ CreateSLocBufferBlobAbbrev(Stream, true);
unsigned SLocExpansionAbbrv = CreateSLocExpansionAbbrev(Stream);
// Write out the source location entry table. We skip the first
@@ -1897,11 +1944,12 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
Record.push_back(SLoc->getOffset() - 2);
if (SLoc->isFile()) {
const SrcMgr::FileInfo &File = SLoc->getFile();
- Record.push_back(File.getIncludeLoc().getRawEncoding());
+ AddSourceLocation(File.getIncludeLoc(), Record);
Record.push_back(File.getFileCharacteristic()); // FIXME: stable encoding
Record.push_back(File.hasLineDirectives());
const SrcMgr::ContentCache *Content = File.getContentCache();
+ bool EmitBlob = false;
if (Content->OrigEntry) {
assert(Content->OrigEntry == Content->ContentsEntry &&
"Writing to AST an overridden file is not supported");
@@ -1923,14 +1971,8 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
Stream.EmitRecordWithAbbrev(SLocFileAbbrv, Record);
- if (Content->BufferOverridden || Content->IsTransient) {
- RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB};
- const llvm::MemoryBuffer *Buffer
- = Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager());
- Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
- StringRef(Buffer->getBufferStart(),
- Buffer->getBufferSize() + 1));
- }
+ if (Content->BufferOverridden || Content->IsTransient)
+ EmitBlob = true;
} else {
// The source location entry is a buffer. The blob associated
// with this entry contains the contents of the buffer.
@@ -1943,22 +1985,43 @@ void ASTWriter::WriteSourceManagerBlock(SourceManager &SourceMgr,
const char *Name = Buffer->getBufferIdentifier();
Stream.EmitRecordWithBlob(SLocBufferAbbrv, Record,
StringRef(Name, strlen(Name) + 1));
- RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB};
- Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record,
- StringRef(Buffer->getBufferStart(),
- Buffer->getBufferSize() + 1));
+ EmitBlob = true;
if (strcmp(Name, "<built-in>") == 0) {
PreloadSLocs.push_back(SLocEntryOffsets.size());
}
}
+
+ if (EmitBlob) {
+ // Include the implicit terminating null character in the on-disk buffer
+ // if we're writing it uncompressed.
+ const llvm::MemoryBuffer *Buffer =
+ Content->getBuffer(PP.getDiagnostics(), PP.getSourceManager());
+ StringRef Blob(Buffer->getBufferStart(), Buffer->getBufferSize() + 1);
+
+ // Compress the buffer if possible. We expect that almost all PCM
+ // consumers will not want its contents.
+ SmallString<0> CompressedBuffer;
+ if (llvm::zlib::compress(Blob.drop_back(1), CompressedBuffer) ==
+ llvm::zlib::StatusOK) {
+ RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB_COMPRESSED,
+ Blob.size() - 1};
+ Stream.EmitRecordWithBlob(SLocBufferBlobCompressedAbbrv, Record,
+ CompressedBuffer);
+ } else {
+ RecordData::value_type Record[] = {SM_SLOC_BUFFER_BLOB};
+ Stream.EmitRecordWithBlob(SLocBufferBlobAbbrv, Record, Blob);
+ }
+ }
} else {
// The source location entry is a macro expansion.
const SrcMgr::ExpansionInfo &Expansion = SLoc->getExpansion();
- Record.push_back(Expansion.getSpellingLoc().getRawEncoding());
- Record.push_back(Expansion.getExpansionLocStart().getRawEncoding());
- Record.push_back(Expansion.isMacroArgExpansion() ? 0
- : Expansion.getExpansionLocEnd().getRawEncoding());
+ AddSourceLocation(Expansion.getSpellingLoc(), Record);
+ AddSourceLocation(Expansion.getExpansionLocStart(), Record);
+ AddSourceLocation(Expansion.isMacroArgExpansion()
+ ? SourceLocation()
+ : Expansion.getExpansionLocEnd(),
+ Record);
// Compute the token length for this macro expansion.
unsigned NextOffset = SourceMgr.getNextLocalOffset();
@@ -2125,30 +2188,29 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP, bool IsModule) {
// Write out any exported module macros.
bool EmittedModuleMacros = false;
- if (IsModule) {
- auto Leafs = PP.getLeafModuleMacros(Name);
- SmallVector<ModuleMacro*, 8> Worklist(Leafs.begin(), Leafs.end());
- llvm::DenseMap<ModuleMacro*, unsigned> Visits;
- while (!Worklist.empty()) {
- auto *Macro = Worklist.pop_back_val();
-
- // Emit a record indicating this submodule exports this macro.
- ModuleMacroRecord.push_back(
- getSubmoduleID(Macro->getOwningModule()));
- ModuleMacroRecord.push_back(getMacroRef(Macro->getMacroInfo(), Name));
- for (auto *M : Macro->overrides())
- ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
-
- Stream.EmitRecord(PP_MODULE_MACRO, ModuleMacroRecord);
- ModuleMacroRecord.clear();
-
- // Enqueue overridden macros once we've visited all their ancestors.
- for (auto *M : Macro->overrides())
- if (++Visits[M] == M->getNumOverridingMacros())
- Worklist.push_back(M);
-
- EmittedModuleMacros = true;
- }
+ // We write out exported module macros for PCH as well.
+ auto Leafs = PP.getLeafModuleMacros(Name);
+ SmallVector<ModuleMacro*, 8> Worklist(Leafs.begin(), Leafs.end());
+ llvm::DenseMap<ModuleMacro*, unsigned> Visits;
+ while (!Worklist.empty()) {
+ auto *Macro = Worklist.pop_back_val();
+
+ // Emit a record indicating this submodule exports this macro.
+ ModuleMacroRecord.push_back(
+ getSubmoduleID(Macro->getOwningModule()));
+ ModuleMacroRecord.push_back(getMacroRef(Macro->getMacroInfo(), Name));
+ for (auto *M : Macro->overrides())
+ ModuleMacroRecord.push_back(getSubmoduleID(M->getOwningModule()));
+
+ Stream.EmitRecord(PP_MODULE_MACRO, ModuleMacroRecord);
+ ModuleMacroRecord.clear();
+
+ // Enqueue overridden macros once we've visited all their ancestors.
+ for (auto *M : Macro->overrides())
+ if (++Visits[M] == M->getNumOverridingMacros())
+ Worklist.push_back(M);
+
+ EmittedModuleMacros = true;
}
if (Record.empty() && !EmittedModuleMacros)
@@ -2640,7 +2702,7 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
if (point.Loc.isInvalid())
continue;
- Record.push_back(point.Loc.getRawEncoding());
+ AddSourceLocation(point.Loc, Record);
unsigned &DiagStateID = DiagStateIDMap[point.State];
Record.push_back(DiagStateID);
@@ -2661,95 +2723,36 @@ void ASTWriter::WritePragmaDiagnosticMappings(const DiagnosticsEngine &Diag,
Stream.EmitRecord(DIAG_PRAGMA_MAPPINGS, Record);
}
-void ASTWriter::WriteCXXCtorInitializersOffsets() {
- if (CXXCtorInitializersOffsets.empty())
- return;
-
- // Create a blob abbreviation for the C++ ctor initializer offsets.
- using namespace llvm;
-
- auto *Abbrev = new BitCodeAbbrev();
- Abbrev->Add(BitCodeAbbrevOp(CXX_CTOR_INITIALIZERS_OFFSETS));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // size
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
- unsigned CtorInitializersOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
-
- // Write the base specifier offsets table.
- RecordData::value_type Record[] = {CXX_CTOR_INITIALIZERS_OFFSETS,
- CXXCtorInitializersOffsets.size()};
- Stream.EmitRecordWithBlob(CtorInitializersOffsetAbbrev, Record,
- bytes(CXXCtorInitializersOffsets));
-}
-
-void ASTWriter::WriteCXXBaseSpecifiersOffsets() {
- if (CXXBaseSpecifiersOffsets.empty())
- return;
-
- // Create a blob abbreviation for the C++ base specifiers offsets.
- using namespace llvm;
-
- auto *Abbrev = new BitCodeAbbrev();
- Abbrev->Add(BitCodeAbbrevOp(CXX_BASE_SPECIFIER_OFFSETS));
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // size
- Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob));
- unsigned BaseSpecifierOffsetAbbrev = Stream.EmitAbbrev(Abbrev);
-
- // Write the base specifier offsets table.
- RecordData::value_type Record[] = {CXX_BASE_SPECIFIER_OFFSETS,
- CXXBaseSpecifiersOffsets.size()};
- Stream.EmitRecordWithBlob(BaseSpecifierOffsetAbbrev, Record,
- bytes(CXXBaseSpecifiersOffsets));
-}
-
//===----------------------------------------------------------------------===//
// Type Serialization
//===----------------------------------------------------------------------===//
/// \brief Write the representation of a type to the AST stream.
void ASTWriter::WriteType(QualType T) {
- TypeIdx &Idx = TypeIdxs[T];
- if (Idx.getIndex() == 0) // we haven't seen this type before.
- Idx = TypeIdx(NextTypeID++);
+ TypeIdx &IdxRef = TypeIdxs[T];
+ if (IdxRef.getIndex() == 0) // we haven't seen this type before.
+ IdxRef = TypeIdx(NextTypeID++);
+ TypeIdx Idx = IdxRef;
assert(Idx.getIndex() >= FirstTypeID && "Re-writing a type from a prior AST");
+ RecordData Record;
+
+ // Emit the type's representation.
+ ASTTypeWriter W(*this, Record);
+ W.Visit(T);
+ uint64_t Offset = W.Emit();
+
// Record the offset for this type.
unsigned Index = Idx.getIndex() - FirstTypeID;
if (TypeOffsets.size() == Index)
- TypeOffsets.push_back(Stream.GetCurrentBitNo());
+ TypeOffsets.push_back(Offset);
else if (TypeOffsets.size() < Index) {
TypeOffsets.resize(Index + 1);
- TypeOffsets[Index] = Stream.GetCurrentBitNo();
- }
-
- RecordData Record;
-
- // Emit the type's representation.
- ASTTypeWriter W(*this, Record);
- W.AbbrevToUse = 0;
-
- if (T.hasLocalNonFastQualifiers()) {
- Qualifiers Qs = T.getLocalQualifiers();
- AddTypeRef(T.getLocalUnqualifiedType(), Record);
- Record.push_back(Qs.getAsOpaqueValue());
- W.Code = TYPE_EXT_QUAL;
- W.AbbrevToUse = TypeExtQualAbbrev;
+ TypeOffsets[Index] = Offset;
} else {
- switch (T->getTypeClass()) {
- // For all of the concrete, non-dependent types, call the
- // appropriate visitor function.
-#define TYPE(Class, Base) \
- case Type::Class: W.Visit##Class##Type(cast<Class##Type>(T)); break;
-#define ABSTRACT_TYPE(Class, Base)
-#include "clang/AST/TypeNodes.def"
- }
+ llvm_unreachable("Types emitted in wrong order");
}
-
- // Emit the serialized record.
- Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);
-
- // Flush any expressions that were written as part of this type.
- FlushStmts();
}
//===----------------------------------------------------------------------===//
@@ -3073,6 +3076,7 @@ void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
return;
RecordData Record;
+ ASTRecordWriter Writer(*this, Record);
// Note: this writes out all references even for a dependent AST. But it is
// very tricky to fix, and given that @selector shouldn't really appear in
@@ -3080,10 +3084,10 @@ void ASTWriter::WriteReferencedSelectorsPool(Sema &SemaRef) {
for (auto &SelectorAndLocation : SemaRef.ReferencedSelectors) {
Selector Sel = SelectorAndLocation.first;
SourceLocation Loc = SelectorAndLocation.second;
- AddSelectorRef(Sel, Record);
- AddSourceLocation(Loc, Record);
+ Writer.AddSelectorRef(Sel);
+ Writer.AddSourceLocation(Loc);
}
- Stream.EmitRecord(REFERENCED_SELECTOR_POOL, Record);
+ Writer.Emit(REFERENCED_SELECTOR_POOL);
}
//===----------------------------------------------------------------------===//
@@ -3103,11 +3107,20 @@ static NamedDecl *getDeclForLocalLookup(const LangOptions &LangOpts,
if (Decl *Redecl = D->getPreviousDecl()) {
// For Redeclarable decls, a prior declaration might be local.
for (; Redecl; Redecl = Redecl->getPreviousDecl()) {
- if (!Redecl->isFromASTFile())
+ // If we find a local decl, we're done.
+ if (!Redecl->isFromASTFile()) {
+ // Exception: in very rare cases (for injected-class-names), not all
+ // redeclarations are in the same semantic context. Skip ones in a
+ // different context. They don't go in this lookup table at all.
+ if (!Redecl->getDeclContext()->getRedeclContext()->Equals(
+ D->getDeclContext()->getRedeclContext()))
+ continue;
return cast<NamedDecl>(Redecl);
+ }
+
// If we find a decl from a (chained-)PCH stop since we won't find a
// local one.
- if (D->getOwningModuleID() == 0)
+ if (Redecl->getOwningModuleID() == 0)
break;
}
} else if (Decl *First = D->getCanonicalDecl()) {
@@ -3162,6 +3175,8 @@ public:
NeedDecls(!IsModule || !Writer.getLangOpts().CPlusPlus),
InterestingIdentifierOffsets(InterestingIdentifierOffsets) {}
+ bool needDecls() const { return NeedDecls; }
+
static hash_value_type ComputeHash(const IdentifierInfo* II) {
return llvm::HashString(II->getName());
}
@@ -3307,7 +3322,12 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
auto *II = const_cast<IdentifierInfo *>(IdentIDPair.first);
IdentID ID = IdentIDPair.second;
assert(II && "NULL identifier in identifier table");
- if (!Chain || !II->isFromAST() || II->hasChangedSinceDeserialization())
+ // Write out identifiers if either the ID is local or the identifier has
+ // changed since it was loaded.
+ if (ID >= FirstIdentID || !Chain || !II->isFromAST()
+ || II->hasChangedSinceDeserialization() ||
+ (Trait.needDecls() &&
+ II->hasFETokenInfoChangedSinceDeserialization()))
Generator.insert(II, ID, Trait);
}
@@ -3896,6 +3916,22 @@ void ASTWriter::WriteOptimizePragmaOptions(Sema &SemaRef) {
Stream.EmitRecord(OPTIMIZE_PRAGMA_OPTIONS, Record);
}
+/// \brief Write the state of 'pragma ms_struct' at the end of the module.
+void ASTWriter::WriteMSStructPragmaOptions(Sema &SemaRef) {
+ RecordData Record;
+ Record.push_back(SemaRef.MSStructPragmaOn ? PMSST_ON : PMSST_OFF);
+ Stream.EmitRecord(MSSTRUCT_PRAGMA_OPTIONS, Record);
+}
+
+/// \brief Write the state of 'pragma pointers_to_members' at the end of the
+//module.
+void ASTWriter::WriteMSPointersToMembersPragmaOptions(Sema &SemaRef) {
+ RecordData Record;
+ Record.push_back(SemaRef.MSPointerToMemberRepresentationMethod);
+ AddSourceLocation(SemaRef.ImplicitMSInheritanceAttrLoc, Record);
+ Stream.EmitRecord(POINTERS_TO_MEMBERS_PRAGMA_OPTIONS, Record);
+}
+
void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
ModuleFileExtensionWriter &Writer) {
// Enter the extension block.
@@ -3935,13 +3971,13 @@ void ASTWriter::WriteModuleFileExtension(Sema &SemaRef,
// General Serialization Routines
//===----------------------------------------------------------------------===//
-/// \brief Write a record containing the given attributes.
-void ASTWriter::WriteAttributes(ArrayRef<const Attr*> Attrs,
- RecordDataImpl &Record) {
+/// \brief Emit the list of attributes to the specified record.
+void ASTRecordWriter::AddAttributes(ArrayRef<const Attr *> Attrs) {
+ auto &Record = *this;
Record.push_back(Attrs.size());
for (const auto *A : Attrs) {
Record.push_back(A->getKind()); // FIXME: stable encoding, target attrs
- AddSourceRange(A->getRange(), Record);
+ Record.AddSourceRange(A->getRange());
#include "clang/Serialization/AttrPCHWrite.inc"
@@ -4046,9 +4082,8 @@ ASTWriter::ASTWriter(
NextMacroID(FirstMacroID), FirstSubmoduleID(NUM_PREDEF_SUBMODULE_IDS),
NextSubmoduleID(FirstSubmoduleID),
FirstSelectorID(NUM_PREDEF_SELECTOR_IDS), NextSelectorID(FirstSelectorID),
- CollectedStmts(&StmtsToEmit), NumStatements(0), NumMacros(0),
+ NumStatements(0), NumMacros(0),
NumLexicalDeclContexts(0), NumVisibleDeclContexts(0),
- NextCXXBaseSpecifiersID(1), NextCXXCtorInitializersID(1),
TypeExtQualAbbrev(0), TypeFunctionProtoAbbrev(0), DeclParmVarAbbrev(0),
DeclContextLexicalAbbrev(0), DeclContextVisibleLookupAbbrev(0),
UpdateVisibleAbbrev(0), DeclRecordAbbrev(0), DeclTypedefAbbrev(0),
@@ -4152,6 +4187,12 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
RegisterPredefDecl(Context.ExternCContext, PREDEF_DECL_EXTERN_C_CONTEXT_ID);
RegisterPredefDecl(Context.MakeIntegerSeqDecl,
PREDEF_DECL_MAKE_INTEGER_SEQ_ID);
+ RegisterPredefDecl(Context.CFConstantStringTypeDecl,
+ PREDEF_DECL_CF_CONSTANT_STRING_ID);
+ RegisterPredefDecl(Context.CFConstantStringTagDecl,
+ PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID);
+ RegisterPredefDecl(Context.TypePackElementDecl,
+ PREDEF_DECL_TYPE_PACK_ELEMENT_ID);
// Build a record containing all of the tentative definitions in this file, in
// TentativeDefinitions order. Generally, this record will be empty for
@@ -4348,6 +4389,19 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
}
}
+ // For method pool in the module, if it contains an entry for a selector,
+ // the entry should be complete, containing everything introduced by that
+ // module and all modules it imports. It's possible that the entry is out of
+ // date, so we need to pull in the new content here.
+
+ // It's possible that updateOutOfDateSelector can update SelectorIDs. To be
+ // safe, we copy all selectors out.
+ llvm::SmallVector<Selector, 256> AllSelectors;
+ for (auto &SelectorAndID : SelectorIDs)
+ AllSelectors.push_back(SelectorAndID.first);
+ for (auto &Selector : AllSelectors)
+ SemaRef.updateOutOfDateSelector(Selector);
+
// Form the record of special types.
RecordData SpecialTypes;
AddTypeRef(Context.getRawCFConstantStringType(), SpecialTypes);
@@ -4445,8 +4499,6 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
WriteTypeDeclOffsets();
if (!DeclUpdatesOffsetsRecord.empty())
Stream.EmitRecord(DECL_UPDATE_OFFSETS, DeclUpdatesOffsetsRecord);
- WriteCXXBaseSpecifiersOffsets();
- WriteCXXCtorInitializersOffsets();
WriteFileDeclIDsMap();
WriteSourceManagerBlock(Context.getSourceManager(), PP);
WriteComments();
@@ -4567,10 +4619,12 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot,
}
}
- WriteDeclReplacementsBlock();
WriteObjCCategories();
- if(!WritingModule)
+ if(!WritingModule) {
WriteOptimizePragmaOptions(SemaRef);
+ WriteMSStructPragmaOptions(SemaRef);
+ WriteMSPointersToMembersPragmaOptions(SemaRef);
+ }
// Some simple statistics
RecordData::value_type Record[] = {
@@ -4596,11 +4650,18 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
const Decl *D = DeclUpdate.first;
bool HasUpdatedBody = false;
- RecordData Record;
+ RecordData RecordData;
+ ASTRecordWriter Record(*this, RecordData);
for (auto &Update : DeclUpdate.second) {
DeclUpdateKind Kind = (DeclUpdateKind)Update.getKind();
- Record.push_back(Kind);
+ // An updated body is emitted last, so that the reader doesn't need
+ // to skip over the lazy body to reach statements for other records.
+ if (Kind == UPD_CXX_ADDED_FUNCTION_DEFINITION)
+ HasUpdatedBody = true;
+ else
+ Record.push_back(Kind);
+
switch (Kind) {
case UPD_CXX_ADDED_IMPLICIT_MEMBER:
case UPD_CXX_ADDED_TEMPLATE_SPECIALIZATION:
@@ -4610,26 +4671,22 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
break;
case UPD_CXX_ADDED_FUNCTION_DEFINITION:
- // An updated body is emitted last, so that the reader doesn't need
- // to skip over the lazy body to reach statements for other records.
- Record.pop_back();
- HasUpdatedBody = true;
break;
case UPD_CXX_INSTANTIATED_STATIC_DATA_MEMBER:
- AddSourceLocation(Update.getLoc(), Record);
+ Record.AddSourceLocation(Update.getLoc());
break;
case UPD_CXX_INSTANTIATED_DEFAULT_ARGUMENT:
- AddStmt(const_cast<Expr*>(
- cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
+ Record.AddStmt(const_cast<Expr *>(
+ cast<ParmVarDecl>(Update.getDecl())->getDefaultArg()));
break;
case UPD_CXX_INSTANTIATED_CLASS_DEFINITION: {
auto *RD = cast<CXXRecordDecl>(D);
UpdatedDeclContexts.insert(RD->getPrimaryContext());
- AddCXXDefinitionData(RD, Record);
- Record.push_back(WriteDeclContextLexicalBlock(
+ Record.AddCXXDefinitionData(RD);
+ Record.AddOffset(WriteDeclContextLexicalBlock(
*Context, const_cast<CXXRecordDecl *>(RD)));
// This state is sometimes updated by template instantiation, when we
@@ -4637,11 +4694,11 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
// to it referring to the template definition.
if (auto *MSInfo = RD->getMemberSpecializationInfo()) {
Record.push_back(MSInfo->getTemplateSpecializationKind());
- AddSourceLocation(MSInfo->getPointOfInstantiation(), Record);
+ Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
} else {
auto *Spec = cast<ClassTemplateSpecializationDecl>(RD);
Record.push_back(Spec->getTemplateSpecializationKind());
- AddSourceLocation(Spec->getPointOfInstantiation(), Record);
+ Record.AddSourceLocation(Spec->getPointOfInstantiation());
// The instantiation might have been resolved to a partial
// specialization. If so, record which one.
@@ -4649,35 +4706,33 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
if (auto PartialSpec =
From.dyn_cast<ClassTemplatePartialSpecializationDecl*>()) {
Record.push_back(true);
- AddDeclRef(PartialSpec, Record);
- AddTemplateArgumentList(&Spec->getTemplateInstantiationArgs(),
- Record);
+ Record.AddDeclRef(PartialSpec);
+ Record.AddTemplateArgumentList(
+ &Spec->getTemplateInstantiationArgs());
} else {
Record.push_back(false);
}
}
Record.push_back(RD->getTagKind());
- AddSourceLocation(RD->getLocation(), Record);
- AddSourceLocation(RD->getLocStart(), Record);
- AddSourceLocation(RD->getRBraceLoc(), Record);
+ Record.AddSourceLocation(RD->getLocation());
+ Record.AddSourceLocation(RD->getLocStart());
+ Record.AddSourceRange(RD->getBraceRange());
// Instantiation may change attributes; write them all out afresh.
Record.push_back(D->hasAttrs());
- if (Record.back())
- WriteAttributes(llvm::makeArrayRef(D->getAttrs().begin(),
- D->getAttrs().size()), Record);
+ if (D->hasAttrs())
+ Record.AddAttributes(D->getAttrs());
// FIXME: Ensure we don't get here for explicit instantiations.
break;
}
case UPD_CXX_RESOLVED_DTOR_DELETE:
- AddDeclRef(Update.getDecl(), Record);
+ Record.AddDeclRef(Update.getDecl());
break;
case UPD_CXX_RESOLVED_EXCEPTION_SPEC:
addExceptionSpec(
- *this,
cast<FunctionDecl>(D)->getType()->castAs<FunctionProtoType>(),
Record);
break;
@@ -4695,8 +4750,13 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
break;
case UPD_DECL_MARKED_OPENMP_THREADPRIVATE:
- AddSourceRange(D->getAttr<OMPThreadPrivateDeclAttr>()->getRange(),
- Record);
+ Record.AddSourceRange(
+ D->getAttr<OMPThreadPrivateDeclAttr>()->getRange());
+ break;
+
+ case UPD_DECL_MARKED_OPENMP_DECLARETARGET:
+ Record.AddSourceRange(
+ D->getAttr<OMPDeclareTargetDeclAttr>()->getRange());
break;
case UPD_DECL_EXPORTED:
@@ -4704,7 +4764,7 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
break;
case UPD_ADDED_ATTR_TO_RECORD:
- WriteAttributes(llvm::makeArrayRef(Update.getAttr()), Record);
+ Record.AddAttributes(llvm::makeArrayRef(Update.getAttr()));
break;
}
}
@@ -4713,34 +4773,18 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) {
const auto *Def = cast<FunctionDecl>(D);
Record.push_back(UPD_CXX_ADDED_FUNCTION_DEFINITION);
Record.push_back(Def->isInlined());
- AddSourceLocation(Def->getInnerLocStart(), Record);
- AddFunctionDefinition(Def, Record);
+ Record.AddSourceLocation(Def->getInnerLocStart());
+ Record.AddFunctionDefinition(Def);
}
OffsetsRecord.push_back(GetDeclRef(D));
- OffsetsRecord.push_back(Stream.GetCurrentBitNo());
-
- Stream.EmitRecord(DECL_UPDATES, Record);
-
- FlushPendingAfterDecl();
+ OffsetsRecord.push_back(Record.Emit(DECL_UPDATES));
}
}
-void ASTWriter::WriteDeclReplacementsBlock() {
- if (ReplacedDecls.empty())
- return;
-
- RecordData Record;
- for (const auto &I : ReplacedDecls) {
- Record.push_back(I.ID);
- Record.push_back(I.Offset);
- Record.push_back(I.Loc);
- }
- Stream.EmitRecord(DECL_REPLACEMENTS, Record);
-}
-
void ASTWriter::AddSourceLocation(SourceLocation Loc, RecordDataImpl &Record) {
- Record.push_back(Loc.getRawEncoding());
+ uint32_t Raw = Loc.getRawEncoding();
+ Record.push_back((Raw << 1) | (Raw >> 31));
}
void ASTWriter::AddSourceRange(SourceRange Range, RecordDataImpl &Record) {
@@ -4748,19 +4792,19 @@ void ASTWriter::AddSourceRange(SourceRange Range, RecordDataImpl &Record) {
AddSourceLocation(Range.getEnd(), Record);
}
-void ASTWriter::AddAPInt(const llvm::APInt &Value, RecordDataImpl &Record) {
- Record.push_back(Value.getBitWidth());
+void ASTRecordWriter::AddAPInt(const llvm::APInt &Value) {
+ Record->push_back(Value.getBitWidth());
const uint64_t *Words = Value.getRawData();
- Record.append(Words, Words + Value.getNumWords());
+ Record->append(Words, Words + Value.getNumWords());
}
-void ASTWriter::AddAPSInt(const llvm::APSInt &Value, RecordDataImpl &Record) {
- Record.push_back(Value.isUnsigned());
- AddAPInt(Value, Record);
+void ASTRecordWriter::AddAPSInt(const llvm::APSInt &Value) {
+ Record->push_back(Value.isUnsigned());
+ AddAPInt(Value);
}
-void ASTWriter::AddAPFloat(const llvm::APFloat &Value, RecordDataImpl &Record) {
- AddAPInt(Value.bitcastToAPInt(), Record);
+void ASTRecordWriter::AddAPFloat(const llvm::APFloat &Value) {
+ AddAPInt(Value.bitcastToAPInt());
}
void ASTWriter::AddIdentifierRef(const IdentifierInfo *II, RecordDataImpl &Record) {
@@ -4805,8 +4849,8 @@ uint64_t ASTWriter::getMacroDirectivesOffset(const IdentifierInfo *Name) {
return IdentMacroDirectivesOffsetMap.lookup(Name);
}
-void ASTWriter::AddSelectorRef(const Selector SelRef, RecordDataImpl &Record) {
- Record.push_back(getSelectorRef(SelRef));
+void ASTRecordWriter::AddSelectorRef(const Selector SelRef) {
+ Record->push_back(Writer->getSelectorRef(SelRef));
}
SelectorID ASTWriter::getSelectorRef(Selector Sel) {
@@ -4828,46 +4872,27 @@ SelectorID ASTWriter::getSelectorRef(Selector Sel) {
return SID;
}
-void ASTWriter::AddCXXTemporary(const CXXTemporary *Temp, RecordDataImpl &Record) {
- AddDeclRef(Temp->getDestructor(), Record);
+void ASTRecordWriter::AddCXXTemporary(const CXXTemporary *Temp) {
+ AddDeclRef(Temp->getDestructor());
}
-void ASTWriter::AddCXXCtorInitializersRef(ArrayRef<CXXCtorInitializer *> Inits,
- RecordDataImpl &Record) {
- assert(!Inits.empty() && "Empty ctor initializer sets are not recorded");
- CXXCtorInitializersToWrite.push_back(
- QueuedCXXCtorInitializers(NextCXXCtorInitializersID, Inits));
- Record.push_back(NextCXXCtorInitializersID++);
-}
-
-void ASTWriter::AddCXXBaseSpecifiersRef(CXXBaseSpecifier const *Bases,
- CXXBaseSpecifier const *BasesEnd,
- RecordDataImpl &Record) {
- assert(Bases != BasesEnd && "Empty base-specifier sets are not recorded");
- CXXBaseSpecifiersToWrite.push_back(
- QueuedCXXBaseSpecifiers(NextCXXBaseSpecifiersID,
- Bases, BasesEnd));
- Record.push_back(NextCXXBaseSpecifiersID++);
-}
-
-void ASTWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
- const TemplateArgumentLocInfo &Arg,
- RecordDataImpl &Record) {
+void ASTRecordWriter::AddTemplateArgumentLocInfo(
+ TemplateArgument::ArgKind Kind, const TemplateArgumentLocInfo &Arg) {
switch (Kind) {
case TemplateArgument::Expression:
AddStmt(Arg.getAsExpr());
break;
case TemplateArgument::Type:
- AddTypeSourceInfo(Arg.getAsTypeSourceInfo(), Record);
+ AddTypeSourceInfo(Arg.getAsTypeSourceInfo());
break;
case TemplateArgument::Template:
- AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc(), Record);
- AddSourceLocation(Arg.getTemplateNameLoc(), Record);
+ AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc());
+ AddSourceLocation(Arg.getTemplateNameLoc());
break;
case TemplateArgument::TemplateExpansion:
- AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc(), Record);
- AddSourceLocation(Arg.getTemplateNameLoc(), Record);
- AddSourceLocation(Arg.getTemplateEllipsisLoc(), Record);
+ AddNestedNameSpecifierLoc(Arg.getTemplateQualifierLoc());
+ AddSourceLocation(Arg.getTemplateNameLoc());
+ AddSourceLocation(Arg.getTemplateEllipsisLoc());
break;
case TemplateArgument::Null:
case TemplateArgument::Integral:
@@ -4879,35 +4904,32 @@ void ASTWriter::AddTemplateArgumentLocInfo(TemplateArgument::ArgKind Kind,
}
}
-void ASTWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg,
- RecordDataImpl &Record) {
- AddTemplateArgument(Arg.getArgument(), Record);
+void ASTRecordWriter::AddTemplateArgumentLoc(const TemplateArgumentLoc &Arg) {
+ AddTemplateArgument(Arg.getArgument());
if (Arg.getArgument().getKind() == TemplateArgument::Expression) {
bool InfoHasSameExpr
= Arg.getArgument().getAsExpr() == Arg.getLocInfo().getAsExpr();
- Record.push_back(InfoHasSameExpr);
+ Record->push_back(InfoHasSameExpr);
if (InfoHasSameExpr)
return; // Avoid storing the same expr twice.
}
- AddTemplateArgumentLocInfo(Arg.getArgument().getKind(), Arg.getLocInfo(),
- Record);
+ AddTemplateArgumentLocInfo(Arg.getArgument().getKind(), Arg.getLocInfo());
}
-void ASTWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo,
- RecordDataImpl &Record) {
+void ASTRecordWriter::AddTypeSourceInfo(TypeSourceInfo *TInfo) {
if (!TInfo) {
- AddTypeRef(QualType(), Record);
+ AddTypeRef(QualType());
return;
}
- AddTypeLoc(TInfo->getTypeLoc(), Record);
+ AddTypeLoc(TInfo->getTypeLoc());
}
-void ASTWriter::AddTypeLoc(TypeLoc TL, RecordDataImpl &Record) {
- AddTypeRef(TL.getType(), Record);
+void ASTRecordWriter::AddTypeLoc(TypeLoc TL) {
+ AddTypeRef(TL.getType());
- TypeLocWriter TLW(*this, Record);
+ TypeLocWriter TLW(*this);
for (; !TL.isNull(); TL = TL.getNextTypeLoc())
TLW.Visit(TL);
}
@@ -5042,32 +5064,32 @@ void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) {
Decls.insert(I, LocDecl);
}
-void ASTWriter::AddDeclarationName(DeclarationName Name, RecordDataImpl &Record) {
+void ASTRecordWriter::AddDeclarationName(DeclarationName Name) {
// FIXME: Emit a stable enum for NameKind. 0 = Identifier etc.
- Record.push_back(Name.getNameKind());
+ Record->push_back(Name.getNameKind());
switch (Name.getNameKind()) {
case DeclarationName::Identifier:
- AddIdentifierRef(Name.getAsIdentifierInfo(), Record);
+ AddIdentifierRef(Name.getAsIdentifierInfo());
break;
case DeclarationName::ObjCZeroArgSelector:
case DeclarationName::ObjCOneArgSelector:
case DeclarationName::ObjCMultiArgSelector:
- AddSelectorRef(Name.getObjCSelector(), Record);
+ AddSelectorRef(Name.getObjCSelector());
break;
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName:
- AddTypeRef(Name.getCXXNameType(), Record);
+ AddTypeRef(Name.getCXXNameType());
break;
case DeclarationName::CXXOperatorName:
- Record.push_back(Name.getCXXOverloadedOperator());
+ Record->push_back(Name.getCXXOverloadedOperator());
break;
case DeclarationName::CXXLiteralOperatorName:
- AddIdentifierRef(Name.getCXXLiteralIdentifier(), Record);
+ AddIdentifierRef(Name.getCXXLiteralIdentifier());
break;
case DeclarationName::CXXUsingDirective:
@@ -5097,28 +5119,25 @@ unsigned ASTWriter::getAnonymousDeclarationNumber(const NamedDecl *D) {
return It->second;
}
-void ASTWriter::AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
- DeclarationName Name, RecordDataImpl &Record) {
+void ASTRecordWriter::AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
+ DeclarationName Name) {
switch (Name.getNameKind()) {
case DeclarationName::CXXConstructorName:
case DeclarationName::CXXDestructorName:
case DeclarationName::CXXConversionFunctionName:
- AddTypeSourceInfo(DNLoc.NamedType.TInfo, Record);
+ AddTypeSourceInfo(DNLoc.NamedType.TInfo);
break;
case DeclarationName::CXXOperatorName:
+ AddSourceLocation(SourceLocation::getFromRawEncoding(
+ DNLoc.CXXOperatorName.BeginOpNameLoc));
AddSourceLocation(
- SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.BeginOpNameLoc),
- Record);
- AddSourceLocation(
- SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.EndOpNameLoc),
- Record);
+ SourceLocation::getFromRawEncoding(DNLoc.CXXOperatorName.EndOpNameLoc));
break;
case DeclarationName::CXXLiteralOperatorName:
- AddSourceLocation(
- SourceLocation::getFromRawEncoding(DNLoc.CXXLiteralOperatorName.OpNameLoc),
- Record);
+ AddSourceLocation(SourceLocation::getFromRawEncoding(
+ DNLoc.CXXLiteralOperatorName.OpNameLoc));
break;
case DeclarationName::Identifier:
@@ -5130,23 +5149,21 @@ void ASTWriter::AddDeclarationNameLoc(const DeclarationNameLoc &DNLoc,
}
}
-void ASTWriter::AddDeclarationNameInfo(const DeclarationNameInfo &NameInfo,
- RecordDataImpl &Record) {
- AddDeclarationName(NameInfo.getName(), Record);
- AddSourceLocation(NameInfo.getLoc(), Record);
- AddDeclarationNameLoc(NameInfo.getInfo(), NameInfo.getName(), Record);
+void ASTRecordWriter::AddDeclarationNameInfo(
+ const DeclarationNameInfo &NameInfo) {
+ AddDeclarationName(NameInfo.getName());
+ AddSourceLocation(NameInfo.getLoc());
+ AddDeclarationNameLoc(NameInfo.getInfo(), NameInfo.getName());
}
-void ASTWriter::AddQualifierInfo(const QualifierInfo &Info,
- RecordDataImpl &Record) {
- AddNestedNameSpecifierLoc(Info.QualifierLoc, Record);
- Record.push_back(Info.NumTemplParamLists);
+void ASTRecordWriter::AddQualifierInfo(const QualifierInfo &Info) {
+ AddNestedNameSpecifierLoc(Info.QualifierLoc);
+ Record->push_back(Info.NumTemplParamLists);
for (unsigned i=0, e=Info.NumTemplParamLists; i != e; ++i)
- AddTemplateParameterList(Info.TemplParamLists[i], Record);
+ AddTemplateParameterList(Info.TemplParamLists[i]);
}
-void ASTWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
- RecordDataImpl &Record) {
+void ASTRecordWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS) {
// Nested name specifiers usually aren't too long. I think that 8 would
// typically accommodate the vast majority.
SmallVector<NestedNameSpecifier *, 8> NestedNames;
@@ -5157,28 +5174,28 @@ void ASTWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
NNS = NNS->getPrefix();
}
- Record.push_back(NestedNames.size());
+ Record->push_back(NestedNames.size());
while(!NestedNames.empty()) {
NNS = NestedNames.pop_back_val();
NestedNameSpecifier::SpecifierKind Kind = NNS->getKind();
- Record.push_back(Kind);
+ Record->push_back(Kind);
switch (Kind) {
case NestedNameSpecifier::Identifier:
- AddIdentifierRef(NNS->getAsIdentifier(), Record);
+ AddIdentifierRef(NNS->getAsIdentifier());
break;
case NestedNameSpecifier::Namespace:
- AddDeclRef(NNS->getAsNamespace(), Record);
+ AddDeclRef(NNS->getAsNamespace());
break;
case NestedNameSpecifier::NamespaceAlias:
- AddDeclRef(NNS->getAsNamespaceAlias(), Record);
+ AddDeclRef(NNS->getAsNamespaceAlias());
break;
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate:
- AddTypeRef(QualType(NNS->getAsType(), 0), Record);
- Record.push_back(Kind == NestedNameSpecifier::TypeSpecWithTemplate);
+ AddTypeRef(QualType(NNS->getAsType(), 0));
+ Record->push_back(Kind == NestedNameSpecifier::TypeSpecWithTemplate);
break;
case NestedNameSpecifier::Global:
@@ -5186,14 +5203,13 @@ void ASTWriter::AddNestedNameSpecifier(NestedNameSpecifier *NNS,
break;
case NestedNameSpecifier::Super:
- AddDeclRef(NNS->getAsRecordDecl(), Record);
+ AddDeclRef(NNS->getAsRecordDecl());
break;
}
}
}
-void ASTWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
- RecordDataImpl &Record) {
+void ASTRecordWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS) {
// Nested name specifiers usually aren't too long. I think that 8 would
// typically accommodate the vast majority.
SmallVector<NestedNameSpecifierLoc , 8> NestedNames;
@@ -5205,373 +5221,333 @@ void ASTWriter::AddNestedNameSpecifierLoc(NestedNameSpecifierLoc NNS,
NNS = NNS.getPrefix();
}
- Record.push_back(NestedNames.size());
+ Record->push_back(NestedNames.size());
while(!NestedNames.empty()) {
NNS = NestedNames.pop_back_val();
NestedNameSpecifier::SpecifierKind Kind
= NNS.getNestedNameSpecifier()->getKind();
- Record.push_back(Kind);
+ Record->push_back(Kind);
switch (Kind) {
case NestedNameSpecifier::Identifier:
- AddIdentifierRef(NNS.getNestedNameSpecifier()->getAsIdentifier(), Record);
- AddSourceRange(NNS.getLocalSourceRange(), Record);
+ AddIdentifierRef(NNS.getNestedNameSpecifier()->getAsIdentifier());
+ AddSourceRange(NNS.getLocalSourceRange());
break;
case NestedNameSpecifier::Namespace:
- AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespace(), Record);
- AddSourceRange(NNS.getLocalSourceRange(), Record);
+ AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespace());
+ AddSourceRange(NNS.getLocalSourceRange());
break;
case NestedNameSpecifier::NamespaceAlias:
- AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespaceAlias(), Record);
- AddSourceRange(NNS.getLocalSourceRange(), Record);
+ AddDeclRef(NNS.getNestedNameSpecifier()->getAsNamespaceAlias());
+ AddSourceRange(NNS.getLocalSourceRange());
break;
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate:
- Record.push_back(Kind == NestedNameSpecifier::TypeSpecWithTemplate);
- AddTypeLoc(NNS.getTypeLoc(), Record);
- AddSourceLocation(NNS.getLocalSourceRange().getEnd(), Record);
+ Record->push_back(Kind == NestedNameSpecifier::TypeSpecWithTemplate);
+ AddTypeLoc(NNS.getTypeLoc());
+ AddSourceLocation(NNS.getLocalSourceRange().getEnd());
break;
case NestedNameSpecifier::Global:
- AddSourceLocation(NNS.getLocalSourceRange().getEnd(), Record);
+ AddSourceLocation(NNS.getLocalSourceRange().getEnd());
break;
case NestedNameSpecifier::Super:
- AddDeclRef(NNS.getNestedNameSpecifier()->getAsRecordDecl(), Record);
- AddSourceRange(NNS.getLocalSourceRange(), Record);
+ AddDeclRef(NNS.getNestedNameSpecifier()->getAsRecordDecl());
+ AddSourceRange(NNS.getLocalSourceRange());
break;
}
}
}
-void ASTWriter::AddTemplateName(TemplateName Name, RecordDataImpl &Record) {
+void ASTRecordWriter::AddTemplateName(TemplateName Name) {
TemplateName::NameKind Kind = Name.getKind();
- Record.push_back(Kind);
+ Record->push_back(Kind);
switch (Kind) {
case TemplateName::Template:
- AddDeclRef(Name.getAsTemplateDecl(), Record);
+ AddDeclRef(Name.getAsTemplateDecl());
break;
case TemplateName::OverloadedTemplate: {
OverloadedTemplateStorage *OvT = Name.getAsOverloadedTemplate();
- Record.push_back(OvT->size());
+ Record->push_back(OvT->size());
for (const auto &I : *OvT)
- AddDeclRef(I, Record);
+ AddDeclRef(I);
break;
}
case TemplateName::QualifiedTemplate: {
QualifiedTemplateName *QualT = Name.getAsQualifiedTemplateName();
- AddNestedNameSpecifier(QualT->getQualifier(), Record);
- Record.push_back(QualT->hasTemplateKeyword());
- AddDeclRef(QualT->getTemplateDecl(), Record);
+ AddNestedNameSpecifier(QualT->getQualifier());
+ Record->push_back(QualT->hasTemplateKeyword());
+ AddDeclRef(QualT->getTemplateDecl());
break;
}
case TemplateName::DependentTemplate: {
DependentTemplateName *DepT = Name.getAsDependentTemplateName();
- AddNestedNameSpecifier(DepT->getQualifier(), Record);
- Record.push_back(DepT->isIdentifier());
+ AddNestedNameSpecifier(DepT->getQualifier());
+ Record->push_back(DepT->isIdentifier());
if (DepT->isIdentifier())
- AddIdentifierRef(DepT->getIdentifier(), Record);
+ AddIdentifierRef(DepT->getIdentifier());
else
- Record.push_back(DepT->getOperator());
+ Record->push_back(DepT->getOperator());
break;
}
case TemplateName::SubstTemplateTemplateParm: {
SubstTemplateTemplateParmStorage *subst
= Name.getAsSubstTemplateTemplateParm();
- AddDeclRef(subst->getParameter(), Record);
- AddTemplateName(subst->getReplacement(), Record);
+ AddDeclRef(subst->getParameter());
+ AddTemplateName(subst->getReplacement());
break;
}
case TemplateName::SubstTemplateTemplateParmPack: {
SubstTemplateTemplateParmPackStorage *SubstPack
= Name.getAsSubstTemplateTemplateParmPack();
- AddDeclRef(SubstPack->getParameterPack(), Record);
- AddTemplateArgument(SubstPack->getArgumentPack(), Record);
+ AddDeclRef(SubstPack->getParameterPack());
+ AddTemplateArgument(SubstPack->getArgumentPack());
break;
}
}
}
-void ASTWriter::AddTemplateArgument(const TemplateArgument &Arg,
- RecordDataImpl &Record) {
- Record.push_back(Arg.getKind());
+void ASTRecordWriter::AddTemplateArgument(const TemplateArgument &Arg) {
+ Record->push_back(Arg.getKind());
switch (Arg.getKind()) {
case TemplateArgument::Null:
break;
case TemplateArgument::Type:
- AddTypeRef(Arg.getAsType(), Record);
+ AddTypeRef(Arg.getAsType());
break;
case TemplateArgument::Declaration:
- AddDeclRef(Arg.getAsDecl(), Record);
- AddTypeRef(Arg.getParamTypeForDecl(), Record);
+ AddDeclRef(Arg.getAsDecl());
+ AddTypeRef(Arg.getParamTypeForDecl());
break;
case TemplateArgument::NullPtr:
- AddTypeRef(Arg.getNullPtrType(), Record);
+ AddTypeRef(Arg.getNullPtrType());
break;
case TemplateArgument::Integral:
- AddAPSInt(Arg.getAsIntegral(), Record);
- AddTypeRef(Arg.getIntegralType(), Record);
+ AddAPSInt(Arg.getAsIntegral());
+ AddTypeRef(Arg.getIntegralType());
break;
case TemplateArgument::Template:
- AddTemplateName(Arg.getAsTemplateOrTemplatePattern(), Record);
+ AddTemplateName(Arg.getAsTemplateOrTemplatePattern());
break;
case TemplateArgument::TemplateExpansion:
- AddTemplateName(Arg.getAsTemplateOrTemplatePattern(), Record);
+ AddTemplateName(Arg.getAsTemplateOrTemplatePattern());
if (Optional<unsigned> NumExpansions = Arg.getNumTemplateExpansions())
- Record.push_back(*NumExpansions + 1);
+ Record->push_back(*NumExpansions + 1);
else
- Record.push_back(0);
+ Record->push_back(0);
break;
case TemplateArgument::Expression:
AddStmt(Arg.getAsExpr());
break;
case TemplateArgument::Pack:
- Record.push_back(Arg.pack_size());
+ Record->push_back(Arg.pack_size());
for (const auto &P : Arg.pack_elements())
- AddTemplateArgument(P, Record);
+ AddTemplateArgument(P);
break;
}
}
-void
-ASTWriter::AddTemplateParameterList(const TemplateParameterList *TemplateParams,
- RecordDataImpl &Record) {
+void ASTRecordWriter::AddTemplateParameterList(
+ const TemplateParameterList *TemplateParams) {
assert(TemplateParams && "No TemplateParams!");
- AddSourceLocation(TemplateParams->getTemplateLoc(), Record);
- AddSourceLocation(TemplateParams->getLAngleLoc(), Record);
- AddSourceLocation(TemplateParams->getRAngleLoc(), Record);
- Record.push_back(TemplateParams->size());
+ AddSourceLocation(TemplateParams->getTemplateLoc());
+ AddSourceLocation(TemplateParams->getLAngleLoc());
+ AddSourceLocation(TemplateParams->getRAngleLoc());
+ Record->push_back(TemplateParams->size());
for (const auto &P : *TemplateParams)
- AddDeclRef(P, Record);
+ AddDeclRef(P);
}
/// \brief Emit a template argument list.
-void
-ASTWriter::AddTemplateArgumentList(const TemplateArgumentList *TemplateArgs,
- RecordDataImpl &Record) {
+void ASTRecordWriter::AddTemplateArgumentList(
+ const TemplateArgumentList *TemplateArgs) {
assert(TemplateArgs && "No TemplateArgs!");
- Record.push_back(TemplateArgs->size());
+ Record->push_back(TemplateArgs->size());
for (int i=0, e = TemplateArgs->size(); i != e; ++i)
- AddTemplateArgument(TemplateArgs->get(i), Record);
+ AddTemplateArgument(TemplateArgs->get(i));
}
-void
-ASTWriter::AddASTTemplateArgumentListInfo
-(const ASTTemplateArgumentListInfo *ASTTemplArgList, RecordDataImpl &Record) {
+void ASTRecordWriter::AddASTTemplateArgumentListInfo(
+ const ASTTemplateArgumentListInfo *ASTTemplArgList) {
assert(ASTTemplArgList && "No ASTTemplArgList!");
- AddSourceLocation(ASTTemplArgList->LAngleLoc, Record);
- AddSourceLocation(ASTTemplArgList->RAngleLoc, Record);
- Record.push_back(ASTTemplArgList->NumTemplateArgs);
+ AddSourceLocation(ASTTemplArgList->LAngleLoc);
+ AddSourceLocation(ASTTemplArgList->RAngleLoc);
+ Record->push_back(ASTTemplArgList->NumTemplateArgs);
const TemplateArgumentLoc *TemplArgs = ASTTemplArgList->getTemplateArgs();
for (int i=0, e = ASTTemplArgList->NumTemplateArgs; i != e; ++i)
- AddTemplateArgumentLoc(TemplArgs[i], Record);
+ AddTemplateArgumentLoc(TemplArgs[i]);
}
-void
-ASTWriter::AddUnresolvedSet(const ASTUnresolvedSet &Set, RecordDataImpl &Record) {
- Record.push_back(Set.size());
+void ASTRecordWriter::AddUnresolvedSet(const ASTUnresolvedSet &Set) {
+ Record->push_back(Set.size());
for (ASTUnresolvedSet::const_iterator
I = Set.begin(), E = Set.end(); I != E; ++I) {
- AddDeclRef(I.getDecl(), Record);
- Record.push_back(I.getAccess());
+ AddDeclRef(I.getDecl());
+ Record->push_back(I.getAccess());
}
}
-void ASTWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base,
- RecordDataImpl &Record) {
- Record.push_back(Base.isVirtual());
- Record.push_back(Base.isBaseOfClass());
- Record.push_back(Base.getAccessSpecifierAsWritten());
- Record.push_back(Base.getInheritConstructors());
- AddTypeSourceInfo(Base.getTypeSourceInfo(), Record);
- AddSourceRange(Base.getSourceRange(), Record);
+// FIXME: Move this out of the main ASTRecordWriter interface.
+void ASTRecordWriter::AddCXXBaseSpecifier(const CXXBaseSpecifier &Base) {
+ Record->push_back(Base.isVirtual());
+ Record->push_back(Base.isBaseOfClass());
+ Record->push_back(Base.getAccessSpecifierAsWritten());
+ Record->push_back(Base.getInheritConstructors());
+ AddTypeSourceInfo(Base.getTypeSourceInfo());
+ AddSourceRange(Base.getSourceRange());
AddSourceLocation(Base.isPackExpansion()? Base.getEllipsisLoc()
- : SourceLocation(),
- Record);
+ : SourceLocation());
}
-void ASTWriter::FlushCXXBaseSpecifiers() {
- RecordData Record;
- unsigned N = CXXBaseSpecifiersToWrite.size();
- for (unsigned I = 0; I != N; ++I) {
- Record.clear();
-
- // Record the offset of this base-specifier set.
- unsigned Index = CXXBaseSpecifiersToWrite[I].ID - 1;
- if (Index == CXXBaseSpecifiersOffsets.size())
- CXXBaseSpecifiersOffsets.push_back(Stream.GetCurrentBitNo());
- else {
- if (Index > CXXBaseSpecifiersOffsets.size())
- CXXBaseSpecifiersOffsets.resize(Index + 1);
- CXXBaseSpecifiersOffsets[Index] = Stream.GetCurrentBitNo();
- }
+static uint64_t EmitCXXBaseSpecifiers(ASTWriter &W,
+ ArrayRef<CXXBaseSpecifier> Bases) {
+ ASTWriter::RecordData Record;
+ ASTRecordWriter Writer(W, Record);
+ Writer.push_back(Bases.size());
- const CXXBaseSpecifier *B = CXXBaseSpecifiersToWrite[I].Bases,
- *BEnd = CXXBaseSpecifiersToWrite[I].BasesEnd;
- Record.push_back(BEnd - B);
- for (; B != BEnd; ++B)
- AddCXXBaseSpecifier(*B, Record);
- Stream.EmitRecord(serialization::DECL_CXX_BASE_SPECIFIERS, Record);
-
- // Flush any expressions that were written as part of the base specifiers.
- FlushStmts();
- }
+ for (auto &Base : Bases)
+ Writer.AddCXXBaseSpecifier(Base);
+
+ return Writer.Emit(serialization::DECL_CXX_BASE_SPECIFIERS);
+}
- assert(N == CXXBaseSpecifiersToWrite.size() &&
- "added more base specifiers while writing base specifiers");
- CXXBaseSpecifiersToWrite.clear();
+// FIXME: Move this out of the main ASTRecordWriter interface.
+void ASTRecordWriter::AddCXXBaseSpecifiers(ArrayRef<CXXBaseSpecifier> Bases) {
+ AddOffset(EmitCXXBaseSpecifiers(*Writer, Bases));
}
-void ASTWriter::AddCXXCtorInitializers(
- const CXXCtorInitializer * const *CtorInitializers,
- unsigned NumCtorInitializers,
- RecordDataImpl &Record) {
- Record.push_back(NumCtorInitializers);
- for (unsigned i=0; i != NumCtorInitializers; ++i) {
- const CXXCtorInitializer *Init = CtorInitializers[i];
+static uint64_t
+EmitCXXCtorInitializers(ASTWriter &W,
+ ArrayRef<CXXCtorInitializer *> CtorInits) {
+ ASTWriter::RecordData Record;
+ ASTRecordWriter Writer(W, Record);
+ Writer.push_back(CtorInits.size());
+ for (auto *Init : CtorInits) {
if (Init->isBaseInitializer()) {
- Record.push_back(CTOR_INITIALIZER_BASE);
- AddTypeSourceInfo(Init->getTypeSourceInfo(), Record);
- Record.push_back(Init->isBaseVirtual());
+ Writer.push_back(CTOR_INITIALIZER_BASE);
+ Writer.AddTypeSourceInfo(Init->getTypeSourceInfo());
+ Writer.push_back(Init->isBaseVirtual());
} else if (Init->isDelegatingInitializer()) {
- Record.push_back(CTOR_INITIALIZER_DELEGATING);
- AddTypeSourceInfo(Init->getTypeSourceInfo(), Record);
+ Writer.push_back(CTOR_INITIALIZER_DELEGATING);
+ Writer.AddTypeSourceInfo(Init->getTypeSourceInfo());
} else if (Init->isMemberInitializer()){
- Record.push_back(CTOR_INITIALIZER_MEMBER);
- AddDeclRef(Init->getMember(), Record);
+ Writer.push_back(CTOR_INITIALIZER_MEMBER);
+ Writer.AddDeclRef(Init->getMember());
} else {
- Record.push_back(CTOR_INITIALIZER_INDIRECT_MEMBER);
- AddDeclRef(Init->getIndirectMember(), Record);
+ Writer.push_back(CTOR_INITIALIZER_INDIRECT_MEMBER);
+ Writer.AddDeclRef(Init->getIndirectMember());
}
- AddSourceLocation(Init->getMemberLocation(), Record);
- AddStmt(Init->getInit());
- AddSourceLocation(Init->getLParenLoc(), Record);
- AddSourceLocation(Init->getRParenLoc(), Record);
- Record.push_back(Init->isWritten());
+ Writer.AddSourceLocation(Init->getMemberLocation());
+ Writer.AddStmt(Init->getInit());
+ Writer.AddSourceLocation(Init->getLParenLoc());
+ Writer.AddSourceLocation(Init->getRParenLoc());
+ Writer.push_back(Init->isWritten());
if (Init->isWritten()) {
- Record.push_back(Init->getSourceOrder());
+ Writer.push_back(Init->getSourceOrder());
} else {
- Record.push_back(Init->getNumArrayIndices());
- for (unsigned i=0, e=Init->getNumArrayIndices(); i != e; ++i)
- AddDeclRef(Init->getArrayIndex(i), Record);
+ Writer.push_back(Init->getNumArrayIndices());
+ for (auto *VD : Init->getArrayIndices())
+ Writer.AddDeclRef(VD);
}
}
-}
-
-void ASTWriter::FlushCXXCtorInitializers() {
- RecordData Record;
- unsigned N = CXXCtorInitializersToWrite.size();
- (void)N; // Silence unused warning in non-assert builds.
- for (auto &Init : CXXCtorInitializersToWrite) {
- Record.clear();
-
- // Record the offset of this mem-initializer list.
- unsigned Index = Init.ID - 1;
- if (Index == CXXCtorInitializersOffsets.size())
- CXXCtorInitializersOffsets.push_back(Stream.GetCurrentBitNo());
- else {
- if (Index > CXXCtorInitializersOffsets.size())
- CXXCtorInitializersOffsets.resize(Index + 1);
- CXXCtorInitializersOffsets[Index] = Stream.GetCurrentBitNo();
- }
-
- AddCXXCtorInitializers(Init.Inits.data(), Init.Inits.size(), Record);
- Stream.EmitRecord(serialization::DECL_CXX_CTOR_INITIALIZERS, Record);
-
- // Flush any expressions that were written as part of the initializers.
- FlushStmts();
- }
+ return Writer.Emit(serialization::DECL_CXX_CTOR_INITIALIZERS);
+}
- assert(N == CXXCtorInitializersToWrite.size() &&
- "added more ctor initializers while writing ctor initializers");
- CXXCtorInitializersToWrite.clear();
+// FIXME: Move this out of the main ASTRecordWriter interface.
+void ASTRecordWriter::AddCXXCtorInitializers(
+ ArrayRef<CXXCtorInitializer *> CtorInits) {
+ AddOffset(EmitCXXCtorInitializers(*Writer, CtorInits));
}
-void ASTWriter::AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Record) {
+void ASTRecordWriter::AddCXXDefinitionData(const CXXRecordDecl *D) {
auto &Data = D->data();
- Record.push_back(Data.IsLambda);
- Record.push_back(Data.UserDeclaredConstructor);
- Record.push_back(Data.UserDeclaredSpecialMembers);
- Record.push_back(Data.Aggregate);
- Record.push_back(Data.PlainOldData);
- Record.push_back(Data.Empty);
- Record.push_back(Data.Polymorphic);
- Record.push_back(Data.Abstract);
- Record.push_back(Data.IsStandardLayout);
- Record.push_back(Data.HasNoNonEmptyBases);
- Record.push_back(Data.HasPrivateFields);
- Record.push_back(Data.HasProtectedFields);
- Record.push_back(Data.HasPublicFields);
- Record.push_back(Data.HasMutableFields);
- Record.push_back(Data.HasVariantMembers);
- Record.push_back(Data.HasOnlyCMembers);
- Record.push_back(Data.HasInClassInitializer);
- Record.push_back(Data.HasUninitializedReferenceMember);
- Record.push_back(Data.NeedOverloadResolutionForMoveConstructor);
- Record.push_back(Data.NeedOverloadResolutionForMoveAssignment);
- Record.push_back(Data.NeedOverloadResolutionForDestructor);
- Record.push_back(Data.DefaultedMoveConstructorIsDeleted);
- Record.push_back(Data.DefaultedMoveAssignmentIsDeleted);
- Record.push_back(Data.DefaultedDestructorIsDeleted);
- Record.push_back(Data.HasTrivialSpecialMembers);
- Record.push_back(Data.DeclaredNonTrivialSpecialMembers);
- Record.push_back(Data.HasIrrelevantDestructor);
- Record.push_back(Data.HasConstexprNonCopyMoveConstructor);
- Record.push_back(Data.DefaultedDefaultConstructorIsConstexpr);
- Record.push_back(Data.HasConstexprDefaultConstructor);
- Record.push_back(Data.HasNonLiteralTypeFieldsOrBases);
- Record.push_back(Data.ComputedVisibleConversions);
- Record.push_back(Data.UserProvidedDefaultConstructor);
- Record.push_back(Data.DeclaredSpecialMembers);
- Record.push_back(Data.ImplicitCopyConstructorHasConstParam);
- Record.push_back(Data.ImplicitCopyAssignmentHasConstParam);
- Record.push_back(Data.HasDeclaredCopyConstructorWithConstParam);
- Record.push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
+ Record->push_back(Data.IsLambda);
+ Record->push_back(Data.UserDeclaredConstructor);
+ Record->push_back(Data.UserDeclaredSpecialMembers);
+ Record->push_back(Data.Aggregate);
+ Record->push_back(Data.PlainOldData);
+ Record->push_back(Data.Empty);
+ Record->push_back(Data.Polymorphic);
+ Record->push_back(Data.Abstract);
+ Record->push_back(Data.IsStandardLayout);
+ Record->push_back(Data.HasNoNonEmptyBases);
+ Record->push_back(Data.HasPrivateFields);
+ Record->push_back(Data.HasProtectedFields);
+ Record->push_back(Data.HasPublicFields);
+ Record->push_back(Data.HasMutableFields);
+ Record->push_back(Data.HasVariantMembers);
+ Record->push_back(Data.HasOnlyCMembers);
+ Record->push_back(Data.HasInClassInitializer);
+ Record->push_back(Data.HasUninitializedReferenceMember);
+ Record->push_back(Data.HasUninitializedFields);
+ Record->push_back(Data.HasInheritedConstructor);
+ Record->push_back(Data.HasInheritedAssignment);
+ Record->push_back(Data.NeedOverloadResolutionForMoveConstructor);
+ Record->push_back(Data.NeedOverloadResolutionForMoveAssignment);
+ Record->push_back(Data.NeedOverloadResolutionForDestructor);
+ Record->push_back(Data.DefaultedMoveConstructorIsDeleted);
+ Record->push_back(Data.DefaultedMoveAssignmentIsDeleted);
+ Record->push_back(Data.DefaultedDestructorIsDeleted);
+ Record->push_back(Data.HasTrivialSpecialMembers);
+ Record->push_back(Data.DeclaredNonTrivialSpecialMembers);
+ Record->push_back(Data.HasIrrelevantDestructor);
+ Record->push_back(Data.HasConstexprNonCopyMoveConstructor);
+ Record->push_back(Data.HasDefaultedDefaultConstructor);
+ Record->push_back(Data.DefaultedDefaultConstructorIsConstexpr);
+ Record->push_back(Data.HasConstexprDefaultConstructor);
+ Record->push_back(Data.HasNonLiteralTypeFieldsOrBases);
+ Record->push_back(Data.ComputedVisibleConversions);
+ Record->push_back(Data.UserProvidedDefaultConstructor);
+ Record->push_back(Data.DeclaredSpecialMembers);
+ Record->push_back(Data.ImplicitCopyConstructorHasConstParam);
+ Record->push_back(Data.ImplicitCopyAssignmentHasConstParam);
+ Record->push_back(Data.HasDeclaredCopyConstructorWithConstParam);
+ Record->push_back(Data.HasDeclaredCopyAssignmentWithConstParam);
// IsLambda bit is already saved.
- Record.push_back(Data.NumBases);
+ Record->push_back(Data.NumBases);
if (Data.NumBases > 0)
- AddCXXBaseSpecifiersRef(Data.getBases(), Data.getBases() + Data.NumBases,
- Record);
-
+ AddCXXBaseSpecifiers(Data.bases());
+
// FIXME: Make VBases lazily computed when needed to avoid storing them.
- Record.push_back(Data.NumVBases);
+ Record->push_back(Data.NumVBases);
if (Data.NumVBases > 0)
- AddCXXBaseSpecifiersRef(Data.getVBases(), Data.getVBases() + Data.NumVBases,
- Record);
+ AddCXXBaseSpecifiers(Data.vbases());
- AddUnresolvedSet(Data.Conversions.get(*Context), Record);
- AddUnresolvedSet(Data.VisibleConversions.get(*Context), Record);
+ AddUnresolvedSet(Data.Conversions.get(*Writer->Context));
+ AddUnresolvedSet(Data.VisibleConversions.get(*Writer->Context));
// Data.Definition is the owning decl, no need to write it.
- AddDeclRef(D->getFirstFriend(), Record);
+ AddDeclRef(D->getFirstFriend());
// Add lambda-specific data.
if (Data.IsLambda) {
auto &Lambda = D->getLambdaData();
- Record.push_back(Lambda.Dependent);
- Record.push_back(Lambda.IsGenericLambda);
- Record.push_back(Lambda.CaptureDefault);
- Record.push_back(Lambda.NumCaptures);
- Record.push_back(Lambda.NumExplicitCaptures);
- Record.push_back(Lambda.ManglingNumber);
- AddDeclRef(Lambda.ContextDecl, Record);
- AddTypeSourceInfo(Lambda.MethodTyInfo, Record);
+ Record->push_back(Lambda.Dependent);
+ Record->push_back(Lambda.IsGenericLambda);
+ Record->push_back(Lambda.CaptureDefault);
+ Record->push_back(Lambda.NumCaptures);
+ Record->push_back(Lambda.NumExplicitCaptures);
+ Record->push_back(Lambda.ManglingNumber);
+ AddDeclRef(Lambda.ContextDecl);
+ AddTypeSourceInfo(Lambda.MethodTyInfo);
for (unsigned I = 0, N = Lambda.NumCaptures; I != N; ++I) {
const LambdaCapture &Capture = Lambda.Captures[I];
- AddSourceLocation(Capture.getLocation(), Record);
- Record.push_back(Capture.isImplicit());
- Record.push_back(Capture.getCaptureKind());
+ AddSourceLocation(Capture.getLocation());
+ Record->push_back(Capture.isImplicit());
+ Record->push_back(Capture.getCaptureKind());
switch (Capture.getCaptureKind()) {
+ case LCK_StarThis:
case LCK_This:
case LCK_VLAType:
break;
@@ -5579,10 +5555,9 @@ void ASTWriter::AddCXXDefinitionData(const CXXRecordDecl *D, RecordDataImpl &Rec
case LCK_ByRef:
VarDecl *Var =
Capture.capturesVariable() ? Capture.getCapturedVar() : nullptr;
- AddDeclRef(Var, Record);
+ AddDeclRef(Var);
AddSourceLocation(Capture.isPackExpansion() ? Capture.getEllipsisLoc()
- : SourceLocation(),
- Record);
+ : SourceLocation());
break;
}
}
@@ -5682,18 +5657,25 @@ static bool isImportedDeclContext(ASTReader *Chain, const Decl *D) {
if (D->isFromASTFile())
return true;
- // If we've not loaded any modules, this can't be imported.
- if (!Chain || !Chain->getModuleManager().size())
- return false;
-
// The predefined __va_list_tag struct is imported if we imported any decls.
// FIXME: This is a gross hack.
return D == D->getASTContext().getVaListTagDecl();
}
void ASTWriter::AddedVisibleDecl(const DeclContext *DC, const Decl *D) {
- // TU and namespaces are handled elsewhere.
- if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC))
+ assert(DC->isLookupContext() &&
+ "Should not add lookup results to non-lookup contexts!");
+
+ // TU is handled elsewhere.
+ if (isa<TranslationUnitDecl>(DC))
+ return;
+
+ // Namespaces are handled elsewhere, except for template instantiations of
+ // FunctionTemplateDecls in namespaces. We are interested in cases where the
+ // local instantiations are added to an imported context. Only happens when
+ // adding ADL lookup candidates, for example templated friends.
+ if (isa<NamespaceDecl>(DC) && D->getFriendObjectKind() == Decl::FOK_None &&
+ !isa<FunctionTemplateDecl>(D))
return;
// We're only interested in cases where a local declaration is added to an
@@ -5815,8 +5797,13 @@ void ASTWriter::AddedObjCCategoryToInterface(const ObjCCategoryDecl *CatD,
void ASTWriter::DeclarationMarkedUsed(const Decl *D) {
assert(!WritingAST && "Already writing the AST!");
- if (!D->isFromASTFile())
- return;
+
+ // If there is *any* declaration of the entity that's not from an AST file,
+ // we can skip writing the update record. We make sure that isUsed() triggers
+ // completion of the redeclaration chain of the entity.
+ for (auto Prev = D->getMostRecentDecl(); Prev; Prev = Prev->getPreviousDecl())
+ if (IsLocalDecl(Prev))
+ return;
DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_MARKED_USED));
}
@@ -5829,6 +5816,16 @@ void ASTWriter::DeclarationMarkedOpenMPThreadPrivate(const Decl *D) {
DeclUpdates[D].push_back(DeclUpdate(UPD_DECL_MARKED_OPENMP_THREADPRIVATE));
}
+void ASTWriter::DeclarationMarkedOpenMPDeclareTarget(const Decl *D,
+ const Attr *Attr) {
+ assert(!WritingAST && "Already writing the AST!");
+ if (!D->isFromASTFile())
+ return;
+
+ DeclUpdates[D].push_back(
+ DeclUpdate(UPD_DECL_MARKED_OPENMP_DECLARETARGET, Attr));
+}
+
void ASTWriter::RedefinedHiddenDefinition(const NamedDecl *D, Module *M) {
assert(!WritingAST && "Already writing the AST!");
assert(D->isHidden() && "expected a hidden declaration");
diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp
index 54bba282ab8d..23d18540e822 100644
--- a/lib/Serialization/ASTWriterDecl.cpp
+++ b/lib/Serialization/ASTWriterDecl.cpp
@@ -32,23 +32,31 @@ using namespace serialization;
namespace clang {
class ASTDeclWriter : public DeclVisitor<ASTDeclWriter, void> {
-
ASTWriter &Writer;
ASTContext &Context;
- typedef ASTWriter::RecordData RecordData;
- RecordData &Record;
+ ASTRecordWriter Record;
- public:
serialization::DeclCode Code;
unsigned AbbrevToUse;
- ASTDeclWriter(ASTWriter &Writer, ASTContext &Context, RecordData &Record)
- : Writer(Writer), Context(Context), Record(Record) {
+ public:
+ ASTDeclWriter(ASTWriter &Writer, ASTContext &Context,
+ ASTWriter::RecordDataImpl &Record)
+ : Writer(Writer), Context(Context), Record(Writer, Record),
+ Code((serialization::DeclCode)0), AbbrevToUse(0) {}
+
+ uint64_t Emit(Decl *D) {
+ if (!Code)
+ llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
+ D->getDeclKindName() + "'");
+ return Record.Emit(Code, AbbrevToUse);
}
void Visit(Decl *D);
void VisitDecl(Decl *D);
+ void VisitPragmaCommentDecl(PragmaCommentDecl *D);
+ void VisitPragmaDetectMismatchDecl(PragmaDetectMismatchDecl *D);
void VisitTranslationUnitDecl(TranslationUnitDecl *D);
void VisitNamedDecl(NamedDecl *D);
void VisitLabelDecl(LabelDecl *LD);
@@ -99,6 +107,7 @@ namespace clang {
void VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D);
void VisitUsingDecl(UsingDecl *D);
void VisitUsingShadowDecl(UsingShadowDecl *D);
+ void VisitConstructorUsingShadowDecl(ConstructorUsingShadowDecl *D);
void VisitLinkageSpecDecl(LinkageSpecDecl *D);
void VisitFileScopeAsmDecl(FileScopeAsmDecl *D);
void VisitImportDecl(ImportDecl *D);
@@ -110,8 +119,7 @@ namespace clang {
void VisitCapturedDecl(CapturedDecl *D);
void VisitEmptyDecl(EmptyDecl *D);
- void VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
- uint64_t VisibleOffset);
+ void VisitDeclContext(DeclContext *DC);
template <typename T> void VisitRedeclarable(Redeclarable<T> *D);
@@ -131,6 +139,8 @@ namespace clang {
void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D);
void VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D);
+ void VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D);
+ void VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D);
/// Add an Objective-C type parameter list to the given record.
void AddObjCTypeParamList(ObjCTypeParamList *typeParams) {
@@ -142,21 +152,10 @@ namespace clang {
Record.push_back(typeParams->size());
for (auto typeParam : *typeParams) {
- Writer.AddDeclRef(typeParam, Record);
+ Record.AddDeclRef(typeParam);
}
- Writer.AddSourceLocation(typeParams->getLAngleLoc(), Record);
- Writer.AddSourceLocation(typeParams->getRAngleLoc(), Record);
- }
-
- void AddFunctionDefinition(const FunctionDecl *FD) {
- assert(FD->doesThisDeclarationHaveABody());
- if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
- Record.push_back(CD->NumCtorInitializers);
- if (CD->NumCtorInitializers)
- Writer.AddCXXCtorInitializersRef(
- llvm::makeArrayRef(CD->init_begin(), CD->init_end()), Record);
- }
- Writer.AddStmt(FD->getBody());
+ Record.AddSourceLocation(typeParams->getLAngleLoc());
+ Record.AddSourceLocation(typeParams->getRAngleLoc());
}
/// Add to the record the first declaration from each module file that
@@ -172,7 +171,7 @@ namespace clang {
Firsts[nullptr] = R;
}
for (const auto &F : Firsts)
- Writer.AddDeclRef(F.second, Record);
+ Record.AddDeclRef(F.second);
}
/// Get the specialization decl from an entry in the specialization list.
@@ -191,8 +190,8 @@ namespace clang {
return None;
}
- template<typename Decl>
- void AddTemplateSpecializations(Decl *D) {
+ template<typename DeclTy>
+ void AddTemplateSpecializations(DeclTy *D) {
auto *Common = D->getCommonPtr();
// If we have any lazy specializations, and the external AST source is
@@ -204,8 +203,6 @@ namespace clang {
assert(!Common->LazySpecializations);
}
- auto &Specializations = Common->Specializations;
- auto &&PartialSpecializations = getPartialSpecializations(Common);
ArrayRef<DeclID> LazySpecializations;
if (auto *LS = Common->LazySpecializations)
LazySpecializations = llvm::makeArrayRef(LS + 1, LS[0]);
@@ -214,13 +211,15 @@ namespace clang {
unsigned I = Record.size();
Record.push_back(0);
- for (auto &Entry : Specializations) {
- auto *D = getSpecializationDecl(Entry);
- assert(D->isCanonicalDecl() && "non-canonical decl in set");
- AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
- }
- for (auto &Entry : PartialSpecializations) {
- auto *D = getSpecializationDecl(Entry);
+ // AddFirstDeclFromEachModule might trigger deserialization, invalidating
+ // *Specializations iterators.
+ llvm::SmallVector<const Decl*, 16> Specs;
+ for (auto &Entry : Common->Specializations)
+ Specs.push_back(getSpecializationDecl(Entry));
+ for (auto &Entry : getPartialSpecializations(Common))
+ Specs.push_back(getSpecializationDecl(Entry));
+
+ for (auto *D : Specs) {
assert(D->isCanonicalDecl() && "non-canonical decl in set");
AddFirstDeclFromEachModule(D, /*IncludeLocal*/true);
}
@@ -261,7 +260,7 @@ void ASTDeclWriter::Visit(Decl *D) {
// abbreviation infrastructure requires that arrays are encoded last, so
// we handle it here in the case of those classes derived from DeclaratorDecl
if (DeclaratorDecl *DD = dyn_cast<DeclaratorDecl>(D)) {
- Writer.AddTypeSourceInfo(DD->getTypeSourceInfo(), Record);
+ Record.AddTypeSourceInfo(DD->getTypeSourceInfo());
}
// Handle FunctionDecl's body here and write it after all other Stmts/Exprs
@@ -270,21 +269,26 @@ void ASTDeclWriter::Visit(Decl *D) {
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
Record.push_back(FD->doesThisDeclarationHaveABody());
if (FD->doesThisDeclarationHaveABody())
- AddFunctionDefinition(FD);
+ Record.AddFunctionDefinition(FD);
}
+
+ // If this declaration is also a DeclContext, write blocks for the
+ // declarations that lexically stored inside its context and those
+ // declarations that are visible from its context.
+ if (DeclContext *DC = dyn_cast<DeclContext>(D))
+ VisitDeclContext(DC);
}
void ASTDeclWriter::VisitDecl(Decl *D) {
- Writer.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()), Record);
+ Record.AddDeclRef(cast_or_null<Decl>(D->getDeclContext()));
if (D->getDeclContext() != D->getLexicalDeclContext())
- Writer.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()), Record);
+ Record.AddDeclRef(cast_or_null<Decl>(D->getLexicalDeclContext()));
else
Record.push_back(0);
Record.push_back(D->isInvalidDecl());
Record.push_back(D->hasAttrs());
if (D->hasAttrs())
- Writer.WriteAttributes(llvm::makeArrayRef(D->getAttrs().begin(),
- D->getAttrs().size()), Record);
+ Record.AddAttributes(D->getAttrs());
Record.push_back(D->isImplicit());
Record.push_back(D->isUsed(false));
Record.push_back(D->isReferenced());
@@ -314,13 +318,35 @@ void ASTDeclWriter::VisitDecl(Decl *D) {
}
}
+void ASTDeclWriter::VisitPragmaCommentDecl(PragmaCommentDecl *D) {
+ StringRef Arg = D->getArg();
+ Record.push_back(Arg.size());
+ VisitDecl(D);
+ Record.AddSourceLocation(D->getLocStart());
+ Record.push_back(D->getCommentKind());
+ Record.AddString(Arg);
+ Code = serialization::DECL_PRAGMA_COMMENT;
+}
+
+void ASTDeclWriter::VisitPragmaDetectMismatchDecl(
+ PragmaDetectMismatchDecl *D) {
+ StringRef Name = D->getName();
+ StringRef Value = D->getValue();
+ Record.push_back(Name.size() + 1 + Value.size());
+ VisitDecl(D);
+ Record.AddSourceLocation(D->getLocStart());
+ Record.AddString(Name);
+ Record.AddString(Value);
+ Code = serialization::DECL_PRAGMA_DETECT_MISMATCH;
+}
+
void ASTDeclWriter::VisitTranslationUnitDecl(TranslationUnitDecl *D) {
llvm_unreachable("Translation units aren't directly serialized");
}
void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) {
VisitDecl(D);
- Writer.AddDeclarationName(D->getDeclName(), Record);
+ Record.AddDeclarationName(D->getDeclName());
Record.push_back(needsAnonymousDeclarationNumber(D)
? Writer.getAnonymousDeclarationNumber(D)
: 0);
@@ -328,17 +354,17 @@ void ASTDeclWriter::VisitNamedDecl(NamedDecl *D) {
void ASTDeclWriter::VisitTypeDecl(TypeDecl *D) {
VisitNamedDecl(D);
- Writer.AddSourceLocation(D->getLocStart(), Record);
- Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
+ Record.AddSourceLocation(D->getLocStart());
+ Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
}
void ASTDeclWriter::VisitTypedefNameDecl(TypedefNameDecl *D) {
VisitRedeclarable(D);
VisitTypeDecl(D);
- Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
+ Record.AddTypeSourceInfo(D->getTypeSourceInfo());
Record.push_back(D->isModed());
if (D->isModed())
- Writer.AddTypeRef(D->getUnderlyingType(), Record);
+ Record.AddTypeRef(D->getUnderlyingType());
}
void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) {
@@ -359,7 +385,7 @@ void ASTDeclWriter::VisitTypedefDecl(TypedefDecl *D) {
void ASTDeclWriter::VisitTypeAliasDecl(TypeAliasDecl *D) {
VisitTypedefNameDecl(D);
- Writer.AddDeclRef(D->getDescribedAliasTemplate(), Record);
+ Record.AddDeclRef(D->getDescribedAliasTemplate());
Code = serialization::DECL_TYPEALIAS;
}
@@ -373,15 +399,15 @@ void ASTDeclWriter::VisitTagDecl(TagDecl *D) {
Record.push_back(D->isEmbeddedInDeclarator());
Record.push_back(D->isFreeStanding());
Record.push_back(D->isCompleteDefinitionRequired());
- Writer.AddSourceLocation(D->getRBraceLoc(), Record);
+ Record.AddSourceRange(D->getBraceRange());
if (D->hasExtInfo()) {
Record.push_back(1);
- Writer.AddQualifierInfo(*D->getExtInfo(), Record);
+ Record.AddQualifierInfo(*D->getExtInfo());
} else if (auto *TD = D->getTypedefNameForAnonDecl()) {
Record.push_back(2);
- Writer.AddDeclRef(TD, Record);
- Writer.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo(), Record);
+ Record.AddDeclRef(TD);
+ Record.AddIdentifierRef(TD->getDeclName().getAsIdentifierInfo());
} else {
Record.push_back(0);
}
@@ -389,21 +415,21 @@ void ASTDeclWriter::VisitTagDecl(TagDecl *D) {
void ASTDeclWriter::VisitEnumDecl(EnumDecl *D) {
VisitTagDecl(D);
- Writer.AddTypeSourceInfo(D->getIntegerTypeSourceInfo(), Record);
+ Record.AddTypeSourceInfo(D->getIntegerTypeSourceInfo());
if (!D->getIntegerTypeSourceInfo())
- Writer.AddTypeRef(D->getIntegerType(), Record);
- Writer.AddTypeRef(D->getPromotionType(), Record);
+ Record.AddTypeRef(D->getIntegerType());
+ Record.AddTypeRef(D->getPromotionType());
Record.push_back(D->getNumPositiveBits());
Record.push_back(D->getNumNegativeBits());
Record.push_back(D->isScoped());
Record.push_back(D->isScopedUsingClassTag());
Record.push_back(D->isFixed());
if (MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo()) {
- Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);
+ Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
Record.push_back(MemberInfo->getTemplateSpecializationKind());
- Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);
+ Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
} else {
- Writer.AddDeclRef(nullptr, Record);
+ Record.AddDeclRef(nullptr);
}
if (D->getDeclContext() == D->getLexicalDeclContext() &&
@@ -457,31 +483,31 @@ void ASTDeclWriter::VisitRecordDecl(RecordDecl *D) {
void ASTDeclWriter::VisitValueDecl(ValueDecl *D) {
VisitNamedDecl(D);
- Writer.AddTypeRef(D->getType(), Record);
+ Record.AddTypeRef(D->getType());
}
void ASTDeclWriter::VisitEnumConstantDecl(EnumConstantDecl *D) {
VisitValueDecl(D);
Record.push_back(D->getInitExpr()? 1 : 0);
if (D->getInitExpr())
- Writer.AddStmt(D->getInitExpr());
- Writer.AddAPSInt(D->getInitVal(), Record);
+ Record.AddStmt(D->getInitExpr());
+ Record.AddAPSInt(D->getInitVal());
Code = serialization::DECL_ENUM_CONSTANT;
}
void ASTDeclWriter::VisitDeclaratorDecl(DeclaratorDecl *D) {
VisitValueDecl(D);
- Writer.AddSourceLocation(D->getInnerLocStart(), Record);
+ Record.AddSourceLocation(D->getInnerLocStart());
Record.push_back(D->hasExtInfo());
if (D->hasExtInfo())
- Writer.AddQualifierInfo(*D->getExtInfo(), Record);
+ Record.AddQualifierInfo(*D->getExtInfo());
}
void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
VisitRedeclarable(D);
VisitDeclaratorDecl(D);
- Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
+ Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
Record.push_back(D->getIdentifierNamespace());
// FunctionDecl's body is handled last at ASTWriterDecl::Visit,
@@ -503,20 +529,20 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
Record.push_back(D->HasSkippedBody);
Record.push_back(D->IsLateTemplateParsed);
Record.push_back(D->getLinkageInternal());
- Writer.AddSourceLocation(D->getLocEnd(), Record);
+ Record.AddSourceLocation(D->getLocEnd());
Record.push_back(D->getTemplatedKind());
switch (D->getTemplatedKind()) {
case FunctionDecl::TK_NonTemplate:
break;
case FunctionDecl::TK_FunctionTemplate:
- Writer.AddDeclRef(D->getDescribedFunctionTemplate(), Record);
+ Record.AddDeclRef(D->getDescribedFunctionTemplate());
break;
case FunctionDecl::TK_MemberSpecialization: {
MemberSpecializationInfo *MemberInfo = D->getMemberSpecializationInfo();
- Writer.AddDeclRef(MemberInfo->getInstantiatedFrom(), Record);
+ Record.AddDeclRef(MemberInfo->getInstantiatedFrom());
Record.push_back(MemberInfo->getTemplateSpecializationKind());
- Writer.AddSourceLocation(MemberInfo->getPointOfInstantiation(), Record);
+ Record.AddSourceLocation(MemberInfo->getPointOfInstantiation());
break;
}
case FunctionDecl::TK_FunctionTemplateSpecialization: {
@@ -525,11 +551,11 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
RegisterTemplateSpecialization(FTSInfo->getTemplate(), D);
- Writer.AddDeclRef(FTSInfo->getTemplate(), Record);
+ Record.AddDeclRef(FTSInfo->getTemplate());
Record.push_back(FTSInfo->getTemplateSpecializationKind());
// Template arguments.
- Writer.AddTemplateArgumentList(FTSInfo->TemplateArguments, Record);
+ Record.AddTemplateArgumentList(FTSInfo->TemplateArguments);
// Template args as written.
Record.push_back(FTSInfo->TemplateArgumentsAsWritten != nullptr);
@@ -537,20 +563,18 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
Record.push_back(FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs);
for (int i=0, e = FTSInfo->TemplateArgumentsAsWritten->NumTemplateArgs;
i!=e; ++i)
- Writer.AddTemplateArgumentLoc((*FTSInfo->TemplateArgumentsAsWritten)[i],
- Record);
- Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc,
- Record);
- Writer.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc,
- Record);
+ Record.AddTemplateArgumentLoc(
+ (*FTSInfo->TemplateArgumentsAsWritten)[i]);
+ Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->LAngleLoc);
+ Record.AddSourceLocation(FTSInfo->TemplateArgumentsAsWritten->RAngleLoc);
}
- Writer.AddSourceLocation(FTSInfo->getPointOfInstantiation(), Record);
+ Record.AddSourceLocation(FTSInfo->getPointOfInstantiation());
if (D->isCanonicalDecl()) {
// Write the template that contains the specializations set. We will
// add a FunctionTemplateSpecializationInfo to it when reading.
- Writer.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl(), Record);
+ Record.AddDeclRef(FTSInfo->getTemplate()->getCanonicalDecl());
}
break;
}
@@ -561,21 +585,21 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
// Templates.
Record.push_back(DFTSInfo->getNumTemplates());
for (int i=0, e = DFTSInfo->getNumTemplates(); i != e; ++i)
- Writer.AddDeclRef(DFTSInfo->getTemplate(i), Record);
+ Record.AddDeclRef(DFTSInfo->getTemplate(i));
// Templates args.
Record.push_back(DFTSInfo->getNumTemplateArgs());
for (int i=0, e = DFTSInfo->getNumTemplateArgs(); i != e; ++i)
- Writer.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i), Record);
- Writer.AddSourceLocation(DFTSInfo->getLAngleLoc(), Record);
- Writer.AddSourceLocation(DFTSInfo->getRAngleLoc(), Record);
+ Record.AddTemplateArgumentLoc(DFTSInfo->getTemplateArg(i));
+ Record.AddSourceLocation(DFTSInfo->getLAngleLoc());
+ Record.AddSourceLocation(DFTSInfo->getRAngleLoc());
break;
}
}
Record.push_back(D->param_size());
- for (auto P : D->params())
- Writer.AddDeclRef(P, Record);
+ for (auto P : D->parameters())
+ Record.AddDeclRef(P);
Code = serialization::DECL_FUNCTION;
}
@@ -587,9 +611,9 @@ void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
D->getSelfDecl() != nullptr || D->getCmdDecl() != nullptr;
Record.push_back(HasBodyStuff);
if (HasBodyStuff) {
- Writer.AddStmt(D->getBody());
- Writer.AddDeclRef(D->getSelfDecl(), Record);
- Writer.AddDeclRef(D->getCmdDecl(), Record);
+ Record.AddStmt(D->getBody());
+ Record.AddDeclRef(D->getSelfDecl());
+ Record.AddDeclRef(D->getCmdDecl());
}
Record.push_back(D->isInstanceMethod());
Record.push_back(D->isVariadic());
@@ -602,7 +626,7 @@ void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
Record.push_back(D->HasRedeclaration);
if (D->HasRedeclaration) {
assert(Context.getObjCMethodRedeclaration(D));
- Writer.AddDeclRef(Context.getObjCMethodRedeclaration(D), Record);
+ Record.AddDeclRef(Context.getObjCMethodRedeclaration(D));
}
// FIXME: stable encoding for @required/@optional
@@ -610,19 +634,19 @@ void ASTDeclWriter::VisitObjCMethodDecl(ObjCMethodDecl *D) {
// FIXME: stable encoding for in/out/inout/bycopy/byref/oneway/nullability
Record.push_back(D->getObjCDeclQualifier());
Record.push_back(D->hasRelatedResultType());
- Writer.AddTypeRef(D->getReturnType(), Record);
- Writer.AddTypeSourceInfo(D->getReturnTypeSourceInfo(), Record);
- Writer.AddSourceLocation(D->getLocEnd(), Record);
+ Record.AddTypeRef(D->getReturnType());
+ Record.AddTypeSourceInfo(D->getReturnTypeSourceInfo());
+ Record.AddSourceLocation(D->getLocEnd());
Record.push_back(D->param_size());
- for (const auto *P : D->params())
- Writer.AddDeclRef(P, Record);
+ for (const auto *P : D->parameters())
+ Record.AddDeclRef(P);
Record.push_back(D->SelLocsKind);
unsigned NumStoredSelLocs = D->getNumStoredSelLocs();
SourceLocation *SelLocs = D->getStoredSelLocs();
Record.push_back(NumStoredSelLocs);
for (unsigned i = 0; i != NumStoredSelLocs; ++i)
- Writer.AddSourceLocation(SelLocs[i], Record);
+ Record.AddSourceLocation(SelLocs[i]);
Code = serialization::DECL_OBJC_METHOD;
}
@@ -631,23 +655,23 @@ void ASTDeclWriter::VisitObjCTypeParamDecl(ObjCTypeParamDecl *D) {
VisitTypedefNameDecl(D);
Record.push_back(D->Variance);
Record.push_back(D->Index);
- Writer.AddSourceLocation(D->VarianceLoc, Record);
- Writer.AddSourceLocation(D->ColonLoc, Record);
+ Record.AddSourceLocation(D->VarianceLoc);
+ Record.AddSourceLocation(D->ColonLoc);
Code = serialization::DECL_OBJC_TYPE_PARAM;
}
void ASTDeclWriter::VisitObjCContainerDecl(ObjCContainerDecl *D) {
VisitNamedDecl(D);
- Writer.AddSourceLocation(D->getAtStartLoc(), Record);
- Writer.AddSourceRange(D->getAtEndRange(), Record);
+ Record.AddSourceLocation(D->getAtStartLoc());
+ Record.AddSourceRange(D->getAtEndRange());
// Abstract class (no need to define a stable serialization::DECL code).
}
void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
VisitRedeclarable(D);
VisitObjCContainerDecl(D);
- Writer.AddTypeRef(QualType(D->getTypeForDecl(), 0), Record);
+ Record.AddTypeRef(QualType(D->getTypeForDecl(), 0));
AddObjCTypeParamList(D->TypeParamList);
Record.push_back(D->isThisDeclarationADefinition());
@@ -655,16 +679,16 @@ void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
// Write the DefinitionData
ObjCInterfaceDecl::DefinitionData &Data = D->data();
- Writer.AddTypeSourceInfo(D->getSuperClassTInfo(), Record);
- Writer.AddSourceLocation(D->getEndOfDefinitionLoc(), Record);
+ Record.AddTypeSourceInfo(D->getSuperClassTInfo());
+ Record.AddSourceLocation(D->getEndOfDefinitionLoc());
Record.push_back(Data.HasDesignatedInitializers);
// Write out the protocols that are directly referenced by the @interface.
Record.push_back(Data.ReferencedProtocols.size());
for (const auto *P : D->protocols())
- Writer.AddDeclRef(P, Record);
+ Record.AddDeclRef(P);
for (const auto &PL : D->protocol_locs())
- Writer.AddSourceLocation(PL, Record);
+ Record.AddSourceLocation(PL);
// Write out the protocols that are transitively referenced.
Record.push_back(Data.AllReferencedProtocols.size());
@@ -672,7 +696,7 @@ void ASTDeclWriter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
P = Data.AllReferencedProtocols.begin(),
PEnd = Data.AllReferencedProtocols.end();
P != PEnd; ++P)
- Writer.AddDeclRef(*P, Record);
+ Record.AddDeclRef(*P);
if (ObjCCategoryDecl *Cat = D->getCategoryListRaw()) {
@@ -717,9 +741,9 @@ void ASTDeclWriter::VisitObjCProtocolDecl(ObjCProtocolDecl *D) {
if (D->isThisDeclarationADefinition()) {
Record.push_back(D->protocol_size());
for (const auto *I : D->protocols())
- Writer.AddDeclRef(I, Record);
+ Record.AddDeclRef(I);
for (const auto &PL : D->protocol_locs())
- Writer.AddSourceLocation(PL, Record);
+ Record.AddSourceLocation(PL);
}
Code = serialization::DECL_OBJC_PROTOCOL;
@@ -732,80 +756,80 @@ void ASTDeclWriter::VisitObjCAtDefsFieldDecl(ObjCAtDefsFieldDecl *D) {
void ASTDeclWriter::VisitObjCCategoryDecl(ObjCCategoryDecl *D) {
VisitObjCContainerDecl(D);
- Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);
- Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);
- Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);
- Writer.AddDeclRef(D->getClassInterface(), Record);
+ Record.AddSourceLocation(D->getCategoryNameLoc());
+ Record.AddSourceLocation(D->getIvarLBraceLoc());
+ Record.AddSourceLocation(D->getIvarRBraceLoc());
+ Record.AddDeclRef(D->getClassInterface());
AddObjCTypeParamList(D->TypeParamList);
Record.push_back(D->protocol_size());
for (const auto *I : D->protocols())
- Writer.AddDeclRef(I, Record);
+ Record.AddDeclRef(I);
for (const auto &PL : D->protocol_locs())
- Writer.AddSourceLocation(PL, Record);
+ Record.AddSourceLocation(PL);
Code = serialization::DECL_OBJC_CATEGORY;
}
void ASTDeclWriter::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *D) {
VisitNamedDecl(D);
- Writer.AddDeclRef(D->getClassInterface(), Record);
+ Record.AddDeclRef(D->getClassInterface());
Code = serialization::DECL_OBJC_COMPATIBLE_ALIAS;
}
void ASTDeclWriter::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
VisitNamedDecl(D);
- Writer.AddSourceLocation(D->getAtLoc(), Record);
- Writer.AddSourceLocation(D->getLParenLoc(), Record);
- Writer.AddTypeRef(D->getType(), Record);
- Writer.AddTypeSourceInfo(D->getTypeSourceInfo(), Record);
+ Record.AddSourceLocation(D->getAtLoc());
+ Record.AddSourceLocation(D->getLParenLoc());
+ Record.AddTypeRef(D->getType());
+ Record.AddTypeSourceInfo(D->getTypeSourceInfo());
// FIXME: stable encoding
Record.push_back((unsigned)D->getPropertyAttributes());
Record.push_back((unsigned)D->getPropertyAttributesAsWritten());
// FIXME: stable encoding
Record.push_back((unsigned)D->getPropertyImplementation());
- Writer.AddDeclarationName(D->getGetterName(), Record);
- Writer.AddDeclarationName(D->getSetterName(), Record);
- Writer.AddDeclRef(D->getGetterMethodDecl(), Record);
- Writer.AddDeclRef(D->getSetterMethodDecl(), Record);
- Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);
+ Record.AddDeclarationName(D->getGetterName());
+ Record.AddDeclarationName(D->getSetterName());
+ Record.AddDeclRef(D->getGetterMethodDecl());
+ Record.AddDeclRef(D->getSetterMethodDecl());
+ Record.AddDeclRef(D->getPropertyIvarDecl());
Code = serialization::DECL_OBJC_PROPERTY;
}
void ASTDeclWriter::VisitObjCImplDecl(ObjCImplDecl *D) {
VisitObjCContainerDecl(D);
- Writer.AddDeclRef(D->getClassInterface(), Record);
+ Record.AddDeclRef(D->getClassInterface());
// Abstract class (no need to define a stable serialization::DECL code).
}
void ASTDeclWriter::VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
VisitObjCImplDecl(D);
- Writer.AddIdentifierRef(D->getIdentifier(), Record);
- Writer.AddSourceLocation(D->getCategoryNameLoc(), Record);
+ Record.AddIdentifierRef(D->getIdentifier());
+ Record.AddSourceLocation(D->getCategoryNameLoc());
Code = serialization::DECL_OBJC_CATEGORY_IMPL;
}
void ASTDeclWriter::VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
VisitObjCImplDecl(D);
- Writer.AddDeclRef(D->getSuperClass(), Record);
- Writer.AddSourceLocation(D->getSuperClassLoc(), Record);
- Writer.AddSourceLocation(D->getIvarLBraceLoc(), Record);
- Writer.AddSourceLocation(D->getIvarRBraceLoc(), Record);
+ Record.AddDeclRef(D->getSuperClass());
+ Record.AddSourceLocation(D->getSuperClassLoc());
+ Record.AddSourceLocation(D->getIvarLBraceLoc());
+ Record.AddSourceLocation(D->getIvarRBraceLoc());
Record.push_back(D->hasNonZeroConstructors());
Record.push_back(D->hasDestructors());
Record.push_back(D->NumIvarInitializers);
if (D->NumIvarInitializers)
- Writer.AddCXXCtorInitializersRef(
- llvm::makeArrayRef(D->init_begin(), D->init_end()), Record);
+ Record.AddCXXCtorInitializers(
+ llvm::makeArrayRef(D->init_begin(), D->init_end()));
Code = serialization::DECL_OBJC_IMPLEMENTATION;
}
void ASTDeclWriter::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) {
VisitDecl(D);
- Writer.AddSourceLocation(D->getLocStart(), Record);
- Writer.AddDeclRef(D->getPropertyDecl(), Record);
- Writer.AddDeclRef(D->getPropertyIvarDecl(), Record);
- Writer.AddSourceLocation(D->getPropertyIvarDeclLoc(), Record);
- Writer.AddStmt(D->getGetterCXXConstructor());
- Writer.AddStmt(D->getSetterCXXAssignment());
+ Record.AddSourceLocation(D->getLocStart());
+ Record.AddDeclRef(D->getPropertyDecl());
+ Record.AddDeclRef(D->getPropertyIvarDecl());
+ Record.AddSourceLocation(D->getPropertyIvarDeclLoc());
+ Record.AddStmt(D->getGetterCXXConstructor());
+ Record.AddStmt(D->getSetterCXXAssignment());
Code = serialization::DECL_OBJC_PROPERTY_IMPL;
}
@@ -817,15 +841,14 @@ void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
Record.push_back(0);
} else if (D->InitStorage.getInt() == FieldDecl::ISK_CapturedVLAType) {
Record.push_back(D->InitStorage.getInt() + 1);
- Writer.AddTypeRef(
- QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0),
- Record);
+ Record.AddTypeRef(
+ QualType(static_cast<Type *>(D->InitStorage.getPointer()), 0));
} else {
Record.push_back(D->InitStorage.getInt() + 1);
- Writer.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
+ Record.AddStmt(static_cast<Expr *>(D->InitStorage.getPointer()));
}
if (!D->getDeclName())
- Writer.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D), Record);
+ Record.AddDeclRef(Context.getInstantiatedFromUnnamedFieldDecl(D));
if (D->getDeclContext() == D->getLexicalDeclContext() &&
!D->hasAttrs() &&
@@ -848,8 +871,8 @@ void ASTDeclWriter::VisitFieldDecl(FieldDecl *D) {
void ASTDeclWriter::VisitMSPropertyDecl(MSPropertyDecl *D) {
VisitDeclaratorDecl(D);
- Writer.AddIdentifierRef(D->getGetterId(), Record);
- Writer.AddIdentifierRef(D->getSetterId(), Record);
+ Record.AddIdentifierRef(D->getGetterId());
+ Record.AddIdentifierRef(D->getSetterId());
Code = serialization::DECL_MS_PROPERTY;
}
@@ -858,7 +881,7 @@ void ASTDeclWriter::VisitIndirectFieldDecl(IndirectFieldDecl *D) {
Record.push_back(D->getChainingSize());
for (const auto *P : D->chain())
- Writer.AddDeclRef(P, Record);
+ Record.AddDeclRef(P);
Code = serialization::DECL_INDIRECTFIELD;
}
@@ -873,6 +896,8 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
Record.push_back(D->isNRVOVariable());
Record.push_back(D->isCXXForRangeDecl());
Record.push_back(D->isARCPseudoStrong());
+ Record.push_back(D->isInline());
+ Record.push_back(D->isInlineSpecified());
Record.push_back(D->isConstexpr());
Record.push_back(D->isInitCapture());
Record.push_back(D->isPreviousDeclInSameBlockScope());
@@ -881,7 +906,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
if (D->getInit()) {
Record.push_back(!D->isInitKnownICE() ? 1 : (D->isInitICE() ? 3 : 2));
- Writer.AddStmt(D->getInit());
+ Record.AddStmt(D->getInit());
} else {
Record.push_back(0);
}
@@ -891,13 +916,13 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
};
if (VarTemplateDecl *TemplD = D->getDescribedVarTemplate()) {
Record.push_back(VarTemplate);
- Writer.AddDeclRef(TemplD, Record);
+ Record.AddDeclRef(TemplD);
} else if (MemberSpecializationInfo *SpecInfo
= D->getMemberSpecializationInfo()) {
Record.push_back(StaticDataMemberSpecialization);
- Writer.AddDeclRef(SpecInfo->getInstantiatedFrom(), Record);
+ Record.AddDeclRef(SpecInfo->getInstantiatedFrom());
Record.push_back(SpecInfo->getTemplateSpecializationKind());
- Writer.AddSourceLocation(SpecInfo->getPointOfInstantiation(), Record);
+ Record.AddSourceLocation(SpecInfo->getPointOfInstantiation());
} else {
Record.push_back(VarNotTemplate);
}
@@ -919,6 +944,7 @@ void ASTDeclWriter::VisitVarDecl(VarDecl *D) {
D->getInit() == nullptr &&
!isa<ParmVarDecl>(D) &&
!isa<VarTemplateSpecializationDecl>(D) &&
+ !D->isInline() &&
!D->isConstexpr() &&
!D->isInitCapture() &&
!D->isPreviousDeclInSameBlockScope() &&
@@ -943,7 +969,7 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
Record.push_back(D->hasInheritedDefaultArg());
Record.push_back(D->hasUninstantiatedDefaultArg());
if (D->hasUninstantiatedDefaultArg())
- Writer.AddStmt(D->getUninstantiatedDefaultArg());
+ Record.AddStmt(D->getUninstantiatedDefaultArg());
Code = serialization::DECL_PARM_VAR;
assert(!D->isARCPseudoStrong()); // can be true of ImplicitParamDecl
@@ -982,8 +1008,8 @@ void ASTDeclWriter::VisitParmVarDecl(ParmVarDecl *D) {
void ASTDeclWriter::VisitFileScopeAsmDecl(FileScopeAsmDecl *D) {
VisitDecl(D);
- Writer.AddStmt(D->getAsmString());
- Writer.AddSourceLocation(D->getRParenLoc(), Record);
+ Record.AddStmt(D->getAsmString());
+ Record.AddSourceLocation(D->getRParenLoc());
Code = serialization::DECL_FILE_SCOPE_ASM;
}
@@ -994,19 +1020,18 @@ void ASTDeclWriter::VisitEmptyDecl(EmptyDecl *D) {
void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) {
VisitDecl(D);
- Writer.AddStmt(D->getBody());
- Writer.AddTypeSourceInfo(D->getSignatureAsWritten(), Record);
+ Record.AddStmt(D->getBody());
+ Record.AddTypeSourceInfo(D->getSignatureAsWritten());
Record.push_back(D->param_size());
- for (FunctionDecl::param_iterator P = D->param_begin(), PEnd = D->param_end();
- P != PEnd; ++P)
- Writer.AddDeclRef(*P, Record);
+ for (ParmVarDecl *P : D->parameters())
+ Record.AddDeclRef(P);
Record.push_back(D->isVariadic());
Record.push_back(D->blockMissingReturnType());
Record.push_back(D->isConversionFromLambda());
Record.push_back(D->capturesCXXThis());
Record.push_back(D->getNumCaptures());
for (const auto &capture : D->captures()) {
- Writer.AddDeclRef(capture.getVariable(), Record);
+ Record.AddDeclRef(capture.getVariable());
unsigned flags = 0;
if (capture.isByRef()) flags |= 1;
@@ -1014,7 +1039,7 @@ void ASTDeclWriter::VisitBlockDecl(BlockDecl *D) {
if (capture.hasCopyExpr()) flags |= 4;
Record.push_back(flags);
- if (capture.hasCopyExpr()) Writer.AddStmt(capture.getCopyExpr());
+ if (capture.hasCopyExpr()) Record.AddStmt(capture.getCopyExpr());
}
Code = serialization::DECL_BLOCK;
@@ -1027,21 +1052,21 @@ void ASTDeclWriter::VisitCapturedDecl(CapturedDecl *CD) {
Record.push_back(CD->isNothrow() ? 1 : 0);
// Body is stored by VisitCapturedStmt.
for (unsigned I = 0; I < CD->getNumParams(); ++I)
- Writer.AddDeclRef(CD->getParam(I), Record);
+ Record.AddDeclRef(CD->getParam(I));
Code = serialization::DECL_CAPTURED;
}
void ASTDeclWriter::VisitLinkageSpecDecl(LinkageSpecDecl *D) {
VisitDecl(D);
Record.push_back(D->getLanguage());
- Writer.AddSourceLocation(D->getExternLoc(), Record);
- Writer.AddSourceLocation(D->getRBraceLoc(), Record);
+ Record.AddSourceLocation(D->getExternLoc());
+ Record.AddSourceLocation(D->getRBraceLoc());
Code = serialization::DECL_LINKAGE_SPEC;
}
void ASTDeclWriter::VisitLabelDecl(LabelDecl *D) {
VisitNamedDecl(D);
- Writer.AddSourceLocation(D->getLocStart(), Record);
+ Record.AddSourceLocation(D->getLocStart());
Code = serialization::DECL_LABEL;
}
@@ -1050,11 +1075,11 @@ void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) {
VisitRedeclarable(D);
VisitNamedDecl(D);
Record.push_back(D->isInline());
- Writer.AddSourceLocation(D->getLocStart(), Record);
- Writer.AddSourceLocation(D->getRBraceLoc(), Record);
+ Record.AddSourceLocation(D->getLocStart());
+ Record.AddSourceLocation(D->getRBraceLoc());
if (D->isOriginalNamespace())
- Writer.AddDeclRef(D->getAnonymousNamespace(), Record);
+ Record.AddDeclRef(D->getAnonymousNamespace());
Code = serialization::DECL_NAMESPACE;
if (Writer.hasChain() && D->isAnonymousNamespace() &&
@@ -1075,56 +1100,65 @@ void ASTDeclWriter::VisitNamespaceDecl(NamespaceDecl *D) {
void ASTDeclWriter::VisitNamespaceAliasDecl(NamespaceAliasDecl *D) {
VisitRedeclarable(D);
VisitNamedDecl(D);
- Writer.AddSourceLocation(D->getNamespaceLoc(), Record);
- Writer.AddSourceLocation(D->getTargetNameLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
- Writer.AddDeclRef(D->getNamespace(), Record);
+ Record.AddSourceLocation(D->getNamespaceLoc());
+ Record.AddSourceLocation(D->getTargetNameLoc());
+ Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
+ Record.AddDeclRef(D->getNamespace());
Code = serialization::DECL_NAMESPACE_ALIAS;
}
void ASTDeclWriter::VisitUsingDecl(UsingDecl *D) {
VisitNamedDecl(D);
- Writer.AddSourceLocation(D->getUsingLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
- Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
- Writer.AddDeclRef(D->FirstUsingShadow.getPointer(), Record);
+ Record.AddSourceLocation(D->getUsingLoc());
+ Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
+ Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
+ Record.AddDeclRef(D->FirstUsingShadow.getPointer());
Record.push_back(D->hasTypename());
- Writer.AddDeclRef(Context.getInstantiatedFromUsingDecl(D), Record);
+ Record.AddDeclRef(Context.getInstantiatedFromUsingDecl(D));
Code = serialization::DECL_USING;
}
void ASTDeclWriter::VisitUsingShadowDecl(UsingShadowDecl *D) {
VisitRedeclarable(D);
VisitNamedDecl(D);
- Writer.AddDeclRef(D->getTargetDecl(), Record);
- Writer.AddDeclRef(D->UsingOrNextShadow, Record);
- Writer.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D), Record);
+ Record.AddDeclRef(D->getTargetDecl());
+ Record.AddDeclRef(D->UsingOrNextShadow);
+ Record.AddDeclRef(Context.getInstantiatedFromUsingShadowDecl(D));
Code = serialization::DECL_USING_SHADOW;
}
+void ASTDeclWriter::VisitConstructorUsingShadowDecl(
+ ConstructorUsingShadowDecl *D) {
+ VisitUsingShadowDecl(D);
+ Record.AddDeclRef(D->NominatedBaseClassShadowDecl);
+ Record.AddDeclRef(D->ConstructedBaseClassShadowDecl);
+ Record.push_back(D->IsVirtual);
+ Code = serialization::DECL_CONSTRUCTOR_USING_SHADOW;
+}
+
void ASTDeclWriter::VisitUsingDirectiveDecl(UsingDirectiveDecl *D) {
VisitNamedDecl(D);
- Writer.AddSourceLocation(D->getUsingLoc(), Record);
- Writer.AddSourceLocation(D->getNamespaceKeyLocation(), Record);
- Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
- Writer.AddDeclRef(D->getNominatedNamespace(), Record);
- Writer.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()), Record);
+ Record.AddSourceLocation(D->getUsingLoc());
+ Record.AddSourceLocation(D->getNamespaceKeyLocation());
+ Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
+ Record.AddDeclRef(D->getNominatedNamespace());
+ Record.AddDeclRef(dyn_cast<Decl>(D->getCommonAncestor()));
Code = serialization::DECL_USING_DIRECTIVE;
}
void ASTDeclWriter::VisitUnresolvedUsingValueDecl(UnresolvedUsingValueDecl *D) {
VisitValueDecl(D);
- Writer.AddSourceLocation(D->getUsingLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
- Writer.AddDeclarationNameLoc(D->DNLoc, D->getDeclName(), Record);
+ Record.AddSourceLocation(D->getUsingLoc());
+ Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
+ Record.AddDeclarationNameLoc(D->DNLoc, D->getDeclName());
Code = serialization::DECL_UNRESOLVED_USING_VALUE;
}
void ASTDeclWriter::VisitUnresolvedUsingTypenameDecl(
UnresolvedUsingTypenameDecl *D) {
VisitTypeDecl(D);
- Writer.AddSourceLocation(D->getTypenameLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(D->getQualifierLoc(), Record);
+ Record.AddSourceLocation(D->getTypenameLoc());
+ Record.AddNestedNameSpecifierLoc(D->getQualifierLoc());
Code = serialization::DECL_UNRESOLVED_USING_TYPENAME;
}
@@ -1136,25 +1170,25 @@ void ASTDeclWriter::VisitCXXRecordDecl(CXXRecordDecl *D) {
};
if (ClassTemplateDecl *TemplD = D->getDescribedClassTemplate()) {
Record.push_back(CXXRecTemplate);
- Writer.AddDeclRef(TemplD, Record);
+ Record.AddDeclRef(TemplD);
} else if (MemberSpecializationInfo *MSInfo
= D->getMemberSpecializationInfo()) {
Record.push_back(CXXRecMemberSpecialization);
- Writer.AddDeclRef(MSInfo->getInstantiatedFrom(), Record);
+ Record.AddDeclRef(MSInfo->getInstantiatedFrom());
Record.push_back(MSInfo->getTemplateSpecializationKind());
- Writer.AddSourceLocation(MSInfo->getPointOfInstantiation(), Record);
+ Record.AddSourceLocation(MSInfo->getPointOfInstantiation());
} else {
Record.push_back(CXXRecNotTemplate);
}
Record.push_back(D->isThisDeclarationADefinition());
if (D->isThisDeclarationADefinition())
- Writer.AddCXXDefinitionData(D, Record);
+ Record.AddCXXDefinitionData(D);
// Store (what we currently believe to be) the key function to avoid
// deserializing every method so we can compute it.
if (D->IsCompleteDefinition)
- Writer.AddDeclRef(Context.getCurrentKeyFunction(D), Record);
+ Record.AddDeclRef(Context.getCurrentKeyFunction(D));
Code = serialization::DECL_CXX_RECORD;
}
@@ -1166,7 +1200,7 @@ void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
for (CXXMethodDecl::method_iterator
I = D->begin_overridden_methods(), E = D->end_overridden_methods();
I != E; ++I)
- Writer.AddDeclRef(*I, Record);
+ Record.AddDeclRef(*I);
} else {
// We only need to record overridden methods once for the canonical decl.
Record.push_back(0);
@@ -1187,18 +1221,27 @@ void ASTDeclWriter::VisitCXXMethodDecl(CXXMethodDecl *D) {
}
void ASTDeclWriter::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
+ if (auto Inherited = D->getInheritedConstructor()) {
+ Record.AddDeclRef(Inherited.getShadowDecl());
+ Record.AddDeclRef(Inherited.getConstructor());
+ Code = serialization::DECL_CXX_INHERITED_CONSTRUCTOR;
+ } else {
+ Code = serialization::DECL_CXX_CONSTRUCTOR;
+ }
+
VisitCXXMethodDecl(D);
- Writer.AddDeclRef(D->getInheritedConstructor(), Record);
Record.push_back(D->IsExplicitSpecified);
- Code = serialization::DECL_CXX_CONSTRUCTOR;
+ Code = D->isInheritingConstructor()
+ ? serialization::DECL_CXX_INHERITED_CONSTRUCTOR
+ : serialization::DECL_CXX_CONSTRUCTOR;
}
void ASTDeclWriter::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
VisitCXXMethodDecl(D);
- Writer.AddDeclRef(D->getOperatorDelete(), Record);
+ Record.AddDeclRef(D->getOperatorDelete());
Code = serialization::DECL_CXX_DESTRUCTOR;
}
@@ -1215,11 +1258,11 @@ void ASTDeclWriter::VisitImportDecl(ImportDecl *D) {
ArrayRef<SourceLocation> IdentifierLocs = D->getIdentifierLocs();
Record.push_back(!IdentifierLocs.empty());
if (IdentifierLocs.empty()) {
- Writer.AddSourceLocation(D->getLocEnd(), Record);
+ Record.AddSourceLocation(D->getLocEnd());
Record.push_back(1);
} else {
for (unsigned I = 0, N = IdentifierLocs.size(); I != N; ++I)
- Writer.AddSourceLocation(IdentifierLocs[I], Record);
+ Record.AddSourceLocation(IdentifierLocs[I]);
Record.push_back(IdentifierLocs.size());
}
// Note: the number of source locations must always be the last element in
@@ -1229,7 +1272,7 @@ void ASTDeclWriter::VisitImportDecl(ImportDecl *D) {
void ASTDeclWriter::VisitAccessSpecDecl(AccessSpecDecl *D) {
VisitDecl(D);
- Writer.AddSourceLocation(D->getColonLoc(), Record);
+ Record.AddSourceLocation(D->getColonLoc());
Code = serialization::DECL_ACCESS_SPEC;
}
@@ -1241,15 +1284,14 @@ void ASTDeclWriter::VisitFriendDecl(FriendDecl *D) {
bool hasFriendDecl = D->Friend.is<NamedDecl*>();
Record.push_back(hasFriendDecl);
if (hasFriendDecl)
- Writer.AddDeclRef(D->getFriendDecl(), Record);
+ Record.AddDeclRef(D->getFriendDecl());
else
- Writer.AddTypeSourceInfo(D->getFriendType(), Record);
+ Record.AddTypeSourceInfo(D->getFriendType());
for (unsigned i = 0; i < D->NumTPLists; ++i)
- Writer.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i),
- Record);
- Writer.AddDeclRef(D->getNextFriend(), Record);
+ Record.AddTemplateParameterList(D->getFriendTypeTemplateParameterList(i));
+ Record.AddDeclRef(D->getNextFriend());
Record.push_back(D->UnsupportedFriend);
- Writer.AddSourceLocation(D->FriendLoc, Record);
+ Record.AddSourceLocation(D->FriendLoc);
Code = serialization::DECL_FRIEND;
}
@@ -1257,21 +1299,21 @@ void ASTDeclWriter::VisitFriendTemplateDecl(FriendTemplateDecl *D) {
VisitDecl(D);
Record.push_back(D->getNumTemplateParameters());
for (unsigned i = 0, e = D->getNumTemplateParameters(); i != e; ++i)
- Writer.AddTemplateParameterList(D->getTemplateParameterList(i), Record);
+ Record.AddTemplateParameterList(D->getTemplateParameterList(i));
Record.push_back(D->getFriendDecl() != nullptr);
if (D->getFriendDecl())
- Writer.AddDeclRef(D->getFriendDecl(), Record);
+ Record.AddDeclRef(D->getFriendDecl());
else
- Writer.AddTypeSourceInfo(D->getFriendType(), Record);
- Writer.AddSourceLocation(D->getFriendLoc(), Record);
+ Record.AddTypeSourceInfo(D->getFriendType());
+ Record.AddSourceLocation(D->getFriendLoc());
Code = serialization::DECL_FRIEND_TEMPLATE;
}
void ASTDeclWriter::VisitTemplateDecl(TemplateDecl *D) {
VisitNamedDecl(D);
- Writer.AddDeclRef(D->getTemplatedDecl(), Record);
- Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
+ Record.AddDeclRef(D->getTemplatedDecl());
+ Record.AddTemplateParameterList(D->getTemplateParameters());
}
void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
@@ -1281,7 +1323,7 @@ void ASTDeclWriter::VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D) {
// getCommonPtr() can be used while this is still initializing.
if (D->isFirstDecl()) {
// This declaration owns the 'common' pointer, so serialize that data now.
- Writer.AddDeclRef(D->getInstantiatedFromMemberTemplate(), Record);
+ Record.AddDeclRef(D->getInstantiatedFromMemberTemplate());
if (D->getInstantiatedFromMemberTemplate())
Record.push_back(D->isMemberSpecialization());
}
@@ -1308,28 +1350,27 @@ void ASTDeclWriter::VisitClassTemplateSpecializationDecl(
ClassTemplatePartialSpecializationDecl *> InstFrom
= D->getSpecializedTemplateOrPartial();
if (Decl *InstFromD = InstFrom.dyn_cast<ClassTemplateDecl *>()) {
- Writer.AddDeclRef(InstFromD, Record);
+ Record.AddDeclRef(InstFromD);
} else {
- Writer.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>(),
- Record);
- Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);
+ Record.AddDeclRef(InstFrom.get<ClassTemplatePartialSpecializationDecl *>());
+ Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
}
- Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);
- Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
+ Record.AddTemplateArgumentList(&D->getTemplateArgs());
+ Record.AddSourceLocation(D->getPointOfInstantiation());
Record.push_back(D->getSpecializationKind());
Record.push_back(D->isCanonicalDecl());
if (D->isCanonicalDecl()) {
// When reading, we'll add it to the folding set of the following template.
- Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);
+ Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
}
// Explicit info.
- Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);
+ Record.AddTypeSourceInfo(D->getTypeAsWritten());
if (D->getTypeAsWritten()) {
- Writer.AddSourceLocation(D->getExternLoc(), Record);
- Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);
+ Record.AddSourceLocation(D->getExternLoc());
+ Record.AddSourceLocation(D->getTemplateKeywordLoc());
}
Code = serialization::DECL_CLASS_TEMPLATE_SPECIALIZATION;
@@ -1339,12 +1380,12 @@ void ASTDeclWriter::VisitClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *D) {
VisitClassTemplateSpecializationDecl(D);
- Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
- Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
+ Record.AddTemplateParameterList(D->getTemplateParameters());
+ Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
// These are read/set from/to the first declaration.
if (D->getPreviousDecl() == nullptr) {
- Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
+ Record.AddDeclRef(D->getInstantiatedFromMember());
Record.push_back(D->isMemberSpecialization());
}
@@ -1368,28 +1409,27 @@ void ASTDeclWriter::VisitVarTemplateSpecializationDecl(
llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
InstFrom = D->getSpecializedTemplateOrPartial();
if (Decl *InstFromD = InstFrom.dyn_cast<VarTemplateDecl *>()) {
- Writer.AddDeclRef(InstFromD, Record);
+ Record.AddDeclRef(InstFromD);
} else {
- Writer.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>(),
- Record);
- Writer.AddTemplateArgumentList(&D->getTemplateInstantiationArgs(), Record);
+ Record.AddDeclRef(InstFrom.get<VarTemplatePartialSpecializationDecl *>());
+ Record.AddTemplateArgumentList(&D->getTemplateInstantiationArgs());
}
// Explicit info.
- Writer.AddTypeSourceInfo(D->getTypeAsWritten(), Record);
+ Record.AddTypeSourceInfo(D->getTypeAsWritten());
if (D->getTypeAsWritten()) {
- Writer.AddSourceLocation(D->getExternLoc(), Record);
- Writer.AddSourceLocation(D->getTemplateKeywordLoc(), Record);
+ Record.AddSourceLocation(D->getExternLoc());
+ Record.AddSourceLocation(D->getTemplateKeywordLoc());
}
- Writer.AddTemplateArgumentList(&D->getTemplateArgs(), Record);
- Writer.AddSourceLocation(D->getPointOfInstantiation(), Record);
+ Record.AddTemplateArgumentList(&D->getTemplateArgs());
+ Record.AddSourceLocation(D->getPointOfInstantiation());
Record.push_back(D->getSpecializationKind());
Record.push_back(D->isCanonicalDecl());
if (D->isCanonicalDecl()) {
// When reading, we'll add it to the folding set of the following template.
- Writer.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl(), Record);
+ Record.AddDeclRef(D->getSpecializedTemplate()->getCanonicalDecl());
}
Code = serialization::DECL_VAR_TEMPLATE_SPECIALIZATION;
@@ -1399,12 +1439,12 @@ void ASTDeclWriter::VisitVarTemplatePartialSpecializationDecl(
VarTemplatePartialSpecializationDecl *D) {
VisitVarTemplateSpecializationDecl(D);
- Writer.AddTemplateParameterList(D->getTemplateParameters(), Record);
- Writer.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten(), Record);
+ Record.AddTemplateParameterList(D->getTemplateParameters());
+ Record.AddASTTemplateArgumentListInfo(D->getTemplateArgsAsWritten());
// These are read/set from/to the first declaration.
if (D->getPreviousDecl() == nullptr) {
- Writer.AddDeclRef(D->getInstantiatedFromMember(), Record);
+ Record.AddDeclRef(D->getInstantiatedFromMember());
Record.push_back(D->isMemberSpecialization());
}
@@ -1414,7 +1454,7 @@ void ASTDeclWriter::VisitVarTemplatePartialSpecializationDecl(
void ASTDeclWriter::VisitClassScopeFunctionSpecializationDecl(
ClassScopeFunctionSpecializationDecl *D) {
VisitDecl(D);
- Writer.AddDeclRef(D->getSpecialization(), Record);
+ Record.AddDeclRef(D->getSpecialization());
Code = serialization::DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION;
}
@@ -1436,7 +1476,7 @@ void ASTDeclWriter::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
!D->defaultArgumentWasInherited();
Record.push_back(OwnsDefaultArg);
if (OwnsDefaultArg)
- Writer.AddTypeSourceInfo(D->getDefaultArgumentInfo(), Record);
+ Record.AddTypeSourceInfo(D->getDefaultArgumentInfo());
Code = serialization::DECL_TEMPLATE_TYPE_PARM;
}
@@ -1455,8 +1495,8 @@ void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
if (D->isExpandedParameterPack()) {
for (unsigned I = 0, N = D->getNumExpansionTypes(); I != N; ++I) {
- Writer.AddTypeRef(D->getExpansionType(I), Record);
- Writer.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I), Record);
+ Record.AddTypeRef(D->getExpansionType(I));
+ Record.AddTypeSourceInfo(D->getExpansionTypeSourceInfo(I));
}
Code = serialization::DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK;
@@ -1467,7 +1507,7 @@ void ASTDeclWriter::VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
!D->defaultArgumentWasInherited();
Record.push_back(OwnsDefaultArg);
if (OwnsDefaultArg)
- Writer.AddStmt(D->getDefaultArgument());
+ Record.AddStmt(D->getDefaultArgument());
Code = serialization::DECL_NON_TYPE_TEMPLATE_PARM;
}
}
@@ -1487,8 +1527,7 @@ void ASTDeclWriter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
if (D->isExpandedParameterPack()) {
for (unsigned I = 0, N = D->getNumExpansionTemplateParameters();
I != N; ++I)
- Writer.AddTemplateParameterList(D->getExpansionTemplateParameters(I),
- Record);
+ Record.AddTemplateParameterList(D->getExpansionTemplateParameters(I));
Code = serialization::DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK;
} else {
// Rest of TemplateTemplateParmDecl.
@@ -1497,7 +1536,7 @@ void ASTDeclWriter::VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
!D->defaultArgumentWasInherited();
Record.push_back(OwnsDefaultArg);
if (OwnsDefaultArg)
- Writer.AddTemplateArgumentLoc(D->getDefaultArgument(), Record);
+ Record.AddTemplateArgumentLoc(D->getDefaultArgument());
Code = serialization::DECL_TEMPLATE_TEMPLATE_PARM;
}
}
@@ -1509,41 +1548,20 @@ void ASTDeclWriter::VisitTypeAliasTemplateDecl(TypeAliasTemplateDecl *D) {
void ASTDeclWriter::VisitStaticAssertDecl(StaticAssertDecl *D) {
VisitDecl(D);
- Writer.AddStmt(D->getAssertExpr());
+ Record.AddStmt(D->getAssertExpr());
Record.push_back(D->isFailed());
- Writer.AddStmt(D->getMessage());
- Writer.AddSourceLocation(D->getRParenLoc(), Record);
+ Record.AddStmt(D->getMessage());
+ Record.AddSourceLocation(D->getRParenLoc());
Code = serialization::DECL_STATIC_ASSERT;
}
/// \brief Emit the DeclContext part of a declaration context decl.
-///
-/// \param LexicalOffset the offset at which the DECL_CONTEXT_LEXICAL
-/// block for this declaration context is stored. May be 0 to indicate
-/// that there are no declarations stored within this context.
-///
-/// \param VisibleOffset the offset at which the DECL_CONTEXT_VISIBLE
-/// block for this declaration context is stored. May be 0 to indicate
-/// that there are no declarations visible from this context. Note
-/// that this value will not be emitted for non-primary declaration
-/// contexts.
-void ASTDeclWriter::VisitDeclContext(DeclContext *DC, uint64_t LexicalOffset,
- uint64_t VisibleOffset) {
- Record.push_back(LexicalOffset);
- Record.push_back(VisibleOffset);
+void ASTDeclWriter::VisitDeclContext(DeclContext *DC) {
+ Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC));
+ Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC));
}
const Decl *ASTWriter::getFirstLocalDecl(const Decl *D) {
- /// \brief Is this a local declaration (that is, one that will be written to
- /// our AST file)? This is the case for declarations that are neither imported
- /// from another AST file nor predefined.
- auto IsLocalDecl = [&](const Decl *D) -> bool {
- if (D->isFromASTFile())
- return false;
- auto I = DeclIDs.find(D);
- return (I == DeclIDs.end() || I->second >= NUM_PREDEF_DECL_IDS);
- };
-
assert(IsLocalDecl(D) && "expected a local declaration");
const Decl *Canon = D->getCanonicalDecl();
@@ -1569,7 +1587,7 @@ void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) {
assert(isRedeclarableDeclKind(DAsT->getKind()) &&
"Not considered redeclarable?");
- Writer.AddDeclRef(First, Record);
+ Record.AddDeclRef(First);
// Write out a list of local redeclarations of this declaration if it's the
// first local declaration in the chain.
@@ -1587,23 +1605,22 @@ void ASTDeclWriter::VisitRedeclarable(Redeclarable<T> *D) {
// Collect the set of local redeclarations of this declaration, from
// newest to oldest.
- RecordData LocalRedecls;
+ ASTWriter::RecordData LocalRedecls;
+ ASTRecordWriter LocalRedeclWriter(Record, LocalRedecls);
for (const Decl *Prev = FirstLocal->getMostRecentDecl();
Prev != FirstLocal; Prev = Prev->getPreviousDecl())
if (!Prev->isFromASTFile())
- Writer.AddDeclRef(Prev, LocalRedecls);
+ LocalRedeclWriter.AddDeclRef(Prev);
// If we have any redecls, write them now as a separate record preceding
// the declaration itself.
if (LocalRedecls.empty())
Record.push_back(0);
- else {
- Record.push_back(Writer.Stream.GetCurrentBitNo());
- Writer.Stream.EmitRecord(LOCAL_REDECLARATIONS, LocalRedecls);
- }
+ else
+ Record.AddOffset(LocalRedeclWriter.Emit(LOCAL_REDECLARATIONS));
} else {
Record.push_back(0);
- Writer.AddDeclRef(FirstLocal, Record);
+ Record.AddDeclRef(FirstLocal);
}
// Make sure that we serialize both the previous and the most-recent
@@ -1624,10 +1641,24 @@ void ASTDeclWriter::VisitOMPThreadPrivateDecl(OMPThreadPrivateDecl *D) {
Record.push_back(D->varlist_size());
VisitDecl(D);
for (auto *I : D->varlists())
- Writer.AddStmt(I);
+ Record.AddStmt(I);
Code = serialization::DECL_OMP_THREADPRIVATE;
}
+void ASTDeclWriter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
+ VisitValueDecl(D);
+ Record.AddSourceLocation(D->getLocStart());
+ Record.AddStmt(D->getCombiner());
+ Record.AddStmt(D->getInitializer());
+ Record.AddDeclRef(D->getPrevDeclInScope());
+ Code = serialization::DECL_OMP_DECLARE_REDUCTION;
+}
+
+void ASTDeclWriter::VisitOMPCapturedExprDecl(OMPCapturedExprDecl *D) {
+ VisitVarDecl(D);
+ Code = serialization::DECL_OMP_CAPTUREDEXPR;
+}
+
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
@@ -1738,6 +1769,7 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
// EnumDecl
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // AddTypeRef
@@ -1786,6 +1818,7 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsFreeStanding
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // IsCompleteDefinitionRequired
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
+ Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // SourceLocation
Abv->Add(BitCodeAbbrevOp(0)); // ExtInfoKind
// RecordDecl
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // FlexibleArrayMember
@@ -1907,6 +1940,8 @@ void ASTWriter::WriteDeclAbbrevs() {
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isNRVOVariable
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isCXXForRangeDecl
Abv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // isARCPseudoStrong
+ Abv->Add(BitCodeAbbrevOp(0)); // isInline
+ Abv->Add(BitCodeAbbrevOp(0)); // isInlineSpecified
Abv->Add(BitCodeAbbrevOp(0)); // isConstexpr
Abv->Add(BitCodeAbbrevOp(0)); // isInitCapture
Abv->Add(BitCodeAbbrevOp(0)); // isPrevDeclInSameScope
@@ -2082,8 +2117,10 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context,
// An ObjCMethodDecl is never considered as "required" because its
// implementation container always is.
- // File scoped assembly or obj-c implementation must be seen.
- if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D))
+ // File scoped assembly or obj-c or OMP declare target implementation must be
+ // seen.
+ if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D) ||
+ D->hasAttr<OMPDeclareTargetDeclAttr>())
return true;
// ImportDecl is used by codegen to determine the set of imported modules to
@@ -2096,12 +2133,6 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context,
}
void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
- // Switch case IDs are per Decl.
- ClearSwitchCaseIDs();
-
- RecordData Record;
- ASTDeclWriter W(*this, Context, Record);
-
// Determine the ID for this declaration.
serialization::DeclID ID;
assert(!D->isFromASTFile() && "should not be emitting imported decl");
@@ -2111,66 +2142,34 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
ID = IDR;
- bool isReplacingADecl = ID < FirstDeclID;
-
- // If this declaration is also a DeclContext, write blocks for the
- // declarations that lexically stored inside its context and those
- // declarations that are visible from its context. These blocks
- // are written before the declaration itself so that we can put
- // their offsets into the record for the declaration.
- uint64_t LexicalOffset = 0;
- uint64_t VisibleOffset = 0;
- DeclContext *DC = dyn_cast<DeclContext>(D);
- if (DC) {
- if (isReplacingADecl) {
- // It is replacing a decl from a chained PCH; make sure that the
- // DeclContext is fully loaded.
- if (DC->hasExternalLexicalStorage())
- DC->LoadLexicalDeclsFromExternalStorage();
- if (DC->hasExternalVisibleStorage())
- Chain->completeVisibleDeclsMap(DC);
- }
- LexicalOffset = WriteDeclContextLexicalBlock(Context, DC);
- VisibleOffset = WriteDeclContextVisibleBlock(Context, DC);
- }
+ assert(ID >= FirstDeclID && "invalid decl ID");
+ RecordData Record;
+ ASTDeclWriter W(*this, Context, Record);
+
// Build a record for this declaration
- Record.clear();
- W.Code = (serialization::DeclCode)0;
- W.AbbrevToUse = 0;
W.Visit(D);
- if (DC) W.VisitDeclContext(DC, LexicalOffset, VisibleOffset);
- if (isReplacingADecl) {
- // We're replacing a decl in a previous file.
- ReplacedDecls.push_back(ReplacedDeclInfo(ID, Stream.GetCurrentBitNo(),
- D->getLocation()));
+ // Emit this declaration to the bitstream.
+ uint64_t Offset = W.Emit(D);
+
+ // Record the offset for this declaration
+ SourceLocation Loc = D->getLocation();
+ unsigned Index = ID - FirstDeclID;
+ if (DeclOffsets.size() == Index)
+ DeclOffsets.push_back(DeclOffset(Loc, Offset));
+ else if (DeclOffsets.size() < Index) {
+ // FIXME: Can/should this happen?
+ DeclOffsets.resize(Index+1);
+ DeclOffsets[Index].setLocation(Loc);
+ DeclOffsets[Index].BitOffset = Offset;
} else {
- unsigned Index = ID - FirstDeclID;
-
- // Record the offset for this declaration
- SourceLocation Loc = D->getLocation();
- if (DeclOffsets.size() == Index)
- DeclOffsets.push_back(DeclOffset(Loc, Stream.GetCurrentBitNo()));
- else if (DeclOffsets.size() < Index) {
- DeclOffsets.resize(Index+1);
- DeclOffsets[Index].setLocation(Loc);
- DeclOffsets[Index].BitOffset = Stream.GetCurrentBitNo();
- }
-
- SourceManager &SM = Context.getSourceManager();
- if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
- associateDeclWithFile(D, ID);
+ llvm_unreachable("declarations should be emitted in ID order");
}
- if (!W.Code)
- llvm::report_fatal_error(StringRef("unexpected declaration kind '") +
- D->getDeclKindName() + "'");
- Stream.EmitRecord(W.Code, Record, W.AbbrevToUse);
-
- // Flush any expressions, base specifiers, and ctor initializers that
- // were written as part of this declaration.
- FlushPendingAfterDecl();
+ SourceManager &SM = Context.getSourceManager();
+ if (Loc.isValid() && SM.isLocalSourceLocation(Loc))
+ associateDeclWithFile(D, ID);
// Note declarations that should be deserialized eagerly so that we can add
// them to a record in the AST file later.
@@ -2178,10 +2177,16 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) {
EagerlyDeserializedDecls.push_back(ID);
}
-void ASTWriter::AddFunctionDefinition(const FunctionDecl *FD,
- RecordData &Record) {
- ClearSwitchCaseIDs();
+void ASTRecordWriter::AddFunctionDefinition(const FunctionDecl *FD) {
+ // Switch case IDs are per function body.
+ Writer->ClearSwitchCaseIDs();
- ASTDeclWriter W(*this, FD->getASTContext(), Record);
- W.AddFunctionDefinition(FD);
+ assert(FD->doesThisDeclarationHaveABody());
+ if (auto *CD = dyn_cast<CXXConstructorDecl>(FD)) {
+ Record->push_back(CD->getNumCtorInitializers());
+ if (CD->getNumCtorInitializers())
+ AddCXXCtorInitializers(
+ llvm::makeArrayRef(CD->init_begin(), CD->init_end()));
+ }
+ AddStmt(FD->getBody());
}
diff --git a/lib/Serialization/ASTWriterStmt.cpp b/lib/Serialization/ASTWriterStmt.cpp
index 000a2185f5f0..84e718e9ef23 100644
--- a/lib/Serialization/ASTWriterStmt.cpp
+++ b/lib/Serialization/ASTWriterStmt.cpp
@@ -29,16 +29,24 @@ using namespace clang;
namespace clang {
class ASTStmtWriter : public StmtVisitor<ASTStmtWriter, void> {
- friend class OMPClauseWriter;
ASTWriter &Writer;
- ASTWriter::RecordData &Record;
+ ASTRecordWriter Record;
- public:
serialization::StmtCode Code;
unsigned AbbrevToUse;
+ public:
ASTStmtWriter(ASTWriter &Writer, ASTWriter::RecordData &Record)
- : Writer(Writer), Record(Record) { }
+ : Writer(Writer), Record(Writer, Record),
+ Code(serialization::STMT_NULL_PTR), AbbrevToUse(0) {}
+
+ ASTStmtWriter(const ASTStmtWriter&) = delete;
+
+ uint64_t Emit() {
+ assert(Code != serialization::STMT_NULL_PTR &&
+ "unhandled sub-statement writing AST file");
+ return Record.EmitStmt(Code, AbbrevToUse);
+ }
void AddTemplateKWAndArgsInfo(const ASTTemplateKWAndArgsInfo &ArgInfo,
const TemplateArgumentLoc *Args);
@@ -52,11 +60,11 @@ namespace clang {
void ASTStmtWriter::AddTemplateKWAndArgsInfo(
const ASTTemplateKWAndArgsInfo &ArgInfo, const TemplateArgumentLoc *Args) {
- Writer.AddSourceLocation(ArgInfo.TemplateKWLoc, Record);
- Writer.AddSourceLocation(ArgInfo.LAngleLoc, Record);
- Writer.AddSourceLocation(ArgInfo.RAngleLoc, Record);
+ Record.AddSourceLocation(ArgInfo.TemplateKWLoc);
+ Record.AddSourceLocation(ArgInfo.LAngleLoc);
+ Record.AddSourceLocation(ArgInfo.RAngleLoc);
for (unsigned i = 0; i != ArgInfo.NumTemplateArgs; ++i)
- Writer.AddTemplateArgumentLoc(Args[i], Record);
+ Record.AddTemplateArgumentLoc(Args[i]);
}
void ASTStmtWriter::VisitStmt(Stmt *S) {
@@ -64,7 +72,7 @@ void ASTStmtWriter::VisitStmt(Stmt *S) {
void ASTStmtWriter::VisitNullStmt(NullStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getSemiLoc(), Record);
+ Record.AddSourceLocation(S->getSemiLoc());
Record.push_back(S->HasLeadingEmptyMacro);
Code = serialization::STMT_NULL;
}
@@ -73,68 +81,71 @@ void ASTStmtWriter::VisitCompoundStmt(CompoundStmt *S) {
VisitStmt(S);
Record.push_back(S->size());
for (auto *CS : S->body())
- Writer.AddStmt(CS);
- Writer.AddSourceLocation(S->getLBracLoc(), Record);
- Writer.AddSourceLocation(S->getRBracLoc(), Record);
+ Record.AddStmt(CS);
+ Record.AddSourceLocation(S->getLBracLoc());
+ Record.AddSourceLocation(S->getRBracLoc());
Code = serialization::STMT_COMPOUND;
}
void ASTStmtWriter::VisitSwitchCase(SwitchCase *S) {
VisitStmt(S);
Record.push_back(Writer.getSwitchCaseID(S));
- Writer.AddSourceLocation(S->getKeywordLoc(), Record);
- Writer.AddSourceLocation(S->getColonLoc(), Record);
+ Record.AddSourceLocation(S->getKeywordLoc());
+ Record.AddSourceLocation(S->getColonLoc());
}
void ASTStmtWriter::VisitCaseStmt(CaseStmt *S) {
VisitSwitchCase(S);
- Writer.AddStmt(S->getLHS());
- Writer.AddStmt(S->getRHS());
- Writer.AddStmt(S->getSubStmt());
- Writer.AddSourceLocation(S->getEllipsisLoc(), Record);
+ Record.AddStmt(S->getLHS());
+ Record.AddStmt(S->getRHS());
+ Record.AddStmt(S->getSubStmt());
+ Record.AddSourceLocation(S->getEllipsisLoc());
Code = serialization::STMT_CASE;
}
void ASTStmtWriter::VisitDefaultStmt(DefaultStmt *S) {
VisitSwitchCase(S);
- Writer.AddStmt(S->getSubStmt());
+ Record.AddStmt(S->getSubStmt());
Code = serialization::STMT_DEFAULT;
}
void ASTStmtWriter::VisitLabelStmt(LabelStmt *S) {
VisitStmt(S);
- Writer.AddDeclRef(S->getDecl(), Record);
- Writer.AddStmt(S->getSubStmt());
- Writer.AddSourceLocation(S->getIdentLoc(), Record);
+ Record.AddDeclRef(S->getDecl());
+ Record.AddStmt(S->getSubStmt());
+ Record.AddSourceLocation(S->getIdentLoc());
Code = serialization::STMT_LABEL;
}
void ASTStmtWriter::VisitAttributedStmt(AttributedStmt *S) {
VisitStmt(S);
Record.push_back(S->getAttrs().size());
- Writer.WriteAttributes(S->getAttrs(), Record);
- Writer.AddStmt(S->getSubStmt());
- Writer.AddSourceLocation(S->getAttrLoc(), Record);
+ Record.AddAttributes(S->getAttrs());
+ Record.AddStmt(S->getSubStmt());
+ Record.AddSourceLocation(S->getAttrLoc());
Code = serialization::STMT_ATTRIBUTED;
}
void ASTStmtWriter::VisitIfStmt(IfStmt *S) {
VisitStmt(S);
- Writer.AddDeclRef(S->getConditionVariable(), Record);
- Writer.AddStmt(S->getCond());
- Writer.AddStmt(S->getThen());
- Writer.AddStmt(S->getElse());
- Writer.AddSourceLocation(S->getIfLoc(), Record);
- Writer.AddSourceLocation(S->getElseLoc(), Record);
+ Record.push_back(S->isConstexpr());
+ Record.AddStmt(S->getInit());
+ Record.AddDeclRef(S->getConditionVariable());
+ Record.AddStmt(S->getCond());
+ Record.AddStmt(S->getThen());
+ Record.AddStmt(S->getElse());
+ Record.AddSourceLocation(S->getIfLoc());
+ Record.AddSourceLocation(S->getElseLoc());
Code = serialization::STMT_IF;
}
void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
VisitStmt(S);
- Writer.AddDeclRef(S->getConditionVariable(), Record);
- Writer.AddStmt(S->getCond());
- Writer.AddStmt(S->getBody());
- Writer.AddSourceLocation(S->getSwitchLoc(), Record);
+ Record.AddStmt(S->getInit());
+ Record.AddDeclRef(S->getConditionVariable());
+ Record.AddStmt(S->getCond());
+ Record.AddStmt(S->getBody());
+ Record.AddSourceLocation(S->getSwitchLoc());
Record.push_back(S->isAllEnumCasesCovered());
for (SwitchCase *SC = S->getSwitchCaseList(); SC;
SC = SC->getNextSwitchCase())
@@ -144,79 +155,79 @@ void ASTStmtWriter::VisitSwitchStmt(SwitchStmt *S) {
void ASTStmtWriter::VisitWhileStmt(WhileStmt *S) {
VisitStmt(S);
- Writer.AddDeclRef(S->getConditionVariable(), Record);
- Writer.AddStmt(S->getCond());
- Writer.AddStmt(S->getBody());
- Writer.AddSourceLocation(S->getWhileLoc(), Record);
+ Record.AddDeclRef(S->getConditionVariable());
+ Record.AddStmt(S->getCond());
+ Record.AddStmt(S->getBody());
+ Record.AddSourceLocation(S->getWhileLoc());
Code = serialization::STMT_WHILE;
}
void ASTStmtWriter::VisitDoStmt(DoStmt *S) {
VisitStmt(S);
- Writer.AddStmt(S->getCond());
- Writer.AddStmt(S->getBody());
- Writer.AddSourceLocation(S->getDoLoc(), Record);
- Writer.AddSourceLocation(S->getWhileLoc(), Record);
- Writer.AddSourceLocation(S->getRParenLoc(), Record);
+ Record.AddStmt(S->getCond());
+ Record.AddStmt(S->getBody());
+ Record.AddSourceLocation(S->getDoLoc());
+ Record.AddSourceLocation(S->getWhileLoc());
+ Record.AddSourceLocation(S->getRParenLoc());
Code = serialization::STMT_DO;
}
void ASTStmtWriter::VisitForStmt(ForStmt *S) {
VisitStmt(S);
- Writer.AddStmt(S->getInit());
- Writer.AddStmt(S->getCond());
- Writer.AddDeclRef(S->getConditionVariable(), Record);
- Writer.AddStmt(S->getInc());
- Writer.AddStmt(S->getBody());
- Writer.AddSourceLocation(S->getForLoc(), Record);
- Writer.AddSourceLocation(S->getLParenLoc(), Record);
- Writer.AddSourceLocation(S->getRParenLoc(), Record);
+ Record.AddStmt(S->getInit());
+ Record.AddStmt(S->getCond());
+ Record.AddDeclRef(S->getConditionVariable());
+ Record.AddStmt(S->getInc());
+ Record.AddStmt(S->getBody());
+ Record.AddSourceLocation(S->getForLoc());
+ Record.AddSourceLocation(S->getLParenLoc());
+ Record.AddSourceLocation(S->getRParenLoc());
Code = serialization::STMT_FOR;
}
void ASTStmtWriter::VisitGotoStmt(GotoStmt *S) {
VisitStmt(S);
- Writer.AddDeclRef(S->getLabel(), Record);
- Writer.AddSourceLocation(S->getGotoLoc(), Record);
- Writer.AddSourceLocation(S->getLabelLoc(), Record);
+ Record.AddDeclRef(S->getLabel());
+ Record.AddSourceLocation(S->getGotoLoc());
+ Record.AddSourceLocation(S->getLabelLoc());
Code = serialization::STMT_GOTO;
}
void ASTStmtWriter::VisitIndirectGotoStmt(IndirectGotoStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getGotoLoc(), Record);
- Writer.AddSourceLocation(S->getStarLoc(), Record);
- Writer.AddStmt(S->getTarget());
+ Record.AddSourceLocation(S->getGotoLoc());
+ Record.AddSourceLocation(S->getStarLoc());
+ Record.AddStmt(S->getTarget());
Code = serialization::STMT_INDIRECT_GOTO;
}
void ASTStmtWriter::VisitContinueStmt(ContinueStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getContinueLoc(), Record);
+ Record.AddSourceLocation(S->getContinueLoc());
Code = serialization::STMT_CONTINUE;
}
void ASTStmtWriter::VisitBreakStmt(BreakStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getBreakLoc(), Record);
+ Record.AddSourceLocation(S->getBreakLoc());
Code = serialization::STMT_BREAK;
}
void ASTStmtWriter::VisitReturnStmt(ReturnStmt *S) {
VisitStmt(S);
- Writer.AddStmt(S->getRetValue());
- Writer.AddSourceLocation(S->getReturnLoc(), Record);
- Writer.AddDeclRef(S->getNRVOCandidate(), Record);
+ Record.AddStmt(S->getRetValue());
+ Record.AddSourceLocation(S->getReturnLoc());
+ Record.AddDeclRef(S->getNRVOCandidate());
Code = serialization::STMT_RETURN;
}
void ASTStmtWriter::VisitDeclStmt(DeclStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getStartLoc(), Record);
- Writer.AddSourceLocation(S->getEndLoc(), Record);
+ Record.AddSourceLocation(S->getStartLoc());
+ Record.AddSourceLocation(S->getEndLoc());
DeclGroupRef DG = S->getDeclGroup();
for (DeclGroupRef::iterator D = DG.begin(), DEnd = DG.end(); D != DEnd; ++D)
- Writer.AddDeclRef(*D, Record);
+ Record.AddDeclRef(*D);
Code = serialization::STMT_DECL;
}
@@ -225,64 +236,65 @@ void ASTStmtWriter::VisitAsmStmt(AsmStmt *S) {
Record.push_back(S->getNumOutputs());
Record.push_back(S->getNumInputs());
Record.push_back(S->getNumClobbers());
- Writer.AddSourceLocation(S->getAsmLoc(), Record);
+ Record.AddSourceLocation(S->getAsmLoc());
Record.push_back(S->isVolatile());
Record.push_back(S->isSimple());
}
void ASTStmtWriter::VisitGCCAsmStmt(GCCAsmStmt *S) {
VisitAsmStmt(S);
- Writer.AddSourceLocation(S->getRParenLoc(), Record);
- Writer.AddStmt(S->getAsmString());
+ Record.AddSourceLocation(S->getRParenLoc());
+ Record.AddStmt(S->getAsmString());
// Outputs
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
- Writer.AddIdentifierRef(S->getOutputIdentifier(I), Record);
- Writer.AddStmt(S->getOutputConstraintLiteral(I));
- Writer.AddStmt(S->getOutputExpr(I));
+ Record.AddIdentifierRef(S->getOutputIdentifier(I));
+ Record.AddStmt(S->getOutputConstraintLiteral(I));
+ Record.AddStmt(S->getOutputExpr(I));
}
// Inputs
for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
- Writer.AddIdentifierRef(S->getInputIdentifier(I), Record);
- Writer.AddStmt(S->getInputConstraintLiteral(I));
- Writer.AddStmt(S->getInputExpr(I));
+ Record.AddIdentifierRef(S->getInputIdentifier(I));
+ Record.AddStmt(S->getInputConstraintLiteral(I));
+ Record.AddStmt(S->getInputExpr(I));
}
// Clobbers
for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I)
- Writer.AddStmt(S->getClobberStringLiteral(I));
+ Record.AddStmt(S->getClobberStringLiteral(I));
Code = serialization::STMT_GCCASM;
}
void ASTStmtWriter::VisitMSAsmStmt(MSAsmStmt *S) {
VisitAsmStmt(S);
- Writer.AddSourceLocation(S->getLBraceLoc(), Record);
- Writer.AddSourceLocation(S->getEndLoc(), Record);
+ Record.AddSourceLocation(S->getLBraceLoc());
+ Record.AddSourceLocation(S->getEndLoc());
Record.push_back(S->getNumAsmToks());
- Writer.AddString(S->getAsmString(), Record);
+ Record.AddString(S->getAsmString());
// Tokens
for (unsigned I = 0, N = S->getNumAsmToks(); I != N; ++I) {
- Writer.AddToken(S->getAsmToks()[I], Record);
+ // FIXME: Move this to ASTRecordWriter?
+ Writer.AddToken(S->getAsmToks()[I], Record.getRecordData());
}
// Clobbers
for (unsigned I = 0, N = S->getNumClobbers(); I != N; ++I) {
- Writer.AddString(S->getClobber(I), Record);
+ Record.AddString(S->getClobber(I));
}
// Outputs
for (unsigned I = 0, N = S->getNumOutputs(); I != N; ++I) {
- Writer.AddStmt(S->getOutputExpr(I));
- Writer.AddString(S->getOutputConstraint(I), Record);
+ Record.AddStmt(S->getOutputExpr(I));
+ Record.AddString(S->getOutputConstraint(I));
}
// Inputs
for (unsigned I = 0, N = S->getNumInputs(); I != N; ++I) {
- Writer.AddStmt(S->getInputExpr(I));
- Writer.AddString(S->getInputConstraint(I), Record);
+ Record.AddStmt(S->getInputExpr(I));
+ Record.AddString(S->getInputConstraint(I));
}
Code = serialization::STMT_MSASM;
@@ -314,26 +326,26 @@ void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
Record.push_back(std::distance(S->capture_begin(), S->capture_end()));
// CapturedDecl and captured region kind
- Writer.AddDeclRef(S->getCapturedDecl(), Record);
+ Record.AddDeclRef(S->getCapturedDecl());
Record.push_back(S->getCapturedRegionKind());
- Writer.AddDeclRef(S->getCapturedRecordDecl(), Record);
+ Record.AddDeclRef(S->getCapturedRecordDecl());
// Capture inits
for (auto *I : S->capture_inits())
- Writer.AddStmt(I);
+ Record.AddStmt(I);
// Body
- Writer.AddStmt(S->getCapturedStmt());
+ Record.AddStmt(S->getCapturedStmt());
// Captures
for (const auto &I : S->captures()) {
if (I.capturesThis() || I.capturesVariableArrayType())
- Writer.AddDeclRef(nullptr, Record);
+ Record.AddDeclRef(nullptr);
else
- Writer.AddDeclRef(I.getCapturedVar(), Record);
+ Record.AddDeclRef(I.getCapturedVar());
Record.push_back(I.getCaptureKind());
- Writer.AddSourceLocation(I.getLocation(), Record);
+ Record.AddSourceLocation(I.getLocation());
}
Code = serialization::STMT_CAPTURED;
@@ -341,7 +353,7 @@ void ASTStmtWriter::VisitCapturedStmt(CapturedStmt *S) {
void ASTStmtWriter::VisitExpr(Expr *E) {
VisitStmt(E);
- Writer.AddTypeRef(E->getType(), Record);
+ Record.AddTypeRef(E->getType());
Record.push_back(E->isTypeDependent());
Record.push_back(E->isValueDependent());
Record.push_back(E->isInstantiationDependent());
@@ -352,9 +364,9 @@ void ASTStmtWriter::VisitExpr(Expr *E) {
void ASTStmtWriter::VisitPredefinedExpr(PredefinedExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddSourceLocation(E->getLocation());
Record.push_back(E->getIdentType()); // FIXME: stable encoding
- Writer.AddStmt(E->getFunctionName());
+ Record.AddStmt(E->getFunctionName());
Code = serialization::EXPR_PREDEFINED;
}
@@ -381,25 +393,25 @@ void ASTStmtWriter::VisitDeclRefExpr(DeclRefExpr *E) {
}
if (E->hasQualifier())
- Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
+ Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
if (E->getDecl() != E->getFoundDecl())
- Writer.AddDeclRef(E->getFoundDecl(), Record);
+ Record.AddDeclRef(E->getFoundDecl());
if (E->hasTemplateKWAndArgsInfo())
AddTemplateKWAndArgsInfo(*E->getTrailingObjects<ASTTemplateKWAndArgsInfo>(),
E->getTrailingObjects<TemplateArgumentLoc>());
- Writer.AddDeclRef(E->getDecl(), Record);
- Writer.AddSourceLocation(E->getLocation(), Record);
- Writer.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName(), Record);
+ Record.AddDeclRef(E->getDecl());
+ Record.AddSourceLocation(E->getLocation());
+ Record.AddDeclarationNameLoc(E->DNLoc, E->getDecl()->getDeclName());
Code = serialization::EXPR_DECL_REF;
}
void ASTStmtWriter::VisitIntegerLiteral(IntegerLiteral *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getLocation(), Record);
- Writer.AddAPInt(E->getValue(), Record);
+ Record.AddSourceLocation(E->getLocation());
+ Record.AddAPInt(E->getValue());
if (E->getValue().getBitWidth() == 32) {
AbbrevToUse = Writer.getIntegerLiteralAbbrev();
@@ -412,14 +424,14 @@ void ASTStmtWriter::VisitFloatingLiteral(FloatingLiteral *E) {
VisitExpr(E);
Record.push_back(E->getRawSemantics());
Record.push_back(E->isExact());
- Writer.AddAPFloat(E->getValue(), Record);
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddAPFloat(E->getValue());
+ Record.AddSourceLocation(E->getLocation());
Code = serialization::EXPR_FLOATING_LITERAL;
}
void ASTStmtWriter::VisitImaginaryLiteral(ImaginaryLiteral *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSubExpr());
+ Record.AddStmt(E->getSubExpr());
Code = serialization::EXPR_IMAGINARY_LITERAL;
}
@@ -435,14 +447,14 @@ void ASTStmtWriter::VisitStringLiteral(StringLiteral *E) {
// the AST file during deserialization.
Record.append(E->getBytes().begin(), E->getBytes().end());
for (unsigned I = 0, N = E->getNumConcatenated(); I != N; ++I)
- Writer.AddSourceLocation(E->getStrTokenLoc(I), Record);
+ Record.AddSourceLocation(E->getStrTokenLoc(I));
Code = serialization::EXPR_STRING_LITERAL;
}
void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
VisitExpr(E);
Record.push_back(E->getValue());
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddSourceLocation(E->getLocation());
Record.push_back(E->getKind());
AbbrevToUse = Writer.getCharacterLiteralAbbrev();
@@ -452,9 +464,9 @@ void ASTStmtWriter::VisitCharacterLiteral(CharacterLiteral *E) {
void ASTStmtWriter::VisitParenExpr(ParenExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getLParen(), Record);
- Writer.AddSourceLocation(E->getRParen(), Record);
- Writer.AddStmt(E->getSubExpr());
+ Record.AddSourceLocation(E->getLParen());
+ Record.AddSourceLocation(E->getRParen());
+ Record.AddStmt(E->getSubExpr());
Code = serialization::EXPR_PAREN;
}
@@ -462,17 +474,17 @@ void ASTStmtWriter::VisitParenListExpr(ParenListExpr *E) {
VisitExpr(E);
Record.push_back(E->NumExprs);
for (unsigned i=0; i != E->NumExprs; ++i)
- Writer.AddStmt(E->Exprs[i]);
- Writer.AddSourceLocation(E->LParenLoc, Record);
- Writer.AddSourceLocation(E->RParenLoc, Record);
+ Record.AddStmt(E->Exprs[i]);
+ Record.AddSourceLocation(E->LParenLoc);
+ Record.AddSourceLocation(E->RParenLoc);
Code = serialization::EXPR_PAREN_LIST;
}
void ASTStmtWriter::VisitUnaryOperator(UnaryOperator *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSubExpr());
+ Record.AddStmt(E->getSubExpr());
Record.push_back(E->getOpcode()); // FIXME: stable encoding
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
+ Record.AddSourceLocation(E->getOperatorLoc());
Code = serialization::EXPR_UNARY_OPERATOR;
}
@@ -480,34 +492,34 @@ void ASTStmtWriter::VisitOffsetOfExpr(OffsetOfExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumComponents());
Record.push_back(E->getNumExpressions());
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
- Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
+ Record.AddSourceLocation(E->getOperatorLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
+ Record.AddTypeSourceInfo(E->getTypeSourceInfo());
for (unsigned I = 0, N = E->getNumComponents(); I != N; ++I) {
const OffsetOfNode &ON = E->getComponent(I);
Record.push_back(ON.getKind()); // FIXME: Stable encoding
- Writer.AddSourceLocation(ON.getSourceRange().getBegin(), Record);
- Writer.AddSourceLocation(ON.getSourceRange().getEnd(), Record);
+ Record.AddSourceLocation(ON.getSourceRange().getBegin());
+ Record.AddSourceLocation(ON.getSourceRange().getEnd());
switch (ON.getKind()) {
case OffsetOfNode::Array:
Record.push_back(ON.getArrayExprIndex());
break;
case OffsetOfNode::Field:
- Writer.AddDeclRef(ON.getField(), Record);
+ Record.AddDeclRef(ON.getField());
break;
case OffsetOfNode::Identifier:
- Writer.AddIdentifierRef(ON.getFieldName(), Record);
+ Record.AddIdentifierRef(ON.getFieldName());
break;
case OffsetOfNode::Base:
- Writer.AddCXXBaseSpecifier(*ON.getBase(), Record);
+ Record.AddCXXBaseSpecifier(*ON.getBase());
break;
}
}
for (unsigned I = 0, N = E->getNumExpressions(); I != N; ++I)
- Writer.AddStmt(E->getIndexExpr(I));
+ Record.AddStmt(E->getIndexExpr(I));
Code = serialization::EXPR_OFFSETOF;
}
@@ -515,42 +527,42 @@ void ASTStmtWriter::VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E) {
VisitExpr(E);
Record.push_back(E->getKind());
if (E->isArgumentType())
- Writer.AddTypeSourceInfo(E->getArgumentTypeInfo(), Record);
+ Record.AddTypeSourceInfo(E->getArgumentTypeInfo());
else {
Record.push_back(0);
- Writer.AddStmt(E->getArgumentExpr());
+ Record.AddStmt(E->getArgumentExpr());
}
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddSourceLocation(E->getOperatorLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_SIZEOF_ALIGN_OF;
}
void ASTStmtWriter::VisitArraySubscriptExpr(ArraySubscriptExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getLHS());
- Writer.AddStmt(E->getRHS());
- Writer.AddSourceLocation(E->getRBracketLoc(), Record);
+ Record.AddStmt(E->getLHS());
+ Record.AddStmt(E->getRHS());
+ Record.AddSourceLocation(E->getRBracketLoc());
Code = serialization::EXPR_ARRAY_SUBSCRIPT;
}
void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getBase());
- Writer.AddStmt(E->getLowerBound());
- Writer.AddStmt(E->getLength());
- Writer.AddSourceLocation(E->getColonLoc(), Record);
- Writer.AddSourceLocation(E->getRBracketLoc(), Record);
+ Record.AddStmt(E->getBase());
+ Record.AddStmt(E->getLowerBound());
+ Record.AddStmt(E->getLength());
+ Record.AddSourceLocation(E->getColonLoc());
+ Record.AddSourceLocation(E->getRBracketLoc());
Code = serialization::EXPR_OMP_ARRAY_SECTION;
}
void ASTStmtWriter::VisitCallExpr(CallExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumArgs());
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
- Writer.AddStmt(E->getCallee());
+ Record.AddSourceLocation(E->getRParenLoc());
+ Record.AddStmt(E->getCallee());
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg)
- Writer.AddStmt(*Arg);
+ Record.AddStmt(*Arg);
Code = serialization::EXPR_CALL;
}
@@ -559,43 +571,43 @@ void ASTStmtWriter::VisitMemberExpr(MemberExpr *E) {
Record.push_back(E->hasQualifier());
if (E->hasQualifier())
- Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
+ Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
Record.push_back(E->HasTemplateKWAndArgsInfo);
if (E->HasTemplateKWAndArgsInfo) {
- Writer.AddSourceLocation(E->getTemplateKeywordLoc(), Record);
+ Record.AddSourceLocation(E->getTemplateKeywordLoc());
unsigned NumTemplateArgs = E->getNumTemplateArgs();
Record.push_back(NumTemplateArgs);
- Writer.AddSourceLocation(E->getLAngleLoc(), Record);
- Writer.AddSourceLocation(E->getRAngleLoc(), Record);
+ Record.AddSourceLocation(E->getLAngleLoc());
+ Record.AddSourceLocation(E->getRAngleLoc());
for (unsigned i=0; i != NumTemplateArgs; ++i)
- Writer.AddTemplateArgumentLoc(E->getTemplateArgs()[i], Record);
+ Record.AddTemplateArgumentLoc(E->getTemplateArgs()[i]);
}
Record.push_back(E->hadMultipleCandidates());
DeclAccessPair FoundDecl = E->getFoundDecl();
- Writer.AddDeclRef(FoundDecl.getDecl(), Record);
+ Record.AddDeclRef(FoundDecl.getDecl());
Record.push_back(FoundDecl.getAccess());
- Writer.AddTypeRef(E->getType(), Record);
+ Record.AddTypeRef(E->getType());
Record.push_back(E->getValueKind());
Record.push_back(E->getObjectKind());
- Writer.AddStmt(E->getBase());
- Writer.AddDeclRef(E->getMemberDecl(), Record);
- Writer.AddSourceLocation(E->getMemberLoc(), Record);
+ Record.AddStmt(E->getBase());
+ Record.AddDeclRef(E->getMemberDecl());
+ Record.AddSourceLocation(E->getMemberLoc());
Record.push_back(E->isArrow());
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
- Writer.AddDeclarationNameLoc(E->MemberDNLoc,
- E->getMemberDecl()->getDeclName(), Record);
+ Record.AddSourceLocation(E->getOperatorLoc());
+ Record.AddDeclarationNameLoc(E->MemberDNLoc,
+ E->getMemberDecl()->getDeclName());
Code = serialization::EXPR_MEMBER;
}
void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getBase());
- Writer.AddSourceLocation(E->getIsaMemberLoc(), Record);
- Writer.AddSourceLocation(E->getOpLoc(), Record);
+ Record.AddStmt(E->getBase());
+ Record.AddSourceLocation(E->getIsaMemberLoc());
+ Record.AddSourceLocation(E->getOpLoc());
Record.push_back(E->isArrow());
Code = serialization::EXPR_OBJC_ISA;
}
@@ -603,15 +615,15 @@ void ASTStmtWriter::VisitObjCIsaExpr(ObjCIsaExpr *E) {
void ASTStmtWriter::
VisitObjCIndirectCopyRestoreExpr(ObjCIndirectCopyRestoreExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSubExpr());
+ Record.AddStmt(E->getSubExpr());
Record.push_back(E->shouldCopy());
Code = serialization::EXPR_OBJC_INDIRECT_COPY_RESTORE;
}
void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
VisitExplicitCastExpr(E);
- Writer.AddSourceLocation(E->getLParenLoc(), Record);
- Writer.AddSourceLocation(E->getBridgeKeywordLoc(), Record);
+ Record.AddSourceLocation(E->getLParenLoc());
+ Record.AddSourceLocation(E->getBridgeKeywordLoc());
Record.push_back(E->getBridgeKind()); // FIXME: Stable encoding
Code = serialization::EXPR_OBJC_BRIDGED_CAST;
}
@@ -619,51 +631,51 @@ void ASTStmtWriter::VisitObjCBridgedCastExpr(ObjCBridgedCastExpr *E) {
void ASTStmtWriter::VisitCastExpr(CastExpr *E) {
VisitExpr(E);
Record.push_back(E->path_size());
- Writer.AddStmt(E->getSubExpr());
+ Record.AddStmt(E->getSubExpr());
Record.push_back(E->getCastKind()); // FIXME: stable encoding
for (CastExpr::path_iterator
PI = E->path_begin(), PE = E->path_end(); PI != PE; ++PI)
- Writer.AddCXXBaseSpecifier(**PI, Record);
+ Record.AddCXXBaseSpecifier(**PI);
}
void ASTStmtWriter::VisitBinaryOperator(BinaryOperator *E) {
VisitExpr(E);
- Writer.AddStmt(E->getLHS());
- Writer.AddStmt(E->getRHS());
+ Record.AddStmt(E->getLHS());
+ Record.AddStmt(E->getRHS());
Record.push_back(E->getOpcode()); // FIXME: stable encoding
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
+ Record.AddSourceLocation(E->getOperatorLoc());
Record.push_back(E->isFPContractable());
Code = serialization::EXPR_BINARY_OPERATOR;
}
void ASTStmtWriter::VisitCompoundAssignOperator(CompoundAssignOperator *E) {
VisitBinaryOperator(E);
- Writer.AddTypeRef(E->getComputationLHSType(), Record);
- Writer.AddTypeRef(E->getComputationResultType(), Record);
+ Record.AddTypeRef(E->getComputationLHSType());
+ Record.AddTypeRef(E->getComputationResultType());
Code = serialization::EXPR_COMPOUND_ASSIGN_OPERATOR;
}
void ASTStmtWriter::VisitConditionalOperator(ConditionalOperator *E) {
VisitExpr(E);
- Writer.AddStmt(E->getCond());
- Writer.AddStmt(E->getLHS());
- Writer.AddStmt(E->getRHS());
- Writer.AddSourceLocation(E->getQuestionLoc(), Record);
- Writer.AddSourceLocation(E->getColonLoc(), Record);
+ Record.AddStmt(E->getCond());
+ Record.AddStmt(E->getLHS());
+ Record.AddStmt(E->getRHS());
+ Record.AddSourceLocation(E->getQuestionLoc());
+ Record.AddSourceLocation(E->getColonLoc());
Code = serialization::EXPR_CONDITIONAL_OPERATOR;
}
void
ASTStmtWriter::VisitBinaryConditionalOperator(BinaryConditionalOperator *E) {
VisitExpr(E);
- Writer.AddStmt(E->getOpaqueValue());
- Writer.AddStmt(E->getCommon());
- Writer.AddStmt(E->getCond());
- Writer.AddStmt(E->getTrueExpr());
- Writer.AddStmt(E->getFalseExpr());
- Writer.AddSourceLocation(E->getQuestionLoc(), Record);
- Writer.AddSourceLocation(E->getColonLoc(), Record);
+ Record.AddStmt(E->getOpaqueValue());
+ Record.AddStmt(E->getCommon());
+ Record.AddStmt(E->getCond());
+ Record.AddStmt(E->getTrueExpr());
+ Record.AddStmt(E->getFalseExpr());
+ Record.AddSourceLocation(E->getQuestionLoc());
+ Record.AddSourceLocation(E->getColonLoc());
Code = serialization::EXPR_BINARY_CONDITIONAL_OPERATOR;
}
@@ -678,30 +690,30 @@ void ASTStmtWriter::VisitImplicitCastExpr(ImplicitCastExpr *E) {
void ASTStmtWriter::VisitExplicitCastExpr(ExplicitCastExpr *E) {
VisitCastExpr(E);
- Writer.AddTypeSourceInfo(E->getTypeInfoAsWritten(), Record);
+ Record.AddTypeSourceInfo(E->getTypeInfoAsWritten());
}
void ASTStmtWriter::VisitCStyleCastExpr(CStyleCastExpr *E) {
VisitExplicitCastExpr(E);
- Writer.AddSourceLocation(E->getLParenLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddSourceLocation(E->getLParenLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_CSTYLE_CAST;
}
void ASTStmtWriter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getLParenLoc(), Record);
- Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
- Writer.AddStmt(E->getInitializer());
+ Record.AddSourceLocation(E->getLParenLoc());
+ Record.AddTypeSourceInfo(E->getTypeSourceInfo());
+ Record.AddStmt(E->getInitializer());
Record.push_back(E->isFileScope());
Code = serialization::EXPR_COMPOUND_LITERAL;
}
void ASTStmtWriter::VisitExtVectorElementExpr(ExtVectorElementExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getBase());
- Writer.AddIdentifierRef(&E->getAccessor(), Record);
- Writer.AddSourceLocation(E->getAccessorLoc(), Record);
+ Record.AddStmt(E->getBase());
+ Record.AddIdentifierRef(&E->getAccessor());
+ Record.AddSourceLocation(E->getAccessorLoc());
Code = serialization::EXPR_EXT_VECTOR_ELEMENT;
}
@@ -709,15 +721,15 @@ void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
VisitExpr(E);
// NOTE: only add the (possibly null) syntactic form.
// No need to serialize the isSemanticForm flag and the semantic form.
- Writer.AddStmt(E->getSyntacticForm());
- Writer.AddSourceLocation(E->getLBraceLoc(), Record);
- Writer.AddSourceLocation(E->getRBraceLoc(), Record);
+ Record.AddStmt(E->getSyntacticForm());
+ Record.AddSourceLocation(E->getLBraceLoc());
+ Record.AddSourceLocation(E->getRBraceLoc());
bool isArrayFiller = E->ArrayFillerOrUnionFieldInit.is<Expr*>();
Record.push_back(isArrayFiller);
if (isArrayFiller)
- Writer.AddStmt(E->getArrayFiller());
+ Record.AddStmt(E->getArrayFiller());
else
- Writer.AddDeclRef(E->getInitializedFieldInUnion(), Record);
+ Record.AddDeclRef(E->getInitializedFieldInUnion());
Record.push_back(E->hadArrayRangeDesignator());
Record.push_back(E->getNumInits());
if (isArrayFiller) {
@@ -725,10 +737,10 @@ void ASTStmtWriter::VisitInitListExpr(InitListExpr *E) {
// Replace them by 0 to indicate that the filler goes in that place.
Expr *filler = E->getArrayFiller();
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
- Writer.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr);
+ Record.AddStmt(E->getInit(I) != filler ? E->getInit(I) : nullptr);
} else {
for (unsigned I = 0, N = E->getNumInits(); I != N; ++I)
- Writer.AddStmt(E->getInit(I));
+ Record.AddStmt(E->getInit(I));
}
Code = serialization::EXPR_INIT_LIST;
}
@@ -737,34 +749,32 @@ void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumSubExprs());
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
- Writer.AddStmt(E->getSubExpr(I));
- Writer.AddSourceLocation(E->getEqualOrColonLoc(), Record);
+ Record.AddStmt(E->getSubExpr(I));
+ Record.AddSourceLocation(E->getEqualOrColonLoc());
Record.push_back(E->usesGNUSyntax());
- for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
- DEnd = E->designators_end();
- D != DEnd; ++D) {
- if (D->isFieldDesignator()) {
- if (FieldDecl *Field = D->getField()) {
+ for (const DesignatedInitExpr::Designator &D : E->designators()) {
+ if (D.isFieldDesignator()) {
+ if (FieldDecl *Field = D.getField()) {
Record.push_back(serialization::DESIG_FIELD_DECL);
- Writer.AddDeclRef(Field, Record);
+ Record.AddDeclRef(Field);
} else {
Record.push_back(serialization::DESIG_FIELD_NAME);
- Writer.AddIdentifierRef(D->getFieldName(), Record);
+ Record.AddIdentifierRef(D.getFieldName());
}
- Writer.AddSourceLocation(D->getDotLoc(), Record);
- Writer.AddSourceLocation(D->getFieldLoc(), Record);
- } else if (D->isArrayDesignator()) {
+ Record.AddSourceLocation(D.getDotLoc());
+ Record.AddSourceLocation(D.getFieldLoc());
+ } else if (D.isArrayDesignator()) {
Record.push_back(serialization::DESIG_ARRAY);
- Record.push_back(D->getFirstExprIndex());
- Writer.AddSourceLocation(D->getLBracketLoc(), Record);
- Writer.AddSourceLocation(D->getRBracketLoc(), Record);
+ Record.push_back(D.getFirstExprIndex());
+ Record.AddSourceLocation(D.getLBracketLoc());
+ Record.AddSourceLocation(D.getRBracketLoc());
} else {
- assert(D->isArrayRangeDesignator() && "Unknown designator");
+ assert(D.isArrayRangeDesignator() && "Unknown designator");
Record.push_back(serialization::DESIG_ARRAY_RANGE);
- Record.push_back(D->getFirstExprIndex());
- Writer.AddSourceLocation(D->getLBracketLoc(), Record);
- Writer.AddSourceLocation(D->getEllipsisLoc(), Record);
- Writer.AddSourceLocation(D->getRBracketLoc(), Record);
+ Record.push_back(D.getFirstExprIndex());
+ Record.AddSourceLocation(D.getLBracketLoc());
+ Record.AddSourceLocation(D.getEllipsisLoc());
+ Record.AddSourceLocation(D.getRBracketLoc());
}
}
Code = serialization::EXPR_DESIGNATED_INIT;
@@ -772,8 +782,8 @@ void ASTStmtWriter::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
void ASTStmtWriter::VisitDesignatedInitUpdateExpr(DesignatedInitUpdateExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getBase());
- Writer.AddStmt(E->getUpdater());
+ Record.AddStmt(E->getBase());
+ Record.AddStmt(E->getUpdater());
Code = serialization::EXPR_DESIGNATED_INIT_UPDATE;
}
@@ -789,44 +799,44 @@ void ASTStmtWriter::VisitImplicitValueInitExpr(ImplicitValueInitExpr *E) {
void ASTStmtWriter::VisitVAArgExpr(VAArgExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSubExpr());
- Writer.AddTypeSourceInfo(E->getWrittenTypeInfo(), Record);
- Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddStmt(E->getSubExpr());
+ Record.AddTypeSourceInfo(E->getWrittenTypeInfo());
+ Record.AddSourceLocation(E->getBuiltinLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Record.push_back(E->isMicrosoftABI());
Code = serialization::EXPR_VA_ARG;
}
void ASTStmtWriter::VisitAddrLabelExpr(AddrLabelExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getAmpAmpLoc(), Record);
- Writer.AddSourceLocation(E->getLabelLoc(), Record);
- Writer.AddDeclRef(E->getLabel(), Record);
+ Record.AddSourceLocation(E->getAmpAmpLoc());
+ Record.AddSourceLocation(E->getLabelLoc());
+ Record.AddDeclRef(E->getLabel());
Code = serialization::EXPR_ADDR_LABEL;
}
void ASTStmtWriter::VisitStmtExpr(StmtExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSubStmt());
- Writer.AddSourceLocation(E->getLParenLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddStmt(E->getSubStmt());
+ Record.AddSourceLocation(E->getLParenLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_STMT;
}
void ASTStmtWriter::VisitChooseExpr(ChooseExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getCond());
- Writer.AddStmt(E->getLHS());
- Writer.AddStmt(E->getRHS());
- Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddStmt(E->getCond());
+ Record.AddStmt(E->getLHS());
+ Record.AddStmt(E->getRHS());
+ Record.AddSourceLocation(E->getBuiltinLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Record.push_back(E->isConditionDependent() ? false : E->isConditionTrue());
Code = serialization::EXPR_CHOOSE;
}
void ASTStmtWriter::VisitGNUNullExpr(GNUNullExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getTokenLocation(), Record);
+ Record.AddSourceLocation(E->getTokenLocation());
Code = serialization::EXPR_GNU_NULL;
}
@@ -834,24 +844,24 @@ void ASTStmtWriter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumSubExprs());
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
- Writer.AddStmt(E->getExpr(I));
- Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddStmt(E->getExpr(I));
+ Record.AddSourceLocation(E->getBuiltinLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_SHUFFLE_VECTOR;
}
void ASTStmtWriter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
- Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
- Writer.AddStmt(E->getSrcExpr());
+ Record.AddSourceLocation(E->getBuiltinLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
+ Record.AddTypeSourceInfo(E->getTypeSourceInfo());
+ Record.AddStmt(E->getSrcExpr());
Code = serialization::EXPR_CONVERT_VECTOR;
}
void ASTStmtWriter::VisitBlockExpr(BlockExpr *E) {
VisitExpr(E);
- Writer.AddDeclRef(E->getBlockDecl(), Record);
+ Record.AddDeclRef(E->getBlockDecl());
Code = serialization::EXPR_BLOCK;
}
@@ -859,16 +869,16 @@ void ASTStmtWriter::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumAssocs());
- Writer.AddStmt(E->getControllingExpr());
+ Record.AddStmt(E->getControllingExpr());
for (unsigned I = 0, N = E->getNumAssocs(); I != N; ++I) {
- Writer.AddTypeSourceInfo(E->getAssocTypeSourceInfo(I), Record);
- Writer.AddStmt(E->getAssocExpr(I));
+ Record.AddTypeSourceInfo(E->getAssocTypeSourceInfo(I));
+ Record.AddStmt(E->getAssocExpr(I));
}
Record.push_back(E->isResultDependent() ? -1U : E->getResultIndex());
- Writer.AddSourceLocation(E->getGenericLoc(), Record);
- Writer.AddSourceLocation(E->getDefaultLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddSourceLocation(E->getGenericLoc());
+ Record.AddSourceLocation(E->getDefaultLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_GENERIC_SELECTION;
}
@@ -882,10 +892,10 @@ void ASTStmtWriter::VisitPseudoObjectExpr(PseudoObjectExpr *E) {
result = (result == PseudoObjectExpr::NoResult ? 0 : result + 1);
Record.push_back(result);
- Writer.AddStmt(E->getSyntacticForm());
+ Record.AddStmt(E->getSyntacticForm());
for (PseudoObjectExpr::semantics_iterator
i = E->semantics_begin(), e = E->semantics_end(); i != e; ++i) {
- Writer.AddStmt(*i);
+ Record.AddStmt(*i);
}
Code = serialization::EXPR_PSEUDO_OBJECT;
}
@@ -894,9 +904,9 @@ void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) {
VisitExpr(E);
Record.push_back(E->getOp());
for (unsigned I = 0, N = E->getNumSubExprs(); I != N; ++I)
- Writer.AddStmt(E->getSubExprs()[I]);
- Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddStmt(E->getSubExprs()[I]);
+ Record.AddSourceLocation(E->getBuiltinLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_ATOMIC;
}
@@ -906,16 +916,16 @@ void ASTStmtWriter::VisitAtomicExpr(AtomicExpr *E) {
void ASTStmtWriter::VisitObjCStringLiteral(ObjCStringLiteral *E) {
VisitExpr(E);
- Writer.AddStmt(E->getString());
- Writer.AddSourceLocation(E->getAtLoc(), Record);
+ Record.AddStmt(E->getString());
+ Record.AddSourceLocation(E->getAtLoc());
Code = serialization::EXPR_OBJC_STRING_LITERAL;
}
void ASTStmtWriter::VisitObjCBoxedExpr(ObjCBoxedExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSubExpr());
- Writer.AddDeclRef(E->getBoxingMethod(), Record);
- Writer.AddSourceRange(E->getSourceRange(), Record);
+ Record.AddStmt(E->getSubExpr());
+ Record.AddDeclRef(E->getBoxingMethod());
+ Record.AddSourceRange(E->getSourceRange());
Code = serialization::EXPR_OBJC_BOXED_EXPRESSION;
}
@@ -923,9 +933,9 @@ void ASTStmtWriter::VisitObjCArrayLiteral(ObjCArrayLiteral *E) {
VisitExpr(E);
Record.push_back(E->getNumElements());
for (unsigned i = 0; i < E->getNumElements(); i++)
- Writer.AddStmt(E->getElement(i));
- Writer.AddDeclRef(E->getArrayWithObjectsMethod(), Record);
- Writer.AddSourceRange(E->getSourceRange(), Record);
+ Record.AddStmt(E->getElement(i));
+ Record.AddDeclRef(E->getArrayWithObjectsMethod());
+ Record.AddSourceRange(E->getSourceRange());
Code = serialization::EXPR_OBJC_ARRAY_LITERAL;
}
@@ -935,10 +945,10 @@ void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
Record.push_back(E->HasPackExpansions);
for (unsigned i = 0; i < E->getNumElements(); i++) {
ObjCDictionaryElement Element = E->getKeyValueElement(i);
- Writer.AddStmt(Element.Key);
- Writer.AddStmt(Element.Value);
+ Record.AddStmt(Element.Key);
+ Record.AddStmt(Element.Value);
if (E->HasPackExpansions) {
- Writer.AddSourceLocation(Element.EllipsisLoc, Record);
+ Record.AddSourceLocation(Element.EllipsisLoc);
unsigned NumExpansions = 0;
if (Element.NumExpansions)
NumExpansions = *Element.NumExpansions + 1;
@@ -946,42 +956,42 @@ void ASTStmtWriter::VisitObjCDictionaryLiteral(ObjCDictionaryLiteral *E) {
}
}
- Writer.AddDeclRef(E->getDictWithObjectsMethod(), Record);
- Writer.AddSourceRange(E->getSourceRange(), Record);
+ Record.AddDeclRef(E->getDictWithObjectsMethod());
+ Record.AddSourceRange(E->getSourceRange());
Code = serialization::EXPR_OBJC_DICTIONARY_LITERAL;
}
void ASTStmtWriter::VisitObjCEncodeExpr(ObjCEncodeExpr *E) {
VisitExpr(E);
- Writer.AddTypeSourceInfo(E->getEncodedTypeSourceInfo(), Record);
- Writer.AddSourceLocation(E->getAtLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddTypeSourceInfo(E->getEncodedTypeSourceInfo());
+ Record.AddSourceLocation(E->getAtLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_OBJC_ENCODE;
}
void ASTStmtWriter::VisitObjCSelectorExpr(ObjCSelectorExpr *E) {
VisitExpr(E);
- Writer.AddSelectorRef(E->getSelector(), Record);
- Writer.AddSourceLocation(E->getAtLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddSelectorRef(E->getSelector());
+ Record.AddSourceLocation(E->getAtLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_OBJC_SELECTOR_EXPR;
}
void ASTStmtWriter::VisitObjCProtocolExpr(ObjCProtocolExpr *E) {
VisitExpr(E);
- Writer.AddDeclRef(E->getProtocol(), Record);
- Writer.AddSourceLocation(E->getAtLoc(), Record);
- Writer.AddSourceLocation(E->ProtoLoc, Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddDeclRef(E->getProtocol());
+ Record.AddSourceLocation(E->getAtLoc());
+ Record.AddSourceLocation(E->ProtoLoc);
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_OBJC_PROTOCOL_EXPR;
}
void ASTStmtWriter::VisitObjCIvarRefExpr(ObjCIvarRefExpr *E) {
VisitExpr(E);
- Writer.AddDeclRef(E->getDecl(), Record);
- Writer.AddSourceLocation(E->getLocation(), Record);
- Writer.AddSourceLocation(E->getOpLoc(), Record);
- Writer.AddStmt(E->getBase());
+ Record.AddDeclRef(E->getDecl());
+ Record.AddSourceLocation(E->getLocation());
+ Record.AddSourceLocation(E->getOpLoc());
+ Record.AddStmt(E->getBase());
Record.push_back(E->isArrow());
Record.push_back(E->isFreeIvar());
Code = serialization::EXPR_OBJC_IVAR_REF_EXPR;
@@ -992,22 +1002,22 @@ void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
Record.push_back(E->SetterAndMethodRefFlags.getInt());
Record.push_back(E->isImplicitProperty());
if (E->isImplicitProperty()) {
- Writer.AddDeclRef(E->getImplicitPropertyGetter(), Record);
- Writer.AddDeclRef(E->getImplicitPropertySetter(), Record);
+ Record.AddDeclRef(E->getImplicitPropertyGetter());
+ Record.AddDeclRef(E->getImplicitPropertySetter());
} else {
- Writer.AddDeclRef(E->getExplicitProperty(), Record);
+ Record.AddDeclRef(E->getExplicitProperty());
}
- Writer.AddSourceLocation(E->getLocation(), Record);
- Writer.AddSourceLocation(E->getReceiverLocation(), Record);
+ Record.AddSourceLocation(E->getLocation());
+ Record.AddSourceLocation(E->getReceiverLocation());
if (E->isObjectReceiver()) {
Record.push_back(0);
- Writer.AddStmt(E->getBase());
+ Record.AddStmt(E->getBase());
} else if (E->isSuperReceiver()) {
Record.push_back(1);
- Writer.AddTypeRef(E->getSuperReceiverType(), Record);
+ Record.AddTypeRef(E->getSuperReceiverType());
} else {
Record.push_back(2);
- Writer.AddDeclRef(E->getClassReceiver(), Record);
+ Record.AddDeclRef(E->getClassReceiver());
}
Code = serialization::EXPR_OBJC_PROPERTY_REF_EXPR;
@@ -1015,11 +1025,11 @@ void ASTStmtWriter::VisitObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
void ASTStmtWriter::VisitObjCSubscriptRefExpr(ObjCSubscriptRefExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getRBracket(), Record);
- Writer.AddStmt(E->getBaseExpr());
- Writer.AddStmt(E->getKeyExpr());
- Writer.AddDeclRef(E->getAtIndexMethodDecl(), Record);
- Writer.AddDeclRef(E->setAtIndexMethodDecl(), Record);
+ Record.AddSourceLocation(E->getRBracket());
+ Record.AddStmt(E->getBaseExpr());
+ Record.AddStmt(E->getKeyExpr());
+ Record.AddDeclRef(E->getAtIndexMethodDecl());
+ Record.AddDeclRef(E->setAtIndexMethodDecl());
Code = serialization::EXPR_OBJC_SUBSCRIPT_REF_EXPR;
}
@@ -1034,155 +1044,163 @@ void ASTStmtWriter::VisitObjCMessageExpr(ObjCMessageExpr *E) {
Record.push_back((unsigned)E->getReceiverKind()); // FIXME: stable encoding
switch (E->getReceiverKind()) {
case ObjCMessageExpr::Instance:
- Writer.AddStmt(E->getInstanceReceiver());
+ Record.AddStmt(E->getInstanceReceiver());
break;
case ObjCMessageExpr::Class:
- Writer.AddTypeSourceInfo(E->getClassReceiverTypeInfo(), Record);
+ Record.AddTypeSourceInfo(E->getClassReceiverTypeInfo());
break;
case ObjCMessageExpr::SuperClass:
case ObjCMessageExpr::SuperInstance:
- Writer.AddTypeRef(E->getSuperType(), Record);
- Writer.AddSourceLocation(E->getSuperLoc(), Record);
+ Record.AddTypeRef(E->getSuperType());
+ Record.AddSourceLocation(E->getSuperLoc());
break;
}
if (E->getMethodDecl()) {
Record.push_back(1);
- Writer.AddDeclRef(E->getMethodDecl(), Record);
+ Record.AddDeclRef(E->getMethodDecl());
} else {
Record.push_back(0);
- Writer.AddSelectorRef(E->getSelector(), Record);
+ Record.AddSelectorRef(E->getSelector());
}
- Writer.AddSourceLocation(E->getLeftLoc(), Record);
- Writer.AddSourceLocation(E->getRightLoc(), Record);
+ Record.AddSourceLocation(E->getLeftLoc());
+ Record.AddSourceLocation(E->getRightLoc());
for (CallExpr::arg_iterator Arg = E->arg_begin(), ArgEnd = E->arg_end();
Arg != ArgEnd; ++Arg)
- Writer.AddStmt(*Arg);
+ Record.AddStmt(*Arg);
SourceLocation *Locs = E->getStoredSelLocs();
for (unsigned i = 0, e = E->getNumStoredSelLocs(); i != e; ++i)
- Writer.AddSourceLocation(Locs[i], Record);
+ Record.AddSourceLocation(Locs[i]);
Code = serialization::EXPR_OBJC_MESSAGE_EXPR;
}
void ASTStmtWriter::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
VisitStmt(S);
- Writer.AddStmt(S->getElement());
- Writer.AddStmt(S->getCollection());
- Writer.AddStmt(S->getBody());
- Writer.AddSourceLocation(S->getForLoc(), Record);
- Writer.AddSourceLocation(S->getRParenLoc(), Record);
+ Record.AddStmt(S->getElement());
+ Record.AddStmt(S->getCollection());
+ Record.AddStmt(S->getBody());
+ Record.AddSourceLocation(S->getForLoc());
+ Record.AddSourceLocation(S->getRParenLoc());
Code = serialization::STMT_OBJC_FOR_COLLECTION;
}
void ASTStmtWriter::VisitObjCAtCatchStmt(ObjCAtCatchStmt *S) {
- Writer.AddStmt(S->getCatchBody());
- Writer.AddDeclRef(S->getCatchParamDecl(), Record);
- Writer.AddSourceLocation(S->getAtCatchLoc(), Record);
- Writer.AddSourceLocation(S->getRParenLoc(), Record);
+ Record.AddStmt(S->getCatchBody());
+ Record.AddDeclRef(S->getCatchParamDecl());
+ Record.AddSourceLocation(S->getAtCatchLoc());
+ Record.AddSourceLocation(S->getRParenLoc());
Code = serialization::STMT_OBJC_CATCH;
}
void ASTStmtWriter::VisitObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
- Writer.AddStmt(S->getFinallyBody());
- Writer.AddSourceLocation(S->getAtFinallyLoc(), Record);
+ Record.AddStmt(S->getFinallyBody());
+ Record.AddSourceLocation(S->getAtFinallyLoc());
Code = serialization::STMT_OBJC_FINALLY;
}
void ASTStmtWriter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *S) {
- Writer.AddStmt(S->getSubStmt());
- Writer.AddSourceLocation(S->getAtLoc(), Record);
+ Record.AddStmt(S->getSubStmt());
+ Record.AddSourceLocation(S->getAtLoc());
Code = serialization::STMT_OBJC_AUTORELEASE_POOL;
}
void ASTStmtWriter::VisitObjCAtTryStmt(ObjCAtTryStmt *S) {
Record.push_back(S->getNumCatchStmts());
Record.push_back(S->getFinallyStmt() != nullptr);
- Writer.AddStmt(S->getTryBody());
+ Record.AddStmt(S->getTryBody());
for (unsigned I = 0, N = S->getNumCatchStmts(); I != N; ++I)
- Writer.AddStmt(S->getCatchStmt(I));
+ Record.AddStmt(S->getCatchStmt(I));
if (S->getFinallyStmt())
- Writer.AddStmt(S->getFinallyStmt());
- Writer.AddSourceLocation(S->getAtTryLoc(), Record);
+ Record.AddStmt(S->getFinallyStmt());
+ Record.AddSourceLocation(S->getAtTryLoc());
Code = serialization::STMT_OBJC_AT_TRY;
}
void ASTStmtWriter::VisitObjCAtSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
- Writer.AddStmt(S->getSynchExpr());
- Writer.AddStmt(S->getSynchBody());
- Writer.AddSourceLocation(S->getAtSynchronizedLoc(), Record);
+ Record.AddStmt(S->getSynchExpr());
+ Record.AddStmt(S->getSynchBody());
+ Record.AddSourceLocation(S->getAtSynchronizedLoc());
Code = serialization::STMT_OBJC_AT_SYNCHRONIZED;
}
void ASTStmtWriter::VisitObjCAtThrowStmt(ObjCAtThrowStmt *S) {
- Writer.AddStmt(S->getThrowExpr());
- Writer.AddSourceLocation(S->getThrowLoc(), Record);
+ Record.AddStmt(S->getThrowExpr());
+ Record.AddSourceLocation(S->getThrowLoc());
Code = serialization::STMT_OBJC_AT_THROW;
}
void ASTStmtWriter::VisitObjCBoolLiteralExpr(ObjCBoolLiteralExpr *E) {
VisitExpr(E);
Record.push_back(E->getValue());
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddSourceLocation(E->getLocation());
Code = serialization::EXPR_OBJC_BOOL_LITERAL;
}
+void ASTStmtWriter::VisitObjCAvailabilityCheckExpr(ObjCAvailabilityCheckExpr *E) {
+ VisitExpr(E);
+ Record.AddSourceRange(E->getSourceRange());
+ Record.AddVersionTuple(E->getVersion());
+ Code = serialization::EXPR_OBJC_AVAILABILITY_CHECK;
+}
+
//===----------------------------------------------------------------------===//
// C++ Expressions and Statements.
//===----------------------------------------------------------------------===//
void ASTStmtWriter::VisitCXXCatchStmt(CXXCatchStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getCatchLoc(), Record);
- Writer.AddDeclRef(S->getExceptionDecl(), Record);
- Writer.AddStmt(S->getHandlerBlock());
+ Record.AddSourceLocation(S->getCatchLoc());
+ Record.AddDeclRef(S->getExceptionDecl());
+ Record.AddStmt(S->getHandlerBlock());
Code = serialization::STMT_CXX_CATCH;
}
void ASTStmtWriter::VisitCXXTryStmt(CXXTryStmt *S) {
VisitStmt(S);
Record.push_back(S->getNumHandlers());
- Writer.AddSourceLocation(S->getTryLoc(), Record);
- Writer.AddStmt(S->getTryBlock());
+ Record.AddSourceLocation(S->getTryLoc());
+ Record.AddStmt(S->getTryBlock());
for (unsigned i = 0, e = S->getNumHandlers(); i != e; ++i)
- Writer.AddStmt(S->getHandler(i));
+ Record.AddStmt(S->getHandler(i));
Code = serialization::STMT_CXX_TRY;
}
void ASTStmtWriter::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getForLoc(), Record);
- Writer.AddSourceLocation(S->getCoawaitLoc(), Record);
- Writer.AddSourceLocation(S->getColonLoc(), Record);
- Writer.AddSourceLocation(S->getRParenLoc(), Record);
- Writer.AddStmt(S->getRangeStmt());
- Writer.AddStmt(S->getBeginEndStmt());
- Writer.AddStmt(S->getCond());
- Writer.AddStmt(S->getInc());
- Writer.AddStmt(S->getLoopVarStmt());
- Writer.AddStmt(S->getBody());
+ Record.AddSourceLocation(S->getForLoc());
+ Record.AddSourceLocation(S->getCoawaitLoc());
+ Record.AddSourceLocation(S->getColonLoc());
+ Record.AddSourceLocation(S->getRParenLoc());
+ Record.AddStmt(S->getRangeStmt());
+ Record.AddStmt(S->getBeginStmt());
+ Record.AddStmt(S->getEndStmt());
+ Record.AddStmt(S->getCond());
+ Record.AddStmt(S->getInc());
+ Record.AddStmt(S->getLoopVarStmt());
+ Record.AddStmt(S->getBody());
Code = serialization::STMT_CXX_FOR_RANGE;
}
void ASTStmtWriter::VisitMSDependentExistsStmt(MSDependentExistsStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getKeywordLoc(), Record);
+ Record.AddSourceLocation(S->getKeywordLoc());
Record.push_back(S->isIfExists());
- Writer.AddNestedNameSpecifierLoc(S->getQualifierLoc(), Record);
- Writer.AddDeclarationNameInfo(S->getNameInfo(), Record);
- Writer.AddStmt(S->getSubStmt());
+ Record.AddNestedNameSpecifierLoc(S->getQualifierLoc());
+ Record.AddDeclarationNameInfo(S->getNameInfo());
+ Record.AddStmt(S->getSubStmt());
Code = serialization::STMT_MS_DEPENDENT_EXISTS;
}
void ASTStmtWriter::VisitCXXOperatorCallExpr(CXXOperatorCallExpr *E) {
VisitCallExpr(E);
Record.push_back(E->getOperator());
- Writer.AddSourceRange(E->Range, Record);
+ Record.AddSourceRange(E->Range);
Record.push_back(E->isFPContractable());
Code = serialization::EXPR_CXX_OPERATOR_CALL;
}
@@ -1196,22 +1214,31 @@ void ASTStmtWriter::VisitCXXConstructExpr(CXXConstructExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumArgs());
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- Writer.AddStmt(E->getArg(I));
- Writer.AddDeclRef(E->getConstructor(), Record);
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddStmt(E->getArg(I));
+ Record.AddDeclRef(E->getConstructor());
+ Record.AddSourceLocation(E->getLocation());
Record.push_back(E->isElidable());
Record.push_back(E->hadMultipleCandidates());
Record.push_back(E->isListInitialization());
Record.push_back(E->isStdInitListInitialization());
Record.push_back(E->requiresZeroInitialization());
Record.push_back(E->getConstructionKind()); // FIXME: stable encoding
- Writer.AddSourceRange(E->getParenOrBraceRange(), Record);
+ Record.AddSourceRange(E->getParenOrBraceRange());
Code = serialization::EXPR_CXX_CONSTRUCT;
}
+void ASTStmtWriter::VisitCXXInheritedCtorInitExpr(CXXInheritedCtorInitExpr *E) {
+ VisitExpr(E);
+ Record.AddDeclRef(E->getConstructor());
+ Record.AddSourceLocation(E->getLocation());
+ Record.push_back(E->constructsVBase());
+ Record.push_back(E->inheritedFromVBase());
+ Code = serialization::EXPR_CXX_INHERITED_CTOR_INIT;
+}
+
void ASTStmtWriter::VisitCXXTemporaryObjectExpr(CXXTemporaryObjectExpr *E) {
VisitCXXConstructExpr(E);
- Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
+ Record.AddTypeSourceInfo(E->getTypeSourceInfo());
Code = serialization::EXPR_CXX_TEMPORARY_OBJECT;
}
@@ -1222,18 +1249,18 @@ void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
if (E->HasArrayIndexVars)
NumArrayIndexVars = E->getArrayIndexStarts()[E->NumCaptures];
Record.push_back(NumArrayIndexVars);
- Writer.AddSourceRange(E->IntroducerRange, Record);
+ Record.AddSourceRange(E->IntroducerRange);
Record.push_back(E->CaptureDefault); // FIXME: stable encoding
- Writer.AddSourceLocation(E->CaptureDefaultLoc, Record);
+ Record.AddSourceLocation(E->CaptureDefaultLoc);
Record.push_back(E->ExplicitParams);
Record.push_back(E->ExplicitResultType);
- Writer.AddSourceLocation(E->ClosingBrace, Record);
+ Record.AddSourceLocation(E->ClosingBrace);
// Add capture initializers.
for (LambdaExpr::capture_init_iterator C = E->capture_init_begin(),
CEnd = E->capture_init_end();
C != CEnd; ++C) {
- Writer.AddStmt(*C);
+ Record.AddStmt(*C);
}
// Add array index variables, if any.
@@ -1242,7 +1269,7 @@ void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
E->getArrayIndexStarts() + E->NumCaptures + 1);
VarDecl **ArrayIndexVars = E->getArrayIndexVars();
for (unsigned I = 0; I != NumArrayIndexVars; ++I)
- Writer.AddDeclRef(ArrayIndexVars[I], Record);
+ Record.AddDeclRef(ArrayIndexVars[I]);
}
Code = serialization::EXPR_LAMBDA;
@@ -1250,15 +1277,14 @@ void ASTStmtWriter::VisitLambdaExpr(LambdaExpr *E) {
void ASTStmtWriter::VisitCXXStdInitializerListExpr(CXXStdInitializerListExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSubExpr());
+ Record.AddStmt(E->getSubExpr());
Code = serialization::EXPR_CXX_STD_INITIALIZER_LIST;
}
void ASTStmtWriter::VisitCXXNamedCastExpr(CXXNamedCastExpr *E) {
VisitExplicitCastExpr(E);
- Writer.AddSourceRange(SourceRange(E->getOperatorLoc(), E->getRParenLoc()),
- Record);
- Writer.AddSourceRange(E->getAngleBrackets(), Record);
+ Record.AddSourceRange(SourceRange(E->getOperatorLoc(), E->getRParenLoc()));
+ Record.AddSourceRange(E->getAngleBrackets());
}
void ASTStmtWriter::VisitCXXStaticCastExpr(CXXStaticCastExpr *E) {
@@ -1283,82 +1309,82 @@ void ASTStmtWriter::VisitCXXConstCastExpr(CXXConstCastExpr *E) {
void ASTStmtWriter::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr *E) {
VisitExplicitCastExpr(E);
- Writer.AddSourceLocation(E->getLParenLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddSourceLocation(E->getLParenLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_CXX_FUNCTIONAL_CAST;
}
void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
VisitCallExpr(E);
- Writer.AddSourceLocation(E->UDSuffixLoc, Record);
+ Record.AddSourceLocation(E->UDSuffixLoc);
Code = serialization::EXPR_USER_DEFINED_LITERAL;
}
void ASTStmtWriter::VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E) {
VisitExpr(E);
Record.push_back(E->getValue());
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddSourceLocation(E->getLocation());
Code = serialization::EXPR_CXX_BOOL_LITERAL;
}
void ASTStmtWriter::VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddSourceLocation(E->getLocation());
Code = serialization::EXPR_CXX_NULL_PTR_LITERAL;
}
void ASTStmtWriter::VisitCXXTypeidExpr(CXXTypeidExpr *E) {
VisitExpr(E);
- Writer.AddSourceRange(E->getSourceRange(), Record);
+ Record.AddSourceRange(E->getSourceRange());
if (E->isTypeOperand()) {
- Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
+ Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
Code = serialization::EXPR_CXX_TYPEID_TYPE;
} else {
- Writer.AddStmt(E->getExprOperand());
+ Record.AddStmt(E->getExprOperand());
Code = serialization::EXPR_CXX_TYPEID_EXPR;
}
}
void ASTStmtWriter::VisitCXXThisExpr(CXXThisExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddSourceLocation(E->getLocation());
Record.push_back(E->isImplicit());
Code = serialization::EXPR_CXX_THIS;
}
void ASTStmtWriter::VisitCXXThrowExpr(CXXThrowExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getThrowLoc(), Record);
- Writer.AddStmt(E->getSubExpr());
+ Record.AddSourceLocation(E->getThrowLoc());
+ Record.AddStmt(E->getSubExpr());
Record.push_back(E->isThrownVariableInScope());
Code = serialization::EXPR_CXX_THROW;
}
void ASTStmtWriter::VisitCXXDefaultArgExpr(CXXDefaultArgExpr *E) {
VisitExpr(E);
- Writer.AddDeclRef(E->getParam(), Record);
- Writer.AddSourceLocation(E->getUsedLocation(), Record);
+ Record.AddDeclRef(E->getParam());
+ Record.AddSourceLocation(E->getUsedLocation());
Code = serialization::EXPR_CXX_DEFAULT_ARG;
}
void ASTStmtWriter::VisitCXXDefaultInitExpr(CXXDefaultInitExpr *E) {
VisitExpr(E);
- Writer.AddDeclRef(E->getField(), Record);
- Writer.AddSourceLocation(E->getExprLoc(), Record);
+ Record.AddDeclRef(E->getField());
+ Record.AddSourceLocation(E->getExprLoc());
Code = serialization::EXPR_CXX_DEFAULT_INIT;
}
void ASTStmtWriter::VisitCXXBindTemporaryExpr(CXXBindTemporaryExpr *E) {
VisitExpr(E);
- Writer.AddCXXTemporary(E->getTemporary(), Record);
- Writer.AddStmt(E->getSubExpr());
+ Record.AddCXXTemporary(E->getTemporary());
+ Record.AddStmt(E->getSubExpr());
Code = serialization::EXPR_CXX_BIND_TEMPORARY;
}
void ASTStmtWriter::VisitCXXScalarValueInitExpr(CXXScalarValueInitExpr *E) {
VisitExpr(E);
- Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddTypeSourceInfo(E->getTypeSourceInfo());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_CXX_SCALAR_VALUE_INIT;
}
@@ -1369,15 +1395,15 @@ void ASTStmtWriter::VisitCXXNewExpr(CXXNewExpr *E) {
Record.push_back(E->doesUsualArrayDeleteWantSize());
Record.push_back(E->getNumPlacementArgs());
Record.push_back(E->StoredInitializationStyle);
- Writer.AddDeclRef(E->getOperatorNew(), Record);
- Writer.AddDeclRef(E->getOperatorDelete(), Record);
- Writer.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo(), Record);
- Writer.AddSourceRange(E->getTypeIdParens(), Record);
- Writer.AddSourceRange(E->getSourceRange(), Record);
- Writer.AddSourceRange(E->getDirectInitRange(), Record);
+ Record.AddDeclRef(E->getOperatorNew());
+ Record.AddDeclRef(E->getOperatorDelete());
+ Record.AddTypeSourceInfo(E->getAllocatedTypeSourceInfo());
+ Record.AddSourceRange(E->getTypeIdParens());
+ Record.AddSourceRange(E->getSourceRange());
+ Record.AddSourceRange(E->getDirectInitRange());
for (CXXNewExpr::arg_iterator I = E->raw_arg_begin(), e = E->raw_arg_end();
I != e; ++I)
- Writer.AddStmt(*I);
+ Record.AddStmt(*I);
Code = serialization::EXPR_CXX_NEW;
}
@@ -1388,9 +1414,9 @@ void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
Record.push_back(E->isArrayForm());
Record.push_back(E->isArrayFormAsWritten());
Record.push_back(E->doesUsualArrayDeleteWantSize());
- Writer.AddDeclRef(E->getOperatorDelete(), Record);
- Writer.AddStmt(E->getArgument());
- Writer.AddSourceLocation(E->getSourceRange().getBegin(), Record);
+ Record.AddDeclRef(E->getOperatorDelete());
+ Record.AddStmt(E->getArgument());
+ Record.AddSourceLocation(E->getSourceRange().getBegin());
Code = serialization::EXPR_CXX_DELETE;
}
@@ -1398,20 +1424,20 @@ void ASTStmtWriter::VisitCXXDeleteExpr(CXXDeleteExpr *E) {
void ASTStmtWriter::VisitCXXPseudoDestructorExpr(CXXPseudoDestructorExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getBase());
+ Record.AddStmt(E->getBase());
Record.push_back(E->isArrow());
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
- Writer.AddTypeSourceInfo(E->getScopeTypeInfo(), Record);
- Writer.AddSourceLocation(E->getColonColonLoc(), Record);
- Writer.AddSourceLocation(E->getTildeLoc(), Record);
+ Record.AddSourceLocation(E->getOperatorLoc());
+ Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
+ Record.AddTypeSourceInfo(E->getScopeTypeInfo());
+ Record.AddSourceLocation(E->getColonColonLoc());
+ Record.AddSourceLocation(E->getTildeLoc());
// PseudoDestructorTypeStorage.
- Writer.AddIdentifierRef(E->getDestroyedTypeIdentifier(), Record);
+ Record.AddIdentifierRef(E->getDestroyedTypeIdentifier());
if (E->getDestroyedTypeIdentifier())
- Writer.AddSourceLocation(E->getDestroyedTypeLoc(), Record);
+ Record.AddSourceLocation(E->getDestroyedTypeLoc());
else
- Writer.AddTypeSourceInfo(E->getDestroyedTypeInfo(), Record);
+ Record.AddTypeSourceInfo(E->getDestroyedTypeInfo());
Code = serialization::EXPR_CXX_PSEUDO_DESTRUCTOR;
}
@@ -1420,9 +1446,10 @@ void ASTStmtWriter::VisitExprWithCleanups(ExprWithCleanups *E) {
VisitExpr(E);
Record.push_back(E->getNumObjects());
for (unsigned i = 0, e = E->getNumObjects(); i != e; ++i)
- Writer.AddDeclRef(E->getObject(i), Record);
-
- Writer.AddStmt(E->getSubExpr());
+ Record.AddDeclRef(E->getObject(i));
+
+ Record.push_back(E->cleanupsHaveSideEffects());
+ Record.AddStmt(E->getSubExpr());
Code = serialization::EXPR_EXPR_WITH_CLEANUPS;
}
@@ -1443,15 +1470,15 @@ ASTStmtWriter::VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E){
}
if (!E->isImplicitAccess())
- Writer.AddStmt(E->getBase());
+ Record.AddStmt(E->getBase());
else
- Writer.AddStmt(nullptr);
- Writer.AddTypeRef(E->getBaseType(), Record);
+ Record.AddStmt(nullptr);
+ Record.AddTypeRef(E->getBaseType());
Record.push_back(E->isArrow());
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
- Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
- Writer.AddDeclRef(E->getFirstQualifierFoundInScope(), Record);
- Writer.AddDeclarationNameInfo(E->MemberNameInfo, Record);
+ Record.AddSourceLocation(E->getOperatorLoc());
+ Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
+ Record.AddDeclRef(E->getFirstQualifierFoundInScope());
+ Record.AddDeclarationNameInfo(E->MemberNameInfo);
Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_MEMBER;
}
@@ -1471,8 +1498,8 @@ ASTStmtWriter::VisitDependentScopeDeclRefExpr(DependentScopeDeclRefExpr *E) {
E->getTrailingObjects<TemplateArgumentLoc>());
}
- Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
- Writer.AddDeclarationNameInfo(E->NameInfo, Record);
+ Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
+ Record.AddDeclarationNameInfo(E->NameInfo);
Code = serialization::EXPR_CXX_DEPENDENT_SCOPE_DECL_REF;
}
@@ -1482,10 +1509,10 @@ ASTStmtWriter::VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *E) {
Record.push_back(E->arg_size());
for (CXXUnresolvedConstructExpr::arg_iterator
ArgI = E->arg_begin(), ArgE = E->arg_end(); ArgI != ArgE; ++ArgI)
- Writer.AddStmt(*ArgI);
- Writer.AddTypeSourceInfo(E->getTypeSourceInfo(), Record);
- Writer.AddSourceLocation(E->getLParenLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
+ Record.AddStmt(*ArgI);
+ Record.AddTypeSourceInfo(E->getTypeSourceInfo());
+ Record.AddSourceLocation(E->getLParenLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
Code = serialization::EXPR_CXX_UNRESOLVED_CONSTRUCT;
}
@@ -1506,21 +1533,21 @@ void ASTStmtWriter::VisitOverloadExpr(OverloadExpr *E) {
Record.push_back(E->getNumDecls());
for (OverloadExpr::decls_iterator
OvI = E->decls_begin(), OvE = E->decls_end(); OvI != OvE; ++OvI) {
- Writer.AddDeclRef(OvI.getDecl(), Record);
+ Record.AddDeclRef(OvI.getDecl());
Record.push_back(OvI.getAccess());
}
- Writer.AddDeclarationNameInfo(E->NameInfo, Record);
- Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
+ Record.AddDeclarationNameInfo(E->NameInfo);
+ Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
}
void ASTStmtWriter::VisitUnresolvedMemberExpr(UnresolvedMemberExpr *E) {
VisitOverloadExpr(E);
Record.push_back(E->isArrow());
Record.push_back(E->hasUnresolvedUsing());
- Writer.AddStmt(!E->isImplicitAccess() ? E->getBase() : nullptr);
- Writer.AddTypeRef(E->getBaseType(), Record);
- Writer.AddSourceLocation(E->getOperatorLoc(), Record);
+ Record.AddStmt(!E->isImplicitAccess() ? E->getBase() : nullptr);
+ Record.AddTypeRef(E->getBaseType());
+ Record.AddSourceLocation(E->getOperatorLoc());
Code = serialization::EXPR_CXX_UNRESOLVED_MEMBER;
}
@@ -1528,7 +1555,7 @@ void ASTStmtWriter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
VisitOverloadExpr(E);
Record.push_back(E->requiresADL());
Record.push_back(E->isOverloaded());
- Writer.AddDeclRef(E->getNamingClass(), Record);
+ Record.AddDeclRef(E->getNamingClass());
Code = serialization::EXPR_CXX_UNRESOLVED_LOOKUP;
}
@@ -1537,9 +1564,9 @@ void ASTStmtWriter::VisitTypeTraitExpr(TypeTraitExpr *E) {
Record.push_back(E->TypeTraitExprBits.NumArgs);
Record.push_back(E->TypeTraitExprBits.Kind); // FIXME: Stable encoding
Record.push_back(E->TypeTraitExprBits.Value);
- Writer.AddSourceRange(E->getSourceRange(), Record);
+ Record.AddSourceRange(E->getSourceRange());
for (unsigned I = 0, N = E->getNumArgs(); I != N; ++I)
- Writer.AddTypeSourceInfo(E->getArg(I), Record);
+ Record.AddTypeSourceInfo(E->getArg(I));
Code = serialization::EXPR_TYPE_TRAIT;
}
@@ -1547,8 +1574,8 @@ void ASTStmtWriter::VisitArrayTypeTraitExpr(ArrayTypeTraitExpr *E) {
VisitExpr(E);
Record.push_back(E->getTrait());
Record.push_back(E->getValue());
- Writer.AddSourceRange(E->getSourceRange(), Record);
- Writer.AddTypeSourceInfo(E->getQueriedTypeSourceInfo(), Record);
+ Record.AddSourceRange(E->getSourceRange());
+ Record.AddTypeSourceInfo(E->getQueriedTypeSourceInfo());
Code = serialization::EXPR_ARRAY_TYPE_TRAIT;
}
@@ -1556,24 +1583,24 @@ void ASTStmtWriter::VisitExpressionTraitExpr(ExpressionTraitExpr *E) {
VisitExpr(E);
Record.push_back(E->getTrait());
Record.push_back(E->getValue());
- Writer.AddSourceRange(E->getSourceRange(), Record);
- Writer.AddStmt(E->getQueriedExpression());
+ Record.AddSourceRange(E->getSourceRange());
+ Record.AddStmt(E->getQueriedExpression());
Code = serialization::EXPR_CXX_EXPRESSION_TRAIT;
}
void ASTStmtWriter::VisitCXXNoexceptExpr(CXXNoexceptExpr *E) {
VisitExpr(E);
Record.push_back(E->getValue());
- Writer.AddSourceRange(E->getSourceRange(), Record);
- Writer.AddStmt(E->getOperand());
+ Record.AddSourceRange(E->getSourceRange());
+ Record.AddStmt(E->getOperand());
Code = serialization::EXPR_CXX_NOEXCEPT;
}
void ASTStmtWriter::VisitPackExpansionExpr(PackExpansionExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getEllipsisLoc(), Record);
+ Record.AddSourceLocation(E->getEllipsisLoc());
Record.push_back(E->NumExpansions);
- Writer.AddStmt(E->getPattern());
+ Record.AddStmt(E->getPattern());
Code = serialization::EXPR_PACK_EXPANSION;
}
@@ -1581,13 +1608,13 @@ void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
VisitExpr(E);
Record.push_back(E->isPartiallySubstituted() ? E->getPartialArguments().size()
: 0);
- Writer.AddSourceLocation(E->OperatorLoc, Record);
- Writer.AddSourceLocation(E->PackLoc, Record);
- Writer.AddSourceLocation(E->RParenLoc, Record);
- Writer.AddDeclRef(E->Pack, Record);
+ Record.AddSourceLocation(E->OperatorLoc);
+ Record.AddSourceLocation(E->PackLoc);
+ Record.AddSourceLocation(E->RParenLoc);
+ Record.AddDeclRef(E->Pack);
if (E->isPartiallySubstituted()) {
for (const auto &TA : E->getPartialArguments())
- Writer.AddTemplateArgument(TA, Record);
+ Record.AddTemplateArgument(TA);
} else if (!E->isValueDependent()) {
Record.push_back(E->getPackLength());
}
@@ -1597,62 +1624,62 @@ void ASTStmtWriter::VisitSizeOfPackExpr(SizeOfPackExpr *E) {
void ASTStmtWriter::VisitSubstNonTypeTemplateParmExpr(
SubstNonTypeTemplateParmExpr *E) {
VisitExpr(E);
- Writer.AddDeclRef(E->getParameter(), Record);
- Writer.AddSourceLocation(E->getNameLoc(), Record);
- Writer.AddStmt(E->getReplacement());
+ Record.AddDeclRef(E->getParameter());
+ Record.AddSourceLocation(E->getNameLoc());
+ Record.AddStmt(E->getReplacement());
Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM;
}
void ASTStmtWriter::VisitSubstNonTypeTemplateParmPackExpr(
SubstNonTypeTemplateParmPackExpr *E) {
VisitExpr(E);
- Writer.AddDeclRef(E->getParameterPack(), Record);
- Writer.AddTemplateArgument(E->getArgumentPack(), Record);
- Writer.AddSourceLocation(E->getParameterPackLocation(), Record);
+ Record.AddDeclRef(E->getParameterPack());
+ Record.AddTemplateArgument(E->getArgumentPack());
+ Record.AddSourceLocation(E->getParameterPackLocation());
Code = serialization::EXPR_SUBST_NON_TYPE_TEMPLATE_PARM_PACK;
}
void ASTStmtWriter::VisitFunctionParmPackExpr(FunctionParmPackExpr *E) {
VisitExpr(E);
Record.push_back(E->getNumExpansions());
- Writer.AddDeclRef(E->getParameterPack(), Record);
- Writer.AddSourceLocation(E->getParameterPackLocation(), Record);
+ Record.AddDeclRef(E->getParameterPack());
+ Record.AddSourceLocation(E->getParameterPackLocation());
for (FunctionParmPackExpr::iterator I = E->begin(), End = E->end();
I != End; ++I)
- Writer.AddDeclRef(*I, Record);
+ Record.AddDeclRef(*I);
Code = serialization::EXPR_FUNCTION_PARM_PACK;
}
void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getTemporary());
- Writer.AddDeclRef(E->getExtendingDecl(), Record);
+ Record.AddStmt(E->getTemporary());
+ Record.AddDeclRef(E->getExtendingDecl());
Record.push_back(E->getManglingNumber());
Code = serialization::EXPR_MATERIALIZE_TEMPORARY;
}
void ASTStmtWriter::VisitCXXFoldExpr(CXXFoldExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->LParenLoc, Record);
- Writer.AddSourceLocation(E->EllipsisLoc, Record);
- Writer.AddSourceLocation(E->RParenLoc, Record);
- Writer.AddStmt(E->SubExprs[0]);
- Writer.AddStmt(E->SubExprs[1]);
+ Record.AddSourceLocation(E->LParenLoc);
+ Record.AddSourceLocation(E->EllipsisLoc);
+ Record.AddSourceLocation(E->RParenLoc);
+ Record.AddStmt(E->SubExprs[0]);
+ Record.AddStmt(E->SubExprs[1]);
Record.push_back(E->Opcode);
Code = serialization::EXPR_CXX_FOLD;
}
void ASTStmtWriter::VisitOpaqueValueExpr(OpaqueValueExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getSourceExpr());
- Writer.AddSourceLocation(E->getLocation(), Record);
+ Record.AddStmt(E->getSourceExpr());
+ Record.AddSourceLocation(E->getLocation());
Code = serialization::EXPR_OPAQUE_VALUE;
}
void ASTStmtWriter::VisitTypoExpr(TypoExpr *E) {
VisitExpr(E);
// TODO: Figure out sane writer behavior for a TypoExpr, if necessary
- assert(false && "Cannot write TypoExpr nodes");
+ llvm_unreachable("Cannot write TypoExpr nodes");
}
//===----------------------------------------------------------------------===//
@@ -1661,7 +1688,7 @@ void ASTStmtWriter::VisitTypoExpr(TypoExpr *E) {
void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
VisitCallExpr(E);
- Writer.AddStmt(E->getConfig());
+ Record.AddStmt(E->getConfig());
Code = serialization::EXPR_CUDA_KERNEL_CALL;
}
@@ -1670,9 +1697,9 @@ void ASTStmtWriter::VisitCUDAKernelCallExpr(CUDAKernelCallExpr *E) {
//===----------------------------------------------------------------------===//
void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) {
VisitExpr(E);
- Writer.AddSourceLocation(E->getBuiltinLoc(), Record);
- Writer.AddSourceLocation(E->getRParenLoc(), Record);
- Writer.AddStmt(E->getSrcExpr());
+ Record.AddSourceLocation(E->getBuiltinLoc());
+ Record.AddSourceLocation(E->getRParenLoc());
+ Record.AddStmt(E->getSrcExpr());
Code = serialization::EXPR_ASTYPE;
}
@@ -1682,60 +1709,61 @@ void ASTStmtWriter::VisitAsTypeExpr(AsTypeExpr *E) {
void ASTStmtWriter::VisitMSPropertyRefExpr(MSPropertyRefExpr *E) {
VisitExpr(E);
Record.push_back(E->isArrow());
- Writer.AddStmt(E->getBaseExpr());
- Writer.AddNestedNameSpecifierLoc(E->getQualifierLoc(), Record);
- Writer.AddSourceLocation(E->getMemberLoc(), Record);
- Writer.AddDeclRef(E->getPropertyDecl(), Record);
+ Record.AddStmt(E->getBaseExpr());
+ Record.AddNestedNameSpecifierLoc(E->getQualifierLoc());
+ Record.AddSourceLocation(E->getMemberLoc());
+ Record.AddDeclRef(E->getPropertyDecl());
Code = serialization::EXPR_CXX_PROPERTY_REF_EXPR;
}
void ASTStmtWriter::VisitMSPropertySubscriptExpr(MSPropertySubscriptExpr *E) {
VisitExpr(E);
- Writer.AddStmt(E->getBase());
- Writer.AddStmt(E->getIdx());
- Writer.AddSourceLocation(E->getRBracketLoc(), Record);
+ Record.AddStmt(E->getBase());
+ Record.AddStmt(E->getIdx());
+ Record.AddSourceLocation(E->getRBracketLoc());
Code = serialization::EXPR_CXX_PROPERTY_SUBSCRIPT_EXPR;
}
void ASTStmtWriter::VisitCXXUuidofExpr(CXXUuidofExpr *E) {
VisitExpr(E);
- Writer.AddSourceRange(E->getSourceRange(), Record);
+ Record.AddSourceRange(E->getSourceRange());
+ Record.AddString(E->getUuidStr());
if (E->isTypeOperand()) {
- Writer.AddTypeSourceInfo(E->getTypeOperandSourceInfo(), Record);
+ Record.AddTypeSourceInfo(E->getTypeOperandSourceInfo());
Code = serialization::EXPR_CXX_UUIDOF_TYPE;
} else {
- Writer.AddStmt(E->getExprOperand());
+ Record.AddStmt(E->getExprOperand());
Code = serialization::EXPR_CXX_UUIDOF_EXPR;
}
}
void ASTStmtWriter::VisitSEHExceptStmt(SEHExceptStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getExceptLoc(), Record);
- Writer.AddStmt(S->getFilterExpr());
- Writer.AddStmt(S->getBlock());
+ Record.AddSourceLocation(S->getExceptLoc());
+ Record.AddStmt(S->getFilterExpr());
+ Record.AddStmt(S->getBlock());
Code = serialization::STMT_SEH_EXCEPT;
}
void ASTStmtWriter::VisitSEHFinallyStmt(SEHFinallyStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getFinallyLoc(), Record);
- Writer.AddStmt(S->getBlock());
+ Record.AddSourceLocation(S->getFinallyLoc());
+ Record.AddStmt(S->getBlock());
Code = serialization::STMT_SEH_FINALLY;
}
void ASTStmtWriter::VisitSEHTryStmt(SEHTryStmt *S) {
VisitStmt(S);
Record.push_back(S->getIsCXXTry());
- Writer.AddSourceLocation(S->getTryLoc(), Record);
- Writer.AddStmt(S->getTryBlock());
- Writer.AddStmt(S->getHandler());
+ Record.AddSourceLocation(S->getTryLoc());
+ Record.AddStmt(S->getTryBlock());
+ Record.AddStmt(S->getHandler());
Code = serialization::STMT_SEH_TRY;
}
void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
VisitStmt(S);
- Writer.AddSourceLocation(S->getLeaveLoc(), Record);
+ Record.AddSourceLocation(S->getLeaveLoc());
Code = serialization::STMT_SEH_LEAVE;
}
@@ -1745,86 +1773,95 @@ void ASTStmtWriter::VisitSEHLeaveStmt(SEHLeaveStmt *S) {
namespace clang {
class OMPClauseWriter : public OMPClauseVisitor<OMPClauseWriter> {
- ASTStmtWriter *Writer;
- ASTWriter::RecordData &Record;
+ ASTRecordWriter &Record;
public:
- OMPClauseWriter(ASTStmtWriter *W, ASTWriter::RecordData &Record)
- : Writer(W), Record(Record) { }
+ OMPClauseWriter(ASTRecordWriter &Record) : Record(Record) {}
#define OPENMP_CLAUSE(Name, Class) \
void Visit##Class(Class *S);
#include "clang/Basic/OpenMPKinds.def"
void writeClause(OMPClause *C);
+ void VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C);
+ void VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C);
};
}
void OMPClauseWriter::writeClause(OMPClause *C) {
Record.push_back(C->getClauseKind());
Visit(C);
- Writer->Writer.AddSourceLocation(C->getLocStart(), Record);
- Writer->Writer.AddSourceLocation(C->getLocEnd(), Record);
+ Record.AddSourceLocation(C->getLocStart());
+ Record.AddSourceLocation(C->getLocEnd());
+}
+
+void OMPClauseWriter::VisitOMPClauseWithPreInit(OMPClauseWithPreInit *C) {
+ Record.AddStmt(C->getPreInitStmt());
+}
+
+void OMPClauseWriter::VisitOMPClauseWithPostUpdate(OMPClauseWithPostUpdate *C) {
+ VisitOMPClauseWithPreInit(C);
+ Record.AddStmt(C->getPostUpdateExpr());
}
void OMPClauseWriter::VisitOMPIfClause(OMPIfClause *C) {
Record.push_back(C->getNameModifier());
- Writer->Writer.AddSourceLocation(C->getNameModifierLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
- Writer->Writer.AddStmt(C->getCondition());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddSourceLocation(C->getNameModifierLoc());
+ Record.AddSourceLocation(C->getColonLoc());
+ Record.AddStmt(C->getCondition());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPFinalClause(OMPFinalClause *C) {
- Writer->Writer.AddStmt(C->getCondition());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getCondition());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPNumThreadsClause(OMPNumThreadsClause *C) {
- Writer->Writer.AddStmt(C->getNumThreads());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getNumThreads());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPSafelenClause(OMPSafelenClause *C) {
- Writer->Writer.AddStmt(C->getSafelen());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getSafelen());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPSimdlenClause(OMPSimdlenClause *C) {
- Writer->Writer.AddStmt(C->getSimdlen());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getSimdlen());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPCollapseClause(OMPCollapseClause *C) {
- Writer->Writer.AddStmt(C->getNumForLoops());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getNumForLoops());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPDefaultClause(OMPDefaultClause *C) {
Record.push_back(C->getDefaultKind());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getDefaultKindKwLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getDefaultKindKwLoc());
}
void OMPClauseWriter::VisitOMPProcBindClause(OMPProcBindClause *C) {
Record.push_back(C->getProcBindKind());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getProcBindKindKwLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getProcBindKindKwLoc());
}
void OMPClauseWriter::VisitOMPScheduleClause(OMPScheduleClause *C) {
+ VisitOMPClauseWithPreInit(C);
Record.push_back(C->getScheduleKind());
Record.push_back(C->getFirstScheduleModifier());
Record.push_back(C->getSecondScheduleModifier());
- Writer->Writer.AddStmt(C->getChunkSize());
- Writer->Writer.AddStmt(C->getHelperChunkSize());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getFirstScheduleModifierLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getSecondScheduleModifierLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getScheduleKindLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getCommaLoc(), Record);
+ Record.AddStmt(C->getChunkSize());
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getFirstScheduleModifierLoc());
+ Record.AddSourceLocation(C->getSecondScheduleModifierLoc());
+ Record.AddSourceLocation(C->getScheduleKindLoc());
+ Record.AddSourceLocation(C->getCommaLoc());
}
void OMPClauseWriter::VisitOMPOrderedClause(OMPOrderedClause *C) {
- Writer->Writer.AddStmt(C->getNumForLoops());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getNumForLoops());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPNowaitClause(OMPNowaitClause *) {}
@@ -1851,204 +1888,295 @@ void OMPClauseWriter::VisitOMPNogroupClause(OMPNogroupClause *) {}
void OMPClauseWriter::VisitOMPPrivateClause(OMPPrivateClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
for (auto *VE : C->varlists()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
for (auto *VE : C->private_copies()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
}
void OMPClauseWriter::VisitOMPFirstprivateClause(OMPFirstprivateClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ VisitOMPClauseWithPreInit(C);
+ Record.AddSourceLocation(C->getLParenLoc());
for (auto *VE : C->varlists()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
for (auto *VE : C->private_copies()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
for (auto *VE : C->inits()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
}
void OMPClauseWriter::VisitOMPLastprivateClause(OMPLastprivateClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ VisitOMPClauseWithPostUpdate(C);
+ Record.AddSourceLocation(C->getLParenLoc());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
for (auto *E : C->private_copies())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->source_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->destination_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->assignment_ops())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
}
void OMPClauseWriter::VisitOMPSharedClause(OMPSharedClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
void OMPClauseWriter::VisitOMPReductionClause(OMPReductionClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
- Writer->Writer.AddNestedNameSpecifierLoc(C->getQualifierLoc(), Record);
- Writer->Writer.AddDeclarationNameInfo(C->getNameInfo(), Record);
+ VisitOMPClauseWithPostUpdate(C);
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getColonLoc());
+ Record.AddNestedNameSpecifierLoc(C->getQualifierLoc());
+ Record.AddDeclarationNameInfo(C->getNameInfo());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
for (auto *VE : C->privates())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
for (auto *E : C->lhs_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->rhs_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->reduction_ops())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
}
void OMPClauseWriter::VisitOMPLinearClause(OMPLinearClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
+ VisitOMPClauseWithPostUpdate(C);
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getColonLoc());
Record.push_back(C->getModifier());
- Writer->Writer.AddSourceLocation(C->getModifierLoc(), Record);
+ Record.AddSourceLocation(C->getModifierLoc());
for (auto *VE : C->varlists()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
for (auto *VE : C->privates()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
for (auto *VE : C->inits()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
for (auto *VE : C->updates()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
for (auto *VE : C->finals()) {
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
- Writer->Writer.AddStmt(C->getStep());
- Writer->Writer.AddStmt(C->getCalcStep());
+ Record.AddStmt(C->getStep());
+ Record.AddStmt(C->getCalcStep());
}
void OMPClauseWriter::VisitOMPAlignedClause(OMPAlignedClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getColonLoc());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
- Writer->Writer.AddStmt(C->getAlignment());
+ Record.AddStmt(VE);
+ Record.AddStmt(C->getAlignment());
}
void OMPClauseWriter::VisitOMPCopyinClause(OMPCopyinClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
for (auto *E : C->source_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->destination_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->assignment_ops())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
}
void OMPClauseWriter::VisitOMPCopyprivateClause(OMPCopyprivateClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
for (auto *E : C->source_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->destination_exprs())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
for (auto *E : C->assignment_ops())
- Writer->Writer.AddStmt(E);
+ Record.AddStmt(E);
}
void OMPClauseWriter::VisitOMPFlushClause(OMPFlushClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
}
void OMPClauseWriter::VisitOMPDependClause(OMPDependClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddSourceLocation(C->getLParenLoc());
Record.push_back(C->getDependencyKind());
- Writer->Writer.AddSourceLocation(C->getDependencyLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
+ Record.AddSourceLocation(C->getDependencyLoc());
+ Record.AddSourceLocation(C->getColonLoc());
for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddStmt(VE);
+ Record.AddStmt(C->getCounterValue());
}
void OMPClauseWriter::VisitOMPDeviceClause(OMPDeviceClause *C) {
- Writer->Writer.AddStmt(C->getDevice());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getDevice());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPMapClause(OMPMapClause *C) {
Record.push_back(C->varlist_size());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.push_back(C->getUniqueDeclarationsNum());
+ Record.push_back(C->getTotalComponentListNum());
+ Record.push_back(C->getTotalComponentsNum());
+ Record.AddSourceLocation(C->getLParenLoc());
Record.push_back(C->getMapTypeModifier());
Record.push_back(C->getMapType());
- Writer->Writer.AddSourceLocation(C->getMapLoc(), Record);
- Writer->Writer.AddSourceLocation(C->getColonLoc(), Record);
- for (auto *VE : C->varlists())
- Writer->Writer.AddStmt(VE);
+ Record.AddSourceLocation(C->getMapLoc());
+ Record.AddSourceLocation(C->getColonLoc());
+ 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());
+ }
}
void OMPClauseWriter::VisitOMPNumTeamsClause(OMPNumTeamsClause *C) {
- Writer->Writer.AddStmt(C->getNumTeams());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getNumTeams());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPThreadLimitClause(OMPThreadLimitClause *C) {
- Writer->Writer.AddStmt(C->getThreadLimit());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getThreadLimit());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPPriorityClause(OMPPriorityClause *C) {
- Writer->Writer.AddStmt(C->getPriority());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getPriority());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPGrainsizeClause(OMPGrainsizeClause *C) {
- Writer->Writer.AddStmt(C->getGrainsize());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getGrainsize());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPNumTasksClause(OMPNumTasksClause *C) {
- Writer->Writer.AddStmt(C->getNumTasks());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getNumTasks());
+ Record.AddSourceLocation(C->getLParenLoc());
}
void OMPClauseWriter::VisitOMPHintClause(OMPHintClause *C) {
- Writer->Writer.AddStmt(C->getHint());
- Writer->Writer.AddSourceLocation(C->getLParenLoc(), Record);
+ Record.AddStmt(C->getHint());
+ Record.AddSourceLocation(C->getLParenLoc());
+}
+
+void OMPClauseWriter::VisitOMPDistScheduleClause(OMPDistScheduleClause *C) {
+ VisitOMPClauseWithPreInit(C);
+ Record.push_back(C->getDistScheduleKind());
+ Record.AddStmt(C->getChunkSize());
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getDistScheduleKindLoc());
+ Record.AddSourceLocation(C->getCommaLoc());
+}
+
+void OMPClauseWriter::VisitOMPDefaultmapClause(OMPDefaultmapClause *C) {
+ Record.push_back(C->getDefaultmapKind());
+ Record.push_back(C->getDefaultmapModifier());
+ Record.AddSourceLocation(C->getLParenLoc());
+ Record.AddSourceLocation(C->getDefaultmapModifierLoc());
+ Record.AddSourceLocation(C->getDefaultmapKindLoc());
+}
+
+void OMPClauseWriter::VisitOMPToClause(OMPToClause *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 *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());
+ }
+}
+
+void OMPClauseWriter::VisitOMPFromClause(OMPFromClause *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 *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());
+ }
+}
+
+void OMPClauseWriter::VisitOMPUseDevicePtrClause(OMPUseDevicePtrClause *C) {
+ Record.push_back(C->varlist_size());
+ Record.AddSourceLocation(C->getLParenLoc());
+ for (auto *VE : C->varlists()) {
+ Record.AddStmt(VE);
+ }
+}
+
+void OMPClauseWriter::VisitOMPIsDevicePtrClause(OMPIsDevicePtrClause *C) {
+ Record.push_back(C->varlist_size());
+ Record.AddSourceLocation(C->getLParenLoc());
+ for (auto *VE : C->varlists()) {
+ Record.AddStmt(VE);
+ }
}
//===----------------------------------------------------------------------===//
// OpenMP Directives.
//===----------------------------------------------------------------------===//
void ASTStmtWriter::VisitOMPExecutableDirective(OMPExecutableDirective *E) {
- Writer.AddSourceLocation(E->getLocStart(), Record);
- Writer.AddSourceLocation(E->getLocEnd(), Record);
- OMPClauseWriter ClauseWriter(this, Record);
+ Record.AddSourceLocation(E->getLocStart());
+ Record.AddSourceLocation(E->getLocEnd());
+ OMPClauseWriter ClauseWriter(Record);
for (unsigned i = 0; i < E->getNumClauses(); ++i) {
ClauseWriter.writeClause(E->getClause(i));
}
if (E->hasAssociatedStmt())
- Writer.AddStmt(E->getAssociatedStmt());
+ Record.AddStmt(E->getAssociatedStmt());
}
void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) {
@@ -2056,36 +2184,44 @@ void ASTStmtWriter::VisitOMPLoopDirective(OMPLoopDirective *D) {
Record.push_back(D->getNumClauses());
Record.push_back(D->getCollapsedNumber());
VisitOMPExecutableDirective(D);
- Writer.AddStmt(D->getIterationVariable());
- Writer.AddStmt(D->getLastIteration());
- Writer.AddStmt(D->getCalcLastIteration());
- Writer.AddStmt(D->getPreCond());
- Writer.AddStmt(D->getCond());
- Writer.AddStmt(D->getInit());
- Writer.AddStmt(D->getInc());
- if (isOpenMPWorksharingDirective(D->getDirectiveKind())) {
- Writer.AddStmt(D->getIsLastIterVariable());
- Writer.AddStmt(D->getLowerBoundVariable());
- Writer.AddStmt(D->getUpperBoundVariable());
- Writer.AddStmt(D->getStrideVariable());
- Writer.AddStmt(D->getEnsureUpperBound());
- Writer.AddStmt(D->getNextLowerBound());
- Writer.AddStmt(D->getNextUpperBound());
+ Record.AddStmt(D->getIterationVariable());
+ Record.AddStmt(D->getLastIteration());
+ Record.AddStmt(D->getCalcLastIteration());
+ Record.AddStmt(D->getPreCond());
+ Record.AddStmt(D->getCond());
+ Record.AddStmt(D->getInit());
+ Record.AddStmt(D->getInc());
+ Record.AddStmt(D->getPreInits());
+ if (isOpenMPWorksharingDirective(D->getDirectiveKind()) ||
+ isOpenMPTaskLoopDirective(D->getDirectiveKind()) ||
+ isOpenMPDistributeDirective(D->getDirectiveKind())) {
+ Record.AddStmt(D->getIsLastIterVariable());
+ Record.AddStmt(D->getLowerBoundVariable());
+ Record.AddStmt(D->getUpperBoundVariable());
+ Record.AddStmt(D->getStrideVariable());
+ Record.AddStmt(D->getEnsureUpperBound());
+ Record.AddStmt(D->getNextLowerBound());
+ Record.AddStmt(D->getNextUpperBound());
+ Record.AddStmt(D->getNumIterations());
+ }
+ if (isOpenMPLoopBoundSharingDirective(D->getDirectiveKind())) {
+ Record.AddStmt(D->getPrevLowerBoundVariable());
+ Record.AddStmt(D->getPrevUpperBoundVariable());
}
for (auto I : D->counters()) {
- Writer.AddStmt(I);
+ Record.AddStmt(I);
}
for (auto I : D->private_counters()) {
- Writer.AddStmt(I);
+ Record.AddStmt(I);
}
for (auto I : D->inits()) {
- Writer.AddStmt(I);
+ Record.AddStmt(I);
}
for (auto I : D->updates()) {
- Writer.AddStmt(I);
+ Record.AddStmt(I);
}
for (auto I : D->finals()) {
- Writer.AddStmt(I);
+ Record.AddStmt(I);
}
}
@@ -2145,7 +2281,7 @@ void ASTStmtWriter::VisitOMPCriticalDirective(OMPCriticalDirective *D) {
VisitStmt(D);
Record.push_back(D->getNumClauses());
VisitOMPExecutableDirective(D);
- Writer.AddDeclarationNameInfo(D->getDirectiveName(), Record);
+ Record.AddDeclarationNameInfo(D->getDirectiveName());
Code = serialization::STMT_OMP_CRITICAL_DIRECTIVE;
}
@@ -2182,10 +2318,10 @@ void ASTStmtWriter::VisitOMPAtomicDirective(OMPAtomicDirective *D) {
VisitStmt(D);
Record.push_back(D->getNumClauses());
VisitOMPExecutableDirective(D);
- Writer.AddStmt(D->getX());
- Writer.AddStmt(D->getV());
- Writer.AddStmt(D->getExpr());
- Writer.AddStmt(D->getUpdateExpr());
+ Record.AddStmt(D->getX());
+ Record.AddStmt(D->getV());
+ Record.AddStmt(D->getExpr());
+ Record.AddStmt(D->getUpdateExpr());
Record.push_back(D->isXLHSInRHSPart() ? 1 : 0);
Record.push_back(D->isPostfixUpdate() ? 1 : 0);
Code = serialization::STMT_OMP_ATOMIC_DIRECTIVE;
@@ -2205,6 +2341,37 @@ void ASTStmtWriter::VisitOMPTargetDataDirective(OMPTargetDataDirective *D) {
Code = serialization::STMT_OMP_TARGET_DATA_DIRECTIVE;
}
+void ASTStmtWriter::VisitOMPTargetEnterDataDirective(
+ OMPTargetEnterDataDirective *D) {
+ VisitStmt(D);
+ Record.push_back(D->getNumClauses());
+ VisitOMPExecutableDirective(D);
+ Code = serialization::STMT_OMP_TARGET_ENTER_DATA_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTargetExitDataDirective(
+ OMPTargetExitDataDirective *D) {
+ VisitStmt(D);
+ Record.push_back(D->getNumClauses());
+ VisitOMPExecutableDirective(D);
+ Code = serialization::STMT_OMP_TARGET_EXIT_DATA_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTargetParallelDirective(
+ OMPTargetParallelDirective *D) {
+ VisitStmt(D);
+ Record.push_back(D->getNumClauses());
+ VisitOMPExecutableDirective(D);
+ Code = serialization::STMT_OMP_TARGET_PARALLEL_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTargetParallelForDirective(
+ OMPTargetParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+ Record.push_back(D->hasCancel() ? 1 : 0);
+ Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_DIRECTIVE;
+}
+
void ASTStmtWriter::VisitOMPTaskyieldDirective(OMPTaskyieldDirective *D) {
VisitStmt(D);
VisitOMPExecutableDirective(D);
@@ -2281,6 +2448,37 @@ void ASTStmtWriter::VisitOMPDistributeDirective(OMPDistributeDirective *D) {
Code = serialization::STMT_OMP_DISTRIBUTE_DIRECTIVE;
}
+void ASTStmtWriter::VisitOMPTargetUpdateDirective(OMPTargetUpdateDirective *D) {
+ VisitStmt(D);
+ Record.push_back(D->getNumClauses());
+ VisitOMPExecutableDirective(D);
+ Code = serialization::STMT_OMP_TARGET_UPDATE_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPDistributeParallelForDirective(
+ OMPDistributeParallelForDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPDistributeParallelForSimdDirective(
+ OMPDistributeParallelForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_DISTRIBUTE_PARALLEL_FOR_SIMD_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPDistributeSimdDirective(
+ OMPDistributeSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_DISTRIBUTE_SIMD_DIRECTIVE;
+}
+
+void ASTStmtWriter::VisitOMPTargetParallelForSimdDirective(
+ OMPTargetParallelForSimdDirective *D) {
+ VisitOMPLoopDirective(D);
+ Code = serialization::STMT_OMP_TARGET_PARALLEL_FOR_SIMD_DIRECTIVE;
+}
+
//===----------------------------------------------------------------------===//
// ASTWriter Implementation
//===----------------------------------------------------------------------===//
@@ -2305,9 +2503,7 @@ void ASTWriter::ClearSwitchCaseIDs() {
/// \brief Write the given substatement or subexpression to the
/// bitstream.
-void ASTWriter::WriteSubStmt(Stmt *S,
- llvm::DenseMap<Stmt *, uint64_t> &SubStmtEntries,
- llvm::DenseSet<Stmt *> &ParentStmts) {
+void ASTWriter::WriteSubStmt(Stmt *S) {
RecordData Record;
ASTStmtWriter Writer(*this, Record);
++NumStatements;
@@ -2343,61 +2539,44 @@ void ASTWriter::WriteSubStmt(Stmt *S,
ParentStmtInserterRAII ParentStmtInserter(S, ParentStmts);
#endif
- // Redirect ASTWriter::AddStmt to collect sub-stmts.
- SmallVector<Stmt *, 16> SubStmts;
- CollectedStmts = &SubStmts;
-
- Writer.Code = serialization::STMT_NULL_PTR;
- Writer.AbbrevToUse = 0;
Writer.Visit(S);
-#ifndef NDEBUG
- if (Writer.Code == serialization::STMT_NULL_PTR) {
- SourceManager &SrcMgr
- = DeclIDs.begin()->first->getASTContext().getSourceManager();
- S->dump(SrcMgr);
- llvm_unreachable("Unhandled sub-statement writing AST file");
- }
-#endif
-
- // Revert ASTWriter::AddStmt.
- CollectedStmts = &StmtsToEmit;
-
- // Write the sub-stmts in reverse order, last to first. When reading them back
- // we will read them in correct order by "pop"ing them from the Stmts stack.
- // This simplifies reading and allows to store a variable number of sub-stmts
- // without knowing it in advance.
- while (!SubStmts.empty())
- WriteSubStmt(SubStmts.pop_back_val(), SubStmtEntries, ParentStmts);
-
- Stream.EmitRecord(Writer.Code, Record, Writer.AbbrevToUse);
-
- SubStmtEntries[S] = Stream.GetCurrentBitNo();
+ uint64_t Offset = Writer.Emit();
+ SubStmtEntries[S] = Offset;
}
/// \brief Flush all of the statements that have been added to the
/// queue via AddStmt().
-void ASTWriter::FlushStmts() {
- RecordData Record;
-
+void ASTRecordWriter::FlushStmts() {
// We expect to be the only consumer of the two temporary statement maps,
// assert that they are empty.
- assert(SubStmtEntries.empty() && "unexpected entries in sub-stmt map");
- assert(ParentStmts.empty() && "unexpected entries in parent stmt map");
+ assert(Writer->SubStmtEntries.empty() && "unexpected entries in sub-stmt map");
+ assert(Writer->ParentStmts.empty() && "unexpected entries in parent stmt map");
for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
- WriteSubStmt(StmtsToEmit[I], SubStmtEntries, ParentStmts);
+ Writer->WriteSubStmt(StmtsToEmit[I]);
- assert(N == StmtsToEmit.size() &&
- "Substatement written via AddStmt rather than WriteSubStmt!");
+ assert(N == StmtsToEmit.size() && "record modified while being written!");
// Note that we are at the end of a full expression. Any
// expression records that follow this one are part of a different
// expression.
- Stream.EmitRecord(serialization::STMT_STOP, Record);
+ Writer->Stream.EmitRecord(serialization::STMT_STOP, ArrayRef<uint32_t>());
- SubStmtEntries.clear();
- ParentStmts.clear();
+ Writer->SubStmtEntries.clear();
+ Writer->ParentStmts.clear();
+ }
+
+ StmtsToEmit.clear();
+}
+
+void ASTRecordWriter::FlushSubStmts() {
+ // For a nested statement, write out the substatements in reverse order (so
+ // that a simple stack machine can be used when loading), and don't emit a
+ // STMT_STOP after each one.
+ for (unsigned I = 0, N = StmtsToEmit.size(); I != N; ++I) {
+ Writer->WriteSubStmt(StmtsToEmit[N - I - 1]);
+ assert(N == StmtsToEmit.size() && "record modified while being written!");
}
StmtsToEmit.clear();
diff --git a/lib/Serialization/GeneratePCH.cpp b/lib/Serialization/GeneratePCH.cpp
index 4a2255ab6d39..308fde8b1dd7 100644
--- a/lib/Serialization/GeneratePCH.cpp
+++ b/lib/Serialization/GeneratePCH.cpp
@@ -51,7 +51,10 @@ void PCHGenerator::HandleTranslationUnit(ASTContext &Ctx) {
// Emit the PCH file to the Buffer.
assert(SemaPtr && "No Sema?");
Buffer->Signature =
- Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot, hasErrors);
+ Writer.WriteAST(*SemaPtr, OutputFile, Module, isysroot,
+ // For serialization we are lenient if the errors were
+ // only warn-as-error kind.
+ PP.getDiagnostics().hasUncompilableErrorOccurred());
Buffer->IsComplete = true;
}
diff --git a/lib/Serialization/GlobalModuleIndex.cpp b/lib/Serialization/GlobalModuleIndex.cpp
index af5f94a5cdc4..581e894d9150 100644
--- a/lib/Serialization/GlobalModuleIndex.cpp
+++ b/lib/Serialization/GlobalModuleIndex.cpp
@@ -354,7 +354,7 @@ void GlobalModuleIndex::printStats() {
std::fprintf(stderr, "\n");
}
-void GlobalModuleIndex::dump() {
+LLVM_DUMP_METHOD void GlobalModuleIndex::dump() {
llvm::errs() << "*** Global Module Index Dump:\n";
llvm::errs() << "Module files:\n";
for (auto &MI : Modules) {
diff --git a/lib/Serialization/Makefile b/lib/Serialization/Makefile
deleted file mode 100644
index e89ddc38ec94..000000000000
--- a/lib/Serialization/Makefile
+++ /dev/null
@@ -1,19 +0,0 @@
-##===- clang/lib/Serialization/Makefile --------------------*- Makefile -*-===##
-#
-# The LLVM Compiler Infrastructure
-#
-# This file is distributed under the University of Illinois Open Source
-# License. See LICENSE.TXT for details.
-#
-##===----------------------------------------------------------------------===##
-#
-# This implements the semantic analyzer and AST builder library for the
-# C-Language front-end.
-#
-##===----------------------------------------------------------------------===##
-
-CLANG_LEVEL := ../..
-LIBRARYNAME := clangSerialization
-
-include $(CLANG_LEVEL)/Makefile
-
diff --git a/lib/Serialization/Module.cpp b/lib/Serialization/Module.cpp
index 4884f0b09480..ca0cb3c8ea17 100644
--- a/lib/Serialization/Module.cpp
+++ b/lib/Serialization/Module.cpp
@@ -37,8 +37,6 @@ ModuleFile::ModuleFile(ModuleKind Kind, unsigned Generation)
LocalNumSelectors(0), SelectorOffsets(nullptr), BaseSelectorID(0),
SelectorLookupTableData(nullptr), SelectorLookupTable(nullptr),
LocalNumDecls(0), DeclOffsets(nullptr), BaseDeclID(0),
- LocalNumCXXBaseSpecifiers(0), CXXBaseSpecifiersOffsets(nullptr),
- LocalNumCXXCtorInitializers(0), CXXCtorInitializersOffsets(nullptr),
FileSortedDecls(nullptr), NumFileSortedDecls(0),
ObjCCategoriesMap(nullptr), LocalNumObjCCategoriesInMap(0),
LocalNumTypes(0), TypeOffsets(nullptr), BaseTypeIndex(0)
@@ -65,7 +63,7 @@ dumpLocalRemap(StringRef Name,
}
}
-void ModuleFile::dump() {
+LLVM_DUMP_METHOD void ModuleFile::dump() {
llvm::errs() << "\nModule: " << FileName << "\n";
if (!Imports.empty()) {
llvm::errs() << " Imports: ";
diff --git a/lib/Serialization/ModuleManager.cpp b/lib/Serialization/ModuleManager.cpp
index 74f75a103f7a..292f36dfeb2a 100644
--- a/lib/Serialization/ModuleManager.cpp
+++ b/lib/Serialization/ModuleManager.cpp
@@ -320,11 +320,11 @@ void ModuleManager::visit(llvm::function_ref<bool(ModuleFile &M)> Visitor,
Queue.reserve(N);
llvm::SmallVector<unsigned, 4> UnusedIncomingEdges;
UnusedIncomingEdges.resize(size());
- for (auto M = rbegin(), MEnd = rend(); M != MEnd; ++M) {
- unsigned Size = (*M)->ImportedBy.size();
- UnusedIncomingEdges[(*M)->Index] = Size;
+ for (ModuleFile *M : llvm::reverse(*this)) {
+ unsigned Size = M->ImportedBy.size();
+ UnusedIncomingEdges[M->Index] = Size;
if (!Size)
- Queue.push_back(*M);
+ Queue.push_back(M);
}
// Traverse the graph, making sure to visit a module before visiting any