Skip to content

Commit 1e7e644

Browse files
committed
citnames: allow pre/postfixes to cc & c++ compiler calls
Specifically excludes `cc1` which would otherwise be matched as `cc` + postfix.
1 parent 4137ec3 commit 1e7e644

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

source/citnames/source/semantic/ToolGcc.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,14 +251,13 @@ namespace cs::semantic {
251251

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

264263
std::cmatch m;

source/citnames/test/ToolGccTest.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ namespace {
3434

3535
EXPECT_TRUE(sut.is_compiler_call("cc"));
3636
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/cc"));
37+
EXPECT_TRUE(sut.is_compiler_call("x86_64-pc-linux-gnu-cc"));
38+
EXPECT_FALSE(sut.is_compiler_call("cc1"));
3739
EXPECT_TRUE(sut.is_compiler_call("gcc"));
3840
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/gcc"));
3941
EXPECT_TRUE(sut.is_compiler_call("c++"));
4042
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/c++"));
43+
EXPECT_TRUE(sut.is_compiler_call("x86_64-pc-linux-gnu-c++"));
4144
EXPECT_TRUE(sut.is_compiler_call("g++"));
4245
EXPECT_TRUE(sut.is_compiler_call("/usr/bin/g++"));
4346
EXPECT_TRUE(sut.is_compiler_call("arm-none-eabi-g++"));

0 commit comments

Comments
 (0)