This is an archive of the discontinued LLVM Phabricator instance.

[codeview] emit debug info for indirect virtual base classes
ClosedPublic

Authored by inglorion on Oct 13 2016, 3:01 PM.

Details

Summary

Fixes PR28281.

MSVC lists indirect virtual base classes in the field list of a class.
This change makes Clang emit the information necessary for LLVM to
emit such records.

Event Timeline

inglorion updated this revision to Diff 74589.Oct 13 2016, 3:01 PM
inglorion retitled this revision from to [codeview] emit debug info for indirect virtual base classes.
inglorion updated this object.
inglorion added reviewers: rnk, ruiu, zturner.
rnk added inline comments.Oct 13 2016, 3:45 PM
lib/CodeGen/CGDebugInfo.cpp
1370–1371

Some LLVM style idiosyncracies:
http://llvm.org/docs/CodingStandards.html

  • Variables start with leading capitals (I know it's weird)
  • We don't usually use auto unless the RHS repeats the type in a cast, make_unique, or new.
1371

Make this a DenseSet<const CXXRecordDecl*>, so that we don't need to call getOrCreateType, which is going to do more hash lookups.

1373

IMO SeenTypes.count(...) would be more idiomatic.

1377

This should be getCodeGenOpts().EmitCodeView.

1391

You should be able to use this as the key into SeenTypes. You also want to do Base = Base->getCanonicalDecl(), though, so that we don't end up with pointers to different redeclarations of the same record. I don't think I can construct a case where this would matter, but it's probably still worth it. :)

zturner added inline comments.Oct 13 2016, 3:54 PM
lib/CodeGen/CGDebugInfo.cpp
1370–1371
  1. Or the type is really gross.
  2. Or it's in a range-based for.
1373

What a silly function. I wonder why it isn't called contains() and return a bool.

ruiu added inline comments.Oct 13 2016, 3:59 PM
lib/CodeGen/CGDebugInfo.cpp
1373

It's probably because std::set doesn't provide contains() but count() too.

majnemer added inline comments.
lib/CodeGen/CGDebugInfo.cpp
1373

You can use is_contained from STLExtras.h, it should be maximally idiomatic :)

inglorion marked 5 inline comments as done.Oct 14 2016, 12:52 PM
inglorion updated this revision to Diff 74733.Oct 14 2016, 12:56 PM

@rnk's comments (thanks!)

  • Converted SeenTypes to a DenseSet<const CXXRecordDecl*>.
  • Switched to getCodeGenOpts().EmitCodeView to check if we should emit the extra records.
  • Switched to using SeenTypes.count(...) != 0 to check if we've seen a type.
inglorion updated this revision to Diff 74734.Oct 14 2016, 12:59 PM
  • Removed unused header.
rnk accepted this revision.Oct 19 2016, 4:30 PM
rnk edited edge metadata.

Thanks, looks good with some nits

lib/CodeGen/CGDebugInfo.cpp
1391

So, the playing field shifted. Justin Lebar recently added the CanonicalDeclPtr template, which does the getCanonicalDecl dance for you. Probably best to use that. :)

1394–1396

Now that we've figured out the best way to test set membership, I've realized we can save a hash lookup like this:

if (SeenTypes.insert(CanonicalBase).second)
  continue;
This revision is now accepted and ready to land.Oct 19 2016, 4:30 PM
inglorion updated this revision to Diff 75367.Oct 20 2016, 4:39 PM
inglorion edited edge metadata.

Updated to track the latest state of D25578

inglorion updated this revision to Diff 75381.Oct 20 2016, 5:38 PM

Use insert's return value to save a set lookup, and use CanonicalDeclPtr

We also need D25578 in before this can land.

This revision was automatically updated to reflect the committed changes.