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
7 changes: 7 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6339,10 +6339,16 @@ void Tokenizer::simplifyHeadersAndUnusedTemplates()
}

const std::set<std::string> functionStart{"static", "const", "unsigned", "signed", "void", "bool", "char", "short", "int", "long", "float", "*"};
bool goBack = false;

for (Token *tok = list.front(); tok; tok = tok->next()) {
const bool isIncluded = (tok->fileIndex() != 0);

if (goBack) {
tok = tok->previous();
}
goBack = false;

// Remove executable code
if (isIncluded && !mSettings.checkHeaders && tok->str() == "{") {
// TODO: We probably need to keep the executable code if this function is called from the source file.
Expand Down Expand Up @@ -6408,6 +6414,7 @@ void Tokenizer::simplifyHeadersAndUnusedTemplates()
const Token *endToken = closingBracket->linkAt(3)->linkAt(1)->next();
Token::eraseTokens(tok, endToken);
tok->deleteThis();
goBack = true;
}
}
}
Expand Down
1 change: 0 additions & 1 deletion test/cli/other_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3130,7 +3130,6 @@ class Cl2
assert stderr.splitlines() == [] # no error since the unused templates are not being checked


@pytest.mark.xfail(strict=True) # TODO: only the first unused templated function is not being checked
def test_check_unused_templates_func(tmp_path): # #13714
test_file_h = tmp_path / 'test.h'
with open(test_file_h, 'wt') as f:
Expand Down