Skip to content

Commit

Permalink
[fix] Get rid of dynamic_casts
Browse files Browse the repository at this point in the history
  • Loading branch information
Columpio committed Sep 4, 2023
1 parent abdbc00 commit 81d888a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
9 changes: 3 additions & 6 deletions include/klee/Module/SarifReport.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ struct LocRange {
virtual Precision maxPrecision() const = 0;
virtual size_t hash() const = 0;
virtual std::string toString() const = 0;
virtual bool operator==(const LocRange &other) const = 0;
bool hasInside(KInstruction *ki) const;
void hasInside(InstrWithPrecision &kp) const {
if (kp.precision > maxPrecision()) {
Expand Down Expand Up @@ -333,10 +332,8 @@ class LineColumnRange final : public LocRange {
kp.precision = Precision::Line;
}

bool operator==(const LocRange &other) const final {
if (auto p = dynamic_cast<LineColumnRange const*>(&other))
return startLine == p->startLine && endLine == p->endLine && startColumn == p->startColumn && endColumn == p->endColumn;
return false;
bool operator==(const LineColumnRange &p) const {
return startLine == p.startLine && endLine == p.endLine && startColumn == p.startColumn && endColumn == p.endColumn;
}
};

Expand Down Expand Up @@ -376,7 +373,7 @@ struct Location {
class ReferenceCounter _refCount;

bool operator==(const Location &other) const {
return filename == other.filename && *range == *other.range;
return filename == other.filename && range->getRange() == other.range->getRange();
}

bool isInside(const std::string &name) const;
Expand Down
6 changes: 0 additions & 6 deletions lib/Module/SarifReport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,6 @@ class InstructionRange : public LocRange {
kp.precision = std::min(kp.precision, Precision::Column);
}

bool operator==(const LocRange &other) const final {
if (auto p = dynamic_cast<InstructionRange const*>(&other))
return opCode == p->opCode && range == p->range;
return false;
}

protected:
virtual bool hasInsidePrecise(const KInstruction *ki) const { return true; }
};
Expand Down

0 comments on commit 81d888a

Please sign in to comment.