This is an archive of the discontinued LLVM Phabricator instance.

[NFC][Attr TableGen] Emit Spelling Enum for Attr types if there >1
ClosedPublic

Authored by erichkeane on Mar 17 2020, 8:29 AM.

Details

Summary

Discovered in a downstream, it is often useful to have slightly
different semantics for an attribute based on its namespace, however our
spelling infrastructure doesn't consider namespace when deciding to
elide the enum list. The result is that the solution for a case where
an attribute has slightly different semantics based on a namespace
requires checking against the integer value, which is fragile.

This patch makes us always emit the spelling enum if there is more than
1 and we're generating the header.

Diff Detail

Event Timeline

erichkeane created this revision.Mar 17 2020, 8:29 AM
rnk added inline comments.Mar 17 2020, 9:08 AM
clang/utils/TableGen/ClangAttrEmitter.cpp
2333

I had to call this function during both header and cpp file generation because some code later used the SemanticToSyntacticMap it fills in.

2537

Won't this assert? I think we come here even if !Header.

I cannot think of a way to add test coverage for this change, can you?

clang/utils/TableGen/ClangAttrEmitter.cpp
2336

Looks like there is a little extra whitespace after the << that can be removed.

erichkeane marked 2 inline comments as done.

Did as @rnk suggested, and it fixed all the problems. Just changed the logic for emitting the enum.

erichkeane marked 3 inline comments as done.Mar 17 2020, 10:29 AM
erichkeane added inline comments.
clang/utils/TableGen/ClangAttrEmitter.cpp
2333

Ah! I didn't see anywhere that SpellingEnum was created. Perhaps thats my issue.

2537

I haven't got any asserts here, but I'm having weird problems from tablegen not getting recreated. I'll put the run-in-both-cases code back which should fix this anyway. New patch incoming as soon as it passes LIT.

This revision is now accepted and ready to land.Mar 17 2020, 10:47 AM
This revision was automatically updated to reflect the committed changes.
erichkeane marked 2 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptMar 17 2020, 12:24 PM