@@ -16,34 +16,38 @@ namespace codeql {
16
16
class TrapDomain ;
17
17
18
18
namespace detail {
19
+ template <typename T>
20
+ concept HasSourceRange = requires (T e) {
21
+ e.getSourceRange ();
22
+ };
23
+
19
24
template <typename T>
20
25
concept HasStartAndEndLoc = requires (T e) {
21
26
e.getStartLoc ();
22
27
e.getEndLoc ();
23
- };
28
+ }
29
+ &&!(HasSourceRange<T>);
24
30
25
31
template <typename T>
26
32
concept HasOneLoc = requires (T e) {
27
33
e.getLoc ();
28
34
}
29
- &&(!HasStartAndEndLoc<T>);
35
+ &&!(HasSourceRange<T>)&& (!HasStartAndEndLoc<T>);
30
36
31
37
template <typename T>
32
38
concept HasOneLocField = requires (T e) {
33
39
e.Loc ;
34
40
};
35
41
36
- template <typename T>
37
- concept HasSourceRangeOnly = requires (T e) {
38
- e.getSourceRange ();
42
+ swift::SourceRange getSourceRange (const HasSourceRange auto & locatable) {
43
+ return locatable.getSourceRange ();
39
44
}
40
- &&(!HasStartAndEndLoc<T>)&&(!HasOneLoc<T>);
41
45
42
46
swift::SourceRange getSourceRange (const HasStartAndEndLoc auto & locatable) {
43
47
if (locatable.getStartLoc () && locatable.getEndLoc ()) {
44
48
return {locatable.getStartLoc (), locatable.getEndLoc ()};
45
49
}
46
- return {};
50
+ return {locatable. getStartLoc () };
47
51
}
48
52
49
53
swift::SourceRange getSourceRange (const HasOneLoc auto & locatable) {
@@ -54,10 +58,6 @@ swift::SourceRange getSourceRange(const HasOneLocField auto& locatable) {
54
58
return {locatable.Loc };
55
59
}
56
60
57
- swift::SourceRange getSourceRange (const HasSourceRangeOnly auto & locatable) {
58
- return locatable.getSourceRange ();
59
- }
60
-
61
61
swift::SourceRange getSourceRange (const swift::Token& token);
62
62
63
63
template <typename Locatable>
@@ -70,7 +70,7 @@ swift::SourceRange getSourceRange(const llvm::MutableArrayRef<Locatable>& locata
70
70
if (startRange.Start && endRange.End ) {
71
71
return {startRange.Start , endRange.End };
72
72
}
73
- return {};
73
+ return {startRange. Start };
74
74
}
75
75
} // namespace detail
76
76
0 commit comments