Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
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.
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.
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?
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.