Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang 18 #622

Merged
merged 1 commit into from
Apr 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 42 additions & 40 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ on:
types: [rebuild_trigger]

env:
CMAKE_VERSION: 3.16.2
NINJA_VERSION: 1.10.0
LLVM_VERSION: 17.0.0
CMAKE_VERSION: 3.29.0
NINJA_VERSION: 1.11.1
LLVM_VERSION: 18.1.0

jobs:
checks:
Expand All @@ -29,7 +29,7 @@ jobs:
name: "Linux Clang - Format check",
os: ubuntu-20.04,
build_type: Release,
cformat_name: 'clang-format-17'
cformat_name: 'clang-format-18'
}

steps:
Expand All @@ -42,7 +42,7 @@ jobs:
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 17
sudo ./llvm.sh 18
sudo apt-get install ${{ matrix.config.cformat_name }}

- name: clang-format check
Expand All @@ -64,11 +64,11 @@ jobs:
config:
# AppleClang
- {
name: "Clang 17 / LLVM 17 @ macOS Release",
os: macos-11,
name: "Clang 18 / LLVM 18 @ macOS Release",
os: macos-14,
build_type: Release,
cxx: "clang++",
llvm_version: "17.0.0",
llvm_version: "18.1.0",
llvm_config: "llvm-config",
coverage: "No",
static: "No",
Expand All @@ -78,15 +78,16 @@ jobs:
bin_name: "insights",
archive_name: "insights-macos",
upload: "Yes",
cmake_args: "-DCMAKE_OSX_ARCHITECTURES=arm64",
}

# AppleClang
- {
name: "Clang 17 / LLVM 17 @ macOS Debug",
os: macos-11,
name: "Clang 18 / LLVM 18 @ macOS Debug",
os: macos-14,
build_type: Release,
cxx: "clang++",
llvm_version: "17.0.0",
llvm_version: "18.1.0",
llvm_config: "llvm-config",
coverage: "No",
static: "No",
Expand All @@ -96,15 +97,16 @@ jobs:
bin_name: "insights",
archive_name: "insights-macos",
upload: "No",
cmake_args: "-DCMAKE_OSX_ARCHITECTURES=arm64",
}

# # AppleClang
# - {
# name: "Clang 17 / LLVM 17 @ macOS Coverage & Debug",
# os: macos-11,
# name: "Clang 18 / LLVM 18 @ macOS Coverage & Debug",
# os: macos-14,
# build_type: Release,
# cxx: "clang++",
# llvm_version: "17.0.0",
# llvm_version: "18.1.0",
# llvm_config: "llvm-config",
# coverage: "Yes",
# static: "No",
Expand All @@ -118,11 +120,11 @@ jobs:

# # MSVC 2019
# - {
# name: "MSVC 2022 / LLVM 17 @ Windows Release",
# name: "MSVC 2022 / LLVM 18 @ Windows Release",
# os: windows-2022,
# build_type: Release,
# cxx: "cl",
# llvm_version: "17.0.0",
# llvm_version: "18.1.0",
# llvm_config: "current/bin/llvm-config.exe",
# static: "Yes",
# debug: "No",
Expand All @@ -137,11 +139,11 @@ jobs:

# # MSVC 2019
# - {
# name: "MSVC 2022 / LLVM 17 @ Windows Debug",
# name: "MSVC 2022 / LLVM 18 @ Windows Debug",
# os: windows-2022,
# build_type: Release,
# cxx: "cl",
# llvm_version: "17.0.0",
# llvm_version: "18.1.0",
# llvm_config: "current/bin/llvm-config.exe",
# static: "Yes",
# debug: "Yes",
Expand All @@ -155,11 +157,11 @@ jobs:

