Skip to content

Commit 098caec

Browse files
committed
Define the LLVM symbol on LLVM-based toolchains
1 parent aca1f3e commit 098caec

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Support for the `LLVM` symbol, which is defined on LLVM-based toolchains from Delphi 12 onward.
13+
1014
### Fixed
1115

1216
- Parsing errors on `.dpr` files without a top-level `begin`.

delphi-frontend/src/main/java/au/com/integradev/delphi/compiler/PredefinedConditionals.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public final class PredefinedConditionals {
3030
private static final CompilerVersion VERSION_2009 = CompilerVersion.fromVersionNumber("20.0");
3131
private static final CompilerVersion VERSION_TOKYO = CompilerVersion.fromVersionNumber("32.0");
3232
private static final CompilerVersion VERSION_SYDNEY = CompilerVersion.fromVersionNumber("34.0");
33+
private static final CompilerVersion VERSION_ATHENS = CompilerVersion.fromVersionNumber("36.0");
3334

3435
private final Toolchain toolchain;
3536
private final CompilerVersion compilerVersion;
@@ -177,7 +178,11 @@ private Set<String> getLLVMConditionalDefines() {
177178
Toolchain.DCCLINUX64);
178179

179180
if (basedOnLLVM) {
180-
return Set.of("EXTERNALLINKER");
181+
Set<String> result = Sets.newHashSet("EXTERNALLINKER");
182+
if (compilerVersion.compareTo(VERSION_ATHENS) >= 0) {
183+
result.add("LLVM");
184+
}
185+
return result;
181186
} else {
182187
return Set.of("ASSEMBLER");
183188
}

delphi-frontend/src/test/java/au/com/integradev/delphi/compiler/PredefinedConditionalsTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class PredefinedConditionalsTest {
3131
private static final CompilerVersion VERSION_SYDNEY = CompilerVersion.fromVersionNumber("34.0");
3232
private static final CompilerVersion VERSION_ALEXANDRIA =
3333
CompilerVersion.fromVersionNumber("35.0");
34+
private static final CompilerVersion VERSION_ATHENS = CompilerVersion.fromVersionNumber("36.0");
3435

3536
private static final Set<String> NEXT_GEN_FEATURES =
3637
Set.of("NEXTGEN", "AUTOREFCOUNT", "WEAKINSTREF");
@@ -368,4 +369,10 @@ void testLinuxOnlySupportsNextGenFeaturesBeforeDelphiRio() {
368369
assertThat(PredefinedConditionals.getConditionalDefines(Toolchain.DCCLINUX64, VERSION_RIO))
369370
.doesNotContainAnyElementsOf(NEXT_GEN_FEATURES);
370371
}
372+
373+
@Test
374+
void testVersionsAfterDelphiAlexandriaShouldDefineLLVM() {
375+
assertThat(PredefinedConditionals.getConditionalDefines(Toolchain.DCCAARM64, VERSION_ATHENS))
376+
.contains("LLVM");
377+
}
371378
}

0 commit comments

Comments
 (0)