aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Serialization/ASTReaderDecl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Serialization/ASTReaderDecl.cpp')
-rw-r--r--lib/Serialization/ASTReaderDecl.cpp171
1 files changed, 54 insertions, 117 deletions
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index 3cac82ad421c..9aa8c77c6231 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -1390,10 +1390,11 @@ ASTDeclReader::RedeclarableResult ASTDeclReader::VisitVarDeclImpl(VarDecl *VD) {
if (uint64_t Val = Record.readInt()) {
VD->setInit(Record.readExpr());
- if (Val > 1) { // IsInitKnownICE = 1, IsInitNotICE = 2, IsInitICE = 3
+ if (Val > 1) {
EvaluatedStmt *Eval = VD->ensureEvaluatedStmt();
Eval->CheckedICE = true;
- Eval->IsICE = Val == 3;
+ Eval->IsICE = (Val & 1) != 0;
+ Eval->HasConstantDestruction = (Val & 4) != 0;
}
}
@@ -1655,55 +1656,11 @@ void ASTDeclReader::VisitUnresolvedUsingTypenameDecl(
void ASTDeclReader::ReadCXXDefinitionData(
struct CXXRecordDecl::DefinitionData &Data, const CXXRecordDecl *D) {
+ #define FIELD(Name, Width, Merge) \
+ Data.Name = Record.readInt();
+ #include "clang/AST/CXXRecordDeclDefinitionBits.def"
+
// Note: the caller has deserialized the IsLambda bit already.
- Data.UserDeclaredConstructor = Record.readInt();
- Data.UserDeclaredSpecialMembers = Record.readInt();
- Data.Aggregate = Record.readInt();
- Data.PlainOldData = Record.readInt();
- Data.Empty = Record.readInt();
- Data.Polymorphic = Record.readInt();
- Data.Abstract = Record.readInt();
- Data.IsStandardLayout = Record.readInt();
- Data.IsCXX11StandardLayout = Record.readInt();
- Data.HasBasesWithFields = Record.readInt();
- Data.HasBasesWithNonStaticDataMembers = Record.readInt();
- Data.HasPrivateFields = Record.readInt();
- Data.HasProtectedFields = Record.readInt();
- Data.HasPublicFields = Record.readInt();
- Data.HasMutableFields = Record.readInt();
- Data.HasVariantMembers = Record.readInt();
- Data.HasOnlyCMembers = Record.readInt();
- Data.HasInClassInitializer = Record.readInt();
- Data.HasUninitializedReferenceMember = Record.readInt();
- Data.HasUninitializedFields = Record.readInt();
- Data.HasInheritedConstructor = Record.readInt();
- Data.HasInheritedAssignment = Record.readInt();
- Data.NeedOverloadResolutionForCopyConstructor = Record.readInt();
- Data.NeedOverloadResolutionForMoveConstructor = Record.readInt();
- Data.NeedOverloadResolutionForMoveAssignment = Record.readInt();
- Data.NeedOverloadResolutionForDestructor = Record.readInt();
- Data.DefaultedCopyConstructorIsDeleted = Record.readInt();
- Data.DefaultedMoveConstructorIsDeleted = Record.readInt();
- Data.DefaultedMoveAssignmentIsDeleted = Record.readInt();
- Data.DefaultedDestructorIsDeleted = Record.readInt();
- Data.HasTrivialSpecialMembers = Record.readInt();
- Data.HasTrivialSpecialMembersForCall = Record.readInt();
- Data.DeclaredNonTrivialSpecialMembers = Record.readInt();
- Data.DeclaredNonTrivialSpecialMembersForCall = Record.readInt();
- Data.HasIrrelevantDestructor = Record.readInt();
- Data.HasConstexprNonCopyMoveConstructor = Record.readInt();
- Data.HasDefaultedDefaultConstructor = Record.readInt();
- Data.DefaultedDefaultConstructorIsConstexpr = Record.readInt();
- Data.HasConstexprDefaultConstructor = Record.readInt();
- Data.HasNonLiteralTypeFieldsOrBases = Record.readInt();
- Data.ComputedVisibleConversions = Record.readInt();
- Data.UserProvidedDefaultConstructor = Record.readInt();
- Data.DeclaredSpecialMembers = Record.readInt();
- Data.ImplicitCopyConstructorCanHaveConstParamForVBase = Record.readInt();
- Data.ImplicitCopyConstructorCanHaveConstParamForNonVBase = Record.readInt();
- Data.ImplicitCopyAssignmentHasConstParam = Record.readInt();
- Data.HasDeclaredCopyConstructorWithConstParam = Record.readInt();
- Data.HasDeclaredCopyAssignmentWithConstParam = Record.readInt();
Data.ODRHash = Record.readInt();
Data.HasODRHash = true;
@@ -1718,7 +1675,9 @@ void ASTDeclReader::ReadCXXDefinitionData(
Data.VBases = ReadGlobalOffset();
Record.readUnresolvedSet(Data.Conversions);
- Record.readUnresolvedSet(Data.VisibleConversions);
+ Data.ComputedVisibleConversions = Record.readInt();
+ if (Data.ComputedVisibleConversions)
+ Record.readUnresolvedSet(Data.VisibleConversions);
assert(Data.Definition && "Data.Definition should be already set!");
Data.FirstFriend = ReadDeclID();
@@ -1731,6 +1690,7 @@ void ASTDeclReader::ReadCXXDefinitionData(
Lambda.CaptureDefault = Record.readInt();
Lambda.NumCaptures = Record.readInt();
Lambda.NumExplicitCaptures = Record.readInt();
+ Lambda.HasKnownInternalLinkage = Record.readInt();
Lambda.ManglingNumber = Record.readInt();
Lambda.ContextDecl = ReadDeclID();
Lambda.Captures = (Capture *)Reader.getContext().Allocate(
@@ -1791,63 +1751,17 @@ void ASTDeclReader::MergeDefinitionData(
return;
}
- // FIXME: Move this out into a .def file?
bool DetectedOdrViolation = false;
-#define OR_FIELD(Field) DD.Field |= MergeDD.Field;
-#define MATCH_FIELD(Field) \
+
+ #define FIELD(Name, Width, Merge) Merge(Name)
+ #define MERGE_OR(Field) DD.Field |= MergeDD.Field;
+ #define NO_MERGE(Field) \
DetectedOdrViolation |= DD.Field != MergeDD.Field; \
- OR_FIELD(Field)
- MATCH_FIELD(UserDeclaredConstructor)
- MATCH_FIELD(UserDeclaredSpecialMembers)
- MATCH_FIELD(Aggregate)
- MATCH_FIELD(PlainOldData)
- MATCH_FIELD(Empty)
- MATCH_FIELD(Polymorphic)
- MATCH_FIELD(Abstract)
- MATCH_FIELD(IsStandardLayout)
- MATCH_FIELD(IsCXX11StandardLayout)
- MATCH_FIELD(HasBasesWithFields)
- MATCH_FIELD(HasBasesWithNonStaticDataMembers)
- MATCH_FIELD(HasPrivateFields)
- MATCH_FIELD(HasProtectedFields)
- MATCH_FIELD(HasPublicFields)
- MATCH_FIELD(HasMutableFields)
- MATCH_FIELD(HasVariantMembers)
- MATCH_FIELD(HasOnlyCMembers)
- MATCH_FIELD(HasInClassInitializer)
- MATCH_FIELD(HasUninitializedReferenceMember)
- MATCH_FIELD(HasUninitializedFields)
- MATCH_FIELD(HasInheritedConstructor)
- MATCH_FIELD(HasInheritedAssignment)
- MATCH_FIELD(NeedOverloadResolutionForCopyConstructor)
- MATCH_FIELD(NeedOverloadResolutionForMoveConstructor)
- MATCH_FIELD(NeedOverloadResolutionForMoveAssignment)
- MATCH_FIELD(NeedOverloadResolutionForDestructor)
- MATCH_FIELD(DefaultedCopyConstructorIsDeleted)
- MATCH_FIELD(DefaultedMoveConstructorIsDeleted)
- MATCH_FIELD(DefaultedMoveAssignmentIsDeleted)
- MATCH_FIELD(DefaultedDestructorIsDeleted)
- OR_FIELD(HasTrivialSpecialMembers)
- OR_FIELD(HasTrivialSpecialMembersForCall)
- OR_FIELD(DeclaredNonTrivialSpecialMembers)
- OR_FIELD(DeclaredNonTrivialSpecialMembersForCall)
- MATCH_FIELD(HasIrrelevantDestructor)
- OR_FIELD(HasConstexprNonCopyMoveConstructor)
- OR_FIELD(HasDefaultedDefaultConstructor)
- MATCH_FIELD(DefaultedDefaultConstructorIsConstexpr)
- OR_FIELD(HasConstexprDefaultConstructor)
- MATCH_FIELD(HasNonLiteralTypeFieldsOrBases)
- // ComputedVisibleConversions is handled below.
- MATCH_FIELD(UserProvidedDefaultConstructor)
- OR_FIELD(DeclaredSpecialMembers)
- MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForVBase)
- MATCH_FIELD(ImplicitCopyConstructorCanHaveConstParamForNonVBase)
- MATCH_FIELD(ImplicitCopyAssignmentHasConstParam)
- OR_FIELD(HasDeclaredCopyConstructorWithConstParam)
- OR_FIELD(HasDeclaredCopyAssignmentWithConstParam)
- MATCH_FIELD(IsLambda)
-#undef OR_FIELD
-#undef MATCH_FIELD
+ MERGE_OR(Field)
+ #include "clang/AST/CXXRecordDeclDefinitionBits.def"
+ NO_MERGE(IsLambda)
+ #undef NO_MERGE
+ #undef MERGE_OR
if (DD.NumBases != MergeDD.NumBases || DD.NumVBases != MergeDD.NumVBases)
DetectedOdrViolation = true;
@@ -2087,7 +2001,6 @@ DeclID ASTDeclReader::VisitTemplateDecl(TemplateDecl *D) {
DeclID PatternID = ReadDeclID();
auto *TemplatedDecl = cast_or_null<NamedDecl>(Reader.GetDecl(PatternID));
TemplateParameterList *TemplateParams = Record.readTemplateParameterList();
- // FIXME handle associated constraints
D->init(TemplatedDecl, TemplateParams);
return PatternID;
@@ -2253,7 +2166,8 @@ void ASTDeclReader::VisitClassTemplatePartialSpecializationDecl(
ClassTemplatePartialSpecializationDecl *D) {
RedeclarableResult Redecl = VisitClassTemplateSpecializationDeclImpl(D);
- D->TemplateParams = Record.readTemplateParameterList();
+ TemplateParameterList *Params = Record.readTemplateParameterList();
+ D->TemplateParams = Params;
D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
// These are read/set from/to the first declaration.
@@ -2355,7 +2269,8 @@ void ASTDeclReader::VisitVarTemplatePartialSpecializationDecl(
VarTemplatePartialSpecializationDecl *D) {
RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
- D->TemplateParams = Record.readTemplateParameterList();
+ TemplateParameterList *Params = Record.readTemplateParameterList();
+ D->TemplateParams = Params;
D->ArgsAsWritten = Record.readASTTemplateArgumentListInfo();
// These are read/set from/to the first declaration.
@@ -2371,6 +2286,7 @@ void ASTDeclReader::VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
D->setDeclaredWithTypename(Record.readInt());
+ // TODO: Concepts: Immediately introduced constraint
if (Record.readInt())
D->setDefaultArgument(GetTypeSourceInfo());
}
@@ -2748,6 +2664,10 @@ public:
return Reader->ReadSourceRange(*F, Record, Idx);
}
+ SourceLocation readSourceLocation() {
+ return Reader->ReadSourceLocation(*F, Record, Idx);
+ }
+
Expr *readExpr() { return Reader->ReadExpr(*F); }
std::string readString() {
@@ -2783,9 +2703,20 @@ Attr *ASTReader::ReadAttr(ModuleFile &M, const RecordData &Rec,
// Kind is stored as a 1-based integer because 0 is used to indicate a null
// Attr pointer.
auto Kind = static_cast<attr::Kind>(V - 1);
- SourceRange Range = Record.readSourceRange();
ASTContext &Context = getContext();
+ IdentifierInfo *AttrName = Record.getIdentifierInfo();
+ IdentifierInfo *ScopeName = Record.getIdentifierInfo();
+ SourceRange AttrRange = Record.readSourceRange();
+ SourceLocation ScopeLoc = Record.readSourceLocation();
+ unsigned ParsedKind = Record.readInt();
+ unsigned Syntax = Record.readInt();
+ unsigned SpellingIndex = Record.readInt();
+
+ AttributeCommonInfo Info(AttrName, ScopeName, AttrRange, ScopeLoc,
+ AttributeCommonInfo::Kind(ParsedKind),
+ AttributeCommonInfo::Syntax(Syntax), SpellingIndex);
+
#include "clang/Serialization/AttrPCHRead.inc"
assert(New && "Unable to decode attribute?");
@@ -4551,8 +4482,9 @@ void ASTDeclReader::UpdateDecl(Decl *D,
break;
case UPD_DECL_MARKED_OPENMP_THREADPRIVATE:
- D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(Reader.getContext(),
- ReadSourceRange()));
+ D->addAttr(OMPThreadPrivateDeclAttr::CreateImplicit(
+ Reader.getContext(), ReadSourceRange(),
+ AttributeCommonInfo::AS_Pragma));
break;
case UPD_DECL_MARKED_OPENMP_ALLOCATE: {
@@ -4561,7 +4493,8 @@ void ASTDeclReader::UpdateDecl(Decl *D,
Expr *Allocator = Record.readExpr();
SourceRange SR = ReadSourceRange();
D->addAttr(OMPAllocateDeclAttr::CreateImplicit(
- Reader.getContext(), AllocatorKind, Allocator, SR));
+ Reader.getContext(), AllocatorKind, Allocator, SR,
+ AttributeCommonInfo::AS_Pragma));
break;
}
@@ -4574,12 +4507,16 @@ void ASTDeclReader::UpdateDecl(Decl *D,
break;
}
- case UPD_DECL_MARKED_OPENMP_DECLARETARGET:
+ case UPD_DECL_MARKED_OPENMP_DECLARETARGET: {
+ OMPDeclareTargetDeclAttr::MapTypeTy MapType =
+ static_cast<OMPDeclareTargetDeclAttr::MapTypeTy>(Record.readInt());
+ OMPDeclareTargetDeclAttr::DevTypeTy DevType =
+ static_cast<OMPDeclareTargetDeclAttr::DevTypeTy>(Record.readInt());
D->addAttr(OMPDeclareTargetDeclAttr::CreateImplicit(
- Reader.getContext(),
- static_cast<OMPDeclareTargetDeclAttr::MapTypeTy>(Record.readInt()),
- ReadSourceRange()));
+ Reader.getContext(), MapType, DevType, ReadSourceRange(),
+ AttributeCommonInfo::AS_Pragma));
break;
+ }
case UPD_ADDED_ATTR_TO_RECORD:
AttrVec Attrs;