pax_global_header 0000666 0000000 0000000 00000000064 14622226652 0014521 g ustar 00root root 0000000 0000000 52 comment=a9626779c0eb910d67a9586ce8d739f859c42536
llvm-toolchain-integration-test-suite-main/ 0000775 0000000 0000000 00000000000 14622226652 0021364 5 ustar 00root root 0000000 0000000 llvm-toolchain-integration-test-suite-main/.github/ 0000775 0000000 0000000 00000000000 14622226652 0022724 5 ustar 00root root 0000000 0000000 llvm-toolchain-integration-test-suite-main/.github/workflows/ 0000775 0000000 0000000 00000000000 14622226652 0024761 5 ustar 00root root 0000000 0000000 llvm-toolchain-integration-test-suite-main/.github/workflows/CI.yml 0000664 0000000 0000000 00000011703 14622226652 0026001 0 ustar 00root root 0000000 0000000 name: Build with different version
on:
push:
pull_request:
schedule:
- cron: "0 2 * * *"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04]
version: [10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
steps:
- uses: actions/checkout@v2
- name: Set Ubuntu codename (Bionic)
if: ${{ matrix.os == 'ubuntu-18.04'}}
run: echo "UBUNTU_CODENAME=bionic" >> $GITHUB_ENV
- name: Set Ubuntu codename (Focal)
if: ${{ matrix.os == 'ubuntu-20.04'}}
run: echo "UBUNTU_CODENAME=focal" >> $GITHUB_ENV
- name: Install Dependencies
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
if test ${{ matrix.version }} == 19; then
sudo apt-add-repository "deb http://apt.llvm.org/${{ env.UBUNTU_CODENAME }}/ llvm-toolchain-${{ env.UBUNTU_CODENAME }} main"
else
sudo apt-add-repository "deb http://apt.llvm.org/${{ env.UBUNTU_CODENAME }}/ llvm-toolchain-${{ env.UBUNTU_CODENAME }}-${{ matrix.version }} main"
fi
if test ${{ matrix.version }} -ge 14 -a ${{ env.UBUNTU_CODENAME }} == "bionic"; then
# Recent versions of llvm need a compiler with C++ 20 support. Bionic doesn't have this out of the box.
# It requires a more recent version of libstdc++
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
fi
sudo apt-get update
sudo apt-get install -y clang-${{ matrix.version }} clangd-${{ matrix.version }} clang-tidy-${{ matrix.version }} clang-format-${{ matrix.version }} clang-tools-${{ matrix.version }} llvm-${{ matrix.version }}-dev lld-${{ matrix.version }} lldb-${{ matrix.version }} llvm-${{ matrix.version }}-tools libomp-${{ matrix.version }}-dev libc++-${{ matrix.version }}-dev libc++abi-${{ matrix.version }}-dev libclang-common-${{ matrix.version }}-dev libclang-${{ matrix.version }}-dev libclang-cpp${{ matrix.version }}-dev
if test ${{ matrix.version }} -gt 11; then
sudo apt-get install -y libunwind-${{ matrix.version }}-dev
fi
# C++ backend for mlir only appeared with LLVM 14
if test ${{ matrix.version }} -gt 13; then
sudo apt-get install -y mlir-${{ matrix.version }}-tools libmlir-${{ matrix.version }}-dev
fi
# Exists only after LLVM 15
if test ${{ matrix.version }} -gt 14; then
sudo apt-get install -y libpolly-${{ matrix.version }}-dev
fi
- name: Run the testsuite
shell: bash
run: |
# temporary workaround
# The path to analyze-cc needs to be set, it will be fixed in
# future upload of apt.llvm.org
export PATH=$PATH:/usr/share/clang/scan-build-py-${{ matrix.version }}/bin/:/usr/lib/llvm-${{ matrix.version }}/libexec
mkdir build && cd build
LIBUNWIND_ENABLED=ON
STATIC_LIBCXX_ENABLED=ON
if test ${{ matrix.version }} -lt 12; then
# Libunwind has been packaged only from 12
LIBUNWIND_ENABLED=OFF
# libc++.a did not link libc++abi.a on old versions
STATIC_LIBCXX_ENABLED=OFF
fi
cmake -DLIT=/usr/lib/llvm-${{ matrix.version }}/build/utils/lit/lit.py \
-DCLANG_BINARY=/usr/bin/clang-${{ matrix.version }} \
-DCLANGXX_BINARY=/usr/bin/clang++-${{ matrix.version }} \
-DCLANG_TIDY_BINARY=/usr/bin/clang-tidy-${{ matrix.version }} \
-DCLANG_FORMAT_BINARY=/usr/bin/clang-format-${{ matrix.version }} \
-DCLANG_FORMAT_DIFF_BINARY=/usr/bin/clang-format-diff-${{ matrix.version }} \
-DCLANGD_BINARY=/usr/bin/clangd-${{ matrix.version }} \
-DLLD_BINARY=/usr/bin/lld-${{ matrix.version }} \
-DLLDB_BINARY=/usr/bin/lldb-${{ matrix.version }} \
-DLLVMCONFIG_BINARY=/usr/bin/llvm-config-${{ matrix.version }} \
-DLLVMOBJDUMP_BINARY=/usr/bin/llvm-objdump-${{ matrix.version }} \
-DOPT_BINARY=/usr/bin/opt-${{ matrix.version }} \
-DSCANBUILD=/usr/bin/scan-build-${{ matrix.version }} \
-DSCANBUILDPY=/usr/bin/scan-build-py-${{ matrix.version }} \
-DCLANG_TIDY_BINARY=/usr/bin/clang-tidy-${{ matrix.version }} \
-DSCANVIEW=/usr/bin/scan-view-${{ matrix.version }} \
-DLLVMNM=/usr/bin/llvm-nm-${{ matrix.version }} \
-DLLC=/usr/bin/llc-${{ matrix.version }} \
-DLLI=/usr/bin/lli-${{ matrix.version }} \
-DOPT=/usr/bin/opt-${{ matrix.version }} \
-DMLIRTRANSLATE=/usr/bin/mlir-translate-${{ matrix.version }} \
-DLLVMPROFDATA=/usr/bin/llvm-profdata-${{ matrix.version }} \
-DENABLE_COMPILER_RT=ON \
-DENABLE_LIBCXX=ON \
-DENABLE_STATIC_LIBCXX=$STATIC_LIBCXX_ENABLED \
-DENABLE_LIBUNWIND=$LIBUNWIND_ENABLED \
../
# debug the output
cat tests/lit.site.cfg
make check
llvm-toolchain-integration-test-suite-main/.github/workflows/archlinux.yml 0000664 0000000 0000000 00000001254 14622226652 0027503 0 ustar 00root root 0000000 0000000 name: Build on Arch Linux
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
container:
image: "archlinux"
# These options are required to be able to run lldb inside the container
options: "--cap-add=SYS_PTRACE --security-opt seccomp=unconfined"
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: pacman -Syu --noconfirm llvm clang cmake make lld lldb gcc libc++ openmp
- name: Run the testsuite
run: |
mkdir build && cd build
cmake .. -DENABLE_LIBUNWIND=OFF -DENABLE_STATIC_LIBCXX=OFF
cmake --build . --target check -v
llvm-toolchain-integration-test-suite-main/.github/workflows/fedora.yml 0000664 0000000 0000000 00000001722 14622226652 0026746 0 ustar 00root root 0000000 0000000 name: Build on fedora
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
fedora-version: [38, 39, rawhide]
container:
image: "fedora:${{matrix.fedora-version}}"
# These options are required to be able to run lldb inside the container
options: "--cap-add=SYS_PTRACE --security-opt seccomp=unconfined"
steps:
- uses: actions/checkout@v2
- name: Install Dependencies
run: |
sudo dnf install -y llvm-devel clang-devel cmake make python3-lit \
lld lldb clang-analyzer clang-tools-extra gcc gcc-c++ \
libcxx-devel compiler-rt libstdc++-devel \
glibc-static libcxx-static libstdc++-static mlir mlir-devel \
llvm-libunwind llvm-libunwind-devel
- name: Run the testsuite
run: |
mkdir build && cd build
cmake ..
cmake --build . --target check -v
llvm-toolchain-integration-test-suite-main/CMakeLists.txt 0000664 0000000 0000000 00000005760 14622226652 0024134 0 ustar 00root root 0000000 0000000 cmake_minimum_required(VERSION 3.4.3)
message(STATUS "Checking for lit")
find_program(LIT lit)
if(NOT LIT)
message(FATAL_ERROR "lit program not found")
endif()
macro(find_program_or_warn OUT_VAR name)
message(STATUS "Checking for ${name}")
find_program(${OUT_VAR} ${name})
if (NOT ${OUT_VAR})
message(STATUS "Disabling tests related to ${name}")
endif()
endmacro()
macro(find_library_or_warn OUT_VAR name)
cmake_parse_arguments(MY_FIND "" "" "HINTS" ${ARGN} )
message(STATUS "Checking for ${name}")
find_library(${OUT_VAR} ${name} HINTS ${MY_FIND_HINTS})
if (NOT ${OUT_VAR})
message(WARNING "${name} not found. Disabling tests related to ${name}")
endif()
endmacro()
find_program_or_warn(CLANGXX_BINARY clang++)
find_program_or_warn(CLANG_BINARY clang)
find_program_or_warn(CLANG_TIDY_BINARY clang-tidy)
find_program_or_warn(CLANG_FORMAT_BINARY clang-format)
find_program_or_warn(CLANG_FORMAT_DIFF_BINARY clang-format-diff)
find_program_or_warn(CLANGD_BINARY clangd)
find_program_or_warn(OPT_BINARY opt)
find_program_or_warn(LLVMNM llvm-nm)
find_program_or_warn(LLC llc)
find_program_or_warn(LLI lli)
find_program_or_warn(OPT opt)
find_program_or_warn(LLVMPROFDATA llvm-profdata)
find_program_or_warn(LLD_BINARY lld)
find_program_or_warn(LLDB_BINARY lldb)
find_program_or_warn(LLVMCONFIG_BINARY llvm-config)
find_program_or_warn(LLVMOBJDUMP_BINARY llvm-objdump)
find_program_or_warn(SCANBUILD scan-build)
find_program_or_warn(SCANVIEW scan-view)
find_program_or_warn(SCANBUILDPY scan-build-py)
find_program_or_warn(MLIRTRANSLATE mlir-translate)
set(CMAKE_C_COMPILER ${CLANG_BINARY})
set(CMAKE_CXX_COMPILER ${CLANGXX_BINARY})
project(LLVMToolchainIntegrationTestSuite VERSION 1.0 LANGUAGES NONE)
enable_language(C)
enable_language(CXX)
option(ENABLE_COMPILER_RT "assume compiler-rt is available" ON)
option(ENABLE_LIBCXX "assume libc++ is available" ON)
option(ENABLE_STATIC_LIBCXX "assume libc++.a is available" ON)
option(ENABLE_LIBUNWIND "assume libunwind is available" ON)
# Detect if libomp is supported. Ubuntu stores the symlink library under a
# version-dependent directory so we need to provide a hint to CMake to find it.
string(REGEX MATCH "^[0-9]+" LLVM_MAJOR ${CMAKE_C_COMPILER_VERSION})
find_library_or_warn(LIBOMP libomp.so HINTS /usr/lib/llvm-${LLVM_MAJOR}/lib/)
message(STATUS "Checking kernel support for tagged address ABI")
try_run(
_TEST_RUN_RESULT
_BUILD_RESULT_UNUSED
${CMAKE_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/test_tagged_addr_abi_support.c
)
if(DEFINED _TEST_RUN_RESULT AND _TEST_RUN_RESULT EQUAL 0)
set(SUPPORT_HWASAN ON)
else()
message(STATUS "Tagged address ABI disabled, disabling hwasan test(s)")
set(SUPPORT_HWASAN OFF)
endif()
option(ENABLE_HWASAN
"The host supports Aarch64 tagged address ABI"
${SUPPORT_HWASAN}
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/tests/lit.site.cfg.in
${CMAKE_BINARY_DIR}/tests/lit.site.cfg
)
add_custom_target(check ${LIT} --show-unsupported --show-xfail -v tests)
llvm-toolchain-integration-test-suite-main/LICENSE.txt 0000664 0000000 0000000 00000026136 14622226652 0023217 0 ustar 00root root 0000000 0000000
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
llvm-toolchain-integration-test-suite-main/README.rst 0000664 0000000 0000000 00000004322 14622226652 0023054 0 ustar 00root root 0000000 0000000 LLVM Toolchain Integration Test Suite
#####################################
An agglomeration of integration tests for the `LLVM Toolchain `_.
Unlike the various existing llvm testing suites, this is meant to be used in an installed
environment to detect packaging issues.
This is an initiative started by Debian/Ubuntu and Fedora maintainers to agregate the testing effort.
Hopefully, this project will be also a forcing function to bring more consistency in the LLVM
toolchain packaging.
Requirements
------------
The `lit `_ tool is used to run the tests and
`cmake `_ is used for the configuration step.
Usage
-----
From source directory:
.. code-block:: sh
> mkdir _build && cd _build
> cmake ..
> make check
Sensible configuration variables
--------------------------------
- ``LIT``: path to the lit program
- ``CLANG_BINARY``: path to the clang binary to check
- ``CLANGXX_BINARY``: path to the clang++ binary to check
- ``CLANG_TIDY_BINARY``: path to the clang tidy binary to check
- ``LLD_BINARY``: path to the lld binary to check
- ``LLDB_BINARY``: path to the lldb binary to check
- ``ENABLE_COMPILER_RT``: ON (the default) if we assume compiler-rt is available
- ``ENABLE_LIBCXX``: ON (the default) if we assume libc++ is available
- ``ENABLE_STATIC_LIBCXX``: ON (the default) if we assume libc++.a is available
- ``ENABLE_LIBUNWIND``: ON (the default) if we assume libunwind is available
- ``ENABLE_HWASAN``: Run hwasan tests. Autodetected based on the host system.
- ``ENABLE_LIBOMP``: Run libomp tests. Autodetected based on the system. It can
be manually forced via `-DENABLE_LIBOMP=` at cmake configure time
Writing new tests
-----------------
Just drop a new file under ``tests/``, using the lit format. Please use the following substitutions and requirements:
Lit substitutions
+++++++++++++++++
- ``%clang``
- ``%clangxx``
- ``%clang-tidy``
- ``%lldb``
- ``%lld``
- ``%scan-build``
- ``%scan-view``
- ``%scan-build-py``
requirements
++++++++++++
- clang
- clangxx
- clang-tidy
- lldb
- lld
- scanbuild
- scanbuild-py
- scanview
License
-------
See LICENSE.txt
llvm-toolchain-integration-test-suite-main/test_tagged_addr_abi_support.c 0000664 0000000 0000000 00000000621 14622226652 0027422 0 ustar 00root root 0000000 0000000 /*
* This simple program checks if the kernel running the testsuite has support
* for tagged address ABI, needed to test hardware assisted address sanitizer.
* https://www.kernel.org/doc/html/next/arm64/tagged-address-abi.html
*
* The program returns 0 if the kernel supports tagged address ABI.
*/
#include
int main(void)
{
return prctl(PR_GET_TAGGED_ADDR_CTRL, 0,0,0,0);
}
llvm-toolchain-integration-test-suite-main/tests/ 0000775 0000000 0000000 00000000000 14622226652 0022526 5 ustar 00root root 0000000 0000000 llvm-toolchain-integration-test-suite-main/tests/Inputs/ 0000775 0000000 0000000 00000000000 14622226652 0024010 5 ustar 00root root 0000000 0000000 llvm-toolchain-integration-test-suite-main/tests/Inputs/clangd.json 0000664 0000000 0000000 00000001702 14622226652 0026133 0 ustar 00root root 0000000 0000000 {
"jsonrpc": "2.0",
"id": 0,
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"completion": {
"completionItem": {
"snippetSupport": true
}
}
}
},
"trace": "off"
}
}
---
{
"jsonrpc": "2.0",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "test:///main.cpp",
"languageId": "cpp",
"version": 1,
"text": "int func_with_args(int a, int b);\nint main() {\nfunc_with\n}"
}
}
}
---
{
"jsonrpc": "2.0",
"id": 1,
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "test:///main.cpp"
},
"position": {
"line": 2,
"character": 7
}
}
}
---
{
"jsonrpc": "2.0",
"id": 4,
"method": "shutdown"
}
---
{
"jsonrpc": "2.0",
"method": "exit"
}
llvm-toolchain-integration-test-suite-main/tests/Inputs/foo.c 0000664 0000000 0000000 00000000035 14622226652 0024735 0 ustar 00root root 0000000 0000000 int foo(void) { return 0; }
llvm-toolchain-integration-test-suite-main/tests/Inputs/llvm_newpm_pass.cpp 0000664 0000000 0000000 00000003476 14622226652 0027734 0 ustar 00root root 0000000 0000000 //=== Example code from "Writing an LLVM Pass" ----------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements a simple LLVM Pass using the new pass manager, based on
// the version described in docs/WritingAnLLVMNewPMPass.html
//
//===----------------------------------------------------------------------===//
#include "llvm/IR/PassManager.h"
#include "llvm/Passes/PassBuilder.h"
#include "llvm/Passes/PassPlugin.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
class HelloWorldNewPMPass : public PassInfoMixin {
public:
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
static bool isRequired() { return true; }
};
PreservedAnalyses HelloWorldNewPMPass::run(
Function &F,
FunctionAnalysisManager &AM)
{
errs() << "Function name: " << F.getName() << "\n";
return PreservedAnalyses::all();
}
// Documented in https://llvm.org/doxygen/PassPlugin_8h_source.html
extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
llvmGetPassPluginInfo() {
return {
LLVM_PLUGIN_API_VERSION, "HelloWorldNewPM", "v0.1", [](PassBuilder &PB) {
PB.registerPipelineParsingCallback(
[](StringRef Name, FunctionPassManager &FPM,
ArrayRef) {
if (Name == "hellonewpm") {
FPM.addPass(HelloWorldNewPMPass());
return true;
}
return false;
}
);
}
};
}
} // namespace llvm
llvm-toolchain-integration-test-suite-main/tests/atomic_fetch.c 0000664 0000000 0000000 00000000327 14622226652 0025321 0 ustar 00root root 0000000 0000000 // Test atomic_init() https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=903709
//
// REQUIRES: clang
// RUN: %clang -c %s
#include
void increment(atomic_size_t *arg) {
atomic_fetch_add(arg, 1);
}
llvm-toolchain-integration-test-suite-main/tests/basic_clang_tidy.cpp 0000664 0000000 0000000 00000000414 14622226652 0026507 0 ustar 00root root 0000000 0000000 // Test check tidy check
// Verify that a checker finds something
//
// RUN: %clang-tidy -checks='modernize-concat-nested-namespaces' %s -extra-arg=-std=c++17 | grep "nested namespaces can"
// REQUIRES: clang-tidy
namespace mozilla {
namespace dom {
void foo();
}
}
llvm-toolchain-integration-test-suite-main/tests/basic_debuginfo.c 0000664 0000000 0000000 00000001372 14622226652 0026000 0 ustar 00root root 0000000 0000000 // Test that debuginfo produced by clang is compatible with basic dwarf tool
// from https://rosettacode.org/wiki/Guess_the_number#C
// RUN: %clang -g3 -gdwarf-4 %s -o %t && objdump -g --dwarf-check %t | grep -E 'DWARF Version:\s*4'
// REQUIRES: clang
#include
#include
#include
int main(void)
{
srand(time(NULL));
int n = 1 + (rand() % 10);
puts("I'm thinking of a number between 1 and 10.");
puts("Try to guess it:");
int g;
while (1) {
if (scanf("%d", &g) != 1) {
/* ignore one char, in case user gave a non-number */
char c;
scanf("%c", &c);
continue;
}
if (g == n) {
puts("Correct!");
return 0;
}
puts("That's not my number. Try another guess:");
}
}
llvm-toolchain-integration-test-suite-main/tests/basic_lib++.cpp 0000664 0000000 0000000 00000001330 14622226652 0025264 0 ustar 00root root 0000000 0000000 // Test libc++ headers and lib detection
//
// RUN: %clangxx -stdlib=libc++ %s -o %t
// RUN: %t
// ldd %t 2>&1|grep -q libc++.so.1
// ldd %t 2>&1|grep -q libc++abi.so.1
// RUN: %clangxx -std=c++11 -stdlib=libc++ %s -o %t
// RUN: %t
// RUN: %clangxx -std=c++14 -stdlib=libc++ %s -o %t
// RUN: %t
// RUN: %clangxx -std=c++17 -stdlib=libc++ %s -o %t
// RUN: %t
// REQUIRES: clangxx, libc++
#include
#include
#include
using namespace std;
int main(void) {
vector tab;
tab.push_back("the");
tab.push_back("world");
tab.insert(tab.begin(), "Hello");
for(vector::iterator it=tab.begin(); it!=tab.end(); ++it)
{
cout << *it << " ";
}
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/basic_lib++2.cpp 0000664 0000000 0000000 00000000615 14622226652 0025353 0 ustar 00root root 0000000 0000000 // Test a libc++ issues reported https://bugs.launchpad.net/ubuntu/+source/libc++/+bug/1586215
//
// RUN: %clangxx -stdlib=libc++ -Wall -Werror %s -o %t
// RUN: %t
// REQUIRES: clangxx, libc++
#include
#include
int main()
{
try
{
std::string x;
char z = x.at(2);
std::cout << z << std::endl;
}
catch (...)
{
}
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/basic_lldb.c 0000664 0000000 0000000 00000000255 14622226652 0024752 0 ustar 00root root 0000000 0000000 // RUN: %clang -g -o %t %s
// RUN: %lldb -s %S/basic_lldb.in %t | grep "main at basic_lldb.c:"
// REQUIRES: lldb, clang
// XFAIL: ppc64
int main() {
int a=0;
return a;
}
llvm-toolchain-integration-test-suite-main/tests/basic_lldb.in 0000664 0000000 0000000 00000000023 14622226652 0025127 0 ustar 00root root 0000000 0000000 b main
run
bt
quit
llvm-toolchain-integration-test-suite-main/tests/basic_lldb2.cpp 0000664 0000000 0000000 00000000336 14622226652 0025374 0 ustar 00root root 0000000 0000000 // RUN: %clangxx -g -o %t %s
// RUN: %lldb -s %S/basic_lldb2.in %t | grep "stop reason = step over"
// REQUIRES: lldb, clangxx
// XFAIL: ppc64
#include
int main (void)
{ std::vector a;
a.push_back (0);
}
llvm-toolchain-integration-test-suite-main/tests/basic_lldb2.in 0000664 0000000 0000000 00000000024 14622226652 0025212 0 ustar 00root root 0000000 0000000 b main
r
n
p a
quit
llvm-toolchain-integration-test-suite-main/tests/basic_openmp.c 0000664 0000000 0000000 00000000463 14622226652 0025334 0 ustar 00root root 0000000 0000000 // Test OpenMP headers and lib detection
//
// RUN: %clang -fopenmp %s -o %t
// RUN: %t | grep "Num Threads: 1"
// REQUIRES: clang, libomp
#include
#include
int main(int argc, char **argv) {
int nthreads = omp_get_num_threads();
printf("Num Threads: %d\n", nthreads);
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/buildid.c 0000664 0000000 0000000 00000000660 14622226652 0024310 0 ustar 00root root 0000000 0000000 // Checks that we generate BuildID
//
// REQUIRES: clang, lld, llvm-objdump
// RUN: %clang -fuse-ld=lld -flto -O2 %S/Inputs/foo.c %s -o %t
// RUN: %t
// RUN: %llvm-objdump -s %t|grep note.gnu.build-id
// RUN: %clang -O2 %S/Inputs/foo.c %s -o %t
// RUN: %t
// RUN: %llvm-objdump -s %t|grep note.gnu.build-id
// RUN: strip %t
// RUN: %llvm-objdump -s %t|grep note.gnu.build-id
int foo(void);
int main() {
foo();
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/clang_format.c 0000664 0000000 0000000 00000000317 14622226652 0025327 0 ustar 00root root 0000000 0000000 // Test clang-format availability
//
// RUN: %clang-format %s | grep -E '^#include '
// REQUIRES: clang-format
#include
int
main() { puts("hello"
"world")
;
return
0;
}
llvm-toolchain-integration-test-suite-main/tests/code_coverage.cpp 0000664 0000000 0000000 00000000604 14622226652 0026017 0 ustar 00root root 0000000 0000000 // Test code coverage
//
// RUN: mkdir -p %t/test && cd %t/test
// RUN: %clang --coverage %s -o foo
// RUN: ./foo
// RUN: test -f code_coverage.gcno -o -f foo-code_coverage.gcno
// RUN: test -f code_coverage.gcda -o -f foo-code_coverage.gcda
// REQUIRES: clang
#include
int main() {
if (1==1) {
printf("true");
} else {
printf("false");
return 42;
}
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/code_profiling.cpp 0000664 0000000 0000000 00000000640 14622226652 0026215 0 ustar 00root root 0000000 0000000 // Test code coverage
//
// RUN: %clang -fprofile-instr-generate %s -o foo
// RUN: LLVM_PROFILE_FILE="foo.profraw" ./foo
// RUN: %llvm-profdata merge -output=foo.profdata foo.profraw
// RUN: %clang -fprofile-instr-use=foo.profdata %s -o foo
// RUN: ./foo
// REQUIRES: clang, llvm-profdata
#include
int main() {
if (1==1) {
printf("true");
} else {
printf("false");
return 42;
}
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/format_diff.c 0000664 0000000 0000000 00000000532 14622226652 0025152 0 ustar 00root root 0000000 0000000 // Make sure clang-format-diff works as expected
//
// REQUIRES: clang-format-diff, clang
// RUN: %clang -E -Wp,-P %s -DV0 > %t.0.c
// RUN: %clang -E -Wp,-P %s -DV1 > %t.1.c
// RUN: diff -u %t.0.c %t.1.c || true > %t.patch
// RUN: %clang-format-diff -i < %t.patch
#if defined(V0)
int main() {
}
#elif defined(V1)
int main() { return 0;
}
#endif
llvm-toolchain-integration-test-suite-main/tests/from_chars.cpp 0000664 0000000 0000000 00000000721 14622226652 0025355 0 ustar 00root root 0000000 0000000 // Test charconv integration, see https://bugzilla.redhat.com/show_bug.cgi?id=1657544
//
// REQUIRES: clang
// RUN: %clangxx %s -o %t
// RUN: %t 100 | grep 100
#include
#include
#include
using namespace std;
int main(int argc, char **argv)
{
size_t r=0;
const char *begin = argv[1];
const char *end = begin + strlen(begin);
from_chars(begin, end, r);
cout << r << '\n';
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/from_chars_libc++.cpp 0000664 0000000 0000000 00000000770 14622226652 0026500 0 ustar 00root root 0000000 0000000 // Test charconv integration, see https://bugzilla.redhat.com/show_bug.cgi?id=1657544
// But uses libc++
// REQUIRES: clang, libc++
// RUN: %clangxx -stdlib=libc++ %s -o %t
// RUN: %t 100 | grep 100
#include
#include
#include
using namespace std;
int main(int argc, char **argv)
{
size_t r=0;
const char *begin = argv[1];
const char *end = begin + strlen(begin);
from_chars(begin, end, r);
cout << r << '\n';
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/gold.c 0000664 0000000 0000000 00000000257 14622226652 0023623 0 ustar 00root root 0000000 0000000 // Test gold support
// REQUIRES: clang
// RUN: %clang -fuse-ld=gold %s -o %t
// RUN: %t
#include
int main() {
puts("I like to std::move(it)");
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/hello.mlir 0000664 0000000 0000000 00000000573 14622226652 0024523 0 ustar 00root root 0000000 0000000 // REQUIRES: clang, mlir-translate, llvm-config
// RUN: if `%llvm-config --version | grep -q 14`; then sed 's/func.func/func/' %s; else cat %s; fi | %mlir-translate --mlir-to-cpp > %t.c
// RUN: %clang %t.c -o %t
// RUN: %t
module {
emitc.include <"stdint.h">
func.func @main() -> i32 {
%ret = "emitc.constant"(){value = 0 : i32} : () -> i32
return %ret : i32
}
}
llvm-toolchain-integration-test-suite-main/tests/include_limits.c 0000664 0000000 0000000 00000000223 14622226652 0025673 0 ustar 00root root 0000000 0000000 // Test includes limits.h https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=913213
//
// REQUIRES: clang
// RUN: %clang -E %s
#include
llvm-toolchain-integration-test-suite-main/tests/libc++_link_static.cpp 0000664 0000000 0000000 00000000714 14622226652 0026657 0 ustar 00root root 0000000 0000000 // Test lib(std)c++ static
// https://bugs.llvm.org/show_bug.cgi?id=43604
//
// Check static linking with libstdc++
// RUN: %clangxx -o %t %s -fPIC -pie -static-libstdc++
// RUN: %t
// RUN: ldd %t 2>&1|grep -v libstdc++
//
// Check static linking with libc++
// RUN: %clangxx -o %t -fPIC %s -pie -stdlib=libc++ -static-libstdc++ -pthread
//
// REQUIRES: clangxx, static-libc++
#include
int main () {
std::cout << "Hello World!" << std::endl;
}
llvm-toolchain-integration-test-suite-main/tests/libc++_static_shared.cpp 0000664 0000000 0000000 00000000606 14622226652 0027170 0 ustar 00root root 0000000 0000000 // Test libc++ static library linking into a shared library.
// See https://bugzilla.redhat.com/show_bug.cgi?id=2186531
//
// RUN: %clangxx -c -o %t.o -fPIC %s
// RUN: %clangxx -fuse-ld=lld -nostdlib++ -Wl,-Bstatic -lc++ -Wl,-Bdynamic -stdlib=libc++ -shared -o %t %t.o
//
// REQUIRES: clangxx, lld, static-libc++
#include
extern void test_shared() {
std::get_terminate();
}
llvm-toolchain-integration-test-suite-main/tests/libclang_cpp.cpp 0000664 0000000 0000000 00000002621 14622226652 0025650 0 ustar 00root root 0000000 0000000 // Test the link against libclang-cppXX
//
// REQUIRES: llvm-config
// RUN: %cxx -DCLANG_MAJOR=`%llvm-config --version | cut -d . -f 1` -v %s -o %t `%llvm-config --cxxflags --ldflags --libs` -lclang-cpp
// RUN: ldd %t 2>&1 > %t.lddoutput
// RUN: grep -q libclang-cpp %t.lddoutput
#include "clang/Tooling/CommonOptionsParser.h"
#include "llvm/Support/CommandLine.h"
using namespace clang::tooling;
using clang::tooling::CommonOptionsParser;
// Apply a custom category to all command-line options so that they are the
// only ones displayed.
static llvm::cl::OptionCategory MyToolCategory("my-tool options");
int main(int argc, const char **argv) {
// CommonOptionsParser constructor will parse arguments and create a
// CompilationDatabase. In case of error it will terminate the program.
#if CLANG_MAJOR < 13
clang::tooling::CommonOptionsParser OptionsParser(argc, argv,
MyToolCategory);
#else
auto ExpectedParser = CommonOptionsParser::create(argc, argv, MyToolCategory);
if (!ExpectedParser) {
// Fail gracefully for unsupported options.
llvm::errs() << ExpectedParser.takeError();
return 1;
}
CommonOptionsParser& OptionsParser = ExpectedParser.get();
#endif
// Use OptionsParser.getCompilations() and OptionsParser.getSourcePathList()
// to retrieve CompilationDatabase and the list of input file paths.
}
llvm-toolchain-integration-test-suite-main/tests/lit.site.cfg.in 0000664 0000000 0000000 00000004276 14622226652 0025360 0 ustar 00root root 0000000 0000000 import os
import lit
config.name = 'LLVM regression suite'
config.test_format = lit.formats.ShTest(True)
config.suffixes = ['.ll', '.c', '.cpp', '.test', '.txt', '.s', '.mir', '.mlir']
config.test_source_root = os.path.join("@CMAKE_CURRENT_SOURCE_DIR@", "tests")
config.excludes = ['Inputs']
config.available_features.add("@CMAKE_HOST_SYSTEM_PROCESSOR@")
def enable_feature(name, option):
if option.lower() in ('on', 1):
config.available_features.add(name)
def enable_program(name, binary):
if os.path.exists(binary):
config.available_features.add(name)
config.substitutions.append(('%'+name, binary))
def enable_library(name, library):
if os.path.exists(library):
config.available_features.add(name)
# The order matters, e.g. substitution for clang-format-diff
# must appear before clang-format, because the latter is a prefix of the former.
enable_program('cc', "@CMAKE_C_COMPILER@")
enable_program('cxx', "@CMAKE_CXX_COMPILER@")
enable_program('clang-tidy', "@CLANG_TIDY_BINARY@")
enable_program('clang-format-diff', "@CLANG_FORMAT_DIFF_BINARY@")
enable_program('clang-format', "@CLANG_FORMAT_BINARY@")
enable_program('clangd', "@CLANGD_BINARY@")
enable_program('clangxx', "@CLANGXX_BINARY@")
enable_program('clang', "@CLANG_BINARY@")
enable_program('llvm-nm', "@LLVMNM@")
enable_program('llc', "@LLC@")
enable_program('lli', "@LLI@")
enable_program('opt', "@OPT@")
enable_program('llvm-profdata', "@LLVMPROFDATA@")
enable_program('llvm-config', "@LLVMCONFIG_BINARY@")
enable_program('llvm-objdump', "@LLVMOBJDUMP_BINARY@")
enable_program('lldb', "@LLDB_BINARY@")
enable_program('lld', "@LLD_BINARY@")
enable_program('scan-build-py', "@SCANBUILDPY@")
enable_program('scan-build', "@SCANBUILD@")
enable_program('scan-view', "@SCANVIEW@")
enable_program('opt', "@OPT_BINARY@")
enable_program('mlir-translate', "@MLIRTRANSLATE@")
enable_library('libomp', "@LIBOMP@")
config.substitutions.append(('%cmake', '@CMAKE_COMMAND@'))
enable_feature("compiler-rt", "@ENABLE_COMPILER_RT@")
enable_feature("libc++", "@ENABLE_LIBCXX@")
enable_feature("static-libc++", "@ENABLE_STATIC_LIBCXX@")
enable_feature("libunwind", "@ENABLE_LIBUNWIND@")
enable_feature("support_hwasan", "@ENABLE_HWASAN@")
llvm-toolchain-integration-test-suite-main/tests/llvm-ir.c 0000664 0000000 0000000 00000000477 14622226652 0024264 0 ustar 00root root 0000000 0000000 // Test LLVM IR
// RUN: %clang -S -emit-llvm %s -o %t.ll
// RUN: %llc %t.ll && touch %t.s
// RUN: %lli %t.ll | grep -q "lli foo"
// RUN: %opt -S -O3 %t.ll -o %t.opt.ll
// RUN: %lli %t.opt.ll | grep -q "lli foo"
// REQUIRES: clang, llc, lli, opt
#include
int main() {
printf("lli foo\n");
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/llvm_config_libs.cpp 0000664 0000000 0000000 00000000676 14622226652 0026553 0 ustar 00root root 0000000 0000000 // Test if llvm-config correctly finds headers and libs
// RUN: %clangxx `%llvm-config --cxxflags --ldflags --libs` %s -o %t
// RUN: %clangxx `%llvm-config --link-shared --cxxflags --ldflags --libs` %s -o %t
//
// Check that warnings are not exported
// RUN: %llvm-config --cxxflags | grep -v " \-W"
//
// REQUIRES: clangxx, llvm-config
#include
int main(int argc, char** argv) {
llvm::LLVMContext ctxt;
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/lto_and_cfi.c 0000664 0000000 0000000 00000000401 14622226652 0025126 0 ustar 00root root 0000000 0000000 // Test compatibility between lto and CFI, see https://bugzilla.redhat.com/show_bug.cgi?id=1794936
// RUN: %clang -flto -fsanitize=cfi -fvisibility=hidden %s -o %t
// REQUIRES: clang, compiler-rt
// XFAIL: s390x, ppc64le, ppc64
int main() {
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/lto_and_cross_dso_cfi.c 0000664 0000000 0000000 00000001365 14622226652 0027216 0 ustar 00root root 0000000 0000000 // Test compatibility between lto and CFI with cross -dso enabled
// RUN: rm -rf %t.dir
// RUN: mkdir %t.dir
// RUN: %clang -UMAIN -flto -fsanitize=cfi -fsanitize-cfi-cross-dso -fvisibility=default -fuse-ld=lld %s -shared -o %t.dir/liblocalcrossdso.so
// RUN: %clang -DMAIN -flto -fsanitize=cfi -fsanitize-cfi-cross-dso -fvisibility=default -fuse-ld=lld %s -o %t -L%t.dir -llocalcrossdso
// RUN: LD_LIBRARY_PATH=%t.dir %t
// RUN: rm -f liblocalcrossdso.so
// REQUIRES: clang, compiler-rt, lld
// XFAIL: s390x, ppc64le, ppc64
#ifdef MAIN
#include
extern int greet(void(*greeter)(void));
void greeter(void) {
puts("hello");
}
int main() {
return greet(greeter);
}
#else
int greet(void(*greeter)(void)) {
greeter();
return 0;
}
#endif
llvm-toolchain-integration-test-suite-main/tests/lto_and_gold.c 0000664 0000000 0000000 00000000573 14622226652 0025324 0 ustar 00root root 0000000 0000000 // Test LTO support within ld.gold
// REQUIRES: clang
// RUN: %clang -c -flto %s -DLIB -o %t-obj.o
// RUN: %clang -c -flto %s -ULIB -o %t-main.o
// RUN: %clang -fuse-ld=gold -flto %t-obj.o %t-main.o -o %t
// RUN: %t | grep "hello lita"
#ifdef LIB
#include
void greet() {
puts("hello lita");
}
#else
extern void greet();
int main() {
greet();
return 0;
}
#endif
llvm-toolchain-integration-test-suite-main/tests/lto_and_lld.c 0000664 0000000 0000000 00000000573 14622226652 0025152 0 ustar 00root root 0000000 0000000 // Test LTO support within lld
// REQUIRES: clang, lld
// RUN: %clang -c -flto %s -DLIB -o %t-obj.o
// RUN: %clang -c -flto %s -ULIB -o %t-main.o
// RUN: %clang -fuse-ld=lld -flto %t-obj.o %t-main.o -o %t
// RUN: %t | grep "hello lita"
#ifdef LIB
#include
void greet() {
puts("hello lita");
}
#else
extern void greet();
int main() {
greet();
return 0;
}
#endif
llvm-toolchain-integration-test-suite-main/tests/minimal_llvm_cmake.txt 0000664 0000000 0000000 00000000314 14622226652 0027105 0 ustar 00root root 0000000 0000000 # Test minimal cmake LLVM project
# RUN: rm -rf %t
# RUN: mkdir -p %t/_build
# RUN: cat %s > %t/CMakeLists.txt
# RUN: cd %t/_build && %cmake ..
cmake_minimum_required(VERSION 3.4.3)
find_package(LLVM)
llvm-toolchain-integration-test-suite-main/tests/minimal_mlir_cmake.txt 0000664 0000000 0000000 00000000703 14622226652 0027100 0 ustar 00root root 0000000 0000000 # Test minimal cmake MLIR project
# REQUIRES: mlir-translate
# RUN: rm -rf %t
# RUN: mkdir -p %t/_build
# RUN: cat %s > %t/CMakeLists.txt
# RUN: cd %t/_build && %cmake .. -DMLIR_DIR=`%llvm-config --libdir`/cmake/mlir
cmake_minimum_required(VERSION 3.13.4)
project(standalone-dialect LANGUAGES CXX C)
set(CMAKE_BUILD_WITH_INSTALL_NAME_DIR ON)
set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
find_package(MLIR REQUIRED CONFIG)
llvm-toolchain-integration-test-suite-main/tests/openmp_headers.c 0000664 0000000 0000000 00000000424 14622226652 0025663 0 ustar 00root root 0000000 0000000 // Test OpenMP headers install
//
// RUN: %clang -fopenmp -E %s -o %t
// REQUIRES: clang, libomp
#include
#if _OPENMP >= 201811
#include
// Still not fixed upstream
#if 0
#define CLIENT_TOOL_LIBRARIES_VAR "SAMPLE"
#include
#endif
#endif
llvm-toolchain-integration-test-suite-main/tests/openmp_tools.c 0000664 0000000 0000000 00000002177 14622226652 0025417 0 ustar 00root root 0000000 0000000 // Test OpenMP Tools support
// RUN: %clang -fopenmp -DTOOLS %s -shared -o %t_Tools.so
// RUN: %clang -fopenmp -UTOOLS %s -o %t
// RUN: OMP_TOOL_LIBRARIES=%t_Tools.so %t | grep "INIT"
// REQUIRES: clang, libomp
#ifdef TOOLS
// OpenMP Tools are only supported starting OpenMP 5
#if _OPENMP >= 201811
#include
#include
int ompt_initialize(
ompt_function_lookup_t lookup,
int initial_device_num,
ompt_data_t *data)
{
puts("[INIT]");
return 1;
}
void ompt_finalize(ompt_data_t* data)
{
puts("[FINAL]");
}
ompt_start_tool_result_t* ompt_start_tool(
unsigned int omp_version,
const char *runtime_version)
{
printf("[START] %s, OMP%u\n", runtime_version, omp_version);
static ompt_start_tool_result_t ompt_start_tool_result = {&ompt_initialize, &ompt_finalize, {.ptr=NULL}};
return &ompt_start_tool_result;
}
#endif
#else
#include
int main() {
#pragma omp parallel
#pragma omp single
{
// if we don't have support for ompt, default to an output that satisfies
// the test check
#if _OPENMP < 201811
puts("INIT");
#else
puts("hello");
#endif
}
return 0;
}
#endif
llvm-toolchain-integration-test-suite-main/tests/partial-toolchain.cpp 0000664 0000000 0000000 00000000420 14622226652 0026640 0 ustar 00root root 0000000 0000000 // Tests all components of the toolchain
// REQUIRES: clang, lld, libc++
// RUN: %clangxx -fuse-ld=lld -stdlib=libc++ %s -o %t
// RUN: %t | grep "Hello World"
#include
int main(int argc, char **argv) {
std::cout << "Hello World" << std::endl;
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/plugins.cpp 0000664 0000000 0000000 00000004127 14622226652 0024717 0 ustar 00root root 0000000 0000000 // RUN: %cxx `%llvm-config --cxxflags` -fPIC -shared %s -o Hello.so
// RUN: %opt -load ./Hello.so -help | grep "Hello World Pass"
// REQUIRES: opt, llvm-config
//===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements two versions of the LLVM "Hello World" pass described
// in docs/WritingAnLLVMPass.html
//
//===----------------------------------------------------------------------===//
#include "llvm/ADT/Statistic.h"
#include "llvm/IR/Function.h"
#include "llvm/Pass.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
#define DEBUG_TYPE "hello"
STATISTIC(HelloCounter, "Counts number of functions greeted");
namespace {
// Hello - The first implementation, without getAnalysisUsage.
struct Hello : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
Hello() : FunctionPass(ID) {}
bool runOnFunction(Function &F) override {
++HelloCounter;
errs() << "Hello: ";
errs().write_escaped(F.getName()) << '\n';
return false;
}
};
}
char Hello::ID = 0;
static RegisterPass X("hello", "Hello World Pass");
namespace {
// Hello2 - The second implementation with getAnalysisUsage implemented.
struct Hello2 : public FunctionPass {
static char ID; // Pass identification, replacement for typeid
Hello2() : FunctionPass(ID) {}
bool runOnFunction(Function &F) override {
++HelloCounter;
errs() << "Hello: ";
errs().write_escaped(F.getName()) << '\n';
return false;
}
// We don't modify the program, so we preserve all analyses.
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.setPreservesAll();
}
};
}
char Hello2::ID = 0;
static RegisterPass
Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)");
llvm-toolchain-integration-test-suite-main/tests/plugins_newpm.txt 0000664 0000000 0000000 00000002342 14622226652 0026157 0 ustar 00root root 0000000 0000000 # Tests LLVM pass using new pass manager. Based on https://llvm.org/docs/WritingAnLLVMNewPMPass.html
# RUN: rm -rf %t
# RUN: mkdir -p %t/_build
# RUN: cat %s > %t/CMakeLists.txt
# RUN: cp %S/Inputs/llvm_newpm_pass.cpp %t
# RUN: cd %t/_build
# RUN: %cmake .. -DCMAKE_C_COMPILER=%cc -DCMAKE_CXX_COMPILER=%cxx -DLLVM_DIR=`%llvm-config --cmakedir`
# RUN: %cmake --build .
# RUN: %clang -emit-llvm -O3 -c %S/Inputs/foo.c -o llvm-ir.bc
# RUN: %opt -load-pass-plugin=./HelloPass.so -disable-output ./llvm-ir.bc -passes=hellonewpm 2> %t.output
# RUN: grep "Function name: foo" %t.output
# REQUIRES: opt, clang
cmake_minimum_required(VERSION 3.4.3)
project(TestLLVMPass)
find_package(LLVM REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)
# Starting LLVM 16, std=c++17 is required
if(LLVM_PACKAGE_VERSION VERSION_GREATER_EQUAL "16.0.0")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "")
else()
set(CMAKE_CXX_STANDARD 14 CACHE STRING "")
endif()
add_llvm_library(HelloPass MODULE llvm_newpm_pass.cpp)
# Add LLVM headers filled from find_package
target_include_directories(HelloPass
PRIVATE ${LLVM_INCLUDE_DIRS}
)
# LLVM's compile definitions
target_compile_definitions(HelloPass
PRIVATE ${LLVM_DEFINITIONS}
)
llvm-toolchain-integration-test-suite-main/tests/rpass_inline.cpp 0000664 0000000 0000000 00000000715 14622226652 0025723 0 ustar 00root root 0000000 0000000 // Test a Rpass=inline (parse the output)
//
// RUN: %clangxx -O2 -Rpass=inline %s -c &> %t.log
// RUN: grep -q -E "(inlined into main with|inlined into 'main' with|cost=always)" %t.log
// REQUIRES: clangxx
int foo(int x, int y) __attribute__((always_inline));
int foo(int x, int y) { return x + y; }
int bar(int j) { return foo(j, j - 2); }
int sum = 0;
int main(int argc, const char *argv[]) {
for (int i = 0; i < 30; i++)
bar(argc);
return sum;
}
llvm-toolchain-integration-test-suite-main/tests/save-optimization-record.c 0000664 0000000 0000000 00000001715 14622226652 0027634 0 ustar 00root root 0000000 0000000 // Test the fsave-optimization-record option and tha tthe file isn't empty
// Make sure that https://bugs.llvm.org/show_bug.cgi?id=51642
// doesn't happen again
//
// RUN: mkdir -p %t/test && cd %t/test
// RUN: %clang -S -O2 -fsave-optimization-record -emit-llvm %s -o save-optimization-record.c.opt
// RUN: test -s save-optimization-record.c.opt.yaml
// REQUIRES: clang
// marking it as failing util the bug is addressed
#define N 1536
float A[N][N];
float B[N][N];
float C[N][N];
void init_array()
{
int i, j;
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
A[i][j] = (1+(i*j)%1024)/2.0;
B[i][j] = (1+(i*j)%1024)/2.0;
}
}
}
int main()
{
int i, j, k;
double t_start, t_end;
init_array();
for (i = 0; i < N; i++) {
for (j = 0; j < N; j++) {
C[i][j] = 0;
for (k = 0; k < N; k++)
C[i][j] = C[i][j] + A[i][k] * B[k][j];
}
}
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/scanbuild_missing_delete.cpp 0000664 0000000 0000000 00000000601 14622226652 0030246 0 ustar 00root root 0000000 0000000 // Tests scan-view runs correctly, see https://bugzilla.redhat.com/show_bug.cgi?id=1647130
// REQUIRES: scan-build, scan-view
// RUN: rm -rf %t.out && mkdir %t.out && cd %t.out && rm -rf *
// RUN: %scan-build -o . %clangxx -c %s -o %t
// RUN: %scan-view --no-browser * & WPID=$! && sleep 5 && kill $WPID
int main(int argc, char *argv[]) {
while (argc--)
new int();
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/scanbuild_py.cpp 0000664 0000000 0000000 00000000224 14622226652 0025704 0 ustar 00root root 0000000 0000000 // RUN: %clang -fsyntax-only %s
int bad_guy(int * i)
{
*i = 9;
return *i;
}
void bad_guy_test()
{
int * ptr = 0;
bad_guy(ptr);
}
llvm-toolchain-integration-test-suite-main/tests/scanbuild_py_makefile.txt 0000664 0000000 0000000 00000000656 14622226652 0027607 0 ustar 00root root 0000000 0000000 # Test scan-build-py
# It seems that scan-build python isn't able to analyze clang raw call
# So, creating a Makefile to allow the test
# REQUIRES: scan-build-py
# RUN: rm -rf %t
# RUN: mkdir -p %t
# RUN: cp %S/scanbuild_py.cpp %t
# RUN: cd %t && %scan-build-py make -f %s|grep "to examine bug reports"
# RUN: cd %t && %scan-build-py --intercept-first make -f %s && test -f compile_commands.json
all:
$(CC) -c scanbuild_py.cpp
llvm-toolchain-integration-test-suite-main/tests/test_asan_heap.c 0000664 0000000 0000000 00000000571 14622226652 0025653 0 ustar 00root root 0000000 0000000 // Test asan use after free
//
// REQUIRES: clang, compiler-rt
// RUN: %clang -o %t -fsanitize=address -O1 -fno-omit-frame-pointer -g %s
// RUN: env ASAN_OPTIONS="log_path=stdout:exitcode=0" %t 2>&1 > %t.out
// RUN: grep -q "heap-use-after-free" %t.out
// XFAIL: arm
#include
int main() {
char *x = (char*)malloc(10 * sizeof(char*));
free(x);
return x[5];
}
llvm-toolchain-integration-test-suite-main/tests/test_asan_lc.c 0000664 0000000 0000000 00000000400 14622226652 0025323 0 ustar 00root root 0000000 0000000 // Test asan with lc https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=876973
//
// REQUIRES: clang
// RUN: %clang -fsanitize=address %s -o %t -lc
// RUN: %t
#include
int main(int argc, char **argv)
{
printf("Hello world!\n");
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/test_clangd.txt 0000664 0000000 0000000 00000000301 14622226652 0025550 0 ustar 00root root 0000000 0000000 # Test clangd
# REQUIRES: clangd
# RUN: %clangd -lit-test -pch-storage=memory < %S/Inputs/clangd.json &> %s.log
# RUN: grep -q '"insertText": "func_with_args(${1:int a}, ${2:int b})",' %s.log
llvm-toolchain-integration-test-suite-main/tests/test_hwasan.c 0000664 0000000 0000000 00000000700 14622226652 0025207 0 ustar 00root root 0000000 0000000 // Test hwasan use after free -- aarch64 only.
//
// REQUIRES: clang, compiler-rt, support_hwasan
// RUN: %clang -o %t -fsanitize=hwaddress -g %s
// RUN: env HWASAN_OPTIONS="log_path=stdout:exitcode=0" %t 2>&1 > %t.out
// RUN: grep -q "HWAddressSanitizer: tag-mismatch" %t.out
// RUN: grep -q "Cause: use-after-free" %t.out
#include
int main() {
int *p = malloc(sizeof(int));
free(p); // The memory is leaked here.
return *p;
}
llvm-toolchain-integration-test-suite-main/tests/test_leaksan.c 0000664 0000000 0000000 00000000512 14622226652 0025345 0 ustar 00root root 0000000 0000000 // Test asan use after free
//
// REQUIRES: clang
// RUN: %clang -o %t -fsanitize=address -g %s
// RUN: env ASAN_OPTIONS="log_path=stdout:exitcode=0" %t 2>&1 > %t.out
// RUN: grep -q "detected memory leaks" %t.out
#include
void *p;
int main() {
p = malloc(7);
p = 0; // The memory is leaked here.
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/test_tsan.c 0000664 0000000 0000000 00000001202 14622226652 0024671 0 ustar 00root root 0000000 0000000 // Test tsan with config variables
//
// REQUIRES: clang, llvm-nm, compiler-rt
// RUN: %clang -o %t -fsanitize=thread -g -O1 %s
// RUN: %llvm-nm %t | grep __tsan
// RUN: env TSAN_OPTIONS="log_path=stdout:exitcode=0" %t 2>&1 > %t.out
// RUN: grep -q "data race" %t.out
// XFAIL: arm, i686, i386
#include
#include
int Global;
void *Thread1(void *x) {
Global++;
return NULL;
}
void *Thread2(void *x) {
Global--;
return NULL;
}
int main() {
pthread_t t[2];
pthread_create(&t[0], NULL, Thread1, NULL);
pthread_create(&t[1], NULL, Thread2, NULL);
pthread_join(t[0], NULL);
pthread_join(t[1], NULL);
}
llvm-toolchain-integration-test-suite-main/tests/test_ubsan.c 0000664 0000000 0000000 00000000543 14622226652 0025043 0 ustar 00root root 0000000 0000000 // Test ubsan with config variables
//
// REQUIRES: clang, llvm-nm, compiler-rt
// RUN: %clang -o %t -fsanitize=undefined -g -O1 %s
// RUN: env UBSAN_OPTIONS="log_path=stdout:exitcode=0" %t 2>&1 > %t.out
// RUN: grep "cannot be represented in type" %t.out
// XFAIL: arm
int main(int argc, char **argv) {
int k = 0x7fffffff;
k += argc;
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/thinlto.c 0000664 0000000 0000000 00000000261 14622226652 0024352 0 ustar 00root root 0000000 0000000 // verify that thinlto is available
// REQUIRES: clang
// RUN: %clang -flto=thin -O2 %S/Inputs/foo.c %s -o %t
// RUN: %t
int foo(void);
int main() {
foo();
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/unwind.cpp 0000664 0000000 0000000 00000001020 14622226652 0024527 0 ustar 00root root 0000000 0000000 // Test libunwind - only packaged from -12
//
// REQUIRES: clang, libunwind, llvm-nm
// NOTE: the extra -L flag is only required by Fedora
// RUN: %clangxx %s -o %t.llvm -unwindlib=libunwind -rtlib=compiler-rt -L/usr/lib64/llvm-unwind
// RUN: %llvm-nm %t.llvm | grep _Unwind_Resume
// RUN: %t.llvm
// XFAIL: s390x
struct f { ~f() { }};
int foo(int n) {
f _;
if(n > 2)
throw int();
return 0;
}
int main(int argc, char** argv) {
try {
return foo(argc);
}
catch(...) {
return 0;
}
}
llvm-toolchain-integration-test-suite-main/tests/warning_conversion.c 0000664 0000000 0000000 00000000373 14622226652 0026607 0 ustar 00root root 0000000 0000000 // Test warning conversion https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=914201
//
// REQUIRES: clang
// RUN: %clang -Wconversion -Werror %s
#include
int main(void)
{
double f = 2.0;
if (isnan(f))
return 1;
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/whole-toolchain.c 0000664 0000000 0000000 00000000543 14622226652 0025770 0 ustar 00root root 0000000 0000000 // Tests all components of the toolchain
// REQUIRES: clang, lld, compiler-rt
// RUN: %clang -fuse-ld=lld -rtlib=compiler-rt %s -o %t
// RUN: %t | grep "Hello World"
// s390x now runs but fails because it does not support compiler-rt builtins.
// XFAIL: s390x
#include
int main(int argc, char **argv) {
printf("Hello World\n");
return 0;
}
llvm-toolchain-integration-test-suite-main/tests/whole-toolchain.cpp 0000664 0000000 0000000 00000001073 14622226652 0026327 0 ustar 00root root 0000000 0000000 // Tests all components of the toolchain
// REQUIRES: clang, lld, compiler-rt, libc++
//
// NOTE: Adding -lgcc_eh here is required to provide unwinding information. An
// alternative would be to force usage of LLVM unwinder when building compiler-rt.
// RUN: %clangxx -fuse-ld=lld -rtlib=compiler-rt -stdlib=libc++ -lgcc_eh %s -o %t
// RUN: %t | grep "Hello World"
// s390x now runs but fails because it does not support compiler-rt builtins.
// XFAIL: s390x
#include
int main(int argc, char **argv) {
std::cout << "Hello World" << std::endl;
return 0;
}