From 447bea5c187c76f3ee55e1c6b06f9fab8a6f3b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 8 Jul 2021 14:36:28 +0200 Subject: [PATCH] Preprocessor; write macrousage in dump output --- lib/preprocessor.cpp | 21 +++++++++++++++++---- lib/preprocessor.h | 2 ++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index d9259c394..a170a8f0d 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -740,6 +740,7 @@ simplecpp::TokenList Preprocessor::preprocess(const simplecpp::TokenList &tokens std::list macroUsage; simplecpp::TokenList tokens2(files); simplecpp::preprocess(tokens2, tokens1, files, mTokenLists, dui, &outputList, ¯oUsage); + mMacroUsage = macroUsage; handleErrors(outputList, throwError); @@ -944,11 +945,9 @@ void Preprocessor::getErrorMessages(ErrorLogger *errorLogger, const Settings *se void Preprocessor::dump(std::ostream &out) const { - // Create a xml directive dump. - // The idea is not that this will be readable for humans. It's a - // data dump that 3rd party tools could load and get useful info from. - out << " " << std::endl; + // Create a xml dump. + out << " " << std::endl; for (const Directive &dir : mDirectives) { out << " " << std::endl; } out << " " << std::endl; + + out << " " << std::endl; + for (const simplecpp::MacroUsage ¯oUsage: mMacroUsage) { + out << " " << std::endl; + } + out << " " << std::endl; } static const std::uint32_t crc32Table[] = { diff --git a/lib/preprocessor.h b/lib/preprocessor.h index 58c8c02d0..9b7d61301 100644 --- a/lib/preprocessor.h +++ b/lib/preprocessor.h @@ -222,6 +222,8 @@ private: /** filename for cpp/c file - useful when reporting errors */ std::string mFile0; + + std::list mMacroUsage; }; /// @}