-
-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4430 from JohanEngelen/sema_plugin
Add support for Semantic Analysis plugins
- Loading branch information
Showing
14 changed files
with
502 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// REQUIRES: Plugins | ||
|
||
// For some reason this test fails with missing symbol linking issues (or crash) with macOS on Intel x86 (but not for all CI testers...) | ||
// UNSUPPORTED: Darwin && host_X86 | ||
|
||
// RUN: split-file %s %t --leading-lines | ||
// RUN: %buildplugin %t/plugin.d -of=%t/plugin%so --buildDir=%t/build | ||
// RUN: %ldc -wi -c -o- --plugin=%t/plugin%so %t/testcase.d 2>&1 | FileCheck %t/testcase.d | ||
|
||
//--- plugin.d | ||
import dmd.dmodule : Module; | ||
import dmd.errors; | ||
import dmd.location; | ||
|
||
extern(C) void runSemanticAnalysis(Module m) { | ||
if (m.md) { | ||
warning(m.md.loc, "It works!"); | ||
} | ||
} | ||
|
||
//--- testcase.d | ||
// CHECK: testcase.d([[@LINE+1]]): Warning: It works! | ||
module testcase; | ||
int testfunction(int i) { | ||
return i * 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
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') | ||
config.environment['LLVM_CONFIG'] = os.path.join(config.llvm_tools_dir, 'llvm-config') | ||
config.environment['LLVM_VERSION'] = str(config.llvm_version) | ||
|
||
# Set feature that tells us that the just-built LDC is ABI compatible with the host D compiler | ||
# For our tets, the required ABI compatibility seems OK since at least LDC 1.30. | ||
# If the compiler is built not by LDC but another compiler, then assume the ABI to be incompatible. | ||
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)" | ||
host_version = re.compile(' built with LDC.* \(1\.([0-9]+).*\)').match(text3) | ||
if (host_version and int(host_version.group(1)) >= 30): # 30 = LDC 1.30 | ||
config.available_features.add('ABI_compatible_with_host_D') | ||
|
||
|
Oops, something went wrong.