LLVM 24.0.0git
ConnectionSpec.cpp
Go to the documentation of this file.
1//===- ConnectionSpec.cpp - Connection spec parsing -----------------------===//
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
10
11using namespace llvm;
12using namespace llvm::orc;
13
15 return make_error<StringError>("in connection spec '" + Spec.str() +
16 "': " + Msg,
18}
19
21 if (!Spec.contains('='))
23 Spec, "expected '<transport>[:<action>]=<descriptor>', but found "
24 "no '='");
25
26 auto [LHS, Descriptor] = Spec.split('=');
27 auto [Transport, Action] = LHS.split(':');
28
29 if (Transport.empty())
30 return makeConnectionSpecError(Spec, "empty transport name");
31
32 // An action is optional, but writing the ':' that introduces one and then
33 // omitting it is an error.
34 if (LHS.contains(':') && Action.empty())
35 return makeConnectionSpecError(Spec, "empty action name");
36
37 return ConnectionSpec(Transport.str(), Action.str(), Descriptor.str());
38}
static Error makeConnectionSpecError(StringRef Spec, const Twine &Msg)
const char * Msg
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
static LLVM_ABI Expected< ConnectionSpec > parse(StringRef Spec)
Parses Spec as <transport>[:<action>]=<descriptor>.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI std::error_code inconvertibleErrorCode()
The value returned by this function can be returned from convertToErrorCode for Error values where no...
Definition Error.cpp:94
Error make_error(ArgTs &&... Args)
Make a Error instance representing failure using the given error info type.
Definition Error.h:340