Skip to content

Commit

Permalink
Merge branch 'replace_libdparse'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladiwostok committed Dec 13, 2024
2 parents 796d212 + b4a9a14 commit d6ff24a
Show file tree
Hide file tree
Showing 83 changed files with 6,668 additions and 7,781 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ on:
push:
branches:
- master
- replace_libdparse

jobs:
main:
name: Run all tests

# Only run for the main repository - not forks
if: ${{ github.repository == 'dlang-community/D-Scanner' }}
if: ${{ github.repository == 'Dlang-UPB/D-Scanner' }}

# Run permutations of common os + host compilers
strategy:
Expand Down Expand Up @@ -87,6 +88,10 @@ jobs:
submodules: 'recursive'
fetch-depth: 0

# Uncomment to get a ssh connection inside the GH Actions runner
#- name: Setup upterm session
# uses: lhotari/action-upterm@v1

# Install the host compiler (DMD or LDC)
# Also grabs DMD for GDC to include dub + rdmd
- name: Install ${{ matrix.compiler.version }}
Expand All @@ -102,6 +107,10 @@ jobs:
sudo apt-get install gdc-12 -y
gdc-12 --version
# - name: Setup upterm session
# if: ${{ matrix.build.type == 'dub' && matrix.host == 'macos-latest'}}
# uses: lhotari/action-upterm@v1

# Compile D-Scanner and execute all tests without dub
- name: Build and test without dub
if: ${{ matrix.build.type == 'make' }}
Expand All @@ -114,7 +123,8 @@ jobs:
./build.bat
./build.bat test
else
make "-j$(nproc)" all test
NUM_PROC=$(nproc || getconf _NPROCESSORS_ONLN || 1)
make "-j$((NUM_PROC / 2))" all test
fi
# Compile D-Scanner and execute all tests using a specific dependency version
Expand All @@ -135,7 +145,7 @@ jobs:
dub build
dub test
- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4
with:
name: bin-${{matrix.build.type}}-${{matrix.build.version}}-${{ matrix.compiler.dmd }}-${{ matrix.host }}
path: bin
Expand All @@ -159,10 +169,21 @@ jobs:
"./bin/dscanner$EXE" --styleCheck -f "$FORMAT" src
- name: Integration Tests
run: ./it.sh
# run: ./it.sh
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
./it.sh Windows
else
./it.sh Unix
fi
working-directory: tests
shell: bash

- name: Run style checks
if: ${{ matrix.compiler.dmd == 'dmd' && matrix.build.type == 'make' }}
run: |
make style
# Parse phobos to check for failures / crashes / ...
- name: Checkout Phobos
uses: actions/checkout@v4
Expand All @@ -171,7 +192,7 @@ jobs:
path: phobos

- name: Apply D-Scanner to Phobos
if: ${{ matrix.build.version != 'min libdparse'}} # Older versions crash with "Invalid UTF..."
if: ${{ matrix.build.version != 'min libdparse'}} # Older versions crash with "Invalid UTF..."
working-directory: phobos
shell: bash
run: |
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# Sublime Text 2
*.sublime-workspace

# Idea stuff
.idea/

# Subversion
.svn/

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@
[submodule "DCD"]
path = DCD
url = https://github.com/dlang-community/DCD.git
[submodule "dmd"]
path = dmd
url = [email protected]:dlang/dmd.git
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,15 @@
D-Scanner is a tool for analyzing D source code

### Building and installing
First make sure that you have all the source code. Run ```git submodule update --init --recursive```

First, make sure that you have fetched the upstream: [email protected]:dlang-community/D-Scanner.git

```
git remote add upstream [email protected]:dlang-community/D-Scanner.git
git fetch upstream
```

Secondly, make sure that you have all the source code. Run ```git submodule update --init --recursive```
after cloning the project.

To build D-Scanner, run ```make``` (or the build.bat file on Windows).
Expand Down
96 changes: 91 additions & 5 deletions build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ if %githashsize% == 0 (
move /y bin\githash_.txt bin\githash.txt
)

