Skip to content

Commit

Permalink
Resolve files passed to skip logic
Browse files Browse the repository at this point in the history
Under the hood the pathlib module is used

Also added a bunch of test cases to test the new logic.
  • Loading branch information
vodorok committed Apr 9, 2024
1 parent 37d4426 commit 533a5e2
Show file tree
Hide file tree
Showing 8 changed files with 369 additions and 28 deletions.
7 changes: 5 additions & 2 deletions analyzer/codechecker_analyzer/analysis_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import zipfile

from threading import Timer
from pathlib import Path

import multiprocess
import psutil
Expand Down Expand Up @@ -712,8 +713,10 @@ def skip_cpp(compile_actions, skip_handlers):
analyze = []
skip = []
for compile_action in compile_actions:

if skip_handlers and skip_handlers.should_skip(compile_action.source):
if skip_handlers and \
skip_handlers.should_skip(
str(Path(Path(compile_action.directory).resolve(),
compile_action.source))):
skip.append(compile_action)
else:
analyze.append(compile_action)
Expand Down
5 changes: 4 additions & 1 deletion analyzer/codechecker_analyzer/buildlog/log_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# pylint: disable=no-name-in-module
from distutils.spawn import find_executable
from enum import Enum
from pathlib import Path

import glob
import json
Expand Down Expand Up @@ -1290,7 +1291,9 @@ def parse_unique_log(compilation_database,
# Skipping of the compile commands is done differently if no
# CTU or statistics related feature was enabled.
if analysis_skip_handlers \
and analysis_skip_handlers.should_skip(entry['file']) \
and analysis_skip_handlers.should_skip(
str(Path(Path(entry["directory"]).resolve(),
entry["file"]))) \
and (not ctu_or_stats_enabled or pre_analysis_skip_handlers
and pre_analysis_skip_handlers.should_skip(
entry['file'])):
Expand Down
3 changes: 3 additions & 0 deletions analyzer/tests/functional/skip/test_files/multidir/b.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int root(){
return 1/0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"directory": ".",
"command": "/usr/bin/g++ -c b.cpp -o /dev/null",
"file": "b.cpp"
}
,
{
"directory": ".",
"command": "/usr/bin/g++ -c lib/lib.cpp -o /dev/null",
"file": "lib/lib.cpp"
}
,
{
"directory": ".",
"command": "/usr/bin/g++ -c src/a.cpp -o /dev/null",
"file": "src/a.cpp"
}
,
{
"directory": ".",
"command": "/usr/bin/g++ -c src/b.cpp -o /dev/null",
"file": "src/b.cpp"
}
]
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include "../include/lib.h"
/*
* The error in this file should only be reported in
* CTU mode, through a.cpp.
*/

int myDiv(int x)
{
Expand Down
3 changes: 3 additions & 0 deletions analyzer/tests/functional/skip/test_files/multidir/src/a.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include "../include/lib.h"

void foo() {
int* p = new int(0);
delete p;
delete p;
myDiv(0);
}

0 comments on commit 533a5e2

Please sign in to comment.