Skip to content

Commit b9d31e9

Browse files
okunzcopybara-github
authored andcommitted
Set LLVM minimum version to 18
Also update all locations where LLVM versions are specified to use 18 at minimum and it updates the readme with information about our LLVM version strategy. PiperOrigin-RevId: 748242057 Change-Id: Ia494d88a8cedb1c42256fed063ec3bf2c8863c21
1 parent 5964399 commit b9d31e9

File tree

8 files changed

+20
-62
lines changed

8 files changed

+20
-62
lines changed

.github/workflows/ubuntu-cmake-contrib.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
include:
2525
- compiler: clang
2626
compiler-version: 11
27-
libclang-version: 11
27+
libclang-version: 18
2828
- compiler: gcc
2929
compiler-version: 10
30-
libclang-version: 11
30+
libclang-version: 18
3131
runs-on: ${{ matrix.os }}
3232
continue-on-error: ${{ matrix.ignore-errors }}
3333

.github/workflows/ubuntu-cmake.yml

+8-14
Original file line numberDiff line numberDiff line change
@@ -11,48 +11,42 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
include:
14-
# Ubuntu 22.04: Use preinstalled Clang 12.0.1, 13.0.1 and 14.0.0
14+
# Ubuntu 22.04: Use preinstalled Clang 20.0.0, 19.0.0 and 18.0.0
1515
- os: ubuntu-22.04
1616
compiler: clang
1717
compiler-version: 14
18-
libclang-version: 14
18+
libclang-version: 18
1919
ignore-errors: false
2020
- os: ubuntu-22.04
2121
compiler: clang
2222
compiler-version: 13
23-
libclang-version: 13
23+
libclang-version: 18
2424
ignore-errors: false
2525
- os: ubuntu-22.04
2626
compiler: clang
2727
compiler-version: 12
28-
libclang-version: 12
28+
libclang-version: 18
2929
ignore-errors: false
3030
# Ubuntu 22.04: Use preinstalled GCC 9.5.0, 10.4.0, 11.3.0, 12.1.0
3131
- os: ubuntu-22.04
3232
compiler: gcc
3333
compiler-version: 12
34-
libclang-version: 14
34+
libclang-version: 18
3535
ignore-errors: false
3636
- os: ubuntu-22.04
3737
compiler: gcc
3838
compiler-version: 11
39-
libclang-version: 14
39+
libclang-version: 18
4040
ignore-errors: false
4141
- os: ubuntu-22.04
4242
compiler: gcc
4343
compiler-version: 10
44-
libclang-version: 14
44+
libclang-version: 18
4545
ignore-errors: false
4646
- os: ubuntu-22.04
4747
compiler: gcc
4848
compiler-version: 9
49-
libclang-version: 14
50-
ignore-errors: false
51-
# Ubuntu 20.04
52-
- os: ubuntu-20.04
53-
compiler: gcc
54-
compiler-version: 8
55-
libclang-version: 12
49+
libclang-version: 18
5650
ignore-errors: false
5751
runs-on: ${{ matrix.os }}
5852
continue-on-error: ${{ matrix.ignore-errors }}

