Skip to content

Commit 45aec9a

Browse files
committed
[NFC] [Serialization] Remove redundant hasPendingBody member
The hasPendingBody member is redundant with the PendingBodies.count(Decl*) method. This patch removes the redundant hasPendingBody member and the corresponding InterestingDecl struct.
1 parent 24e8c6a commit 45aec9a

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

clang/include/clang/Serialization/ASTReader.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,27 +1089,13 @@ class ASTReader
10891089
/// the last time we loaded information about this identifier.
10901090
llvm::DenseMap<IdentifierInfo *, unsigned> IdentifierGeneration;
10911091

1092-
class InterestingDecl {
1093-
Decl *D;
1094-
bool DeclHasPendingBody;
1095-
1096-
public:
1097-
InterestingDecl(Decl *D, bool HasBody)
1098-
: D(D), DeclHasPendingBody(HasBody) {}
1099-
1100-
Decl *getDecl() { return D; }
1101-
1102-
/// Whether the declaration has a pending body.
1103-
bool hasPendingBody() { return DeclHasPendingBody; }
1104-
};
1105-
11061092
/// Contains declarations and definitions that could be
11071093
/// "interesting" to the ASTConsumer, when we get that AST consumer.
11081094
///
11091095
/// "Interesting" declarations are those that have data that may
11101096
/// need to be emitted, such as inline function definitions or
11111097
/// Objective-C protocols.
1112-
std::deque<InterestingDecl> PotentiallyInterestingDecls;
1098+
std::deque<Decl *> PotentiallyInterestingDecls;
11131099

11141100
/// The list of deduced function types that we have not yet read, because
11151101
/// they might contain a deduced return type that refers to a local type

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ namespace clang {
9494
GlobalDeclID NamedDeclForTagDecl = 0;
9595
IdentifierInfo *TypedefNameForLinkage = nullptr;
9696

97-
bool HasPendingBody = false;
98-
9997
///A flag to carry the information for a decl from the entity is
10098
/// used. We use it to delay the marking of the canonical decl as used until
10199
/// the entire declaration is deserialized and merged.
@@ -314,9 +312,6 @@ namespace clang {
314312
static void markIncompleteDeclChainImpl(Redeclarable<DeclT> *D);
315313
static void markIncompleteDeclChainImpl(...);
316314

317-
/// Determine whether this declaration has a pending body.
318-
bool hasPendingBody() const { return HasPendingBody; }
319-
320315
void ReadFunctionDefinition(FunctionDecl *FD);
321316
void Visit(Decl *D);
322317

@@ -541,7 +536,6 @@ void ASTDeclReader::ReadFunctionDefinition(FunctionDecl *FD) {
541536
}
542537
// Store the offset of the body so we can lazily load it later.
543538
Reader.PendingBodies[FD] = GetCurrentCursorOffset();
544-
HasPendingBody = true;
545539
}
546540

547541
void ASTDeclReader::Visit(Decl *D) {
@@ -1164,7 +1158,6 @@ void ASTDeclReader::VisitObjCMethodDecl(ObjCMethodDecl *MD) {
11641158
// Load the body on-demand. Most clients won't care, because method
11651159
// definitions rarely show up in headers.
11661160
Reader.PendingBodies[MD] = GetCurrentCursorOffset();
1167-
HasPendingBody = true;
11681161
}
11691162
MD->setSelfDecl(readDeclAs<ImplicitParamDecl>());
11701163
MD->setCmdDecl(readDeclAs<ImplicitParamDecl>());
@@ -4156,8 +4149,7 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
41564149
// AST consumer might need to know about, queue it.
41574150
// We don't pass it to the consumer immediately because we may be in recursive
41584151
// loading, and some declarations may still be initializing.
4159-
PotentiallyInterestingDecls.push_back(
4160-
InterestingDecl(D, Reader.hasPendingBody()));
4152+
PotentiallyInterestingDecls.push_back(D);
41614153

41624154
return D;
41634155
}
@@ -4179,10 +4171,10 @@ void ASTReader::PassInterestingDeclsToConsumer() {
41794171
EagerlyDeserializedDecls.clear();
41804172

41814173
while (!PotentiallyInterestingDecls.empty()) {
4182-
InterestingDecl D = PotentiallyInterestingDecls.front();
4174+
Decl *D = PotentiallyInterestingDecls.front();
41834175
PotentiallyInterestingDecls.pop_front();
4184-
if (isConsumerInterestedIn(getContext(), D.getDecl(), D.hasPendingBody()))
4185-
PassInterestingDeclToConsumer(D.getDecl());
4176+
if (isConsumerInterestedIn(getContext(), D, PendingBodies.count(D)))
4177+
PassInterestingDeclToConsumer(D);
41864178
}
41874179
}
41884180

@@ -4239,9 +4231,8 @@ void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
42394231
// We might have made this declaration interesting. If so, remember that
42404232
// we need to hand it off to the consumer.
42414233
if (!WasInteresting &&
4242-
isConsumerInterestedIn(getContext(), D, Reader.hasPendingBody())) {
4243-
PotentiallyInterestingDecls.push_back(
4244-
InterestingDecl(D, Reader.hasPendingBody()));
4234+
isConsumerInterestedIn(getContext(), D, PendingBodies.count(D))) {
4235+
PotentiallyInterestingDecls.push_back(D);
42454236
WasInteresting = true;
42464237
}
42474238
}

0 commit comments

Comments
 (0)