brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 9f98a67 Raw
49 lines · python
1# DExTer : Debugging Experience Tester2# ~~~~~~   ~         ~~         ~   ~~3#4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5# See https://llvm.org/LICENSE.txt for license information.6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7import os8 9 10class LocIR:11    """Data class which represents a source location."""12 13    def __init__(self, path: str, lineno: int, column: int):14        if path:15            path = os.path.normcase(path)16        self.path = path17        self.lineno = lineno18        self.column = column19 20    def __str__(self):21        return "{}({}:{})".format(self.path, self.lineno, self.column)22 23    def __eq__(self, rhs):24        return (25            os.path.exists(self.path)26            and os.path.exists(rhs.path)27            and os.path.samefile(self.path, rhs.path)28            and self.lineno == rhs.lineno29            and self.column == rhs.column30        )31 32    def __lt__(self, rhs):33        if self.path != rhs.path:34            return False35 36        if self.lineno == rhs.lineno:37            return self.column < rhs.column38 39        return self.lineno < rhs.lineno40 41    def __gt__(self, rhs):42        if self.path != rhs.path:43            return False44 45        if self.lineno == rhs.lineno:46            return self.column > rhs.column47 48        return self.lineno > rhs.lineno49