diff --git a/lib/checkmemoryleak.cpp b/lib/checkmemoryleak.cpp index 329c92b5b..3b5d6bae9 100644 --- a/lib/checkmemoryleak.cpp +++ b/lib/checkmemoryleak.cpp @@ -2556,8 +2556,6 @@ void CheckMemoryLeakInClass::checkPublicFunctions(const Scope *scope, const Toke return; const unsigned int varid = classtok->varId(); - if (varid == 0) - return; // Parse public functions.. // If they allocate member variables, they should also deallocate diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ce21e242d..c392e52d6 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -2108,6 +2108,9 @@ bool Tokenizer::tokenize(std::istream &code, // remove Borland stuff.. simplifyBorland(); + // remove wxWidgets stuff.. + simplifyWxWidgets(); + // Remove "volatile", "inline", "register", and "restrict" simplifyKeyword(); @@ -8994,6 +8997,32 @@ void Tokenizer::simplifyQtSignalsSlots() } } +void Tokenizer::simplifyWxWidgets() +{ + std::set macros; + + macros.insert("WXDLLIMPEXP_FWD_BASE"); + macros.insert("WXDLLIMPEXP_FWD_NET"); + macros.insert("WXDLLIMPEXP_FWD_CORE"); + macros.insert("WXDLLIMPEXP_FWD_ADV"); + macros.insert("WXDLLIMPEXP_FWD_QA"); + macros.insert("WXDLLIMPEXP_FWD_HTML"); + macros.insert("WXDLLIMPEXP_FWD_GL"); + macros.insert("WXDLLIMPEXP_FWD_XML"); + macros.insert("WXDLLIMPEXP_FWD_XRC"); + macros.insert("WXDLLIMPEXP_FWD_AUI"); + macros.insert("WXDLLIMPEXP_FWD_PROPGRID"); + macros.insert("WXDLLIMPEXP_FWD_RICHTEXT"); + macros.insert("WXDLLIMPEXP_FWD_MEDIA"); + macros.insert("WXDLLIMPEXP_FWD_STC"); + macros.insert("WXDLLIMPEXP_FWD_WEBVIEW"); + + for (Token *tok = _tokens; tok; tok = tok->next()) { + if (tok->next() && macros.find(tok->next()->str()) != macros.end()) + tok->deleteNext(); + } +} + const SymbolDatabase *Tokenizer::getSymbolDatabase() const { if (!_symbolDatabase) diff --git a/lib/tokenize.h b/lib/tokenize.h index 83c39b52b..64fc7784d 100644 --- a/lib/tokenize.h +++ b/lib/tokenize.h @@ -671,6 +671,11 @@ public: */ void simplifyQtSignalsSlots(); + /** + * Remove wxWidgets macros + */ + void simplifyWxWidgets(); + /** * Collapse operator name tokens into single token * operator = => operator= diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index cda8111ae..558fc8c02 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -355,6 +355,8 @@ private: TEST_CASE(Qt); + TEST_CASE(wxWidgets); // ticket #3527 + TEST_CASE(sql); TEST_CASE(simplifyLogicalOperators); @@ -5903,6 +5905,25 @@ private: ASSERT_EQUALS("", errout.str()); } + // ticket #3527 + void wxWidgets() { + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_BASE wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_NET wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_CORE wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_ADV wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_QA wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_HTML wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_GL wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_XML wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_XRC wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_AUI wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_PROPGRID wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_RICHTEXT wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_MEDIA wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_STC wxCheckBox;")); + ASSERT_EQUALS("class wxCheckBox ;", tokenizeAndStringify("class WXDLLIMPEXP_FWD_WEBVIEW wxCheckBox;")); + } + void sql() { // Oracle PRO*C extensions for inline SQL. Just replace the SQL with "asm()" to fix wrong error messages // ticket: #1959