Skip to content

[clang][driver][clang-cl] Fix unused argument warning for /std:c++20 for precompiled module inputs to clang-cl #99300

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

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

sharadhr
Copy link
Contributor

Relates to #98761: -fmodule-file requires /std:c++20 or greater, but passing that option results in an unused argument warning. This resolves that.

Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Jul 17, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 17, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Sharadh Rajaraman (sharadhr)

Changes

Relates to #98761: -fmodule-file requires /std:c++20 or greater, but passing that option results in an unused argument warning. This resolves that.


Full diff: https://github.com/llvm/llvm-project/pull/99300.diff

1 Files Affected:

  • (modified) clang/lib/Driver/Types.cpp (+3-1)
diff --git a/clang/lib/Driver/Types.cpp b/clang/lib/Driver/Types.cpp
index a7b6b9000e1d2..842eb59b7382d 100644
--- a/clang/lib/Driver/Types.cpp
+++ b/clang/lib/Driver/Types.cpp
@@ -242,7 +242,9 @@ bool types::isCXX(ID Id) {
   case TY_CXXHUHeader:
   case TY_PP_CXXHeaderUnit:
   case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader:
-  case TY_CXXModule: case TY_PP_CXXModule:
+  case TY_CXXModule: 
+  case TY_PP_CXXModule:
+  case TY_ModuleFile:
   case TY_PP_CLCXX:
   case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE:
   case TY_HIP:

@sharadhr sharadhr changed the title [clang][driver] Fix unused argument warning for /std:c++20 for precompiled module inputs to clang-cl [clang][driver][clang-cl] Fix unused argument warning for /std:c++20 for precompiled module inputs to clang-cl Jul 17, 2024
Copy link
Member

@ChuanqiXu9 ChuanqiXu9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a test for this too. We can use any file ends with .pcm to mimic module file in the Driver's test and we can use CHECK-NOT: to filter the warning.

@sharadhr sharadhr force-pushed the clang-cl-modules-unused-argument branch from fe0e22a to cbe5a79 Compare August 6, 2024 20:33
@sharadhr
Copy link
Contributor Author

sharadhr commented Aug 6, 2024

Not quite sure how to handle the test for this; I'm struggling to find a .pcm file that can be used.

Copy link

github-actions bot commented Aug 6, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@sharadhr sharadhr force-pushed the clang-cl-modules-unused-argument branch from cbe5a79 to 3b9c3d2 Compare August 6, 2024 20:43
@ChuanqiXu9
Copy link
Member

Maybe something like this:

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %clang %t/fake.pcm -std=c++20 -### 2>&1 | FileCheck %t/fake.pcm

//--- fake.pcm
// CHECK-NOT: warning

@sharadhr sharadhr force-pushed the clang-cl-modules-unused-argument branch from f1d83d6 to ad840c4 Compare August 7, 2024 19:45
Copy link
Member

@ChuanqiXu9 ChuanqiXu9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ChuanqiXu9 ChuanqiXu9 merged commit 9d315bc into llvm:main Aug 8, 2024
7 checks passed
@ChuanqiXu9 ChuanqiXu9 added this to the LLVM 19.X Release milestone Aug 8, 2024
Copy link

github-actions bot commented Aug 8, 2024

@sharadhr Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

@ChuanqiXu9
Copy link
Member

/cherry-pick 9d315bc

@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2024

Failed to cherry-pick: 9d315bc

https://github.com/llvm/llvm-project/actions/runs/10294654014

Please manually backport the fix and push it to your github fork. Once this is done, please create a pull request

@ChuanqiXu9
Copy link
Member

From the log, it looks like the git crashes instead of conflicts. @tru would you like to take look.

@sharadhr also if you want to backport this to 19.x, maybe you can try to create a PR to the branch of 19.x branch manually in case the automated cherry-pick doesn't work.

@sharadhr
Copy link
Contributor Author

sharadhr commented Aug 8, 2024

Just to clarify—you'd like me to open another PR to release/19.X? I can do that.

In fact I'm a little more ambitious because this and #98761 are honestly very simple PRs—I'd like them to be backported as far as Clang 16 (which is when modules support first appeared) if possible.

@ChuanqiXu9
Copy link
Member

Just to clarify—you'd like me to open another PR to release/19.X? I can do that.

Yes. You can find the automated generated example in #102159

In fact I'm a little more ambitious because this and #98761 are honestly very simple PRs—I'd like them to be backported as far as Clang 16 (which is when modules support first appeared) if possible.

No, this is not possible. We may never have new releases for 18, 17 and 16 as far as I know.

@sharadhr
Copy link
Contributor Author

sharadhr commented Aug 8, 2024

Ah. That's a pity but no problem. I'll create the PR now. Thanks!

huangqinjin added a commit to huangqinjin/cxxmodules that referenced this pull request Nov 10, 2024
1. __cpp_lib_modules now is defined.
llvm/llvm-project#90091

2. clang-cl supports -x option for all languages.
llvm/llvm-project#89772

3. Header units allow non-inline external static members definitions.
llvm/llvm-project#98309

4. winsysroot alias to the GNU driver: -Xmicrosoft-windows-sys-root.
llvm/llvm-project#94731

5. clang-cl gained options for compiling C++ modules.
llvm/llvm-project#98761

6. fix unused argument warning for /std:c++20 when compiling c++ modules.
llvm/llvm-project#99300
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category release:cherry-pick-failed
Projects
Development

Successfully merging this pull request may close these issues.

3 participants