Closed Bug 1463907 Opened 6 years ago Closed 6 years ago

Clean up redundant uses of do_QueryInterface

Categories

(Developer Infrastructure :: Source Code Analysis, enhancement)

enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1493226

People

(Reporter: adrian17, Unassigned)

References

Details

Attachments

(2 files)

I've noticed that the codebase has a small amount of seemingly-redundant (casting to the same type or base type) interface conversions. It seems like some of them were caused by recent interface refactors and removals.

For example, what used to be

nsIDOMNode* aDestinationNode;
...
nsCOMPtr<nsINode> node = do_QueryInterface(aDestinationNode);

After bug 1449147 became

nsINode* aDestinationNode;
...
nsCOMPtr<nsINode> node = do_QueryInterface(aDestinationNode);

Which is clearly unnecessary.

I've written a simple Clang checker that detects such QI uses. I'll attach the patch (not for review, I don't think it should go into the repo?) and output. While I don't think it has false positives, some cases of QI to related type are intentional. Still, it should be a useful tool for cleaning such code.
Product: Core → Firefox Build System
Keywords: in-triage
Component: General → Source Code Analysis
Keywords: in-triage
See Also: → 1481645
I'm working on a patch for this, including fixes, in bug 1493226. I enforce it via a static_assert rather than a static analysis.
See Also: → 1493226
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → DUPLICATE
See Also: 1493226
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: