1 //===-- LVSort.h ------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the sort algorithms.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSORT_H
14 #define LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSORT_H
15 
16 namespace llvm {
17 namespace logicalview {
18 
19 class LVObject;
20 
21 // Object Sorting Mode.
22 enum class LVSortMode {
23   None = 0, // No given sort.
24   Kind,     // Sort by kind.
25   Line,     // Sort by line.
26   Name,     // Sort by name.
27   Offset    // Sort by offset.
28 };
29 
30 // Type of function to be called when sorting an object.
31 using LVSortValue = int;
32 using LVSortFunction = LVSortValue (*)(const LVObject *LHS,
33                                        const LVObject *RHS);
34 
35 // Get the comparator function, based on the command line options.
36 LVSortFunction getSortFunction();
37 
38 // Comparator functions that can be used for sorting.
39 LVSortValue compareKind(const LVObject *LHS, const LVObject *RHS);
40 LVSortValue compareLine(const LVObject *LHS, const LVObject *RHS);
41 LVSortValue compareName(const LVObject *LHS, const LVObject *RHS);
42 LVSortValue compareOffset(const LVObject *LHS, const LVObject *RHS);
43 LVSortValue compareRange(const LVObject *LHS, const LVObject *RHS);
44 LVSortValue sortByKind(const LVObject *LHS, const LVObject *RHS);
45 LVSortValue sortByLine(const LVObject *LHS, const LVObject *RHS);
46 LVSortValue sortByName(const LVObject *LHS, const LVObject *RHS);
47 
48 } // end namespace logicalview
49 } // end namespace llvm
50 
51 #endif // LLVM_DEBUGINFO_LOGICALVIEW_CORE_LVSORT_H
52