This is an archive of the discontinued LLVM Phabricator instance.

[include-mapping] Introduce a human-edit CXXSymbolMapping file
ClosedPublic

Authored by hokein on Feb 2 2023, 2:39 AM.

Details

Summary

A patch based on https://reviews.llvm.org/D143054

This file is allowed to be edit by human, and it overlays the generated symbol file. It contains a list of multiple-header symbols.
This patch introduces the file only. Usage will come afterwards.

Diff Detail

Event Timeline

hokein created this revision.Feb 2 2023, 2:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 2:39 AM
hokein requested review of this revision.Feb 2 2023, 2:39 AM
Herald added a project: Restricted Project. · View Herald Transcript
hokein updated this revision to Diff 494299.Feb 2 2023, 7:13 AM

update, separate out a new file.

hokein updated this revision to Diff 494300.Feb 2 2023, 7:14 AM

upload the missing file.

hokein retitled this revision from [include-mapping] Extend c-compatibility symbols in StdSymbolMap.inc to [include-mapping] Introduce a human-edit CXXSymbolMapping file.Feb 2 2023, 7:18 AM
hokein edited the summary of this revision. (Show Details)
hokein added a reviewer: kadircet.
hokein updated this revision to Diff 494573.Feb 3 2023, 3:05 AM

refine the patch: include multiple-header symbols.

hokein edited the summary of this revision. (Show Details)Feb 3 2023, 3:06 AM
kadircet added inline comments.Feb 6 2023, 12:25 AM
clang/include/clang/Tooling/Inclusions/CXXSymbolMap.inc
12 ↗(On Diff #494573)

i feel like cppreference is wrong here (at least per libstdc++-12, and https://eel.is/c++draft/locale.syn#header:%3clocale%3e)

#include <locale>
auto x = std::consume_header;

same for generate_header and little_endian.

it might be worth changing these into:

SYMBOL(consume_header, std::, <codecvt>)
// cppreference mentions this header as an alternative, but it isn't in practice.
// SYMBOL(consume_header, std::, <locale>)
19 ↗(On Diff #494573)

can we actually use the ordering from standard: [cstddef.syn], [cstdlib.syn], [cstring.syn], [cwchar.syn], [cuchar.syn], [ctime.syn], [cstdio.syn] (1)

26 ↗(On Diff #494573)

nit: i don't think we need the comments here, both headers are also mentioned in cppreference pages.
i am afraid these might get out of date (or only seldom mentioned) as future editors of this mapping might not be delicate enough.

kadircet added inline comments.Feb 6 2023, 12:54 AM
clang/include/clang/Tooling/Inclusions/CXXSymbolMap.inc
1 ↗(On Diff #494573)

also maybe rename this to, AlternativeHeaderMap.inc ?

3 ↗(On Diff #494573)

i'd rather say This is a hand-curated list for symbols provided by multiple headers, to address the short comings of cppreference or automated extraction logic. All entries for a symbol name provide the same declaration (hence these are not overloads/variants like std::remove from algorithm vs cstdio).

hokein updated this revision to Diff 495032.Feb 6 2023, 1:35 AM
hokein marked an inline comment as done.
hokein edited the summary of this revision. (Show Details)

address review comments

clang/include/clang/Tooling/Inclusions/CXXSymbolMap.inc
1 ↗(On Diff #494573)

Renamed it to StdAlternativeHeaderMap.inc, to align with the existing StdSymbolMap.inc name pattern for C++ symbols.

12 ↗(On Diff #494573)

Right, thanks for checking it! You're right. I also have checked the C++11, C++17 standard, I don't find any relevant text about the header "<locale>" contains the these symbol definition.
I'd rather delete this entry, and only keep <codecvt>.

19 ↗(On Diff #494573)

Sure.

26 ↗(On Diff #494573)

Removed.

kadircet added inline comments.Feb 6 2023, 2:28 AM
clang/include/clang/Tooling/Inclusions/StdAlternativeHeaderMap.inc
3 ↗(On Diff #495032)

This is a hand-curated list for C++ symbols reads like we're planning to put all special C++ symbols into this file, rather than just the ones that are provided by alternative headers. that's the reason why i mentioned it as This is a hand-curated list for symbols provided by multiple headers specifically.

hokein added inline comments.Feb 6 2023, 4:16 AM
clang/include/clang/Tooling/Inclusions/StdAlternativeHeaderMap.inc
3 ↗(On Diff #495032)

Restricting the file only to multiple-header symbols seems a bit narrow (and the consume_header symbol only has one header which doesn't fit into this bucket nicely).

My take of this file is - we'll put all special C++ symbols that are not able to handle by the cppreference generator, multiple-header symbols are the most critical ones.

What do you think?

kadircet added inline comments.Feb 6 2023, 5:17 AM
clang/include/clang/Tooling/Inclusions/StdAlternativeHeaderMap.inc
3 ↗(On Diff #495032)

(and the consume_header symbol only has one header which doesn't fit into this bucket nicely).

Well, i'd say they deserve their own list in that case.

My take of this file is - we'll put all special C++ symbols that are not able to handle by the cppreference generator, multiple-header symbols are the most critical ones.

I am afraid of that list getting too long and impossible to read manually any more.
but since these are going to be private files soon, we can always do that split once that's actually the case.

We need a different name for this file in that case though. As I thought we are only putting symbols with alternative headers into this file. What about StdSpecialSymbolMap.inc instead and update the file comment to:

This is a hand-curated list for C++ symbols that cannot be parsed/extracted via include-mapping tool.

and not talk about All headers for a symbol name provide the same declaration (hence these are not overloads/variants like std::remove from algorithm vs cstdio). as we're planning to add them to here as well. it's just we aren't adding them "right now".

hokein updated this revision to Diff 495100.Feb 6 2023, 5:54 AM

Rename the file name for more general purposes.

clang/include/clang/Tooling/Inclusions/StdAlternativeHeaderMap.inc
3 ↗(On Diff #495032)

Yeah, this sounds good to me.

Well, i'd say they deserve their own list in that case.

Yeah, this is an alternative (a mono file vs. muti files). I would start with a single file.
The list of these symbols is not that large now.

kadircet accepted this revision.Feb 6 2023, 5:56 AM

thanks, lgtm!

This revision is now accepted and ready to land.Feb 6 2023, 5:56 AM
This revision was landed with ongoing or failed builds.Feb 7 2023, 1:17 AM
This revision was automatically updated to reflect the committed changes.