CMakePM: Remove comment line lexer addition

This brings the lexer back to vanilla CMake version.

The comment arguments were not needed in the implementation of
source file addition / rename / removal operations.

Change-Id: If28b738b9ce93511b109fe09dcd03f42ee07a431
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Cristian Adam
2023-05-23 14:55:52 +02:00
parent b90600e674
commit 2f04f08611
6 changed files with 17 additions and 42 deletions

View File

@@ -75,8 +75,7 @@ bool cmListFileParser::Parse()
if (token->type == cmListFileLexer_Token_Space) {
} else if (token->type == cmListFileLexer_Token_Newline) {
haveNewline = true;
} else if (token->type == cmListFileLexer_Token_CommentBracket
|| token->type == cmListFileLexer_Token_CommentLine) {
} else if (token->type == cmListFileLexer_Token_CommentBracket) {
haveNewline = false;
} else if (token->type == cmListFileLexer_Token_Identifier) {
if (haveNewline) {
@@ -187,11 +186,6 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
return false;
}
this->Separation = SeparationWarning;
} else if (token->type == cmListFileLexer_Token_CommentLine) {
if (!this->AddArgument(token, cmListFileArgument::Comment)) {
return false;
}
this->Separation = SeparationWarning;
} else if (token->type == cmListFileLexer_Token_ArgumentBracket) {
if (!this->AddArgument(token, cmListFileArgument::Bracket)) {
return false;

View File

@@ -22,8 +22,7 @@ struct cmListFileArgument
{
Unquoted,
Quoted,
Bracket,
Comment
Bracket
};
cmListFileArgument() = default;
cmListFileArgument(std::string v, Delimiter d, long line, long column)

View File

@@ -755,7 +755,7 @@ This file must be translated to C and modified to build everywhere.
Run flex >= 2.6 like this:
flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.c cmListFileLexer.in.l
flex --nounistd -DFLEXINT_H --noline -ocmListFileLexer.cxx cmListFileLexer.in.l
Modify cmListFileLexer.c:
- remove trailing whitespace: sed -i 's/\s*$//' cmListFileLexer.c
@@ -1172,10 +1172,7 @@ YY_RULE_SETUP
case 4:
YY_RULE_SETUP
{
lexer->token.type = cmListFileLexer_Token_CommentLine;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
YY_BREAK
case 5:
@@ -2596,7 +2593,7 @@ static void cmListFileLexerAppend(cmListFileLexer* lexer, const char* text,
}
/* We need to extend the buffer. */
temp = (char *) malloc(newSize);
temp = (char *)malloc(newSize);
if (lexer->token.text) {
memcpy(temp, lexer->token.text, lexer->token.length);
free(lexer->token.text);
@@ -2828,8 +2825,7 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
return "unterminated bracket";
case cmListFileLexer_Token_BadString:
return "unterminated string";
case cmListFileLexer_Token_CommentLine:
return "line comment";
}
return "unknown token";
}

View File

@@ -21,8 +21,7 @@ typedef enum cmListFileLexer_Type_e
cmListFileLexer_Token_CommentBracket,
cmListFileLexer_Token_BadCharacter,
cmListFileLexer_Token_BadBracket,
cmListFileLexer_Token_BadString,
cmListFileLexer_Token_CommentLine
cmListFileLexer_Token_BadString
} cmListFileLexer_Type;
/* NOLINTNEXTLINE(modernize-use-using) */

View File

@@ -110,10 +110,7 @@ LEGACY {MAKEVAR}|{UNQUOTED}|\"({MAKEVAR}|{UNQUOTED}|[ \t[=])*\"
}
<COMMENT>[^\0\n]* {
lexer->token.type = cmListFileLexer_Token_CommentLine;
cmListFileLexerSetToken(lexer, yytext, yyleng);
lexer->column += yyleng;
return 1;
}
\( {
@@ -541,8 +538,6 @@ const char* cmListFileLexer_GetTypeAsString(cmListFileLexer* lexer,
return "unterminated bracket";
case cmListFileLexer_Token_BadString:
return "unterminated string";
case cmListFileLexer_Token_CommentLine:
return "line comment";
}
return "unknown token";
}

View File

@@ -432,12 +432,11 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
for (const auto &func : {function, targetSourcesFunc, addQmlModuleFunc}) {
if (func == cmakeListFile.Functions.end())
continue;
auto filePathArgument
= Utils::findOrDefault(func->Arguments(),
[file_name = fileName.toStdString()](const auto &arg) {
return arg.Delim != cmListFileArgument::Comment
&& arg.Value == file_name;
});
auto filePathArgument = Utils::findOrDefault(func->Arguments(),
[file_name = fileName.toStdString()](
const auto &arg) {
return arg.Value == file_name;
});
if (!filePathArgument.Value.empty()) {
return ProjectFileArgumentPosition{filePathArgument, targetCMakeFile, fileName};
@@ -456,9 +455,7 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
const auto haveGlobbing = Utils::anyOf(func->Arguments(),
[globVariables](const auto &arg) {
return globVariables.contains(arg.Value)
&& arg.Delim
!= cmListFileArgument::Comment;
return globVariables.contains(arg.Value);
});
if (haveGlobbing) {
@@ -475,21 +472,16 @@ CMakeBuildSystem::projectFileArgumentPosition(const QString &targetName, const Q
}));
for (const auto &arg : func->Arguments()) {
if (arg.Delim == cmListFileArgument::Comment)
continue;
auto matchedFunctions = Utils::filtered(setFunctions, [arg](const auto &f) {
return arg.Value == std::string("${") + f.Arguments()[0].Value + "}";
});
for (const auto &f : matchedFunctions) {
filePathArgument
= Utils::findOrDefault(f.Arguments(),
[file_name = fileName.toStdString()](
const auto &arg) {
return arg.Delim != cmListFileArgument::Comment
&& arg.Value == file_name;
});
filePathArgument = Utils::findOrDefault(f.Arguments(),
[file_name = fileName.toStdString()](
const auto &arg) {
return arg.Value == file_name;
});
if (!filePathArgument.Value.empty()) {
return ProjectFileArgumentPosition{filePathArgument,