LLVM
24.0.0git
lib
Frontend
Directive
Spelling.cpp
Go to the documentation of this file.
1
//===-------------------------------------------------------------- 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
#include "
llvm/Frontend/Directive/Spelling.h
"
10
11
#include "
llvm/ADT/StringRef.h
"
12
#include "
llvm/Frontend/Directive/Version.h
"
13
14
#include <cassert>
15
16
using namespace
llvm
;
17
18
llvm::StringRef
llvm::directive::FindName
(
19
llvm::iterator_range<const directive::Spelling *>
Range
,
20
directive::Version
Ver) {
21
// Do a linear search to find the first Spelling that contains Version.
22
// The condition "contains(S, Version)" does not partition the list of
23
// spellings, so std::[lower|upper]_bound cannot be used.
24
// In practice the list of spellings is expected to be very short, so
25
// linear search seems appropriate. In general, an interval tree may be
26
// a better choice, but in this case it may be an overkill.
27
for
(
auto
&S :
Range
) {
28
if
(S.Versions.contains(Ver))
29
return
S.Name;
30
}
31
return
StringRef
();
32
}
Range
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
Spelling.h
StringRef.h
Version.h
llvm::StringRef
Represent a constant reference to a string, i.e.
Definition
StringRef.h:56
llvm::iterator_range
A range adaptor for a pair of iterators.
Definition
iterator_range.h:31
llvm::directive::FindName
LLVM_ABI StringRef FindName(llvm::iterator_range< const Spelling * >, Version Version)
Definition
Spelling.cpp:18
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
DefaultTargetInfo.h:21
llvm::directive::Version
Definition
Version.h:18
Generated on
for LLVM by
1.14.0