Skip to content

Commit

Permalink
fixed #13128 - apply enforced language with --clang (danmar#6825)
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave authored Sep 25, 2024
1 parent 3f8244d commit 3309f02
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/cppcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,11 @@ unsigned int CppCheck::checkClang(const FileWithDetails &file)
mErrorLogger.reportOut(std::string("Checking ") + file.spath() + " ...", Color::FgGreen);

// TODO: get language from FileWithDetails object
// TODO: this ignores the configured language
const bool isCpp = Path::identify(file.spath(), mSettings.cppHeaderProbe) == Standards::Language::CPP;
bool isCpp;
if (mSettings.enforcedLang != Standards::None)
isCpp = (mSettings.enforcedLang == Standards::CPP);
else
isCpp = Path::identify(file.spath(), mSettings.cppHeaderProbe) == Standards::Language::CPP;
const std::string langOpt = isCpp ? "-x c++" : "-x c";
const std::string analyzerInfo = mSettings.buildDir.empty() ? std::string() : AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, file.spath(), emptyString);
const std::string clangcmd = analyzerInfo + ".clang-cmd";
Expand Down
2 changes: 0 additions & 2 deletions test/cli/clang-import_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,10 @@ def test_cmd_def(tmp_path):
__test_cmd(tmp_path, 'test.cpp',['-DDEF'], '-x c++ -DDEF=1')


@pytest.mark.xfail(strict=True)
def test_cmd_enforce_c(tmp_path): # #13128
__test_cmd(tmp_path, 'test.cpp',['-x', 'c'], '-x c')


@pytest.mark.xfail(strict=True)
def test_cmd_enforce_cpp(tmp_path): # #13128
__test_cmd(tmp_path, 'test.c',['-x', 'c++'], '-x c++')

Expand Down

0 comments on commit 3309f02

Please sign in to comment.