sandboxed_api/bazel/llvm_config.bzl

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def _locate_llvm_config_tool(repository_ctx):
7272
The path to the llvm-config tool.
7373
"""
7474
max_version = 20
75-
min_version = 10
75+
min_version = 18
7676

7777
llvm_config_tool = repository_ctx.execute(
7878
["which"] + # Prints all arguments it finds in the system PATH

sandboxed_api/tools/clang_generator/CMakeLists.txt

+6-8
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
# Minimum supported: LLVM 11.0.0
15+
# Minimum supported: LLVM 18.0.0
1616
find_package(LLVM REQUIRED)
1717
find_package(Clang REQUIRED)
18-
if(LLVM_VERSION VERSION_LESS "11.0.0")
19-
message(FATAL_ERROR "SAPI header generator needs LLVM 11 or newer")
18+
if(LLVM_VERSION VERSION_LESS "18.0.0")
19+
message(FATAL_ERROR "SAPI header generator needs LLVM 18 or newer")
2020
endif()
2121

2222
add_library(sapi_generator
@@ -55,11 +55,9 @@ list(APPEND _sapi_generator_llvm_comp
5555
BinaryFormat
5656
Demangle
5757
)
58-
if(LLVM_VERSION VERSION_GREATER_EQUAL "15.0.0")
59-
list(APPEND _sapi_generator_llvm_comp
60-
WindowsDriver # Always needed
61-
)
62-
endif()
58+
list(APPEND _sapi_generator_llvm_comp
59+
WindowsDriver # Always needed
60+
)
6361
llvm_map_components_to_libnames(_sapi_generator_llvm_libs
6462
${_sapi_generator_llvm_comp}
6563
)

sandboxed_api/tools/clang_generator/frontend_action_test_util.cc

-5
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,8 @@ absl::Status RunClangTool(
7070
}
7171
}
7272

73-
#if LLVM_VERSION_MAJOR >= 10
7473
clang::tooling::ToolInvocation invocation(command_line, std::move(action),
7574
files.get());
76-
#else
77-
clang::tooling::ToolInvocation invocation(command_line, action.get(),
78-
files.get());
79-
#endif
8075
if (!invocation.run()) {
8176
return absl::UnknownError("Tool invocation failed");
8277
}

sandboxed_api/tools/clang_generator/frontend_action_test_util.h

-7
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ class FrontendActionTest : public ::testing::Test {
7979
std::move(action));
8080
}
8181

82-
// Runs the specified frontend action. Provided for compatibility with LLVM <
83-
// 10. Takes ownership.
84-
absl::Status RunFrontendAction(absl::string_view code,
85-
clang::FrontendAction* action) {
86-
return RunFrontendAction(code, absl::WrapUnique(action));
87-
}
88-
8982
private:
9083
std::string input_file_ = "input.cc";
9184
absl::flat_hash_map<std::string, std::string> file_contents_;

sandboxed_api/tools/clang_generator/generator.h

-6
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,9 @@ class GeneratorFactory : public clang::tooling::FrontendActionFactory {
138138
: emitter_(emitter), options_(options) {}
139139

140140
private:
141-
#if LLVM_VERSION_MAJOR >= 10
142141
std::unique_ptr<clang::FrontendAction> create() override {
143142
return std::make_unique<GeneratorAction>(emitter_, options_);
144143
}
145-
#else
146-
clang::FrontendAction* create() override {
147-
return new GeneratorAction(emitter_, options_);
148-
}
149-
#endif
150144

151145
bool runInvocation(
152146
std::shared_ptr<clang::CompilerInvocation> invocation,

sandboxed_api/tools/clang_generator/types.cc

+3-19
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,11 @@
2525
#include "clang/AST/DeclCXX.h"
2626
#include "clang/AST/QualTypeNames.h"
2727
#include "clang/AST/Type.h"
28-
#include "llvm/Config/llvm-config.h"
2928
#include "llvm/Support/Casting.h"
3029

3130
namespace sapi {
3231
namespace {
3332

34-
bool IsFunctionReferenceType(clang::QualType qual) {
35-
#if LLVM_VERSION_MAJOR >= 9
36-
return qual->isFunctionReferenceType();
37-
#else
38-
const auto* ref = qual->getAs<clang::ReferenceType>();
39-
return ref && ref->getPointeeType()->isFunctionType();
40-
#endif
41-
}
42-
4333
bool IsProtoBuf(const clang::RecordDecl* decl) {
4434
const auto* cxxdecl = llvm::dyn_cast<const clang::CXXRecordDecl>(decl);
4535
if (cxxdecl == nullptr) {
@@ -96,7 +86,7 @@ void TypeCollector::CollectRelatedTypes(clang::QualType qual) {
9686
return;
9787
}
9888

99-
if (qual->isFunctionPointerType() || IsFunctionReferenceType(qual) ||
89+
if (qual->isFunctionPointerType() || qual->isFunctionReferenceType() ||
10090
qual->isMemberFunctionPointerType()) {
10191
if (const auto* function_type = qual->getPointeeOrArrayElementType()
10292
->getAs<clang::FunctionProtoType>()) {
@@ -143,7 +133,7 @@ std::string GetQualTypeName(const clang::ASTContext& context,
143133
clang::QualType unqual = qual.getLocalUnqualifiedType();
144134

145135
// This is to get to the actual name of function pointers.
146-
if (unqual->isFunctionPointerType() || IsFunctionReferenceType(unqual) ||
136+
if (unqual->isFunctionPointerType() || unqual->isFunctionReferenceType() ||
147137
unqual->isMemberFunctionPointerType()) {
148138
unqual = unqual->getPointeeType();
149139
}
@@ -219,13 +209,7 @@ namespace {
219209
// type. Keeps top-level typedef types intact.
220210
clang::QualType MaybeRemoveConst(const clang::ASTContext& context,
221211
clang::QualType qual) {
222-
if (
223-
#if LLVM_VERSION_MAJOR < 13
224-
qual->getAs<clang::TypedefType>() == nullptr
225-
#else
226-
!qual->isTypedefNameType()
227-
#endif
228-
&& IsPointerOrReference(qual)) {
212+
if (!qual->isTypedefNameType() && IsPointerOrReference(qual)) {
229213
clang::QualType pointee_qual = qual->getPointeeType();
230214
pointee_qual.removeLocalConst();
231215
qual = context.getPointerType(pointee_qual);

0 commit comments

Comments
 (0)