Skip to content

[SR-9482] Swift's filtering of "header guard" macros is too strict #51944

@belkadan

Description

@belkadan
Previous ID SR-9482
Radar rdar://problem/46644027
Original Reporter @belkadan
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ClangImporter, StarterBug
Assignee @typesanitizer
Priority Medium

md5: 01b81c30eea7001ee4aeaf49942f86c3

Issue Description:

The O_SYNC macro on Apple platforms is defined in its own file that looks like this:

#ifndef O_SYNC
#define O_SYNC                  0x0080          /* synch I/O file integrity */
#endif /* O_SYNC */

(with an APSL header too)

This pattern is one that Clang can use as a "header guard", to know whether it has to bother re-parsing the file when it's included again later or whether it can just skip it. Usually header guard macros are written explicitly for this purpose, but in this case O_SYNC is actually defining a useful constant. We should restrict our check for "header guard" to cases where there's exactly one token, the integer constant "1". (Macros with no expansions are already not imported into Swift.)

Metadata

Metadata

Assignees

Labels

bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfgood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions