Skip to content

Commit

Permalink
citnames: allow pre/postfixes to cc & c++ compiler calls
Browse files Browse the repository at this point in the history
Specifically excludes `cc1` which would otherwise be matched as `cc` + postfix.
  • Loading branch information
jan-krieg authored and rizsotto committed Oct 15, 2024
1 parent 2da6d29 commit 612df90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 3 additions & 4 deletions source/citnames/source/semantic/ToolGcc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,13 @@ namespace cs::semantic {

bool ToolGcc::is_compiler_call(const fs::path& program) const {
static const auto pattern = std::regex(
// - cc
// - c++
// - cxx
// - CC
// - mcc, gcc, m++, g++, gfortran, fortran
// - cc, mcc, gcc, c++, m++, g++, gfortran, fortran
// - with prefixes like: arm-none-eabi-
// - with postfixes like: -7.0 or 6.4.0
R"(^(cc|c\+\+|cxx|CC|(([^-]*-)*([mg](cc|\+\+)|[g]?fortran)(-?\d+(\.\d+){0,2})?))$)"
// - (excluding cc1)
R"(^(cxx|CC|(([^-]*-)*(cc(?!1(?![\d\.]))|[mg]cc|[cmg]\+\+|[g]?fortran)(-?\d+(\.\d+){0,2})?))$)"
);

std::cmatch m;
Expand Down
3 changes: 3 additions & 0 deletions source/citnames/test/ToolGccTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,13 @@ namespace {

EXPECT_TRUE(sut.is_compiler_call("cc"));
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/cc"));
EXPECT_TRUE(sut.is_compiler_call("x86_64-pc-linux-gnu-cc"));
EXPECT_FALSE(sut.is_compiler_call("cc1"));
EXPECT_TRUE(sut.is_compiler_call("gcc"));
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/gcc"));
EXPECT_TRUE(sut.is_compiler_call("c++"));
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/c++"));
EXPECT_TRUE(sut.is_compiler_call("x86_64-pc-linux-gnu-c++"));
EXPECT_TRUE(sut.is_compiler_call("g++"));
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/g++"));
EXPECT_TRUE(sut.is_compiler_call("arm-none-eabi-g++"));
Expand Down

0 comments on commit 612df90

Please sign in to comment.