Skip to content

Commit

Permalink
fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanEngelen committed Jul 5, 2023
1 parent c1e895e commit 89f43fd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
20 changes: 20 additions & 0 deletions tests/plugins/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import lit.formats
import lit.util
import os
import sys
import platform
import string
import re
import subprocess
import glob

if (config.plugins_supported):
config.available_features.add('Plugins')
Expand All @@ -17,4 +23,18 @@ if (config.plugins_supported):
plugin_compile_flags.append('-L-Wl,-undefined,dynamic_lookup')
config.substitutions.append( ('%plugin_compile_flags', " ".join(plugin_compile_flags) ) )

# Set feature that tells us that the just-built LDC is ABI compatible with the host D compiler
# Be conservative: only set it when host LDC and just-built LDC have identical versions
command = [config.ldc2_bin, '--version']
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
text1 = p.stdout.readline() # Ex.: "LDC - the LLVM D compiler (1.33.0-git-716f627)"
text2 = p.stdout.readline() # Ex.: " based on DMD v2.103.1 and LLVM 14.0.0"
text3 = p.stdout.readline() # Ex.: " built with LDC - the LLVM D compiler (1.33.0-beta2)"
m = re.compile('LDC - the LLVM D compiler \((.*)\)').match(text1)
ldc_version = m.group(1)
m3 = re.compile(' built with.* \((.*)\)').match(text3)
host_version = m3.group(1)
if (ldc_version == host_version):
config.available_features.add('ABI_compatible_with_host_D')


11 changes: 9 additions & 2 deletions tests/plugins/visitor_example.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// REQUIRES: Plugins
// REQUIRES: ABI_compatible_with_host_D

// RUN: split-file %s %t --leading-lines
// RUN: %ldc -g %t/plugin.d %plugin_compile_flags -of=%t/plugin%so
Expand All @@ -16,8 +17,14 @@ extern(C++) class MyVisitor : SemanticTimeTransitiveVisitor {
alias visit = SemanticTimeTransitiveVisitor.visit;

override void visit(VarDeclaration vd) {
if (vd.aliasTuple)
warning(vd.loc, "It works!");
if (vd.aliasTuple) {
vd.aliasTuple.foreachVar((s) {
auto vardecl = s.isVarDeclaration();
if (vardecl && vardecl.type.needsDestruction()) {
warning(vardecl.loc, "It works!");
}
});
}
}
}

Expand Down

0 comments on commit 89f43fd

Please sign in to comment.