This is an archive of the discontinued LLVM Phabricator instance.

NFC: Implement OMPClause dump in terms of visitors
ClosedPublic

Authored by steveire on Jan 15 2019, 1:43 AM.

Diff Detail

Event Timeline

steveire created this revision.Jan 15 2019, 1:43 AM
aaron.ballman accepted this revision.Jan 15 2019, 11:05 AM

LGTM aside from a nit.

lib/AST/ASTDumper.cpp
1464

const auto *

lib/AST/TextNodeDumper.cpp
276–280

This pattern is coming up quite frequently. I wonder if we should factor this out into something like:

template <typename Ty>
bool dumpNullObject(const Ty *Val, StringRef Label) const {
  if (!Val) {
    ColorScope Color(OS, ShowColors, NullColor);
    OS << "<<<NULL>>> " << Label;  
  }
  return !Val;
}

So that uses become:

if (dumpNullObject(Whatever, "Whatever"))
  return;

Doesn't have to be done as part of this patch, but it seems like it might reduce some redundancy.

This revision is now accepted and ready to land.Jan 15 2019, 11:05 AM
This revision was automatically updated to reflect the committed changes.
steveire marked an inline comment as done.Jan 15 2019, 12:37 PM
steveire added inline comments.
lib/AST/TextNodeDumper.cpp
276–280

Something to come back to later I think. It would be more consistent now to have the label on the left side (dumping the various parts of an if() which may be nullptr), and in this OMPClause case, to not have a label on the right side.

Also - at least the 'OS << "<<<NULL>>>"' in the comment visitor is dead unreachable code.