This is an archive of the discontinued LLVM Phabricator instance.

[clang][modules] Add -Wsystem-headers-in-module=
ClosedPublic

Authored by benlangmuir on Aug 2 2023, 4:19 PM.

Details

Summary

Add a way to enable -Wsystem-headers only for a specific module. This is useful for validating a module that would otherwise not see system header diagnostics without being flooded by diagnostics for unrelated headers/modules. It's relatively common for a module to be marked [system] but still wish to validate itself explicitly.

Diff Detail

Event Timeline

benlangmuir created this revision.Aug 2 2023, 4:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2023, 4:19 PM
benlangmuir requested review of this revision.Aug 2 2023, 4:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 2 2023, 4:19 PM
jansvoboda11 accepted this revision.Aug 4 2023, 9:39 AM

LGTM

clang/include/clang/Basic/DiagnosticOptions.h
128

Out of interest, is there an existing use-case for having multiple modules here, or is this just future-proofing?

clang/lib/Frontend/CompilerInstance.cpp
1239–1240

I assume llvm::is_contained() wouldn't be okay with the std::string and StringRef mismatch?

This revision is now accepted and ready to land.Aug 4 2023, 9:39 AM

Use llvm::is_contained

benlangmuir marked an inline comment as done.Aug 4 2023, 10:01 AM
benlangmuir added inline comments.
clang/include/clang/Basic/DiagnosticOptions.h
128

I'm not using it currently, but I think it makes sense to handle any number. You could have multiple such modules you're testing together.

clang/lib/Frontend/CompilerInstance.cpp
1239–1240

Nope, I just didn't think of it here for some reason. Updated.

iana accepted this revision.Aug 8 2023, 10:20 PM
iana added inline comments.
clang/include/clang/Basic/DiagnosticOptions.h
128

I'd imagine you'd typically have Framework and Framework_Private in there

benlangmuir marked an inline comment as done.Aug 9 2023, 10:03 AM
benlangmuir added inline comments.
clang/include/clang/Basic/DiagnosticOptions.h
128

Ah, good point. I am in fact doing that already and just forgot.

This revision was landed with ongoing or failed builds.Aug 9 2023, 10:41 AM
This revision was automatically updated to reflect the committed changes.