This is an archive of the discontinued LLVM Phabricator instance.

Effectively revert 33c3d8a916c / D33782
ClosedPublic

Authored by rnk on Aug 25 2021, 11:45 AM.

Details

Summary

This change would treat the token or in system headers as an
identifier, and elsewhere as an operator. As reported in
llvm.org/pr42427, many users classify their third party library headers
as "system" headers to suppress warnings. There's no clean way to
separate Windows SDK headers from user headers.

Since D103773, clang-cl's default mode completely disables C++ operator
names. That means that query.h compiles out of the box without this hack
in the pre-processor. For users who are using /permissive-, they must
set the QUERY_H_RESTRICTION_PERMISSIVE macro to rename this problematic
or field.

By reverting this change, we get to a consistent state: C++ operator
names are either enabled or disabled globally. If that breaks
compilation because legacy code is using or as an identifier, the user
has flags to work around the problem (/permissive or
/clang:-fno-operator-names).

Fixes PR42427

Diff Detail

Event Timeline

rnk requested review of this revision.Aug 25 2021, 11:45 AM
rnk created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2021, 11:45 AM
erichkeane accepted this revision.Aug 25 2021, 11:49 AM

This seems reasonable to me. The changes for /permissive and /permissive- I think are a better way about this, and now that there is a trivial workaround (QUERY_H_RESTRICTION_PERMISSIVE) I don't really see value in the original patch anymore.

Side note: @mibintc is now retired, so you won't see a response from her.

This revision is now accepted and ready to land.Aug 25 2021, 11:49 AM
zero9178 accepted this revision.Aug 25 2021, 11:56 AM

Thanks a lot for the patch :) Wanted this bit of code to be removed for quite some time.

Since D103773, clang-cl's default mode completely disables C++ operator
names. That means that query.h compiles out of the box without this hack
in the pre-processor. For users who are using /permissive-, they must
set the QUERY_H_RESTRICTION_PERMISSIVE macro to rename this problematic
or field.

Just a heads up, the patch added /permissive and /permissive-, but made neither the default as to not be a breaking change. That means that clang-cl still parses operator keywords and also does delayed template parsing, as it did before the patch.

rnk added a comment.Aug 25 2021, 12:43 PM

Just a heads up, the patch added /permissive and /permissive-, but made neither the default as to not be a breaking change. That means that clang-cl still parses operator keywords and also does delayed template parsing, as it did before the patch.

Oh, I see. So, my change will then be a breaking change: users of clang-cl with no flags will not be able to include <query.h> from the Windows SDK out of the box. But, such users can simply add /permissive and probably carry on their way. I think I can live with that. I may add a release note for it.

This revision was landed with ongoing or failed builds.Aug 25 2021, 2:41 PM
This revision was automatically updated to reflect the committed changes.
clang/test/Headers/ms-cppoperkey.cpp