Fixed analyzer issues and disabled clang in CI

This commit is contained in:
Ivan-lis 2024-10-21 09:08:40 +00:00
parent 72f96c2a86
commit 7315fda512
9 changed files with 170 additions and 114 deletions

View file

@ -12,21 +12,6 @@ RUN pacman -Syyu --noconfirm \
&& pacman -S --noconfirm cmake make gcc ninja meson shellcheck \
&& pacman -S --noconfirm gtk4 gtkmm-4.0 boost spdlog fmt libxml++-5.0
# Add cached layer with the latest LLVM-19.1.0
RUN mkdir -p /home/artifacts
ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.0/LLVM-19.1.0-Linux-X64.tar.xz /home/artifacts/
# Create the LLVM directory and extract only binaries into it
RUN mkdir -p /home/LLVM-19.1.0
RUN tar -xJf /home/artifacts/LLVM-19.1.0-Linux-X64.tar.xz -C /home/LLVM-19.1.0 --strip-components=1 LLVM-19.1.0-Linux-X64/bin/clang-19 LLVM-19.1.0-Linux-X64/bin/clang LLVM-19.1.0-Linux-X64/bin/clang++ LLVM-19.1.0-Linux-X64/bin/clang-scan-deps LLVM-19.1.0-Linux-X64/bin/clang-format LLVM-19.1.0-Linux-X64/bin/clang-tidy LLVM-19.1.0-Linux-X64/include/ LLVM-19.1.0-Linux-X64/lib/ LLVM-19.1.0-Linux-X64/libexec/ LLVM-19.1.0-Linux-X64/local/ LLVM-19.1.0-Linux-X64/share/
# Add /home/LLVM-19.1.0/bin to the PATH environment variable
ENV PATH="/home/LLVM-19.1.0/bin:${PATH}"
# Add extra tools
RUN mkdir -p /home/tools
ADD https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py /home/tools/
# Create a non-root user 'dev'
RUN useradd -ms /bin/bash dev \
&& echo "dev ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers.d/dev \
@ -36,10 +21,46 @@ RUN useradd -ms /bin/bash dev \
COPY --from=library/docker:latest /usr/local/bin/docker /usr/bin/docker
COPY --from=docker/compose:latest /usr/local/bin/docker-compose /usr/bin/docker-compose
# Allow dev to execute docker without sudo
RUN groupadd docker &&\
usermod -aG docker dev &&\
newgrp docker
# Switch to the 'dev' user
USER dev
# Add cached layer with the latest LLVM-${LLVM_VER}
ARG LLVM_VER=19.1.1
ENV LLVM_VER=${LLVM_VER}
RUN sudo mkdir -p /home/artifacts
ADD https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/LLVM-${LLVM_VER}-Linux-X64.tar.xz /home/artifacts/
# Create the LLVM directory and extract only binaries into it
RUN sudo mkdir -p /home/LLVM-${LLVM_VER}
RUN sudo tar -xJf /home/artifacts/LLVM-${LLVM_VER}-Linux-X64.tar.xz -C /home/LLVM-${LLVM_VER} --strip-components=1 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-19 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang \
LLVM-${LLVM_VER}-Linux-X64/bin/clang++ \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-scan-deps \
LLVM-${LLVM_VER}-Linux-X64/bin/llvm-symbolizer \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-format \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-tidy \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-apply-replacements \
LLVM-${LLVM_VER}-Linux-X64/include/ \
LLVM-${LLVM_VER}-Linux-X64/lib/ \
LLVM-${LLVM_VER}-Linux-X64/libexec/ \
LLVM-${LLVM_VER}-Linux-X64/local/ \
LLVM-${LLVM_VER}-Linux-X64/share/
# Add /home/LLVM-${LLVM_VER}/bin to the PATH environment variable
ENV PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
# Add extra tools
RUN sudo mkdir -p /home/tools
ADD https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py /home/tools/
RUN sudo chmod -R a+x /home/tools/
RUN sudo chown -R dev /home/tools/
# Add the custom bash prompt with branch info
RUN printf '\n\
function modify_prompt { \n\
@ -52,9 +73,6 @@ function modify_prompt { \n\
} \n\
modify_prompt\n' >> /home/dev/.bashrc
# Switch to the 'dev' user
USER dev
RUN git config --global core.editor vim
# Set the default working directory

