Skip to content

Commit a7835d0

Browse files
authored
Fix #15176: Export isAttributeUsed to dumpfile (#8995)
1 parent 153c01d commit a7835d0

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎lib/tokenize.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6359,6 +6359,8 @@ void Tokenizer::dump(std::ostream &out) const
63596359
outs += " isAttributeMaybeUnused=\"true\"";
63606360
if (tok->isAttributeUnused())
63616361
outs += " isAttributeUnused=\"true\"";
6362+
if (tok->isAttributeUsed())
6363+
outs += " isAttributeUsed=\"true\"";
63626364
if (tok->isAttributeFallthrough())
63636365
outs += " isAttributeFallthrough=\"true\"";
63646366
if (tok->isInitBracket())

‎test/testtokenize.cpp‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,7 @@ class TestTokenizer : public TestFixture {
537537
TEST_CASE(simplifyPlatformTypes);
538538

539539
TEST_CASE(dumpFallthrough);
540+
TEST_CASE(dumpAttributeUsed);
540541

541542
TEST_CASE(simplifyRedundantParentheses);
542543

@@ -9389,6 +9390,16 @@ class TestTokenizer : public TestFixture {
93899390
ASSERT(dump.find(" isAttributeFallthrough=\"true\"") != std::string::npos);
93909391
}
93919392

9393+
void dumpAttributeUsed() {
9394+
const char code[] = "static int x __attribute__((used));\n";
9395+
SimpleTokenizer tokenizer(settingsDefault, *this, false);
9396+
ASSERT(tokenizer.tokenize(code));
9397+
std::ostringstream ostr;
9398+
tokenizer.dump(ostr);
9399+
const std::string dump = ostr.str();
9400+
ASSERT(dump.find(" isAttributeUsed=\"true\"") != std::string::npos);
9401+
}
9402+
93929403
void simplifyRedundantParentheses() {
93939404
const char code[] = "int f(struct S s) {\n"
93949405
" return g(1, &(int){ s.i });\n"

0 commit comments

Comments
 (0)