Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
belkadan opened this issue Dec 12, 2018 · 3 comments
Closed

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

belkadan opened this issue Dec 12, 2018 · 3 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers

Comments

@belkadan
Copy link
Contributor

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.)

@belkadan
Copy link
Contributor Author

The place where this check lives is shouldIgnoreMacro in ImportName.cpp.

@belkadan
Copy link
Contributor Author

(This isn't perfect because sometimes the value really is 1, particularly if it's a feature flag or something, but it's a better compromise for now.)

@typesanitizer
Copy link

Fixed in GitHub PR #26150.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants