microsoft / microsoft/STL

Add a Clang-specific diagnostic ignore push-pop for `module std;`

Open
#5,975 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

modules
Dominant language
C++
Stars
11.1k
Forks
1.7k
Avg merge
4d 15h
Merged PRs (30d)
22

Description

https://github.com/microsoft/STL/blob/cbe2ee99caf122555a305d18f69e57c75b3fe5ec/stl/modules/std.ixx#L39-L40

It seems the MSVC STL module works with clang++.exe (this is the driver with the GNU-like command-line interface, but targets the MSVC ABI). However, the module needs to have additional guards for Clang so that the same warnings of having #include <angle> and defining module std are suppressed. The core of it is:

#if defined(__clang__)
    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
    #pragma clang diagnostic ignored "-Wreserved-module-identifier"
#endif

...

#if defined(__clang__)
    #pragma clang diagnostic pop
#endif

But I suspect we need to be much more judicious about the macro guards, because clang-cl.exe disguises itself as MSVC to source code, with the exception that __clang__ is also defined.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at stl/modules/std.ixx around lines 39–40 and compare how clang++.exe and clang-cl.exe define compiler macros. Reproduce the module warnings for the angle-bracket include and module name, then determine guards that suppress them for Clang without changing MSVC behavior; done means both diagnostics are appropriately scoped and the warning-free module remains compatible with both drivers.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.