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

Apple: Fixes for stricter compiler parsing #3434

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

dgovil
Copy link
Collaborator

@dgovil dgovil commented Nov 23, 2024

Description of Change(s)

An upcoming Clang/LLVM version has stricter mandatory template checking that causes OpenUSD to fail to compile.
These are technically issues in the OpenUSD codebase that go against the C++ standard, but compilers have ignored them thus far. Therefore I am submitting them as fixes here.

We request that these please be part of the 25.2 release to prevent compilation issues for other developers.

The two issues:

  1. Clang will check for template uses along uninitialized paths as well during compilation. SdfChildrenProxy had one such path, which had to be removed to allow compilation as it referenced a non existent method.

  2. Clang is being stricter about templated function calls in its parser. Sdf_Children<ChildPolicy>::_UpdateChildNames() used a method call that was in violation of the following ISO spec:

    ISO C++03 14.2/4:

    When the name of a member template specialization appears after . or -> in a postfix-expression, or after nested-name-specifier in a qualified-id, and the postfix-expression or qualified-id explicitly depends on a template-parameter (14.6.2), the member template name must be prefixed by the keyword template. Otherwise the name is assumed to name a non-template.

    Explicitly adding the template keyword resolves this. Unfortunately this also gets tagged as unnecessary by older LLVM versions or other compilers. However, a warning felt better than a compile failure.

Checklist

[X] I have created this PR based on the dev branch

[X] I have followed the coding conventions

[ ] I have added unit tests that exercise this functionality (Reference:
testing guidelines)

[X] I have verified that all unit tests pass with the proposed changes

[X] I have submitted a signed Contributor License Agreement (Reference:
Contributor License Agreement instructions)

…e even when the specific path is not taken during compilation.

This fix removes on such unused path from SdfChildrenProxy in the assignment operator where there is no implementation of _Set
…te syntax, causing OpenUSD to fail to compile.

`Sdf_Children<ChildPolicy>::_UpdateChildNames()` includes a template call that was in violation of ISO C standards to compile properly.

ISO C++03 14.2/4:

> When the name of a member template specialization appears after . or -> in a postfix-expression, or after nested-name-specifier in a qualified-id, and the postfix-expression or qualified-id explicitly depends on a template-parameter (14.6.2), the member template name must be prefixed by the keyword template. Otherwise the name is assumed to name a non-template.

Explicitly adding the template keyword resolves this. Unfortunately this also gets tagged as unnecessary by older LLVM versions or other compilers, but c'est la vie.
@dgovil dgovil added needs review Issue needing input/review by the repo maintainer (Pixar) build Build-related issue/PR labels Nov 23, 2024
@dgovil dgovil changed the title Apple: Fixes for stricter compiler settings Apple: Fixes for stricter compiler parsing Nov 25, 2024
@jesschimein
Copy link
Contributor

Filed as internal issue #USD-10458

@jesschimein
Copy link
Contributor

/AzurePipelines run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@nvmkuruc
Copy link
Collaborator

nvmkuruc commented Nov 25, 2024

Just to confirm @dgovil -- You're saying that because SdfChildrenProxy doesn't have a _Set method, the assignment operator can never be initialized?

_owner->_Set(*_pos, x);

The change looks good to me, but I'm just making sure I understand which method was non-existent.

@dgovil
Copy link
Collaborator Author

dgovil commented Nov 25, 2024

@nvmkuruc Yes, pretty much. In older versions of the compiler, that path would never be taken and so the compiler never discovers that _Set isn't locatable.

However, now it traverses paths that aren't used as a safety measure, and sees that there's no way to find _Set, and so fails to compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build-related issue/PR needs review Issue needing input/review by the repo maintainer (Pixar)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants