This is an archive of the discontinued LLVM Phabricator instance.

[libclang] Deprecate CXPrintingPolicy_IncludeTagDefinition
AbandonedPublic

Authored by jdenny on May 15 2018, 5:22 PM.

Details

Reviewers
rsmith
Summary

And make it have no effect. Suggested at:

https://reviews.llvm.org/D45463#1096629

Diff Detail

Event Timeline

jdenny created this revision.May 15 2018, 5:22 PM

The deprecated enumerator is also referenced by tools/c-index-test/c-index-test.c

This looks fine to me, but let's leave this review thread open for a week or so, to give people a bit more time to object in case they're using the flag for something.

include/clang/AST/PrettyPrinter.h
97–99 ↗(On Diff #146964)

There's no need to keep this around. We have no API stability guarantees for our C++ API.

100–108 ↗(On Diff #146964)

Please explicitly mark this as being transient state that's internal to the printing algorithm and not part of its external configuration, so that people don't try to expose it again in the future. The same is true for a bunch of the other flags around here -- if we're going to do this, we should systematically examine these flags to see which ones are external configuration and which ones are internal state that we're (hackily) passing between printing steps via the PrintingPolicy. It would also make sense to move the internal state flags to a separate struct from the policy.

The deprecated enumerator is also referenced by tools/c-index-test/c-index-test.c

This test prompted me to keep the IncludeTagDefinition member in PrintingPolicy so that clang_PrintingPolicy_getProperty would return the previous value set by clang_PrintingPolicy_setProperty. Otherwise, the value doesn't have any effect. Is that self-consistency not worth worrying about? If so, I'll remove both.

This looks fine to me, but let's leave this review thread open for a week or so, to give people a bit more time to object in case they're using the flag for something.

Sure.

include/clang/AST/PrettyPrinter.h
100–108 ↗(On Diff #146964)

Please explicitly mark this as being transient state that's internal to the printing algorithm and not part of its external configuration, so that people don't try to expose it again in the future.

Will do.

The same is true for a bunch of the other flags around here -- if we're going to do this, we should systematically examine these flags to see which ones are external configuration and which ones are internal state that we're (hackily) passing between printing steps via the PrintingPolicy.

Doing that now sounds like a lot of analysis and difficult judgment calls without much immediate gain -- at least for me as I'm not so familiar with all the flags and their potential uses from libclang. My inclination is to write a fixme and refactor gradually.

It would also make sense to move the internal state flags to a separate struct from the policy.

Are you ok with making the new struct a member of the existing policy to simplify the refactoring effort?

jdenny updated this revision to Diff 147887.May 21 2018, 3:32 PM
jdenny marked 2 inline comments as done.
jdenny edited the summary of this revision. (Show Details)

Made a stab at the suggested changes.

The deprecated enumerator is also referenced by tools/c-index-test/c-index-test.c

This test prompted me to keep the IncludeTagDefinition member in PrintingPolicy so that clang_PrintingPolicy_getProperty would return the previous value set by clang_PrintingPolicy_setProperty. Otherwise, the value doesn't have any effect. Is that self-consistency not worth worrying about? If so, I'll remove both.

Sorry, I was thinking of a different test. I've removed the reference you mentioned.

include/clang/AST/PrettyPrinter.h
97–99 ↗(On Diff #146964)

The test LibclangPrintingPolicyTest in unittests/libclang/LibclangTest.cpp wants clang_PrintingPolicy_getProperty to return the previous value set by clang_PrintingPolicy_setProperty for every member of CXPrintingPolicyProperty. Keeping this field makes that possible.

The deprecated enumerator is also referenced by tools/c-index-test/c-index-test.c

This test prompted me to keep the IncludeTagDefinition member in PrintingPolicy so that clang_PrintingPolicy_getProperty would return the previous value set by clang_PrintingPolicy_setProperty. Otherwise, the value doesn't have any effect. Is that self-consistency not worth worrying about? If so, I'll remove both.

I don't think it's worth worrying about. We don't guarantee that the values round-trip in general (most of them are unsigneds being written to a bool, so we don't preserve values that are neither 0 nor 1).

The deprecated enumerator is also referenced by tools/c-index-test/c-index-test.c

This test prompted me to keep the IncludeTagDefinition member in PrintingPolicy so that clang_PrintingPolicy_getProperty would return the previous value set by clang_PrintingPolicy_setProperty. Otherwise, the value doesn't have any effect. Is that self-consistency not worth worrying about? If so, I'll remove both.

I don't think it's worth worrying about. We don't guarantee that the values round-trip in general (most of them are unsigneds being written to a bool, so we don't preserve values that are neither 0 nor 1).

I was actually thinking of a different test (see my comments from today), and it wants 0 and 1 to be preserved.

jdenny set the repository for this revision to rC Clang.May 24 2018, 12:35 PM
jdenny updated this revision to Diff 151979.Jun 19 2018, 2:30 PM

Rebased. Ping.

jdenny updated this revision to Diff 153930.Jul 3 2018, 9:37 AM

Ping. Rebased.

jdenny updated this revision to Diff 156620.Jul 20 2018, 3:46 PM

Ping. Rebased.

jdenny updated this revision to Diff 166992.Sep 25 2018, 2:27 PM
jdenny set the repository for this revision to rC Clang.

Ping. Rebased. This patch intends to perform cleanup that @rsmith suggested while reviewing another patch from me. If there's no more interest, it's fine with me to abandon. I'll wait at least one more week.

jdenny abandoned this revision.Oct 8 2018, 9:56 AM