Skip to content

Re-enable the warning classes the iOS template disables at project level #5785

Description

@shai-almog

The iOS Xcode template turns five warning classes off at project level:

CLANG_WARN_EMPTY_BODY            CLANG_WARN_ENUM_CONVERSION
CLANG_WARN_INT_CONVERSION        CLANG_WARN__DUPLICATE_METHOD_MATCH
GCC_WARN_UNUSED_VARIABLE

Being project level, the hand-written Ports/iOSPort/nativeSources lose them
too, not just the translated output they were presumably turned off for.

CLANG_WARN_EMPTY_BODY and CLANG_WARN__DUPLICATE_METHOD_MATCH are already
flipped to YES and cost nothing. The remaining three are each gated on their
category reaching zero, and should ship one setting per PR:

setting blocked by census count
CLANG_WARN_ENUM_CONVERSION -Wenum-conversion 10 instances / 6 shapes (port)
GCC_WARN_UNUSED_VARIABLE -Wunused-variable 98 generated + 71 port + 10 runtime
CLANG_WARN_INT_CONVERSION -Wint-conversion 14 instances / 7 shapes (port)

CLANG_WARN_INT_CONVERSION deserves the hardest look. In current clang
-Wint-conversion defaults to an error, so = NO is actively suppressing a
pointer/integer confusion class. Treat its remaining 14 as a bug list, not a
burn-down list. (The 13 instances that were there when this started are already
fixed and their baseline rows deleted.)

Three constraints on editing the template pbxproj, all verified the hard
way:

  1. Do not move or reformat the literal-matched anchor lines (SDKROOT,
    CLANG_ENABLE_MODULES, IPHONEOS_DEPLOYMENT_TARGET, PRODUCT_NAME,
    TARGETED_DEVICE_FAMILY) -- IPhoneBuilder matches them as exact literals.
    Adding lines around them is safe; editing them is not.
  2. Never introduce a }; inside a buildSettings = { ... } block.
    injectDevelopmentTeam matches buildSettings = \{.*?\}; non-greedy with
    DOTALL and the first nested }; truncates it. A parenthesised list is safe;
    a nested dictionary is not.
  3. Comments must not contain the substring template -- replaceInFile is
    a plain global replace that rewrites it to the application name.

Do not extend the app-extension CLANG_WARN_* block wholesale: it is written
for ARC-enabled code and the main target is CLANG_ENABLE_OBJC_ARC = NO, so
several members are meaningless there. Take
CLANG_WARN_UNGUARDED_AVAILABILITY and
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS individually.

Found by the native warning census (scripts/check-native-warnings.py).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions