Skip to content

Analyze with --file flag runs for multiple files #4664

@furtib

Description

@furtib

Describe the bug
On a project with 2 files with names, such that one file's name is a prefix to the other file's name (e.g, simple.c and simple.cc), CodeChecker analyze --file=simple.c will analyze simple.cc too, not just simple.c

CodeChecker version
6.26.1

To Reproduce

  1. Run the following script:
mkdir test_file_tag
cd test_file_tag

echo "int foo() { return 0/0; }" > simple.c
echo "int bar() { return 0/0; }" > simple.cc

echo "cmake_minimum_required(VERSION 3.10)" > CMakeLists.txt
echo "project(SimpleProject C CXX)" >> CMakeLists.txt
echo "add_executable(simple_app simple.c simple.cc)" >> CMakeLists.txt

mkdir build
cd build
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..
cd ..
CodeChecker analyze --analyzers clangsa clang-tidy --output=data --file=simple.c build/compile_commands.json
  1. See that CodeChecker analyzed both simple.c and simple.cc
[INFO 2025-09-22 09:21] - Starting static analysis ...
[INFO 2025-09-22 09:21] - [1/4] clangsa analyzed simple.cc successfully.
[INFO 2025-09-22 09:21] - [1/4] clangsa analyzed simple.c successfully.
[INFO 2025-09-22 09:21] - [2/4] clang-tidy analyzed simple.cc successfully.
[INFO 2025-09-22 09:21] - [3/4] clang-tidy analyzed simple.c successfully.

Expected behaviour
I expected that only simple.c would be analyzed

**Desktop

  • OS: Linux - Ubuntu (ELX) 24.04
  • Browser: Firefox (143.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    analyzer 📈Related to the analyze commands (analysis driver)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions