Skip to content
Closed
Show file tree
Hide file tree
Changes from 139 commits
Commits
Show all changes
310 commits
Select commit Hold shift + click to select a range
9e58df1
Upload ignore file
J2000A Jun 23, 2023
2a91ac9
Switch thread command
J2000A Jun 23, 2023
d52b985
Update gitignore for witness files
J2000A Jun 23, 2023
474a10f
Add ignore files for regression tests
J2000A Jun 23, 2023
da3d776
Update ignore success files
Jun 23, 2023
68be73f
Fix
J2000A Jun 23, 2023
f276f08
Update gitignore
J2000A Jun 23, 2023
387cbfe
Remove failed tests
J2000A Jun 23, 2023
f4ae4ff
Always print skip info
J2000A Jun 23, 2023
211e251
Always print skip info
J2000A Jun 23, 2023
e50756b
Remove cil creation before check creation
Jun 24, 2023
50ededb
Add test No more input
J2000A Jun 24, 2023
b42fd92
Fix params
J2000A Jun 24, 2023
91e78e7
Change printing style
Jun 24, 2023
8b9be13
Merge remote-tracking branch 'refs/remotes/origin/master'
Jun 24, 2023
6d11ed0
Update successful runs
J2000A Jun 26, 2023
0a1c92b
Change coloring
J2000A Jun 26, 2023
4685c87
Add possibility to add multiple ignore files
J2000A Jun 26, 2023
2356070
Check if annotations not part of word
J2000A Jun 26, 2023
bdc613f
Fix
J2000A Jun 26, 2023
667b077
print seperator over whole line
J2000A Jun 26, 2023
72e57b6
Update batch ignore files
J2000A Jun 26, 2023
581fba4
Write check result in place
J2000A Jun 26, 2023
0f6a796
Change color
J2000A Jun 26, 2023
1596611
Print in place
J2000A Jun 26, 2023
d3638aa
Remve superflous print
J2000A Jun 26, 2023
58217ee
Add extra int case
J2000A Jun 26, 2023
50c80c1
Add new param replacements
J2000A Jun 26, 2023
7940d27
Update batch ignore files
J2000A Jun 26, 2023
f9d8131
Add try catch
J2000A Jun 26, 2023
b76269b
Add including of files
J2000A Jun 26, 2023
25345ab
Fix
J2000A Jun 26, 2023
594efd6
Fix comment
Jun 26, 2023
e7ea5e3
Update regression parsing files
Jun 26, 2023
0dd7327
Update regression success files
Jun 26, 2023
2103fed
Fix
Jun 27, 2023
8cee9ea
Remove deadcode checks
Jun 27, 2023
7bd0cc5
Add nowarn annotation
Jun 27, 2023
1cf0c18
Do not rename goblint assert and assert
Jun 27, 2023
f4b75cd
Update documentation
Jun 27, 2023
12cbbfb
Update documentation
Jun 27, 2023
6b19431
move onetime use functions from util
Jun 27, 2023
c35ff74
Fix
Jun 28, 2023
09856ce
Do not keep checks in comments
Jun 28, 2023
217ef06
Remove all unwanted generated checks
Jun 28, 2023
bd71997
Update printing
Jun 28, 2023
3181000
Update prompt and move models to util
Jun 28, 2023
c61a5bc
fix git problems
Jun 28, 2023
acf05ed
Add figlet to sample files
Jun 28, 2023
4b0a287
Remove repos for git running
Jun 28, 2023
c1243b4
Fix
Jun 28, 2023
fd7708d
Print removed options in grey
Jun 28, 2023
d43e17f
accept non compiling of add annotations
Jun 29, 2023
6bbd0ec
Change printing
Jun 29, 2023
204ec2c
Change color
Jun 29, 2023
97e9790
Update exceptions txt
Jun 29, 2023
526cb2f
Fix
Jun 29, 2023
c1cdbd0
Update test results
Jun 29, 2023
03f5487
Refine parameters
J2000A Jun 29, 2023
064c428
Change naming of tests
J2000A Jun 29, 2023
659a081
Refine parameters
J2000A Jun 29, 2023
301d81d
Update test results
J2000A Jun 29, 2023
982652e
Allow patterns in ignore files
J2000A Jun 29, 2023
77eba2c
ignore longjump files
Jun 29, 2023
3d3dbcc
Refine parameters
J2000A Jun 29, 2023
67e634d
Merge remote-tracking branch 'refs/remotes/origin/master'
J2000A Jun 29, 2023
21a04f6
Refine parameters
J2000A Jun 29, 2023
d61733b
Rearrange params
J2000A Jun 29, 2023
bfc1faf
Remove whitespace
J2000A Jun 29, 2023
1eb1a8d
Update test results
Jun 29, 2023
aa0e6e3
Add notes to ignore files
J2000A Jun 29, 2023
ba4fadf
Check files with linter and spell check
J2000A Jun 29, 2023
27a880a
Update Results
Jun 29, 2023
424dd73
Keep mutation options also when -m was not set
J2000A Jun 29, 2023
198e4c8
Fix mutation selection on comand line
J2000A Jun 29, 2023
91eca97
Add ending .ignore for ignore-files
J2000A Jun 29, 2023
1d27d04
Add date to ignore files
J2000A Jun 29, 2023
d5794fa
Update param fixing
J2000A Jun 30, 2023
1628dfd
Update param fixing
J2000A Jun 30, 2023
3d5b8cb
Update test results
J2000A Jul 1, 2023
ddc1980
Update param fixing
J2000A Jul 1, 2023
69cc2f0
Fix check annotation
J2000A Jul 1, 2023
71db0a7
Improve traversing of json
J2000A Jul 1, 2023
6f59310
Remove unnessecary code
J2000A Jul 3, 2023
464e718
Remvoe unnecessary sample files
J2000A Jul 3, 2023
f442d17
Change behaviour of precision option
Jul 4, 2023
e4fed96
Update gitignore
Jul 4, 2023
f0689f5
Uncomment git option
Jul 4, 2023
2470133
Update param fixing
Jul 5, 2023
4fff267
Fix
J2000A Jul 5, 2023
73eb1ff
Comment reasons for ignoring
J2000A Jul 5, 2023
639f084
Categorize parsing errors
J2000A Jul 5, 2023
26f5d0b
Remove fix errors for clang tidy
J2000A Jul 5, 2023
e4162f8
Add new options to clang tidy
J2000A Jul 6, 2023
c91af7d
Add new options to clang tidy
J2000A Jul 6, 2023
5f69401
Update Clang documentation
J2000A Jul 6, 2023
5702c7c
Fix
J2000A Jul 6, 2023
b80eeac
Add missing parsing error
J2000A Jul 6, 2023
7f96cb1
Rename original to inital
J2000A Jul 6, 2023
ac7987e
Add default option
J2000A Jul 6, 2023
3f0ae7a
Update ignore files
J2000A Jul 7, 2023
aaacdab
Rename ignore files directory
J2000A Jul 7, 2023
d60901b
Investigate O3
J2000A Jul 7, 2023
a08d355
Fix printing of changes params
J2000A Jul 7, 2023
13af342
Update ignore file
J2000A Jul 7, 2023
dac1117
Do not print skip keyword
Jul 7, 2023
fc7ea59
Fix
J2000A Jul 7, 2023
288d8d1
Add mutation remove if statements
Jul 11, 2023
e10e4f1
Add mutation remove if statements to ml
Jul 11, 2023
e5b1285
Add issue to longjump exception
Jul 11, 2023
4c6f2cb
Add problem of regression test 70/03
Jul 11, 2023
5293ff9
Add annotation not imprecise
Jul 11, 2023
65f88a7
Rephrase to inital
Jul 11, 2023
4a26951
Fix test creation for precision tests
Jul 11, 2023
f753b33
Fix type
Jul 11, 2023
4cef2ef
Fix
Jul 11, 2023
951ad29
Refine explanation longjump exception
Jul 12, 2023
d86f8ac
Remove git implementation
Jul 12, 2023
d3c6bbf
Remove git implementation
Jul 12, 2023
b68e8c7
Refine meta file
Jul 12, 2023
aa2b724
Collection and printing of statistics
Jul 12, 2023
a3122d2
Add stats and meta files to documentation
J2000A Jul 13, 2023
34d8a2c
Fix default mutations
J2000A Jul 13, 2023
5c6967b
Fix printing
J2000A Jul 13, 2023
20ac363
Add stats by type
J2000A Jul 13, 2023
37419b8
Fix
J2000A Jul 13, 2023
25a8d4b
Fix
J2000A Jul 13, 2023
30b7e5f
Fix
J2000A Jul 14, 2023
0294596
Add stats print to readme
J2000A Jul 14, 2023
da9c528
Add new stats
J2000A Jul 14, 2023
9c70c12
Refine Printning
J2000A Jul 14, 2023
8e6fb2e
Store stats with timestamp in out
J2000A Jul 14, 2023
73c5b1e
Rename mutations to clang
J2000A Jul 14, 2023
f2a2dae
change ml to ai
J2000A Jul 14, 2023
76d7ee1
Rename mutation to clang and operator
J2000A Jul 14, 2023
720baff
Rename mutation to clang and operator
J2000A Jul 14, 2023
dfc10a7
Fix
J2000A Jul 14, 2023
434d21c
More printing
J2000A Jul 14, 2023
fbc8f74
Fix
J2000A Jul 14, 2023
914b826
Add performance measurements
J2000A Jul 15, 2023
fcd620c
Add min performance
J2000A Jul 15, 2023
99303fe
Update readme for statistics
Jul 15, 2023
bf87319
Pass index in function
J2000A Jul 17, 2023
a79fd76
Merge remote-tracking branch 'refs/remotes/origin/master'
J2000A Jul 17, 2023
c118876
Add notes for new mutator
J2000A Jul 17, 2023
6d05318
Add notes for new mutator
J2000A Jul 17, 2023
3048e1c
Remove unneeded module
J2000A Jul 17, 2023
896d410
Simplify
J2000A Jul 17, 2023
5596240
Check for ruby and curl
J2000A Jul 17, 2023
cb1c49f
Rename stats
J2000A Jul 17, 2023
6dbbdce
Rename stats
J2000A Jul 17, 2023
ec3e46b
Add token statistics and refine exception handling
J2000A Jul 17, 2023
7e4f2c1
Store command in meta file
J2000A Jul 17, 2023
fa1f895
update prompt
J2000A Jul 18, 2023
f645b65
Add clang querry reference
J2000A Jul 18, 2023
14cc26c
Fix RIS range
J2000A Jul 18, 2023
6620518
change processor count
J2000A Jul 18, 2023
d458632
Add tutorial for creating clang tidy checks
J2000A Jul 18, 2023
c6e568f
Add mutation generator to readme
J2000A Jul 18, 2023
b503a27
Store meta data only once
J2000A Jul 19, 2023
d77037b
Collect total execution time for batch processing
J2000A Jul 19, 2023
78af138
Rename inital to input
J2000A Jul 20, 2023
213e55c
Wrap in try catch
J2000A Jul 20, 2023
1977ff3
Wrap in try catch
J2000A Jul 20, 2023
a35679a
Error handling
J2000A Jul 20, 2023
a5d9e70
Wrap in try catch
J2000A Jul 20, 2023
92d1363
Rename compile to exception
J2000A Jul 21, 2023
2d264f8
Update Name
J2000A Jul 21, 2023
71e50eb
Rename Directory
Jul 25, 2023
9d4d181
Update Name to IATT
Jul 25, 2023
1b44e35
Update paths in readme
Jul 25, 2023
f14ce1e
Allow arbitrary options order
Jul 25, 2023
15514b7
Fix typos and add issue
Jul 25, 2023
b9ac3e3
Add issue to O3 removal
Jul 25, 2023
e79b353
Update Name to TAIA
Jul 25, 2023
7b164a8
Update logo
Jul 25, 2023
500e42f
Update dir name to TAIA
Jul 25, 2023
e9ab108
Update dir name to TAIA
Jul 25, 2023
22a8025
Check for gcc installation
J2000A Jul 26, 2023
9c04d07
Include options
J2000A Jul 26, 2023
3e225a4
Add goblint.h include when needed
J2000A Jul 26, 2023
6772c21
Add gcc for checking compiltation
J2000A Jul 27, 2023
92e5a36
Print gcc perf in stats
Jul 28, 2023
0dda7e9
Fix stats min collection
Jul 28, 2023
296a7e0
Add gcc error to batch processing
Jul 28, 2023
9c1033f
Add Evals
Jul 29, 2023
ee1b77e
Add includes to clang
Jul 29, 2023
86d460a
Fix clang rt
Jul 29, 2023
3a97ea2
Fix gcc includes
Jul 29, 2023
0d3c491
Processing file rename
Jul 29, 2023
e65ba44
Fix printing
Jul 29, 2023
d34f70e
Add more info to unexpected exception
Jul 29, 2023
d511772
Remove solved ignore files
Jul 29, 2023
4bab9cb
Update ignore files with gcc check
Jul 29, 2023
f95ba3c
Fix bug
Jul 30, 2023
5bf8b34
Fix type
J2000A Jul 31, 2023
e4e3d4c
Update ignore files
J2000A Jul 31, 2023
d5a6f7e
Fix printing
J2000A Jul 31, 2023
63b5a4c
Fix naming
J2000A Jul 31, 2023
c572d83
Fix div 0
J2000A Jul 31, 2023
c95c7a0
Move params from util
J2000A Jul 31, 2023
68d24f9
Move Clang Functions from util
J2000A Jul 31, 2023
2facf8f
supply default input
J2000A Jul 31, 2023
77ac7ec
Fix printing
J2000A Jul 31, 2023
35d1a8e
Add 5min timeout
J2000A Jul 31, 2023
1dbf14a
Fix printing
J2000A Jul 31, 2023
9de1888
Fix statistics with timeout
J2000A Jul 31, 2023
b9bed90
Fix Timeout
J2000A Aug 1, 2023
2ca36fe
Fix Sigint behaviour
J2000A Aug 1, 2023
2bed693
Fix return code retriveal
J2000A Aug 1, 2023
33d5a2b
Remove debugging
J2000A Aug 1, 2023
7886e91
Disable gcc warnings
J2000A Aug 1, 2023
80b27f7
Update ignore file
J2000A Aug 1, 2023
b2111d5
Increase timeout to 10min
J2000A Aug 1, 2023
912bd7d
Change behaviour of ignore files
J2000A Aug 2, 2023
ed349b3
performance prepare program
J2000A Aug 2, 2023
07bbdee
Stats: add vars by type
J2000A Aug 2, 2023
aad7aaf
Statistics about patches
J2000A Aug 2, 2023
588f8df
Fix
J2000A Aug 2, 2023
8d122c7
Linting
J2000A Aug 2, 2023
af9174a
Fix
J2000A Aug 2, 2023
085d002
Fix
J2000A Aug 2, 2023
8a95fd2
Fix line shift
J2000A Aug 2, 2023
cfa7395
Fix typos
J2000A Aug 3, 2023
fd9809f
Fix sample file to compile with gcc
J2000A Aug 3, 2023
a4c6f7a
Update ignore file
J2000A Aug 3, 2023
8e890be
Move test with O3 option to ignore file
J2000A Aug 3, 2023
e052392
Remove unneeded processing
J2000A Aug 4, 2023
b0ae9b7
Add remaining time calculation
J2000A Aug 4, 2023
a4f7627
Removed time estimation because to imprecise
J2000A Aug 4, 2023
082e2f4
Remove stats variables
J2000A Aug 4, 2023
971c068
Collect file size
J2000A Aug 4, 2023
bf956b6
Adopt test creation and running to thesis
J2000A Aug 4, 2023
4e3af5f
Update ignore files
J2000A Aug 5, 2023
d35c228
Rename ignore file compiler
J2000A Aug 5, 2023
e3804b4
Fix typo
J2000A Aug 5, 2023
25c16bc
Add total number of tokens to statistics
J2000A Aug 5, 2023
1306c12
not applied mutations as exception
J2000A Aug 6, 2023
ff29aa5
Skip Clang exceptions for gcc
J2000A Aug 6, 2023
893d78c
Update description
J2000A Aug 6, 2023
c85c737
Fix Bug
J2000A Aug 7, 2023
a411107
Error printing to stderr
J2000A Aug 7, 2023
6ec7bd9
Remove stderr for gcc
J2000A Aug 7, 2023
5ce5633
Update readme
J2000A Aug 13, 2023
10a19a6
Remove unnecessary sample files
J2000A Aug 13, 2023
e8e8e5f
Add last update date
J2000A Aug 13, 2023
9423a33
Update comments
J2000A Aug 13, 2023
126056a
Upload Thesis
J2000A Aug 15, 2023
339ed1e
Presentation
J2000A Aug 21, 2023
65d861f
Add presentation to README.md
J2000A Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions incremental-test-generation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
temp/**
config.yaml
api-key.yaml
out/**
witness.*
finished*
transformed.c
20 changes: 20 additions & 0 deletions incremental-test-generation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Create the clang tidy checks
Read [this](clang-mutations/README.md) for creating the clang tidy checks needed to generate mutations.

# The mutations
Read [this](clang-mutations/MUTATIONS.md) to find out more about the different types of mutations.

# Sample files
In `samle-files/` you find some examples you can use as input to get started.

# Mutation Generator
Run `./RUN.sh` to start the Command Line Interface. With `./RUN.sh -h` you can see the command line options for skipping the interactive user input.

# Run on regression tests
Run `./RUN_BATCH <directory> [additional arguments...]` for running all c files in the directory. The additional arguments are passed to goblint to skip the interactive cli (Recommended: `--enable-mutations --disable-precision --enable-running --disable-create-tests --enable-cfg --goblint-config {}`). When there are arguments defined in the file by the `PARAM` keyword they are recognized and passed to the incremental tester. When running on the regression test `28-race_reach` you should add this include `--include YOUR_PATH_TO_GOBLINT/analyzer/tests/regression/28-race_reach/racemacros.h`. You can also ignore files using a `.ignore` file with all the paths seperated by a new line. It is recommended to ignore the files `--ignore sample-files/batch-ignore-files/regression-parsing-error.ignore` and `--ignore sample-files/batch-ignore-files/regression-exceptions.ignore`. Use `--no-print` to print only the status updates on input level. This results in the command:
```
./RUN_BATCH.sh YOUR_PATH_TO_GOBLINT/analyzer/tests/regression/ --no-print --ignore sample-files/batch-ignore-files/regression-parsing-error.ignore --ignore sample-files/batch-ignore-files/regression-exceptions.ignore -m -dp -er -dt -ec -c {} --include YOUR_PATH_TO_GOBLINT/analyzer/tests/regression/28-race_reach/racemacros.h
```

# Implementation
To find out more about the implementation check out the `./scripts` directory and its [readme](./scripts/README.md) file.
30 changes: 30 additions & 0 deletions incremental-test-generation/RUN.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

# Check if the script is run from the correct location
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
CURRENT_DIR=$(pwd)
if [ "$SCRIPT_DIR" != "$CURRENT_DIR" ]; then
echo "Script is NOT run from its own directory! Please change the directory to the location of the script."
exit 1
fi

# Check for python imports
modules=("argparse" "difflib" "glob" "threading" "re" "json" "os" "subprocess" "sys" "yaml" "pydriller" "ast" "random" "time" "concurrent.futures" "multiprocessing" "openai" "questionary" "pathlib" "enum" "shutil")
for module in "${modules[@]}"
do
python3 -c "import $module" &> /dev/null
if [ $? -ne 0 ]; then
echo "Python module '$module' is not installed."
exit 1
fi
done

# Check if 'git' is installed
command -v git > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "'git' is not installed."
exit 1
fi

# Run cli
python3 ./scripts/run_cli.py "$@"
201 changes: 201 additions & 0 deletions incremental-test-generation/RUN_BATCH.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
#!/bin/bash

# Check if the script is run from the correct location
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
CURRENT_DIR=$(pwd)
if [ "$SCRIPT_DIR" != "$CURRENT_DIR" ]; then
echo "Script is NOT run from its own directory! Please change the directory to the location of the script."
exit 1
fi

# Check if realpath is available
if ! command -v realpath &> /dev/null; then
echo "realpath command is not available. Please install it."
exit 1
fi

color_grey="\033[90m"
color_red="\033[31m"
color_blue='\033[34m'
color_green='\033[32m'
color_yellow="\033[33m"
color_orange="\033[38;5;208m"
color_reset="\033[0m"

no_print=false
ignore_files=()

# Check for at least one argument
if [ $# -lt 1 ]; then
printf "Usage: $0 <directory> [--no-print] [--ignore <file_path>]* [additional arguments...]\n"
printf "Please order the arguments and options as stated above"
printf "<directory>: path to a directory with the .c files for the batch\n"
printf "[--no-print]: Do not print the mutation generator output\n"
printf "[--ignore <file_path>]* : paths to files containing paths to be ignored, separated by newlines\n"
printf "[additional arguments...]: Arguments passed to Goblint to skip interactive cli.\n"
printf " -> Recommended: --enable-mutations --disable-precision --enable-running --disable-create-tests --enable-cfg --Goblint-config {}\n"
printf " or in short: -m -dp -er -dt -ec -c {}\n"
exit 1
fi

# Store directory and shift to get other arguments
dir=$1
shift

# Check if directory exists
if [ ! -d "$dir" ]; then
printf "Directory $dir does not exist.\n"
exit 1
fi

# Check for --no-print option
if [[ $1 == "--no-print" ]]; then
no_print=true
shift
fi

# Check for --ignore options and store ignore files in an array
while [[ $1 == "--ignore" ]]; do
ignore_files+=($2)
shift 2
done

# Normalize paths in ignore files
ignore_patterns=()
for ignore_file in "${ignore_files[@]}"; do
while IFS= read -r line; do
ignore_patterns+=("$(realpath "$line" 2>/dev/null)")
done < "$ignore_file"
done

# Find .c files in subdirectories of the specified directory
files=$(find "$dir" -type f -name "*.c" | sort)
files_length=$(find "$dir" -type f -name "*.c" | wc -l)

# Iterate over the found files
index=0
for file in $files
do
((index=index+1))

# Check if the file should be ignored
file_realpath=$(realpath "$file")
for pattern in "${ignore_patterns[@]}"; do
if [[ "$file_realpath" == $pattern ]]; then
printf "${color_grey}[BATCH][${index}/${files_length}] Ignoring file $file${color_reset}\n"
ignored_files+=("$file")
continue 2
fi
done

# Run the command with remaining arguments
printf "${color_blue}[BATCH][${index}/${files_length}] Running file $file${color_reset}"
if [ "$no_print" = true ]; then
./RUN.sh -i "$file" "$@" > /dev/null
else
printf "\n"
./RUN.sh -i "$file" "$@"
fi

# Check for different return values
case $? in
0)
printf "$\r${color_green}[BATCH][${index}/${files_length}] Test succeeded for file $file"
success_files+=("$file")
;;
100)
printf "$\r${color_orange}[BATCH][${index}/${files_length}] Test failed for file $file"
failed_files+=("$file")
;;
*)
printf "$\r${color_red}[BATCH][${index}/${files_length}] Exception during execution for file $file"
exception_files+=("$file")
;;
esac
printf "${color_reset}\n"
done

ignored_length=${#ignored_files[@]}
success_length=${#success_files[@]}
failed_length=${#failed_files[@]}
exception_length=${#exception_files[@]}
printf "\n\n${color_blue}[BATCH] Batch finished running $files_length input files${color_reset}\n\n"

# Print all ignored files
if [ ${#ignored_files[@]} -ne 0 ]; then
printf "${color_yellow}The following $ignored_length files were ignored:\n"
for file in "${ignored_files[@]}"; do
printf "$file"
if [[ $first_line == *"SKIP"* ]]; then
printf " (Contained SKIP keyword in first line)\n"
else
printf "\n"
fi
done
printf "${color_reset}\n"
fi

# Print all success files
if [ ${#success_files[@]} -ne 0 ]; then
printf "${color_green}The following $success_length files were run successfully with all tests passing:\n"
for file in "${success_files[@]}"; do
printf "$file"
# Check if the first line of the file contains "SKIP"
first_line=$(head -n 1 "$file")
if [[ $first_line == *"SKIP"* ]]; then
printf "${color_yellow} (Contained SKIP keyword in first line)${color_green}\n"
else
printf "\n"
fi
done
printf "${color_reset}\n"
fi

# Print all files for which the test failed
if [ ${#failed_files[@]} -ne 0 ]; then
printf "${color_orange}The following $failed_length files failed the tests:\n"
for file in "${failed_files[@]}"; do
printf "$file"
# Check if the first line of the file contains "SKIP"
first_line=$(head -n 1 "$file")
if [[ $first_line == *"SKIP"* ]]; then
printf "${color_yellow} (Contained SKIP keyword in first line)${color_orange}\n"
else
printf "\n"
fi
done
printf "${color_reset}\n"
fi


# Print all files for which an exception occurred during execution
if [ ${#exception_files[@]} -ne 0 ]; then
printf "${color_red}The following $exception_length files experienced an exception during execution:\n"
for file in "${exception_files[@]}"; do
printf "$file"
# Check if the first line of the file contains "SKIP"
first_line=$(head -n 1 "$file")
if [[ $first_line == *"SKIP"* ]]; then
printf "${color_yellow} (Contained SKIP keyword in first line)${color_red}\n"
else
printf "\n"
fi
done
printf "${color_reset}\n"
fi

# Print summary
printf "\n[BATCH] Summary:\n"
printf "Total number of executed files: $files_length\n"

if [ "$ignored_length" -eq 0 ]; then color=${color_grey}; else color=${color_yellow}; fi
printf "${color}Number of ignored files: $ignored_length\n"

if [ "$success_length" -eq 0 ]; then color=${color_grey}; else color=${color_green}; fi
printf "${color}Number of successfully executed files: $success_length\n"

if [ "$failed_length" -eq 0 ]; then color=${color_grey}; else color=${color_orange}; fi
printf "${color}Number of files that failed the tests: $failed_length\n"

if [ "$exception_length" -eq 0 ]; then color=${color_grey}; else color=${color_red}; fi
printf "${color}Number of files that experienced an exception during execution: $exception_length\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "ConstantReplacementCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/Lex/Lexer.h"

using namespace clang::ast_matchers;

namespace clang::tidy::readability {

void ConstantReplacementCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(integerLiteral(isExpansionInMainFile(), unless(anyOf(equals(0), equals(1)))).bind("constant-replacement"), this);
}

// Replaces all Integer Literals != 0 with 1
void ConstantReplacementCheck::check(const MatchFinder::MatchResult &Result) {
const auto *MatchedDecl = Result.Nodes.getNodeAs<IntegerLiteral>("constant-replacement");

// Get old int value
llvm::APInt value = MatchedDecl->getValue();
std::string valueAsString;
llvm::SmallString<8> buffer;
value.toString(buffer, 10, true);
valueAsString = buffer.str();
// Get locations
SourceLocation Start = MatchedDecl->getBeginLoc();
auto Range = MatchedDecl->getSourceRange();
// Check if it is a Macro
std::string MacroInfo = " ";
if (MatchedDecl->getLocation().isMacroID()) {
std::string MacroId = Lexer::getImmediateMacroName(MatchedDecl->getLocation(), *Result.SourceManager, Result.Context->getLangOpts()).str();
MacroInfo = "[MACRO][" + MacroId + "] ";
}
// Replace with 1
std::string Replacement = "1 /* [MUTATION][CR]" + MacroInfo + "Replaced Constant " + valueAsString + " */";
diag(Start, "[MUTATION][CR]" + MacroInfo + "Replaced Constant %0 with 1")
<< valueAsString
<< FixItHint::CreateReplacement(Range, Replacement);
}

} // namespace clang::tidy::readability
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONSTANTREPLACEMENTCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONSTANTREPLACEMENTCHECK_H

#include "../ClangTidyCheck.h"

namespace clang::tidy::readability {

/// Constant Replacement
class ConstantReplacementCheck : public ClangTidyCheck {
public:
ConstantReplacementCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace clang::tidy::readability

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_CONSTANTREPLACEMENTCHECK_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#include "LogicalConnectorReplacementCheck.h"
#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"

using namespace clang::ast_matchers;

namespace clang::tidy::readability {

void LogicalConnectorReplacementCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(stmt(expr(binaryOperator())).bind("logical-connector-replacement"), this);
}

// "||" <-> "&&"
void LogicalConnectorReplacementCheck::check(const MatchFinder::MatchResult &Result) {
const auto *MatchedDecl = Result.Nodes.getNodeAs<BinaryOperator>("logical-connector-replacement");

std::string Replacement;

if (MatchedDecl->getOpcode() == BO_LOr) {
// || -> &&
Replacement = "&&";
} else if (MatchedDecl->getOpcode() == BO_LAnd) {
// && -> ||
Replacement = "||";
} else {
return;
}
Replacement += " /* [MUTATION][LCR] Replaced Logical Connector */";

// Get locations
SourceLocation Start = MatchedDecl->getOperatorLoc();
SourceLocation End = MatchedDecl->getOperatorLoc().getLocWithOffset(2);
auto Range = CharSourceRange::getCharRange(Start, End);

diag(Start, "[MUTATION][LCR] Replaced Logical Connector %0")
<< MatchedDecl->getOpcodeStr()
<< FixItHint::CreateReplacement(Range, Replacement);
}

} // namespace clang::tidy::readability
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_LOGICALCONNECTORREPLACEMENTCHECK_H
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_LOGICALCONNECTORREPLACEMENTCHECK_H

#include "../ClangTidyCheck.h"

namespace clang::tidy::readability {

/// Logical Connector Replacement
class LogicalConnectorReplacementCheck : public ClangTidyCheck {
public:
LogicalConnectorReplacementCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace clang::tidy::readability

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_LOGICALCONNECTORREPLACEMENTCHECK_H
Loading