set DFLAGS=-O -release -Jbin %MFLAGS%
set TESTFLAGS=-g -w -Jbin
set DFLAGS=-O -release -version=StdLoggerDisableWarning -version=CallbackAPI -version=DMDLIB -version=MARS -version=NoBackend -version=NoMain -Jbin -Jdmd -Jdmd\compiler\src\dmd\res %MFLAGS%
set TESTFLAGS=-g -w -version=StdLoggerDisableWarning -version=CallbackAPI -version=DMDLIB -version=MARS -version=NoBackend -version=NoMain -Jbin -Jdmd -Jdmd\compiler\src\dmd\res
set CORE=
set LIBDPARSE=
set STD=
Expand All @@ -29,6 +29,44 @@ set DSYMBOL=
set CONTAINERS=
set LIBDDOC=

set DMD_FRONTEND_DENYLIST=^
dmd\compiler\src\dmd\mars.d^
dmd\compiler\src\dmd\dmsc.d^
dmd\compiler\src\dmd\e2ir.d^
dmd\compiler\src\dmd\eh.d^
dmd\compiler\src\dmd\glue.d^
dmd\compiler\src\dmd\iasmdmd.d^
dmd\compiler\src\dmd\irstate.d^
dmd\compiler\src\dmd\lib.d^
dmd\compiler\src\dmd\libelf.d^
dmd\compiler\src\dmd\libmach.d^
dmd\compiler\src\dmd\libmscoff.d^
dmd\compiler\src\dmd\libomf.d^
dmd\compiler\src\dmd\objc_glue.d^
dmd\compiler\src\dmd\s2ir.d^
dmd\compiler\src\dmd\scanelf.d^
dmd\compiler\src\dmd\scanmach.d^
dmd\compiler\src\dmd\scanmscoff.d^
dmd\compiler\src\dmd\scanomf.d^
dmd\compiler\src\dmd\tocsym.d^
dmd\compiler\src\dmd\toctype.d^
dmd\compiler\src\dmd\tocvdebug.d^
dmd\compiler\src\dmd\toobj.d^
dmd\compiler\src\dmd\todt.d^
dmd\compiler\src\dmd\toir.d

set DMD_FRONTEND_SRC=
for %%x in (dmd\compiler\src\dmd\common\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\root\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\visitor\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\mangle\*.d) do set DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x
for %%x in (dmd\compiler\src\dmd\*.d) do (
echo "%DMD_FRONTEND_DENYLIST%" | findstr /i /c:"%%x" >nul
if errorlevel 1 (
set "DMD_FRONTEND_SRC=!DMD_FRONTEND_SRC! %%x"
)
)

for %%x in (src\dscanner\*.d) do set CORE=!CORE! %%x
for %%x in (src\dscanner\analysis\*.d) do set ANALYSIS=!ANALYSIS! %%x
for %%x in (libdparse\src\dparse\*.d) do set LIBDPARSE=!LIBDPARSE! %%x
Expand All @@ -45,14 +83,62 @@ for %%x in (containers\src\containers\internal\*.d) do set CONTAINERS=!CONTAINER
if "%1" == "test" goto test_cmd

@echo on
%DC% %MFLAGS% %CORE% %STD% %LIBDPARSE% %LIBDDOC% %ANALYSIS% %INIFILED% %DSYMBOL% %CONTAINERS% %DFLAGS% -I"libdparse\src" -I"DCD\dsymbol\src" -I"containers\src" -I"libddoc\src" -I"libddoc\common\source" -ofbin\dscanner.exe
%DC% %MFLAGS%^
%CORE%^
%STD%^
%LIBDPARSE%^
%LIBDDOC%^
%ANALYSIS%^
%INIFILED%^
%DSYMBOL%^
%CONTAINERS%^
%DMD_FRONTEND_SRC%^
%DFLAGS%^
-Ilibdparse\src^
-IDCD\dsymbol\src^
-Icontainers\src^
-Ilibddoc\src^
-Ilibddoc\common\source^
-Idmd\compiler\src^
-ofbin\dscanner.exe
goto eof

:test_cmd
@echo on
set TESTNAME="bin\dscanner-unittest"
%DC% %MFLAGS% %STD% %LIBDPARSE% %LIBDDOC% %INIFILED% %DSYMBOL% %CONTAINERS% -I"libdparse\src" -I"DCD\dsymbol\src" -I"containers\src" -I"libddoc\src" -lib %TESTFLAGS% -of%TESTNAME%.lib
if exist %TESTNAME%.lib %DC% %MFLAGS% %CORE% %ANALYSIS% %TESTNAME%.lib -I"src" -I"inifiled\source" -I"libdparse\src" -I"DCD\dsymbol\src" -I"containers\src" -I"libddoc\src" -I"libddoc\common\source" -unittest %TESTFLAGS% -of%TESTNAME%.exe
%DC% %MFLAGS% ^
%STD%^
%LIBDPARSE%^
%LIBDDOC%^
%INIFILED%^
%DSYMBOL%^
%CONTAINERS%^
%DMD_FRONTEND_SRC%^
-I"libdparse\src"^
-I"DCD\dsymbol\src"^
-I"containers\src"^
-I"libddoc\src"^
-I"dmd\compiler\src"^
-I"dmd\compiler\src\dmd\res"^
%TESTFLAGS%^
-lib^
-of%TESTNAME%.lib
if exist %TESTNAME%.lib %DC% %MFLAGS%^
%CORE%^
%ANALYSIS%^
%TESTNAME%.lib^
-I"src"^
-I"inifiled\source"^
-I"libdparse\src"^
-I"DCD\dsymbol\src"^
-I"containers\src"^
-I"libddoc\src"^
-I"libddoc\common\source"^
-I"dmd\compiler\src"^
-I"dmd\compiler\src\dmd\res"^
-unittest^
%TESTFLAGS%^
-of%TESTNAME%.exe
if exist %TESTNAME%.exe %TESTNAME%.exe

if exist %TESTNAME%.obj del %TESTNAME%.obj
Expand Down
1 change: 1 addition & 0 deletions changelog/dscanner.assert-without-message.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid checking `enforce` calls as it is phobos specific.
3 changes: 3 additions & 0 deletions changelog/dscanner.comma-expression.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Remove the check for comma expression check
e.g. (int a = 3, a + 7)
This check is no longer necessary since comma expression have been removed from the D language.
2 changes: 2 additions & 0 deletions changelog/dscanner.duplicate-attribute-check.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove the check for duplicate attributes (@property, @safe, @trusted, @system, pure, nothrow).
This check is no longer necessary since having duplicated attributes is now a compiler error.
1 change: 1 addition & 0 deletions changelog/dscanner.if-statements.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove IfStatementCheck, as it has been disabled in 2015 due to false positives and untouched ever since then.
19 changes: 19 additions & 0 deletions changelog/dscanner.struct-ctor-check.dd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Remove the check regarding structs with no arguments constructors.

The check is implemented in constructors.d and it warns against the usage
of both constructors with all parameters with default values and constructors
without any arguments, as this might be confusing. This scenario, for structs,
is no longer D valid code and that's why it is being deprecated.

Let's consider the following code:

---
struct Dog
{
this() {}
this(string name = "doggie") {} // [warn]: This struct constructor can never be called with its default argument.
}
---

D-Scanner would throw and error for this particular struct, but this code
does not compile anymore hence this check is not needed anymore/
1 change: 1 addition & 0 deletions dmd
Submodule dmd added at 4a9088
6 changes: 5 additions & 1 deletion dub.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
"dcd:dsymbol": ">=0.16.0-beta.2 <0.17.0",
"inifiled": "~>1.3.1",
"emsi_containers": "~>0.9.0",
"libddoc": "~>0.8.0"
"libddoc": "~>0.8.0",
"dmd": {
"repository": "git+https://github.com/dlang/dmd.git",
"version": "4a90885ef8e0fc29334da91a4318f9ab52af9f80"
}
},
"targetPath" : "bin",
"stringImportPaths" : [
Expand Down
1 change: 1 addition & 0 deletions dub.selections.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"fileVersion": 1,
"versions": {
"dcd": "0.16.0-beta.2",
"dmd": "~master",
"dsymbol": "0.13.0",
"emsi_containers": "0.9.0",
"inifiled": "1.3.3",
Expand Down
Loading

0 comments on commit d6ff24a

Please sign in to comment.