Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ static bool parseInlineSuppressionCommentToken(const simplecpp::Token *tok, std:
}

static std::string getRelativeFilename(const simplecpp::Token* tok, const Settings &settings) {
if (!tok)
return "";
std::string relativeFilename(tok->location.file());
if (settings.relativePaths) {
for (const std::string & basePath : settings.basePaths) {
Expand Down Expand Up @@ -1079,6 +1081,8 @@ void Preprocessor::addRemarkComments(const simplecpp::TokenList &tokens, std::ve
remarkedToken = prev;
break;
}
if (!remarkedToken)
continue;

// Relative filename
const std::string relativeFilename = getRelativeFilename(remarkedToken, mSettings);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//REMARK /
7 changes: 7 additions & 0 deletions test/testpreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class TestPreprocessor : public TestFixture {
TEST_CASE(remarkComment1);
TEST_CASE(remarkComment2);
TEST_CASE(remarkComment3);
TEST_CASE(remarkComment4);

// Using -D to predefine symbols
TEST_CASE(predefine1);
Expand Down Expand Up @@ -1940,6 +1941,12 @@ class TestPreprocessor : public TestFixture {
ASSERT_EQUALS("assignment with 1 ", remarkComments[0].str);
}

void remarkComment4() {
const char code[] = "//REMARK /";
const auto remarkComments = PreprocessorHelper::getRemarkComments(code, *this);
ASSERT_EQUALS(0, remarkComments.size());
}

void predefine1() {
const std::string src("#if defined X || Y\n"
"Fred & Wilma\n"
Expand Down