diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 31e54535512..fff4b475383 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4255,6 +4255,10 @@ void SymbolDatabase::printXml(std::ostream &out) const outs += id_string(overriddenFunction); outs += "\""; } + if (function->isAttributeConst()) + outs += " isAttributeConst=\"true\""; + if (function->isAttributePure()) + outs += " isAttributePure=\"true\""; if (function->argCount() == 0U) outs += "/>\n"; else { diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 0c73f301820..10276b3dc72 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -530,6 +530,9 @@ class TestSymbolDatabase : public TestFixture { TEST_CASE(throwFunction1); TEST_CASE(throwFunction2); + TEST_CASE(constAttributeFunction); + TEST_CASE(pureAttributeFunction); + TEST_CASE(nothrowAttributeFunction); TEST_CASE(nothrowDeclspecFunction); @@ -8395,6 +8398,26 @@ class TestSymbolDatabase : public TestFixture { CLASS_FUNC_THROW(func12, fred); } + void constAttributeFunction() { + GET_SYMBOL_DB("void func(void) __attribute__((const));"); + ASSERT_EQUALS("", errout_str()); + ASSERT_EQUALS(true, db != nullptr); // not null + + const Function* func = findFunctionByName("func", &db->scopeList.front()); + ASSERT_EQUALS(true, func != nullptr); + ASSERT_EQUALS(true, func->isAttributeConst()); + } + + void pureAttributeFunction() { + GET_SYMBOL_DB("void func(void) __attribute__((pure));"); + ASSERT_EQUALS("", errout_str()); + ASSERT_EQUALS(true, db != nullptr); // not null + + const Function* func = findFunctionByName("func", &db->scopeList.front()); + ASSERT_EQUALS(true, func != nullptr); + ASSERT_EQUALS(true, func->isAttributePure()); + } + void nothrowAttributeFunction() { GET_SYMBOL_DB("void func() __attribute__((nothrow));\n" "void func() { }");