Skip to content

Commit 36c6877

Browse files
committed
s [skip ci]
1 parent 90abdd1 commit 36c6877

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

cli/cmdlineparser.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,8 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
547547
}
548548
}
549549

550-
else if (std::strcmp(argv[i], "--cpp-probe") == 0) {
551-
mSettings.cppProbe = true;
550+
else if (std::strcmp(argv[i], "--cpp-header-probe") == 0) {
551+
mSettings.cppHeaderProbe = true;
552552
}
553553

554554
// Show --debug output after the first simplifications
@@ -895,7 +895,7 @@ CmdLineParser::Result CmdLineParser::parseFromArgs(int argc, const char* const a
895895
}
896896

897897
else if (std::strcmp(argv[i], "--no-cpp-probe") == 0) {
898-
mSettings.cppProbe = false;
898+
mSettings.cppHeaderProbe = false;
899899
}
900900

901901
// Write results in file

lib/cppcheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static void createDumpFile(const Settings& settings,
182182
case Standards::Language::None:
183183
{
184184
// TODO: error out on unknown language?
185-
const Standards::Language lang = Path::identify(filename, settings.cppProbe);
185+
const Standards::Language lang = Path::identify(filename, settings.cppHeaderProbe);
186186
if (lang == Standards::Language::CPP)
187187
language = " language=\"cpp\"";
188188
else if (lang == Standards::Language::C)
@@ -420,7 +420,7 @@ unsigned int CppCheck::checkClang(const std::string &path)
420420
mErrorLogger.reportOut(std::string("Checking ") + path + " ...", Color::FgGreen);
421421

422422
// TODO: this ignores the configured language
423-
const bool isCpp = Path::identify(path, mSettings.cppProbe) == Standards::Language::CPP;
423+
const bool isCpp = Path::identify(path, mSettings.cppHeaderProbe) == Standards::Language::CPP;
424424
const std::string langOpt = isCpp ? "-x c++" : "-x c";
425425
const std::string analyzerInfo = mSettings.buildDir.empty() ? std::string() : AnalyzerInformation::getAnalyzerInfoFile(mSettings.buildDir, path, emptyString);
426426
const std::string clangcmd = analyzerInfo + ".clang-cmd";

lib/preprocessor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@ static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cf
684684
dui.includes = mSettings.userIncludes; // --include
685685
// TODO: use mSettings.standards.stdValue instead
686686
// TODO: error out on unknown language?
687-
const Standards::Language lang = Path::identify(filename, mSettings.cppProbe);
687+
const Standards::Language lang = Path::identify(filename, mSettings.cppHeaderProbe);
688688
if (lang == Standards::Language::CPP) {
689689
dui.std = mSettings.standards.getCPP();
690690
splitcfg(mSettings.platform.getLimitsDefines(Standards::getCPP(dui.std)), dui.defines, "");

lib/settings.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ class CPPCHECKLIB WARN_UNUSED Settings {
167167
/** cppcheck.cfg: About text */
168168
std::string cppcheckCfgAbout;
169169

170-
/** @brief check Emacs marker to detect header files as C++ */
171-
bool cppProbe{};
170+
/** @brief check Emacs marker to detect extension-less and *.h files as C++ */
171+
bool cppHeaderProbe{};
172172

173173
/** @brief Are we running from DACA script? */
174174
bool daca{};

lib/tokenlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void TokenList::determineCppC()
9696
// only try to determine if it wasn't enforced
9797
if (mLang == Standards::Language::None) {
9898
ASSERT_LANG(!getSourceFilePath().empty());
99-
mLang = Path::identify(getSourceFilePath(), mSettings ? mSettings->cppProbe : false);
99+
mLang = Path::identify(getSourceFilePath(), mSettings ? mSettings->cppHeaderProbe : false);
100100
// TODO: cannot enable assert as this might occur for unknown extensions
101101
//ASSERT_LANG(mLang != Standards::Language::None);
102102
if (mLang == Standards::Language::None) {

releasenotes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,5 @@ Deprecations:
1616
-
1717

1818
Other:
19+
- added command-line option `--cpp-header-probe` to probe headers and extension-less files for Emacs marker (see https://trac.cppcheck.net/ticket/10692 for more details)
1920
-

test/cli/other_test.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,7 +1367,7 @@ def test_cpp_probe(tmpdir):
13671367
'class A {};'
13681368
])
13691369

1370-
args = ['-q', '--template=simple', '--cpp-probe', test_file]
1370+
args = ['-q', '--template=simple', '--cpp-header-probe', test_file]
13711371
err_lines = [
13721372
"{}:1:1: error: Code 'classA{{' is invalid C code. Use --std or --language to configure the language. [syntaxError]".format(test_file)
13731373
]
@@ -1383,7 +1383,6 @@ def test_cpp_probe_2(tmpdir):
13831383
'class A {};'
13841384
])
13851385

1386-
# TODO: the probing is performed twice
1387-
args = ['-q', '--template=simple', '--cpp-probe', test_file]
1386+
args = ['-q', '--template=simple', '--cpp-header-probe', test_file]
13881387

13891388
assert_cppcheck(args, ec_exp=0, err_exp=[], out_exp=[])

test/testcmdlineparser.cpp

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -387,10 +387,10 @@ class TestCmdlineParser : public TestFixture {
387387
TEST_CASE(checkLevelNormal);
388388
TEST_CASE(checkLevelExhaustive);
389389
TEST_CASE(checkLevelUnknown);
390-
TEST_CASE(cppProbe);
391-
TEST_CASE(cppProbe2);
392-
TEST_CASE(noCppProbe);
393-
TEST_CASE(noCppProbe2);
390+
TEST_CASE(cppHeaderProbe);
391+
TEST_CASE(cppHeaderProbe2);
392+
TEST_CASE(noCppHeaderProbe);
393+
TEST_CASE(noCppHeaderProbe2);
394394

395395
TEST_CASE(ignorepaths1);
396396
TEST_CASE(ignorepaths2);
@@ -2607,32 +2607,32 @@ class TestCmdlineParser : public TestFixture {
26072607
ASSERT_EQUALS("cppcheck: error: unknown '--check-level' value 'default'.\n", logger->str());
26082608
}
26092609

2610-
void cppProbe() {
2610+
void cppHeaderProbe() {
26112611
REDIRECT;
2612-
const char * const argv[] = {"cppcheck", "--cpp-probe", "file.cpp"};
2612+
const char * const argv[] = {"cppcheck", "--cpp-header-probe", "file.cpp"};
26132613
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parser->parseFromArgs(3, argv));
2614-
ASSERT_EQUALS(true, settings->cppProbe);
2614+
ASSERT_EQUALS(true, settings->cppHeaderProbe);
26152615
}
26162616

2617-
void cppProbe2() {
2617+
void cppHeaderProbe2() {
26182618
REDIRECT;
2619-
const char * const argv[] = {"cppcheck", "--no-cpp-probe", "--cpp-probe", "file.cpp"};
2619+
const char * const argv[] = {"cppcheck", "--no-cpp-header-probe", "--cpp-header-probe", "file.cpp"};
26202620
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parser->parseFromArgs(4, argv));
2621-
ASSERT_EQUALS(true, settings->cppProbe);
2621+
ASSERT_EQUALS(true, settings->cppHeaderProbe);
26222622
}
26232623

2624-
void noCppProbe() {
2624+
void noCppHeaderProbe() {
26252625
REDIRECT;
26262626
const char * const argv[] = {"cppcheck", "--no-cpp-probe", "file.cpp"};
26272627
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parser->parseFromArgs(3, argv));
2628-
ASSERT_EQUALS(false, settings->cppProbe);
2628+
ASSERT_EQUALS(false, settings->cppHeaderProbe);
26292629
}
26302630

2631-
void noCppProbe2() {
2631+
void noCppHeaderProbe2() {
26322632
REDIRECT;
2633-
const char * const argv[] = {"cppcheck", "--cpp-probe", "--no-cpp-probe", "file.cpp"};
2633+
const char * const argv[] = {"cppcheck", "--cpp-header-probe", "--no-cpp-probe", "file.cpp"};
26342634
ASSERT_EQUALS_ENUM(CmdLineParser::Result::Success, parser->parseFromArgs(4, argv));
2635-
ASSERT_EQUALS(false, settings->cppProbe);
2635+
ASSERT_EQUALS(false, settings->cppHeaderProbe);
26362636
}
26372637

26382638
void ignorepaths1() {

0 commit comments

Comments
 (0)