This is an archive of the discontinued LLVM Phabricator instance.

Use fully qualified name when printing S_CONSTANT records
ClosedPublic

Authored by akhuang on Jun 7 2019, 9:35 AM.

Details

Summary

Before it was using the fully qualified name only for static data members.
Now it does for all variable names to match MSVC.

Diff Detail

Repository
rL LLVM

Event Timeline

akhuang created this revision.Jun 7 2019, 9:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2019, 9:35 AM
akhuang updated this revision to Diff 203609.Jun 7 2019, 1:13 PM

Add case for enums in classes.

rnk added inline comments.Jun 7 2019, 1:42 PM
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
3080–3081 ↗(On Diff #203609)

This seems like it would do the wrong thing for a regular constant that isn't an enum, but which has an enum type. This kind of thing:

namespace Bar {
enum Foo { FooA, FooB };
}
const Bar::Foo foo_gv = Bar::FooA;

... might come out as Bar::foo_gv when it should be just foo_gv.

I'm not actually sure what to do in this case, because we made enumerators look a lot like const ints, that was the whole idea. I mean, we could change clang to make them look like static const data members, I guess, but that seems like a step too far.

akhuang marked an inline comment as done.Jun 7 2019, 4:56 PM
akhuang added inline comments.
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
3080–3081 ↗(On Diff #203609)

It happens to do the right thing here because the type for global constants is a const tag.. but this seems kind of unreliable.

Other than making them look like static const data members or adding some enum type to the DIGlobalVariable, I can't really think of a good way to do this other than making the scope not global?

rnk added inline comments.Jun 10 2019, 1:12 PM
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
3080–3081 ↗(On Diff #203609)

Making the scope not global seems like the most logical thing to me. It sounds like there's no particularly good reason why we use the global scope for static data members, other than that's the DWARF we want to emit, so we can go ahead and revise that decision for enums.

akhuang marked an inline comment as done.Jun 10 2019, 1:57 PM
akhuang added inline comments.
llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
3080–3081 ↗(On Diff #203609)

Actually, enums in classes currently have global scope, so maybe that won't work

akhuang updated this revision to Diff 204137.Jun 11 2019, 12:56 PM

Change to not emit DIGlobalVariable for enums when they are defined in a class, which
matches MSVC's behavior and gets around the issue of having to create a name with scope.

Herald added a project: Restricted Project. · View Herald TranscriptJun 11 2019, 12:56 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
rnk accepted this revision.Jun 11 2019, 1:41 PM

lgtm

This revision is now accepted and ready to land.Jun 11 2019, 1:41 PM
This revision was automatically updated to reflect the committed changes.