Uploaded image for project: 'Swift'
  1. Swift
  2. SR-9482

Swift's filtering of "header guard" macros is too strict

    XMLWordPrintable

    Details

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

        Attachments

          Activity

            People

            • Assignee:
              theindigamer Varun Gandhi
              Reporter:
              jrose Jordan Rose
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: