Coverage Report

Created: 2018-09-25 23:22

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/clang/include/clang/Edit/FileOffset.h
Line
Count
Source (jump to first uncovered line)
1
//===- FileOffset.h - Offset in a file --------------------------*- C++ -*-===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_EDIT_FILEOFFSET_H
11
#define LLVM_CLANG_EDIT_FILEOFFSET_H
12
13
#include "clang/Basic/SourceLocation.h"
14
#include <tuple>
15
16
namespace clang {
17
namespace edit {
18
19
class FileOffset {
20
  FileID FID;
21
  unsigned Offs = 0;
22
23
public:
24
33.4k
  FileOffset() = default;
25
7.92k
  FileOffset(FileID fid, unsigned offs) : FID(fid), Offs(offs) {}
26
27
0
  bool isInvalid() const { return FID.isInvalid(); }
28
29
8.86k
  FileID getFID() const { return FID; }
30
7.39k
  unsigned getOffset() const { return Offs; }
31
32
17.6k
  FileOffset getWithOffset(unsigned offset) const {
33
17.6k
    FileOffset NewOffs = *this;
34
17.6k
    NewOffs.Offs += offset;
35
17.6k
    return NewOffs;
36
17.6k
  }
37
38
5.10k
  friend bool operator==(FileOffset LHS, FileOffset RHS) {
39
5.10k
    return LHS.FID == RHS.FID && 
LHS.Offs == RHS.Offs5.10k
;
40
5.10k
  }
41
42
2.22k
  friend bool operator!=(FileOffset LHS, FileOffset RHS) {
43
2.22k
    return !(LHS == RHS);
44
2.22k
  }
45
46
86.1k
  friend bool operator<(FileOffset LHS, FileOffset RHS) {
47
86.1k
    return std::tie(LHS.FID, LHS.Offs) < std::tie(RHS.FID, RHS.Offs);
48
86.1k
  }
49
50
1.78k
  friend bool operator>(FileOffset LHS, FileOffset RHS) {
51
1.78k
    return RHS < LHS;
52
1.78k
  }
53
54
5.19k
  friend bool operator>=(FileOffset LHS, FileOffset RHS) {
55
5.19k
    return !(LHS < RHS);
56
5.19k
  }
57
58
42
  friend bool operator<=(FileOffset LHS, FileOffset RHS) {
59
42
    return !(RHS < LHS);
60
42
  }
61
};
62
63
} // namespace edit
64
} // namespace clang
65
66
#endif // LLVM_CLANG_EDIT_FILEOFFSET_H