From af5c5d4dedecddfba202493434ba5d4db8d044a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= Date: Fri, 22 Feb 2019 12:05:21 +0100 Subject: [PATCH] Better match gcc compilers Allows for `foo-bar-gcc` & friends to match with gcc familly. Unlocks graph display with compilers others than native ones. --- lib/base-compiler.js | 5 ++--- test/base-compiler-tests.js | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/base-compiler.js b/lib/base-compiler.js index 596113a43..b4caffaba 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -610,9 +610,8 @@ class BaseCompiler { isCfgCompiler(compilerVersion) { return compilerVersion.includes("clang") || - compilerVersion.indexOf("g++") === 0 || - compilerVersion.indexOf("gcc") === 0 || - compilerVersion.indexOf("gdc") === 0; + compilerVersion.match(/^([\w-]*-)?g((\+\+)|(cc)|(dc))/g) !== null; + } processAstOutput(output) { diff --git a/test/base-compiler-tests.js b/test/base-compiler-tests.js index 159a45b9d..5ea6a5c62 100644 --- a/test/base-compiler-tests.js +++ b/test/base-compiler-tests.js @@ -64,6 +64,10 @@ describe('Basic compiler invariants', function () { compiler.isCfgCompiler("g++ (GCC-Explorer-Build) 8.0.1 20180223 (experimental)").should.equal(true); compiler.isCfgCompiler("g++ (GCC) 4.1.2").should.equal(true); + compiler.isCfgCompiler("foo-bar-g++ (GCC-Explorer-Build) 4.9.4").should.equal(true); + compiler.isCfgCompiler("foo-bar-gcc (GCC-Explorer-Build) 4.9.4").should.equal(true); + compiler.isCfgCompiler("foo-bar-gdc (GCC-Explorer-Build) 4.9.4").should.equal(true); + compiler.isCfgCompiler("fake-for-test (Based on g++)").should.equal(false); compiler.isCfgCompiler("gdc (crosstool-NG 203be35 - 20160205-2.066.1-e95a735b97) 5.2.0").should.equal(true);