clang
20.0.0git
lib
AST
SelectorLocationsKind.cpp
Go to the documentation of this file.
1
//===--- SelectorLocationsKind.cpp - Kind of selector locations -*- 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
// Describes whether the identifier locations for a selector are "standard"
10
// or not.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#include "
clang/AST/SelectorLocationsKind.h
"
15
#include "
clang/AST/Expr.h
"
16
17
using namespace
clang
;
18
19
static
SourceLocation
getStandardSelLoc
(
unsigned
Index,
20
Selector
Sel,
21
bool
WithArgSpace,
22
SourceLocation
ArgLoc,
23
SourceLocation
EndLoc) {
24
unsigned
NumSelArgs = Sel.
getNumArgs
();
25
if
(NumSelArgs == 0) {
26
assert(Index == 0);
27
if
(EndLoc.
isInvalid
())
28
return
SourceLocation
();
29
const
IdentifierInfo
*II = Sel.
getIdentifierInfoForSlot
(0);
30
unsigned
Len = II ? II->
getLength
() : 0;
31
return
EndLoc.
getLocWithOffset
(-Len);
32
}
33
34
assert(Index < NumSelArgs);
35
if
(ArgLoc.
isInvalid
())
36
return
SourceLocation
();
37
const
IdentifierInfo
*II = Sel.
getIdentifierInfoForSlot
(Index);
38
unsigned
Len =
/* selector id */
(II ? II->
getLength
() : 0) +
/* ':' */
1;
39
if
(WithArgSpace)
40
++Len;
41
return
ArgLoc.
getLocWithOffset
(-Len);
42
}
43
44
namespace
{
45
46
template
<
typename
T>
47
SourceLocation
getArgLoc(
T
* Arg);
48
49
template
<>
50
SourceLocation
getArgLoc<Expr>(