# # MSVC 2019
# - {
# name: "MSVC 2022 / LLVM 17 @ Windows Code Coverage & Debug",
# name: "MSVC 2022 / LLVM 18 @ Windows Code Coverage & Debug",
# os: windows-2022,
# build_type: Release,
# cxx: "clang-cl.exe",
# llvm_version: "17.0.0",
# llvm_version: "18.1.0",
# llvm_config: "current/bin/llvm-config.exe",
# coverage: "Yes",
# static: "Yes",
Expand Down Expand Up @@ -199,8 +201,8 @@ jobs:
cmake_dir="${cmake_base_dir}/bin"
elif [ "$RUNNER_OS" == "macOS" ]; then
ninja_suffix="mac.zip"
cmake_suffix="Darwin-x86_64.tar.gz"
cmake_base_dir="cmake-${cmake_version}-Darwin-x86_64"
cmake_suffix="macos-universal.tar.gz"
cmake_base_dir="cmake-${cmake_version}-macos-universal"
cmake_dir="${cmake_base_dir}/CMake.app/Contents/bin"
fi

Expand Down Expand Up @@ -261,12 +263,12 @@ jobs:
key: ${{ runner.os }}-clang-${{ matrix.config.llvm_version }}-${{ hashFiles('${{ github.workspace }}/current') }}

- name: Install Clang
if: "(startsWith(matrix.config.os, 'macos') || startsWith(matrix.config.os, 'Window')) && steps.cache-clang-binary.outputs.cache-hit != 'true'"
if: "(startsWith(matrix.config.os, 'macos') || startsWith(matrix.config.os, 'Window'))"
shell: cmake -P {0}
run: |
set(llvm_version ${{ matrix.config.llvm_version }})
set(path_separator ":")
set(archive_name "clang+llvm-${llvm_version}-x86_64-apple-darwin")
set(archive_name "clang+llvm-${llvm_version}-arm64-apple-darwin")
if ("${{ runner.os }}" STREQUAL "Windows")
set(archive_name "clang+llvm-${llvm_version}-win64-msvc")
set(path_separator ";")
Expand Down Expand Up @@ -322,7 +324,7 @@ jobs:
export HOMEBREW_NO_AUTO_UPDATE=1
brew update > /dev/null
brew install lcov || brew upgrade lcov
brew install gcc@10 || brew upgrade gcc@10 # for Clang 17 and newer gcov
brew install gcc@10 || brew upgrade gcc@10 # for Clang 18 and newer gcov

- name: Setup MSVC Dev
if: "startsWith(matrix.config.os, 'Windows')"
Expand Down Expand Up @@ -465,13 +467,13 @@ jobs:
fail-fast: false
matrix:
config:
# GCC 12 / LLVM 17
# GCC 13 / LLVM 18
- {
name: "GCC 12 / LLVM 17 @ Ubuntu Release @docker",
name: "GCC 13 / LLVM 18 @ Ubuntu Release @docker",
build_type: Release,
cxx: "g++-12",
llvm_version: "17.0.0",
llvm_config: "/usr/bin/llvm-config-17",
cxx: "g++-13",
llvm_version: "18.1.0",
llvm_config: "/usr/bin/llvm-config-18",
coverage: "No",
static: "Yes",
debug: "No",
Expand All @@ -484,13 +486,13 @@ jobs:
docs: "Yes",
}

# GCC 12 / LLVM 17
# GCC 13 / LLVM 18
- {
name: "GCC 12 / LLVM 17 @ Ubuntu Code Coverage & Debug @docker",
name: "GCC 13 / LLVM 18 @ Ubuntu Code Coverage & Debug @docker",
build_type: Release,
cxx: "g++-12",
llvm_version: "17.0.0",
llvm_config: "/usr/bin/llvm-config-17",
cxx: "g++-13",
llvm_version: "18.1.0",
llvm_config: "/usr/bin/llvm-config-18",
coverage: "Yes",
static: "No",
debug: "Yes",
Expand All @@ -501,13 +503,13 @@ jobs:
archive_name: "insights-ubuntu-14.04",
}