View file

@ -15,25 +15,34 @@ jobs:
- name: Setup environment - Install LLVM-19.1.1
run: |
echo "" >> ~/.bashrc
echo "export LLVM_VER='LLVM-19.1.1'" >> ~/.bashrc
source ~/.bashrc
export LLVM_VER=19.1.1
echo "::group::Download $LLVM_VER"
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.1/LLVM-19.1.1-Linux-X64.tar.xz -O /$LLVM_VER-Linux-X64.tar.xz
echo "::group::Download LLVM-${LLVM_VER}"
wget https://github.com/llvm/llvm-project/releases/download/llvmorg-${LLVM_VER}/LLVM-${LLVM_VER}-Linux-X64.tar.xz -O /LLVM-${LLVM_VER}-Linux-X64.tar.xz
echo "::endgroup::"
echo "::group::Extracting $LLVM_VER"
mkdir -p /home/$LLVM_VER/
tar -xf /$LLVM_VER-Linux-X64.tar.xz -C "/home/$LLVM_VER/" --strip-components=1 $LLVM_VER-Linux-X64/bin/clang-19 $LLVM_VER-Linux-X64/bin/clang $LLVM_VER-Linux-X64/bin/clang++ $LLVM_VER-Linux-X64/bin/clang-scan-deps $LLVM_VER-Linux-X64/bin/clang-format $LLVM_VER-Linux-X64/bin/clang-tidy $LLVM_VER-Linux-X64/include/ $LLVM_VER-Linux-X64/lib/ $LLVM_VER-Linux-X64/libexec/ $LLVM_VER-Linux-X64/local/ $LLVM_VER-Linux-X64/share/
rm /$LLVM_VER-Linux-X64.tar.xz
echo "::group::Extracting LLVM-${LLVM_VER}"
mkdir -p /home/LLVM-${LLVM_VER}/
tar -xf /LLVM-${LLVM_VER}-Linux-X64.tar.xz -C "/home/LLVM-${LLVM_VER}/" --strip-components=1 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-19 \
LLVM-${LLVM_VER}-Linux-X64/bin/clang \
LLVM-${LLVM_VER}-Linux-X64/bin/clang++ \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-scan-deps \
LLVM-${LLVM_VER}-Linux-X64/bin/llvm-symbolizer \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-format \
LLVM-${LLVM_VER}-Linux-X64/bin/clang-tidy \
LLVM-${LLVM_VER}-Linux-X64/include/ \
LLVM-${LLVM_VER}-Linux-X64/lib/ \
LLVM-${LLVM_VER}-Linux-X64/libexec/ \
LLVM-${LLVM_VER}-Linux-X64/local/ \
LLVM-${LLVM_VER}-Linux-X64/share/
rm /LLVM-${LLVM_VER}-Linux-X64.tar.xz
echo "::endgroup::"
echo "" >> ~/.bashrc
echo "export PATH='/home/$LLVM_VER/bin:${PATH}'" >> ~/.bashrc
echo "LLVM version ${LLVM_VER}"
echo "Available LLVM binaries:"
ls -la /home/$LLVM_VER/bin/
ls -la /home/LLVM-${LLVM_VER}/bin/
- name: List CI environment variables
run: |
@ -45,6 +54,7 @@ jobs:
echo "Ref: ${{ github.ref }}"
echo "Ref name: ${{ github.ref_name }}"
echo "SHA: ${{ github.sha }}"
echo "PATH: ${PATH}"
- name: Check out repository code
run: |
@ -77,20 +87,21 @@ jobs:
# id: cache-llvm-19-bins-restore
# uses: actions/cache@v4
# with:
# path: /$LLVM_VER-Linux-X64-small.tar.xz
# key: $LLVM_VER-Linux-X64-small
# path: /LLVM-${LLVM_VER}-Linux-X64-small.tar.xz
# key: LLVM-${LLVM_VER}-Linux-X64-small
#
#- name: Save LLVM-19 to cache
# if: steps.cache-llvm-19-bins-restore.outputs.cache-hit != 'true'
# id: cache-llvm-19-save
# uses: actions/cache/save@v4
# with:
# path: /$LLVM_VER-Linux-X64-small.tar.xz
# key: $LLVM_VER-Linux-X64-small
# path: /LLVM-${LLVM_VER}-Linux-X64-small.tar.xz
# key: LLVM-${LLVM_VER}-Linux-X64-small
- name: Check clang-format
run: |
export PATH="/home/$LLVM_VER/bin:${PATH}"
export LLVM_VER=19.1.1
export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
cd ${{ github.workspace }}
find -type f \( -name "*.h" -o -name "*.hpp" -o -name "*.c" -o -name "*.cpp" \) > repo_sources_to_check.txt
export REPO_FILES=$(cat repo_sources_to_check.txt)
@ -103,43 +114,12 @@ jobs:
for FILE in $REPO_FILES; do clang-format -i ${{ github.workspace }}/$FILE --dry-run --Werror; done
echo "No clang-format violations detected!"
- name: Clang build with -fsanitize=address
environment:
CC: /home/$LLVM_VER/bin/clang
CXX: /home/$LLVM_VER/bin/clang++
run: |
mkdir -p ${{ github.workspace }}/build_clang
cmake -Wno-dev \
-DCMAKE_C_COMPILER=/home/$LLVM_VER/bin/clang \
-DCMAKE_CXX_COMPILER=/home/$LLVM_VER/bin/clang++ \
-S ${{ github.workspace }} \
-B ${{ github.workspace }}/build_clang \
-GNinja -DCMAKE_BUILD_TYPE=Release \
-DENABLE_EXAMPLES=ON \
-DENABLE_TESTS=ON \
-DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \
-DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr"
cmake --build ${{ github.workspace }}/build_clang --parallel `nproc`
- name: Clang unit tests with -fsanitize=address
run: |
cd ${{ github.workspace }}/build_clang
ASAN_SYMBOLIZER_PATH=/home/$LLVM_VER/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests
- name: Check clang-tidy
run: |
export PATH="/home/$LLVM_VER/bin:${PATH}"
wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
python run-clang-tidy.py -use-color -exclude-header-filter .*build.* -header-filter .hpp -p ${{ github.workspace }}/build_clang/ -config-file ${{ github.workspace }}/.clang-tidy ${{ github.workspace }}/examples ${{ github.workspace }}/library/ ${{ github.workspace }}/src/
echo "::warning::TODO Fix warnings and add '-warnings-as-errors' flags to report clang-tidy errors"
- name: GCC build
environment:
CC: /usr/sbin/gcc
CXX: /usr/sbin/g++
run: |
mkdir -p ${{ github.workspace }}/build_gcc
cmake -Wno-dev \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-S ${{ github.workspace }} \
-B ${{ github.workspace }}/build_gcc \
-GNinja -DCMAKE_BUILD_TYPE=Release \
@ -151,3 +131,46 @@ jobs:
run: |
cd ${{ github.workspace }}/build_gcc
./larra_xmpp_tests
- name: Check clang-tidy
run: |
export LLVM_VER=19.1.1
export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
wget https://raw.githubusercontent.com/llvm/llvm-project/refs/heads/main/clang-tools-extra/clang-tidy/tool/run-clang-tidy.py
python run-clang-tidy.py \
-use-color \
-warnings-as-errors all \
-exclude-header-filter .*build.* \
-header-filter .hpp \
-p ${{ github.workspace }}/build_gcc/ \
-config-file ${{ github.workspace }}/.clang-tidy \
\
${{ github.workspace }}/examples \
${{ github.workspace }}/library/ \
${{ github.workspace }}/src/
echo "No clang-tidy violations detected!"
#- name: Clang build with -fsanitize=address
# run: |
# export LLVM_VER=19.1.1
# export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
# mkdir -p ${{ github.workspace }}/build_clang
# cmake -Wno-dev \
# -DCMAKE_C_COMPILER=clang \
# -DCMAKE_CXX_COMPILER=clang++ \
# -S ${{ github.workspace }} \
# -B ${{ github.workspace }}/build_clang \
# -GNinja -DCMAKE_BUILD_TYPE=Release \
# -DENABLE_EXAMPLES=ON \
# -DENABLE_TESTS=ON \
# -DCMAKE_CXX_FLAGS="-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr" \
# -DCMAKE_EXE_LINKER_FLAGS="-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr"
# cmake --build ${{ github.workspace }}/build_clang --parallel `nproc`
#
#- name: Clang unit tests with -fsanitize=address
# run: |
# export LLVM_VER=19.1.1
# export PATH="/home/LLVM-${LLVM_VER}/bin:${PATH}"
# cd ${{ github.workspace }}/build_clang
# ASAN_SYMBOLIZER_PATH=llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests

