This is an archive of the discontinued LLVM Phabricator instance.

Remove namespace lld { namespace coff { from COFF LLD cpp files
ClosedPublic

Authored by rnk on Feb 19 2020, 5:08 PM.

Details

Summary

Instead, use using namespace lld(::coff), and fully qualify the names
of free functions where they are defined in cpp files.

This effectively reverts d79c3be618 to follow the new style guide added
in 236fcbc21a7a8872.

Diff Detail

Event Timeline

rnk created this revision.Feb 19 2020, 5:08 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 19 2020, 5:08 PM
MaskRay added inline comments.Feb 19 2020, 6:25 PM
lld/COFF/DebugTypes.cpp
23

Other files using namespace lld before llvm.

rnk updated this revision to Diff 245753.Feb 20 2020, 2:53 PM
rnk marked an inline comment as done.
  • adjust namespace using
lld/COFF/DebugTypes.cpp
23

That's true. Actually, I'm not sure I like it. I started just feeding these blocks to vim :sort, but now it makes them like this:

using namespace lld::coff;
using namespace lld;
using namespace llvm::codeview;
using namespace llvm;

This seems kind of wrong, it's better to go most general to most specific. At the very least, we should use lld before lld::coff. By the same reasoning, we could put llvm before lld, since it has general things like ADT, StringRef, etc.

MaskRay added inline comments.Feb 20 2020, 3:29 PM
lld/COFF/DebugTypes.cpp
23

For #includes, we follow this order:

  • Main Module Header
  • Local/Private Headers
  • LLVM project/subproject headers (clang/..., lldb/..., llvm/..., etc)
  • System #includes

lld headers are included before LLVM headers. Now it becomes unclear to me why for using directives we follow a different convention......

rnk marked an inline comment as done.Feb 25 2020, 4:57 PM
rnk added inline comments.
lld/COFF/DebugTypes.cpp
23

I don't think we have rules because it really hasn't come up. LLVM just doesn't have that many namespaces, just llvm::, clang::, and some small per-library namespaces in that area. So we only ever have two or so using namespace decls in most source code. I don't feel like the header guidelines define an ordering between the project headers. For example, llvm includes and clang includes are part of the same block, sorted alphabetically.

In any case, as written now, it is closer to a straight revert. Should we do that and decide on namespace ordering rules another time?

MaskRay accepted this revision.Feb 25 2020, 5:10 PM
This revision is now accepted and ready to land.Feb 25 2020, 5:10 PM
This revision was automatically updated to reflect the committed changes.