# GCC 12 / LLVM 17
# GCC 13 / LLVM 18
- {
name: "GCC 12 / LLVM 17 @ Ubuntu Code Coverage (libc++) @docker",
name: "GCC 13 / LLVM 18 @ Ubuntu Code Coverage (libc++) @docker",
build_type: Release,
cxx: "g++-12",
llvm_version: "17.0.0",
llvm_config: "/usr/bin/llvm-config-17",
cxx: "g++-13",
llvm_version: "18.1.0",
llvm_config: "/usr/bin/llvm-config-18",
coverage: "Yes",
static: "No",
debug: "Yes",
Expand Down
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cmake_minimum_required(VERSION 3.10 FATAL_ERROR)
# 3.8* is required because of C++17 support
cmake_minimum_required(VERSION 3.20 FATAL_ERROR)

# For better control enable MSVC_RUNTIME_LIBRARY target property
# see https://cmake.org/cmake/help/latest/policy/CMP0091.html
Expand Down Expand Up @@ -33,7 +32,7 @@ option(INSIGHTS_STATIC "Use static linking" Off)

set(INSIGHTS_LLVM_CONFIG "llvm-config" CACHE STRING "LLVM config executable to use")

set(INSIGHTS_MIN_LLVM_MAJOR_VERSION 17)
set(INSIGHTS_MIN_LLVM_MAJOR_VERSION 18)
set(INSIGHTS_MIN_LLVM_VERSION ${INSIGHTS_MIN_LLVM_MAJOR_VERSION}.0)

if(NOT DEFINED LLVM_VERSION_MAJOR) # used when build inside the clang tool/extra folder
Expand Down Expand Up @@ -372,6 +371,17 @@ if (BUILD_INSIGHTS_OUTSIDE_LLVM)
# additional libs required when building insights outside llvm
set(ADDITIONAL_LIBS
${LLVM_LDFLAGS}
)

if(${LLVM_PACKAGE_VERSION_PLAIN} VERSION_GREATER_EQUAL "18.0.0")
set(ADDITIONAL_LIBS
${ADDITIONAL_LIBS}
clangAPINotes
)
endif()

set(ADDITIONAL_LIBS
${ADDITIONAL_LIBS}
clangFrontend
clangDriver
clangSerialization
Expand Down Expand Up @@ -768,6 +778,7 @@ message(STATUS "[ Build summary ]")
message(STATUS "CMAKE_GENERATOR : ${CMAKE_GENERATOR}")
message(STATUS "CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
message(STATUS "CMAKE_LINKER : ${CMAKE_LINKER}")
message(STATUS "CMAKE_OSX_ARCHITECTURES : ${CMAKE_OSX_ARCHITECTURES}")
message(STATUS "Compiler ID : ${CMAKE_CXX_COMPILER_ID}")
message(STATUS "Compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "Compiler path : ${CMAKE_CXX_COMPILER}")
Expand Down
8 changes: 8 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ There are a couple of options that can be enabled with [cmake](https://cmake.org
| INSIGHTS_USE_LIBCPP | Use libc++ for tests | OFF |
| DEBUG | Enable debug | OFF |

### Building for ARM on macOS

It seems best to supply the architecture during configuration:

```
cmake -DCMAKE_OSX_ARCHITECTURES=arm64 ../cppinsights
```


### Use it with [Cevelop](https://www.cevelop.com)

Expand Down
6 changes: 3 additions & 3 deletions scripts/prepare-release.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
def main():
versionH = open('version.h.in', 'r').read()

oldClangStable = '16'
newClangStable = '17'
newInsightsVersion = '17.0'
oldClangStable = '17'
newClangStable = '18'
newInsightsVersion = '18.0'
oldInsightsVersion = re.search(r'INSIGHTS_VERSION\s+"(.*?)"', versionH, re.DOTALL | re.MULTILINE).group(1)


Expand Down
1 change: 1 addition & 0 deletions tests/ClassOpInTemplateFunctionTest.expect
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class Foo
{
if constexpr(true) {
return this->mX;
} else /* constexpr */ {
}

}
Expand Down
2 changes: 1 addition & 1 deletion tests/EduCoroutineCoAwaitOperatorTest.expect
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ awaiter operator co_await<long long, std::ratio<1, 1000> >(std::chrono::duration

};

return awaiter{std::chrono::duration<long long, std::ratio<1, 1000000> >(d, nullptr)};
return awaiter{std::chrono::duration<long long, std::ratio<1, 1000000> >(d)};
}
#endif

Expand Down
2 changes: 1 addition & 1 deletion tests/IfSwitchInitHandler5Test.expect
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
int main()
{
std::shared_ptr<int> sharedPtr = std::make_shared<int>(2011);
std::weak_ptr<int> weakPtr = std::weak_ptr<int>(sharedPtr, 0);
std::weak_ptr<int> weakPtr = std::weak_ptr<int>(sharedPtr);
{
std::shared_ptr<int> sharedPtr1 = weakPtr.lock();
if(sharedPtr1.operator bool()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Issue15.expect
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

std::chrono::duration<long long, std::ratio<1, 1> > operator""_s(unsigned long long s)
{
return std::chrono::duration<long long, std::ratio<1, 1> >(s, nullptr);
return std::chrono::duration<long long, std::ratio<1, 1> >(s);
}

std::basic_string<char, std::char_traits<char>, std::allocator<char> > operator""_str(const char * s, std::size_t len)
Expand Down
2 changes: 1 addition & 1 deletion tests/Issue41.cerr
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
29 | template<class type_parameter_0_0>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from .tmp.cpp:1:
In file included from ... vector:310:
In file included from ... vector:314:
In file included from ... remove.h:13:
... find_if.h:25:9: error: no matching function for call to object of type '__lambda_12_26'
25 | if (__pred(*__first))
Expand Down
23 changes: 22 additions & 1 deletion tests/LambdaHandlerVLA2Test.cerr
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
.tmp.cpp:3:15: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
3 | char buffer[n];
| ^
.tmp.cpp:3:15: note: function parameter 'n' with unknown value cannot be used in a constant expression
.tmp.cpp:1:15: note: declared here
1 | void Test(int n)
| ^
.tmp.cpp:14:5: warning: declaration does not declare anything [-Wmissing-declarations]
14 | unsigned long;
| ^~~~~~~~~~~~~
Expand All @@ -7,6 +14,13 @@
.tmp.cpp:1:15: note: 'n' declared here
1 | void Test(int n)
| ^
.tmp.cpp:15:20: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
15 | char (&buffer)[n];
| ^
.tmp.cpp:15:20: note: function parameter 'n' with unknown value cannot be used in a constant expression
.tmp.cpp:1:15: note: declared here
1 | void Test(int n)
| ^
.tmp.cpp:15:12: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
15 | char (&buffer)[n];
| ^
Expand All @@ -16,6 +30,13 @@
.tmp.cpp:1:15: note: 'n' declared here
1 | void Test(int n)
| ^
.tmp.cpp:18:34: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
18 | __lambda_6_5(char (&_buffer)[n])
| ^
.tmp.cpp:18:34: note: function parameter 'n' with unknown value cannot be used in a constant expression
.tmp.cpp:1:15: note: declared here
1 | void Test(int n)
| ^
.tmp.cpp:22:5: error: no matching constructor for initialization of 'class __lambda_6_5'
22 | } __lambda_6_5{buffer};
| ^ ~~~~~~~~
Expand All @@ -28,4 +49,4 @@
.tmp.cpp:18:5: note: candidate constructor not viable: no known conversion from 'char[n]' to 'char (&)[n]' for 1st argument
18 | __lambda_6_5(char (&_buffer)[n])
| ^ ~~~~~~~~~~~~~~~~~~
1 warning and 4 errors generated.
4 warnings and 4 errors generated.
4 changes: 2 additions & 2 deletions tests/MacroExpensionTest.expect
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ enum eTest
/* PASSED: static_assert(true); */

template<class T>
constexpr const T pi = T(3.14159265358979323851L);
constexpr const T pi = T(3.1415926535897931L);

template<>
constexpr const int pi<int> = int(3.14159265358979323851L);
constexpr const int pi<int> = int(3.1415926535897931L);

int i = pi<int>;
Loading
Loading