Coverage Report

Created: 2020-09-15 12:33

/Users/buildslave/jenkins/workspace/coverage/llvm-project/clang/include/clang/Edit/FileOffset.h
Line
Count
Source (jump to first uncovered line)
1
//===- FileOffset.h - Offset in a file --------------------------*- 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
#ifndef LLVM_CLANG_EDIT_FILEOFFSET_H
10
#define LLVM_CLANG_EDIT_FILEOFFSET_H
11
12
#include "clang/Basic/SourceLocation.h"
13
#include <tuple>
14
15
namespace clang {
16
namespace edit {
17
18
class FileOffset {
19
  FileID FID;
20
  unsigned Offs = 0;
21
22
public:
23
37.6k
  FileOffset() = default;
24
8.82k
  FileOffset(FileID fid, unsigned offs) : FID(fid), Offs(offs) {}
25
26
0
  bool isInvalid() const { return FID.isInvalid(); }
27
28
15.6k
  FileID getFID() const { return FID; }
29
8.19k
  unsigned getOffset() const { return Offs; }
30
31
19.1k
  FileOffset getWithOffset(unsigned offset) const {
32
19.1k
    FileOffset NewOffs = *this;
33
19.1k
    NewOffs.Offs += offset;
34
19.1k
    return NewOffs;
35
19.1k
  }
36
37
5.46k
  friend bool operator==(FileOffset LHS, FileOffset RHS) {
38
5.46k
    return LHS.FID == RHS.FID && 
LHS.Offs == RHS.Offs5.46k
;
39
5.46k
  }
40
41
2.45k
  friend bool operator!=(FileOffset LHS, FileOffset RHS) {
42
2.45k
    return !(LHS == RHS);
43
2.45k
  }
44
45
92.5k
  friend bool operator<(FileOffset LHS, FileOffset RHS) {
46
92.5k
    return std::tie(LHS.FID, LHS.Offs) < std::tie(RHS.FID, RHS.Offs);
47
92.5k
  }
48
49
1.79k
  friend bool operator>(FileOffset LHS, FileOffset RHS) {
50
1.79k
    return RHS < LHS;
51
1.79k
  }
52
53
8.49k
  friend bool operator>=(FileOffset LHS, FileOffset RHS) {
54
8.49k
    return !(LHS < RHS);
55
8.49k
  }
56
57
170
  friend bool operator<=(FileOffset LHS, FileOffset RHS) {
58
170
    return !(RHS < LHS);
59
170
  }
60
};
61
62
} // namespace edit
63
} // namespace clang
64
65
#endif // LLVM_CLANG_EDIT_FILEOFFSET_H