This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Delete unused using statements (NFC)
ClosedPublic

Authored by aheejin on Nov 18 2018, 7:35 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

aheejin created this revision.Nov 18 2018, 7:35 PM

Great, thanks.

I'm not sure how you created this change, but I think using statements are like IWYU in that you don't want remove any line that can be removed and have the file still compile. i.e. you don't want to rely on recursively included using statements.

wasm/InputFiles.h
23 ↗(On Diff #174556)

Archive::Symbol does looks like its used below

wasm/SymbolTable.h
21 ↗(On Diff #174556)

These do look like they are used.

LLVM doesn't actually have an IWYU guideline though: https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible ... but also not a "dont IWYU".

Also this general problem is why Chrome has a rule against using namespace in header files. I like that rule because you can always tell by looking in the cpp file which namespaces are in scope.
If we do the same, then using directive in a cpp file can be removed if the file still compiles after removing it because we know it's not coming from somewhere else.

Also even if we adopt that convention for the wasm backend we might have to make an exception for using namespace llvm because it's so ubiquitous.

aheejin marked 2 inline comments as done.EditedNov 19 2018, 5:37 PM

Great, thanks.

I'm not sure how you created this change, but I think using statements are like IWYU in that you don't want remove any line that can be removed and have the file still compile. i.e. you don't want to rely on recursively included using statements.

Oh I see. So even if you can delete some of them because of other included headers, we don't necessarily want to remove them, right?
I happened to find a couple of really unused usings, and while submitting that, I thought maybe I'll spend 10 more mins find other possibly-can-be-deleted usings, and that's how ended up with this. Anyway, restored usings that are actually being used in the same file, even if it is included in other headers.

aheejin updated this revision to Diff 174717.Nov 19 2018, 5:37 PM
  • Restore some usings

LLVM doesn't actually have an IWYU guideline though: https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible ... but also not a "dont IWYU".

Also this general problem is why Chrome has a rule against using namespace in header files. I like that rule because you can always tell by looking in the cpp file which namespaces are in scope.

Looks like the current code complies with this.

If we do the same, then using directive in a cpp file can be removed if the file still compiles after removing it because we know it's not coming from somewhere else.

Also even if we adopt that convention for the wasm backend we might have to make an exception for using namespace llvm because it's so ubiquitous.

I agree, but it's lld, so maybe using namespace lld can belong to that ubiquitous realm?

sbc100 accepted this revision.Nov 20 2018, 7:28 AM
sbc100 added a subscriber: ruiu.

LLVM doesn't actually have an IWYU guideline though: https://llvm.org/docs/CodingStandards.html#include-as-little-as-possible ... but also not a "dont IWYU".

Also this general problem is why Chrome has a rule against using namespace in header files. I like that rule because you can always tell by looking in the cpp file which namespaces are in scope.
If we do the same, then using directive in a cpp file can be removed if the file still compiles after removing it because we know it's not coming from somewhere else.

Also even if we adopt that convention for the wasm backend we might have to make an exception for using namespace llvm because it's so ubiquitous.

Yes, I seem to remember @ruiu saying that was the policy for lld too. Lets try to remove all the using statements from the .h files. It seems the ELF/*.h already avoids doing this. COFF and wasm should probably follow suite.

This change to remove actually unused statements lgtm though in any case.

This revision is now accepted and ready to land.Nov 20 2018, 7:28 AM
This revision was automatically updated to reflect the committed changes.