Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ getDerivedParameter(const ClassTemplateSpecializationDecl *CRTP,
Arg.getAsType()->getAsCXXRecordDecl() == Derived;
});

return AnyOf ? CRTP->getSpecializedTemplate()
->getTemplateParameters()
->getParam(Idx - 1)
: nullptr;
return AnyOf && Idx > 0 ? CRTP->getSpecializedTemplate()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's possible for AnyOf to be true and Idx to be 0 at the same time. Idx starts as zero, but the call to any_of on line 54 has a lambda which explicitly does ++Idx, so any_of cannot return true without incrementing Idx.

If this came from a static analysis tool, I would claim it's a false positive that doesn't require changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if the range is empty Idx will be incremented?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the range is empty, then Idx is not incremented, but AnyOf will be false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closing the PR then. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the noise.

->getTemplateParameters()
->getParam(Idx - 1)
: nullptr;
}

static std::vector<FixItHint>
Expand Down
Loading