This is an archive of the discontinued LLVM Phabricator instance.

[ASTDump] Mark null params with a tag rather than a child node
ClosedPublic

Authored by steveire on Jan 15 2019, 3:46 PM.

Diff Detail

Event Timeline

steveire created this revision.Jan 15 2019, 3:46 PM

Do we have any test coverage for this change? IIRC, this was one we couldn't figure out how to trigger?

lib/AST/ASTDumper.cpp
637

Extra whitespace at the start of the string literal, or is that intentional? Also, do we want to standardize on <<<NULL>>> with three brackets instead of two?

647–648

You can drop getNumParams() here -- if param_begin() returns a non-null value, getNumParams() must return a non-zero value.

(param_begin() is implemented in terms of parameters(), which calls getNumParams() when setting up the returned ArrayRef.)

aaron.ballman added inline comments.Jan 16 2019, 5:30 AM
lib/AST/ASTDumper.cpp
637

Ah, I understand the whitespace now, so that was intentional I believe. Question remains about whether we want to also switch to use <<< consistently remains though.

aaron.ballman added inline comments.Jan 17 2019, 7:21 AM
lib/AST/ASTDumper.cpp
647–648

It seems that this is needed because the situation can arise when the function is not fully constructed yet, such as when calling dump() under the debugger.

I think this can be more clearly expressed as if (!D->param_empty() && !D->param_begin()), but should also have some comments explaining that this is guarding against a situation that only comes up while debugging, and thus is not covered by any existing test cases.

steveire updated this revision to Diff 182476.Jan 18 2019, 1:49 AM
steveire marked an inline comment as done.

Update

aaron.ballman accepted this revision.Jan 18 2019, 5:52 AM

With bracket and comment changes, LGTM. No need for tests on this one because the scenario changed can only occur during debugging.

lib/AST/ASTDumper.cpp
636

Re-flow comments to 80-col.

642

Let's make this <<<NULL params x blah>>> with three brackets instead of two.

This revision is now accepted and ready to land.Jan 18 2019, 5:52 AM
This revision was automatically updated to reflect the committed changes.