Skip to content

Commit 902880a

Browse files
authored
Merge pull request #6963 from bitjammer/decl-escaped-from-ifconfig-bit
Add 'EscapedFromIfConfig' bit to Decl
2 parents 6e89dbe + 8944ec0 commit 902880a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

include/swift/AST/Decl.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,12 @@ class alignas(1 << DeclAlignInBits) Decl {
237237

238238
/// \brief Whether this declaration is currently being validated.
239239
unsigned BeingValidated : 1;
240+
241+
/// \brief Whether this declaration was added to the surrounding
242+
/// DeclContext of an active #if config clause.
243+
unsigned EscapedFromIfConfig : 1;
240244
};
241-
enum { NumDeclBits = 11 };
245+
enum { NumDeclBits = 12 };
242246
static_assert(NumDeclBits <= 32, "fits in an unsigned");
243247

244248
class PatternBindingDeclBitfields {
@@ -649,6 +653,7 @@ class alignas(1 << DeclAlignInBits) Decl {
649653
DeclBits.FromClang = false;
650654
DeclBits.EarlyAttrValidation = false;
651655
DeclBits.BeingValidated = false;
656+
DeclBits.EscapedFromIfConfig = false;
652657
}
653658

654659
ClangNode getClangNodeImpl() const {
@@ -806,6 +811,14 @@ class alignas(1 << DeclAlignInBits) Decl {
806811
DeclBits.BeingValidated = ibv;
807812
}
808813

814+
bool escapedFromIfConfig() const {
815+
return DeclBits.EscapedFromIfConfig;
816+
}
817+
818+
void setEscapedFromIfConfig(bool Escaped) {
819+
DeclBits.EscapedFromIfConfig = Escaped;
820+
}
821+
809822
/// \returns the unparsed comment attached to this declaration.
810823
RawComment getRawComment() const;
811824

lib/Parse/ParseStmt.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
346346
IfConfigStmt *ICS = cast<IfConfigStmt>(Result.get<Stmt*>());
347347
for (auto &Entry : ICS->getActiveClauseElements()) {
348348
Entries.push_back(Entry);
349+
if (Entry.is<Decl*>()) {
350+
Entry.get<Decl*>()->setEscapedFromIfConfig(true);
351+
}
349352
}
350353
} else if (Tok.is(tok::pound_line)) {
351354
ParserStatus Status = parseLineDirective(true);

0 commit comments

Comments
 (0)