34
.vscode/tasks.json vendored
View file

@ -18,10 +18,11 @@
},
{
// https://clang.llvm.org/extra/clang-tidy/
// Add ' -fix ' to automatically fix errors
"label": "Checker: clang-tidy dry-run",
"type": "shell",
"command": [
"python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy ",
"python /home/tools/run-clang-tidy.py -exclude-header-filter .*build.* -use-color -warnings-as-errors all -header-filter .hpp -p ${workspaceFolder}/build_clang/ -config-file ${workspaceFolder}/.clang-tidy",
" ${workspaceFolder}/examples ",
" ${workspaceFolder}/library/ ",
" ${workspaceFolder}/src/"
@ -67,8 +68,7 @@
"command": [
"cd ${workspaceFolder} &&",
"mkdir -p build && cd build &&",
"cmake -Wno-dev ",
" -DCMAKE_CXX_FLAGS=\"-Wno-non-template-friend\"",
"cmake cmake -Wno-dev ",
" -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON .."
],
"options": {
@ -132,8 +132,8 @@
],
"options": {
"env": {
"CC": "/home/LLVM-19.1.0/bin/clang",
"CXX": "/home/LLVM-19.1.0/bin/clang++"
"CC": "clang",
"CXX": "clang++"
}
},
"presentation": {
@ -149,13 +149,19 @@
"mkdir -p build_clang && cd build_clang &&",
"cmake -Wno-dev ",
" -DCMAKE_BUILD_TYPE=Debug -DENABLE_EXAMPLES=ON -DENABLE_TESTS=ON ",
" -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"",
" -DCMAKE_EXE_LINKER_FLAGS=\"-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\" ..",
//
// Uncomment for GCC standart library: libstdc++
//" -DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"",
//" -DCMAKE_EXE_LINKER_FLAGS=\"-L/usr/lib/x86_64-linux-gnu -lstdc++ -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"",
//
" -DCMAKE_CXX_FLAGS=\"-stdlib=libc++ -I/home/LLVM-19.1.1/include/c++/v1 -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"",
" -DCMAKE_EXE_LINKER_FLAGS=\"-L/home/LLVM-19.1.1/lib/ -Wl,-rpath,/home/LLVM-19.1.1/lib -lc++ -lc++abi -lm -lc -lgcc_s -lgcc -fuse-ld=lld -fno-omit-frame-pointer -g -fsanitize=address,undefined,leak,function,nullability,vptr\"",
" .."
],
"options": {
"env": {
"CC": "/home/LLVM-19.1.0/bin/clang",
"CXX": "/home/LLVM-19.1.0/bin/clang++"
"CC": "clang",
"CXX": "clang++"
}
},
"presentation": {
@ -174,7 +180,7 @@
"command": [
"cd ${workspaceFolder} &&",
"mkdir -p build_clang && cd build_clang &&",
"ASAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"",
"ASAN_SYMBOLIZER_PATH=llvm-symbolizer ASAN_OPTIONS=detect_stack_use_after_return=1:check_initialization_order=1:detect_leaks=1:atexit=1:abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"",
],
"presentation": {
"clear": true
@ -199,8 +205,8 @@
],
"options": {
"env": {
"CC": "/home/LLVM-19.1.0/bin/clang",
"CXX": "/home/LLVM-19.1.0/bin/clang++"
"CC": "clang",
"CXX": "clang++"
}
},
"presentation": {
@ -219,7 +225,7 @@
"command": [
"cd ${workspaceFolder} &&",
"mkdir -p build_clang && cd build_clang &&",
"MSAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"",
"MSAN_SYMBOLIZER_PATH=llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"",
],
"presentation": {
"clear": true
@ -253,7 +259,7 @@
"command": [
"cd ${workspaceFolder} &&",
"mkdir -p build_clang && cd build_clang &&",
"MSAN_SYMBOLIZER_PATH=/home/LLVM-19.1.0/bin/llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"",
"MSAN_SYMBOLIZER_PATH=llvm-symbolizer MSAN_OPTIONS=abort_on_error=1 ./larra_xmpp_tests ; echo \"exit code: $?\"",
],
"presentation": {
"clear": true

View file

@ -163,8 +163,10 @@ add_library(larra::larra_xmpp ALIAS larra_xmpp)
target_compile_features(larra_xmpp PUBLIC cxx_std_23)
target_compile_options(larra_xmpp PUBLIC "$<$<CXX_COMPILER_ID:GNU>:-Wno-changes-meaning>")
target_compile_options(larra_xmpp PUBLIC
"$<$<CXX_COMPILER_ID:GNU>:-Wno-changes-meaning>"
"$<$<CXX_COMPILER_ID:GNU>:-Wno-non-template-friend>"
)
target_include_directories(larra_xmpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/library/include>

View file

@ -138,7 +138,7 @@ struct boost::asio::ssl::stream<larra::xmpp::PrintStream<Socket>> : public boost
auto next_layer() -> next_layer_type& {
return static_cast<next_layer_type&>(this->Base::next_layer());
}
auto next_layer() const -> const next_layer_type& {
[[nodiscard]] auto next_layer() const -> const next_layer_type& {
return static_cast<const next_layer_type&>(this->Base::next_layer());
}
};

View file

@ -20,7 +20,8 @@ struct PlainUserAccount {
struct EncryptionUserAccount : PlainUserAccount {
using PlainUserAccount::PlainUserAccount;
constexpr EncryptionUserAccount(PlainUserAccount base) : PlainUserAccount{std::move(base)} {};
constexpr EncryptionUserAccount(BareJid jid, std::string password) : PlainUserAccount{std::move(jid), std::move(password)} {};
constexpr EncryptionUserAccount(BareJid jid, std::string password) :
PlainUserAccount{.jid = std::move(jid), .password = std::move(password)} {};
};
struct EncryptionRequiredUserAccount : EncryptionUserAccount {

View file

@ -98,7 +98,7 @@ struct XmlStream : Stream {
return *this;
}
auto next_layer() const -> const Stream& {
[[nodiscard]] auto next_layer() const -> const Stream& {
return *this;
}

View file

@ -53,30 +53,36 @@ struct DataHolder {
};
consteval auto GetDataForTag(sha512sum::EncryptionTag) {
return DataHolder{[] {
return DataHolder{.first =
[] {
return EVP_sha512();
},
kSha512ResultSize,
.second = kSha512ResultSize,
.third =
[](auto... args) {
return SHA512(args...);
}};
}
consteval auto GetDataForTag(sha256sum::EncryptionTag) {
return DataHolder{[] {
return DataHolder{.first =
[] {
return EVP_sha256();
},
kSha256ResultSize,
.second = kSha256ResultSize,
.third =
[](auto... args) {
return SHA256(args...);
}};
}
consteval auto GetDataForTag(sha1sum::EncryptionTag) {
return DataHolder{[] {
return DataHolder{.first =
[] {
return EVP_sha256();
},
kSha1ResultSize,
.second = kSha1ResultSize,
.third =
[](auto... args) {
return SHA1(args...);
}};

View file

@ -4,17 +4,17 @@
namespace larra::xmpp {
auto ParseBareJid(std::string_view jid, std::size_t at) -> BareJid {
return {static_cast<std::string>(jid.substr(0, at)), static_cast<std::string>(jid.substr(at + 1))};
return {.username = static_cast<std::string>(jid.substr(0, at)), .server = static_cast<std::string>(jid.substr(at + 1))};
}
auto ParseBareResourceJid(std::string_view jid, std::size_t slash) -> BareResourceJid {
return {static_cast<std::string>(jid.substr(0, slash)), static_cast<std::string>(jid.substr(slash + 1))};
return {.server = static_cast<std::string>(jid.substr(0, slash)), .resource = static_cast<std::string>(jid.substr(slash + 1))};
}
auto ParseFullJid(std::string_view jid, std::size_t at, std::size_t slash) -> FullJid {
return {static_cast<std::string>(jid.substr(0, at)),
static_cast<std::string>(jid.substr(at + 1, slash - at - 1)),
static_cast<std::string>(jid.substr(slash + 1))};
return {.username = static_cast<std::string>(jid.substr(0, at)),
.server = static_cast<std::string>(jid.substr(at + 1, slash - at - 1)),
.resource = static_cast<std::string>(jid.substr(slash + 1))};
}
auto BareJid::Parse(std::string_view jid) -> BareJid {